@schibsted/account-sdk-browser 5.2.5 → 5.2.6
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 +1 -1
- package/es5/global.js +85 -57
- 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 +1 -1
- 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 +85 -57
- 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 +561 -533
- package/es5/monetization.js.map +1 -1
- package/es5/monetization.min.js +1 -1
- package/es5/monetization.min.js.map +1 -1
- package/identity.js +1 -1
- package/index.js +1 -1
- package/monetization.js +1 -1
- package/package.json +1 -1
- package/payment.js +1 -1
- package/src/monetization.js +18 -6
- package/src/version.js +1 -1
package/identity.js
CHANGED
package/index.js
CHANGED
package/monetization.js
CHANGED
package/package.json
CHANGED
package/payment.js
CHANGED
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/version.js
CHANGED