Skip to content

Commit

Permalink
Release 7.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ferhatelmas committed Jan 21, 2021
1 parent 13155bf commit 2b8a410
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
26 changes: 20 additions & 6 deletions dist/js/getstream.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion dist/js_min/getstream.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 2b8a410

Please sign in to comment.