@schibsted/account-sdk-browser 5.2.7 → 6.0.0-alpha.2
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 +12 -59
- package/dist/RESTClient.d.ts +91 -0
- package/dist/SDKError.d.ts +27 -0
- package/dist/cache.d.ts +65 -0
- package/dist/config.d.ts +86 -0
- package/dist/global-registry.d.ts +23 -0
- package/dist/globals.d.ts +13 -0
- package/dist/identity-s4nofYmB.js +370 -0
- package/dist/identity-s4nofYmB.js.map +1 -0
- package/dist/identity.d.ts +523 -0
- package/dist/identity.js +2 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +4 -0
- package/dist/monetization.d.ts +94 -0
- package/dist/monetization.js +72 -0
- package/dist/monetization.js.map +1 -0
- package/{src → dist}/object.d.ts +4 -9
- package/dist/popup.d.ts +9 -0
- package/{src → dist}/spidTalk.d.ts +4 -6
- package/dist/url.d.ts +8 -0
- package/dist/validate.d.ts +50 -0
- package/dist/version-spE-k97g.js +289 -0
- package/dist/version-spE-k97g.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/package.json +42 -49
- package/src/RESTClient.ts +226 -0
- package/src/SDKError.ts +59 -0
- package/src/{cache.js → cache.ts} +52 -37
- package/src/{config.js → config.ts} +7 -32
- package/src/global-registry.ts +39 -0
- package/src/globals.ts +10 -0
- package/src/{identity.js → identity.ts} +536 -437
- package/{index.js → src/index.ts} +1 -3
- package/src/{monetization.js → monetization.ts} +77 -48
- package/src/{object.js → object.ts} +8 -15
- package/src/popup.ts +74 -0
- package/src/{spidTalk.js → spidTalk.ts} +10 -12
- package/src/{url.js → url.ts} +6 -10
- package/src/{validate.js → validate.ts} +26 -42
- package/src/{version.js → version.ts} +1 -2
- package/es5/global.js +0 -12968
- package/es5/global.js.map +0 -1
- package/es5/global.min.js +0 -2
- package/es5/global.min.js.map +0 -1
- package/es5/identity.js +0 -12212
- package/es5/identity.js.map +0 -1
- package/es5/identity.min.js +0 -2
- package/es5/identity.min.js.map +0 -1
- package/es5/index.js +0 -12940
- package/es5/index.js.map +0 -1
- package/es5/index.min.js +0 -2
- package/es5/index.min.js.map +0 -1
- package/es5/monetization.js +0 -9176
- package/es5/monetization.js.map +0 -1
- package/es5/monetization.min.js +0 -2
- package/es5/monetization.min.js.map +0 -1
- package/es5/payment.js +0 -8853
- package/es5/payment.js.map +0 -1
- package/es5/payment.min.js +0 -2
- package/es5/payment.min.js.map +0 -1
- package/identity.d.ts +0 -1
- package/identity.js +0 -5
- package/index.d.ts +0 -4
- package/monetization.d.ts +0 -1
- package/monetization.js +0 -5
- package/payment.d.ts +0 -1
- package/payment.js +0 -5
- package/src/RESTClient.d.ts +0 -89
- package/src/RESTClient.js +0 -193
- package/src/SDKError.d.ts +0 -16
- package/src/SDKError.js +0 -55
- package/src/__mocks__/.eslintrc.yml +0 -8
- package/src/__mocks__/RESTClient.js +0 -54
- package/src/cache.d.ts +0 -64
- package/src/config.d.ts +0 -34
- package/src/es5/global.js +0 -13
- package/src/es5/identity.js +0 -10
- package/src/es5/index.js +0 -13
- package/src/es5/monetization.js +0 -10
- package/src/es5/payment.js +0 -10
- package/src/global-registry.js +0 -20
- package/src/identity.d.ts +0 -679
- package/src/monetization.d.ts +0 -80
- package/src/payment.d.ts +0 -115
- package/src/payment.js +0 -211
- package/src/popup.d.ts +0 -10
- package/src/popup.js +0 -59
- package/src/url.d.ts +0 -10
- package/src/validate.d.ts +0 -64
- package/src/version.d.ts +0 -2
package/src/identity.d.ts
DELETED
|
@@ -1,679 +0,0 @@
|
|
|
1
|
-
import type { TinyEmitter } from 'tiny-emitter';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Provides Identity functionality to a web page
|
|
5
|
-
*/
|
|
6
|
-
export class Identity extends TinyEmitter {
|
|
7
|
-
/**
|
|
8
|
-
* @param {object} options
|
|
9
|
-
* @param {string} options.clientId - Example: "1234567890abcdef12345678"
|
|
10
|
-
* @param {string} options.sessionDomain - Example: "https://id.site.com"
|
|
11
|
-
* @param {string} options.redirectUri - Example: "https://site.com"
|
|
12
|
-
* @param {string} [options.env=PRE] - Schibsted account environment: `PRE`, `PRO`, `PRO_NO`, `PRO_FI` or `PRO_DK`
|
|
13
|
-
* @param {function} [options.log] - A function that receives debug log information. If not set,
|
|
14
|
-
* no logging will be done
|
|
15
|
-
* @param {object} [options.window] - window object
|
|
16
|
-
* @param {function} [options.callbackBeforeRedirect] - callback triggered before session refresh redirect happen
|
|
17
|
-
* @throws {SDKError} - If any of options are invalid
|
|
18
|
-
*/
|
|
19
|
-
constructor({ clientId, redirectUri, sessionDomain, env, log, window, callbackBeforeRedirect }: {
|
|
20
|
-
clientId: string;
|
|
21
|
-
sessionDomain: string;
|
|
22
|
-
redirectUri: string;
|
|
23
|
-
env?: string;
|
|
24
|
-
log?: Function;
|
|
25
|
-
window?: any;
|
|
26
|
-
callbackBeforeRedirect?: Function;
|
|
27
|
-
});
|
|
28
|
-
_sessionInitiatedSent: boolean;
|
|
29
|
-
window: any;
|
|
30
|
-
clientId: string;
|
|
31
|
-
sessionStorageCache: any;
|
|
32
|
-
localStorageCache: any;
|
|
33
|
-
redirectUri: string;
|
|
34
|
-
env: string;
|
|
35
|
-
log: Function;
|
|
36
|
-
callbackBeforeRedirect: Function;
|
|
37
|
-
_sessionDomain: string;
|
|
38
|
-
_enableSessionCaching: boolean;
|
|
39
|
-
_session: {};
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Read tabId from session storage
|
|
43
|
-
* @returns {number}
|
|
44
|
-
* @private
|
|
45
|
-
*/
|
|
46
|
-
private _getTabId;
|
|
47
|
-
/**
|
|
48
|
-
* Checks if getting session is blocked
|
|
49
|
-
* @private
|
|
50
|
-
*
|
|
51
|
-
* @returns {boolean|void}
|
|
52
|
-
*/
|
|
53
|
-
private _isSessionCallBlocked;
|
|
54
|
-
/**
|
|
55
|
-
* Block calls to get session
|
|
56
|
-
* @private
|
|
57
|
-
*
|
|
58
|
-
* @returns {void}
|
|
59
|
-
*/
|
|
60
|
-
private _blockSessionCall;
|
|
61
|
-
/**
|
|
62
|
-
* Unblocks calls to get session
|
|
63
|
-
* @private
|
|
64
|
-
*
|
|
65
|
-
* @returns {void}
|
|
66
|
-
*/
|
|
67
|
-
private _unblockSessionCall;
|
|
68
|
-
/**
|
|
69
|
-
* Set SPiD server URL
|
|
70
|
-
* @private
|
|
71
|
-
* @param {string} url - real URL or 'PRE' style key
|
|
72
|
-
* @returns {void}
|
|
73
|
-
*/
|
|
74
|
-
private _setSpidServerUrl;
|
|
75
|
-
_spid: RESTClient;
|
|
76
|
-
/**
|
|
77
|
-
* Set OAuth server URL
|
|
78
|
-
* @private
|
|
79
|
-
* @param {string} url - real URL or 'PRE' style key
|
|
80
|
-
* @returns {void}
|
|
81
|
-
*/
|
|
82
|
-
private _setOauthServerUrl;
|
|
83
|
-
_oauthService: RESTClient;
|
|
84
|
-
/**
|
|
85
|
-
* Set BFF server URL
|
|
86
|
-
* @private
|
|
87
|
-
* @param {string} url - real URL or 'PRE' style key
|
|
88
|
-
* @returns {void}
|
|
89
|
-
*/
|
|
90
|
-
private _setBffServerUrl;
|
|
91
|
-
_bffService: RESTClient;
|
|
92
|
-
/**
|
|
93
|
-
* Set site-specific session-service domain
|
|
94
|
-
* @private
|
|
95
|
-
* @param {string} domain - real URL — (**not** 'PRE' style env key)
|
|
96
|
-
* @returns {void}
|
|
97
|
-
*/
|
|
98
|
-
private _setSessionServiceUrl;
|
|
99
|
-
_sessionService: RESTClient;
|
|
100
|
-
/**
|
|
101
|
-
* Set global session-service server URL
|
|
102
|
-
* @private
|
|
103
|
-
* @param {string} url - real URL or 'PRE' style key
|
|
104
|
-
* @returns {void}
|
|
105
|
-
*/
|
|
106
|
-
private _setGlobalSessionServiceUrl;
|
|
107
|
-
_globalSessionService: RESTClient;
|
|
108
|
-
/**
|
|
109
|
-
* Emits the relevant events based on the previous and new reply from hassession
|
|
110
|
-
* @private
|
|
111
|
-
* @param {object} previous
|
|
112
|
-
* @param {object} current
|
|
113
|
-
* @returns {void}
|
|
114
|
-
*/
|
|
115
|
-
private _emitSessionEvent;
|
|
116
|
-
/**
|
|
117
|
-
* Close this.popup if it exists and is open
|
|
118
|
-
* @private
|
|
119
|
-
* @returns {void}
|
|
120
|
-
*/
|
|
121
|
-
private _closePopup;
|
|
122
|
-
popup: Window;
|
|
123
|
-
/**
|
|
124
|
-
* Set the Varnish cookie (`SP_ID`) when hasSession() is called. Note that most browsers require
|
|
125
|
-
* that you are on a "real domain" for this to work — so, **not** `localhost`
|
|
126
|
-
* @param {object} [options]
|
|
127
|
-
* @param {number} [options.expiresIn] Override this to set number of seconds before the varnish
|
|
128
|
-
* cookie expires. The default is to use the same time that hasSession responses are cached for
|
|
129
|
-
* @param {string} [options.domain] Override cookie domain. E.g. «vg.no» instead of «www.vg.no»
|
|
130
|
-
* @returns {void}
|
|
131
|
-
*/
|
|
132
|
-
enableVarnishCookie(options?: {
|
|
133
|
-
expiresIn?: number;
|
|
134
|
-
domain?: string;
|
|
135
|
-
}): void;
|
|
136
|
-
setVarnishCookie: boolean;
|
|
137
|
-
varnishExpiresIn: number;
|
|
138
|
-
varnishCookieDomain: string;
|
|
139
|
-
/**
|
|
140
|
-
* Set the Varnish cookie if configured
|
|
141
|
-
* @private
|
|
142
|
-
* @param {HasSessionSuccessResponse} sessionData
|
|
143
|
-
* @returns {void}
|
|
144
|
-
*/
|
|
145
|
-
private _maybeSetVarnishCookie;
|
|
146
|
-
/**
|
|
147
|
-
* Clear the Varnish cookie if configured
|
|
148
|
-
* @private
|
|
149
|
-
* @returns {void}
|
|
150
|
-
*/
|
|
151
|
-
private _maybeClearVarnishCookie;
|
|
152
|
-
/**
|
|
153
|
-
* Clear the Varnish cookie
|
|
154
|
-
* @private
|
|
155
|
-
* @returns {void}
|
|
156
|
-
*/
|
|
157
|
-
private _clearVarnishCookie;
|
|
158
|
-
/**
|
|
159
|
-
* Log used settings and version
|
|
160
|
-
* @throws {SDKError} - If log method is not provided
|
|
161
|
-
* @return {void}
|
|
162
|
-
*/
|
|
163
|
-
logSettings(): void;
|
|
164
|
-
/**
|
|
165
|
-
* @summary Queries the hassession endpoint and returns information about the status of the user
|
|
166
|
-
* @description When we send a request to this endpoint, cookies sent along with the request
|
|
167
|
-
* determines the status of the user.
|
|
168
|
-
* @throws {SDKError} - If the call to the hasSession service fails in any way (this will happen
|
|
169
|
-
* if, say, the user is not logged in)
|
|
170
|
-
* @fires Identity#login
|
|
171
|
-
* @fires Identity#logout
|
|
172
|
-
* @fires Identity#userChange
|
|
173
|
-
* @fires Identity#sessionChange
|
|
174
|
-
* @fires Identity#notLoggedin
|
|
175
|
-
* @fires Identity#sessionInit
|
|
176
|
-
* @fires Identity#statusChange
|
|
177
|
-
* @fires Identity#error
|
|
178
|
-
* @return {Promise<HasSessionSuccessResponse|HasSessionFailureResponse>}
|
|
179
|
-
*/
|
|
180
|
-
hasSession(): Promise<HasSessionSuccessResponse | HasSessionFailureResponse>;
|
|
181
|
-
_hasSessionInProgress: boolean | Promise<any>;
|
|
182
|
-
/**
|
|
183
|
-
* @async
|
|
184
|
-
* @summary Allows the client app to check if the user is logged in to Schibsted account
|
|
185
|
-
* @description This function calls {@link Identity#hasSession} internally and thus has the side
|
|
186
|
-
* effect that it might perform an auto-login on the user
|
|
187
|
-
* @return {Promise<boolean>}
|
|
188
|
-
*/
|
|
189
|
-
isLoggedIn(): Promise<boolean>;
|
|
190
|
-
/**
|
|
191
|
-
* Removes the cached user session.
|
|
192
|
-
* @returns {void}
|
|
193
|
-
*/
|
|
194
|
-
clearCachedUserSession(): void;
|
|
195
|
-
/**
|
|
196
|
-
* @async
|
|
197
|
-
* @summary Allows the caller to check if the current user is connected to the client_id in
|
|
198
|
-
* Schibsted account. Being connected means that the user has agreed for their account to be
|
|
199
|
-
* used by your web app and have accepted the required terms
|
|
200
|
-
* @description This function calls {@link Identity#hasSession} internally and thus has the side
|
|
201
|
-
* effect that it might perform an auto-login on the user
|
|
202
|
-
* @summary Check if the user is connected to the client_id
|
|
203
|
-
* @return {Promise<boolean>}
|
|
204
|
-
*/
|
|
205
|
-
isConnected(): Promise<boolean>;
|
|
206
|
-
/**
|
|
207
|
-
* @async
|
|
208
|
-
* @summary Returns information about the user
|
|
209
|
-
* @description This function calls {@link Identity#hasSession} internally and thus has the side
|
|
210
|
-
* effect that it might perform an auto-login on the user
|
|
211
|
-
* @throws {SDKError} If the user isn't connected to the merchant
|
|
212
|
-
* @throws {SDKError} If we couldn't get the user
|
|
213
|
-
* @return {Promise<HasSessionSuccessResponse>}
|
|
214
|
-
*/
|
|
215
|
-
getUser(): Promise<HasSessionSuccessResponse>;
|
|
216
|
-
/**
|
|
217
|
-
* @async
|
|
218
|
-
* @summary In Schibsted account, there are two ways of identifying a user; the `userId` and the
|
|
219
|
-
* `uuid`. There are reasons for them both existing. The `userId` is a numeric identifier, but
|
|
220
|
-
* since Schibsted account is deployed separately in Norway and Sweden, there are a lot of
|
|
221
|
-
* duplicates. The `userId` was introduced early, so many sites still need to use them for
|
|
222
|
-
* legacy reasons. The `uuid` is universally unique, and so — if we could disregard a lot of
|
|
223
|
-
* Schibsted components depending on the numeric `userId` — it would be a good identifier to use
|
|
224
|
-
* @description This function calls {@link Identity#hasSession} internally and thus has the side
|
|
225
|
-
* effect that it might perform an auto-login on the user
|
|
226
|
-
* @throws {SDKError} If the user isn't connected to the merchant
|
|
227
|
-
* @return {Promise<string>} The `userId` field (not to be confused with the `uuid`)
|
|
228
|
-
*/
|
|
229
|
-
getUserId(): Promise<string>;
|
|
230
|
-
/**
|
|
231
|
-
* @async
|
|
232
|
-
* @summary In Schibsted account, there are two ways of identifying a user; the `userId` and the
|
|
233
|
-
* `uuid`. There are reasons for them both existing. The `userId` is a numeric identifier, but
|
|
234
|
-
* since Schibsted account is deployed separately in Norway and Sweden, there are a lot of
|
|
235
|
-
* duplicates. The `userId` was introduced early, so many sites still need to use them for
|
|
236
|
-
* legacy reasons. The `uuid` is universally unique, and so — if we could disregard a lot of
|
|
237
|
-
* Schibsted components depending on the numeric `userId` — it would be a good identifier to use
|
|
238
|
-
* @description This function calls {@link Identity#hasSession} internally and thus has the side
|
|
239
|
-
* effect that it might perform an auto-login on the user
|
|
240
|
-
* @throws {SDKError} If the user isn't connected to the merchant
|
|
241
|
-
* @return {Promise<string>} The `uuid` field (not to be confused with the `userId`)
|
|
242
|
-
*/
|
|
243
|
-
getUserUuid(): Promise<string>;
|
|
244
|
-
/**
|
|
245
|
-
* @async
|
|
246
|
-
* @summary Get basic information about any user currently logged-in to their Schibsted account
|
|
247
|
-
* in this browser. Can be used to provide context in a continue-as prompt.
|
|
248
|
-
* @description This function relies on the global Schibsted account user session cookie, which
|
|
249
|
-
* is a third-party cookie and hence might be blocked by the browser (for example due to ITP in
|
|
250
|
-
* Safari). So there's no guarantee any data is returned, even though a user is logged-in in
|
|
251
|
-
* the current browser.
|
|
252
|
-
* @return {Promise<SimplifiedLoginData|null>}
|
|
253
|
-
*/
|
|
254
|
-
getUserContextData(): Promise<SimplifiedLoginData | null>;
|
|
255
|
-
/**
|
|
256
|
-
* @async
|
|
257
|
-
* @function
|
|
258
|
-
* @summary
|
|
259
|
-
* Retrieves the external identifier (`externalId`) for the authenticated user.
|
|
260
|
-
*
|
|
261
|
-
* In Schibsted Account there are multiple ways of identifying users, however for integrations with
|
|
262
|
-
* third-parties it's recommended to use `externalId` as it does not disclose
|
|
263
|
-
* any critical data whilst allowing for user identification.
|
|
264
|
-
*
|
|
265
|
-
* `externalId` is merchant-scoped using a pairwise identifier (`pairId`),
|
|
266
|
-
* meaning the same user's ID will differ between merchants.
|
|
267
|
-
* Additionally, this identifier is bound to the external party provided as argument.
|
|
268
|
-
*
|
|
269
|
-
* @description This function calls {@link Identity#hasSession} internally and thus has the side
|
|
270
|
-
* effect that it might perform an auto-login on the user
|
|
271
|
-
* @param {string} externalParty
|
|
272
|
-
* @param {string|null} optionalSuffix
|
|
273
|
-
* @throws {SDKError} If the `pairId` is missing in user session.
|
|
274
|
-
* @throws {SDKError} If the `externalParty` is not defined
|
|
275
|
-
* @return {Promise<string>} The merchant- and 3rd-party-specific `externalId`
|
|
276
|
-
*/
|
|
277
|
-
getExternalId(externalParty: string, optionalSuffix?: string): Promise<string>;
|
|
278
|
-
/**
|
|
279
|
-
* @async
|
|
280
|
-
* @summary Enables brands to programmatically get the current the SDRN based on the user's session.
|
|
281
|
-
* @description This function calls {@link Identity#hasSession} internally and thus has the side
|
|
282
|
-
* effect that it might perform an auto-login on the user
|
|
283
|
-
* @throws {SDKError} If the SDRN is missing in user session object.
|
|
284
|
-
* @returns {Promise<string>}
|
|
285
|
-
*/
|
|
286
|
-
getUserSDRN(): Promise<string>;
|
|
287
|
-
/**
|
|
288
|
-
* If a popup is desired, this function needs to be called in response to a user event (like
|
|
289
|
-
* click or tap) in order to work correctly. Otherwise the popup will be blocked by the
|
|
290
|
-
* browser's popup blockers and has to be explicitly authorized to be shown.
|
|
291
|
-
* @summary Perform a login, either using a full-page redirect or a popup
|
|
292
|
-
* @see https://tools.ietf.org/html/rfc6749#section-4.1.1
|
|
293
|
-
*
|
|
294
|
-
* @param {LoginOptions} options
|
|
295
|
-
* @param {string} options.state
|
|
296
|
-
* @param {string} [options.acrValues]
|
|
297
|
-
* @param {string} [options.scope=openid]
|
|
298
|
-
* @param {string} [options.redirectUri]
|
|
299
|
-
* @param {boolean} [options.preferPopup=false]
|
|
300
|
-
* @param {string} [options.loginHint]
|
|
301
|
-
* @param {string} [options.tag]
|
|
302
|
-
* @param {string} [options.teaser]
|
|
303
|
-
* @param {number|string} [options.maxAge]
|
|
304
|
-
* @param {string} [options.locale]
|
|
305
|
-
* @param {boolean} [options.oneStepLogin=false]
|
|
306
|
-
* @param {string} [options.prompt=select_account]
|
|
307
|
-
* @param {string} [options.xDomainId]
|
|
308
|
-
* @param {string} [options.xEnvironmentId]
|
|
309
|
-
* @param {string} [options.originCampaign]
|
|
310
|
-
* @return {Window|null} - Reference to popup window if created (or `null` otherwise)
|
|
311
|
-
*/
|
|
312
|
-
login({ state, acrValues, scope, redirectUri, preferPopup, loginHint, tag, teaser, maxAge, locale, oneStepLogin, prompt, xDomainId, xEnvironmentId, originCampaign }: LoginOptions): Window | null;
|
|
313
|
-
/**
|
|
314
|
-
* @async
|
|
315
|
-
* @summary Retrieve the sp_id (Varnish ID)
|
|
316
|
-
* @description This function calls {@link Identity#hasSession} internally and thus has the side
|
|
317
|
-
* effect that it might perform an auto-login on the user
|
|
318
|
-
* @return {Promise<string|null>} - The sp_id string or null (if the server didn't return it)
|
|
319
|
-
*/
|
|
320
|
-
getSpId(): Promise<string | null>;
|
|
321
|
-
/**
|
|
322
|
-
* @summary Logs the user out from the Identity platform
|
|
323
|
-
* @param {string} redirectUri - Where to redirect the browser after logging out of Schibsted
|
|
324
|
-
* account
|
|
325
|
-
* @return {void}
|
|
326
|
-
*/
|
|
327
|
-
logout(redirectUri?: string): void;
|
|
328
|
-
/**
|
|
329
|
-
* Generates the link to the new login page that'll be used in the popup or redirect flow
|
|
330
|
-
* @param {LoginOptions} options
|
|
331
|
-
* @param {string} options.state
|
|
332
|
-
* @param {string} [options.acrValues]
|
|
333
|
-
* @param {string} [options.scope=openid]
|
|
334
|
-
* @param {string} [options.redirectUri]
|
|
335
|
-
* @param {string} [options.loginHint]
|
|
336
|
-
* @param {string} [options.tag]
|
|
337
|
-
* @param {string} [options.teaser]
|
|
338
|
-
* @param {number|string} [options.maxAge]
|
|
339
|
-
* @param {string} [options.locale]
|
|
340
|
-
* @param {boolean} [options.oneStepLogin=false]
|
|
341
|
-
* @param {string} [options.prompt=select_account]
|
|
342
|
-
* @param {string} [options.xDomainId]
|
|
343
|
-
* @param {string} [options.xEnvironmentId]
|
|
344
|
-
* @param {string} [options.originCampaign]
|
|
345
|
-
* @return {string} - The url
|
|
346
|
-
*/
|
|
347
|
-
loginUrl({ state, acrValues, scope, redirectUri, loginHint, tag, teaser, maxAge, locale, oneStepLogin, prompt, xDomainId, xEnvironmentId, originCampaign }: LoginOptions, ...args: any[]): string;
|
|
348
|
-
/**
|
|
349
|
-
* The url for logging the user out
|
|
350
|
-
* @param {string} [redirectUri=this.redirectUri]
|
|
351
|
-
* @return {string} url
|
|
352
|
-
*/
|
|
353
|
-
logoutUrl(redirectUri?: string): string;
|
|
354
|
-
/**
|
|
355
|
-
* The account summary page url
|
|
356
|
-
* @param {string} [redirectUri=this.redirectUri]
|
|
357
|
-
* @return {string}
|
|
358
|
-
*/
|
|
359
|
-
accountUrl(redirectUri?: string): string;
|
|
360
|
-
/**
|
|
361
|
-
* The phone editing page url
|
|
362
|
-
* @param {string} [redirectUri=this.redirectUri]
|
|
363
|
-
* @return {string}
|
|
364
|
-
*/
|
|
365
|
-
phonesUrl(redirectUri?: string): string;
|
|
366
|
-
/**
|
|
367
|
-
* Function responsible for loading and displaying simplified login widget. How often
|
|
368
|
-
* widget will be display is up to you. Preferred way would be to show it once per user,
|
|
369
|
-
* and store that info in localStorage. Widget will be display only if user is logged in to SSO.
|
|
370
|
-
*
|
|
371
|
-
* @async
|
|
372
|
-
* @param {SimplifiedLoginWidgetLoginOptions} loginParams - the same as `options` param for login function. Login will be called on user
|
|
373
|
-
* continue action. `state` might be string or async function.
|
|
374
|
-
* @param {SimplifiedLoginWidgetOptions} [options] - additional configuration of Simplified Login Widget
|
|
375
|
-
* @return {Promise<boolean|SDKError>} - will resolve to true if widget will be display. Otherwise will throw SDKError
|
|
376
|
-
*/
|
|
377
|
-
showSimplifiedLoginWidget(loginParams: SimplifiedLoginWidgetLoginOptions, options?: SimplifiedLoginWidgetOptions): Promise<boolean | SDKError>;
|
|
378
|
-
}
|
|
379
|
-
export default Identity;
|
|
380
|
-
export type LoginOptions = {
|
|
381
|
-
/**
|
|
382
|
-
* - An opaque value used by the client to maintain state between
|
|
383
|
-
* the request and callback. It's also recommended to prevent CSRF {@link https://tools.ietf.org/html/rfc6749#section-10.12}
|
|
384
|
-
*/
|
|
385
|
-
state: string;
|
|
386
|
-
/**
|
|
387
|
-
* - Authentication Context Class Reference Values. If
|
|
388
|
-
* omitted, the user will be asked to authenticate using username+password.
|
|
389
|
-
* For 2FA (Two-Factor Authentication) possible values are `sms`, `otp` (one time password),
|
|
390
|
-
* `password` (will force password confirmation, even if user is already logged in), `eid`. Those values might
|
|
391
|
-
* be mixed as space-separated string. To make sure that user has authenticated with 2FA you need
|
|
392
|
-
* to verify AMR (Authentication Methods References) claim in ID token.
|
|
393
|
-
* Might also be used to ensure additional acr (sms, otp, eid) for already logged in users.
|
|
394
|
-
* Supported value is also 'otp-email' means one time password using email.
|
|
395
|
-
*/
|
|
396
|
-
acrValues?: string;
|
|
397
|
-
/**
|
|
398
|
-
* - The OAuth scopes for the tokens. This is a list of
|
|
399
|
-
* scopes, separated by space. If the list of scopes contains `openid`, the generated tokens
|
|
400
|
-
* includes the id token which can be useful for getting information about the user. Omitting
|
|
401
|
-
* scope is allowed, while `invalid_scope` is returned when the client asks for a scope you
|
|
402
|
-
* aren’t allowed to request. {@link https://tools.ietf.org/html/rfc6749#section-3.3}
|
|
403
|
-
*/
|
|
404
|
-
scope?: string;
|
|
405
|
-
/**
|
|
406
|
-
* - Redirect uri that will receive the
|
|
407
|
-
* code. Must exactly match a redirectUri from your client in self-service
|
|
408
|
-
*/
|
|
409
|
-
redirectUri?: string;
|
|
410
|
-
/**
|
|
411
|
-
* - Should we try to open a popup window?
|
|
412
|
-
*/
|
|
413
|
-
preferPopup?: boolean;
|
|
414
|
-
/**
|
|
415
|
-
* - user email or UUID hint
|
|
416
|
-
*/
|
|
417
|
-
loginHint?: string;
|
|
418
|
-
/**
|
|
419
|
-
* - Pulse tag
|
|
420
|
-
*/
|
|
421
|
-
tag?: string;
|
|
422
|
-
/**
|
|
423
|
-
* - Teaser slug. Teaser with given slug will be displayed
|
|
424
|
-
* in place of default teaser
|
|
425
|
-
*/
|
|
426
|
-
teaser?: string;
|
|
427
|
-
/**
|
|
428
|
-
* - Specifies the allowable elapsed time in seconds since
|
|
429
|
-
* the last time the End-User was actively authenticated. If last authentication time is more
|
|
430
|
-
* than maxAge seconds in the past, re-authentication will be required. See the OpenID Connect
|
|
431
|
-
* spec section 3.1.2.1 for more information
|
|
432
|
-
*/
|
|
433
|
-
maxAge?: number | string;
|
|
434
|
-
/**
|
|
435
|
-
* - Optional parameter to overwrite client locale setting.
|
|
436
|
-
* New flows supports nb_NO, fi_FI, sv_SE, en_US
|
|
437
|
-
*/
|
|
438
|
-
locale?: string;
|
|
439
|
-
/**
|
|
440
|
-
* - display username and password on one screen
|
|
441
|
-
*/
|
|
442
|
-
oneStepLogin?: boolean;
|
|
443
|
-
/**
|
|
444
|
-
* - String that specifies whether the Authorization Server prompts the
|
|
445
|
-
* End-User for reauthentication or confirm account screen. Supported values: `select_account` or `login`
|
|
446
|
-
*/
|
|
447
|
-
prompt?: string;
|
|
448
|
-
/**
|
|
449
|
-
* - Identifier for cross-domain tracking in Pulse
|
|
450
|
-
*/
|
|
451
|
-
xDomainId?: string;
|
|
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;
|
|
460
|
-
};
|
|
461
|
-
export type SimplifiedLoginWidgetLoginOptions = {
|
|
462
|
-
/**
|
|
463
|
-
* - An opaque value used by the client to maintain state between
|
|
464
|
-
* the request and callback. It's also recommended to prevent CSRF {@link https://tools.ietf.org/html/rfc6749#section-10.12}
|
|
465
|
-
*/
|
|
466
|
-
state: string | (() => (string | Promise<string>));
|
|
467
|
-
/**
|
|
468
|
-
* - Authentication Context Class Reference Values. If
|
|
469
|
-
* omitted, the user will be asked to authenticate using username+password.
|
|
470
|
-
* For 2FA (Two-Factor Authentication) possible values are `sms`, `otp` (one time password) and
|
|
471
|
-
* `password` (will force password confirmation, even if user is already logged in). Those values might
|
|
472
|
-
* be mixed as space-separated string. To make sure that user has authenticated with 2FA you need
|
|
473
|
-
* to verify AMR (Authentication Methods References) claim in ID token.
|
|
474
|
-
* Might also be used to ensure additional acr (sms, otp) for already logged in users.
|
|
475
|
-
* Supported value is also 'otp-email' means one time password using email.
|
|
476
|
-
*/
|
|
477
|
-
acrValues?: string;
|
|
478
|
-
/**
|
|
479
|
-
* - The OAuth scopes for the tokens. This is a list of
|
|
480
|
-
* scopes, separated by space. If the list of scopes contains `openid`, the generated tokens
|
|
481
|
-
* includes the id token which can be useful for getting information about the user. Omitting
|
|
482
|
-
* scope is allowed, while `invalid_scope` is returned when the client asks for a scope you
|
|
483
|
-
* aren’t allowed to request. {@link https ://tools.ietf.org/html/rfc6749#section-3.3}
|
|
484
|
-
*/
|
|
485
|
-
scope?: string;
|
|
486
|
-
/**
|
|
487
|
-
* - Redirect uri that will receive the
|
|
488
|
-
* code. Must exactly match a redirectUri from your client in self-service
|
|
489
|
-
*/
|
|
490
|
-
redirectUri?: string;
|
|
491
|
-
/**
|
|
492
|
-
* - Should we try to open a popup window?
|
|
493
|
-
*/
|
|
494
|
-
preferPopup?: boolean;
|
|
495
|
-
/**
|
|
496
|
-
* - user email or UUID hint
|
|
497
|
-
*/
|
|
498
|
-
loginHint?: string;
|
|
499
|
-
/**
|
|
500
|
-
* - Pulse tag
|
|
501
|
-
*/
|
|
502
|
-
tag?: string;
|
|
503
|
-
/**
|
|
504
|
-
* - Teaser slug. Teaser with given slug will be displayed
|
|
505
|
-
* in place of default teaser
|
|
506
|
-
*/
|
|
507
|
-
teaser?: string;
|
|
508
|
-
/**
|
|
509
|
-
* - Specifies the allowable elapsed time in seconds since
|
|
510
|
-
* the last time the End-User was actively authenticated. If last authentication time is more
|
|
511
|
-
* than maxAge seconds in the past, re-authentication will be required. See the OpenID Connect
|
|
512
|
-
* spec section 3.1.2.1 for more information
|
|
513
|
-
*/
|
|
514
|
-
maxAge?: string | number;
|
|
515
|
-
/**
|
|
516
|
-
* - Optional parameter to overwrite client locale setting.
|
|
517
|
-
* New flows supports nb_NO, fi_FI, sv_SE, en_US
|
|
518
|
-
*/
|
|
519
|
-
locale?: string;
|
|
520
|
-
/**
|
|
521
|
-
* - display username and password on one screen
|
|
522
|
-
*/
|
|
523
|
-
oneStepLogin?: boolean;
|
|
524
|
-
/**
|
|
525
|
-
* - String that specifies whether the Authorization Server prompts the
|
|
526
|
-
* End-User for reauthentication or confirm account screen. Supported values: `select_account` or `login`
|
|
527
|
-
*/
|
|
528
|
-
prompt?: string;
|
|
529
|
-
/**
|
|
530
|
-
* - Identifier for cross-domain tracking in Pulse
|
|
531
|
-
*/
|
|
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
|
-
|
|
542
|
-
};
|
|
543
|
-
export type HasSessionSuccessResponse = {
|
|
544
|
-
/**
|
|
545
|
-
* - Is the user connected to the merchant? (it means that the merchant
|
|
546
|
-
* id is in the list of merchants listed of this user in the database)? Example: false
|
|
547
|
-
*/
|
|
548
|
-
result: boolean;
|
|
549
|
-
/**
|
|
550
|
-
* - Example: 'notConnected' or 'connected'. Deprecated, use
|
|
551
|
-
* `Identity.isConnected()`
|
|
552
|
-
*/
|
|
553
|
-
userStatus: string;
|
|
554
|
-
/**
|
|
555
|
-
* - Example: 'localhost'
|
|
556
|
-
*/
|
|
557
|
-
baseDomain: string;
|
|
558
|
-
/**
|
|
559
|
-
* - Example: '58eca10fdbb9f6df72c3368f'. Obsolete
|
|
560
|
-
*/
|
|
561
|
-
id: string;
|
|
562
|
-
/**
|
|
563
|
-
* - Example: 37162
|
|
564
|
-
*/
|
|
565
|
-
userId: number;
|
|
566
|
-
/**
|
|
567
|
-
* - Example: 'b3b23aa7-34f2-5d02-a10e-5a3455c6ab2c'
|
|
568
|
-
*/
|
|
569
|
-
uuid: string;
|
|
570
|
-
/**
|
|
571
|
-
* - Example: 'eyJjbGllbnRfaWQ...'
|
|
572
|
-
*/
|
|
573
|
-
sp_id: string;
|
|
574
|
-
/**
|
|
575
|
-
* - Example: 30 * 60 * 1000 (for 30 minutes)
|
|
576
|
-
*/
|
|
577
|
-
expiresIn: number;
|
|
578
|
-
/**
|
|
579
|
-
* - Example: 1506285759
|
|
580
|
-
*/
|
|
581
|
-
serverTime: number;
|
|
582
|
-
/**
|
|
583
|
-
* - Example: 'NCdzXaz4ZRb7...' The sig parameter is a concatenation of an
|
|
584
|
-
* HMAC SHA-256 signature string, a dot (.) and a base64url encoded JSON object (session).
|
|
585
|
-
* {@link http://techdocs.spid.no/sdks/js/response-signature-and-validation/}
|
|
586
|
-
*/
|
|
587
|
-
sig: string;
|
|
588
|
-
/**
|
|
589
|
-
* - (Only for connected users) Example: 'batman'
|
|
590
|
-
*/
|
|
591
|
-
displayName: string;
|
|
592
|
-
/**
|
|
593
|
-
* - (Only for connected users) Example: 'Bruce'
|
|
594
|
-
*/
|
|
595
|
-
givenName: string;
|
|
596
|
-
/**
|
|
597
|
-
* - (Only for connected users) Example: 'Wayne'
|
|
598
|
-
*/
|
|
599
|
-
familyName: string;
|
|
600
|
-
/**
|
|
601
|
-
* - (Only for connected users) Example: 'male', 'female', 'undisclosed'
|
|
602
|
-
*/
|
|
603
|
-
gender: string;
|
|
604
|
-
/**
|
|
605
|
-
* - (Only for connected users) Example:
|
|
606
|
-
* 'http://www.srv.com/some/picture.jpg'
|
|
607
|
-
*/
|
|
608
|
-
photo: string;
|
|
609
|
-
/**
|
|
610
|
-
* - (Only for connected users)
|
|
611
|
-
*/
|
|
612
|
-
tracking: boolean;
|
|
613
|
-
/**
|
|
614
|
-
* - (Only for connected users)
|
|
615
|
-
*/
|
|
616
|
-
clientAgreementAccepted: boolean;
|
|
617
|
-
/**
|
|
618
|
-
* - (Only for connected users)
|
|
619
|
-
*/
|
|
620
|
-
defaultAgreementAccepted: boolean;
|
|
621
|
-
};
|
|
622
|
-
export type HasSessionFailureResponse = {
|
|
623
|
-
error: {
|
|
624
|
-
/**
|
|
625
|
-
* - Typically an HTTP response code. Example: 401
|
|
626
|
-
*/
|
|
627
|
-
code: number;
|
|
628
|
-
/**
|
|
629
|
-
* - Example: "No session found!"
|
|
630
|
-
*/
|
|
631
|
-
description: string;
|
|
632
|
-
/**
|
|
633
|
-
* - Example: "UserException"
|
|
634
|
-
*/
|
|
635
|
-
type: string;
|
|
636
|
-
};
|
|
637
|
-
response: {
|
|
638
|
-
/**
|
|
639
|
-
* - Example: "localhost"
|
|
640
|
-
*/
|
|
641
|
-
baseDomain: string;
|
|
642
|
-
/**
|
|
643
|
-
* - Time span in milliseconds. Example: 30 * 60 * 1000 (for 30 minutes)
|
|
644
|
-
*/
|
|
645
|
-
expiresIn: number;
|
|
646
|
-
result: boolean;
|
|
647
|
-
/**
|
|
648
|
-
* - Server time in seconds since the Unix Epoch. Example: 1506287788
|
|
649
|
-
*/
|
|
650
|
-
serverTime: number;
|
|
651
|
-
};
|
|
652
|
-
};
|
|
653
|
-
export type SimplifiedLoginData = {
|
|
654
|
-
/**
|
|
655
|
-
* - Deprecated: User UUID, to be be used as `loginHint` for {@link Identity#login}
|
|
656
|
-
*/
|
|
657
|
-
identifier: string;
|
|
658
|
-
/**
|
|
659
|
-
* - Human-readable user identifier
|
|
660
|
-
*/
|
|
661
|
-
display_text: string;
|
|
662
|
-
/**
|
|
663
|
-
* - Client name
|
|
664
|
-
*/
|
|
665
|
-
client_name: string;
|
|
666
|
-
};
|
|
667
|
-
export type SimplifiedLoginWidgetOptions = {
|
|
668
|
-
/**
|
|
669
|
-
* - expected encoding of simplified login widget. Could be utf-8 (default), iso-8859-1 or iso-8859-15
|
|
670
|
-
*/
|
|
671
|
-
encoding: string;
|
|
672
|
-
/**
|
|
673
|
-
* - expected locale of simplified login widget. Should be provided in a short format like 'nb',
|
|
674
|
-
* 'sv'. If not set, a value from the env variable is used.
|
|
675
|
-
*/
|
|
676
|
-
locale?: "nb"|"sv"|"fi"|"da"|"en";
|
|
677
|
-
};
|
|
678
|
-
import RESTClient from "./RESTClient.js";
|
|
679
|
-
import SDKError from "./SDKError.js";
|