@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.
Files changed (90) hide show
  1. package/README.md +12 -59
  2. package/dist/RESTClient.d.ts +91 -0
  3. package/dist/SDKError.d.ts +27 -0
  4. package/dist/cache.d.ts +65 -0
  5. package/dist/config.d.ts +86 -0
  6. package/dist/global-registry.d.ts +23 -0
  7. package/dist/globals.d.ts +13 -0
  8. package/dist/identity-s4nofYmB.js +370 -0
  9. package/dist/identity-s4nofYmB.js.map +1 -0
  10. package/dist/identity.d.ts +523 -0
  11. package/dist/identity.js +2 -0
  12. package/dist/index.d.ts +3 -0
  13. package/dist/index.js +4 -0
  14. package/dist/monetization.d.ts +94 -0
  15. package/dist/monetization.js +72 -0
  16. package/dist/monetization.js.map +1 -0
  17. package/{src → dist}/object.d.ts +4 -9
  18. package/dist/popup.d.ts +9 -0
  19. package/{src → dist}/spidTalk.d.ts +4 -6
  20. package/dist/url.d.ts +8 -0
  21. package/dist/validate.d.ts +50 -0
  22. package/dist/version-spE-k97g.js +289 -0
  23. package/dist/version-spE-k97g.js.map +1 -0
  24. package/dist/version.d.ts +2 -0
  25. package/package.json +42 -49
  26. package/src/RESTClient.ts +226 -0
  27. package/src/SDKError.ts +59 -0
  28. package/src/{cache.js → cache.ts} +52 -37
  29. package/src/{config.js → config.ts} +7 -32
  30. package/src/global-registry.ts +39 -0
  31. package/src/globals.ts +10 -0
  32. package/src/{identity.js → identity.ts} +536 -437
  33. package/{index.js → src/index.ts} +1 -3
  34. package/src/{monetization.js → monetization.ts} +77 -48
  35. package/src/{object.js → object.ts} +8 -15
  36. package/src/popup.ts +74 -0
  37. package/src/{spidTalk.js → spidTalk.ts} +10 -12
  38. package/src/{url.js → url.ts} +6 -10
  39. package/src/{validate.js → validate.ts} +26 -42
  40. package/src/{version.js → version.ts} +1 -2
  41. package/es5/global.js +0 -12968
  42. package/es5/global.js.map +0 -1
  43. package/es5/global.min.js +0 -2
  44. package/es5/global.min.js.map +0 -1
  45. package/es5/identity.js +0 -12212
  46. package/es5/identity.js.map +0 -1
  47. package/es5/identity.min.js +0 -2
  48. package/es5/identity.min.js.map +0 -1
  49. package/es5/index.js +0 -12940
  50. package/es5/index.js.map +0 -1
  51. package/es5/index.min.js +0 -2
  52. package/es5/index.min.js.map +0 -1
  53. package/es5/monetization.js +0 -9176
  54. package/es5/monetization.js.map +0 -1
  55. package/es5/monetization.min.js +0 -2
  56. package/es5/monetization.min.js.map +0 -1
  57. package/es5/payment.js +0 -8853
  58. package/es5/payment.js.map +0 -1
  59. package/es5/payment.min.js +0 -2
  60. package/es5/payment.min.js.map +0 -1
  61. package/identity.d.ts +0 -1
  62. package/identity.js +0 -5
  63. package/index.d.ts +0 -4
  64. package/monetization.d.ts +0 -1
  65. package/monetization.js +0 -5
  66. package/payment.d.ts +0 -1
  67. package/payment.js +0 -5
  68. package/src/RESTClient.d.ts +0 -89
  69. package/src/RESTClient.js +0 -193
  70. package/src/SDKError.d.ts +0 -16
  71. package/src/SDKError.js +0 -55
  72. package/src/__mocks__/.eslintrc.yml +0 -8
  73. package/src/__mocks__/RESTClient.js +0 -54
  74. package/src/cache.d.ts +0 -64
  75. package/src/config.d.ts +0 -34
  76. package/src/es5/global.js +0 -13
  77. package/src/es5/identity.js +0 -10
  78. package/src/es5/index.js +0 -13
  79. package/src/es5/monetization.js +0 -10
  80. package/src/es5/payment.js +0 -10
  81. package/src/global-registry.js +0 -20
  82. package/src/identity.d.ts +0 -679
  83. package/src/monetization.d.ts +0 -80
  84. package/src/payment.d.ts +0 -115
  85. package/src/payment.js +0 -211
  86. package/src/popup.d.ts +0 -10
  87. package/src/popup.js +0 -59
  88. package/src/url.d.ts +0 -10
  89. package/src/validate.d.ts +0 -64
  90. package/src/version.d.ts +0 -2
