@schibsted/account-sdk-browser 5.2.7 → 6.0.0-alpha.2
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 +12 -59
- package/dist/RESTClient.d.ts +91 -0
- package/dist/SDKError.d.ts +27 -0
- package/dist/cache.d.ts +65 -0
- package/dist/config.d.ts +86 -0
- package/dist/global-registry.d.ts +23 -0
- package/dist/globals.d.ts +13 -0
- package/dist/identity-s4nofYmB.js +370 -0
- package/dist/identity-s4nofYmB.js.map +1 -0
- package/dist/identity.d.ts +523 -0
- package/dist/identity.js +2 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +4 -0
- package/dist/monetization.d.ts +94 -0
- package/dist/monetization.js +72 -0
- package/dist/monetization.js.map +1 -0
- package/{src → dist}/object.d.ts +4 -9
- package/dist/popup.d.ts +9 -0
- package/{src → dist}/spidTalk.d.ts +4 -6
- package/dist/url.d.ts +8 -0
- package/dist/validate.d.ts +50 -0
- package/dist/version-spE-k97g.js +289 -0
- package/dist/version-spE-k97g.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/package.json +42 -49
- package/src/RESTClient.ts +226 -0
- package/src/SDKError.ts +59 -0
- package/src/{cache.js → cache.ts} +52 -37
- package/src/{config.js → config.ts} +7 -32
- package/src/global-registry.ts +39 -0
- package/src/globals.ts +10 -0
- package/src/{identity.js → identity.ts} +536 -437
- package/{index.js → src/index.ts} +1 -3
- package/src/{monetization.js → monetization.ts} +77 -48
- package/src/{object.js → object.ts} +8 -15
- package/src/popup.ts +74 -0
- package/src/{spidTalk.js → spidTalk.ts} +10 -12
- package/src/{url.js → url.ts} +6 -10
- package/src/{validate.js → validate.ts} +26 -42
- package/src/{version.js → version.ts} +1 -2
- package/es5/global.js +0 -12968
- package/es5/global.js.map +0 -1
- package/es5/global.min.js +0 -2
- package/es5/global.min.js.map +0 -1
- package/es5/identity.js +0 -12212
- package/es5/identity.js.map +0 -1
- package/es5/identity.min.js +0 -2
- package/es5/identity.min.js.map +0 -1
- package/es5/index.js +0 -12940
- package/es5/index.js.map +0 -1
- package/es5/index.min.js +0 -2
- package/es5/index.min.js.map +0 -1
- package/es5/monetization.js +0 -9176
- package/es5/monetization.js.map +0 -1
- package/es5/monetization.min.js +0 -2
- package/es5/monetization.min.js.map +0 -1
- package/es5/payment.js +0 -8853
- package/es5/payment.js.map +0 -1
- package/es5/payment.min.js +0 -2
- package/es5/payment.min.js.map +0 -1
- package/identity.d.ts +0 -1
- package/identity.js +0 -5
- package/index.d.ts +0 -4
- package/monetization.d.ts +0 -1
- package/monetization.js +0 -5
- package/payment.d.ts +0 -1
- package/payment.js +0 -5
- package/src/RESTClient.d.ts +0 -89
- package/src/RESTClient.js +0 -193
- package/src/SDKError.d.ts +0 -16
- package/src/SDKError.js +0 -55
- package/src/__mocks__/.eslintrc.yml +0 -8
- package/src/__mocks__/RESTClient.js +0 -54
- package/src/cache.d.ts +0 -64
- package/src/config.d.ts +0 -34
- package/src/es5/global.js +0 -13
- package/src/es5/identity.js +0 -10
- package/src/es5/index.js +0 -13
- package/src/es5/monetization.js +0 -10
- package/src/es5/payment.js +0 -10
- package/src/global-registry.js +0 -20
- package/src/identity.d.ts +0 -679
- package/src/monetization.d.ts +0 -80
- package/src/payment.d.ts +0 -115
- package/src/payment.js +0 -211
- package/src/popup.d.ts +0 -10
- package/src/popup.js +0 -59
- package/src/url.d.ts +0 -10
- package/src/validate.d.ts +0 -64
- package/src/version.d.ts +0 -2
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { _ as e, d as t, g as n, h as r, i, l as a, m as o, n as s, p as c, r as l, s as u, t as d, v as f, y as p } from "./version-spE-k97g.js";
|
|
2
|
+
//#region src/monetization.ts
|
|
3
|
+
var m = p(), h = () => window, g = class extends m.TinyEmitter {
|
|
4
|
+
cache;
|
|
5
|
+
clientId;
|
|
6
|
+
env;
|
|
7
|
+
redirectUri;
|
|
8
|
+
_spid;
|
|
9
|
+
_sessionService;
|
|
10
|
+
pendingHasAccessRequests;
|
|
11
|
+
constructor({ clientId: t, redirectUri: n, env: r = "PRE", sessionDomain: i, window: l = h() }) {
|
|
12
|
+
super(), s(l), u(a(t), "clientId parameter is required"), this.cache = new e(() => l && l.sessionStorage), this.clientId = t, this.env = r, this.redirectUri = n, this.pendingHasAccessRequests = {}, this._setSpidServerUrl(r), i && (u(c(i), "sessionDomain parameter is not a valid URL"), this._setSessionServiceUrl(i)), o(l, "schMonetization", this);
|
|
13
|
+
}
|
|
14
|
+
_setSpidServerUrl(e) {
|
|
15
|
+
u(t(e), `url parameter is invalid: ${e}`), this._spid = new l({
|
|
16
|
+
serverUrl: i(e, r.SPiD),
|
|
17
|
+
defaultParams: {
|
|
18
|
+
client_id: this.clientId,
|
|
19
|
+
redirect_uri: this.redirectUri
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
_setSessionServiceUrl(e) {
|
|
24
|
+
u(t(e), `domain parameter is invalid: ${e}`);
|
|
25
|
+
let r = `sdrn:${n[this.env]}:client:${this.clientId}`;
|
|
26
|
+
this._sessionService = new l({
|
|
27
|
+
serverUrl: e,
|
|
28
|
+
defaultParams: {
|
|
29
|
+
client_sdrn: r,
|
|
30
|
+
redirect_uri: this.redirectUri,
|
|
31
|
+
sdk_version: d
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
async hasAccess(e, t) {
|
|
36
|
+
if (!this._sessionService) throw new f("hasAccess can only be called if 'sessionDomain' is configured");
|
|
37
|
+
if (!t) throw new f("'userId' must be specified");
|
|
38
|
+
if (!Array.isArray(e)) throw new f("'productIds' must be an array");
|
|
39
|
+
let n = [...e].sort(), r = this._accessCacheKey(n, t), i = this.cache.get(r);
|
|
40
|
+
if (!i) {
|
|
41
|
+
this.pendingHasAccessRequests[r] || (this.pendingHasAccessRequests[r] = this._sessionService.get(`/hasAccess/${n.join(",")}`));
|
|
42
|
+
let e = this.pendingHasAccessRequests[r];
|
|
43
|
+
try {
|
|
44
|
+
i = await e;
|
|
45
|
+
let t = i.ttl;
|
|
46
|
+
this.cache.set(r, i, t * 1e3);
|
|
47
|
+
} finally {
|
|
48
|
+
this.pendingHasAccessRequests[r] === e && delete this.pendingHasAccessRequests[r];
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return i.entitled ? (this.emit("hasAccess", {
|
|
52
|
+
ids: n,
|
|
53
|
+
data: i
|
|
54
|
+
}), i) : null;
|
|
55
|
+
}
|
|
56
|
+
clearCachedAccessResult(e, t) {
|
|
57
|
+
this.cache.delete(this._accessCacheKey(e, t));
|
|
58
|
+
}
|
|
59
|
+
_accessCacheKey(e, t) {
|
|
60
|
+
return `prd_${[...e].sort()}_${t}`;
|
|
61
|
+
}
|
|
62
|
+
subscriptionsUrl(e = this.redirectUri) {
|
|
63
|
+
return u(c(e), "subscriptionsUrl(): redirectUri is invalid"), this._spid.makeUrl("account/subscriptions", { redirect_uri: e });
|
|
64
|
+
}
|
|
65
|
+
productsUrl(e = this.redirectUri) {
|
|
66
|
+
return u(c(e), "productsUrl(): redirectUri is invalid"), this._spid.makeUrl("account/products", { redirect_uri: e });
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
//#endregion
|
|
70
|
+
export { g as Monetization, g as default };
|
|
71
|
+
|
|
72
|
+
//# sourceMappingURL=monetization.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"monetization.js","names":[],"sources":["../src/monetization.ts"],"sourcesContent":["/* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.\n * See LICENSE.md in the project root.\n */\n\nimport { TinyEmitter } from 'tiny-emitter';\nimport Cache from './cache.js';\nimport { ENDPOINTS, NAMESPACE } from './config.js';\nimport { registerAndDispatchInGlobal } from './global-registry.js';\nimport RESTClient from './RESTClient.js';\nimport SDKError from './SDKError.js';\nimport * as spidTalk from './spidTalk.js';\nimport { urlMapper } from './url.js';\nimport { assert, isNonEmptyString, isStr, isUrl } from './validate.js';\nimport version from './version.js';\n\nconst globalWindow = () => window;\n\n/**\n * Result returned by the Session Service `/hasAccess` endpoint, describing whether the user\n * is entitled to a requested set of products/features.\n * @internal\n */\nexport interface HasAccessResult {\n /** Whether the user is entitled to at least one of the requested products/features. */\n entitled: boolean;\n /** How long this result stays valid, in seconds, before the cache entry expires. */\n ttl: number;\n allowedFeatures: string[];\n userId: number;\n uuid: string;\n sig: string;\n}\n\n/**\n * Provides features related to monetization\n */\nexport class Monetization extends TinyEmitter {\n cache: Cache;\n clientId: string;\n env: string;\n redirectUri: string;\n _spid!: RESTClient;\n _sessionService?: RESTClient;\n private pendingHasAccessRequests: Record<string, Promise<HasAccessResult>>;\n\n /**\n * @param options - Monetization configuration\n * @throws {SDKError} - If any of options are invalid\n */\n constructor({\n clientId,\n redirectUri,\n env = 'PRE',\n sessionDomain,\n window = globalWindow(),\n }: {\n /** Mandatory client id */\n clientId: string;\n /** Redirect uri */\n redirectUri: string;\n /** Example: `\"https://id.site.com\"` */\n sessionDomain: string;\n /** Schibsted account environment: `PRE` (default), `PRO`, `PRO_NO` */\n env?: string;\n /** Window object to use (defaults to the global `window`). */\n window?: Window;\n }) {\n super();\n spidTalk.emulate(window);\n assert(isNonEmptyString(clientId), 'clientId parameter is required');\n\n this.cache = new Cache(() => window && window.sessionStorage);\n this.clientId = clientId;\n this.env = env;\n this.redirectUri = redirectUri;\n this.pendingHasAccessRequests = {};\n this._setSpidServerUrl(env);\n\n if (sessionDomain) {\n assert(isUrl(sessionDomain), 'sessionDomain parameter is not a valid URL');\n this._setSessionServiceUrl(sessionDomain);\n }\n registerAndDispatchInGlobal(window, 'schMonetization', this);\n }\n\n /**\n * Set SPiD server URL\n * @private\n * @param url\n */\n private _setSpidServerUrl(url: string): void {\n assert(isStr(url), `url parameter is invalid: ${url}`);\n this._spid = new RESTClient({\n serverUrl: urlMapper(url, ENDPOINTS.SPiD),\n defaultParams: { client_id: this.clientId, redirect_uri: this.redirectUri },\n });\n }\n\n /**\n * Set session-service domain\n * @private\n * @param domain - real URL — (**not** 'PRE' style env key)\n */\n private _setSessionServiceUrl(domain: string): void {\n assert(isStr(domain), `domain parameter is invalid: ${domain}`);\n const client_sdrn = `sdrn:${NAMESPACE[this.env as keyof typeof NAMESPACE]}:client:${this.clientId}`;\n this._sessionService = new RESTClient({\n serverUrl: domain,\n defaultParams: { client_sdrn, redirect_uri: this.redirectUri, sdk_version: version },\n });\n }\n\n /**\n * Checks if the user has access to a set of products or features.\n * @param productIds - which products/features to check\n * @param userId - id of currently logged in user\n * @throws {SDKError} - If the input is incorrect, or a network call fails in any way\n * (this will happen if, say, the user is not logged in)\n * @returns The data object returned from Schibsted account (or `null` if the user\n * doesn't have access to any of the given products/features)\n */\n async hasAccess(productIds: string[], userId: number): Promise<HasAccessResult | null> {\n if (!this._sessionService) {\n throw new SDKError(`hasAccess can only be called if 'sessionDomain' is configured`);\n }\n if (!userId) {\n throw new SDKError(`'userId' must be specified`);\n }\n if (!Array.isArray(productIds)) {\n throw new SDKError(`'productIds' must be an array`);\n }\n\n const sortedIds = [...productIds].sort();\n const cacheKey = this._accessCacheKey(sortedIds, userId);\n let data = this.cache.get(cacheKey) as HasAccessResult | null;\n if (!data) {\n if (!this.pendingHasAccessRequests[cacheKey]) {\n this.pendingHasAccessRequests[cacheKey] = this._sessionService.get(\n `/hasAccess/${sortedIds.join(',')}`,\n );\n }\n const promise = this.pendingHasAccessRequests[cacheKey];\n try {\n data = await promise;\n const expiresSeconds = data.ttl;\n this.cache.set(cacheKey, data, expiresSeconds * 1000);\n } finally {\n if (this.pendingHasAccessRequests[cacheKey] === promise) {\n delete this.pendingHasAccessRequests[cacheKey];\n }\n }\n }\n\n if (!data.entitled) {\n return null;\n }\n this.emit('hasAccess', { ids: sortedIds, data });\n return data;\n }\n\n /**\n * Removes the cached access result.\n * @param productIds - which products/features to check\n * @param userId - id of currently logged in user\n */\n clearCachedAccessResult(productIds: string[], userId: number): void {\n this.cache.delete(this._accessCacheKey(productIds, userId));\n }\n\n /**\n * Compute \"has access\" cache key for the given product ids and user id.\n * @private\n * @param productIds - which products/features to check\n * @param userId - id of currently logged in user\n */\n private _accessCacheKey(productIds: string[], userId: number): string {\n return `prd_${[...productIds].sort()}_${userId}`;\n }\n\n /**\n * Get the url for the end user to review the subscriptions\n * @param redirectUri\n * @returns - The url to the subscriptions review page\n */\n subscriptionsUrl(redirectUri: string = this.redirectUri): string {\n assert(isUrl(redirectUri), `subscriptionsUrl(): redirectUri is invalid`);\n return this._spid.makeUrl('account/subscriptions', { redirect_uri: redirectUri });\n }\n\n /**\n * Get the url for the end user to review the products\n * @param redirectUri\n * @returns - The url to the products review page\n */\n productsUrl(redirectUri: string = this.redirectUri): string {\n assert(isUrl(redirectUri), `productsUrl(): redirectUri is invalid`);\n return this._spid.makeUrl('account/products', { redirect_uri: redirectUri });\n }\n}\n\nexport default Monetization;\n"],"mappings":";;aAeM,UAAqB,QAqBd,IAAb,cAAkC,EAAA,YAAY;CAC1C;CACA;CACA;CACA;CACA;CACA;CACA;CAMA,YAAY,EACR,aACA,gBACA,SAAM,OACN,kBACA,YAAS,EAAa,KAYvB;EAgBC,AAfA,MAAM,GACN,EAAiB,CAAM,GACvB,EAAO,EAAiB,CAAQ,GAAG,gCAAgC,GAEnE,KAAK,QAAQ,IAAI,QAAY,KAAU,EAAO,cAAc,GAC5D,KAAK,WAAW,GAChB,KAAK,MAAM,GACX,KAAK,cAAc,GACnB,KAAK,2BAA2B,CAAC,GACjC,KAAK,kBAAkB,CAAG,GAEtB,MACA,EAAO,EAAM,CAAa,GAAG,4CAA4C,GACzE,KAAK,sBAAsB,CAAa,IAE5C,EAA4B,GAAQ,mBAAmB,IAAI;CAC/D;CAOA,kBAA0B,GAAmB;EAEzC,AADA,EAAO,EAAM,CAAG,GAAG,6BAA6B,GAAK,GACrD,KAAK,QAAQ,IAAI,EAAW;GACxB,WAAW,EAAU,GAAK,EAAU,IAAI;GACxC,eAAe;IAAE,WAAW,KAAK;I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E,GAAG;CAC5C;CAOA,iBAAiB,IAAsB,KAAK,aAAqB;EAE7D,OADA,EAAO,EAAM,CAAW,GAAG,4CAA4C,GAChE,KAAK,MAAM,QAAQ,yBAAyB,EAAE,cAAc,EAAY,CAAC;CACpF;CAOA,YAAY,IAAsB,KAAK,aAAqB;EAExD,OADA,EAAO,EAAM,CAAW,GAAG,uCAAuC,GAC3D,KAAK,MAAM,QAAQ,oBAAoB,EAAE,cAAc,EAAY,CAAC;CAC/E;AACJ"}
|
package/{src → dist}/object.d.ts
RENAMED
|
@@ -3,23 +3,18 @@
|
|
|
3
3
|
* values.
|
|
4
4
|
* Please note that the values in the rightmost parameters can overwrite the values of the earlier
|
|
5
5
|
* parameters so the order of the parameters matters.
|
|
6
|
-
* @memberof core
|
|
7
6
|
* @example
|
|
8
7
|
* cloneDefined({foo: 1, bar: 2}, {foo: 2}) // returns {foo: 2, bar: 2}
|
|
9
8
|
*
|
|
10
|
-
* @param
|
|
9
|
+
* @param sources - one or more sources. Their defined properties will override the ones
|
|
11
10
|
* that came before it. For example if `source1.foo = 'bar'` and `source2.foo = 'baz'`, the
|
|
12
11
|
* result will include `{ foo: 'baz' }`
|
|
13
|
-
* @return {object} a new object that is similar to src with all the key/values where the
|
|
14
|
-
* keys for undefined values are removed.
|
|
15
12
|
*/
|
|
16
|
-
export function cloneDefined(...sources:
|
|
13
|
+
export declare function cloneDefined(...sources: object[]): Record<string, unknown>;
|
|
17
14
|
/**
|
|
18
15
|
* Deep copies an object. This is handy for immutability.
|
|
19
|
-
* @
|
|
20
|
-
* @param {object} obj - An object, array or null.
|
|
21
|
-
* @return {object} - an exact copy of the object but deep copied
|
|
16
|
+
* @param obj - An object, array or null.
|
|
22
17
|
* @throws {SDKError} - if the obj is not an accepted type or is not
|
|
23
18
|
* stringifiable by JSON for example if it has loops
|
|
24
19
|
*/
|
|
25
|
-
export function cloneDeep(obj:
|
|
20
|
+
export declare function cloneDeep<T extends object | null>(obj: T): T;
|
package/dist/popup.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Opens a popup
|
|
3
|
+
* @param parentWindow - A reference to the window that will open the popup
|
|
4
|
+
* @param url - The URL that the popup will open
|
|
5
|
+
* @param windowName - A name for the window
|
|
6
|
+
* @param windowFeatures - Window features for the popup (default ones are usually ok)
|
|
7
|
+
* @private
|
|
8
|
+
*/
|
|
9
|
+
export declare function open(parentWindow: Window, url: string, windowName?: string, windowFeatures?: Record<string, string | number>): Window | null;
|
|
@@ -7,10 +7,8 @@
|
|
|
7
7
|
* The old SPiD JSONP APIs relied on SPiD.Talk.response(callbackName, data) but fetch-jsonp merely
|
|
8
8
|
* calls window[callbackName](data) which is more common practice. This module simply acts as an
|
|
9
9
|
* adapter to modernize the old mechanism until we support CORS. To see how the SPiD solution works,
|
|
10
|
-
* try to run a simple JSONP request or debug it in
|
|
11
|
-
* CORS is supported.
|
|
12
|
-
* @
|
|
13
|
-
* @param {object} global - a reference to the global object
|
|
14
|
-
* @return {void}
|
|
10
|
+
* try to run a simple JSONP request or debug it in the network tab. This module will be removed
|
|
11
|
+
* when CORS is supported.
|
|
12
|
+
* @param global - A reference to the global object, typically the `Window`.
|
|
15
13
|
*/
|
|
16
|
-
export function emulate(global:
|
|
14
|
+
export declare function emulate(global: Window): void;
|
package/dist/url.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A simple utility function that allows looking up URLs from a dictionary
|
|
3
|
+
* @param url - A url like http://example.com, or a key used for lookup
|
|
4
|
+
* @param urlMap - A map of URLs like `{ DEV: 'http://dev.example.com' }`
|
|
5
|
+
* @returns The resolved URL: the mapped value when `url` is a known key, otherwise `url` itself
|
|
6
|
+
* @throws {SDKError} - If the url is not a string or is an empty string
|
|
7
|
+
*/
|
|
8
|
+
export declare function urlMapper(url: string, urlMap: Record<string, string>): string;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A utility function that throws an SDKError if an assertion fails. It's mostly useful for
|
|
3
|
+
* validating function inputs.
|
|
4
|
+
*
|
|
5
|
+
* Narrows `condition` for the rest of the enclosing scope (TypeScript assertion signature).
|
|
6
|
+
* @param condition - The condition that we're asserting
|
|
7
|
+
* @param message - The error message
|
|
8
|
+
* @throws {SDKError} - If the condition is falsy it throws the appropriate error
|
|
9
|
+
*/
|
|
10
|
+
export declare function assert(condition: boolean, message?: string): asserts condition;
|
|
11
|
+
/**
|
|
12
|
+
* Checks if a value is a string or not
|
|
13
|
+
* @param value - The value to check
|
|
14
|
+
*/
|
|
15
|
+
export declare function isStr(value: unknown): value is string;
|
|
16
|
+
/**
|
|
17
|
+
* Checks if a value is a non-empty string
|
|
18
|
+
* @param value - The value to check
|
|
19
|
+
*/
|
|
20
|
+
export declare function isNonEmptyString(value: unknown): value is string;
|
|
21
|
+
/**
|
|
22
|
+
* checks if a given value is an object (but not null)
|
|
23
|
+
* @param value - The value to check
|
|
24
|
+
*/
|
|
25
|
+
export declare function isObject(value: unknown): value is Record<string, unknown>;
|
|
26
|
+
/**
|
|
27
|
+
* Checks if a given value is an object with at least one own key
|
|
28
|
+
* @param value - The value to check
|
|
29
|
+
*/
|
|
30
|
+
export declare function isNonEmptyObj(value: unknown): value is Record<string, unknown>;
|
|
31
|
+
/**
|
|
32
|
+
* Checks if a given string is a valid URL
|
|
33
|
+
* @param value - The string to be tested
|
|
34
|
+
* @param mandatoryFields - A list of mandatory fields that should exist in the parsed
|
|
35
|
+
* `URL` object
|
|
36
|
+
*/
|
|
37
|
+
export declare function isUrl(value: string, ...mandatoryFields: (keyof URL)[]): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Checks if a given value is a function
|
|
40
|
+
* @param value - The value to check
|
|
41
|
+
*/
|
|
42
|
+
export declare function isFunction(value: unknown): value is (...args: unknown[]) => unknown;
|
|
43
|
+
/**
|
|
44
|
+
* Checks if a string matches any of the strings in a set of possibilities
|
|
45
|
+
* @param value
|
|
46
|
+
* @param possibilities - An array of strings that'll be used to check the string
|
|
47
|
+
* inclusion. Note that for performance reasons, we don't validate this parameter.
|
|
48
|
+
* @param caseSensitive - Should the check be case sensitive
|
|
49
|
+
*/
|
|
50
|
+
export declare function isStrIn(value: string, possibilities: string[], caseSensitive?: boolean): boolean;
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
//#endregion
|
|
2
|
+
//#region node_modules/tiny-emitter/index.js
|
|
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 = [
|
|
31
|
+
"boolean",
|
|
32
|
+
"number",
|
|
33
|
+
"string"
|
|
34
|
+
], n = class extends Error {
|
|
35
|
+
code;
|
|
36
|
+
constructor(e, t) {
|
|
37
|
+
if (super(e), this.name = "SDKError", t) try {
|
|
38
|
+
Object.assign(this, t);
|
|
39
|
+
} catch {}
|
|
40
|
+
}
|
|
41
|
+
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;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/cache.ts
|
|
48
|
+
function r(e) {
|
|
49
|
+
if (!e) return !1;
|
|
50
|
+
try {
|
|
51
|
+
let t = e(), n = "x-x-x-x".replace(/x/g, () => String(Math.random())), r = "TEST-VALUE";
|
|
52
|
+
t.setItem(n, r);
|
|
53
|
+
let i = t.getItem(n);
|
|
54
|
+
return t.removeItem(n), i === r;
|
|
55
|
+
} catch {
|
|
56
|
+
return !1;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
var i = class {
|
|
60
|
+
store;
|
|
61
|
+
get;
|
|
62
|
+
set;
|
|
63
|
+
delete;
|
|
64
|
+
constructor(e) {
|
|
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);
|
|
66
|
+
}
|
|
67
|
+
}, a = class {
|
|
68
|
+
store;
|
|
69
|
+
get;
|
|
70
|
+
set;
|
|
71
|
+
delete;
|
|
72
|
+
constructor() {
|
|
73
|
+
this.store = {}, this.get = (e) => this.store[e], this.set = (e, t) => {
|
|
74
|
+
this.store[e] = t;
|
|
75
|
+
}, this.delete = (e) => {
|
|
76
|
+
delete this.store[e];
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}, o = 2 ** 31 - 1, s = class {
|
|
80
|
+
cache;
|
|
81
|
+
type;
|
|
82
|
+
constructor(e) {
|
|
83
|
+
e && r(e) ? (this.cache = new i(e()), this.type = "WebStorage") : (this.cache = new a(), this.type = "ObjectLiteralStorage");
|
|
84
|
+
}
|
|
85
|
+
get(e) {
|
|
86
|
+
function t(e) {
|
|
87
|
+
if (e == null) return null;
|
|
88
|
+
try {
|
|
89
|
+
return JSON.parse(e);
|
|
90
|
+
} catch {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
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);
|
|
97
|
+
} catch (e) {
|
|
98
|
+
throw new n(String(e));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
set(e, t, r = 0) {
|
|
102
|
+
if (!(r <= 0)) {
|
|
103
|
+
r = Math.min(o, r);
|
|
104
|
+
try {
|
|
105
|
+
let n = Math.floor(Date.now() + r);
|
|
106
|
+
this.cache.set(e, JSON.stringify({
|
|
107
|
+
expiresOn: n,
|
|
108
|
+
value: t
|
|
109
|
+
})), setTimeout(() => this.delete(e), r);
|
|
110
|
+
} catch (e) {
|
|
111
|
+
throw new n(String(e));
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
delete(e) {
|
|
116
|
+
try {
|
|
117
|
+
this.cache.delete(e);
|
|
118
|
+
} catch (e) {
|
|
119
|
+
throw new n(String(e));
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}, c = {
|
|
123
|
+
ENDPOINTS: {
|
|
124
|
+
SPiD: {
|
|
125
|
+
LOCAL: "http://id.localhost",
|
|
126
|
+
DEV: "https://identity-dev.schibsted.com",
|
|
127
|
+
PRE: "https://identity-pre.schibsted.com",
|
|
128
|
+
PRO: "https://login.schibsted.com",
|
|
129
|
+
PRO_NO: "https://payment.schibsted.no",
|
|
130
|
+
PRO_FI: "https://login.schibsted.fi",
|
|
131
|
+
PRO_DK: "https://login.schibsted.dk"
|
|
132
|
+
},
|
|
133
|
+
BFF: {
|
|
134
|
+
LOCAL: "http://id.localhost/authn/",
|
|
135
|
+
DEV: "https://identity-dev.schibsted.com/authn/",
|
|
136
|
+
PRE: "https://identity-pre.schibsted.com/authn/",
|
|
137
|
+
PRO: "https://login.schibsted.com/authn/",
|
|
138
|
+
PRO_NO: "https://payment.schibsted.no/authn/",
|
|
139
|
+
PRO_FI: "https://login.schibsted.fi/authn/",
|
|
140
|
+
PRO_DK: "https://login.schibsted.dk/authn/"
|
|
141
|
+
},
|
|
142
|
+
SESSION_SERVICE: {
|
|
143
|
+
LOCAL: "http://session-service.id.localhost",
|
|
144
|
+
DEV: "https://session-service.identity-dev.schibsted.com",
|
|
145
|
+
PRE: "https://session-service.identity-pre.schibsted.com",
|
|
146
|
+
PRO: "https://session-service.login.schibsted.com",
|
|
147
|
+
PRO_NO: "https://session-service.payment.schibsted.no",
|
|
148
|
+
PRO_FI: "https://session-service.login.schibsted.fi",
|
|
149
|
+
PRO_DK: "https://session-service.login.schibsted.dk"
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
NAMESPACE: {
|
|
153
|
+
LOCAL: "id.localhost",
|
|
154
|
+
DEV: "schibsted.com",
|
|
155
|
+
PRE: "schibsted.com",
|
|
156
|
+
PRO: "schibsted.com",
|
|
157
|
+
PRO_NO: "spid.no",
|
|
158
|
+
PRO_FI: "schibsted.fi",
|
|
159
|
+
PRO_DK: "schibsted.dk"
|
|
160
|
+
}
|
|
161
|
+
}, l = c.ENDPOINTS, u = c.NAMESPACE, d = (e, t, n) => {
|
|
162
|
+
e[t] || (e[t] = n), e.dispatchEvent(new CustomEvent(`${t}:ready`, { detail: { instance: e[t] } }));
|
|
163
|
+
};
|
|
164
|
+
//#endregion
|
|
165
|
+
//#region src/validate.ts
|
|
166
|
+
function f(e, t = "Assertion failed") {
|
|
167
|
+
if (!e) throw new n(t);
|
|
168
|
+
}
|
|
169
|
+
function p(e) {
|
|
170
|
+
return typeof e == "string";
|
|
171
|
+
}
|
|
172
|
+
function m(e) {
|
|
173
|
+
return typeof e == "string" && e.length > 0;
|
|
174
|
+
}
|
|
175
|
+
function h(e) {
|
|
176
|
+
return typeof e == "object" && !!e;
|
|
177
|
+
}
|
|
178
|
+
function g(e) {
|
|
179
|
+
return h(e) && Object.keys(e).length > 0;
|
|
180
|
+
}
|
|
181
|
+
function _(e, ...t) {
|
|
182
|
+
try {
|
|
183
|
+
let n = new URL(e);
|
|
184
|
+
return t.every((e) => n[e]);
|
|
185
|
+
} catch {
|
|
186
|
+
return !1;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
function v(e) {
|
|
190
|
+
return typeof e == "function";
|
|
191
|
+
}
|
|
192
|
+
function y(e, t, n = !1) {
|
|
193
|
+
return p(e) && Array.isArray(t) ? n ? t.indexOf(e) !== -1 : t.some((t) => p(t) && e.toUpperCase() === t.toUpperCase()) : !1;
|
|
194
|
+
}
|
|
195
|
+
//#endregion
|
|
196
|
+
//#region src/object.ts
|
|
197
|
+
function b(...e) {
|
|
198
|
+
let t = {};
|
|
199
|
+
if (!(e && e.length)) throw new n("No objects to clone");
|
|
200
|
+
return e.forEach((e) => {
|
|
201
|
+
f(h(e)), g(e) && Object.entries(e).forEach(([e, n]) => {
|
|
202
|
+
n !== void 0 && (t[e] = h(n) ? x(n) : n);
|
|
203
|
+
});
|
|
204
|
+
}), t;
|
|
205
|
+
}
|
|
206
|
+
function x(e) {
|
|
207
|
+
return f(typeof e == "object", `obj should be an object (even null) but it is ${e}`), JSON.parse(JSON.stringify(e)) || e;
|
|
208
|
+
}
|
|
209
|
+
//#endregion
|
|
210
|
+
//#region src/url.ts
|
|
211
|
+
function S(e, t) {
|
|
212
|
+
return f(m(e), `"url" param must be a non empty string: ${typeof e}`), g(t) && _(t[e]) ? t[e] : (f(_(e, "hostname"), `Bad URL given: '${e}'`), e);
|
|
213
|
+
}
|
|
214
|
+
//#endregion
|
|
215
|
+
//#region src/RESTClient.ts
|
|
216
|
+
var C = (e) => e.map((e) => h(e) ? JSON.stringify(e, null, 2) : e).join(" "), w = (e, ...t) => {
|
|
217
|
+
e && e(C(t));
|
|
218
|
+
};
|
|
219
|
+
function T(e) {
|
|
220
|
+
let t = {
|
|
221
|
+
"!": "%21",
|
|
222
|
+
"'": "%27",
|
|
223
|
+
"(": "%28",
|
|
224
|
+
")": "%29",
|
|
225
|
+
"~": "%7E",
|
|
226
|
+
"%20": "+",
|
|
227
|
+
"%00": "\0"
|
|
228
|
+
};
|
|
229
|
+
return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g, (e) => t[e]);
|
|
230
|
+
}
|
|
231
|
+
var E = () => window.fetch && window.fetch.bind(window), D = () => {
|
|
232
|
+
throw new n("fetch is not available in this environment");
|
|
233
|
+
}, O = class e {
|
|
234
|
+
url;
|
|
235
|
+
defaultParams;
|
|
236
|
+
log;
|
|
237
|
+
fetch;
|
|
238
|
+
constructor({ serverUrl: e = "PRE", envDic: t, fetch: n = E() ?? D, log: r, defaultParams: i = {} }) {
|
|
239
|
+
f(h(i), "defaultParams should be a non-null object");
|
|
240
|
+
let a = S(e, t ?? {}), o = a.endsWith("/") ? a : `${a}/`;
|
|
241
|
+
this.url = new URL(o), this.defaultParams = i, r && (f(v(r), `log must be a function but it is ${r}`), this.log = r), this.fetch = n;
|
|
242
|
+
}
|
|
243
|
+
async go({ method: e, headers: t, pathname: r, data: i = {}, useDefaultParams: a = !0, fetchOptions: o = {
|
|
244
|
+
method: e,
|
|
245
|
+
credentials: "include"
|
|
246
|
+
} }) {
|
|
247
|
+
f(m(e), `Method must be a non empty string but it is "${e}"`), f(m(r), `Pathname must be string but it is "${r}"`), f(h(i), "data must be a non-null object"), o.headers = h(t) ? t : {};
|
|
248
|
+
let s = this.makeUrl(r, i, a);
|
|
249
|
+
w(this.log, "Request:", e.toUpperCase(), s), w(this.log, "Request Headers:", o.headers), w(this.log, "Request Body:", o.body);
|
|
250
|
+
try {
|
|
251
|
+
let e = await this.fetch(s, o);
|
|
252
|
+
if (w(this.log, "Response Code:", e.status, e.statusText), !e.ok) throw new n(e.statusText, { code: e.status });
|
|
253
|
+
let t = await e.json();
|
|
254
|
+
return w(this.log, "Response Parsed:", t), t;
|
|
255
|
+
} catch (t) {
|
|
256
|
+
let r = p(t) ? t : "Unknown RESTClient error";
|
|
257
|
+
h(t) && p(t.message) && (r = t.message);
|
|
258
|
+
let i = h(t) ? t : void 0;
|
|
259
|
+
throw new n(`Failed to '${e}' '${s}': '${r}'`, i);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
makeUrl(t = "", n = {}, r = !0) {
|
|
263
|
+
let i = t.startsWith("/") ? t.slice(1) : t, a = new URL(i, this.url);
|
|
264
|
+
return a.search = e.search(n, r, this.defaultParams), a.href;
|
|
265
|
+
}
|
|
266
|
+
get(e, t) {
|
|
267
|
+
return this.go({
|
|
268
|
+
method: "GET",
|
|
269
|
+
pathname: e,
|
|
270
|
+
data: t
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
static search(e, t, n) {
|
|
274
|
+
let r = t ? b(n, e) : b(e);
|
|
275
|
+
return Object.keys(r).filter((e) => r[e] !== "").map((e) => `${T(e)}=${T(String(r[e]))}`).join("&");
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
//#endregion
|
|
279
|
+
//#region src/spidTalk.ts
|
|
280
|
+
function k(e) {
|
|
281
|
+
(!e.SPiD || typeof e.SPiD != "object") && (e.SPiD = {}), (!e.SPiD.Talk || typeof e.SPiD.Talk != "object") && (e.SPiD.Talk = {}), v(e.SPiD.Talk.response) || (e.SPiD.Talk.response = (t, n) => e[t](n));
|
|
282
|
+
}
|
|
283
|
+
//#endregion
|
|
284
|
+
//#region src/version.ts
|
|
285
|
+
var A = "6.0.0-alpha.2";
|
|
286
|
+
//#endregion
|
|
287
|
+
export { s as _, x as a, v as c, p as d, y as f, u as g, l as h, S as i, m as l, d as m, k as n, b as o, _ as p, O as r, f as s, A as t, h as u, n as v, e as y };
|
|
288
|
+
|
|
289
|
+
//# sourceMappingURL=version-spE-k97g.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version-spE-k97g.js","names":[],"sources":["../node_modules/tiny-emitter/index.js","../src/SDKError.ts","../src/cache.ts","../src/config.ts","../src/global-registry.ts","../src/validate.ts","../src/object.ts","../src/url.ts","../src/RESTClient.ts","../src/spidTalk.ts","../src/version.ts"],"sourcesContent":["function E () {\n // Keep this empty so it's easier to inherit from\n // (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3)\n}\n\nE.prototype = {\n on: function (name, callback, ctx) {\n var e = this.e || (this.e = {});\n\n (e[name] || (e[name] = [])).push({\n fn: callback,\n ctx: ctx\n });\n\n return this;\n },\n\n once: function (name, callback, ctx) {\n var self = this;\n function listener () {\n self.off(name, listener);\n callback.apply(ctx, arguments);\n };\n\n listener._ = callback\n return this.on(name, listener, ctx);\n },\n\n emit: function (name) {\n var data = [].slice.call(arguments, 1);\n var evtArr = ((this.e || (this.e = {}))[name] || []).slice();\n var i = 0;\n var len = evtArr.length;\n\n for (i; i < len; i++) {\n evtArr[i].fn.apply(evtArr[i].ctx, data);\n }\n\n return this;\n },\n\n off: function (name, callback) {\n var e = this.e || (this.e = {});\n var evts = e[name];\n var liveEvents = [];\n\n if (evts && callback) {\n for (var i = 0, len = evts.length; i < len; i++) {\n if (evts[i].fn !== callback && evts[i].fn._ !== callback)\n liveEvents.push(evts[i]);\n }\n }\n\n // Remove event from queue to prevent memory leak\n // Suggested by https://github.com/lazd\n // Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910\n\n (liveEvents.length)\n ? e[name] = liveEvents\n : delete e[name];\n\n return this;\n }\n};\n\nmodule.exports = E;\nmodule.exports.TinyEmitter = E;\n","/* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.\n * See LICENSE.md in the project root.\n */\n\n/*\n * Note: this module can't have any internal dependencies because it's used in ./validate which\n * in turn is used as a dependency to a lot of other modules. Doing so may create a circular\n * dependency that's hard to debug in Node.\n */\n\nconst STRINGIFY_TYPES = ['boolean', 'number', 'string'];\n\n/**\n * Custom error class thrown by all SDK methods on failure.\n *\n * All rejected promises from API calls reject with an instance of this class.\n */\nexport default class SDKError extends Error {\n /** HTTP status code from the server error payload;\n * declared explicitly to allow numeric comparisons without type-casting.\n */\n code?: number;\n /**\n * Properties copied from the server error object.\n * @internal\n */\n [key: string]: unknown;\n\n /**\n * @param message - Human-readable error message\n * @param errorObject - Optional server error payload. All enumerable properties are\n * shallow-copied onto this instance.\n */\n constructor(message: string, errorObject?: Record<string, unknown>) {\n super(message);\n this.name = 'SDKError';\n\n if (errorObject) {\n try {\n Object.assign(this, errorObject);\n } catch {\n // silent\n }\n }\n }\n\n /**\n * Returns a multi-line string with the error name, message, and any other properties copied\n * from the server error payload.\n */\n toString(): string {\n const ret = `${this.name}: ${this.message}`;\n const additionalInfo = Object.keys(this)\n .filter((key) => key !== 'name' && STRINGIFY_TYPES.includes(typeof this[key]))\n .map((key) => ` ${key}: ${this[key]}`)\n .join('\\n');\n return additionalInfo ? `${ret}\\n${additionalInfo}` : ret;\n }\n}\n","/* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.\n * See LICENSE.md in the project root.\n */\n\nimport SDKError from './SDKError.js';\n\n/**\n * Check whether we are able to use web storage\n * @param storeProvider - A function to return a WebStorage instance (either\n * `sessionStorage` or `localStorage` from a `Window` object)\n * @private\n */\nfunction webStorageWorks(storeProvider: (() => Storage) | undefined): boolean {\n if (!storeProvider) {\n return false;\n }\n try {\n const store = storeProvider();\n const randomKey = 'x-x-x-x'.replace(/x/g, () => String(Math.random()));\n const testValue = 'TEST-VALUE';\n store.setItem(randomKey, testValue);\n const val = store.getItem(randomKey);\n store.removeItem(randomKey);\n return val === testValue;\n } catch {\n return false;\n }\n}\n\n/**\n * Cache implementation used when web storage is available. Wraps a `Storage` instance.\n * @private\n */\nclass WebStorageCache {\n store: Storage;\n get: (key: string) => string | null;\n set: (key: string, value: string) => void;\n delete: (key: string) => void;\n\n /**\n * Create web storage cache object\n * @param store - A reference to either `sessionStorage` or `localStorage` from a\n * `Window` object\n */\n constructor(store: Storage) {\n this.store = store;\n this.get = (key) => this.store.getItem(key);\n this.set = (key, value) => this.store.setItem(key, value);\n this.delete = (key) => this.store.removeItem(key);\n }\n}\n\n/**\n * Cache implementation used when web storage is not available. Stores entries in an in-memory object.\n * @private\n */\nclass LiteralCache {\n store: Record<string, string>;\n get: (key: string) => string | undefined;\n set: (key: string, value: string) => void;\n delete: (key: string) => void;\n\n /**\n * Create JS object literal cache object\n */\n constructor() {\n this.store = {};\n this.get = (key) => this.store[key];\n this.set = (key, value) => {\n this.store[key] = value;\n };\n this.delete = (key) => {\n delete this.store[key];\n };\n }\n}\n\ntype CacheEntry = { expiresOn: number; value: unknown };\n\nconst maxExpiresIn = 2 ** 31 - 1;\n\n/**\n * Cache class that attempts WebStorage (session/local storage), and falls back to JS object literal\n * @private\n */\nexport default class Cache {\n cache: WebStorageCache | LiteralCache;\n type: string;\n\n /**\n * @param storeProvider - A function to return a WebStorage instance (either\n * `sessionStorage` or `localStorage` from a `Window` object)\n * @throws {SDKError} - If sessionStorage or localStorage are not accessible\n */\n constructor(storeProvider?: () => Storage) {\n if (storeProvider && webStorageWorks(storeProvider)) {\n this.cache = new WebStorageCache(storeProvider());\n this.type = 'WebStorage';\n } else {\n this.cache = new LiteralCache();\n this.type = 'ObjectLiteralStorage';\n }\n }\n\n /**\n * Get a value from cache (checks that the object has not expired)\n * @param key\n * @private\n */\n get(key: string): unknown {\n /**\n * JSON.parse safe wrapper\n * @param raw\n */\n function getObj(raw: string | null | undefined): CacheEntry | null {\n if (raw == null) {\n return null;\n }\n try {\n return JSON.parse(raw);\n } catch {\n return null;\n }\n }\n\n try {\n const raw = this.cache.get(key);\n const obj = getObj(raw);\n if (obj && Number.isInteger(obj.expiresOn) && obj.expiresOn > Date.now()) {\n return obj.value;\n }\n this.delete(key);\n return null;\n } catch (e) {\n throw new SDKError(String(e));\n }\n }\n\n /**\n * Set a cache entry\n * @param key\n * @param value\n * @param expiresIn - Value in milliseconds until the entry expires\n * @private\n */\n set(key: string, value: unknown, expiresIn = 0): void {\n if (expiresIn <= 0) {\n return;\n }\n expiresIn = Math.min(maxExpiresIn, expiresIn);\n\n try {\n const expiresOn = Math.floor(Date.now() + expiresIn);\n this.cache.set(key, JSON.stringify({ expiresOn, value }));\n setTimeout(() => this.delete(key), expiresIn);\n } catch (e) {\n throw new SDKError(String(e));\n }\n }\n\n /**\n * Delete a cache entry\n * @param key\n * @private\n */\n delete(key: string): void {\n try {\n this.cache.delete(key);\n } catch (e) {\n throw new SDKError(String(e));\n }\n }\n}\n","/* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.\n * See LICENSE.md in the project root.\n */\n\n/*\n * This file declares configs that are essentially part of how the SDK works and interacts with our\n * backend servers.\n *\n * What goes here?\n * - The configurations that are likely to change over time\n * - Constants that are otherwise obscure (for example 7000 for a TIMEOUT)\n *\n * What doesn't go here?\n * - options that the users of the SDK are supposed to set or provide as a parameter to functions\n * and classes.\n */\n\n/**\n * Core configuration used by the SDK.\n * - `ENDPOINTS.SPiD` — SPiD endpoints per environment\n * - `ENDPOINTS.BFF` — Endpoints used with new GDPR-compliant web flows\n * - `ENDPOINTS.SESSION_SERVICE` — Endpoints to check global user session data\n *\n */\nconst config = {\n ENDPOINTS: {\n SPiD: {\n LOCAL: 'http://id.localhost',\n DEV: 'https://identity-dev.schibsted.com',\n PRE: 'https://identity-pre.schibsted.com',\n PRO: 'https://login.schibsted.com',\n PRO_NO: 'https://payment.schibsted.no',\n PRO_FI: 'https://login.schibsted.fi',\n PRO_DK: 'https://login.schibsted.dk',\n },\n BFF: {\n LOCAL: 'http://id.localhost/authn/',\n DEV: 'https://identity-dev.schibsted.com/authn/',\n PRE: 'https://identity-pre.schibsted.com/authn/',\n PRO: 'https://login.schibsted.com/authn/',\n PRO_NO: 'https://payment.schibsted.no/authn/',\n PRO_FI: 'https://login.schibsted.fi/authn/',\n PRO_DK: 'https://login.schibsted.dk/authn/',\n },\n SESSION_SERVICE: {\n LOCAL: 'http://session-service.id.localhost',\n DEV: 'https://session-service.identity-dev.schibsted.com',\n PRE: 'https://session-service.identity-pre.schibsted.com',\n PRO: 'https://session-service.login.schibsted.com',\n PRO_NO: 'https://session-service.payment.schibsted.no',\n PRO_FI: 'https://session-service.login.schibsted.fi',\n PRO_DK: 'https://session-service.login.schibsted.dk',\n },\n },\n NAMESPACE: {\n LOCAL: 'id.localhost',\n DEV: 'schibsted.com',\n PRE: 'schibsted.com',\n PRO: 'schibsted.com',\n PRO_NO: 'spid.no',\n PRO_FI: 'schibsted.fi',\n PRO_DK: 'schibsted.dk',\n },\n} as const;\n\nexport default config;\nexport const ENDPOINTS = config.ENDPOINTS;\nexport const NAMESPACE = config.NAMESPACE;\n","import './globals.js';\n\n/**\n * Names of the SDK instance properties that can be registered on the global {@link Window} object.\n */\ntype Property = 'schIdentity' | 'schMonetization';\n\n/**\n * Registers an SDK instance on the global {@link Window} object's given property and dispatches a ready event.\n *\n * The dispatched event is a {@link CustomEvent} fired on `global` (i.e. `window`) with:\n * - name: `${property}:ready` (e.g. `\"schIdentity:ready\"` or `\"schMonetization:ready\"`)\n * - `detail.instance`: the registered SDK instance\n *\n * @typeParam T - Constrained to {@link Property}; inferred from the `property` argument.\n * @param global - The `Window` object to register on.\n * @param property - The window property name to assign the instance to, 'schIdentity' or 'schMonetization'.\n * @param instance - The SDK instance to register. Must be non-nullable.\n *\n * @example\n * registerAndDispatchInGlobal(window, 'schIdentity', identityInstance);\n * / window.schIdentity === identityInstance\n * / CustomEvent 'schIdentity:ready' has been dispatched on window\n */\n\nexport const registerAndDispatchInGlobal = <T extends Property>(\n global: Window,\n property: T,\n instance: NonNullable<Window[T]>,\n): void => {\n if (!global[property]) {\n global[property] = instance;\n }\n\n global.dispatchEvent(\n //TODO -> https://schibsted.ghe.com/connect/team/issues/645\n new CustomEvent(`${property}:ready`, { detail: { instance: global[property] } }),\n );\n};\n","/* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.\n * See LICENSE.md in the project root.\n */\n\nimport SDKError from './SDKError.js';\n\n/*\n * This module defines a set of validation functions which are used in the rest of the SDK.\n * Why make our own validation module?\n * 1. To implement the validations that we specifically need for the SDK\n * 2. To have one less dependency\n */\n\n/**\n * A utility function that throws an SDKError if an assertion fails. It's mostly useful for\n * validating function inputs.\n *\n * Narrows `condition` for the rest of the enclosing scope (TypeScript assertion signature).\n * @param condition - The condition that we're asserting\n * @param message - The error message\n * @throws {SDKError} - If the condition is falsy it throws the appropriate error\n */\nexport function assert(condition: boolean, message = 'Assertion failed'): asserts condition {\n if (!condition) {\n throw new SDKError(message);\n }\n}\n\n/**\n * Checks if a value is a string or not\n * @param value - The value to check\n */\nexport function isStr(value: unknown): value is string {\n return typeof value === 'string';\n}\n\n/**\n * Checks if a value is a non-empty string\n * @param value - The value to check\n */\nexport function isNonEmptyString(value: unknown): value is string {\n return typeof value === 'string' && value.length > 0;\n}\n\n/**\n * checks if a given value is an object (but not null)\n * @param value - The value to check\n */\nexport function isObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null;\n}\n\n/**\n * Checks if a given value is an object with at least one own key\n * @param value - The value to check\n */\nexport function isNonEmptyObj(value: unknown): value is Record<string, unknown> {\n return isObject(value) && Object.keys(value).length > 0;\n}\n\n/**\n * Checks if a given string is a valid URL\n * @param value - The string to be tested\n * @param mandatoryFields - A list of mandatory fields that should exist in the parsed\n * `URL` object\n */\nexport function isUrl(value: string, ...mandatoryFields: (keyof URL)[]): boolean {\n try {\n const parsedUrl = new URL(value);\n return mandatoryFields.every((f) => parsedUrl[f]);\n } catch {\n return false;\n }\n}\n\n/**\n * Checks if a given value is a function\n * @param value - The value to check\n */\nexport function isFunction(value: unknown): value is (...args: unknown[]) => unknown {\n return typeof value === 'function';\n}\n\n/**\n * Checks if a string matches any of the strings in a set of possibilities\n * @param value\n * @param possibilities - An array of strings that'll be used to check the string\n * inclusion. Note that for performance reasons, we don't validate this parameter.\n * @param caseSensitive - Should the check be case sensitive\n */\nexport function isStrIn(value: string, possibilities: string[], caseSensitive = false): boolean {\n const _isSameStrCaseInsensitive = (str: string) =>\n isStr(str) && value.toUpperCase() === str.toUpperCase();\n if (!(isStr(value) && Array.isArray(possibilities))) {\n return false;\n }\n if (caseSensitive) {\n return possibilities.indexOf(value) !== -1;\n }\n return possibilities.some(_isSameStrCaseInsensitive);\n}\n","/* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.\n * See LICENSE.md in the project root.\n */\n\n/**\n * @summary Some routines that work on javascript objects\n * @private\n */\n\nimport SDKError from './SDKError.js';\nimport { assert, isNonEmptyObj, isObject } from './validate.js';\n\n/**\n * Similar to Object.assign({}, src) but only clones the keys of an object that have non-undefined\n * values.\n * Please note that the values in the rightmost parameters can overwrite the values of the earlier\n * parameters so the order of the parameters matters.\n * @example\n * cloneDefined({foo: 1, bar: 2}, {foo: 2}) // returns {foo: 2, bar: 2}\n *\n * @param sources - one or more sources. Their defined properties will override the ones\n * that came before it. For example if `source1.foo = 'bar'` and `source2.foo = 'baz'`, the\n * result will include `{ foo: 'baz' }`\n */\nexport function cloneDefined(...sources: object[]): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n if (!(sources && sources.length)) {\n throw new SDKError('No objects to clone');\n }\n sources.forEach((source) => {\n assert(isObject(source));\n if (isNonEmptyObj(source)) {\n Object.entries(source).forEach(([key, value]) => {\n if (typeof value !== 'undefined') {\n result[key] = isObject(value) ? cloneDeep(value) : value;\n }\n });\n }\n });\n return result;\n}\n\n/**\n * Deep copies an object. This is handy for immutability.\n * @param obj - An object, array or null.\n * @throws {SDKError} - if the obj is not an accepted type or is not\n * stringifiable by JSON for example if it has loops\n */\nexport function cloneDeep<T extends object | null>(obj: T): T {\n assert(typeof obj === 'object', `obj should be an object (even null) but it is ${obj}`);\n return JSON.parse(JSON.stringify(obj)) || obj;\n}\n","/* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.\n * See LICENSE.md in the project root.\n */\n\nimport { assert, isNonEmptyObj, isNonEmptyString, isUrl } from './validate.js';\n\n/**\n * A simple utility function that allows looking up URLs from a dictionary\n * @param url - A url like http://example.com, or a key used for lookup\n * @param urlMap - A map of URLs like `{ DEV: 'http://dev.example.com' }`\n * @returns The resolved URL: the mapped value when `url` is a known key, otherwise `url` itself\n * @throws {SDKError} - If the url is not a string or is an empty string\n */\nexport function urlMapper(url: string, urlMap: Record<string, string>): string {\n assert(isNonEmptyString(url), `\"url\" param must be a non empty string: ${typeof url}`);\n if (isNonEmptyObj(urlMap) && isUrl(urlMap[url])) {\n return urlMap[url];\n }\n assert(isUrl(url, 'hostname'), `Bad URL given: '${url}'`);\n return url;\n}\n","/* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.\n * See LICENSE.md in the project root.\n */\n\nimport { cloneDefined } from './object.js';\nimport SDKError from './SDKError.js';\nimport { urlMapper } from './url.js';\nimport { assert, isFunction, isNonEmptyString, isObject, isStr } from './validate.js';\n\n/**\n * Converts a series of parameters of various types to a string that's suitable for logging.\n * @private\n * @param msg - The values to format; objects are stringified to JSON\n */\nconst logString = (msg: unknown[]): string =>\n msg.map((m) => (isObject(m) ? JSON.stringify(m, null, 2) : m)).join(' ');\n\n/**\n * Calls a log function passing a string\n * @private\n * @param fn - The log function\n * @param msg - The values to log\n */\nconst logFn = (fn: Function | undefined, ...msg: unknown[]): void => {\n if (fn) {\n fn(logString(msg));\n }\n};\n\n/**\n * Encode a string like URLSearchParams would do\n * @private\n * @param str - The input\n */\nfunction encode(str: string): string {\n const replace: Record<string, string> = {\n '!': '%21',\n \"'\": '%27',\n '(': '%28',\n ')': '%29',\n '~': '%7E',\n '%20': '+',\n '%00': '\\x00',\n };\n return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, (match) => replace[match]);\n}\ntype FetchFunction = (input: RequestInfo, init?: RequestInit) => Promise<Response>;\nconst globalFetch = () => window.fetch && window.fetch.bind(window);\nconst noFetch: FetchFunction = () => {\n throw new SDKError('fetch is not available in this environment');\n};\n\n/**\n * The value of a single query parameter; `undefined` entries are skipped.\n */\ntype QueryValue = string | number | boolean | undefined;\n\n/**\n * Query parameters appended to a request URL.\n */\ntype QueryParams = Record<string, QueryValue>;\n\n/**\n * HTTP method used for a request.\n */\ntype HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';\n\n/**\n * This class can be used for creating a wrapper around a server and all its endpoints.\n * Its functionality is extended by {@link JSONPClient}\n * Creates a client to a REST server. While useful stand-alone, it's also used for some other\n * types of client that change some functionalities.\n * @throws {SDKError} - If any of options are invalid\n * @summary The simplest way to communicate to a REST endpoint without any\n * special authentication\n * @private\n */\nexport class RESTClient {\n url: URL;\n defaultParams: QueryParams;\n log?: Function;\n fetch: FetchFunction;\n\n /**\n * @param options\n * @param options.serverUrl - The URL to the server eg.\n * https://login.schibsted.com or a URL key like 'DEV' in combination with {@link envDic}.\n * @param options.envDic - A dictionary that will be used for looking up\n * {@link serverUrl} keys. If serverUrl is always a URL, you don't need this.\n * @param options.fetch - The fetch function to use. It can be native\n * or a polyfill\n * @param options.log - A function that will be called with log messages about\n * request and response\n * @param options.defaultParams - Query parameters added to every request\n */\n constructor({\n serverUrl = 'PRE',\n envDic,\n fetch = globalFetch() ?? noFetch,\n log,\n defaultParams = {},\n }: {\n serverUrl?: string;\n envDic?: Record<string, string>;\n fetch?: FetchFunction;\n log?: Function;\n defaultParams?: QueryParams;\n }) {\n assert(isObject(defaultParams), `defaultParams should be a non-null object`);\n\n const mappedUrl = urlMapper(serverUrl, envDic ?? {});\n const handledServerUrl = mappedUrl.endsWith('/') ? mappedUrl : `${mappedUrl}/`;\n this.url = new URL(handledServerUrl);\n\n this.defaultParams = defaultParams;\n\n if (log) {\n assert(isFunction(log), `log must be a function but it is ${log}`);\n this.log = log;\n }\n\n this.fetch = fetch;\n }\n\n /**\n * Makes the actual call to the server and deals with headers, data objects and the edge cases.\n * Please note that this method expects the response to be in JSON format. However, it'll not\n * parse the response if its code is not in the 200 range.\n * @param options - An obligatory options object\n * @param options.method - The HTTP request method, e.g. 'GET' or 'POST'\n * @param options.pathname - The path to the endpoint like 'api/2/endpoint-name'\n * @param options.data - Query parameters added to the request URL\n * @param options.headers - Request headers as a plain key/value map\n * @param options.useDefaultParams - Should we add the defaultParams to the query?\n * @param options.fetchOptions - Additional fetch options\n * @throws {SDKError} - If the call can't be made for whatever reason.\n */\n async go({\n method,\n headers,\n pathname,\n data = {},\n useDefaultParams = true,\n fetchOptions = { method, credentials: 'include' },\n }: {\n method: HttpMethod;\n pathname: string;\n data?: QueryParams;\n headers?: Record<string, string>;\n useDefaultParams?: boolean;\n fetchOptions?: RequestInit;\n }): Promise<any> {\n assert(isNonEmptyString(method), `Method must be a non empty string but it is \"${method}\"`);\n assert(isNonEmptyString(pathname), `Pathname must be string but it is \"${pathname}\"`);\n assert(isObject(data), `data must be a non-null object`);\n\n fetchOptions.headers = isObject(headers) ? headers : {};\n const fullUrl = this.makeUrl(pathname, data, useDefaultParams);\n\n logFn(this.log, 'Request:', method.toUpperCase(), fullUrl);\n logFn(this.log, 'Request Headers:', fetchOptions.headers);\n logFn(this.log, 'Request Body:', fetchOptions.body);\n try {\n const response = await this.fetch(fullUrl, fetchOptions);\n logFn(this.log, 'Response Code:', response.status, response.statusText);\n if (!response.ok) {\n // status code not in range 200-299\n throw new SDKError(response.statusText, { code: response.status });\n }\n const responseObject = await response.json();\n logFn(this.log, 'Response Parsed:', responseObject);\n return responseObject;\n } catch (err: unknown) {\n let msg = isStr(err) ? err : 'Unknown RESTClient error';\n if (isObject(err) && isStr(err.message)) {\n msg = err.message;\n }\n const errorObject = isObject(err) ? err : undefined;\n throw new SDKError(`Failed to '${method}' '${fullUrl}': '${msg}'`, errorObject);\n }\n }\n\n /**\n * Creates a url that points to an endpoint in the server\n * @param pathname - WHATWG pathname ie. 'api/2/endpoint-name'\n * @param query - Query parameters to serialize into the query string\n * @param useDefaultParams - Should we add the defaultParams to the query?\n */\n makeUrl(pathname = '', query: QueryParams = {}, useDefaultParams = true): string {\n const handledPathname = pathname.startsWith('/') ? pathname.slice(1) : pathname;\n\n const url = new URL(handledPathname, this.url);\n url.search = RESTClient.search(query, useDefaultParams, this.defaultParams);\n return url.href;\n }\n\n /**\n * Make a GET request\n * @param pathname - WHATWG pathname ie. 'api/2/endpoint-name'\n * @param data - Query parameters\n */\n get(pathname: string, data?: QueryParams): Promise<any> {\n return this.go({ method: 'GET', pathname, data });\n }\n\n /**\n * Construct query string for WHATWG urls\n * @private\n * @param query - Query parameters to generate the query string from\n * @param useDefaultParams - Use defaultParams or not\n * @param defaultParams - Default params\n */\n private static search(\n query: QueryParams,\n useDefaultParams: boolean,\n defaultParams: QueryParams,\n ): string {\n const params = useDefaultParams ? cloneDefined(defaultParams, query) : cloneDefined(query);\n return Object.keys(params)\n .filter((p) => params[p] !== '')\n .map((p) => `${encode(p)}=${encode(String(params[p]))}`)\n .join('&');\n }\n}\n\nexport default RESTClient;\n","/* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.\n * See LICENSE.md in the project root.\n */\n\n/**\n * A workaround for how Schibsted account handles JSONP calls in the browser\n * @private\n */\n\nimport './globals.js';\nimport { isFunction } from './validate.js';\n\n/**\n * This is a workaround for making the old SPiD/hassession on JSONP APIs compatible with more common\n * JSONP convention where the callback function is expected to exist in the global object.\n *\n * How does it work?\n * =================\n * The old SPiD JSONP APIs relied on SPiD.Talk.response(callbackName, data) but fetch-jsonp merely\n * calls window[callbackName](data) which is more common practice. This module simply acts as an\n * adapter to modernize the old mechanism until we support CORS. To see how the SPiD solution works,\n * try to run a simple JSONP request or debug it in the network tab. This module will be removed\n * when CORS is supported.\n * @param global - A reference to the global object, typically the `Window`.\n */\nexport function emulate(global: Window): void {\n if (!global.SPiD || typeof global.SPiD !== 'object') {\n global.SPiD = {};\n }\n if (!global.SPiD.Talk || typeof global.SPiD.Talk !== 'object') {\n global.SPiD.Talk = {};\n }\n if (!isFunction(global.SPiD.Talk.response)) {\n global.SPiD.Talk.response = (callbackName: string, data: unknown) =>\n (global as any)[callbackName](data);\n }\n}\n","// Version is bumped automatically by release-please. See release-please-config.json.\n\nconst version = '6.0.0-alpha.2'; // x-release-please-version\nexport default version;\n"],"x_google_ignoreList":[0],"mappings":";;;CAAA,SAAS,IAAK,CAGd;CA+DA,AA7DA,EAAE,YAAY;EACZ,IAAI,SAAU,GAAM,GAAU,GAAK;GACjC,IAAI,IAAI,AAAW,KAAK,MAAI,CAAC;GAO7B,QALC,EAAE,OAAU,EAAE,KAAQ,CAAC,IAAI,KAAK;IAC/B,IAAI;IACC;GACP,CAAC,GAEM;EACT;EAEA,MAAM,SAAU,GAAM,GAAU,GAAK;GACnC,IAAI,IAAO;GACX,SAAS,IAAY;IAEnB,AADA,EAAK,IAAI,GAAM,CAAQ,GACvB,EAAS,MAAM,GAAK,SAAS;GAC/B;GAGA,OADA,EAAS,IAAI,GACN,KAAK,GAAG,GAAM,GAAU,CAAG;EACpC;EAEA,MAAM,SAAU,GAAM;GAMpB,KALA,IAAI,IAAO,CAAC,EAAE,MAAM,KAAK,WAAW,CAAC,GACjC,MAAW,AAAW,KAAK,MAAI,CAAC,GAAI,MAAS,CAAC,GAAG,MAAM,GACvD,IAAI,GACJ,IAAM,EAAO,QAET,IAAI,GAAK,KACf,EAAO,GAAG,GAAG,MAAM,EAAO,GAAG,KAAK,CAAI;GAGxC,OAAO;EACT;EAEA,KAAK,SAAU,GAAM,GAAU;GAC7B,IAAI,IAAI,AAAW,KAAK,MAAI,CAAC,GACzB,IAAO,EAAE,IACT,IAAa,CAAC;GAElB,IAAI,KAAQ,QACL,IAAI,IAAI,GAAG,IAAM,EAAK,QAAQ,IAAI,GAAK,KAC1C,AAAI,EAAK,GAAG,OAAO,KAAY,EAAK,GAAG,GAAG,MAA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