diff --git a/Identity.html b/Identity.html index f4ac366e..4495d99a 100644 --- a/Identity.html +++ b/Identity.html @@ -23,7 +23,7 @@
@@ -70,7 +70,7 @@

new Identity<
Source:
@@ -504,7 +504,7 @@

en
Source:
@@ -763,7 +763,7 @@

logSetting
Source:
@@ -898,7 +898,7 @@

hasSession<
Source:
@@ -1054,7 +1054,7 @@

(async) isL
Source:
@@ -1157,7 +1157,7 @@

Source:
@@ -1261,7 +1261,7 @@

(async) is
Source:
@@ -1366,7 +1366,7 @@

(async) getUse
Source:
@@ -1516,8 +1516,9 @@

Returns:

(async) getUserId() → {Promise.<string>}

-

In Schibsted account, there are two ways of identifying a user; the userId and the -uuid. There are reasons for them both existing. The userId is a numeric identifier, but +

In Schibsted account, there are multiple ways of identifying a user; the userId, +uuid and externalId used for identifying a user-merchant pair (see Identity#getExternalId). +There are reasons for them all to exist. The userId is a numeric identifier, but since Schibsted account is deployed separately in Norway and Sweden, there are a lot of duplicates. The userId was introduced early, so many sites still need to use them for legacy reasons. The uuid is universally unique, and so — if we could disregard a lot of @@ -1532,7 +1533,7 @@

(async) getU
Source:
@@ -1656,6 +1657,311 @@

Returns:
+

(async) getExternalId() → {Promise.<string>}

+ + +

Retrieves the external identifier (externalId) for the authenticated user.

+

In Schibsted Account there are multiple ways of identifying users, however for integrations with +third-parties it's recommended to use externalId as it does not disclose +any critical data whilst allowing for user identification.

+

externalId is merchant-scoped using a pairwise identifier (pairId), +meaning the same user's ID will differ between merchants. +Additionally, this identifier is bound to the external party provided as argument.

+ + + + + +
+ + +
Source:
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+

This function calls Identity#hasSession internally and thus has the side +effect that it might perform an auto-login on the user

+
+ + + + + + + + + + + + + + + + + + + + + +
Throws:
+ + + +
Returns:
+ + +
+

The merchant- and 3rd-party-specific externalId

+
+ + + +
+
+ Type +
+
+ +Promise.<string> + + +
+
+ + + + + + + + + +

(async) getUserSDRN() → {Promise.<string>}

+ + +

Enables brands to programmatically get the current the SDRN based on the user's session.

+ + + + + +
+ + +
Source:
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+

This function calls Identity#hasSession internally and thus has the side +effect that it might perform an auto-login on the user

+
+ + + + + + + + + + + + + + + + + + + + + +
Throws:
+ + + +
+
+
+

If the SDRN is missing in user session object.

+
+
+
+
+
+
+ Type +
+
+ +SDKError + + +
+
+
+
+
+ + + + + +
Returns:
+ + + + +
+
+ Type +
+
+ +Promise.<string> + + +
+
+ + + + + + + + +

(async) getUserUuid() → {Promise.<string>}

@@ -1675,7 +1981,7 @@

(async) ge
Source:
@@ -1814,7 +2120,7 @@

(async) Source:
@@ -1921,7 +2227,7 @@

loginSource:
@@ -2575,7 +2881,7 @@

(async) getSpI
Source:
@@ -2686,7 +2992,7 @@

logoutSource:
@@ -2834,7 +3140,7 @@

loginUrlSource:
@@ -3435,7 +3741,7 @@

logoutUrlSource:
@@ -3610,7 +3916,7 @@

accountUrl<
Source:
@@ -3781,7 +4087,7 @@

phonesUrlSource:
@@ -3952,7 +4258,7 @@

(as
Source:
@@ -4170,7 +4476,7 @@

error

Source:
@@ -4254,7 +4560,7 @@

login

Source:
@@ -4339,7 +4645,7 @@

logout

Source:
@@ -4423,7 +4729,7 @@

userChange

Source:
@@ -4509,7 +4815,7 @@

sessionChange

Source:
@@ -4595,7 +4901,7 @@

notLoggedin

Source:
@@ -4680,7 +4986,7 @@

sessionInit

Source:
@@ -4764,7 +5070,7 @@

statusChange

Source:
@@ -4849,7 +5155,7 @@

simplifiedLoginOpened

Source:
@@ -4933,7 +5239,7 @@

simplifiedLoginCancelledSource:
@@ -5014,7 +5320,7 @@

simplifiedLoginCancelled
- Documentation generated by JSDoc 3.6.11 on Wed Oct 25 2023 11:39:21 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 3.6.11 on Wed Nov 29 2023 13:26:58 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/Monetization.html b/Monetization.html index 9e242800..b8f53381 100644 --- a/Monetization.html +++ b/Monetization.html @@ -23,7 +23,7 @@
@@ -1211,7 +1211,7 @@
Returns:

- Documentation generated by JSDoc 3.6.11 on Wed Oct 25 2023 11:39:21 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 3.6.11 on Wed Nov 29 2023 13:26:58 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/Payment.html b/Payment.html index 9bf8615d..9e5e1e0e 100644 --- a/Payment.html +++ b/Payment.html @@ -23,7 +23,7 @@
@@ -2136,7 +2136,7 @@
Returns:

- Documentation generated by JSDoc 3.6.11 on Wed Oct 25 2023 11:39:21 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 3.6.11 on Wed Nov 29 2023 13:26:58 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/RESTClient.js.html b/RESTClient.js.html index abb7522b..feed752c 100644 --- a/RESTClient.js.html +++ b/RESTClient.js.html @@ -23,7 +23,7 @@
@@ -239,7 +239,7 @@

RESTClient.js


- Documentation generated by JSDoc 3.6.11 on Wed Oct 25 2023 11:39:20 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 3.6.11 on Wed Nov 29 2023 13:26:58 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/config.js.html b/config.js.html index 80e3f393..2cc41479 100644 --- a/config.js.html +++ b/config.js.html @@ -23,7 +23,7 @@
@@ -143,7 +143,7 @@

config.js


- Documentation generated by JSDoc 3.6.11 on Wed Oct 25 2023 11:39:20 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 3.6.11 on Wed Nov 29 2023 13:26:58 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/global.html b/global.html index 8012d66f..35ff4026 100644 --- a/global.html +++ b/global.html @@ -23,7 +23,7 @@
@@ -1592,6 +1592,52 @@
Properties:
+ + + + pairId + + + + + +string + + + + + + + + + + + + + + + + + sdrn + + + + + +string + + + + + + + + + + + + + @@ -1630,7 +1676,7 @@

HasSessionFailureResponse

Source:
@@ -1985,7 +2031,7 @@

SimplifiedLoginData

Source:
@@ -2152,7 +2198,7 @@

SimplifiedLoginWidgetOptions<
Source:
@@ -2276,7 +2322,7 @@

Type:

- Documentation generated by JSDoc 3.6.11 on Wed Oct 25 2023 11:39:20 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 3.6.11 on Wed Nov 29 2023 13:26:58 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/identity.js.html b/identity.js.html index 2ec734dd..bfb02103 100644 --- a/identity.js.html +++ b/identity.js.html @@ -23,7 +23,7 @@
@@ -150,6 +150,8 @@

identity.js

* @property {boolean} tracking - (Only for connected users) * @property {boolean} clientAgreementAccepted - (Only for connected users) * @property {boolean} defaultAgreementAccepted - (Only for connected users) + * @property {string} pairId + * @property {string} sdrn */ /** @@ -632,8 +634,10 @@

identity.js

/** * @async - * @summary In Schibsted account, there are two ways of identifying a user; the `userId` and the - * `uuid`. There are reasons for them both existing. The `userId` is a numeric identifier, but + * @summary + * In Schibsted account, there are multiple ways of identifying a user; the `userId`, + * `uuid` and `externalId` used for identifying a user-merchant pair (see {@link Identity#getExternalId}). + * There are reasons for them all to exist. The `userId` is a numeric identifier, but * since Schibsted account is deployed separately in Norway and Sweden, there are a lot of * duplicates. The `userId` was introduced early, so many sites still need to use them for * legacy reasons. The `uuid` is universally unique, and so — if we could disregard a lot of @@ -651,6 +655,76 @@

identity.js

throw new SDKError('The user is not connected to this merchant'); } + /** + * @async + * @function + * @summary + * Retrieves the external identifier (`externalId`) for the authenticated user. + * + * In Schibsted Account there are multiple ways of identifying users, however for integrations with + * third-parties it's recommended to use `externalId` as it does not disclose + * any critical data whilst allowing for user identification. + * + * `externalId` is merchant-scoped using a pairwise identifier (`pairId`), + * meaning the same user's ID will differ between merchants. + * Additionally, this identifier is bound to the external party provided as argument. + * + * @description This function calls {@link Identity#hasSession} internally and thus has the side + * effect that it might perform an auto-login on the user + * @throws {SDKError} If the `pairId` is missing in user session. + * @throws {SDKError} If the `externalParty` is not defined + * @return {Promise<string>} The merchant- and 3rd-party-specific `externalId` + */ + async getExternalId(externalParty, optionalSuffix = "") { + const { pairId } = await this.hasSession(); + + if (!pairId) + throw new SDKError('pairId missing in user session!'); + + if(!externalParty || externalParty.length === 0) { + throw new SDKError('externalParty cannot be empty'); + } + const _toHexDigest = (hashBuffer) =>{ + // convert buffer to byte array + const hashArray = Array.from(new Uint8Array(hashBuffer)); + // convert bytes to hex string + return hashArray.map(b => b.toString(16).padStart(2, '0')).join(''); + } + + const _getSha256Digest = (data) => { + return crypto.subtle.digest('SHA-256', data); + } + + const _hashMessage = async (message) => { + const msgUint8 = new TextEncoder().encode(message); + return _getSha256Digest(msgUint8).then( (it) => _toHexDigest(it)); + } + + const _constructMessage = (pairId, externalParty, optionalSuffix) => { + return optionalSuffix + ? `${pairId}:${externalParty}:${optionalSuffix}` + : `${pairId}:${externalParty}`; + } + + return _hashMessage(_constructMessage(pairId, externalParty, optionalSuffix)) + } + + /** + * @async + * @summary Enables brands to programmatically get the current the SDRN based on the user's session. + * @description This function calls {@link Identity#hasSession} internally and thus has the side + * effect that it might perform an auto-login on the user + * @throws {SDKError} If the SDRN is missing in user session object. + * @returns {Promise<string>} + */ + async getUserSDRN() { + const { sdrn } = await this.hasSession(); + if (sdrn) { + return sdrn; + } + throw new SDKError('Failed to get SDRN from user session'); + } + /** * @async * @summary In Schibsted account, there are two ways of identifying a user; the `userId` and the @@ -991,7 +1065,7 @@

identity.js


- Documentation generated by JSDoc 3.6.11 on Wed Oct 25 2023 11:39:20 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 3.6.11 on Wed Nov 29 2023 13:26:58 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/index.html b/index.html index 5cd29325..5e9f5e82 100644 --- a/index.html +++ b/index.html @@ -23,7 +23,7 @@
@@ -342,7 +342,7 @@

LICENSE


- Documentation generated by JSDoc 3.6.11 on Wed Oct 25 2023 11:39:20 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 3.6.11 on Wed Nov 29 2023 13:26:58 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/monetization.js.html b/monetization.js.html index a558a631..9a671dc5 100644 --- a/monetization.js.html +++ b/monetization.js.html @@ -23,7 +23,7 @@
@@ -208,7 +208,7 @@

monetization.js


- Documentation generated by JSDoc 3.6.11 on Wed Oct 25 2023 11:39:20 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 3.6.11 on Wed Nov 29 2023 13:26:58 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/object.js.html b/object.js.html index b31d4661..c4288591 100644 --- a/object.js.html +++ b/object.js.html @@ -23,7 +23,7 @@
@@ -109,7 +109,7 @@

object.js


- Documentation generated by JSDoc 3.6.11 on Wed Oct 25 2023 11:39:20 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 3.6.11 on Wed Nov 29 2023 13:26:58 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/payment.js.html b/payment.js.html index 650a68ee..e49607f0 100644 --- a/payment.js.html +++ b/payment.js.html @@ -23,7 +23,7 @@
@@ -259,7 +259,7 @@

payment.js


- Documentation generated by JSDoc 3.6.11 on Wed Oct 25 2023 11:39:20 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 3.6.11 on Wed Nov 29 2023 13:26:58 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/spidTalk.js.html b/spidTalk.js.html index 6a8a0828..af68a180 100644 --- a/spidTalk.js.html +++ b/spidTalk.js.html @@ -23,7 +23,7 @@
@@ -89,7 +89,7 @@

spidTalk.js


- Documentation generated by JSDoc 3.6.11 on Wed Oct 25 2023 11:39:20 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 3.6.11 on Wed Nov 29 2023 13:26:58 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/url.js.html b/url.js.html index 689c2fa5..39c66220 100644 --- a/url.js.html +++ b/url.js.html @@ -23,7 +23,7 @@
@@ -75,7 +75,7 @@

url.js


- Documentation generated by JSDoc 3.6.11 on Wed Oct 25 2023 11:39:20 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 3.6.11 on Wed Nov 29 2023 13:26:58 GMT+0000 (Coordinated Universal Time) using the docdash theme.
diff --git a/validate.js.html b/validate.js.html index 5bac92bd..413d86ab 100644 --- a/validate.js.html +++ b/validate.js.html @@ -23,7 +23,7 @@
@@ -167,7 +167,7 @@

validate.js


- Documentation generated by JSDoc 3.6.11 on Wed Oct 25 2023 11:39:20 GMT+0000 (Coordinated Universal Time) using the docdash theme. + Documentation generated by JSDoc 3.6.11 on Wed Nov 29 2023 13:26:58 GMT+0000 (Coordinated Universal Time) using the docdash theme.