@schibsted/account-sdk-browser 6.0.0-alpha.5 → 6.0.0-alpha.7

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