@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/identity.js CHANGED
@@ -1,4 +1,4 @@
1
- /* Copyright 2018 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
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
 
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /* Copyright 2018 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
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
 
package/monetization.js CHANGED
@@ -1,4 +1,4 @@
1
- /* Copyright 2018 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schibsted/account-sdk-browser",
3
- "version": "4.8.6-beta",
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
- "pretest": "npm run lint",
12
+ "lint:fix": "eslint . --fix",
13
13
  "test": "jest",
14
- "precover": "npm run lint",
15
14
  "cover": "jest --coverage",
16
- "postcover": "codecov",
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
@@ -1,4 +1,4 @@
1
- /* Copyright 2018 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
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
 
package/src/RESTClient.js CHANGED
@@ -1,4 +1,4 @@
1
- /* Copyright 2018 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
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
 
package/src/SDKError.js CHANGED
@@ -1,4 +1,4 @@
1
- /* Copyright 2018 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
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
 
package/src/cache.js CHANGED
@@ -1,4 +1,4 @@
1
- /* Copyright 2018 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
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
 
package/src/config.js CHANGED
@@ -1,4 +1,4 @@
1
- /* Copyright 2018 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
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
 
package/src/es5/global.js CHANGED
@@ -1,4 +1,4 @@
1
- /* Copyright 2018 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
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
 
@@ -1,4 +1,4 @@
1
- /* Copyright 2018 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
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
 
package/src/es5/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /* Copyright 2018 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
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
 
@@ -1,4 +1,4 @@
1
- /* Copyright 2018 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
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
 
@@ -1,4 +1,4 @@
1
- /* Copyright 2018 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
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
 
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 2018 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
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
- ({ expiresIn = expiresIn, domain = domain } = options);
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
- ((this._session && typeof this._session.baseDomain === 'string')
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
- // for expiring session and safari browser do full page redirect to gain new session
525
- if(_checkRedirectionNeed(sessionData)){
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`
@@ -1,4 +1,4 @@
1
- /* Copyright 2018 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
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
 
package/src/object.js CHANGED
@@ -1,4 +1,4 @@
1
- /* Copyright 2018 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
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 dest = {};
31
+ const result = {};
32
32
  if (!(sources && sources.length)) {
33
33
  throw new SDKError('No objects to clone');
34
34
  }
35
- sources.forEach(src => {
36
- assert(isObject(src));
37
- if (isNonEmptyObj(src)) {
38
- Object.entries(src).forEach(([key, val]) => {
39
- if (val !== undefined ) { // eslint-disable-line no-undefined
40
- dest[key] = isObject(val) ? cloneDeep(val) : val;
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 dest;
45
+ return result;
46
46
  }
47
47
 
48
48
  /**
package/src/payment.js CHANGED
@@ -1,4 +1,4 @@
1
- /* Copyright 2018 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
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
 
package/src/popup.js CHANGED
@@ -1,4 +1,4 @@
1
- /* Copyright 2018 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
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
 
package/src/spidTalk.js CHANGED
@@ -1,4 +1,4 @@
1
- /* Copyright 2018 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
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
 
package/src/url.js CHANGED
@@ -1,4 +1,4 @@
1
- /* Copyright 2018 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
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
 
package/src/validate.js CHANGED
@@ -1,4 +1,4 @@
1
- /* Copyright 2018 Schibsted Products & Technology AS. Licensed under the terms of the MIT license.
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
 
package/src/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // Automatically generated in 'npm version' by scripts/genversion.js
2
2
 
3
3
  'use strict'
4
- const version = '4.8.5';
4
+ const version = '4.8.7';
5
5
  export default version;