@schibsted/account-sdk-browser 6.0.0-alpha.12 → 6.0.0-alpha.14
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 +4 -0
- package/dist/account.d.ts +11 -5
- package/dist/compatibility/types.d.ts +3 -3
- package/dist/compatibility.js +3 -3
- package/dist/compatibility.js.map +1 -1
- package/dist/consents.d.ts +29 -0
- package/dist/identity.d.ts +21 -3
- package/dist/index.d.ts +2 -1
- package/dist/index.js +272 -187
- package/dist/index.js.map +1 -1
- package/dist/types/account.d.ts +9 -8
- package/dist/types/common.d.ts +2 -2
- package/dist/types/identity.d.ts +10 -1
- package/dist/version.d.ts +1 -1
- package/package.json +5 -1
- package/src/account.ts +49 -22
- package/src/compatibility/legacy-identity.ts +6 -6
- package/src/compatibility/types.ts +3 -3
- package/src/consents.ts +94 -0
- package/src/identity.ts +94 -20
- package/src/index.ts +1 -1
- package/src/types/account.ts +13 -11
- package/src/types/common.ts +2 -2
- package/src/types/identity.ts +11 -1
- package/src/version.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -115,23 +115,80 @@ var i = class {
|
|
|
115
115
|
}
|
|
116
116
|
}, l = c.ENDPOINTS, u = c.NAMESPACE;
|
|
117
117
|
//#endregion
|
|
118
|
+
//#region node_modules/@schibsted/consent-url-utils/lib/esm/consent-manager.js
|
|
119
|
+
function d(e = window) {
|
|
120
|
+
let t = e._tcf_ || e._scc_;
|
|
121
|
+
return t ? {
|
|
122
|
+
advertising: t.getPermissionSync("CMP:advertising"),
|
|
123
|
+
analytics: t.getPermissionSync("CMP:analytics"),
|
|
124
|
+
marketing: t.getPermissionSync("CMP:marketing"),
|
|
125
|
+
personalisation: t.getPermissionSync("CMP:personalisation")
|
|
126
|
+
} : (console.warn("Consent-query-utils: getConsentsSync called but no consent manager found on window"), null);
|
|
127
|
+
}
|
|
128
|
+
//#endregion
|
|
129
|
+
//#region node_modules/@schibsted/consent-url-utils/lib/esm/serializeConsents.js
|
|
130
|
+
var f = "rejected", p = "v1";
|
|
131
|
+
function m(e) {
|
|
132
|
+
return Object.values(e).some((e) => e !== null);
|
|
133
|
+
}
|
|
134
|
+
function h(e) {
|
|
135
|
+
let t = new URLSearchParams();
|
|
136
|
+
if (!e || !m(e)) return t;
|
|
137
|
+
let n = [];
|
|
138
|
+
for (let [t, r] of Object.entries(e)) r === "1" && n.push(t);
|
|
139
|
+
n.length === 0 && n.push(f);
|
|
140
|
+
let r = [...new Set(n)].sort();
|
|
141
|
+
return t.set("consents", r.join(",")), t.set("consent_version", p), t;
|
|
142
|
+
}
|
|
143
|
+
//#endregion
|
|
144
|
+
//#region src/consents.ts
|
|
145
|
+
var ee = ["click", "auxclick"];
|
|
146
|
+
function te(e) {
|
|
147
|
+
return !e._tcf_ && !e._scc_ ? null : h(d(e));
|
|
148
|
+
}
|
|
149
|
+
function g(e, t) {
|
|
150
|
+
let n = new URL(e);
|
|
151
|
+
return t.forEach((e, t) => {
|
|
152
|
+
n.searchParams.delete(t);
|
|
153
|
+
}), t.forEach((e, t) => {
|
|
154
|
+
n.searchParams.append(t, e);
|
|
155
|
+
}), n.href;
|
|
156
|
+
}
|
|
157
|
+
function _(e) {
|
|
158
|
+
return (typeof e.composedPath == "function" ? e.composedPath() : [e.target]).find((e) => {
|
|
159
|
+
let t = e;
|
|
160
|
+
return !!t && t.tagName === "A" && typeof t.href == "string";
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
function ne(e, { isLoginUrl: t, getConsentParams: n }) {
|
|
164
|
+
let r = (e) => {
|
|
165
|
+
let r = _(e);
|
|
166
|
+
if (!r || !t(r.href)) return;
|
|
167
|
+
let i = n();
|
|
168
|
+
i.toString() !== "" && (r.href = g(r.href, i));
|
|
169
|
+
};
|
|
170
|
+
ee.forEach((t) => {
|
|
171
|
+
e.addEventListener(t, r, !0);
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
//#endregion
|
|
118
175
|
//#region src/validate.ts
|
|
119
|
-
function
|
|
176
|
+
function v(e, n = "Assertion failed") {
|
|
120
177
|
if (!e) throw new t(n);
|
|
121
178
|
}
|
|
122
|
-
function
|
|
179
|
+
function y(e) {
|
|
123
180
|
return typeof e == "string";
|
|
124
181
|
}
|
|
125
|
-
function
|
|
182
|
+
function b(e) {
|
|
126
183
|
return typeof e == "string" && e.length > 0;
|
|
127
184
|
}
|
|
128
|
-
function
|
|
185
|
+
function x(e) {
|
|
129
186
|
return typeof e == "object" && !!e;
|
|
130
187
|
}
|
|
131
|
-
function
|
|
132
|
-
return
|
|
188
|
+
function S(e) {
|
|
189
|
+
return x(e) && Object.keys(e).length > 0;
|
|
133
190
|
}
|
|
134
|
-
function
|
|
191
|
+
function C(e, ...t) {
|
|
135
192
|
try {
|
|
136
193
|
let n = new URL(e);
|
|
137
194
|
return t.every((e) => n[e]);
|
|
@@ -139,32 +196,32 @@ function g(e, ...t) {
|
|
|
139
196
|
return !1;
|
|
140
197
|
}
|
|
141
198
|
}
|
|
142
|
-
function
|
|
199
|
+
function w(e) {
|
|
143
200
|
return typeof e == "function";
|
|
144
201
|
}
|
|
145
|
-
function
|
|
146
|
-
return
|
|
202
|
+
function T(e, t, n = !1) {
|
|
203
|
+
return y(e) && Array.isArray(t) ? n ? t.indexOf(e) !== -1 : t.some((t) => y(t) && e.toUpperCase() === t.toUpperCase()) : !1;
|
|
147
204
|
}
|
|
148
205
|
//#endregion
|
|
149
206
|
//#region src/object.ts
|
|
150
|
-
function
|
|
207
|
+
function E(...e) {
|
|
151
208
|
let n = {};
|
|
152
209
|
if (!(e && e.length)) throw new t("No objects to clone");
|
|
153
210
|
return e.forEach((e) => {
|
|
154
|
-
|
|
155
|
-
t !== void 0 && (n[e] =
|
|
211
|
+
v(x(e)), S(e) && Object.entries(e).forEach(([e, t]) => {
|
|
212
|
+
t !== void 0 && (n[e] = x(t) ? D(t) : t);
|
|
156
213
|
});
|
|
157
214
|
}), n;
|
|
158
215
|
}
|
|
159
|
-
function
|
|
160
|
-
return
|
|
216
|
+
function D(e) {
|
|
217
|
+
return v(typeof e == "object", `obj should be an object (even null) but it is ${e}`), JSON.parse(JSON.stringify(e)) || e;
|
|
161
218
|
}
|
|
162
219
|
//#endregion
|
|
163
220
|
//#region src/popup.ts
|
|
164
|
-
function
|
|
165
|
-
return
|
|
221
|
+
function re(e) {
|
|
222
|
+
return v(x(e), `Object must be an object but it is '${e}'`), Object.keys(e).map((t) => `${t}=${e[t]}`).join(",");
|
|
166
223
|
}
|
|
167
|
-
var
|
|
224
|
+
var O = {
|
|
168
225
|
scrollbars: "yes",
|
|
169
226
|
location: "yes",
|
|
170
227
|
status: "no",
|
|
@@ -172,24 +229,24 @@ var te = {
|
|
|
172
229
|
toolbar: "no",
|
|
173
230
|
resizable: "yes"
|
|
174
231
|
};
|
|
175
|
-
function
|
|
176
|
-
|
|
177
|
-
let { height: i, width: a } = e.screen, o =
|
|
232
|
+
function k(e, t, n = "", r = {}) {
|
|
233
|
+
v(x(e), `window was supposed to be an object but it is ${e}`), v(x(e.screen), "window should be a valid Window object but it lacks a 'screen' property"), v(w(e.open), "window should be a valid Window object but it lacks an 'open' function"), v(C(t), "Invalid URL for popup");
|
|
234
|
+
let { height: i, width: a } = e.screen, o = E(O, r), { width: s, height: c } = o;
|
|
178
235
|
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);
|
|
179
|
-
let l =
|
|
236
|
+
let l = re(o);
|
|
180
237
|
return e.open(t, n, l);
|
|
181
238
|
}
|
|
182
239
|
//#endregion
|
|
183
240
|
//#region src/url.ts
|
|
184
|
-
function
|
|
185
|
-
return
|
|
241
|
+
function A(e, t) {
|
|
242
|
+
return v(b(e), `"url" param must be a non empty string: ${typeof e}`), S(t) && C(t[e]) ? t[e] : (v(C(e, "hostname"), `Bad URL given: '${e}'`), e);
|
|
186
243
|
}
|
|
187
244
|
//#endregion
|
|
188
245
|
//#region src/rest-client.ts
|
|
189
|
-
var
|
|
190
|
-
e && e(
|
|
246
|
+
var ie = (e) => e.map((e) => x(e) ? JSON.stringify(e, null, 2) : e).join(" "), j = (e, ...t) => {
|
|
247
|
+
e && e(ie(t));
|
|
191
248
|
};
|
|
192
|
-
function
|
|
249
|
+
function M(e) {
|
|
193
250
|
let t = {
|
|
194
251
|
"!": "%21",
|
|
195
252
|
"'": "%27",
|
|
@@ -201,35 +258,35 @@ function C(e) {
|
|
|
201
258
|
};
|
|
202
259
|
return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g, (e) => t[e]);
|
|
203
260
|
}
|
|
204
|
-
var
|
|
261
|
+
var ae = () => window.fetch && window.fetch.bind(window), oe = () => {
|
|
205
262
|
throw new t("fetch is not available in this environment");
|
|
206
|
-
},
|
|
263
|
+
}, N = class e {
|
|
207
264
|
url;
|
|
208
265
|
defaultParams;
|
|
209
266
|
log;
|
|
210
267
|
fetch;
|
|
211
|
-
constructor({ serverUrl: e = "PRE", envDic: t, fetch: n =
|
|
212
|
-
|
|
213
|
-
let a =
|
|
214
|
-
this.url = new URL(o), this.defaultParams = i, r && (
|
|
268
|
+
constructor({ serverUrl: e = "PRE", envDic: t, fetch: n = ae() ?? oe, log: r, defaultParams: i = {} }) {
|
|
269
|
+
v(x(i), "defaultParams should be a non-null object");
|
|
270
|
+
let a = A(e, t ?? {}), o = a.endsWith("/") ? a : `${a}/`;
|
|
271
|
+
this.url = new URL(o), this.defaultParams = i, r && (v(w(r), `log must be a function but it is ${r}`), this.log = r), this.fetch = n;
|
|
215
272
|
}
|
|
216
273
|
async go(e) {
|
|
217
274
|
let { method: n, headers: r, pathname: i, data: a = {}, useDefaultParams: o = !0, fetchOptions: s = {
|
|
218
275
|
method: e.method,
|
|
219
276
|
credentials: "include"
|
|
220
277
|
}, parseResponse: c } = e;
|
|
221
|
-
|
|
278
|
+
v(b(n), `Method must be a non empty string but it is "${n}"`), v(b(i), `Pathname must be string but it is "${i}"`), v(x(a), "data must be a non-null object"), s.headers = x(r) ? r : {};
|
|
222
279
|
let l = this.makeUrl(i, a, o);
|
|
223
|
-
|
|
280
|
+
j(this.log, "Request:", n.toUpperCase(), l), j(this.log, "Request Headers:", s.headers), j(this.log, "Request Body:", s.body);
|
|
224
281
|
try {
|
|
225
282
|
let e = await this.fetch(l, s);
|
|
226
|
-
if (
|
|
283
|
+
if (j(this.log, "Response Code:", e.status, e.statusText), !e.ok) throw new t(e.statusText, { code: e.status });
|
|
227
284
|
let n = await e.json();
|
|
228
|
-
return
|
|
285
|
+
return j(this.log, "Response Parsed:", n), c ? c(n) : n;
|
|
229
286
|
} catch (e) {
|
|
230
|
-
let r =
|
|
231
|
-
|
|
232
|
-
let i =
|
|
287
|
+
let r = y(e) ? e : "Unknown RESTClient error";
|
|
288
|
+
x(e) && y(e.message) && (r = e.message);
|
|
289
|
+
let i = x(e) ? e : void 0;
|
|
233
290
|
throw new t(`Failed to '${n}' '${l}': '${r}'`, i);
|
|
234
291
|
}
|
|
235
292
|
}
|
|
@@ -250,42 +307,42 @@ var w = () => window.fetch && window.fetch.bind(window), T = () => {
|
|
|
250
307
|
});
|
|
251
308
|
}
|
|
252
309
|
static search(e, t, n) {
|
|
253
|
-
let r = t ?
|
|
254
|
-
return Object.keys(r).filter((e) => r[e] !== "").map((e) => `${
|
|
310
|
+
let r = t ? E(n, e) : E(e);
|
|
311
|
+
return Object.keys(r).filter((e) => r[e] !== "").map((e) => `${M(e)}=${M(String(r[e]))}`).join("&");
|
|
255
312
|
}
|
|
256
|
-
},
|
|
313
|
+
}, se = (e) => Object.hasOwn(u, e), P = (e, t) => (v(b(t), "clientId parameter is required"), v(se(e), `env parameter is invalid: ${e}`), `sdrn:${u[e]}:client:${t}`), F = ({ serverUrl: e, log: t, defaultParams: n }) => new N({
|
|
257
314
|
serverUrl: e,
|
|
258
315
|
log: t,
|
|
259
316
|
defaultParams: n
|
|
260
317
|
});
|
|
261
318
|
//#endregion
|
|
262
319
|
//#region src/session-response.ts
|
|
263
|
-
function
|
|
264
|
-
return
|
|
320
|
+
function I(e) {
|
|
321
|
+
return x(e) && typeof e.result == "boolean";
|
|
265
322
|
}
|
|
266
|
-
function
|
|
267
|
-
return
|
|
323
|
+
function L(e) {
|
|
324
|
+
return I(e) && e.result === !0;
|
|
268
325
|
}
|
|
269
|
-
function
|
|
270
|
-
return
|
|
326
|
+
function R(e) {
|
|
327
|
+
return x(e) && !!e.error;
|
|
271
328
|
}
|
|
272
|
-
function
|
|
273
|
-
return
|
|
329
|
+
function z(e) {
|
|
330
|
+
return x(e) && Object.keys(e).length === 1 && y(e.redirectURL);
|
|
274
331
|
}
|
|
275
|
-
function
|
|
276
|
-
return
|
|
332
|
+
function B(e) {
|
|
333
|
+
return L(e) && typeof e.userId == "number";
|
|
277
334
|
}
|
|
278
|
-
function
|
|
279
|
-
return
|
|
335
|
+
function V(e) {
|
|
336
|
+
return z(e) || R(e) || I(e) || x(e) ? e : {};
|
|
280
337
|
}
|
|
281
338
|
//#endregion
|
|
282
339
|
//#region src/spid-talk.ts
|
|
283
|
-
function
|
|
284
|
-
(!e.SPiD || typeof e.SPiD != "object") && (e.SPiD = {}), (!e.SPiD.Talk || typeof e.SPiD.Talk != "object") && (e.SPiD.Talk = {}),
|
|
340
|
+
function H(e) {
|
|
341
|
+
(!e.SPiD || typeof e.SPiD != "object") && (e.SPiD = {}), (!e.SPiD.Talk || typeof e.SPiD.Talk != "object") && (e.SPiD.Talk = {}), w(e.SPiD.Talk.response) || (e.SPiD.Talk.response = (t, n) => e[t](n));
|
|
285
342
|
}
|
|
286
343
|
//#endregion
|
|
287
344
|
//#region src/types/login.ts
|
|
288
|
-
var
|
|
345
|
+
var U = (e) => typeof e.openSimplifiedLoginWidget == "function", W = "6.0.0-alpha.14", G = "hasSession-cache", K = "sessionCallBlocked-cache", ce = 1e3 * 60 * 5, q = "tab-id-cache", J = Math.floor(Math.random() * 1e5), le = 1e3 * 60 * 60 * 24 * 30, ue = () => window, de = class {
|
|
289
346
|
eventTarget = new EventTarget();
|
|
290
347
|
window;
|
|
291
348
|
clientId;
|
|
@@ -293,6 +350,7 @@ var L = (e) => typeof e.openSimplifiedLoginWidget == "function", R = "6.0.0-alph
|
|
|
293
350
|
env;
|
|
294
351
|
log;
|
|
295
352
|
callbackBeforeRedirect;
|
|
353
|
+
getConsents;
|
|
296
354
|
sessionStorageCache;
|
|
297
355
|
localStorageCache;
|
|
298
356
|
enableSessionCaching;
|
|
@@ -308,41 +366,48 @@ var L = (e) => typeof e.openSimplifiedLoginWidget == "function", R = "6.0.0-alph
|
|
|
308
366
|
setVarnishCookie;
|
|
309
367
|
varnishExpiresIn;
|
|
310
368
|
varnishCookieDomain;
|
|
311
|
-
constructor({ clientId: t, redirectUri: n, sessionDomain: r, env: i, log: a, window: o =
|
|
312
|
-
|
|
313
|
-
let
|
|
369
|
+
constructor({ clientId: t, redirectUri: n, sessionDomain: r, env: i, log: a, window: o = ue(), callbackBeforeRedirect: c = () => {}, getConsents: u = () => te(o) }) {
|
|
370
|
+
v(b(t), "clientId parameter is required"), v(x(o), "The reference to window is missing"), v(!n || C(n), "redirectUri parameter is invalid"), v(b(r) && C(r), "sessionDomain parameter is not a valid URL"), v(y(i), `env parameter is invalid: ${i}`), v(w(u), "getConsents parameter must be a function"), H(o), this.window = o, this.clientId = t, this.redirectUri = n, this.env = i, this.log = a, this.callbackBeforeRedirect = c, this.getConsents = u, 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 });
|
|
371
|
+
let d = {
|
|
314
372
|
client_id: this.clientId,
|
|
315
373
|
redirect_uri: this.redirectUri
|
|
316
|
-
},
|
|
317
|
-
this.spid =
|
|
318
|
-
serverUrl:
|
|
374
|
+
}, f = P(this.env, this.clientId);
|
|
375
|
+
this.spid = F({
|
|
376
|
+
serverUrl: A(i, l.SPiD),
|
|
319
377
|
log: this.log,
|
|
320
|
-
defaultParams:
|
|
321
|
-
}), this.oauthService =
|
|
322
|
-
serverUrl:
|
|
378
|
+
defaultParams: d
|
|
379
|
+
}), this.oauthService = F({
|
|
380
|
+
serverUrl: A(i, l.SPiD),
|
|
323
381
|
log: this.log,
|
|
324
|
-
defaultParams:
|
|
325
|
-
}), this.bffService =
|
|
326
|
-
serverUrl:
|
|
382
|
+
defaultParams: d
|
|
383
|
+
}), this.bffService = F({
|
|
384
|
+
serverUrl: A(i, l.BFF),
|
|
327
385
|
log: this.log,
|
|
328
|
-
defaultParams:
|
|
329
|
-
}), this.sessionService =
|
|
386
|
+
defaultParams: d
|
|
387
|
+
}), this.sessionService = F({
|
|
330
388
|
serverUrl: r,
|
|
331
389
|
log: this.log,
|
|
332
390
|
defaultParams: {
|
|
333
|
-
client_sdrn:
|
|
391
|
+
client_sdrn: f,
|
|
334
392
|
redirect_uri: this.redirectUri,
|
|
335
|
-
sdk_version:
|
|
393
|
+
sdk_version: W
|
|
336
394
|
}
|
|
337
|
-
}), this.globalSessionService =
|
|
338
|
-
serverUrl:
|
|
395
|
+
}), this.globalSessionService = F({
|
|
396
|
+
serverUrl: A(i, l.SESSION_SERVICE),
|
|
339
397
|
log: this.log,
|
|
340
398
|
defaultParams: {
|
|
341
|
-
client_sdrn:
|
|
342
|
-
sdk_version:
|
|
399
|
+
client_sdrn: f,
|
|
400
|
+
sdk_version: W
|
|
343
401
|
}
|
|
344
402
|
}), this.usedSessionServiceGetSessionEndpoint = this.sessionService.url.pathname && this.sessionService.url.pathname.length <= 1 ? "v2/session" : "session", this._unblockSessionCall();
|
|
345
403
|
}
|
|
404
|
+
enableLoginLinkRefresh() {
|
|
405
|
+
let { document: e } = this.window;
|
|
406
|
+
e && w(e.addEventListener) && ne(e, {
|
|
407
|
+
isLoginUrl: (e) => this.isLoginUrl(e),
|
|
408
|
+
getConsentParams: () => this.getConsentParams()
|
|
409
|
+
});
|
|
410
|
+
}
|
|
346
411
|
addEventListener(e, t) {
|
|
347
412
|
this.eventTarget.addEventListener(e, t);
|
|
348
413
|
}
|
|
@@ -351,18 +416,18 @@ var L = (e) => typeof e.openSimplifiedLoginWidget == "function", R = "6.0.0-alph
|
|
|
351
416
|
}
|
|
352
417
|
_getTabId() {
|
|
353
418
|
if (this.enableSessionCaching) {
|
|
354
|
-
let e = this.sessionStorageCache.get(
|
|
355
|
-
return typeof e == "number" ? e : (this.sessionStorageCache.set(
|
|
419
|
+
let e = this.sessionStorageCache.get(q);
|
|
420
|
+
return typeof e == "number" ? e : (this.sessionStorageCache.set(q, J, le), J);
|
|
356
421
|
}
|
|
357
422
|
}
|
|
358
423
|
_isSessionCallBlocked() {
|
|
359
|
-
return !!this.localStorageCache.get(
|
|
424
|
+
return !!this.localStorageCache.get(K);
|
|
360
425
|
}
|
|
361
426
|
_blockSessionCall() {
|
|
362
|
-
this.localStorageCache.set(
|
|
427
|
+
this.localStorageCache.set(K, !0, ce);
|
|
363
428
|
}
|
|
364
429
|
_unblockSessionCall() {
|
|
365
|
-
this.localStorageCache.delete(
|
|
430
|
+
this.localStorageCache.delete(K);
|
|
366
431
|
}
|
|
367
432
|
_closePopup() {
|
|
368
433
|
this.popup &&= (this.popup.closed || this.popup.close(), null);
|
|
@@ -370,10 +435,10 @@ var L = (e) => typeof e.openSimplifiedLoginWidget == "function", R = "6.0.0-alph
|
|
|
370
435
|
enableVarnishCookie(e) {
|
|
371
436
|
if (typeof e != "object") throw new t("VarnishCookieOptions must be an object");
|
|
372
437
|
let { expiresIn: n = 0, domain: r } = e;
|
|
373
|
-
|
|
438
|
+
v(Number.isInteger(n), "'expiresIn' must be an integer"), v(n >= 0, "'expiresIn' cannot be negative"), this.setVarnishCookie = !0, this.varnishExpiresIn = n, this.varnishCookieDomain = r;
|
|
374
439
|
}
|
|
375
440
|
_maybeSetVarnishCookie(e) {
|
|
376
|
-
if (!this.setVarnishCookie || !
|
|
441
|
+
if (!this.setVarnishCookie || !I(e)) return;
|
|
377
442
|
let t = /* @__PURE__ */ new Date();
|
|
378
443
|
if (this.varnishExpiresIn || typeof e.expiresIn == "number" && e.expiresIn > 0) {
|
|
379
444
|
let n = this.varnishExpiresIn || e.expiresIn || 0;
|
|
@@ -391,42 +456,42 @@ var L = (e) => typeof e.openSimplifiedLoginWidget == "function", R = "6.0.0-alph
|
|
|
391
456
|
this.setVarnishCookie && this._clearVarnishCookie();
|
|
392
457
|
}
|
|
393
458
|
_clearVarnishCookie() {
|
|
394
|
-
let e = this.session &&
|
|
459
|
+
let e = this.session && I(this.session) && typeof this.session.baseDomain == "string" ? this.session.baseDomain : this.window.location.hostname, t = this.varnishCookieDomain || e || "";
|
|
395
460
|
document.cookie = `SP_ID=nothing; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; domain=.${t}`;
|
|
396
461
|
}
|
|
397
462
|
hasSession() {
|
|
398
463
|
if (this._isSessionCallBlocked()) {
|
|
399
|
-
let e =
|
|
400
|
-
return Promise.resolve(
|
|
464
|
+
let e = V(this.session);
|
|
465
|
+
return Promise.resolve(z(e) ? {} : e);
|
|
401
466
|
}
|
|
402
467
|
if (this.hasSessionInProgress) return this.hasSessionInProgress;
|
|
403
468
|
let n = !1, r = (r) => {
|
|
404
|
-
if (
|
|
405
|
-
return this._maybeSetVarnishCookie(r), n = (
|
|
469
|
+
if (R(r)) throw new t("HasSession failed", x(r.error) ? r.error : { description: String(r.error) });
|
|
470
|
+
return this._maybeSetVarnishCookie(r), n = (I(this.session) && this.session.id) !== (I(r) && r.id), e.get(this)?.beforeUpdate?.(this.session, r), this.session = r, r;
|
|
406
471
|
}, i = () => {
|
|
407
|
-
let e = this.sessionStorageCache.get(
|
|
408
|
-
return e ?
|
|
472
|
+
let e = this.sessionStorageCache.get(G);
|
|
473
|
+
return e ? V(e) : null;
|
|
409
474
|
}, a = async () => {
|
|
410
475
|
if (this.enableSessionCaching) {
|
|
411
476
|
let e = i();
|
|
412
|
-
if (e) return
|
|
477
|
+
if (e) return z(e) ? {} : r(e);
|
|
413
478
|
}
|
|
414
479
|
let e = null;
|
|
415
480
|
try {
|
|
416
|
-
e = await this.sessionService.get(this.usedSessionServiceGetSessionEndpoint, { tabId: this._getTabId() },
|
|
481
|
+
e = await this.sessionService.get(this.usedSessionServiceGetSessionEndpoint, { tabId: this._getTabId() }, V);
|
|
417
482
|
} catch (e) {
|
|
418
|
-
let t =
|
|
483
|
+
let t = x(e) ? e : void 0;
|
|
419
484
|
if (t?.code === 400 && this.enableSessionCaching) {
|
|
420
485
|
let n = 1e3 * (typeof t.expiresIn == "number" ? t.expiresIn : 300);
|
|
421
|
-
this.sessionStorageCache.set(
|
|
422
|
-
} else t && typeof t.code == "number" && t.code >= 500 && t.code < 600 && this.enableSessionCaching && this.sessionStorageCache.set(
|
|
486
|
+
this.sessionStorageCache.set(G, { error: e }, n);
|
|
487
|
+
} else t && typeof t.code == "number" && t.code >= 500 && t.code < 600 && this.enableSessionCaching && this.sessionStorageCache.set(G, { error: e }, 30 * 1e3);
|
|
423
488
|
throw e;
|
|
424
489
|
}
|
|
425
490
|
if (e) {
|
|
426
|
-
if (
|
|
491
|
+
if (z(e)) return this._blockSessionCall(), await this.callbackBeforeRedirect(), this.sessionService.makeUrl(e.redirectURL, { tabId: this._getTabId() });
|
|
427
492
|
if (this.enableSessionCaching) {
|
|
428
|
-
let t = 1e3 * (
|
|
429
|
-
this.sessionStorageCache.set(
|
|
493
|
+
let t = 1e3 * (I(e) && e.expiresIn || 300);
|
|
494
|
+
this.sessionStorageCache.set(G, e, t);
|
|
430
495
|
}
|
|
431
496
|
}
|
|
432
497
|
return r(e ?? {});
|
|
@@ -437,7 +502,7 @@ var L = (e) => typeof e.openSimplifiedLoginWidget == "function", R = "6.0.0-alph
|
|
|
437
502
|
}
|
|
438
503
|
async isLoggedIn() {
|
|
439
504
|
try {
|
|
440
|
-
return
|
|
505
|
+
return I(await this.hasSession());
|
|
441
506
|
} catch {
|
|
442
507
|
return !1;
|
|
443
508
|
}
|
|
@@ -446,27 +511,27 @@ var L = (e) => typeof e.openSimplifiedLoginWidget == "function", R = "6.0.0-alph
|
|
|
446
511
|
this.enableSessionCaching = e;
|
|
447
512
|
}
|
|
448
513
|
clearCachedUserSession() {
|
|
449
|
-
this.sessionStorageCache.delete(
|
|
514
|
+
this.sessionStorageCache.delete(G);
|
|
450
515
|
}
|
|
451
516
|
async isConnected() {
|
|
452
517
|
try {
|
|
453
|
-
return
|
|
518
|
+
return L(await this.hasSession());
|
|
454
519
|
} catch {
|
|
455
520
|
return !1;
|
|
456
521
|
}
|
|
457
522
|
}
|
|
458
523
|
async getUser() {
|
|
459
524
|
let e = await this.hasSession();
|
|
460
|
-
if (!
|
|
461
|
-
return
|
|
525
|
+
if (!L(e)) throw new t("The user is not connected to this merchant");
|
|
526
|
+
return D(e);
|
|
462
527
|
}
|
|
463
528
|
async getUserId() {
|
|
464
529
|
let e = await this.hasSession();
|
|
465
|
-
if (
|
|
530
|
+
if (B(e)) return e.userId;
|
|
466
531
|
throw new t("The user is not connected to this merchant");
|
|
467
532
|
}
|
|
468
533
|
async getExternalId(e, n = "") {
|
|
469
|
-
let r = await this.hasSession(), i =
|
|
534
|
+
let r = await this.hasSession(), i = I(r) ? r.pairId : void 0;
|
|
470
535
|
if (!i) throw new t("pairId missing in user session!");
|
|
471
536
|
if (!e || e.length === 0) throw new t("externalParty cannot be empty");
|
|
472
537
|
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);
|
|
@@ -474,28 +539,28 @@ var L = (e) => typeof e.openSimplifiedLoginWidget == "function", R = "6.0.0-alph
|
|
|
474
539
|
}
|
|
475
540
|
async getUserSDRN() {
|
|
476
541
|
let e = await this.hasSession();
|
|
477
|
-
if (
|
|
542
|
+
if (I(e) && e.sdrn) return e.sdrn;
|
|
478
543
|
throw new t("Failed to get SDRN from user session");
|
|
479
544
|
}
|
|
480
545
|
async getUserUuid() {
|
|
481
546
|
let e = await this.hasSession();
|
|
482
|
-
if (
|
|
547
|
+
if (I(e) && e.uuid && e.result) return e.uuid;
|
|
483
548
|
throw new t("The user is not connected to this merchant");
|
|
484
549
|
}
|
|
485
550
|
async getUserContextData() {
|
|
486
551
|
try {
|
|
487
|
-
return await this.globalSessionService.get("user-context", void 0, (e) =>
|
|
552
|
+
return await this.globalSessionService.get("user-context", void 0, (e) => x(e) && y(e.identifier) ? {
|
|
488
553
|
identifier: e.identifier,
|
|
489
|
-
display_text:
|
|
490
|
-
client_name:
|
|
491
|
-
provider_id:
|
|
554
|
+
display_text: y(e.display_text) ? e.display_text : "",
|
|
555
|
+
client_name: y(e.client_name) ? e.client_name : "",
|
|
556
|
+
provider_id: y(e.provider_id) ? e.provider_id : void 0
|
|
492
557
|
} : null);
|
|
493
558
|
} catch {
|
|
494
559
|
return null;
|
|
495
560
|
}
|
|
496
561
|
}
|
|
497
562
|
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 = "" }) {
|
|
498
|
-
this._closePopup(), this.sessionStorageCache.delete(
|
|
563
|
+
this._closePopup(), this.sessionStorageCache.delete(G);
|
|
499
564
|
let h = this.loginUrl({
|
|
500
565
|
state: e,
|
|
501
566
|
acrValues: t,
|
|
@@ -512,7 +577,7 @@ var L = (e) => typeof e.openSimplifiedLoginWidget == "function", R = "6.0.0-alph
|
|
|
512
577
|
xEnvironmentId: p,
|
|
513
578
|
originCampaign: m
|
|
514
579
|
});
|
|
515
|
-
return i && (this.popup =
|
|
580
|
+
return i && (this.popup = k(this.window, h, "Schibsted account", {
|
|
516
581
|
width: 360,
|
|
517
582
|
height: 570
|
|
518
583
|
}), this.popup) ? (this.eventTarget.dispatchEvent(new CustomEvent("loginRequested", { detail: {
|
|
@@ -526,20 +591,20 @@ var L = (e) => typeof e.openSimplifiedLoginWidget == "function", R = "6.0.0-alph
|
|
|
526
591
|
async getSpId() {
|
|
527
592
|
try {
|
|
528
593
|
let e = await this.hasSession();
|
|
529
|
-
if (
|
|
530
|
-
let t =
|
|
531
|
-
return
|
|
594
|
+
if (I(e)) return e.sp_id || null;
|
|
595
|
+
let t = x(e) && "sp_id" in e ? e.sp_id : void 0;
|
|
596
|
+
return y(t) ? t : null;
|
|
532
597
|
} catch {
|
|
533
598
|
return null;
|
|
534
599
|
}
|
|
535
600
|
}
|
|
536
601
|
logout(e = this.redirectUri) {
|
|
537
|
-
this.sessionStorageCache.delete(
|
|
602
|
+
this.sessionStorageCache.delete(G), this._maybeClearVarnishCookie();
|
|
538
603
|
let t = this.logoutUrl(e);
|
|
539
604
|
this.eventTarget.dispatchEvent(new CustomEvent("logoutRequested", { detail: { url: t } })), this.window.location.href = t;
|
|
540
605
|
}
|
|
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:
|
|
542
|
-
return
|
|
606
|
+
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: d = "", xEnvironmentId: f = "", originCampaign: p = "" }) {
|
|
607
|
+
return v(!t || T(t, ["", "otp-email"], !0) || t.split(" ").every((e) => T(e, [
|
|
543
608
|
"password",
|
|
544
609
|
"otp",
|
|
545
610
|
"sms",
|
|
@@ -548,7 +613,7 @@ var L = (e) => typeof e.openSimplifiedLoginWidget == "function", R = "6.0.0-alph
|
|
|
548
613
|
"eid-se",
|
|
549
614
|
"eid-fi",
|
|
550
615
|
"eid"
|
|
551
|
-
], !0)), `The acrValues parameter is not acceptable: ${t}`),
|
|
616
|
+
], !0)), `The acrValues parameter is not acceptable: ${t}`), v(C(r), `loginUrl(): redirectUri must be a valid url but is ${r}`), v(b(e), `the state parameter should be a non empty string but it is ${e}`), g(this.oauthService.makeUrl("oauth/authorize", {
|
|
552
617
|
response_type: "code",
|
|
553
618
|
redirect_uri: r,
|
|
554
619
|
scope: n,
|
|
@@ -561,13 +626,26 @@ var L = (e) => typeof e.openSimplifiedLoginWidget == "function", R = "6.0.0-alph
|
|
|
561
626
|
locale: c,
|
|
562
627
|
one_step_login: l || "",
|
|
563
628
|
prompt: t ? "" : u,
|
|
564
|
-
x_domain_id:
|
|
565
|
-
x_env_id:
|
|
566
|
-
utm_campaign:
|
|
567
|
-
});
|
|
629
|
+
x_domain_id: d,
|
|
630
|
+
x_env_id: f,
|
|
631
|
+
utm_campaign: p
|
|
632
|
+
}), this.getConsentParams());
|
|
633
|
+
}
|
|
634
|
+
getConsentParams() {
|
|
635
|
+
try {
|
|
636
|
+
let e = this.getConsents() || new URLSearchParams();
|
|
637
|
+
return v(e instanceof URLSearchParams, `getConsents must return URLSearchParams but it returned ${e}`), e;
|
|
638
|
+
} catch (e) {
|
|
639
|
+
return (this.log || console.warn)("Schibsted account SDK: could not read consents, logging in without them", e), new URLSearchParams();
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
isLoginUrl(e) {
|
|
643
|
+
if (!C(e)) return !1;
|
|
644
|
+
let t = new URL(e), n = new URL(this.oauthService.makeUrl("oauth/authorize", {}, !1));
|
|
645
|
+
return t.origin === n.origin && t.pathname === n.pathname && t.searchParams.get("client_id") === this.clientId;
|
|
568
646
|
}
|
|
569
647
|
logoutUrl(e = this.redirectUri) {
|
|
570
|
-
|
|
648
|
+
v(C(e), "logoutUrl(): redirectUri is invalid");
|
|
571
649
|
let t = { redirect_uri: e };
|
|
572
650
|
return this.sessionService.makeUrl("logout", t);
|
|
573
651
|
}
|
|
@@ -616,10 +694,10 @@ var L = (e) => typeof e.openSimplifiedLoginWidget == "function", R = "6.0.0-alph
|
|
|
616
694
|
}, f = () => {
|
|
617
695
|
this.eventTarget.dispatchEvent(new Event("simplifiedLoginCancelled"));
|
|
618
696
|
};
|
|
619
|
-
if (
|
|
697
|
+
if (U(window)) return window.openSimplifiedLoginWidget(c, l, u, d, f), i(!0);
|
|
620
698
|
let p = document.createElement("script");
|
|
621
699
|
p.type = "text/javascript", p.src = a, p.onload = () => {
|
|
622
|
-
if (!
|
|
700
|
+
if (!U(window)) {
|
|
623
701
|
s(new t("Error when loading simplified login widget content"));
|
|
624
702
|
return;
|
|
625
703
|
}
|
|
@@ -632,14 +710,14 @@ var L = (e) => typeof e.openSimplifiedLoginWidget == "function", R = "6.0.0-alph
|
|
|
632
710
|
};
|
|
633
711
|
//#endregion
|
|
634
712
|
//#region src/has-access-response.ts
|
|
635
|
-
function
|
|
636
|
-
if (!
|
|
713
|
+
function fe(e) {
|
|
714
|
+
if (!x(e)) throw new t("Invalid hasAccess response");
|
|
637
715
|
let { entitled: n, ttl: r, allowedFeatures: i, userId: a, uuid: o, sig: s } = e;
|
|
638
|
-
if (typeof n != "boolean" || typeof r != "number" || !Array.isArray(i) || typeof a != "number" || !
|
|
716
|
+
if (typeof n != "boolean" || typeof r != "number" || !Array.isArray(i) || typeof a != "number" || !y(o) || !y(s)) throw new t("Invalid hasAccess response");
|
|
639
717
|
return {
|
|
640
718
|
entitled: n,
|
|
641
719
|
ttl: r,
|
|
642
|
-
allowedFeatures: i.filter(
|
|
720
|
+
allowedFeatures: i.filter(y),
|
|
643
721
|
userId: a,
|
|
644
722
|
uuid: o,
|
|
645
723
|
sig: s
|
|
@@ -647,19 +725,19 @@ function q(e) {
|
|
|
647
725
|
}
|
|
648
726
|
//#endregion
|
|
649
727
|
//#region src/monetization.ts
|
|
650
|
-
var
|
|
728
|
+
var pe = () => window, Y = class {
|
|
651
729
|
cache;
|
|
652
730
|
sessionService;
|
|
653
731
|
pendingHasAccessRequests;
|
|
654
|
-
constructor({ clientId: e, redirectUri: t, env: n, sessionDomain: r, window: i =
|
|
655
|
-
|
|
656
|
-
let a =
|
|
657
|
-
this.cache = new s(() => i && i.sessionStorage), this.pendingHasAccessRequests = {}, r && (
|
|
732
|
+
constructor({ clientId: e, redirectUri: t, env: n, sessionDomain: r, window: i = pe() }) {
|
|
733
|
+
H(i), v(b(e), "clientId parameter is required"), v(y(n), `env parameter is invalid: ${n}`);
|
|
734
|
+
let a = P(n, e);
|
|
735
|
+
this.cache = new s(() => i && i.sessionStorage), this.pendingHasAccessRequests = {}, r && (v(C(r), "sessionDomain parameter is not a valid URL"), this.sessionService = F({
|
|
658
736
|
serverUrl: r,
|
|
659
737
|
defaultParams: {
|
|
660
738
|
client_sdrn: a,
|
|
661
739
|
redirect_uri: t,
|
|
662
|
-
sdk_version:
|
|
740
|
+
sdk_version: W
|
|
663
741
|
}
|
|
664
742
|
}));
|
|
665
743
|
}
|
|
@@ -669,7 +747,7 @@ var J = () => window, Y = class {
|
|
|
669
747
|
if (!Array.isArray(e)) throw new t("'productIds' must be an array");
|
|
670
748
|
let r = [...e].sort(), i = this.accessCacheKey(r, n), a = this.cache.get(i);
|
|
671
749
|
if (!a) {
|
|
672
|
-
this.pendingHasAccessRequests[i] || (this.pendingHasAccessRequests[i] = this.sessionService.get(`/hasAccess/${r.join(",")}`, void 0,
|
|
750
|
+
this.pendingHasAccessRequests[i] || (this.pendingHasAccessRequests[i] = this.sessionService.get(`/hasAccess/${r.join(",")}`, void 0, fe));
|
|
673
751
|
let e = this.pendingHasAccessRequests[i];
|
|
674
752
|
try {
|
|
675
753
|
a = await e;
|
|
@@ -691,113 +769,120 @@ var J = () => window, Y = class {
|
|
|
691
769
|
#e;
|
|
692
770
|
#t;
|
|
693
771
|
#n;
|
|
772
|
+
#r;
|
|
773
|
+
#i;
|
|
774
|
+
#a;
|
|
694
775
|
constructor(r) {
|
|
695
776
|
let i = n(r.window);
|
|
696
777
|
if (!i) throw new t("Schibsted Account SDK is not available in this browser context");
|
|
697
778
|
if (i.schAccount) throw new t("Schibsted Account SDK has already been initialized");
|
|
698
|
-
let { log: a, callbackBeforeRedirect: o,
|
|
779
|
+
let { log: a, callbackBeforeRedirect: o, getConsents: s, refreshLoginLinks: c = !0, defaultProductIds: l, varnish: u } = r, d = {
|
|
699
780
|
clientId: r.clientId,
|
|
700
781
|
redirectUri: r.redirectUri,
|
|
701
782
|
sessionDomain: r.sessionDomain,
|
|
702
783
|
env: r.env ?? "PRE",
|
|
703
784
|
window: i
|
|
704
785
|
};
|
|
705
|
-
if (this.#
|
|
706
|
-
...
|
|
786
|
+
if (v(typeof c == "boolean", "refreshLoginLinks parameter must be a boolean"), this.#i = new de({
|
|
787
|
+
...d,
|
|
707
788
|
log: a,
|
|
708
|
-
callbackBeforeRedirect: o
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
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() {
|
|
789
|
+
callbackBeforeRedirect: o,
|
|
790
|
+
getConsents: s
|
|
791
|
+
}), l !== void 0 && !Array.isArray(l)) throw new t("Account defaultProductIds config must be an array");
|
|
792
|
+
if (u && (typeof u != "object" || Array.isArray(u))) throw new t("Account varnish config must be an object");
|
|
793
|
+
u && this.#i.enableVarnishCookie(u), this.#a = new Y(d), this.#e = d.clientId, this.#t = d.env, this.#n = d.redirectUri, this.#r = l && Object.freeze([...l]);
|
|
794
|
+
let f = e.get(this.#i);
|
|
795
|
+
f && e.set(this, f), c && this.#i.enableLoginLinkRefresh(), i.schAccount = this, i.dispatchEvent(new CustomEvent("schAccount:ready", { detail: { instance: this } }));
|
|
796
|
+
}
|
|
797
|
+
get clientId() {
|
|
722
798
|
return this.#e;
|
|
723
799
|
}
|
|
800
|
+
get env() {
|
|
801
|
+
return this.#t;
|
|
802
|
+
}
|
|
803
|
+
get redirectUri() {
|
|
804
|
+
return this.#n;
|
|
805
|
+
}
|
|
806
|
+
get defaultProductIds() {
|
|
807
|
+
return this.#r;
|
|
808
|
+
}
|
|
724
809
|
hasSession() {
|
|
725
|
-
return this.#
|
|
810
|
+
return this.#i.hasSession();
|
|
726
811
|
}
|
|
727
812
|
isLoggedIn() {
|
|
728
|
-
return this.#
|
|
813
|
+
return this.#i.isLoggedIn();
|
|
729
814
|
}
|
|
730
815
|
isConnected() {
|
|
731
|
-
return this.#
|
|
816
|
+
return this.#i.isConnected();
|
|
732
817
|
}
|
|
733
818
|
getUser() {
|
|
734
|
-
return this.#
|
|
819
|
+
return this.#i.getUser();
|
|
735
820
|
}
|
|
736
821
|
getUserId() {
|
|
737
|
-
return this.#
|
|
822
|
+
return this.#i.getUserId();
|
|
738
823
|
}
|
|
739
824
|
getExternalId(e, t = "") {
|
|
740
|
-
return this.#
|
|
825
|
+
return this.#i.getExternalId(e, t);
|
|
741
826
|
}
|
|
742
827
|
getUserUuid() {
|
|
743
|
-
return this.#
|
|
828
|
+
return this.#i.getUserUuid();
|
|
744
829
|
}
|
|
745
830
|
getUserSDRN() {
|
|
746
|
-
return this.#
|
|
831
|
+
return this.#i.getUserSDRN();
|
|
747
832
|
}
|
|
748
833
|
getUserContextData() {
|
|
749
|
-
return this.#
|
|
834
|
+
return this.#i.getUserContextData();
|
|
750
835
|
}
|
|
751
836
|
getSpId() {
|
|
752
|
-
return this.#
|
|
837
|
+
return this.#i.getSpId();
|
|
753
838
|
}
|
|
754
839
|
login(e) {
|
|
755
|
-
return this.#
|
|
840
|
+
return this.#i.login(e);
|
|
756
841
|
}
|
|
757
842
|
logout(e) {
|
|
758
|
-
this.#
|
|
843
|
+
this.#i.logout(e);
|
|
759
844
|
}
|
|
760
845
|
loginUrl(e) {
|
|
761
|
-
return this.#
|
|
846
|
+
return this.#i.loginUrl(e);
|
|
762
847
|
}
|
|
763
848
|
logoutUrl(e) {
|
|
764
|
-
return this.#
|
|
849
|
+
return this.#i.logoutUrl(e);
|
|
765
850
|
}
|
|
766
851
|
accountUrl(e) {
|
|
767
|
-
return this.#
|
|
852
|
+
return this.#i.accountUrl(e);
|
|
768
853
|
}
|
|
769
854
|
showSimplifiedLoginWidget(e, t) {
|
|
770
|
-
return this.#
|
|
855
|
+
return this.#i.showSimplifiedLoginWidget(e, t);
|
|
771
856
|
}
|
|
772
857
|
setSessionCachingEnabled(e) {
|
|
773
|
-
this.#
|
|
858
|
+
this.#i.setSessionCachingEnabled(e);
|
|
774
859
|
}
|
|
775
860
|
clearCachedUserSession() {
|
|
776
|
-
this.#
|
|
861
|
+
this.#i.clearCachedUserSession();
|
|
777
862
|
}
|
|
778
|
-
async hasAccess(e = this.#
|
|
863
|
+
async hasAccess(e = this.#r) {
|
|
779
864
|
if (!e) throw new t("hasAccess requires productIds or defaultProductIds in the Account config");
|
|
780
865
|
if (e.length === 0) return null;
|
|
781
|
-
let n = await this.#
|
|
782
|
-
return this.#
|
|
866
|
+
let n = await this.#i.getUserId();
|
|
867
|
+
return this.#a.hasAccess(e, n);
|
|
783
868
|
}
|
|
784
869
|
clearCachedAccessResult(e, t) {
|
|
785
|
-
this.#
|
|
870
|
+
this.#a.clearCachedAccessResult(e, t);
|
|
786
871
|
}
|
|
787
872
|
on(e, t) {
|
|
788
|
-
return this.#
|
|
873
|
+
return this.#i.addEventListener(e, t), this;
|
|
789
874
|
}
|
|
790
875
|
off(e, t) {
|
|
791
|
-
return this.#
|
|
876
|
+
return this.#i.removeEventListener(e, t), this;
|
|
792
877
|
}
|
|
793
|
-
}, Z = "schAccount:ready", Q = 4e3, $,
|
|
794
|
-
function
|
|
878
|
+
}, Z = "schAccount:ready", Q = 4e3, $, me = () => /* @__PURE__ */ Error("Schibsted Account SDK is not available in this browser context"), he = () => /* @__PURE__ */ Error(`Schibsted Account SDK was not initialized within ${Q} ms`);
|
|
879
|
+
function ge(e) {
|
|
795
880
|
return new X(e);
|
|
796
881
|
}
|
|
797
|
-
function
|
|
882
|
+
function _e() {
|
|
798
883
|
let e = n();
|
|
799
884
|
if (!e) {
|
|
800
|
-
let e =
|
|
885
|
+
let e = me();
|
|
801
886
|
return console.error(e.message), Promise.reject(e);
|
|
802
887
|
}
|
|
803
888
|
return e.schAccount ? Promise.resolve(e.schAccount) : $ || ($ = new Promise((t, n) => {
|
|
@@ -808,12 +893,12 @@ function se() {
|
|
|
808
893
|
n && (i(), t(n));
|
|
809
894
|
};
|
|
810
895
|
e.addEventListener(Z, a), r = e.setTimeout(() => {
|
|
811
|
-
let e =
|
|
896
|
+
let e = he();
|
|
812
897
|
console.error(e.message), i(), n(e);
|
|
813
898
|
}, Q), a();
|
|
814
899
|
}), $);
|
|
815
900
|
}
|
|
816
901
|
//#endregion
|
|
817
|
-
export { X as Account, t as SDKError,
|
|
902
|
+
export { X as Account, t as SDKError, ge as createAccountSdk, _e as getAccountSdk, L as isConnectedSessionResponse, B as isConnectedSessionWithUserIdResponse, R as isSessionFailureResponse, I as isSessionSuccessResponse };
|
|
818
903
|
|
|
819
904
|
//# sourceMappingURL=index.js.map
|