@schibsted/account-sdk-browser 6.0.0-alpha.5 → 6.0.0-alpha.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/README.md +278 -224
- package/dist/account-sdk.d.ts +18 -0
- package/dist/account.d.ts +139 -3
- package/dist/identity.d.ts +38 -40
- package/dist/index.d.ts +1 -1
- package/dist/index.js +225 -242
- package/dist/index.js.map +1 -1
- package/dist/monetization.d.ts +4 -10
- package/dist/sdk-error.d.ts +2 -0
- package/dist/types/account.d.ts +30 -8
- package/dist/types/common.d.ts +7 -1
- package/dist/types/login.d.ts +16 -11
- package/dist/types/monetization.d.ts +6 -1
- package/dist/types/session.d.ts +28 -3
- package/dist/version.d.ts +1 -1
- package/package.json +1 -4
- package/src/account-sdk.ts +18 -0
- package/src/account.ts +155 -5
- package/src/identity.ts +125 -110
- package/src/index.ts +1 -1
- package/src/monetization.ts +12 -24
- package/src/sdk-error.ts +2 -0
- package/src/types/account.ts +35 -13
- package/src/types/common.ts +7 -1
- package/src/types/login.ts +16 -11
- package/src/types/monetization.ts +6 -1
- package/src/types/session.ts +28 -3
- package/src/version.ts +1 -1
package/src/types/login.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Options accepted by {@link
|
|
2
|
+
* Options accepted by {@link Account#login} and related login URL helpers.
|
|
3
|
+
*
|
|
4
|
+
* @group Login & Widget
|
|
3
5
|
*/
|
|
4
6
|
export type LoginOptions = {
|
|
5
7
|
/**
|
|
@@ -8,14 +10,11 @@ export type LoginOptions = {
|
|
|
8
10
|
*/
|
|
9
11
|
state: string;
|
|
10
12
|
/**
|
|
11
|
-
* Authentication Context Class Reference
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* Methods References) claim in ID token. Might also be used to ensure additional acr
|
|
17
|
-
* (sms, otp, eid) for already logged in users. Supported value is also 'otp-email' means one
|
|
18
|
-
* time password using email.
|
|
13
|
+
* Authentication Context Class Reference values. If omitted, the default account flow is used.
|
|
14
|
+
* Supported values include `password`, `otp`, `sms`, `otp-email`, `eid`, `eid-no`, `eid-se`,
|
|
15
|
+
* `eid-fi`, and `eid-dk`. Values other than `otp-email` may be combined as a space-separated
|
|
16
|
+
* string. Verify the AMR (Authentication Methods References) claim in the ID token on your
|
|
17
|
+
* backend if you need to enforce a completed authentication method.
|
|
19
18
|
*/
|
|
20
19
|
acrValues?:
|
|
21
20
|
| 'password'
|
|
@@ -81,6 +80,8 @@ export type LoginOptions = {
|
|
|
81
80
|
/**
|
|
82
81
|
* Identical to {@link LoginOptions} except that `state` may also be a (possibly async) function;
|
|
83
82
|
* all other fields reuse the `LoginOptions` documentation.
|
|
83
|
+
*
|
|
84
|
+
* @group Login & Widget
|
|
84
85
|
*/
|
|
85
86
|
export type SimplifiedLoginWidgetLoginOptions = Omit<LoginOptions, 'state'> & {
|
|
86
87
|
/**
|
|
@@ -92,9 +93,11 @@ export type SimplifiedLoginWidgetLoginOptions = Omit<LoginOptions, 'state'> & {
|
|
|
92
93
|
|
|
93
94
|
/**
|
|
94
95
|
* Minimal user information used by the simplified login widget flow.
|
|
96
|
+
*
|
|
97
|
+
* @group Login & Widget
|
|
95
98
|
*/
|
|
96
99
|
export type SimplifiedLoginData = {
|
|
97
|
-
/** Deprecated: User UUID
|
|
100
|
+
/** Deprecated: User UUID used as `loginHint` for {@link Account#login}. */
|
|
98
101
|
identifier: string;
|
|
99
102
|
/** Human-readable user identifier */
|
|
100
103
|
display_text: string;
|
|
@@ -105,7 +108,9 @@ export type SimplifiedLoginData = {
|
|
|
105
108
|
};
|
|
106
109
|
|
|
107
110
|
/**
|
|
108
|
-
* Configuration options for {@link
|
|
111
|
+
* Configuration options for {@link Account#showSimplifiedLoginWidget}.
|
|
112
|
+
*
|
|
113
|
+
* @group Login & Widget
|
|
109
114
|
*/
|
|
110
115
|
export type SimplifiedLoginWidgetOptions = {
|
|
111
116
|
/** expected encoding of simplified login widget. Could be utf-8 (default), iso-8859-1 or iso-8859-15 */
|
|
@@ -4,16 +4,21 @@ import type { SessionUserId } from './session';
|
|
|
4
4
|
/**
|
|
5
5
|
* Result returned by the Session Service `/hasAccess` endpoint, describing whether the user
|
|
6
6
|
* is entitled to a requested set of products/features.
|
|
7
|
-
*
|
|
7
|
+
*
|
|
8
|
+
* @group Access Checks
|
|
8
9
|
*/
|
|
9
10
|
export interface HasAccessResult {
|
|
10
11
|
/** Whether the user is entitled to at least one of the requested products/features. */
|
|
11
12
|
entitled: boolean;
|
|
12
13
|
/** How long this result stays valid, in seconds, before the cache entry expires. */
|
|
13
14
|
ttl: number;
|
|
15
|
+
/** Feature ids the user is allowed to access. */
|
|
14
16
|
allowedFeatures: string[];
|
|
17
|
+
/** User id the access result belongs to. */
|
|
15
18
|
userId: SessionUserId;
|
|
19
|
+
/** Globally unique user id the access result belongs to. */
|
|
16
20
|
uuid: string;
|
|
21
|
+
/** Signed response payload. */
|
|
17
22
|
sig: string;
|
|
18
23
|
}
|
|
19
24
|
|
package/src/types/session.ts
CHANGED
|
@@ -7,17 +7,21 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Session Service historically returned numeric ids, while some integrations and tests use
|
|
9
9
|
* string ids. SDK convenience methods normalize this where they promise a string.
|
|
10
|
+
*
|
|
11
|
+
* @group Session
|
|
10
12
|
*/
|
|
11
13
|
export type SessionUserId = number | string;
|
|
12
14
|
|
|
13
15
|
// Session Service object payloads.
|
|
14
16
|
|
|
15
17
|
/**
|
|
16
|
-
* Successful response returned from {@link
|
|
18
|
+
* Successful response returned from {@link Account#hasSession}.
|
|
17
19
|
*
|
|
18
20
|
* `result` means the has-session call itself succeeded. `result: true` means the user is
|
|
19
21
|
* connected to the merchant; `result: false` means a session may exist, but the user is not
|
|
20
22
|
* connected to this client.
|
|
23
|
+
*
|
|
24
|
+
* @group Session
|
|
21
25
|
*/
|
|
22
26
|
export type SessionSuccessResponse = {
|
|
23
27
|
/** Response status code. Example: 200. */
|
|
@@ -31,7 +35,7 @@ export type SessionSuccessResponse = {
|
|
|
31
35
|
* merchants connected to this user.
|
|
32
36
|
*/
|
|
33
37
|
result: boolean;
|
|
34
|
-
/** Connection status string. Deprecated; use `
|
|
38
|
+
/** Connection status string. Deprecated; use `Account.isConnected()`. Example: 'connected'. */
|
|
35
39
|
userStatus?: string;
|
|
36
40
|
/** Cookie base domain used as the `SP_ID` cookie domain fallback. Example: 'spid.no'. */
|
|
37
41
|
baseDomain?: string;
|
|
@@ -77,6 +81,8 @@ export type SessionSuccessResponse = {
|
|
|
77
81
|
|
|
78
82
|
/**
|
|
79
83
|
* Successful has-session response for a user connected to the merchant.
|
|
84
|
+
*
|
|
85
|
+
* @group Session
|
|
80
86
|
*/
|
|
81
87
|
export type ConnectedSessionResponse = SessionSuccessResponse & {
|
|
82
88
|
result: true;
|
|
@@ -84,6 +90,8 @@ export type ConnectedSessionResponse = SessionSuccessResponse & {
|
|
|
84
90
|
|
|
85
91
|
/**
|
|
86
92
|
* Connected session response that also carries a usable user id.
|
|
93
|
+
*
|
|
94
|
+
* @group Session
|
|
87
95
|
*/
|
|
88
96
|
export type ConnectedSessionWithUserIdResponse = ConnectedSessionResponse & {
|
|
89
97
|
userId: SessionUserId;
|
|
@@ -94,6 +102,8 @@ export type ConnectedSessionWithUserIdResponse = ConnectedSessionResponse & {
|
|
|
94
102
|
*
|
|
95
103
|
* API and network failures usually reject with {@link SDKError}; this shape represents a failure
|
|
96
104
|
* payload when one is returned by Session Service and reaches the has-session flow.
|
|
105
|
+
*
|
|
106
|
+
* @group Session
|
|
97
107
|
*/
|
|
98
108
|
export type SessionFailureResponse = {
|
|
99
109
|
/** Failure payload returned by Session Service. Usually an object, but tests also pass strings. */
|
|
@@ -121,9 +131,16 @@ export type SessionFailureResponse = {
|
|
|
121
131
|
*
|
|
122
132
|
* This intentionally includes `{}`. Historically `hasSession()` could resolve an empty object or
|
|
123
133
|
* other object payloads that callers inspected themselves, so the SDK preserves those responses.
|
|
134
|
+
*
|
|
135
|
+
* @group Session
|
|
124
136
|
*/
|
|
125
137
|
export type UnrecognizedSessionResponse = object;
|
|
126
138
|
|
|
139
|
+
/**
|
|
140
|
+
* Redirect URL returned by `hasSession()` when Session Service needs a full-page session refresh.
|
|
141
|
+
*
|
|
142
|
+
* @group Session
|
|
143
|
+
*/
|
|
127
144
|
export type RedirectSessionResponse = string;
|
|
128
145
|
|
|
129
146
|
export type SessionObjectResponse =
|
|
@@ -135,10 +152,18 @@ export type RedirectSessionPayload = {
|
|
|
135
152
|
redirectURL: string;
|
|
136
153
|
};
|
|
137
154
|
|
|
155
|
+
/**
|
|
156
|
+
* Internal shape returned by `normalizeSessionResponse()` before `hasSession()` post-processing.
|
|
157
|
+
*
|
|
158
|
+
* It includes regular Session Service object responses and redirect responses used for full-page
|
|
159
|
+
* session refresh.
|
|
160
|
+
*/
|
|
138
161
|
export type NormalizedSessionPayload = SessionObjectResponse | RedirectSessionPayload;
|
|
139
162
|
|
|
140
163
|
/**
|
|
141
|
-
* Public response union returned from {@link
|
|
164
|
+
* Public response union returned from {@link Account#hasSession}.
|
|
165
|
+
*
|
|
166
|
+
* @group Session
|
|
142
167
|
*/
|
|
143
168
|
export type SessionResponse =
|
|
144
169
|
| SessionSuccessResponse
|
package/src/version.ts
CHANGED