@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/LICENSE.md +1 -1
- package/README.md +14 -15
- package/es5/global.js +92 -59
- package/es5/global.js.map +1 -1
- package/es5/global.min.js +1 -1
- package/es5/global.min.js.map +1 -1
- package/es5/identity.js +7 -2
- package/es5/identity.js.map +1 -1
- package/es5/identity.min.js +1 -1
- package/es5/identity.min.js.map +1 -1
- package/es5/index.js +92 -59
- package/es5/index.js.map +1 -1
- package/es5/index.min.js +1 -1
- package/es5/index.min.js.map +1 -1
- package/es5/monetization.js +562 -534
- package/es5/monetization.js.map +1 -1
- package/es5/monetization.min.js +1 -1
- package/es5/monetization.min.js.map +1 -1
- package/es5/payment.js +1 -1
- package/es5/payment.js.map +1 -1
- package/es5/payment.min.js.map +1 -1
- package/identity.js +1 -1
- package/index.js +1 -1
- package/monetization.js +1 -1
- package/package.json +3 -6
- package/payment.js +1 -1
- package/src/identity.js +3 -0
- package/src/monetization.js +18 -6
- package/src/payment.d.ts +1 -1
- package/src/payment.js +1 -1
- package/src/version.js +2 -2
package/identity.js
CHANGED
package/index.js
CHANGED
package/monetization.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@schibsted/account-sdk-browser",
|
|
3
|
-
"version": "5.2.
|
|
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://
|
|
40
|
+
"url": "git://schibsted.ghe.com/user-identity/account-sdk-browser.git"
|
|
44
41
|
},
|
|
45
42
|
"babel": {
|
|
46
43
|
"presets": [
|
package/payment.js
CHANGED
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
|
}
|
package/src/monetization.js
CHANGED
|
@@ -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(
|
|
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
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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://
|
|
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://
|
|
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
|
-
//
|
|
1
|
+
// Version is bumped automatically by release-please. See release-please-config.json.
|
|
2
2
|
|
|
3
3
|
'use strict'
|
|
4
|
-
const version = '5.2.
|
|
4
|
+
const version = '5.2.7'; // x-release-please-version
|
|
5
5
|
export default version;
|