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

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