@schibsted/account-sdk-browser 5.2.5 → 5.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/identity.js CHANGED
@@ -1,4 +1,4 @@
1
- /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
1
+ /* Copyright 2026 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
2
2
  * See LICENSE.md in the project root.
3
3
  */
4
4
 
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
1
+ /* Copyright 2026 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
2
2
  * See LICENSE.md in the project root.
3
3
  */
4
4
 
package/monetization.js CHANGED
@@ -1,4 +1,4 @@
1
- /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
1
+ /* Copyright 2026 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
2
2
  * See LICENSE.md in the project root.
3
3
  */
4
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schibsted/account-sdk-browser",
3
- "version": "5.2.5",
3
+ "version": "5.2.7",
4
4
  "description": "Schibsted account SDK for browsers",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -11,10 +11,7 @@
11
11
  "lint": "eslint .",
12
12
  "lint:fix": "eslint . --fix",
13
13
  "test": "jest",
14
- "cover": "jest --coverage",
15
- "preversion": "npm run lint && npm test",
16
- "version": "node ./scripts/genversion.js && git add src/version.js",
17
- "postversion": "git push && git push --tags"
14
+ "cover": "jest --coverage"
18
15
  },
19
16
  "author": "",
20
17
  "license": "MIT",
@@ -40,7 +37,7 @@
40
37
  },
41
38
  "repository": {
42
39
  "type": "git",
43
- "url": "git://github.com/schibsted/account-sdk-browser.git"
40
+ "url": "git://schibsted.ghe.com/user-identity/account-sdk-browser.git"
44
41
  },
45
42
  "babel": {
46
43
  "presets": [
package/payment.js CHANGED
@@ -1,4 +1,4 @@
1
- /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
1
+ /* Copyright 2026 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
2
2
  * See LICENSE.md in the project root.
3
3
  */
4
4
 
package/src/identity.js CHANGED
@@ -606,6 +606,9 @@ export class Identity extends EventEmitter {
606
606
  if (err && err.code === 400 && this._enableSessionCaching) {
607
607
  const expiresIn = 1000 * (err.expiresIn || 300);
608
608
  this.sessionStorageCache.set(HAS_SESSION_CACHE_KEY, { error: err }, expiresIn);
609
+ } else if (err && err.code >= 500 && err.code < 600 && this._enableSessionCaching) {
610
+ // Temporary fix: 30 seconds cache to limit number of calls when service is unavailable
611
+ this.sessionStorageCache.set(HAS_SESSION_CACHE_KEY, { error: err }, 30 * 1000);
609
612
  }
610
613
  throw err;
611
614
  }
@@ -40,6 +40,7 @@ export class Monetization extends EventEmitter {
40
40
  this.clientId = clientId;
41
41
  this.env = env;
42
42
  this.redirectUri = redirectUri;
43
+ this.pendingHasAccessRequests = {};
43
44
  this._setSpidServerUrl(env);
44
45
 
45
46
  if (sessionDomain) {
@@ -99,13 +100,24 @@ export class Monetization extends EventEmitter {
99
100
  throw new SDKError(`'productIds' must be an array`);
100
101
  }
101
102
 
102
- const sortedIds = productIds.sort();
103
- const cacheKey = this._accessCacheKey(productIds, userId);
103
+ const sortedIds = [...productIds].sort();
104
+ const cacheKey = this._accessCacheKey(sortedIds, userId);
104
105
  let data = this.cache.get(cacheKey);
105
106
  if (!data) {
106
- data = await this._sessionService.get(`/hasAccess/${sortedIds.join(',')}`);
107
- const expiresSeconds = data.ttl;
108
- this.cache.set(cacheKey, data, expiresSeconds * 1000);
107
+ if (!this.pendingHasAccessRequests[cacheKey]) {
108
+ this.pendingHasAccessRequests[cacheKey] = this._sessionService.get(`/hasAccess/${sortedIds.join(',')}`);
109
+ }
110
+ const promise = this.pendingHasAccessRequests[cacheKey];
111
+ try {
112
+ data = await promise;
113
+ const expiresSeconds = data.ttl;
114
+ this.cache.set(cacheKey, data, expiresSeconds * 1000);
115
+ } finally {
116
+ // If it rejects, we still want to clear the pending request
117
+ if (this.pendingHasAccessRequests[cacheKey] === promise) {
118
+ delete this.pendingHasAccessRequests[cacheKey];
119
+ }
120
+ }
109
121
  }
110
122
 
111
123
  if (!data.entitled) {
@@ -133,7 +145,7 @@ export class Monetization extends EventEmitter {
133
145
  * @private
134
146
  */
135
147
  _accessCacheKey(productIds, userId) {
136
- return `prd_${productIds.sort()}_${userId}`;
148
+ return `prd_${[...productIds].sort()}_${userId}`;
137
149
  }
138
150
 
139
151
  /**
package/src/payment.d.ts CHANGED
@@ -74,7 +74,7 @@ export class Payment {
74
74
  */
75
75
  redeemUrl(voucherCode: string, redirectUri?: string): string;
76
76
  /**
77
- * @deprecated https://github.com/schibsted/account-sdk-browser/issues/94
77
+ * @deprecated https://schibsted.ghe.com/user-identity/account-sdk-browser/issues/94
78
78
  *
79
79
  * Get the url for the paylink purchase
80
80
  * @todo Check working-ness for BFF + SPiD
package/src/payment.js CHANGED
@@ -129,7 +129,7 @@ export class Payment {
129
129
  }
130
130
 
131
131
  /**
132
- * @deprecated https://github.com/schibsted/account-sdk-browser/issues/94
132
+ * @deprecated https://schibsted.ghe.com/user-identity/account-sdk-browser/issues/94
133
133
  *
134
134
  * Get the url for the paylink purchase
135
135
  * @todo Check working-ness for BFF + SPiD
package/src/version.js CHANGED
@@ -1,5 +1,5 @@
1
- // Automatically generated in 'npm version' by scripts/genversion.js
1
+ // Version is bumped automatically by release-please. See release-please-config.json.
2
2
 
3
3
  'use strict'
4
- const version = '5.2.5';
4
+ const version = '5.2.7'; // x-release-please-version
5
5
  export default version;