From 2b8a4101ae7fbf36aaf234c40fc9d7613b2e9391 Mon Sep 17 00:00:00 2001 From: ferhat elmas Date: Thu, 21 Jan 2021 16:38:42 +0100 Subject: [PATCH] Release 7.2.0 --- CHANGELOG.md | 4 ++++ dist/js/getstream.js | 26 ++++++++++++++++++++------ dist/js_min/getstream.js | 2 +- package.json | 2 +- 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 41060afe..2ba6e8a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 --- +## [7.2.0](https://github.com/GetStream/stream-js/releases/tag/v7.2.0) - 2021-01-21 + +- Add JWT support for multi action, resource and feed id [#415](https://github.com/GetStream/stream-js/pull/415) + ## [7.1.3](https://github.com/GetStream/stream-js/releases/tag/v7.1.3) - 2021-01-21 - Add a note into readme about browser detection and option to skip [#414](https://github.com/GetStream/stream-js/pull/414) diff --git a/dist/js/getstream.js b/dist/js/getstream.js index b486b713..9f2bfb99 100644 --- a/dist/js/getstream.js +++ b/dist/js/getstream.js @@ -540,30 +540,44 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + // for a claim in jwt +function joinClaimValue(items) { + var values = Array.isArray(items) ? items : [items]; + var claims = []; + + for (var i = 0; i < values.length; i += 1) { + var s = values[i].trim(); + if (s === '*') return s; + claims.push(s); + } + + return claims.join(','); +} /** * Creates the JWT token for feedId, resource and action using the apiSecret * @method JWTScopeToken * @memberof signing * @private * @param {string} apiSecret - API Secret key - * @param {string} resource - JWT payload resource - * @param {string} action - JWT payload action + * @param {string | string[]} resource - JWT payload resource + * @param {string | string[]} action - JWT payload action * @param {object} [options] - Optional additional options - * @param {string} [options.feedId] - JWT payload feed identifier + * @param {string | string[]} [options.feedId] - JWT payload feed identifier * @param {string} [options.userId] - JWT payload user identifier * @param {boolean} [options.expireTokens] - JWT noTimestamp * @return {string} JWT Token */ + function JWTScopeToken(apiSecret, resource, action) { var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; var noTimestamp = options.expireTokens ? !options.expireTokens : true; var payload = { - resource: resource, - action: action + resource: joinClaimValue(resource), + action: joinClaimValue(action) }; - if (options.feedId) payload.feed_id = options.feedId; + if (options.feedId) payload.feed_id = joinClaimValue(options.feedId); if (options.userId) payload.user_id = options.userId; return jsonwebtoken__WEBPACK_IMPORTED_MODULE_1___default.a.sign(payload, apiSecret, { algorithm: 'HS256', diff --git a/dist/js_min/getstream.js b/dist/js_min/getstream.js index a2f968ca..77139456 100644 --- a/dist/js_min/getstream.js +++ b/dist/js_min/getstream.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.stream=e():t.stream=e()}(window,function(){return r={},i.m=n=[function(t,e){t.exports=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}},function(t,e,n){t.exports=n(75)},function(t,e){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}},function(t,e,n){"use strict";n.d(e,"a",function(){return d}),n.d(e,"c",function(){return p}),n.d(e,"b",function(){return v}),n.d(e,"d",function(){return y});var r=n(2),o=n.n(r),e=n(17),s=n.n(e),r=n(18),a=n.n(r),e=n(63),i=n.n(e),r=n(32),c=n.n(r),e=n(64),r=n.n(e),e=n(0),u=n.n(e);function l(n){var r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}();return function(){var t,e=c()(n);return e=r?(t=c()(this).constructor,Reflect.construct(e,arguments,t)):e.apply(this,arguments),i()(this,e)}}var h="function"==typeof Error.captureStackTrace,f=!!(new Error).stack,r=function(t){a()(r,t);var n=l(r);function r(t){var e;return o()(this,r),e=n.call(this,t),u()(s()(e),"message",void 0),e.message=t,h?Error.captureStackTrace(s()(e),r.constructor):e.stack=f?(new Error).stack:"",e}return r}(r()(Error)),d=function(t){a()(n,t);var e=l(n);function n(){return o()(this,n),e.apply(this,arguments)}return n}(r),p=function(t){a()(n,t);var e=l(n);function n(){return o()(this,n),e.apply(this,arguments)}return n}(r),v=function(t){a()(n,t);var e=l(n);function n(){return o()(this,n),e.apply(this,arguments)}return n}(r),y=function(t){a()(i,t);var r=l(i);function i(t,e,n){return o()(this,i),t=r.call(this,t),u()(s()(t),"error",void 0),u()(s()(t),"response",void 0),t.error=e,t.response=n,t}return i}(r)},function(t,e){function r(t,e){for(var n=0;n>(-2*i&6))))r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(r);return s};function i(t){this.message=t}(i.prototype=new Error).name="InvalidTokenError",e.a=function(t,e){if("string"!=typeof t)throw new i("Invalid token specified");var n=!0===(e=e||{}).header?0:1;try{return JSON.parse(function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return decodeURIComponent(r(e).replace(/(.)/g,function(t,e){e=e.charCodeAt(0).toString(16).toUpperCase();return e.length<2&&(e="0"+e),"%"+e}))}catch(t){return r(e)}}(t.split(".")[n]))}catch(t){throw new i("Invalid token specified: "+t.message)}}},function(t,e,n){var r=n(38),i=n(17);t.exports=function(t,e){return!e||"object"!==r(e)&&"function"!=typeof e?i(t):e}},function(e,t,n){var r=n(32),i=n(37),o=n(109),s=n(110);function a(t){var n="function"==typeof Map?new Map:void 0;return e.exports=a=function(t){if(null===t||!o(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(t))return n.get(t);n.set(t,e)}function e(){return s(t,arguments,r(this).constructor)}return e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),i(e,t)},a(t)}e.exports=a},function(t,e){function n(){return t.exports=n=Object.assign||function(t){for(var e=1;et.length)&&(e=t.length);for(var n=0,r=new Array(e);n=Math.pow(2,32)&&(this._messageId=0),this._messageId.toString(36)},_receiveMessage:function(t){var e,n=t.id;void 0!==t.successful&&(e=this._responseCallbacks[n],delete this._responseCallbacks[n]),this.pipeThroughExtensions("incoming",t,null,function(t){t&&(t.advice&&this._handleAdvice(t.advice),this._deliverMessage(t),e&&e[0].call(e[1],t))},this)},_handleAdvice:function(t){e(this._advice,t),this._dispatcher.timeout=this._advice.timeout/1e3,this._advice.reconnect===this.HANDSHAKE&&this._state!==this.DISCONNECTED&&(this._state=this.UNCONNECTED,this._dispatcher.clientId=null,this._cycleConnection())},_deliverMessage:function(t){t.channel&&void 0!==t.data&&(this.info("Client ? calling listeners for ? with ?",this._dispatcher.clientId,t.channel,t.data),this._channels.distributeMessage(t))},_cycleConnection:function(){this._connectRequest&&(this._connectRequest=null,this.info("Closed connection for ?",this._dispatcher.clientId));var t=this;i.setTimeout(function(){t.connect()},this._advice.interval)}});e(t.prototype,r),e(t.prototype,l),e(t.prototype,u),e(t.prototype,p),g.exports=t}).call(this,m(11))},function(h,t,e){"use strict";(function(t){function e(t){r.length||(n(),0),r[r.length]=t}h.exports=e;var n,r=[],i=0;function o(){for(;i=10"},"repository":{"type":"git","url":"git://github.com/GetStream/stream-js.git"},"files":["src","dist","types","lib"],"engines":{"node":"10 || 12 || >=14"},"keywords":["stream","get","get-stream","chat","notification","feed","stream.io","getstream"]}')}],i.c=r,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)i.d(n,r,function(t){return e[t]}.bind(null,r));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="dist/",i(i.s=67);function i(t){if(r[t])return r[t].exports;var e=r[t]={i:t,l:!1,exports:{}};return n[t].call(e.exports,e,e.exports,i),e.l=!0,e.exports}var n,r}); \ No newline at end of file +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.stream=e():t.stream=e()}(window,function(){return r={},i.m=n=[function(t,e){t.exports=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}},function(t,e,n){t.exports=n(75)},function(t,e){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}},function(t,e,n){"use strict";n.d(e,"a",function(){return d}),n.d(e,"c",function(){return p}),n.d(e,"b",function(){return v}),n.d(e,"d",function(){return y});var r=n(2),o=n.n(r),e=n(17),s=n.n(e),r=n(18),a=n.n(r),e=n(63),i=n.n(e),r=n(32),c=n.n(r),e=n(64),r=n.n(e),e=n(0),u=n.n(e);function l(n){var r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}();return function(){var t,e=c()(n);return e=r?(t=c()(this).constructor,Reflect.construct(e,arguments,t)):e.apply(this,arguments),i()(this,e)}}var h="function"==typeof Error.captureStackTrace,f=!!(new Error).stack,r=function(t){a()(r,t);var n=l(r);function r(t){var e;return o()(this,r),e=n.call(this,t),u()(s()(e),"message",void 0),e.message=t,h?Error.captureStackTrace(s()(e),r.constructor):e.stack=f?(new Error).stack:"",e}return r}(r()(Error)),d=function(t){a()(n,t);var e=l(n);function n(){return o()(this,n),e.apply(this,arguments)}return n}(r),p=function(t){a()(n,t);var e=l(n);function n(){return o()(this,n),e.apply(this,arguments)}return n}(r),v=function(t){a()(n,t);var e=l(n);function n(){return o()(this,n),e.apply(this,arguments)}return n}(r),y=function(t){a()(i,t);var r=l(i);function i(t,e,n){return o()(this,i),t=r.call(this,t),u()(s()(t),"error",void 0),u()(s()(t),"response",void 0),t.error=e,t.response=n,t}return i}(r)},function(t,e){function r(t,e){for(var n=0;n>(-2*i&6))))r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(r);return s};function i(t){this.message=t}(i.prototype=new Error).name="InvalidTokenError",e.a=function(t,e){if("string"!=typeof t)throw new i("Invalid token specified");var n=!0===(e=e||{}).header?0:1;try{return JSON.parse(function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return decodeURIComponent(r(e).replace(/(.)/g,function(t,e){e=e.charCodeAt(0).toString(16).toUpperCase();return e.length<2&&(e="0"+e),"%"+e}))}catch(t){return r(e)}}(t.split(".")[n]))}catch(t){throw new i("Invalid token specified: "+t.message)}}},function(t,e,n){var r=n(38),i=n(17);t.exports=function(t,e){return!e||"object"!==r(e)&&"function"!=typeof e?i(t):e}},function(e,t,n){var r=n(32),i=n(37),o=n(109),s=n(110);function a(t){var n="function"==typeof Map?new Map:void 0;return e.exports=a=function(t){if(null===t||!o(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(t))return n.get(t);n.set(t,e)}function e(){return s(t,arguments,r(this).constructor)}return e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),i(e,t)},a(t)}e.exports=a},function(t,e){function n(){return t.exports=n=Object.assign||function(t){for(var e=1;et.length)&&(e=t.length);for(var n=0,r=new Array(e);n=Math.pow(2,32)&&(this._messageId=0),this._messageId.toString(36)},_receiveMessage:function(t){var e,n=t.id;void 0!==t.successful&&(e=this._responseCallbacks[n],delete this._responseCallbacks[n]),this.pipeThroughExtensions("incoming",t,null,function(t){t&&(t.advice&&this._handleAdvice(t.advice),this._deliverMessage(t),e&&e[0].call(e[1],t))},this)},_handleAdvice:function(t){e(this._advice,t),this._dispatcher.timeout=this._advice.timeout/1e3,this._advice.reconnect===this.HANDSHAKE&&this._state!==this.DISCONNECTED&&(this._state=this.UNCONNECTED,this._dispatcher.clientId=null,this._cycleConnection())},_deliverMessage:function(t){t.channel&&void 0!==t.data&&(this.info("Client ? calling listeners for ? with ?",this._dispatcher.clientId,t.channel,t.data),this._channels.distributeMessage(t))},_cycleConnection:function(){this._connectRequest&&(this._connectRequest=null,this.info("Closed connection for ?",this._dispatcher.clientId));var t=this;i.setTimeout(function(){t.connect()},this._advice.interval)}});e(t.prototype,r),e(t.prototype,l),e(t.prototype,u),e(t.prototype,p),g.exports=t}).call(this,m(11))},function(h,t,e){"use strict";(function(t){function e(t){r.length||(n(),0),r[r.length]=t}h.exports=e;var n,r=[],i=0;function o(){for(;i=10"},"repository":{"type":"git","url":"git://github.com/GetStream/stream-js.git"},"files":["src","dist","types","lib"],"engines":{"node":"10 || 12 || >=14"},"keywords":["stream","get","get-stream","chat","notification","feed","stream.io","getstream"]}')}],i.c=r,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)i.d(n,r,function(t){return e[t]}.bind(null,r));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="dist/",i(i.s=67);function i(t){if(r[t])return r[t].exports;var e=r[t]={i:t,l:!1,exports:{}};return n[t].call(e.exports,e,e.exports,i),e.l=!0,e.exports}var n,r}); \ No newline at end of file diff --git a/package.json b/package.json index 2fa51848..b808dfc9 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "homepage": "https://getstream.io/docs/?language=js", "email": "support@getstream.io", "license": "BSD-3-Clause", - "version": "7.1.3", + "version": "7.2.0", "scripts": { "transpile": "babel src --out-dir lib --extensions '.ts'", "types": "tsc --emitDeclarationOnly",