package/identity.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from "./src/identity.js";
package/identity.js DELETED
@@ -1,5 +0,0 @@
1
- /* Copyright 2026 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
2
- * See LICENSE.md in the project root.
3
- */
4
-
5
- export { default, Identity } from './src/identity.js';
package/index.d.ts DELETED
@@ -1,4 +0,0 @@
1
- export * from "./identity.js";
2
- export * from "./monetization.js";
3
- export * from "./payment.js";
4
- export { default as SDKError } from "./src/SDKError.js";
package/monetization.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from "./src/monetization.js";
package/monetization.js DELETED
@@ -1,5 +0,0 @@
1
- /* Copyright 2026 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
2
- * See LICENSE.md in the project root.
3
- */
4
-
5
- export { default, Monetization } from './src/monetization.js';
package/payment.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from "./src/payment.js";
package/payment.js DELETED
@@ -1,5 +0,0 @@
1
- /* Copyright 2026 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
2
- * See LICENSE.md in the project root.
3
- */
4
-
5
- export { default, Payment } from './src/payment.js';
@@ -1,89 +0,0 @@
1
- /**
2
- * This class can be used for creating a wrapper around a server and all its endpoints.
3
- * Its functionality is extended by {@link JSONPClient}
4
- * Creates a client to a REST server. While useful stand-alone, it's also used for some other
5
- * types of client that change some functionalities.
6
- * @throws {SDKError} if any of options are invalid
7
- * @summary the simplest way to communicate to a REST endpoint without any
8
- * special authentication
9
- * @memberof core
10
- * @private
11
- */
12
- export class RESTClient {
13
- /**
14
- * Construct query string for WHATWG urls
15
- * @private
16
- * @param {object} query - Object to generate query string from
17
- * @param {boolean} useDefaultParams - Use defaultParams or not
18
- * @param {object} defaultParams - Default params
19
- * @returns {string} Query string
20
- */
21
- private static search;
22
- /**
23
- * @param {object} options
24
- * @param {string} [options.serverUrl=PRE] - The URL to the server eg.
25
- * https://login.schibsted.com or a URL key like 'DEV' in combination with {@link envDic}.
26
- * @param {object} [options.envDic] - A dictionary that will be used for looking up
27
- * {@link serverUrl} keys. If serverUrl is always a URL, you don't need this.
28
- * @param {function} [options.fetch=window.fetch] - The fetch function to use. It can be native
29
- * or a polyfill
30
- * @param {function} [options.log] - A function that will be called with log messages about
31
- * request and response
32
- * @param {object} [options.defaultParams={}] - a set of parameters to add to every call custom.
33
- * As long as it supports the standard fetch API we're good.
34
- */
35
- constructor({ serverUrl, envDic, fetch, log, defaultParams }: {
36
- serverUrl?: string;
37
- envDic?: any;
38
- fetch?: Function;
39
- log?: Function;
40
- defaultParams?: any;
41
- });
42
- url: URL;
43
- defaultParams: any;
44
- log: Function;
45
- fetch: Function;
46
- /**
47
- * Makes the actual call to the server and deals with headers, data objects and the edge cases.
48
- * Please note that this method expects the response to be in JSON format. However, it'll not
49
- * parse the response if its code is not in the 200 range.
50
- * @param {object} options - an obligatory options object
51
- * @param {string} options.method - can be 'GET', 'POST', 'DELETE', etc. case sensitive. To be
52
- * more specific, this can be one of the values that are passed to the `methods`
53
- * property of the constructor's `options` parameter.
54
- * @param {string} options.pathname - the path to the endpoint like 'api/2/endpoint-name'
55
- * @param {Object} [options.data={}] - data payload (depending on GET/DELETE or POST it may be a query
56
- * string or form body)
57
- * @param {array} [options.headers] - fetch options headers
58
- * @param {boolean} [options.useDefaultParams] - should we add the defaultParams to the query?
59
- * @param {object} [options.fetchOptions] - fetch options
60
- * @throws {SDKError} - if the call can't be made for whatever reason.
61
- * @return {Promise<object>} - A promise that will resolve to the call's response or reject if there
62
- * is an error before making the call or if the server returns a non-2xx error or
63
- * something that's not parsable as JSON.
64
- */
65
- go({ method, headers, pathname, data, useDefaultParams, fetchOptions }: {
66
- method: string;
67
- pathname: string;
68
- data?: any;
69
- headers?: any[];
70
- useDefaultParams?: boolean;
71
- fetchOptions?: any;
72
- }): Promise<any>;
73
- /**
74
- * Creates a url that points to an endpoint in the server
75
- * @param {string} [pathname=] - WHATWG pathname ie. 'api/2/endpoint-name'
76
- * @param {object} [query={}] - WHATWG query. It's the data payload.
77
- * @param {boolean} [useDefaultParams=true] - should we add the defaultParams to the query?
78
- * @return {string} - the resulting url string ready to pass to fetch
79
- */
80
- makeUrl(pathname?: string, query?: any, useDefaultParams?: boolean): string;
81
- /**
82
- * Make a GET request
83
- * @param {string} pathname - WHATWG pathname ie. 'api/2/endpoint-name'
84
- * @param {object} [data={}] - the data payload.
85
- * @return {Promise}
86
- */
87
- get(pathname: string, data?: any): Promise<any>;
88
- }
89
- export default RESTClient;
package/src/RESTClient.js DELETED
@@ -1,193 +0,0 @@
1
- /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
2
- * See LICENSE.md in the project root.
3
- */
4
-
5
- 'use strict';
6
-
7
- import SDKError from './SDKError.js';
8
- import { cloneDefined } from './object.js';
9
- import { urlMapper } from './url.js';
10
- import { assert, isObject, isFunction, isStr, isNonEmptyString } from './validate.js';
11
-
12
- /**
13
- * Converts a series of parameters of various types to a string that's suitable for logging.
14
- * @private
15
- * @param {Array.<*>} msg - a number of parameters from any type (including objects)
16
- * @return {string}
17
- */
18
- const logString = (msg) => msg.map(m => isObject(m) ? JSON.stringify(m, null, 2) : m).join(' ');
19
-
20
- /**
21
- * Calls a log function passing a string
22
- * @private
23
- * @param {function} fn - the log function
24
- * @param {...*} msg - a series of message objects
25
- * @return {*} - The result of calling fn
26
- */
27
- const logFn = (fn, ...msg) => (typeof fn === 'function') && fn(logString(msg));
28
-
29
- /**
30
- * Encode a string like URLSearchParams would do
31
- * @private
32
- * @param {string} str - The input
33
- * @returns {string} The encoded string
34
- */
35
- function encode(str) {
36
- const replace = {
37
- '!': '%21',
38
- "'": '%27',
39
- '(': '%28',
40
- ')': '%29',
41
- '~': '%7E',
42
- '%20': '+',
43
- '%00': '\x00'
44
- };
45
- return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, match => replace[match]);
46
- }
47
-
48
- const globalFetch = () => window.fetch && window.fetch.bind(window);
49
-
50
- /**
51
- * This class can be used for creating a wrapper around a server and all its endpoints.
52
- * Its functionality is extended by {@link JSONPClient}
53
- * Creates a client to a REST server. While useful stand-alone, it's also used for some other
54
- * types of client that change some functionalities.
55
- * @throws {SDKError} if any of options are invalid
56
- * @summary the simplest way to communicate to a REST endpoint without any
57
- * special authentication
58
- * @memberof core
59
- * @private
60
- */
61
- export class RESTClient {
62
-
63
- /**
64
- * @param {object} options
65
- * @param {string} [options.serverUrl=PRE] - The URL to the server eg.
66
- * https://login.schibsted.com or a URL key like 'DEV' in combination with {@link envDic}.
67
- * @param {object} [options.envDic] - A dictionary that will be used for looking up
68
- * {@link serverUrl} keys. If serverUrl is always a URL, you don't need this.
69
- * @param {function} [options.fetch=window.fetch] - The fetch function to use. It can be native
70
- * or a polyfill
71
- * @param {function} [options.log] - A function that will be called with log messages about
72
- * request and response
73
- * @param {object} [options.defaultParams={}] - a set of parameters to add to every call custom.
74
- * As long as it supports the standard fetch API we're good.
75
- */
76
- constructor({ serverUrl = 'PRE', envDic, fetch = globalFetch(), log, defaultParams = {}}) {
77
- assert(isObject(defaultParams), `defaultParams should be a non-null object`);
78
-
79
- const mappedUrl = urlMapper(serverUrl, envDic);
80
- const handledServerUrl = mappedUrl.endsWith('/') ? mappedUrl : `${mappedUrl}/`;
81
- this.url = new URL(handledServerUrl);
82
-
83
- this.defaultParams = defaultParams;
84
-
85
- if (log) {
86
- assert(isFunction(log), `log must be a function but it is ${log}`);
87
- this.log = log;
88
- }
89
-
90
- if (fetch) {
91
- assert(isFunction(fetch), 'Fetch should be a function');
92
- this.fetch = fetch;
93
- }
94
- }
95
-
96
- /**
97
- * Makes the actual call to the server and deals with headers, data objects and the edge cases.
98
- * Please note that this method expects the response to be in JSON format. However, it'll not
99
- * parse the response if its code is not in the 200 range.
100
- * @param {object} options - an obligatory options object
101
- * @param {string} options.method - can be 'GET', 'POST', 'DELETE', etc. case sensitive. To be
102
- * more specific, this can be one of the values that are passed to the `methods`
103
- * property of the constructor's `options` parameter.
104
- * @param {string} options.pathname - the path to the endpoint like 'api/2/endpoint-name'
105
- * @param {Object} [options.data={}] - data payload (depending on GET/DELETE or POST it may be a query
106
- * string or form body)
107
- * @param {array} [options.headers] - fetch options headers
108
- * @param {boolean} [options.useDefaultParams] - should we add the defaultParams to the query?
109
- * @param {object} [options.fetchOptions] - fetch options
110
- * @throws {SDKError} - if the call can't be made for whatever reason.
111
- * @return {Promise<object>} - A promise that will resolve to the call's response or reject if there
112
- * is an error before making the call or if the server returns a non-2xx error or
113
- * something that's not parsable as JSON.
114
- */
115
- async go({
116
- method,
117
- headers,
118
- pathname,
119
- data = {},
120
- useDefaultParams = true,
121
- fetchOptions = { method, credentials: 'include' }
122
- }) {
123
- assert(isFunction(this.fetch),
124
- `Can't make a call. The reference to fetch is missing or not a function.`);
125
- assert(isNonEmptyString(method), `Method must be a non empty string but it is "${method}"`);
126
- assert(isNonEmptyString(pathname), `Pathname must be string but it is "${pathname}"`);
127
- assert(isObject(data), `data must be a non-null object`);
128
-
129
- fetchOptions.headers = isObject(headers) ? cloneDefined(headers) : {};
130
- const fullUrl = this.makeUrl(pathname, data, useDefaultParams);
131
-
132
- logFn(this.log, 'Request:', fetchOptions.method.toUpperCase(), fullUrl);
133
- logFn(this.log, 'Request Headers:', fetchOptions.headers);
134
- logFn(this.log, 'Request Body:', fetchOptions.body);
135
- try {
136
- const response = await this.fetch(fullUrl, fetchOptions);
137
- logFn(this.log, 'Response Code:', response.status, response.statusText);
138
- if (!response.ok) {
139
- // status code not in range 200-299
140
- throw new SDKError(response.statusText, { code: response.status });
141
- }
142
- const responseObject = await response.json();
143
- logFn(this.log, 'Response Parsed:', responseObject);
144
- return responseObject;
145
- } catch (err) {
146
- let msg = isStr(err) ? err : 'Unknown RESTClient error';
147
- if (isObject(err) && isStr(err.message)) {
148
- msg = err.message;
149
- }
150
- throw new SDKError(`Failed to '${method}' '${fullUrl}': '${msg}'`, err);
151
- }
152
- }
153
-
154
- /**
155
- * Creates a url that points to an endpoint in the server
156
- * @param {string} [pathname=] - WHATWG pathname ie. 'api/2/endpoint-name'
157
- * @param {object} [query={}] - WHATWG query. It's the data payload.
158
- * @param {boolean} [useDefaultParams=true] - should we add the defaultParams to the query?
159
- * @return {string} - the resulting url string ready to pass to fetch
160
- */
161
- makeUrl(pathname = '', query = {}, useDefaultParams = true) {
162
- const handledPathname = pathname.startsWith('/') ? pathname.slice(1) : pathname;
163
-
164
- const url = new URL(handledPathname, this.url);
165
- url.search = RESTClient.search(query, useDefaultParams, this.defaultParams);
166
- return url.href;
167
- }
168
-
169
- /**
170
- * Make a GET request
171
- * @param {string} pathname - WHATWG pathname ie. 'api/2/endpoint-name'
172
- * @param {object} [data={}] - the data payload.
173
- * @return {Promise}
174
- */
175
- get(pathname, data) {
176
- return this.go({ method: 'get', pathname, data });
177
- }
178
-
179
- /**
180
- * Construct query string for WHATWG urls
181
- * @private
182
- * @param {object} query - Object to generate query string from
183
- * @param {boolean} useDefaultParams - Use defaultParams or not
184
- * @param {object} defaultParams - Default params
185
- * @returns {string} Query string
186
- */
187
- static search(query, useDefaultParams, defaultParams) {
188
- const params = useDefaultParams ? cloneDefined(defaultParams, query) : cloneDefined(query);
189
- return Object.keys(params).filter(p => params[p]!=='').map(p => `${encode(p)}=${encode(params[p])}`).join('&');
190
- }
191
- }
192
-
193
- export default RESTClient;
package/src/SDKError.d.ts DELETED
@@ -1,16 +0,0 @@
1
- /**
2
- * Represents a SDK error. This is returned from all rejected promises that are returned from an API
3
- * call. Constructs an SDK error ready to throw
4
- * @summary When the SDK throws an error, it's supposed to be an instance of this class
5
- * @private
6
- */
7
- export default class SDKError extends Error {
8
- /**
9
- * @property {number} code - The HTTP error code
10
- * @extends {Error}
11
- * @param {string} message - The error message
12
- * @param {object} [errorObject] - The error object that was returned from the server. Any
13
- * property of errorObject object will be copied into this instance SDKError
14
- */
15
- constructor(message: string, errorObject?: any);
16
- }
package/src/SDKError.js DELETED
@@ -1,55 +0,0 @@
1
- /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
2
- * See LICENSE.md in the project root.
3
- */
4
-
5
- 'use strict';
6
-
7
- /*
8
- * Note: this module can't have any internal dependencies because it's used in ./validate which
9
- * in turn is used as a dependency to a lot of other modules. Doing so may create a circular
10
- * dependency that's hard to debug in Node.
11
- */
12
-
13
- const STRINGIFY_TYPES = ['boolean', 'number', 'string'];
14
-
15
- /**
16
- * Represents a SDK error. This is returned from all rejected promises that are returned from an API
17
- * call. Constructs an SDK error ready to throw
18
- * @summary When the SDK throws an error, it's supposed to be an instance of this class
19
- * @private
20
- */
21
- export default class SDKError extends Error {
22
- /**
23
- * @property {number} code - The HTTP error code
24
- * @extends {Error}
25
- * @param {string} message - The error message
26
- * @param {object} [errorObject] - The error object that was returned from the server. Any
27
- * property of errorObject object will be copied into this instance SDKError
28
- */
29
- constructor(message, errorObject) {
30
- super(message);
31
- this.name = 'SDKError';
32
- if (typeof errorObject === 'object') {
33
- try {
34
- // At this point it doesn't matter if errorObject === null
35
- Object.assign(this, errorObject);
36
- } catch(err) {
37
- // silent
38
- }
39
- }
40
- }
41
-
42
- /**
43
- * Serializes the error printing any interesting additional info
44
- * @private
45
- * @return {String}
46
- */
47
- toString() {
48
- const ret = `${this.name}: ${this.message}`;
49
- const additionalInfo = Object.keys(this)
50
- .filter(key => key !== 'name' && STRINGIFY_TYPES.includes(typeof this[key]))
51
- .map(key => ` ${key}: ${this[key]}`)
52
- .join('\n');
53
- return additionalInfo ? `${ret}\n${additionalInfo}` : ret;
54
- }
55
- }
@@ -1,8 +0,0 @@
1
- rules:
2
- require-jsdoc: 0
3
- no-undefined: 0
4
- globals:
5
- beforeAll: true
6
- afterAll: true
7
- expect: true
8
- jest: true
@@ -1,54 +0,0 @@
1
- import { URL } from 'url';
2
- import { urlMapper } from '../url.js';
3
- import { cloneDefined } from '../object.js';
4
- import { Fixtures } from '../../__tests__/utils.js';
5
-
6
- const goFn = () => jest.fn().mockImplementation(async ({ pathname }) => {
7
- if (pathname.startsWith('/hasAccess/')) {
8
- if (pathname.endsWith('/existing')) {
9
- return Fixtures.sessionServiceAccess;
10
- } else if (pathname.endsWith('/non_existing')) {
11
- return Fixtures.sessionServiceNoAccess;
12
- } else if (pathname.endsWith('/existing,non_existing')) {
13
- return Fixtures.sessionServiceAccess;
14
- }
15
- }
16
- throw new Error(`Unimplemented mock response for url: '${pathname}'`);
17
- });
18
-
19
- function search(query, useDefaultParams, defaultParams) {
20
- const params = useDefaultParams ? cloneDefined(defaultParams, query) : cloneDefined(query);
21
- return Object.keys(params).filter(p => params[p]!=='').map(p => `${encode(p)}=${encode(params[p])}`).join('&');
22
- }
23
-
24
- function encode(str) {
25
- const replace = {
26
- '!': '%21',
27
- "'": '%27',
28
- '(': '%28',
29
- ')': '%29',
30
- '~': '%7E',
31
- '%20': '+',
32
- '%00': '\x00'
33
- };
34
- return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, match => replace[match]);
35
- }
36
-
37
- export const RESTClient = jest.fn().mockImplementation(({ serverUrl = 'PRE', envDic, defaultParams = {} }) => {
38
- const foo = {
39
- url: new URL(urlMapper(serverUrl, envDic)),
40
- defaultParams,
41
- go: goFn(),
42
- makeUrl: (pathname = '', query = {}, useDefaultParams = true) => {
43
- const url = new URL(pathname, foo.url);
44
- url.search = search(query, useDefaultParams, foo.defaultParams);
45
- return url.href;
46
- },
47
- get: (pathname, data) => {
48
- return foo.go({ method: 'get', pathname, data });
49
- },
50
- }
51
- return foo;
52
- });
53
-
54
- export default RESTClient;
package/src/cache.d.ts DELETED
@@ -1,64 +0,0 @@
1
- /**
2
- * Cache class that attempts WebStorage (session/local storage), and falls back to JS object literal
3
- * @private
4
- */
5
- export default class Cache {
6
- /**
7
- * @param {Storage} [storeProvider] - A function to return a WebStorage instance (either
8
- * `sessionStorage` or `localStorage` from a `Window` object)
9
- * @throws {SDKError} - If sessionStorage or localStorage are not accessible
10
- */
11
- constructor(storeProvider?: Storage);
12
- cache: WebStorageCache | LiteralCache;
13
- type: string;
14
- /**
15
- * Get a value from cache (checks that the object has not expired)
16
- * @param {string} key
17
- * @private
18
- * @returns {*} - The value if it exists, otherwise null
19
- */
20
- private get;
21
- /**
22
- * Set a cache entry
23
- * @param {string} key
24
- * @param {*} value
25
- * @param {Number} expiresIn - Value in milliseconds until the entry expires
26
- * @private
27
- * @returns {void}
28
- */
29
- private set;
30
- /**
31
- * Delete a cache entry
32
- * @param {string} key
33
- * @private
34
- * @returns {void}
35
- */
36
- private delete;
37
- }
38
- /**
39
- * Will be used if web storage is available
40
- * @private
41
- */
42
- declare class WebStorageCache {
43
- /**
44
- * Create web storage cache object
45
- * @param {Storage} store - A reference to either `sessionStorage` or `localStorage` from a
46
- * `Window` object
47
- */
48
- constructor(store: Storage);
49
- store: Storage;
50
- get: (key: any) => string;
51
- set: (key: any, value: any) => void;
52
- delete: (key: any) => void;
53
- }
54
- /**
55
- * Will be used if session storage is not available
56
- * @private
57
- */
58
- declare class LiteralCache {
59
- store: {};
60
- get: (key: any) => any;
61
- set: (key: any, value: any) => any;
62
- delete: (key: any) => boolean;
63
- }
64
- export {};
package/src/config.d.ts DELETED
@@ -1,34 +0,0 @@
1
- export default config;
2
- export const ENDPOINTS: any;
3
- export const NAMESPACE: any;
4
- /**
5
- * Core configuration used by the SDK
6
- * @type {Object}
7
- * @memberof core
8
- * @prop {object} ENDPOINTS - URL to some of the services that users of this SDK may interact with
9
- * @prop {object} ENDPOINTS.SPiD - SPiD endpoints
10
- * @prop {string} ENDPOINTS.SPiD.LOCAL - Local endpoint (for Identity team)
11
- * @prop {string} ENDPOINTS.SPiD.DEV - Dev environment (for Identity team)
12
- * @prop {string} ENDPOINTS.SPiD.PRE - Staging environment
13
- * @prop {string} ENDPOINTS.SPiD.PRO - Production environment Sweden
14
- * @prop {string} ENDPOINTS.SPiD.PRO_NO - Production environment Norway
15
- * @prop {string} ENDPOINTS.SPiD.PRO_FI - Production environment Finland
16
- * @prop {string} ENDPOINTS.SPiD.PRO_DK - Production environment Denmark
17
- * @prop {object} ENDPOINTS.BFF - Endpoints used with new GDPR-compliant web flows
18
- * @prop {string} ENDPOINTS.BFF.LOCAL - Local endpoint (for Identity team)
19
- * @prop {string} ENDPOINTS.BFF.DEV - Dev environment (for Identity team)
20
- * @prop {string} ENDPOINTS.BFF.PRE - Staging environment
21
- * @prop {string} ENDPOINTS.BFF.PRO - Production environment Sweden
22
- * @prop {string} ENDPOINTS.BFF.PRO_NO - Production environment Norway
23
- * @prop {string} ENDPOINTS.BFF.PRO_FI - Production environment Finland
24
- * @prop {string} ENDPOINTS.BFF.PRO_DK - Production environment Denmark
25
- * @prop {object} ENDPOINTS.SESSION_SERVICE - Endpoints to check global user session data
26
- * @prop {string} ENDPOINTS.SESSION_SERVICE.LOCAL - Local endpoint (for Identity team)
27
- * @prop {string} ENDPOINTS.SESSION_SERVICE.DEV - Dev environment (for Identity team)
28
- * @prop {string} ENDPOINTS.SESSION_SERVICE.PRE - Staging environment
29
- * @prop {string} ENDPOINTS.SESSION_SERVICE.PRO - Production environment Sweden
30
- * @prop {string} ENDPOINTS.SESSION_SERVICE.PRO_NO - Production environment Norway
31
- * @prop {string} ENDPOINTS.SESSION_SERVICE.PRO_FI - Production environment Finland
32
- * @prop {string} ENDPOINTS.SESSION_SERVICE.PRO_DK - Production environment Denmark
33
- */
34
- declare const config: Object;
package/src/es5/global.js DELETED
@@ -1,13 +0,0 @@
1
- /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
2
- * See LICENSE.md in the project root.
3
- */
4
-
5
- /* This file is usually not used by the SDK, but is a simple wrapper to generate a file where the
6
- * three classes Identity, Monetization and Payment are available on the window object.
7
- */
8
-
9
- 'use strict';
10
-
11
- const { Identity, Monetization, Payment } = require('./index');
12
-
13
- Object.assign(window, { Identity, Monetization, Payment });
@@ -1,10 +0,0 @@
1
- /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
2
- * See LICENSE.md in the project root.
3
- */
4
-
5
- 'use strict';
6
-
7
- window.regeneratorRuntime = require('regenerator-runtime');
8
- const { Identity } = require('../identity.js');
9
-
10
- module.exports = { Identity };
package/src/es5/index.js DELETED
@@ -1,13 +0,0 @@
1
- /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
2
- * See LICENSE.md in the project root.
3
- */
4
-
5
- 'use strict';
6
-
7
- window.regeneratorRuntime = require('regenerator-runtime');
8
-
9
- const { Identity } = require('../identity');
10
- const { Monetization } = require('../monetization');
11
- const { Payment } = require('../payment');
12
-
13
- module.exports = { Identity, Monetization, Payment };
@@ -1,10 +0,0 @@
1
- /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
2
- * See LICENSE.md in the project root.
3
- */
4
-
5
- 'use strict';
6
-
7
- window.regeneratorRuntime = require('regenerator-runtime');
8
- const { Monetization } = require('../monetization');
9
-
10
- module.exports = { Monetization };
@@ -1,10 +0,0 @@
1
- /* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
2
- * See LICENSE.md in the project root.
3
- */
4
-
5
- 'use strict';
6
-
7
- window.regeneratorRuntime = require('regenerator-runtime');
8
- const { Payment } = require('../payment');
9
-
10
- module.exports = { Payment };
@@ -1,20 +0,0 @@
1
-
2
- /**
3
- * Registers a component as a property on the provided global object, if not already registered, and dispatches an event to notify listeners.
4
- * The event is dispatched on `document` and will have the name `$sch${componentClassName}:ready` and a `detail` property with the instance.
5
- *
6
- * @param {any} global typically `window`
7
- * @param {string} componentClassName the name of the component to register, 'identity', 'monetization' or 'payment'
8
- * @param {any} instance the instance of the component to register
9
- * @returns {void}
10
- */
11
- export const registerGlobal = (global, componentClassName, instance) => {
12
- const prefixedName = `sch${componentClassName}`;
13
- if (!(global)[prefixedName]) {
14
- (global)[prefixedName] = instance;
15
- }
16
- if (typeof global.dispatchEvent === 'function') {
17
- global.dispatchEvent(new CustomEvent(`${prefixedName}:ready`, { detail: { instance } }));
18
- }
19
- }
20
-