@schibsted/account-sdk-browser 5.2.2 → 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 +79 -17
- 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 +68 -12
- 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 +79 -17
- 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.d.ts +24 -3
- package/src/identity.js +35 -12
- 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.d.ts
CHANGED
|
@@ -305,9 +305,11 @@ export class Identity extends TinyEmitter {
|
|
|
305
305
|
* @param {boolean} [options.oneStepLogin=false]
|
|
306
306
|
* @param {string} [options.prompt=select_account]
|
|
307
307
|
* @param {string} [options.xDomainId]
|
|
308
|
+
* @param {string} [options.xEnvironmentId]
|
|
309
|
+
* @param {string} [options.originCampaign]
|
|
308
310
|
* @return {Window|null} - Reference to popup window if created (or `null` otherwise)
|
|
309
311
|
*/
|
|
310
|
-
login({ state, acrValues, scope, redirectUri, preferPopup, loginHint, tag, teaser, maxAge, locale, oneStepLogin, prompt, xDomainId }: LoginOptions): Window | null;
|
|
312
|
+
login({ state, acrValues, scope, redirectUri, preferPopup, loginHint, tag, teaser, maxAge, locale, oneStepLogin, prompt, xDomainId, xEnvironmentId, originCampaign }: LoginOptions): Window | null;
|
|
311
313
|
/**
|
|
312
314
|
* @async
|
|
313
315
|
* @summary Retrieve the sp_id (Varnish ID)
|
|
@@ -337,9 +339,12 @@ export class Identity extends TinyEmitter {
|
|
|
337
339
|
* @param {string} [options.locale]
|
|
338
340
|
* @param {boolean} [options.oneStepLogin=false]
|
|
339
341
|
* @param {string} [options.prompt=select_account]
|
|
342
|
+
* @param {string} [options.xDomainId]
|
|
343
|
+
* @param {string} [options.xEnvironmentId]
|
|
344
|
+
* @param {string} [options.originCampaign]
|
|
340
345
|
* @return {string} - The url
|
|
341
346
|
*/
|
|
342
|
-
loginUrl({ state, acrValues, scope, redirectUri, loginHint, tag, teaser, maxAge, locale, oneStepLogin, prompt, }: LoginOptions, ...args: any[]): string;
|
|
347
|
+
loginUrl({ state, acrValues, scope, redirectUri, loginHint, tag, teaser, maxAge, locale, oneStepLogin, prompt, xDomainId, xEnvironmentId, originCampaign }: LoginOptions, ...args: any[]): string;
|
|
343
348
|
/**
|
|
344
349
|
* The url for logging the user out
|
|
345
350
|
* @param {string} [redirectUri=this.redirectUri]
|
|
@@ -444,7 +449,14 @@ export type LoginOptions = {
|
|
|
444
449
|
* - Identifier for cross-domain tracking in Pulse
|
|
445
450
|
*/
|
|
446
451
|
xDomainId?: string;
|
|
447
|
-
|
|
452
|
+
/**
|
|
453
|
+
* - Environment for cross-domain tracking in Pulse
|
|
454
|
+
*/
|
|
455
|
+
xEnvironmentId?: string;
|
|
456
|
+
/**
|
|
457
|
+
* - Campaign identifier for tracking in Pulse
|
|
458
|
+
*/
|
|
459
|
+
originCampaign?: string;
|
|
448
460
|
};
|
|
449
461
|
export type SimplifiedLoginWidgetLoginOptions = {
|
|
450
462
|
/**
|
|
@@ -518,6 +530,15 @@ export type SimplifiedLoginWidgetLoginOptions = {
|
|
|
518
530
|
* - Identifier for cross-domain tracking in Pulse
|
|
519
531
|
*/
|
|
520
532
|
xDomainId?: string;
|
|
533
|
+
/**
|
|
534
|
+
* - Environment for cross-domain tracking in Pulse
|
|
535
|
+
*/
|
|
536
|
+
xEnvironmentId?: string;
|
|
537
|
+
/**
|
|
538
|
+
* - Campaign identifier for tracking in Pulse
|
|
539
|
+
*/
|
|
540
|
+
originCampaign?: string;
|
|
541
|
+
|
|
521
542
|
};
|
|
522
543
|
export type HasSessionSuccessResponse = {
|
|
523
544
|
/**
|
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
|
|
@@ -26,7 +27,7 @@ import version from './version.js';
|
|
|
26
27
|
* `password` (will force password confirmation, even if user is already logged in), `eid`. Those values might
|
|
27
28
|
* be mixed as space-separated string. To make sure that user has authenticated with 2FA you need
|
|
28
29
|
* to verify AMR (Authentication Methods References) claim in ID token.
|
|
29
|
-
* Might also be used to ensure additional acr (sms, otp) for already logged
|
|
30
|
+
* Might also be used to ensure additional acr (sms, otp) for already logged-in users.
|
|
30
31
|
* Supported value is also 'otp-email' means one time password using email.
|
|
31
32
|
* @property {string} [scope] - The OAuth scopes for the tokens. This is a list of
|
|
32
33
|
* scopes, separated by space. If the list of scopes contains `openid`, the generated tokens
|
|
@@ -36,7 +37,7 @@ import version from './version.js';
|
|
|
36
37
|
* @property {string} [redirectUri] - Redirect uri that will receive the
|
|
37
38
|
* code. Must exactly match a redirectUri from your client in self-service
|
|
38
39
|
* @property {boolean} [preferPopup] - Should we try to open a popup window?
|
|
39
|
-
* @property {string} [loginHint] -
|
|
40
|
+
* @property {string} [loginHint] - User email or UUID hint
|
|
40
41
|
* @property {string} [tag] - Pulse tag
|
|
41
42
|
* @property {string} [teaser] - Teaser slug. Teaser with given slug will be displayed
|
|
42
43
|
* in place of default teaser
|
|
@@ -46,9 +47,12 @@ import version from './version.js';
|
|
|
46
47
|
* spec section 3.1.2.1 for more information
|
|
47
48
|
* @property {string} [locale] - Optional parameter to overwrite client locale setting.
|
|
48
49
|
* New flows supports nb_NO, fi_FI, sv_SE, en_US
|
|
49
|
-
* @property {boolean} [oneStepLogin] -
|
|
50
|
+
* @property {boolean} [oneStepLogin] - Display username and password on one screen
|
|
50
51
|
* @property {string} [prompt] - String that specifies whether the Authorization Server prompts the
|
|
51
|
-
* End-User for
|
|
52
|
+
* End-User for re-authentication or confirm account screen. Supported values: `select_account` or `login`
|
|
53
|
+
* @property {string} [xDomainId] - Identifier for cross-domain tracking in Pulse
|
|
54
|
+
* @property {string} [xEnvironmentId] - Environment for cross-domain tracking in Pulse
|
|
55
|
+
* @property {string} [originCampaign] - Campaign identifier for tracking in Pulse
|
|
52
56
|
*/
|
|
53
57
|
/**
|
|
54
58
|
* @typedef {object} SimplifiedLoginWidgetLoginOptions
|
|
@@ -60,7 +64,7 @@ import version from './version.js';
|
|
|
60
64
|
* `password` (will force password confirmation, even if user is already logged in). Those values might
|
|
61
65
|
* be mixed as space-separated string. To make sure that user has authenticated with 2FA you need
|
|
62
66
|
* to verify AMR (Authentication Methods References) claim in ID token.
|
|
63
|
-
* Might also be used to ensure additional acr (sms, otp) for already logged
|
|
67
|
+
* Might also be used to ensure additional acr (sms, otp) for already logged-in users.
|
|
64
68
|
* Supported value is also 'otp-email' means one time password using email.
|
|
65
69
|
* @property {string} [scope] - The OAuth scopes for the tokens. This is a list of
|
|
66
70
|
* scopes, separated by space. If the list of scopes contains `openid`, the generated tokens
|
|
@@ -70,7 +74,7 @@ import version from './version.js';
|
|
|
70
74
|
* @property {string} [redirectUri] - Redirect uri that will receive the
|
|
71
75
|
* code. Must exactly match a redirectUri from your client in self-service
|
|
72
76
|
* @property {boolean} [preferPopup] - Should we try to open a popup window?
|
|
73
|
-
* @property {string} [loginHint] -
|
|
77
|
+
* @property {string} [loginHint] - User email or UUID hint
|
|
74
78
|
* @property {string} [tag] - Pulse tag
|
|
75
79
|
* @property {string} [teaser] - Teaser slug. Teaser with given slug will be displayed
|
|
76
80
|
* in place of default teaser
|
|
@@ -80,9 +84,12 @@ import version from './version.js';
|
|
|
80
84
|
* spec section 3.1.2.1 for more information
|
|
81
85
|
* @property {string} [locale] - Optional parameter to overwrite client locale setting.
|
|
82
86
|
* New flows supports nb_NO, fi_FI, sv_SE, en_US
|
|
83
|
-
* @property {boolean} [oneStepLogin] -
|
|
87
|
+
* @property {boolean} [oneStepLogin] - Display username and password on one screen
|
|
84
88
|
* @property {string} [prompt] - String that specifies whether the Authorization Server prompts the
|
|
85
89
|
* End-User for reauthentication or confirm account screen. Supported values: `select_account` or `login`
|
|
90
|
+
* @property {string} [xDomainId] - Identifier for cross-domain tracking in Pulse
|
|
91
|
+
* @property {string} [xEnvironmentId] - Environment for cross-domain tracking in Pulse
|
|
92
|
+
* @property {string} [originCampaign] - Campaign identifier for tracking in Pulse
|
|
86
93
|
*/
|
|
87
94
|
|
|
88
95
|
/**
|
|
@@ -212,6 +219,9 @@ export class Identity extends EventEmitter {
|
|
|
212
219
|
this._setGlobalSessionServiceUrl(env);
|
|
213
220
|
|
|
214
221
|
this._unblockSessionCall();
|
|
222
|
+
|
|
223
|
+
registerGlobal(window, 'Identity', this);
|
|
224
|
+
|
|
215
225
|
}
|
|
216
226
|
|
|
217
227
|
/**
|
|
@@ -834,6 +844,7 @@ export class Identity extends EventEmitter {
|
|
|
834
844
|
return null;
|
|
835
845
|
}
|
|
836
846
|
}
|
|
847
|
+
|
|
837
848
|
/**
|
|
838
849
|
* If a popup is desired, this function needs to be called in response to a user event (like
|
|
839
850
|
* click or tap) in order to work correctly. Otherwise the popup will be blocked by the
|
|
@@ -855,6 +866,8 @@ export class Identity extends EventEmitter {
|
|
|
855
866
|
* @param {boolean} [options.oneStepLogin=false]
|
|
856
867
|
* @param {string} [options.prompt=select_account]
|
|
857
868
|
* @param {string} [options.xDomainId]
|
|
869
|
+
* @param {string} [options.xEnvironmentId]
|
|
870
|
+
* @param {string} [options.originCampaign]
|
|
858
871
|
* @return {Window|null} - Reference to popup window if created (or `null` otherwise)
|
|
859
872
|
*/
|
|
860
873
|
login({
|
|
@@ -870,7 +883,9 @@ export class Identity extends EventEmitter {
|
|
|
870
883
|
locale = '',
|
|
871
884
|
oneStepLogin = false,
|
|
872
885
|
prompt = 'select_account',
|
|
873
|
-
xDomainId = ''
|
|
886
|
+
xDomainId = '',
|
|
887
|
+
xEnvironmentId = '',
|
|
888
|
+
originCampaign = ''
|
|
874
889
|
}) {
|
|
875
890
|
this._closePopup();
|
|
876
891
|
this.sessionStorageCache.delete(HAS_SESSION_CACHE_KEY);
|
|
@@ -886,7 +901,9 @@ export class Identity extends EventEmitter {
|
|
|
886
901
|
locale,
|
|
887
902
|
oneStepLogin,
|
|
888
903
|
prompt,
|
|
889
|
-
xDomainId
|
|
904
|
+
xDomainId,
|
|
905
|
+
xEnvironmentId,
|
|
906
|
+
originCampaign
|
|
890
907
|
});
|
|
891
908
|
|
|
892
909
|
if (preferPopup) {
|
|
@@ -943,6 +960,9 @@ export class Identity extends EventEmitter {
|
|
|
943
960
|
* @param {string} [options.locale]
|
|
944
961
|
* @param {boolean} [options.oneStepLogin=false]
|
|
945
962
|
* @param {string} [options.prompt=select_account]
|
|
963
|
+
* @param {string} [options.xDomainId]
|
|
964
|
+
* @param {string} [options.xEnvironmentId]
|
|
965
|
+
* @param {string} [options.originCampaign]
|
|
946
966
|
* @return {string} - The url
|
|
947
967
|
*/
|
|
948
968
|
loginUrl({
|
|
@@ -957,7 +977,9 @@ export class Identity extends EventEmitter {
|
|
|
957
977
|
locale = '',
|
|
958
978
|
oneStepLogin = false,
|
|
959
979
|
prompt = 'select_account',
|
|
960
|
-
xDomainId = ''
|
|
980
|
+
xDomainId = '',
|
|
981
|
+
xEnvironmentId = '',
|
|
982
|
+
originCampaign = ''
|
|
961
983
|
}) {
|
|
962
984
|
if (typeof arguments[0] !== 'object') {
|
|
963
985
|
// backward compatibility
|
|
@@ -991,7 +1013,9 @@ export class Identity extends EventEmitter {
|
|
|
991
1013
|
locale,
|
|
992
1014
|
one_step_login: oneStepLogin || '',
|
|
993
1015
|
prompt: acrValues ? '' : prompt,
|
|
994
|
-
x_domain_id: xDomainId
|
|
1016
|
+
x_domain_id: xDomainId,
|
|
1017
|
+
x_env_id: xEnvironmentId,
|
|
1018
|
+
utm_campaign: originCampaign
|
|
995
1019
|
});
|
|
996
1020
|
}
|
|
997
1021
|
|
|
@@ -1061,7 +1085,6 @@ export class Identity extends EventEmitter {
|
|
|
1061
1085
|
return loginPrams;
|
|
1062
1086
|
}
|
|
1063
1087
|
|
|
1064
|
-
|
|
1065
1088
|
return new Promise(
|
|
1066
1089
|
(resolve, reject) => {
|
|
1067
1090
|
if (!userData || !userData.display_text || !userData.identifier) {
|
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