@schibsted/account-sdk-browser 4.8.6-beta → 4.8.7
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/LICENSE.md +1 -1
- package/README.md +2 -2
- package/es5/global.js +2996 -3028
- 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 +2959 -2991
- 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 +3000 -3032
- 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 +20 -21
- 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 +19 -20
- package/es5/payment.js.map +1 -1
- package/es5/payment.min.js.map +1 -1
- package/identity.js +1 -1
- package/index.js +1 -1
- package/monetization.js +1 -1
- package/package.json +3 -6
- package/payment.js +1 -1
- package/src/RESTClient.js +1 -1
- package/src/SDKError.js +1 -1
- package/src/cache.js +1 -1
- package/src/config.js +1 -1
- package/src/es5/global.js +1 -1
- package/src/es5/identity.js +1 -1
- package/src/es5/index.js +1 -1
- package/src/es5/monetization.js +1 -1
- package/src/es5/payment.js +1 -1
- package/src/identity.d.ts +2 -5
- package/src/identity.js +13 -31
- package/src/monetization.js +1 -1
- package/src/object.js +9 -9
- package/src/payment.js +1 -1
- package/src/popup.js +1 -1
- package/src/spidTalk.js +1 -1
- package/src/url.js +1 -1
- package/src/validate.js +1 -1
- package/src/version.js +1 -1
package/identity.js
CHANGED
package/index.js
CHANGED
package/monetization.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@schibsted/account-sdk-browser",
|
|
3
|
-
"version": "4.8.
|
|
3
|
+
"version": "4.8.7",
|
|
4
4
|
"description": "Schibsted account SDK for browsers",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -9,12 +9,10 @@
|
|
|
9
9
|
"clean": "rimraf .cache coverage dist docs",
|
|
10
10
|
"docs": "rimraf docs && jsdoc -c ./jsdoc.conf.json --verbose",
|
|
11
11
|
"lint": "eslint .",
|
|
12
|
-
"
|
|
12
|
+
"lint:fix": "eslint . --fix",
|
|
13
13
|
"test": "jest",
|
|
14
|
-
"precover": "npm run lint",
|
|
15
14
|
"cover": "jest --coverage",
|
|
16
|
-
"
|
|
17
|
-
"preversion": "npm test",
|
|
15
|
+
"preversion": "npm run lint && npm test",
|
|
18
16
|
"version": "node ./scripts/genversion.js && git add src/version.js",
|
|
19
17
|
"postversion": "git push && git push --tags"
|
|
20
18
|
},
|
|
@@ -27,7 +25,6 @@
|
|
|
27
25
|
"@babel/core": "^7.11.4",
|
|
28
26
|
"@babel/preset-env": "^7.23.2",
|
|
29
27
|
"babel-loader": "^8.1.0",
|
|
30
|
-
"codecov": "^3.6.5",
|
|
31
28
|
"core-js": "^3.6.5",
|
|
32
29
|
"docdash": "git+https://github.com/torarvid/docdash.git#v0.5.0",
|
|
33
30
|
"eslint": "^6.8.0",
|
package/payment.js
CHANGED
package/src/RESTClient.js
CHANGED
package/src/SDKError.js
CHANGED
package/src/cache.js
CHANGED
package/src/config.js
CHANGED
package/src/es5/global.js
CHANGED
package/src/es5/identity.js
CHANGED
package/src/es5/index.js
CHANGED
package/src/es5/monetization.js
CHANGED
package/src/es5/payment.js
CHANGED
package/src/identity.d.ts
CHANGED
|
@@ -236,6 +236,8 @@ export class Identity extends TinyEmitter {
|
|
|
236
236
|
*
|
|
237
237
|
* @description This function calls {@link Identity#hasSession} internally and thus has the side
|
|
238
238
|
* effect that it might perform an auto-login on the user
|
|
239
|
+
* @param {string} externalParty
|
|
240
|
+
* @param {string|null} optionalSuffix
|
|
239
241
|
* @throws {SDKError} If the `pairId` is missing in user session.
|
|
240
242
|
* @throws {SDKError} If the `externalParty` is not defined
|
|
241
243
|
* @return {Promise<string>} The merchant- and 3rd-party-specific `externalId`
|
|
@@ -553,11 +555,6 @@ export type HasSessionSuccessResponse = {
|
|
|
553
555
|
* - (Only for connected users)
|
|
554
556
|
*/
|
|
555
557
|
defaultAgreementAccepted: boolean;
|
|
556
|
-
} | {
|
|
557
|
-
/**
|
|
558
|
-
* Used for expiring session in Safari browser to indicate redirection need
|
|
559
|
-
*/
|
|
560
|
-
redirectURL: string;
|
|
561
558
|
};
|
|
562
559
|
export type HasSessionFailureResponse = {
|
|
563
560
|
error: {
|
package/src/identity.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* Copyright
|
|
1
|
+
/* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
|
|
2
2
|
* See LICENSE.md in the project root.
|
|
3
3
|
*/
|
|
4
4
|
|
|
@@ -365,7 +365,8 @@ export class Identity extends EventEmitter {
|
|
|
365
365
|
expiresIn = options;
|
|
366
366
|
}
|
|
367
367
|
else if (typeof options == 'object') {
|
|
368
|
-
|
|
368
|
+
expiresIn = options.expiresIn || expiresIn;
|
|
369
|
+
domain = options.domain || domain;
|
|
369
370
|
}
|
|
370
371
|
|
|
371
372
|
assert(Number.isInteger(expiresIn), `'expiresIn' must be an integer`);
|
|
@@ -428,10 +429,12 @@ export class Identity extends EventEmitter {
|
|
|
428
429
|
* @returns {void}
|
|
429
430
|
*/
|
|
430
431
|
_clearVarnishCookie() {
|
|
432
|
+
const baseDomain = this._session && typeof this._session.baseDomain === 'string'
|
|
433
|
+
? this._session.baseDomain
|
|
434
|
+
: document.domain;
|
|
435
|
+
|
|
431
436
|
let domain = this.varnishCookieDomain ||
|
|
432
|
-
|
|
433
|
-
? this._session.baseDomain
|
|
434
|
-
: document.domain) ||
|
|
437
|
+
baseDomain ||
|
|
435
438
|
'';
|
|
436
439
|
|
|
437
440
|
document.cookie = `SP_ID=nothing; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; domain=.${domain}`;
|
|
@@ -489,18 +492,6 @@ export class Identity extends EventEmitter {
|
|
|
489
492
|
this._session = sessionData;
|
|
490
493
|
return sessionData;
|
|
491
494
|
};
|
|
492
|
-
const _checkRedirectionNeed = (sessionData={})=>{
|
|
493
|
-
const sessionDataKeys = Object.keys(sessionData);
|
|
494
|
-
|
|
495
|
-
const isRedirectNeeded = sessionDataKeys.length === 1 &&
|
|
496
|
-
sessionDataKeys[0] === 'redirectURL';
|
|
497
|
-
|
|
498
|
-
if(isRedirectNeeded && !isUrl(sessionData.redirectURL)){
|
|
499
|
-
throw new SDKError('Session refresh url is not valid');
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
return isRedirectNeeded;
|
|
503
|
-
}
|
|
504
495
|
const _getSession = async () => {
|
|
505
496
|
if (this._enableSessionCaching) {
|
|
506
497
|
// Try to resolve from cache (it has a TTL)
|
|
@@ -520,19 +511,10 @@ export class Identity extends EventEmitter {
|
|
|
520
511
|
throw err;
|
|
521
512
|
}
|
|
522
513
|
|
|
523
|
-
if(sessionData){
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
window.location.replace(sessionData.redirectURL);
|
|
527
|
-
return;
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
if (this._enableSessionCaching) {
|
|
531
|
-
const expiresIn = 1000 * (sessionData.expiresIn || 300);
|
|
532
|
-
this.cache.set(HAS_SESSION_CACHE_KEY, sessionData, expiresIn);
|
|
533
|
-
}
|
|
514
|
+
if (sessionData && this._enableSessionCaching) {
|
|
515
|
+
const expiresIn = 1000 * (sessionData.expiresIn || 300);
|
|
516
|
+
this.cache.set(HAS_SESSION_CACHE_KEY, sessionData, expiresIn);
|
|
534
517
|
}
|
|
535
|
-
|
|
536
518
|
return _postProcess(sessionData);
|
|
537
519
|
};
|
|
538
520
|
this._hasSessionInProgress = _getSession()
|
|
@@ -650,10 +632,10 @@ export class Identity extends EventEmitter {
|
|
|
650
632
|
* meaning the same user's ID will differ between merchants.
|
|
651
633
|
* Additionally, this identifier is bound to the external party provided as argument.
|
|
652
634
|
*
|
|
653
|
-
* @param {string} externalParty
|
|
654
|
-
* @param {string|null} optionalSuffix
|
|
655
635
|
* @description This function calls {@link Identity#hasSession} internally and thus has the side
|
|
656
636
|
* effect that it might perform an auto-login on the user
|
|
637
|
+
* @param {string} externalParty
|
|
638
|
+
* @param {string|null} optionalSuffix
|
|
657
639
|
* @throws {SDKError} If the `pairId` is missing in user session.
|
|
658
640
|
* @throws {SDKError} If the `externalParty` is not defined
|
|
659
641
|
* @return {Promise<string>} The merchant- and 3rd-party-specific `externalId`
|
package/src/monetization.js
CHANGED
package/src/object.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* Copyright
|
|
1
|
+
/* Copyright 2024 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
|
|
2
2
|
* See LICENSE.md in the project root.
|
|
3
3
|
*/
|
|
4
4
|
|
|
@@ -28,21 +28,21 @@ import SDKError from './SDKError.js';
|
|
|
28
28
|
* keys for undefined values are removed.
|
|
29
29
|
*/
|
|
30
30
|
export function cloneDefined(...sources) {
|
|
31
|
-
const
|
|
31
|
+
const result = {};
|
|
32
32
|
if (!(sources && sources.length)) {
|
|
33
33
|
throw new SDKError('No objects to clone');
|
|
34
34
|
}
|
|
35
|
-
sources.forEach(
|
|
36
|
-
assert(isObject(
|
|
37
|
-
if (isNonEmptyObj(
|
|
38
|
-
Object.entries(
|
|
39
|
-
if (
|
|
40
|
-
|
|
35
|
+
sources.forEach(source => {
|
|
36
|
+
assert(isObject(source));
|
|
37
|
+
if (isNonEmptyObj(source)) {
|
|
38
|
+
Object.entries(source).forEach(([key, value]) => {
|
|
39
|
+
if (typeof value !== 'undefined' ) {
|
|
40
|
+
result[key] = isObject(value) ? cloneDeep(value) : value;
|
|
41
41
|
}
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
});
|
|
45
|
-
return
|
|
45
|
+
return result;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
/**
|
package/src/payment.js
CHANGED
package/src/popup.js
CHANGED
package/src/spidTalk.js
CHANGED
package/src/url.js
CHANGED
package/src/validate.js
CHANGED
package/src/version.js
CHANGED