@schibsted/account-sdk-browser 5.2.3 → 5.2.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/README.md +78 -58
- package/es5/global.js +45 -6
- package/es5/global.js.map +1 -1
- package/es5/global.min.js +1 -1
- package/es5/global.min.js.map +1 -1
- package/es5/identity.js +34 -1
- package/es5/identity.js.map +1 -1
- package/es5/identity.min.js +1 -1
- package/es5/identity.min.js.map +1 -1
- package/es5/index.js +45 -6
- package/es5/index.js.map +1 -1
- package/es5/index.min.js +1 -1
- package/es5/index.min.js.map +1 -1
- package/es5/monetization.js +34 -1
- package/es5/monetization.js.map +1 -1
- package/es5/monetization.min.js +1 -1
- package/es5/monetization.min.js.map +1 -1
- package/es5/payment.js +33 -0
- package/es5/payment.js.map +1 -1
- package/es5/payment.min.js +1 -1
- package/es5/payment.min.js.map +1 -1
- package/package.json +1 -1
- package/src/global-registry.js +20 -0
- package/src/identity.js +4 -0
- package/src/monetization.js +2 -0
- package/src/payment.js +2 -0
- package/src/version.js +1 -1
package/package.json
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
|
package/src/identity.js
CHANGED
|
@@ -15,6 +15,7 @@ import RESTClient from './RESTClient.js';
|
|
|
15
15
|
import SDKError from './SDKError.js';
|
|
16
16
|
import * as spidTalk from './spidTalk.js';
|
|
17
17
|
import version from './version.js';
|
|
18
|
+
import { registerGlobal } from './global-registry.js';
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* @typedef {object} LoginOptions
|
|
@@ -218,6 +219,9 @@ export class Identity extends EventEmitter {
|
|
|
218
219
|
this._setGlobalSessionServiceUrl(env);
|
|
219
220
|
|
|
220
221
|
this._unblockSessionCall();
|
|
222
|
+
|
|
223
|
+
registerGlobal(window, 'Identity', this);
|
|
224
|
+
|
|
221
225
|
}
|
|
222
226
|
|
|
223
227
|
/**
|
package/src/monetization.js
CHANGED
|
@@ -13,6 +13,7 @@ import Cache from './cache.js';
|
|
|
13
13
|
import * as spidTalk from './spidTalk.js';
|
|
14
14
|
import SDKError from './SDKError.js';
|
|
15
15
|
import version from './version.js';
|
|
16
|
+
import { registerGlobal } from './global-registry.js';
|
|
16
17
|
|
|
17
18
|
const globalWindow = () => window;
|
|
18
19
|
|
|
@@ -45,6 +46,7 @@ export class Monetization extends EventEmitter {
|
|
|
45
46
|
assert(isUrl(sessionDomain), 'sessionDomain parameter is not a valid URL');
|
|
46
47
|
this._setSessionServiceUrl(sessionDomain);
|
|
47
48
|
}
|
|
49
|
+
registerGlobal(window, 'Monetization', this);
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
/**
|
package/src/payment.js
CHANGED
|
@@ -10,6 +10,7 @@ import { ENDPOINTS } from './config.js';
|
|
|
10
10
|
import * as popup from './popup.js';
|
|
11
11
|
import RESTClient from './RESTClient.js';
|
|
12
12
|
import * as spidTalk from './spidTalk.js';
|
|
13
|
+
import { registerGlobal } from './global-registry.js';
|
|
13
14
|
|
|
14
15
|
const globalWindow = () => window;
|
|
15
16
|
|
|
@@ -37,6 +38,7 @@ export class Payment {
|
|
|
37
38
|
this.publisher = publisher;
|
|
38
39
|
this._setSpidServerUrl(env);
|
|
39
40
|
this._setBffServerUrl(env);
|
|
41
|
+
registerGlobal(window, 'Payment', this);
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
/**
|
package/src/version.js
CHANGED