@schibsted/account-sdk-browser 6.0.0-alpha.10 → 6.0.0-alpha.12
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/README.md +18 -10
- package/dist/account.d.ts +9 -2
- package/dist/compatibility/index.d.ts +2 -0
- package/dist/compatibility/install-legacy-compatibility.d.ts +10 -0
- package/dist/compatibility/legacy-identity.d.ts +32 -0
- package/dist/compatibility/legacy-monetization.d.ts +9 -0
- package/dist/compatibility/types.d.ts +43 -0
- package/dist/compatibility/warnings.d.ts +3 -0
- package/dist/compatibility.js +171 -0
- package/dist/compatibility.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +199 -208
- package/dist/index.js.map +1 -1
- package/dist/monetization.d.ts +1 -1
- package/dist/resolve-browser-window-wUnycyxt.js +21 -0
- package/dist/resolve-browser-window-wUnycyxt.js.map +1 -0
- package/dist/session-state.d.ts +13 -0
- package/dist/types/account.d.ts +35 -6
- package/dist/types/common.d.ts +2 -2
- package/dist/types/session.d.ts +2 -0
- package/dist/version.d.ts +1 -1
- package/package.json +7 -3
- package/src/account.ts +36 -8
- package/src/compatibility/index.ts +10 -0
- package/src/compatibility/install-legacy-compatibility.ts +139 -0
- package/src/compatibility/legacy-identity.ts +229 -0
- package/src/compatibility/legacy-monetization.ts +30 -0
- package/src/compatibility/types.ts +79 -0
- package/src/compatibility/warnings.ts +28 -0
- package/src/identity.ts +4 -1
- package/src/index.ts +4 -0
- package/src/monetization.ts +5 -2
- package/src/session-state.ts +20 -0
- package/src/types/account.ts +38 -5
- package/src/types/common.ts +2 -2
- package/src/types/session.ts +2 -0
- package/src/version.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -1,23 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
var e = [
|
|
3
|
-
"boolean",
|
|
4
|
-
"number",
|
|
5
|
-
"string"
|
|
6
|
-
], t = class extends Error {
|
|
7
|
-
code;
|
|
8
|
-
constructor(e, t) {
|
|
9
|
-
if (super(e), this.name = "SDKError", t) try {
|
|
10
|
-
Object.assign(this, t);
|
|
11
|
-
} catch {}
|
|
12
|
-
}
|
|
13
|
-
toString() {
|
|
14
|
-
let t = `${this.name}: ${this.message}`, n = Object.keys(this).filter((t) => t !== "name" && e.includes(typeof this[t])).map((e) => ` ${e}: ${this[e]}`).join("\n");
|
|
15
|
-
return n ? `${t}\n${n}` : t;
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
//#endregion
|
|
1
|
+
import { n as e, r as t, t as n } from "./resolve-browser-window-wUnycyxt.js";
|
|
19
2
|
//#region src/cache.ts
|
|
20
|
-
function
|
|
3
|
+
function r(e) {
|
|
21
4
|
if (!e) return !1;
|
|
22
5
|
try {
|
|
23
6
|
let t = e(), n = "x-x-x-x".replace(/x/g, () => String(Math.random())), r = "TEST-VALUE";
|
|
@@ -28,7 +11,7 @@ function n(e) {
|
|
|
28
11
|
return !1;
|
|
29
12
|
}
|
|
30
13
|
}
|
|
31
|
-
var
|
|
14
|
+
var i = class {
|
|
32
15
|
store;
|
|
33
16
|
get;
|
|
34
17
|
set;
|
|
@@ -36,7 +19,7 @@ var r = class {
|
|
|
36
19
|
constructor(e) {
|
|
37
20
|
this.store = e, this.get = (e) => this.store.getItem(e), this.set = (e, t) => this.store.setItem(e, t), this.delete = (e) => this.store.removeItem(e);
|
|
38
21
|
}
|
|
39
|
-
},
|
|
22
|
+
}, a = class {
|
|
40
23
|
store;
|
|
41
24
|
get;
|
|
42
25
|
set;
|
|
@@ -48,11 +31,11 @@ var r = class {
|
|
|
48
31
|
delete this.store[e];
|
|
49
32
|
};
|
|
50
33
|
}
|
|
51
|
-
},
|
|
34
|
+
}, o = 2 ** 31 - 1, s = class {
|
|
52
35
|
cache;
|
|
53
36
|
type;
|
|
54
37
|
constructor(e) {
|
|
55
|
-
e &&
|
|
38
|
+
e && r(e) ? (this.cache = new i(e()), this.type = "WebStorage") : (this.cache = new a(), this.type = "ObjectLiteralStorage");
|
|
56
39
|
}
|
|
57
40
|
get(e) {
|
|
58
41
|
function n(e) {
|
|
@@ -72,7 +55,7 @@ var r = class {
|
|
|
72
55
|
}
|
|
73
56
|
set(e, n, r = 0) {
|
|
74
57
|
if (!(r <= 0)) {
|
|
75
|
-
r = Math.min(
|
|
58
|
+
r = Math.min(o, r);
|
|
76
59
|
try {
|
|
77
60
|
let t = Math.floor(Date.now() + r);
|
|
78
61
|
this.cache.set(e, JSON.stringify({
|
|
@@ -91,7 +74,7 @@ var r = class {
|
|
|
91
74
|
throw new t(String(e));
|
|
92
75
|
}
|
|
93
76
|
}
|
|
94
|
-
},
|
|
77
|
+
}, c = {
|
|
95
78
|
ENDPOINTS: {
|
|
96
79
|
SPiD: {
|
|
97
80
|
LOCAL: "http://id.localhost",
|
|
@@ -130,25 +113,25 @@ var r = class {
|
|
|
130
113
|
PRO_FI: "schibsted.fi",
|
|
131
114
|
PRO_DK: "schibsted.dk"
|
|
132
115
|
}
|
|
133
|
-
},
|
|
116
|
+
}, l = c.ENDPOINTS, u = c.NAMESPACE;
|
|
134
117
|
//#endregion
|
|
135
118
|
//#region src/validate.ts
|
|
136
|
-
function
|
|
119
|
+
function d(e, n = "Assertion failed") {
|
|
137
120
|
if (!e) throw new t(n);
|
|
138
121
|
}
|
|
139
|
-
function
|
|
122
|
+
function f(e) {
|
|
140
123
|
return typeof e == "string";
|
|
141
124
|
}
|
|
142
|
-
function
|
|
125
|
+
function p(e) {
|
|
143
126
|
return typeof e == "string" && e.length > 0;
|
|
144
127
|
}
|
|
145
|
-
function
|
|
128
|
+
function m(e) {
|
|
146
129
|
return typeof e == "object" && !!e;
|
|
147
130
|
}
|
|
148
|
-
function
|
|
149
|
-
return
|
|
131
|
+
function h(e) {
|
|
132
|
+
return m(e) && Object.keys(e).length > 0;
|
|
150
133
|
}
|
|
151
|
-
function
|
|
134
|
+
function g(e, ...t) {
|
|
152
135
|
try {
|
|
153
136
|
let n = new URL(e);
|
|
154
137
|
return t.every((e) => n[e]);
|
|
@@ -156,32 +139,32 @@ function h(e, ...t) {
|
|
|
156
139
|
return !1;
|
|
157
140
|
}
|
|
158
141
|
}
|
|
159
|
-
function
|
|
142
|
+
function _(e) {
|
|
160
143
|
return typeof e == "function";
|
|
161
144
|
}
|
|
162
|
-
function
|
|
163
|
-
return
|
|
145
|
+
function v(e, t, n = !1) {
|
|
146
|
+
return f(e) && Array.isArray(t) ? n ? t.indexOf(e) !== -1 : t.some((t) => f(t) && e.toUpperCase() === t.toUpperCase()) : !1;
|
|
164
147
|
}
|
|
165
148
|
//#endregion
|
|
166
149
|
//#region src/object.ts
|
|
167
|
-
function
|
|
150
|
+
function y(...e) {
|
|
168
151
|
let n = {};
|
|
169
152
|
if (!(e && e.length)) throw new t("No objects to clone");
|
|
170
153
|
return e.forEach((e) => {
|
|
171
|
-
|
|
172
|
-
t !== void 0 && (n[e] =
|
|
154
|
+
d(m(e)), h(e) && Object.entries(e).forEach(([e, t]) => {
|
|
155
|
+
t !== void 0 && (n[e] = m(t) ? b(t) : t);
|
|
173
156
|
});
|
|
174
157
|
}), n;
|
|
175
158
|
}
|
|
176
|
-
function
|
|
177
|
-
return
|
|
159
|
+
function b(e) {
|
|
160
|
+
return d(typeof e == "object", `obj should be an object (even null) but it is ${e}`), JSON.parse(JSON.stringify(e)) || e;
|
|
178
161
|
}
|
|
179
162
|
//#endregion
|
|
180
163
|
//#region src/popup.ts
|
|
181
|
-
function
|
|
182
|
-
return
|
|
164
|
+
function ee(e) {
|
|
165
|
+
return d(m(e), `Object must be an object but it is '${e}'`), Object.keys(e).map((t) => `${t}=${e[t]}`).join(",");
|
|
183
166
|
}
|
|
184
|
-
var
|
|
167
|
+
var te = {
|
|
185
168
|
scrollbars: "yes",
|
|
186
169
|
location: "yes",
|
|
187
170
|
status: "no",
|
|
@@ -189,22 +172,22 @@ var ee = {
|
|
|
189
172
|
toolbar: "no",
|
|
190
173
|
resizable: "yes"
|
|
191
174
|
};
|
|
192
|
-
function
|
|
193
|
-
|
|
194
|
-
let { height: i, width: a } = e.screen, o =
|
|
175
|
+
function ne(e, t, n = "", r = {}) {
|
|
176
|
+
d(m(e), `window was supposed to be an object but it is ${e}`), d(m(e.screen), "window should be a valid Window object but it lacks a 'screen' property"), d(_(e.open), "window should be a valid Window object but it lacks an 'open' function"), d(g(t), "Invalid URL for popup");
|
|
177
|
+
let { height: i, width: a } = e.screen, o = y(te, r), { width: s, height: c } = o;
|
|
195
178
|
typeof s == "number" && Number.isFinite(s) && Number.isFinite(a) && (o.left = (a - s) / 2), typeof c == "number" && Number.isFinite(c) && Number.isFinite(i) && (o.top = (i - c) / 2);
|
|
196
|
-
let l =
|
|
179
|
+
let l = ee(o);
|
|
197
180
|
return e.open(t, n, l);
|
|
198
181
|
}
|
|
199
182
|
//#endregion
|
|
200
183
|
//#region src/url.ts
|
|
201
184
|
function x(e, t) {
|
|
202
|
-
return
|
|
185
|
+
return d(p(e), `"url" param must be a non empty string: ${typeof e}`), h(t) && g(t[e]) ? t[e] : (d(g(e, "hostname"), `Bad URL given: '${e}'`), e);
|
|
203
186
|
}
|
|
204
187
|
//#endregion
|
|
205
188
|
//#region src/rest-client.ts
|
|
206
|
-
var
|
|
207
|
-
e && e(
|
|
189
|
+
var re = (e) => e.map((e) => m(e) ? JSON.stringify(e, null, 2) : e).join(" "), S = (e, ...t) => {
|
|
190
|
+
e && e(re(t));
|
|
208
191
|
};
|
|
209
192
|
function C(e) {
|
|
210
193
|
let t = {
|
|
@@ -218,24 +201,24 @@ function C(e) {
|
|
|
218
201
|
};
|
|
219
202
|
return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g, (e) => t[e]);
|
|
220
203
|
}
|
|
221
|
-
var
|
|
204
|
+
var w = () => window.fetch && window.fetch.bind(window), T = () => {
|
|
222
205
|
throw new t("fetch is not available in this environment");
|
|
223
|
-
},
|
|
206
|
+
}, E = class e {
|
|
224
207
|
url;
|
|
225
208
|
defaultParams;
|
|
226
209
|
log;
|
|
227
210
|
fetch;
|
|
228
|
-
constructor({ serverUrl: e = "PRE", envDic: t, fetch: n =
|
|
229
|
-
|
|
211
|
+
constructor({ serverUrl: e = "PRE", envDic: t, fetch: n = w() ?? T, log: r, defaultParams: i = {} }) {
|
|
212
|
+
d(m(i), "defaultParams should be a non-null object");
|
|
230
213
|
let a = x(e, t ?? {}), o = a.endsWith("/") ? a : `${a}/`;
|
|
231
|
-
this.url = new URL(o), this.defaultParams = i, r && (
|
|
214
|
+
this.url = new URL(o), this.defaultParams = i, r && (d(_(r), `log must be a function but it is ${r}`), this.log = r), this.fetch = n;
|
|
232
215
|
}
|
|
233
216
|
async go(e) {
|
|
234
217
|
let { method: n, headers: r, pathname: i, data: a = {}, useDefaultParams: o = !0, fetchOptions: s = {
|
|
235
218
|
method: e.method,
|
|
236
219
|
credentials: "include"
|
|
237
220
|
}, parseResponse: c } = e;
|
|
238
|
-
|
|
221
|
+
d(p(n), `Method must be a non empty string but it is "${n}"`), d(p(i), `Pathname must be string but it is "${i}"`), d(m(a), "data must be a non-null object"), s.headers = m(r) ? r : {};
|
|
239
222
|
let l = this.makeUrl(i, a, o);
|
|
240
223
|
S(this.log, "Request:", n.toUpperCase(), l), S(this.log, "Request Headers:", s.headers), S(this.log, "Request Body:", s.body);
|
|
241
224
|
try {
|
|
@@ -244,9 +227,9 @@ var re = () => window.fetch && window.fetch.bind(window), w = () => {
|
|
|
244
227
|
let n = await e.json();
|
|
245
228
|
return S(this.log, "Response Parsed:", n), c ? c(n) : n;
|
|
246
229
|
} catch (e) {
|
|
247
|
-
let r =
|
|
248
|
-
|
|
249
|
-
let i =
|
|
230
|
+
let r = f(e) ? e : "Unknown RESTClient error";
|
|
231
|
+
m(e) && f(e.message) && (r = e.message);
|
|
232
|
+
let i = m(e) ? e : void 0;
|
|
250
233
|
throw new t(`Failed to '${n}' '${l}': '${r}'`, i);
|
|
251
234
|
}
|
|
252
235
|
}
|
|
@@ -267,42 +250,42 @@ var re = () => window.fetch && window.fetch.bind(window), w = () => {
|
|
|
267
250
|
});
|
|
268
251
|
}
|
|
269
252
|
static search(e, t, n) {
|
|
270
|
-
let r = t ?
|
|
253
|
+
let r = t ? y(n, e) : y(e);
|
|
271
254
|
return Object.keys(r).filter((e) => r[e] !== "").map((e) => `${C(e)}=${C(String(r[e]))}`).join("&");
|
|
272
255
|
}
|
|
273
|
-
},
|
|
256
|
+
}, D = (e) => Object.hasOwn(u, e), O = (e, t) => (d(p(t), "clientId parameter is required"), d(D(e), `env parameter is invalid: ${e}`), `sdrn:${u[e]}:client:${t}`), k = ({ serverUrl: e, log: t, defaultParams: n }) => new E({
|
|
274
257
|
serverUrl: e,
|
|
275
258
|
log: t,
|
|
276
259
|
defaultParams: n
|
|
277
260
|
});
|
|
278
261
|
//#endregion
|
|
279
262
|
//#region src/session-response.ts
|
|
280
|
-
function k(e) {
|
|
281
|
-
return p(e) && typeof e.result == "boolean";
|
|
282
|
-
}
|
|
283
263
|
function A(e) {
|
|
284
|
-
return
|
|
264
|
+
return m(e) && typeof e.result == "boolean";
|
|
285
265
|
}
|
|
286
266
|
function j(e) {
|
|
287
|
-
return
|
|
267
|
+
return A(e) && e.result === !0;
|
|
288
268
|
}
|
|
289
269
|
function M(e) {
|
|
290
|
-
return
|
|
270
|
+
return m(e) && !!e.error;
|
|
291
271
|
}
|
|
292
272
|
function N(e) {
|
|
293
|
-
return
|
|
273
|
+
return m(e) && Object.keys(e).length === 1 && f(e.redirectURL);
|
|
294
274
|
}
|
|
295
275
|
function P(e) {
|
|
296
|
-
return
|
|
276
|
+
return j(e) && typeof e.userId == "number";
|
|
277
|
+
}
|
|
278
|
+
function F(e) {
|
|
279
|
+
return N(e) || M(e) || A(e) || m(e) ? e : {};
|
|
297
280
|
}
|
|
298
281
|
//#endregion
|
|
299
282
|
//#region src/spid-talk.ts
|
|
300
|
-
function
|
|
301
|
-
(!e.SPiD || typeof e.SPiD != "object") && (e.SPiD = {}), (!e.SPiD.Talk || typeof e.SPiD.Talk != "object") && (e.SPiD.Talk = {}),
|
|
283
|
+
function I(e) {
|
|
284
|
+
(!e.SPiD || typeof e.SPiD != "object") && (e.SPiD = {}), (!e.SPiD.Talk || typeof e.SPiD.Talk != "object") && (e.SPiD.Talk = {}), _(e.SPiD.Talk.response) || (e.SPiD.Talk.response = (t, n) => e[t](n));
|
|
302
285
|
}
|
|
303
286
|
//#endregion
|
|
304
287
|
//#region src/types/login.ts
|
|
305
|
-
var
|
|
288
|
+
var L = (e) => typeof e.openSimplifiedLoginWidget == "function", R = "6.0.0-alpha.12", z = "hasSession-cache", B = "sessionCallBlocked-cache", V = 1e3 * 60 * 5, H = "tab-id-cache", U = Math.floor(Math.random() * 1e5), W = 1e3 * 60 * 60 * 24 * 30, G = () => window, K = class {
|
|
306
289
|
eventTarget = new EventTarget();
|
|
307
290
|
window;
|
|
308
291
|
clientId;
|
|
@@ -325,38 +308,38 @@ var I = (e) => typeof e.openSimplifiedLoginWidget == "function", L = "6.0.0-alph
|
|
|
325
308
|
setVarnishCookie;
|
|
326
309
|
varnishExpiresIn;
|
|
327
310
|
varnishCookieDomain;
|
|
328
|
-
constructor({ clientId:
|
|
329
|
-
|
|
330
|
-
let
|
|
311
|
+
constructor({ clientId: t, redirectUri: n, sessionDomain: r, env: i, log: a, window: o = G(), callbackBeforeRedirect: c = () => {} }) {
|
|
312
|
+
d(p(t), "clientId parameter is required"), d(m(o), "The reference to window is missing"), d(!n || g(n), "redirectUri parameter is invalid"), d(p(r) && g(r), "sessionDomain parameter is not a valid URL"), d(f(i), `env parameter is invalid: ${i}`), I(o), this.window = o, this.clientId = t, this.redirectUri = n, this.env = i, this.log = a, this.callbackBeforeRedirect = c, this.sessionStorageCache = new s(() => this.window && this.window.sessionStorage), this.localStorageCache = new s(() => this.window && this.window.localStorage), this.enableSessionCaching = !0, this.session = {}, e.set(this, { getSession: () => this.session });
|
|
313
|
+
let u = {
|
|
331
314
|
client_id: this.clientId,
|
|
332
315
|
redirect_uri: this.redirectUri
|
|
333
|
-
},
|
|
334
|
-
this.spid =
|
|
335
|
-
serverUrl: x(
|
|
316
|
+
}, h = O(this.env, this.clientId);
|
|
317
|
+
this.spid = k({
|
|
318
|
+
serverUrl: x(i, l.SPiD),
|
|
336
319
|
log: this.log,
|
|
337
|
-
defaultParams:
|
|
338
|
-
}), this.oauthService =
|
|
339
|
-
serverUrl: x(
|
|
320
|
+
defaultParams: u
|
|
321
|
+
}), this.oauthService = k({
|
|
322
|
+
serverUrl: x(i, l.SPiD),
|
|
340
323
|
log: this.log,
|
|
341
|
-
defaultParams:
|
|
342
|
-
}), this.bffService =
|
|
343
|
-
serverUrl: x(
|
|
324
|
+
defaultParams: u
|
|
325
|
+
}), this.bffService = k({
|
|
326
|
+
serverUrl: x(i, l.BFF),
|
|
344
327
|
log: this.log,
|
|
345
|
-
defaultParams:
|
|
346
|
-
}), this.sessionService =
|
|
347
|
-
serverUrl:
|
|
328
|
+
defaultParams: u
|
|
329
|
+
}), this.sessionService = k({
|
|
330
|
+
serverUrl: r,
|
|
348
331
|
log: this.log,
|
|
349
332
|
defaultParams: {
|
|
350
|
-
client_sdrn:
|
|
333
|
+
client_sdrn: h,
|
|
351
334
|
redirect_uri: this.redirectUri,
|
|
352
|
-
sdk_version:
|
|
335
|
+
sdk_version: R
|
|
353
336
|
}
|
|
354
|
-
}), this.globalSessionService =
|
|
355
|
-
serverUrl: x(
|
|
337
|
+
}), this.globalSessionService = k({
|
|
338
|
+
serverUrl: x(i, l.SESSION_SERVICE),
|
|
356
339
|
log: this.log,
|
|
357
340
|
defaultParams: {
|
|
358
|
-
client_sdrn:
|
|
359
|
-
sdk_version:
|
|
341
|
+
client_sdrn: h,
|
|
342
|
+
sdk_version: R
|
|
360
343
|
}
|
|
361
344
|
}), this.usedSessionServiceGetSessionEndpoint = this.sessionService.url.pathname && this.sessionService.url.pathname.length <= 1 ? "v2/session" : "session", this._unblockSessionCall();
|
|
362
345
|
}
|
|
@@ -368,18 +351,18 @@ var I = (e) => typeof e.openSimplifiedLoginWidget == "function", L = "6.0.0-alph
|
|
|
368
351
|
}
|
|
369
352
|
_getTabId() {
|
|
370
353
|
if (this.enableSessionCaching) {
|
|
371
|
-
let e = this.sessionStorageCache.get(
|
|
372
|
-
return typeof e == "number" ? e : (this.sessionStorageCache.set(
|
|
354
|
+
let e = this.sessionStorageCache.get(H);
|
|
355
|
+
return typeof e == "number" ? e : (this.sessionStorageCache.set(H, U, W), U);
|
|
373
356
|
}
|
|
374
357
|
}
|
|
375
358
|
_isSessionCallBlocked() {
|
|
376
|
-
return !!this.localStorageCache.get(
|
|
359
|
+
return !!this.localStorageCache.get(B);
|
|
377
360
|
}
|
|
378
361
|
_blockSessionCall() {
|
|
379
|
-
this.localStorageCache.set(
|
|
362
|
+
this.localStorageCache.set(B, !0, V);
|
|
380
363
|
}
|
|
381
364
|
_unblockSessionCall() {
|
|
382
|
-
this.localStorageCache.delete(
|
|
365
|
+
this.localStorageCache.delete(B);
|
|
383
366
|
}
|
|
384
367
|
_closePopup() {
|
|
385
368
|
this.popup &&= (this.popup.closed || this.popup.close(), null);
|
|
@@ -387,10 +370,10 @@ var I = (e) => typeof e.openSimplifiedLoginWidget == "function", L = "6.0.0-alph
|
|
|
387
370
|
enableVarnishCookie(e) {
|
|
388
371
|
if (typeof e != "object") throw new t("VarnishCookieOptions must be an object");
|
|
389
372
|
let { expiresIn: n = 0, domain: r } = e;
|
|
390
|
-
|
|
373
|
+
d(Number.isInteger(n), "'expiresIn' must be an integer"), d(n >= 0, "'expiresIn' cannot be negative"), this.setVarnishCookie = !0, this.varnishExpiresIn = n, this.varnishCookieDomain = r;
|
|
391
374
|
}
|
|
392
375
|
_maybeSetVarnishCookie(e) {
|
|
393
|
-
if (!this.setVarnishCookie || !
|
|
376
|
+
if (!this.setVarnishCookie || !A(e)) return;
|
|
394
377
|
let t = /* @__PURE__ */ new Date();
|
|
395
378
|
if (this.varnishExpiresIn || typeof e.expiresIn == "number" && e.expiresIn > 0) {
|
|
396
379
|
let n = this.varnishExpiresIn || e.expiresIn || 0;
|
|
@@ -408,53 +391,53 @@ var I = (e) => typeof e.openSimplifiedLoginWidget == "function", L = "6.0.0-alph
|
|
|
408
391
|
this.setVarnishCookie && this._clearVarnishCookie();
|
|
409
392
|
}
|
|
410
393
|
_clearVarnishCookie() {
|
|
411
|
-
let e = this.session &&
|
|
394
|
+
let e = this.session && A(this.session) && typeof this.session.baseDomain == "string" ? this.session.baseDomain : this.window.location.hostname, t = this.varnishCookieDomain || e || "";
|
|
412
395
|
document.cookie = `SP_ID=nothing; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; domain=.${t}`;
|
|
413
396
|
}
|
|
414
397
|
hasSession() {
|
|
415
398
|
if (this._isSessionCallBlocked()) {
|
|
416
|
-
let e =
|
|
417
|
-
return Promise.resolve(
|
|
399
|
+
let e = F(this.session);
|
|
400
|
+
return Promise.resolve(N(e) ? {} : e);
|
|
418
401
|
}
|
|
419
402
|
if (this.hasSessionInProgress) return this.hasSessionInProgress;
|
|
420
|
-
let
|
|
421
|
-
if (
|
|
422
|
-
return this._maybeSetVarnishCookie(
|
|
423
|
-
},
|
|
424
|
-
let e = this.sessionStorageCache.get(
|
|
425
|
-
return e ?
|
|
426
|
-
},
|
|
403
|
+
let n = !1, r = (r) => {
|
|
404
|
+
if (M(r)) throw new t("HasSession failed", m(r.error) ? r.error : { description: String(r.error) });
|
|
405
|
+
return this._maybeSetVarnishCookie(r), n = (A(this.session) && this.session.id) !== (A(r) && r.id), e.get(this)?.beforeUpdate?.(this.session, r), this.session = r, r;
|
|
406
|
+
}, i = () => {
|
|
407
|
+
let e = this.sessionStorageCache.get(z);
|
|
408
|
+
return e ? F(e) : null;
|
|
409
|
+
}, a = async () => {
|
|
427
410
|
if (this.enableSessionCaching) {
|
|
428
|
-
let e =
|
|
429
|
-
if (e) return
|
|
411
|
+
let e = i();
|
|
412
|
+
if (e) return N(e) ? {} : r(e);
|
|
430
413
|
}
|
|
431
414
|
let e = null;
|
|
432
415
|
try {
|
|
433
|
-
e = await this.sessionService.get(this.usedSessionServiceGetSessionEndpoint, { tabId: this._getTabId() },
|
|
416
|
+
e = await this.sessionService.get(this.usedSessionServiceGetSessionEndpoint, { tabId: this._getTabId() }, F);
|
|
434
417
|
} catch (e) {
|
|
435
|
-
let t =
|
|
418
|
+
let t = m(e) ? e : void 0;
|
|
436
419
|
if (t?.code === 400 && this.enableSessionCaching) {
|
|
437
420
|
let n = 1e3 * (typeof t.expiresIn == "number" ? t.expiresIn : 300);
|
|
438
|
-
this.sessionStorageCache.set(
|
|
439
|
-
} else t && typeof t.code == "number" && t.code >= 500 && t.code < 600 && this.enableSessionCaching && this.sessionStorageCache.set(
|
|
421
|
+
this.sessionStorageCache.set(z, { error: e }, n);
|
|
422
|
+
} else t && typeof t.code == "number" && t.code >= 500 && t.code < 600 && this.enableSessionCaching && this.sessionStorageCache.set(z, { error: e }, 30 * 1e3);
|
|
440
423
|
throw e;
|
|
441
424
|
}
|
|
442
425
|
if (e) {
|
|
443
|
-
if (
|
|
426
|
+
if (N(e)) return this._blockSessionCall(), await this.callbackBeforeRedirect(), this.sessionService.makeUrl(e.redirectURL, { tabId: this._getTabId() });
|
|
444
427
|
if (this.enableSessionCaching) {
|
|
445
|
-
let t = 1e3 * (
|
|
446
|
-
this.sessionStorageCache.set(
|
|
428
|
+
let t = 1e3 * (A(e) && e.expiresIn || 300);
|
|
429
|
+
this.sessionStorageCache.set(z, e, t);
|
|
447
430
|
}
|
|
448
431
|
}
|
|
449
|
-
return
|
|
432
|
+
return r(e ?? {});
|
|
450
433
|
};
|
|
451
|
-
return this.hasSessionInProgress =
|
|
434
|
+
return this.hasSessionInProgress = a().then((e) => (n && typeof e != "string" && this.eventTarget.dispatchEvent(new CustomEvent("sessionUpdated", { detail: e })), this.hasSessionInProgress = !1, typeof e == "string" && (this.window.location.href = e), e), (e) => {
|
|
452
435
|
throw this.hasSessionInProgress = !1, new t("HasSession failed", e);
|
|
453
436
|
}), this.hasSessionInProgress;
|
|
454
437
|
}
|
|
455
438
|
async isLoggedIn() {
|
|
456
439
|
try {
|
|
457
|
-
return
|
|
440
|
+
return A(await this.hasSession());
|
|
458
441
|
} catch {
|
|
459
442
|
return !1;
|
|
460
443
|
}
|
|
@@ -463,27 +446,27 @@ var I = (e) => typeof e.openSimplifiedLoginWidget == "function", L = "6.0.0-alph
|
|
|
463
446
|
this.enableSessionCaching = e;
|
|
464
447
|
}
|
|
465
448
|
clearCachedUserSession() {
|
|
466
|
-
this.sessionStorageCache.delete(
|
|
449
|
+
this.sessionStorageCache.delete(z);
|
|
467
450
|
}
|
|
468
451
|
async isConnected() {
|
|
469
452
|
try {
|
|
470
|
-
return
|
|
453
|
+
return j(await this.hasSession());
|
|
471
454
|
} catch {
|
|
472
455
|
return !1;
|
|
473
456
|
}
|
|
474
457
|
}
|
|
475
458
|
async getUser() {
|
|
476
459
|
let e = await this.hasSession();
|
|
477
|
-
if (!
|
|
478
|
-
return
|
|
460
|
+
if (!j(e)) throw new t("The user is not connected to this merchant");
|
|
461
|
+
return b(e);
|
|
479
462
|
}
|
|
480
463
|
async getUserId() {
|
|
481
464
|
let e = await this.hasSession();
|
|
482
|
-
if (
|
|
465
|
+
if (P(e)) return e.userId;
|
|
483
466
|
throw new t("The user is not connected to this merchant");
|
|
484
467
|
}
|
|
485
468
|
async getExternalId(e, n = "") {
|
|
486
|
-
let r = await this.hasSession(), i =
|
|
469
|
+
let r = await this.hasSession(), i = A(r) ? r.pairId : void 0;
|
|
487
470
|
if (!i) throw new t("pairId missing in user session!");
|
|
488
471
|
if (!e || e.length === 0) throw new t("externalParty cannot be empty");
|
|
489
472
|
let a = (e) => Array.from(new Uint8Array(e)).map((e) => e.toString(16).padStart(2, "0")).join(""), o = (e) => crypto.subtle.digest("SHA-256", e);
|
|
@@ -491,28 +474,28 @@ var I = (e) => typeof e.openSimplifiedLoginWidget == "function", L = "6.0.0-alph
|
|
|
491
474
|
}
|
|
492
475
|
async getUserSDRN() {
|
|
493
476
|
let e = await this.hasSession();
|
|
494
|
-
if (
|
|
477
|
+
if (A(e) && e.sdrn) return e.sdrn;
|
|
495
478
|
throw new t("Failed to get SDRN from user session");
|
|
496
479
|
}
|
|
497
480
|
async getUserUuid() {
|
|
498
481
|
let e = await this.hasSession();
|
|
499
|
-
if (
|
|
482
|
+
if (A(e) && e.uuid && e.result) return e.uuid;
|
|
500
483
|
throw new t("The user is not connected to this merchant");
|
|
501
484
|
}
|
|
502
485
|
async getUserContextData() {
|
|
503
486
|
try {
|
|
504
|
-
return await this.globalSessionService.get("user-context", void 0, (e) =>
|
|
487
|
+
return await this.globalSessionService.get("user-context", void 0, (e) => m(e) && f(e.identifier) ? {
|
|
505
488
|
identifier: e.identifier,
|
|
506
|
-
display_text:
|
|
507
|
-
client_name:
|
|
508
|
-
provider_id:
|
|
489
|
+
display_text: f(e.display_text) ? e.display_text : "",
|
|
490
|
+
client_name: f(e.client_name) ? e.client_name : "",
|
|
491
|
+
provider_id: f(e.provider_id) ? e.provider_id : void 0
|
|
509
492
|
} : null);
|
|
510
493
|
} catch {
|
|
511
494
|
return null;
|
|
512
495
|
}
|
|
513
496
|
}
|
|
514
497
|
login({ state: e, acrValues: t, scope: n = "openid", redirectUri: r = this.redirectUri, preferPopup: i = !1, loginHint: a = "", tag: o = "", teaser: s = "", maxAge: c = "", locale: l, oneStepLogin: u = !1, prompt: d = "select_account", xDomainId: f = "", xEnvironmentId: p = "", originCampaign: m = "" }) {
|
|
515
|
-
this._closePopup(), this.sessionStorageCache.delete(
|
|
498
|
+
this._closePopup(), this.sessionStorageCache.delete(z);
|
|
516
499
|
let h = this.loginUrl({
|
|
517
500
|
state: e,
|
|
518
501
|
acrValues: t,
|
|
@@ -529,7 +512,7 @@ var I = (e) => typeof e.openSimplifiedLoginWidget == "function", L = "6.0.0-alph
|
|
|
529
512
|
xEnvironmentId: p,
|
|
530
513
|
originCampaign: m
|
|
531
514
|
});
|
|
532
|
-
return i && (this.popup =
|
|
515
|
+
return i && (this.popup = ne(this.window, h, "Schibsted account", {
|
|
533
516
|
width: 360,
|
|
534
517
|
height: 570
|
|
535
518
|
}), this.popup) ? (this.eventTarget.dispatchEvent(new CustomEvent("loginRequested", { detail: {
|
|
@@ -543,20 +526,20 @@ var I = (e) => typeof e.openSimplifiedLoginWidget == "function", L = "6.0.0-alph
|
|
|
543
526
|
async getSpId() {
|
|
544
527
|
try {
|
|
545
528
|
let e = await this.hasSession();
|
|
546
|
-
if (
|
|
547
|
-
let t =
|
|
548
|
-
return
|
|
529
|
+
if (A(e)) return e.sp_id || null;
|
|
530
|
+
let t = m(e) && "sp_id" in e ? e.sp_id : void 0;
|
|
531
|
+
return f(t) ? t : null;
|
|
549
532
|
} catch {
|
|
550
533
|
return null;
|
|
551
534
|
}
|
|
552
535
|
}
|
|
553
536
|
logout(e = this.redirectUri) {
|
|
554
|
-
this.sessionStorageCache.delete(
|
|
537
|
+
this.sessionStorageCache.delete(z), this._maybeClearVarnishCookie();
|
|
555
538
|
let t = this.logoutUrl(e);
|
|
556
539
|
this.eventTarget.dispatchEvent(new CustomEvent("logoutRequested", { detail: { url: t } })), this.window.location.href = t;
|
|
557
540
|
}
|
|
558
|
-
loginUrl({ state: e, acrValues: t = "", scope: n = "openid", redirectUri: r = this.redirectUri, loginHint: i = "", tag: a = "", teaser: o = "", maxAge: s = "", locale: c, oneStepLogin: l = !1, prompt:
|
|
559
|
-
return
|
|
541
|
+
loginUrl({ state: e, acrValues: t = "", scope: n = "openid", redirectUri: r = this.redirectUri, loginHint: i = "", tag: a = "", teaser: o = "", maxAge: s = "", locale: c, oneStepLogin: l = !1, prompt: u = "select_account", xDomainId: f = "", xEnvironmentId: m = "", originCampaign: h = "" }) {
|
|
542
|
+
return d(!t || v(t, ["", "otp-email"], !0) || t.split(" ").every((e) => v(e, [
|
|
560
543
|
"password",
|
|
561
544
|
"otp",
|
|
562
545
|
"sms",
|
|
@@ -565,7 +548,7 @@ var I = (e) => typeof e.openSimplifiedLoginWidget == "function", L = "6.0.0-alph
|
|
|
565
548
|
"eid-se",
|
|
566
549
|
"eid-fi",
|
|
567
550
|
"eid"
|
|
568
|
-
], !0)), `The acrValues parameter is not acceptable: ${t}`),
|
|
551
|
+
], !0)), `The acrValues parameter is not acceptable: ${t}`), d(g(r), `loginUrl(): redirectUri must be a valid url but is ${r}`), d(p(e), `the state parameter should be a non empty string but it is ${e}`), this.oauthService.makeUrl("oauth/authorize", {
|
|
569
552
|
response_type: "code",
|
|
570
553
|
redirect_uri: r,
|
|
571
554
|
scope: n,
|
|
@@ -577,14 +560,14 @@ var I = (e) => typeof e.openSimplifiedLoginWidget == "function", L = "6.0.0-alph
|
|
|
577
560
|
max_age: s,
|
|
578
561
|
locale: c,
|
|
579
562
|
one_step_login: l || "",
|
|
580
|
-
prompt: t ? "" :
|
|
581
|
-
x_domain_id:
|
|
563
|
+
prompt: t ? "" : u,
|
|
564
|
+
x_domain_id: f,
|
|
582
565
|
x_env_id: m,
|
|
583
|
-
utm_campaign:
|
|
566
|
+
utm_campaign: h
|
|
584
567
|
});
|
|
585
568
|
}
|
|
586
569
|
logoutUrl(e = this.redirectUri) {
|
|
587
|
-
|
|
570
|
+
d(g(e), "logoutUrl(): redirectUri is invalid");
|
|
588
571
|
let t = { redirect_uri: e };
|
|
589
572
|
return this.sessionService.makeUrl("logout", t);
|
|
590
573
|
}
|
|
@@ -633,10 +616,10 @@ var I = (e) => typeof e.openSimplifiedLoginWidget == "function", L = "6.0.0-alph
|
|
|
633
616
|
}, f = () => {
|
|
634
617
|
this.eventTarget.dispatchEvent(new Event("simplifiedLoginCancelled"));
|
|
635
618
|
};
|
|
636
|
-
if (
|
|
619
|
+
if (L(window)) return window.openSimplifiedLoginWidget(c, l, u, d, f), i(!0);
|
|
637
620
|
let p = document.createElement("script");
|
|
638
621
|
p.type = "text/javascript", p.src = a, p.onload = () => {
|
|
639
|
-
if (!
|
|
622
|
+
if (!L(window)) {
|
|
640
623
|
s(new t("Error when loading simplified login widget content"));
|
|
641
624
|
return;
|
|
642
625
|
}
|
|
@@ -649,14 +632,14 @@ var I = (e) => typeof e.openSimplifiedLoginWidget == "function", L = "6.0.0-alph
|
|
|
649
632
|
};
|
|
650
633
|
//#endregion
|
|
651
634
|
//#region src/has-access-response.ts
|
|
652
|
-
function
|
|
653
|
-
if (!
|
|
635
|
+
function q(e) {
|
|
636
|
+
if (!m(e)) throw new t("Invalid hasAccess response");
|
|
654
637
|
let { entitled: n, ttl: r, allowedFeatures: i, userId: a, uuid: o, sig: s } = e;
|
|
655
|
-
if (typeof n != "boolean" || typeof r != "number" || !Array.isArray(i) || typeof a != "number" || !
|
|
638
|
+
if (typeof n != "boolean" || typeof r != "number" || !Array.isArray(i) || typeof a != "number" || !f(o) || !f(s)) throw new t("Invalid hasAccess response");
|
|
656
639
|
return {
|
|
657
640
|
entitled: n,
|
|
658
641
|
ttl: r,
|
|
659
|
-
allowedFeatures: i.filter(
|
|
642
|
+
allowedFeatures: i.filter(f),
|
|
660
643
|
userId: a,
|
|
661
644
|
uuid: o,
|
|
662
645
|
sig: s
|
|
@@ -664,19 +647,19 @@ function K(e) {
|
|
|
664
647
|
}
|
|
665
648
|
//#endregion
|
|
666
649
|
//#region src/monetization.ts
|
|
667
|
-
var
|
|
650
|
+
var J = () => window, Y = class {
|
|
668
651
|
cache;
|
|
669
652
|
sessionService;
|
|
670
653
|
pendingHasAccessRequests;
|
|
671
|
-
constructor({ clientId: e, redirectUri: t, env: n
|
|
672
|
-
|
|
673
|
-
let a =
|
|
674
|
-
this.cache = new
|
|
654
|
+
constructor({ clientId: e, redirectUri: t, env: n, sessionDomain: r, window: i = J() }) {
|
|
655
|
+
I(i), d(p(e), "clientId parameter is required"), d(f(n), `env parameter is invalid: ${n}`);
|
|
656
|
+
let a = O(n, e);
|
|
657
|
+
this.cache = new s(() => i && i.sessionStorage), this.pendingHasAccessRequests = {}, r && (d(g(r), "sessionDomain parameter is not a valid URL"), this.sessionService = k({
|
|
675
658
|
serverUrl: r,
|
|
676
659
|
defaultParams: {
|
|
677
660
|
client_sdrn: a,
|
|
678
661
|
redirect_uri: t,
|
|
679
|
-
sdk_version:
|
|
662
|
+
sdk_version: R
|
|
680
663
|
}
|
|
681
664
|
}));
|
|
682
665
|
}
|
|
@@ -686,7 +669,7 @@ var q = () => window, J = class {
|
|
|
686
669
|
if (!Array.isArray(e)) throw new t("'productIds' must be an array");
|
|
687
670
|
let r = [...e].sort(), i = this.accessCacheKey(r, n), a = this.cache.get(i);
|
|
688
671
|
if (!a) {
|
|
689
|
-
this.pendingHasAccessRequests[i] || (this.pendingHasAccessRequests[i] = this.sessionService.get(`/hasAccess/${r.join(",")}`, void 0,
|
|
672
|
+
this.pendingHasAccessRequests[i] || (this.pendingHasAccessRequests[i] = this.sessionService.get(`/hasAccess/${r.join(",")}`, void 0, q));
|
|
690
673
|
let e = this.pendingHasAccessRequests[i];
|
|
691
674
|
try {
|
|
692
675
|
a = await e;
|
|
@@ -704,107 +687,115 @@ var q = () => window, J = class {
|
|
|
704
687
|
accessCacheKey(e, t) {
|
|
705
688
|
return `prd_${[...e].sort()}_${t}`;
|
|
706
689
|
}
|
|
707
|
-
},
|
|
690
|
+
}, X = class {
|
|
708
691
|
#e;
|
|
709
692
|
#t;
|
|
710
693
|
#n;
|
|
711
|
-
constructor(
|
|
712
|
-
let
|
|
713
|
-
if (!
|
|
714
|
-
if (
|
|
715
|
-
let { log:
|
|
716
|
-
clientId:
|
|
717
|
-
redirectUri:
|
|
718
|
-
sessionDomain:
|
|
719
|
-
env:
|
|
720
|
-
window:
|
|
694
|
+
constructor(r) {
|
|
695
|
+
let i = n(r.window);
|
|
696
|
+
if (!i) throw new t("Schibsted Account SDK is not available in this browser context");
|
|
697
|
+
if (i.schAccount) throw new t("Schibsted Account SDK has already been initialized");
|
|
698
|
+
let { log: a, callbackBeforeRedirect: o, defaultProductIds: s, varnish: c } = r, l = {
|
|
699
|
+
clientId: r.clientId,
|
|
700
|
+
redirectUri: r.redirectUri,
|
|
701
|
+
sessionDomain: r.sessionDomain,
|
|
702
|
+
env: r.env ?? "PRE",
|
|
703
|
+
window: i
|
|
721
704
|
};
|
|
722
|
-
if (this.#
|
|
723
|
-
...
|
|
724
|
-
log:
|
|
725
|
-
callbackBeforeRedirect:
|
|
726
|
-
}),
|
|
727
|
-
if (
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
705
|
+
if (this.#t = new K({
|
|
706
|
+
...l,
|
|
707
|
+
log: a,
|
|
708
|
+
callbackBeforeRedirect: o
|
|
709
|
+
}), s !== void 0 && !Array.isArray(s)) throw new t("Account defaultProductIds config must be an array");
|
|
710
|
+
if (c && (typeof c != "object" || Array.isArray(c))) throw new t("Account varnish config must be an object");
|
|
711
|
+
c && this.#t.enableVarnishCookie(c), this.#n = new Y(l), this.#e = Object.freeze({
|
|
712
|
+
...r,
|
|
713
|
+
defaultProductIds: s && Object.freeze([...s]),
|
|
714
|
+
varnish: c && Object.freeze({ ...c }),
|
|
715
|
+
env: l.env,
|
|
716
|
+
window: i
|
|
717
|
+
});
|
|
718
|
+
let u = e.get(this.#t);
|
|
719
|
+
u && e.set(this, u), i.schAccount = this, i.dispatchEvent(new CustomEvent("schAccount:ready", { detail: { instance: this } }));
|
|
720
|
+
}
|
|
721
|
+
get config() {
|
|
722
|
+
return this.#e;
|
|
732
723
|
}
|
|
733
724
|
hasSession() {
|
|
734
|
-
return this.#
|
|
725
|
+
return this.#t.hasSession();
|
|
735
726
|
}
|
|
736
727
|
isLoggedIn() {
|
|
737
|
-
return this.#
|
|
728
|
+
return this.#t.isLoggedIn();
|
|
738
729
|
}
|
|
739
730
|
isConnected() {
|
|
740
|
-
return this.#
|
|
731
|
+
return this.#t.isConnected();
|
|
741
732
|
}
|
|
742
733
|
getUser() {
|
|
743
|
-
return this.#
|
|
734
|
+
return this.#t.getUser();
|
|
744
735
|
}
|
|
745
736
|
getUserId() {
|
|
746
|
-
return this.#
|
|
737
|
+
return this.#t.getUserId();
|
|
747
738
|
}
|
|
748
739
|
getExternalId(e, t = "") {
|
|
749
|
-
return this.#
|
|
740
|
+
return this.#t.getExternalId(e, t);
|
|
750
741
|
}
|
|
751
742
|
getUserUuid() {
|
|
752
|
-
return this.#
|
|
743
|
+
return this.#t.getUserUuid();
|
|
753
744
|
}
|
|
754
745
|
getUserSDRN() {
|
|
755
|
-
return this.#
|
|
746
|
+
return this.#t.getUserSDRN();
|
|
756
747
|
}
|
|
757
748
|
getUserContextData() {
|
|
758
|
-
return this.#
|
|
749
|
+
return this.#t.getUserContextData();
|
|
759
750
|
}
|
|
760
751
|
getSpId() {
|
|
761
|
-
return this.#
|
|
752
|
+
return this.#t.getSpId();
|
|
762
753
|
}
|
|
763
754
|
login(e) {
|
|
764
|
-
return this.#
|
|
755
|
+
return this.#t.login(e);
|
|
765
756
|
}
|
|
766
757
|
logout(e) {
|
|
767
|
-
this.#
|
|
758
|
+
this.#t.logout(e);
|
|
768
759
|
}
|
|
769
760
|
loginUrl(e) {
|
|
770
|
-
return this.#
|
|
761
|
+
return this.#t.loginUrl(e);
|
|
771
762
|
}
|
|
772
763
|
logoutUrl(e) {
|
|
773
|
-
return this.#
|
|
764
|
+
return this.#t.logoutUrl(e);
|
|
774
765
|
}
|
|
775
766
|
accountUrl(e) {
|
|
776
|
-
return this.#
|
|
767
|
+
return this.#t.accountUrl(e);
|
|
777
768
|
}
|
|
778
769
|
showSimplifiedLoginWidget(e, t) {
|
|
779
|
-
return this.#
|
|
770
|
+
return this.#t.showSimplifiedLoginWidget(e, t);
|
|
780
771
|
}
|
|
781
772
|
setSessionCachingEnabled(e) {
|
|
782
|
-
this.#
|
|
773
|
+
this.#t.setSessionCachingEnabled(e);
|
|
783
774
|
}
|
|
784
775
|
clearCachedUserSession() {
|
|
785
|
-
this.#
|
|
776
|
+
this.#t.clearCachedUserSession();
|
|
786
777
|
}
|
|
787
|
-
async hasAccess(e = this.#
|
|
778
|
+
async hasAccess(e = this.#e.defaultProductIds) {
|
|
788
779
|
if (!e) throw new t("hasAccess requires productIds or defaultProductIds in the Account config");
|
|
789
780
|
if (e.length === 0) return null;
|
|
790
|
-
let n = await this.#
|
|
791
|
-
return this.#
|
|
781
|
+
let n = await this.#t.getUserId();
|
|
782
|
+
return this.#n.hasAccess(e, n);
|
|
792
783
|
}
|
|
793
784
|
clearCachedAccessResult(e, t) {
|
|
794
|
-
this.#
|
|
785
|
+
this.#n.clearCachedAccessResult(e, t);
|
|
795
786
|
}
|
|
796
787
|
on(e, t) {
|
|
797
|
-
return this.#
|
|
788
|
+
return this.#t.addEventListener(e, t), this;
|
|
798
789
|
}
|
|
799
790
|
off(e, t) {
|
|
800
|
-
return this.#
|
|
791
|
+
return this.#t.removeEventListener(e, t), this;
|
|
801
792
|
}
|
|
802
793
|
}, Z = "schAccount:ready", Q = 4e3, $, ie = () => /* @__PURE__ */ Error("Schibsted Account SDK is not available in this browser context"), ae = () => /* @__PURE__ */ Error(`Schibsted Account SDK was not initialized within ${Q} ms`);
|
|
803
794
|
function oe(e) {
|
|
804
795
|
return new X(e);
|
|
805
796
|
}
|
|
806
797
|
function se() {
|
|
807
|
-
let e =
|
|
798
|
+
let e = n();
|
|
808
799
|
if (!e) {
|
|
809
800
|
let e = ie();
|
|
810
801
|
return console.error(e.message), Promise.reject(e);
|
|
@@ -823,6 +814,6 @@ function se() {
|
|
|
823
814
|
}), $);
|
|
824
815
|
}
|
|
825
816
|
//#endregion
|
|
826
|
-
export { X as Account, t as SDKError, oe as createAccountSdk, se as getAccountSdk,
|
|
817
|
+
export { X as Account, t as SDKError, oe as createAccountSdk, se as getAccountSdk, j as isConnectedSessionResponse, P as isConnectedSessionWithUserIdResponse, M as isSessionFailureResponse, A as isSessionSuccessResponse };
|
|
827
818
|
|
|
828
819
|
//# sourceMappingURL=index.js.map
|