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