@teamhanko/hanko-frontend-sdk 1.5.2 → 2.0.0
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 +453 -97
- package/dist/Hanko.d.ts +57 -29
- package/dist/index.d.ts +16 -9
- package/dist/lib/Cookie.d.ts +2 -2
- package/dist/lib/Dto.d.ts +11 -184
- package/dist/lib/client/HttpClient.d.ts +7 -9
- package/dist/lib/client/SessionClient.d.ts +0 -11
- package/dist/lib/client/UserClient.d.ts +1 -35
- package/dist/lib/events/CustomEvents.d.ts +25 -0
- package/dist/lib/events/Dispatcher.d.ts +9 -1
- package/dist/lib/events/Listener.d.ts +3 -1
- package/dist/lib/events/Relay.d.ts +3 -3
- package/dist/lib/flow-api/State.d.ts +192 -62
- package/dist/lib/flow-api/WebauthnManager.d.ts +47 -0
- package/dist/lib/flow-api/auto-steps.d.ts +2 -0
- package/dist/lib/flow-api/passkey-autofill-activation.d.ts +2 -0
- package/dist/lib/flow-api/types/action.d.ts +2 -1
- package/dist/lib/flow-api/types/flow.d.ts +25 -0
- package/dist/lib/flow-api/types/{error.d.ts → flowError.d.ts} +1 -2
- package/dist/lib/flow-api/types/input.d.ts +3 -4
- package/dist/lib/flow-api/types/{state-handling.d.ts → state.d.ts} +0 -7
- package/dist/sdk.cjs +1 -1
- package/dist/sdk.cjs.map +1 -1
- package/dist/sdk.modern.js +1 -1
- package/dist/sdk.modern.js.map +1 -1
- package/dist/sdk.module.js +1 -1
- package/dist/sdk.module.js.map +1 -1
- package/dist/sdk.umd.js +1 -1
- package/dist/sdk.umd.js.map +1 -1
- package/package.json +1 -1
- package/dist/lib/client/EmailClient.d.ts +0 -58
- package/dist/lib/client/EnterpriseClient.d.ts +0 -41
- package/dist/lib/client/ThirdPartyClient.d.ts +0 -28
- package/dist/lib/client/TokenClient.d.ts +0 -21
- package/dist/lib/flow-api/BrowserFlowStorage.d.ts +0 -6
- package/dist/lib/flow-api/Flow.d.ts +0 -41
- package/dist/lib/state/State.d.ts +0 -50
package/dist/index.d.ts
CHANGED
|
@@ -1,20 +1,27 @@
|
|
|
1
1
|
import { Hanko } from "./Hanko";
|
|
2
2
|
export { Hanko };
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { ThirdPartyClient } from "./lib/client/ThirdPartyClient";
|
|
6
|
-
import { TokenClient } from "./lib/client/TokenClient";
|
|
7
|
-
import { EnterpriseClient } from "./lib/client/EnterpriseClient";
|
|
3
|
+
import { HttpClient } from "./lib/client/HttpClient";
|
|
4
|
+
import { Client } from "./lib/client/Client";
|
|
8
5
|
import { SessionClient } from "./lib/client/SessionClient";
|
|
9
|
-
|
|
6
|
+
import { UserClient } from "./lib/client/UserClient";
|
|
7
|
+
export { HttpClient, Client, SessionClient, UserClient };
|
|
8
|
+
import { Relay } from "./lib/events/Relay";
|
|
9
|
+
export { Relay };
|
|
10
10
|
import { WebauthnSupport } from "./lib/WebauthnSupport";
|
|
11
11
|
export { WebauthnSupport };
|
|
12
|
-
import {
|
|
13
|
-
export type {
|
|
12
|
+
import { Email, Emails, Identity, SessionCheckResponse } from "./lib/Dto";
|
|
13
|
+
export type { Email, Emails, Identity, SessionCheckResponse };
|
|
14
14
|
import { HankoError, ConflictError, ForbiddenError, EmailAddressAlreadyExistsError, InvalidPasswordError, InvalidPasscodeError, InvalidWebauthnCredentialError, MaxNumOfEmailAddressesReachedError, MaxNumOfPasscodeAttemptsReachedError, NotFoundError, PasscodeExpiredError, RequestTimeoutError, TechnicalError, ThirdPartyError, TooManyRequestsError, UnauthorizedError, UserVerificationError, WebauthnRequestCancelledError } from "./lib/Errors";
|
|
15
15
|
export { HankoError, ConflictError, ForbiddenError, EmailAddressAlreadyExistsError, InvalidPasswordError, InvalidPasscodeError, InvalidWebauthnCredentialError, MaxNumOfEmailAddressesReachedError, MaxNumOfPasscodeAttemptsReachedError, NotFoundError, PasscodeExpiredError, RequestTimeoutError, TechnicalError, ThirdPartyError, TooManyRequestsError, UnauthorizedError, UserVerificationError, WebauthnRequestCancelledError, };
|
|
16
|
-
import { CustomEventWithDetail, SessionDetail, sessionCreatedType, sessionExpiredType, userLoggedOutType, userDeletedType } from "./lib/events/CustomEvents";
|
|
16
|
+
import { CustomEventWithDetail, SessionDetail, FlowDetail, sessionCreatedType, sessionExpiredType, userLoggedOutType, userDeletedType } from "./lib/events/CustomEvents";
|
|
17
17
|
export type { SessionDetail };
|
|
18
|
+
export type { FlowDetail };
|
|
18
19
|
export { sessionCreatedType, sessionExpiredType, userLoggedOutType, userDeletedType, CustomEventWithDetail, };
|
|
19
20
|
import { CookieSameSite } from "./lib/Cookie";
|
|
20
21
|
export type { CookieSameSite };
|
|
22
|
+
export * from "./lib/flow-api/State";
|
|
23
|
+
export * from "./lib/flow-api/types/flow";
|
|
24
|
+
export * from "./lib/flow-api/types/flowError";
|
|
25
|
+
export * from "./lib/flow-api/types/payload";
|
|
26
|
+
export * from "./lib/flow-api/types/state";
|
|
27
|
+
export * from "./lib/flow-api/types/input";
|
package/dist/lib/Cookie.d.ts
CHANGED
|
@@ -4,12 +4,12 @@ import { CookieAttributes } from "js-cookie";
|
|
|
4
4
|
*
|
|
5
5
|
* @category SDK
|
|
6
6
|
* @subcategory Internal
|
|
7
|
-
* @property {string} cookieName - The name of the session cookie set from the SDK.
|
|
7
|
+
* @property {string=} cookieName - The name of the session cookie set from the SDK. Defaults to "hanko".
|
|
8
8
|
* @property {string=} cookieDomain - The domain where the cookie set from the SDK is available. Defaults to the domain of the page where the cookie was created.
|
|
9
9
|
* @property {string=} cookieSameSite -Specify whether/when cookies are sent with cross-site requests. Defaults to "lax".
|
|
10
10
|
*/
|
|
11
11
|
interface CookieOptions {
|
|
12
|
-
cookieName
|
|
12
|
+
cookieName?: string;
|
|
13
13
|
cookieDomain?: string;
|
|
14
14
|
cookieSameSite?: CookieSameSite;
|
|
15
15
|
}
|
package/dist/lib/Dto.d.ts
CHANGED
|
@@ -1,89 +1,3 @@
|
|
|
1
|
-
import { PublicKeyCredentialWithAttestationJSON } from "@github/webauthn-json";
|
|
2
|
-
/**
|
|
3
|
-
* @interface
|
|
4
|
-
* @category SDK
|
|
5
|
-
* @subcategory DTO
|
|
6
|
-
* @property {boolean} enabled - Indicates passwords are enabled, so the API accepts login attempts using passwords.
|
|
7
|
-
* @property {number} min_password_length - The minimum length of a password. To be used for password validation.
|
|
8
|
-
*/
|
|
9
|
-
export interface PasswordConfig {
|
|
10
|
-
enabled: boolean;
|
|
11
|
-
min_password_length: number;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* @interface
|
|
15
|
-
* @category SDK
|
|
16
|
-
* @subcategory DTO
|
|
17
|
-
* @property {boolean} require_verification - Indicates that email addresses must be verified.
|
|
18
|
-
* @property {number} max_num_of_addresses - The maximum number of email addresses a user can have.
|
|
19
|
-
*/
|
|
20
|
-
export interface EmailConfig {
|
|
21
|
-
require_verification: boolean;
|
|
22
|
-
max_num_of_addresses: number;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* @interface
|
|
26
|
-
* @category SDK
|
|
27
|
-
* @subcategory DTO
|
|
28
|
-
* @property {boolean} allow_deletion - Indicates the current user is allowed to delete the account.
|
|
29
|
-
* @property {boolean} allow_signup - Indicates the current user is allowed to sign up.
|
|
30
|
-
*/
|
|
31
|
-
export interface AccountConfig {
|
|
32
|
-
allow_deletion: boolean;
|
|
33
|
-
allow_signup: boolean;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* @interface
|
|
37
|
-
* @category SDK
|
|
38
|
-
* @subcategory DTO
|
|
39
|
-
* @property {PasswordConfig} password - The password configuration.
|
|
40
|
-
* @property {EmailConfig} emails - The email configuration.
|
|
41
|
-
* @property {string[]} providers - The enabled third party providers.
|
|
42
|
-
* @property {AccountConfig} account - Controls the behaviour regarding user accounts.
|
|
43
|
-
* @property {boolean} use_enterprise - Enterprise Connections are enabled.
|
|
44
|
-
*/
|
|
45
|
-
export interface Config {
|
|
46
|
-
password: PasswordConfig;
|
|
47
|
-
emails: EmailConfig;
|
|
48
|
-
providers: string[];
|
|
49
|
-
account: AccountConfig;
|
|
50
|
-
use_enterprise: boolean;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* @interface
|
|
54
|
-
* @category SDK
|
|
55
|
-
* @subcategory DTO
|
|
56
|
-
* @property {string} credential_id - The ID of the credential that was used.
|
|
57
|
-
* @property {string} user_id - The ID of the user that was used.
|
|
58
|
-
*/
|
|
59
|
-
export interface WebauthnFinalized {
|
|
60
|
-
credential_id: string;
|
|
61
|
-
user_id: string;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* @interface
|
|
65
|
-
* @category SDK
|
|
66
|
-
* @subcategory DTO
|
|
67
|
-
* @property {string} user_id - The ID of the user associated with the token.
|
|
68
|
-
*/
|
|
69
|
-
export interface TokenFinalized {
|
|
70
|
-
user_id: string;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* @interface
|
|
74
|
-
* @category SDK
|
|
75
|
-
* @subcategory DTO
|
|
76
|
-
* @property {string} id - The UUID of the user.
|
|
77
|
-
* @property {boolean} verified - Indicates whether the user's email address is verified.
|
|
78
|
-
* @property {string} email_id - The UUID of the email address.
|
|
79
|
-
* @property {boolean} has_webauthn_credential - Indicates that the user has registered a WebAuthn credential in the past.
|
|
80
|
-
*/
|
|
81
|
-
export interface UserInfo {
|
|
82
|
-
id: string;
|
|
83
|
-
verified: boolean;
|
|
84
|
-
email_id: string;
|
|
85
|
-
has_webauthn_credential: boolean;
|
|
86
|
-
}
|
|
87
1
|
/**
|
|
88
2
|
* @interface
|
|
89
3
|
* @category SDK
|
|
@@ -94,70 +8,6 @@ export interface UserInfo {
|
|
|
94
8
|
export interface Me {
|
|
95
9
|
id: string;
|
|
96
10
|
}
|
|
97
|
-
/**
|
|
98
|
-
* @interface
|
|
99
|
-
* @category SDK
|
|
100
|
-
* @subcategory DTO
|
|
101
|
-
* @property {string} id - The WebAuthn credential ID.
|
|
102
|
-
*/
|
|
103
|
-
export interface Credential {
|
|
104
|
-
id: string;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* @interface
|
|
108
|
-
* @category SDK
|
|
109
|
-
* @subcategory DTO
|
|
110
|
-
* @property {string} id - The user's UUID.
|
|
111
|
-
* @property {string=} email - The user's email.
|
|
112
|
-
* @property {string=} username - The user's username.
|
|
113
|
-
* @property {Credential[]} webauthn_credentials - A list of credentials that have been registered.
|
|
114
|
-
*/
|
|
115
|
-
export interface User {
|
|
116
|
-
id: string;
|
|
117
|
-
email?: string;
|
|
118
|
-
username?: string;
|
|
119
|
-
webauthn_credentials: Credential[];
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* @interface
|
|
123
|
-
* @category SDK
|
|
124
|
-
* @subcategory DTO
|
|
125
|
-
* @property {string} user_id - The user's UUID.
|
|
126
|
-
* @property {string} email_id - The ID of the new email.
|
|
127
|
-
*/
|
|
128
|
-
export interface UserCreated {
|
|
129
|
-
user_id: string;
|
|
130
|
-
email_id: string;
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* @interface
|
|
134
|
-
* @category SDK
|
|
135
|
-
* @subcategory DTO
|
|
136
|
-
* @property {string} id - The UUID of the passcode.
|
|
137
|
-
* @property {number} ttl - How long the code is active in seconds.
|
|
138
|
-
*/
|
|
139
|
-
export interface Passcode {
|
|
140
|
-
id: string;
|
|
141
|
-
ttl: number;
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* @interface
|
|
145
|
-
* @category SDK
|
|
146
|
-
* @subcategory DTO
|
|
147
|
-
* @property {string[]} - Transports which may be used by the authenticator. E.g. "internal", "ble",...
|
|
148
|
-
*/
|
|
149
|
-
export interface WebauthnTransports extends Array<string> {
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* @interface
|
|
153
|
-
* @category SDK
|
|
154
|
-
* @subcategory DTO
|
|
155
|
-
* @property {WebauthnTransports} transports
|
|
156
|
-
* @ignore
|
|
157
|
-
*/
|
|
158
|
-
export interface Attestation extends PublicKeyCredentialWithAttestationJSON {
|
|
159
|
-
transports: WebauthnTransports;
|
|
160
|
-
}
|
|
161
11
|
/**
|
|
162
12
|
* @interface
|
|
163
13
|
* @category SDK
|
|
@@ -185,37 +35,6 @@ export interface Email {
|
|
|
185
35
|
*/
|
|
186
36
|
export interface Emails extends Array<Email> {
|
|
187
37
|
}
|
|
188
|
-
/**
|
|
189
|
-
* @interface
|
|
190
|
-
* @category SDK
|
|
191
|
-
* @subcategory DTO
|
|
192
|
-
* @property {string} id - The credential id.
|
|
193
|
-
* @property {string=} name - The credential name.
|
|
194
|
-
* @property {string} public_key - The public key.
|
|
195
|
-
* @property {string} attestation_type - The attestation type.
|
|
196
|
-
* @property {string} aaguid - The AAGUID of the authenticator.
|
|
197
|
-
* @property {string} last_used_at - The time when the credential was used last.
|
|
198
|
-
* @property {string} created_at - Time of credential creation.
|
|
199
|
-
* @property {WebauthnTransports} transports
|
|
200
|
-
*/
|
|
201
|
-
export interface WebauthnCredential {
|
|
202
|
-
id: string;
|
|
203
|
-
name?: string;
|
|
204
|
-
public_key: string;
|
|
205
|
-
attestation_type: string;
|
|
206
|
-
aaguid: string;
|
|
207
|
-
last_used_at: string;
|
|
208
|
-
created_at: string;
|
|
209
|
-
transports: WebauthnTransports;
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* @interface
|
|
213
|
-
* @category SDK
|
|
214
|
-
* @subcategory DTO
|
|
215
|
-
* @property {WebauthnCredential[]} - A list of WebAuthn credential assigned to the current user.
|
|
216
|
-
*/
|
|
217
|
-
export interface WebauthnCredentials extends Array<WebauthnCredential> {
|
|
218
|
-
}
|
|
219
38
|
/**
|
|
220
39
|
* @interface
|
|
221
40
|
* @category SDK
|
|
@@ -228,7 +47,12 @@ export interface Identity {
|
|
|
228
47
|
provider: string;
|
|
229
48
|
}
|
|
230
49
|
/**
|
|
231
|
-
* Represents the claims associated with a session or token.
|
|
50
|
+
* Represents the claims associated with a session or token. Includes standard claims such as `subject`, `issued_at`,
|
|
51
|
+
* `expiration`, and others, as well as custom claims defined by the user.
|
|
52
|
+
*
|
|
53
|
+
* @template TCustomClaims - An optional generic parameter that represents custom claims.
|
|
54
|
+
* It extends a record with string keys and unknown values.
|
|
55
|
+
* Defaults to `Record<string, unknown>` if not provided.
|
|
232
56
|
*
|
|
233
57
|
* @interface
|
|
234
58
|
* @category SDK
|
|
@@ -241,8 +65,11 @@ export interface Identity {
|
|
|
241
65
|
* @property {Pick<Email, "address" | "is_primary" | "is_verified">} [email] - Email information associated with the subject (optional).
|
|
242
66
|
* @property {string} [username] - The subject's username (optional).
|
|
243
67
|
* @property {string} session_id - The session identifier linked to the claims.
|
|
68
|
+
*
|
|
69
|
+
* @description Custom claims can be added via the `TCustomClaims` generic parameter, which will be merged
|
|
70
|
+
* with the standard claims properties. These custom claims must follow the `Record<string, unknown>` pattern.
|
|
244
71
|
*/
|
|
245
|
-
export
|
|
72
|
+
export type Claims<TCustomClaims extends Record<string, unknown> = Record<string, unknown>> = {
|
|
246
73
|
subject: string;
|
|
247
74
|
issued_at?: string;
|
|
248
75
|
expiration: string;
|
|
@@ -251,7 +78,7 @@ export interface Claims {
|
|
|
251
78
|
email?: Pick<Email, "address" | "is_primary" | "is_verified">;
|
|
252
79
|
username?: string;
|
|
253
80
|
session_id: string;
|
|
254
|
-
}
|
|
81
|
+
} & TCustomClaims;
|
|
255
82
|
/**
|
|
256
83
|
* Represents the response from a session validation or retrieval operation.
|
|
257
84
|
*
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Dispatcher } from "../events/Dispatcher";
|
|
2
2
|
import { Cookie } from "../Cookie";
|
|
3
3
|
import { SessionStorage } from "../SessionStorage";
|
|
4
|
+
import { HankoOptions } from "../../Hanko";
|
|
4
5
|
export type SessionTokenLocation = "cookie" | "sessionStorage";
|
|
5
6
|
/**
|
|
6
7
|
* This class wraps an XMLHttpRequest to maintain compatibility with the fetch API.
|
|
@@ -58,20 +59,18 @@ declare class Response {
|
|
|
58
59
|
*
|
|
59
60
|
* @category SDK
|
|
60
61
|
* @subcategory Internal
|
|
61
|
-
* @property {number} timeout - The http request timeout in milliseconds.
|
|
62
|
+
* @property {number=} timeout - The http request timeout in milliseconds.
|
|
62
63
|
* @property {string} cookieName - The name of the session cookie set from the SDK.
|
|
63
64
|
* @property {string=} cookieDomain - The domain where cookie set from the SDK is available. Defaults to the domain of the page where the cookie was created.
|
|
64
|
-
* @property {string}
|
|
65
|
-
* @property {string} lang - The language used by the client(s) to convey to the Hanko API the language to use -
|
|
65
|
+
* @property {string?} lang - The language used by the client(s) to convey to the Hanko API the language to use -
|
|
66
66
|
* e.g. for translating outgoing emails - in a custom header (X-Language).
|
|
67
67
|
*/
|
|
68
68
|
export interface HttpClientOptions {
|
|
69
|
-
timeout
|
|
70
|
-
cookieName
|
|
69
|
+
timeout?: number;
|
|
70
|
+
cookieName?: string;
|
|
71
71
|
cookieDomain?: string;
|
|
72
|
-
localStorageKey: string;
|
|
73
72
|
lang?: string;
|
|
74
|
-
sessionTokenLocation
|
|
73
|
+
sessionTokenLocation?: SessionTokenLocation;
|
|
75
74
|
}
|
|
76
75
|
/**
|
|
77
76
|
* Internally used for communication with the Hanko API. It also handles authorization tokens to enable authorized
|
|
@@ -95,9 +94,8 @@ declare class HttpClient {
|
|
|
95
94
|
sessionTokenStorage: SessionStorage;
|
|
96
95
|
lang: string;
|
|
97
96
|
sessionTokenLocation: SessionTokenLocation;
|
|
98
|
-
constructor(api: string, options:
|
|
97
|
+
constructor(api: string, options: HankoOptions);
|
|
99
98
|
_fetch(path: string, options: RequestInit, xhr?: XMLHttpRequest): Promise<Response>;
|
|
100
|
-
_fetch_blocking(path: string, options: RequestInit, xhr?: XMLHttpRequest): string;
|
|
101
99
|
/**
|
|
102
100
|
* Processes the response headers on login and extracts the JWT and expiration time.
|
|
103
101
|
*
|
|
@@ -18,14 +18,3 @@ export declare class SessionClient extends Client {
|
|
|
18
18
|
*/
|
|
19
19
|
validate(): Promise<SessionCheckResponse>;
|
|
20
20
|
}
|
|
21
|
-
export declare class Session extends Client {
|
|
22
|
-
/**
|
|
23
|
-
* Checks if the current session is still valid. This function is to be removed - please replace
|
|
24
|
-
* any usage with the new 'SessionClient.validate()' function.
|
|
25
|
-
*
|
|
26
|
-
* @return {boolean}
|
|
27
|
-
* @throws {TechnicalError}
|
|
28
|
-
* @deprecated
|
|
29
|
-
*/
|
|
30
|
-
isValid(): boolean;
|
|
31
|
-
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { User, UserInfo, UserCreated } from "../Dto";
|
|
2
1
|
import { Client } from "./Client";
|
|
2
|
+
import { User } from "../flow-api/types/payload";
|
|
3
3
|
/**
|
|
4
4
|
* A class to manage user information.
|
|
5
5
|
*
|
|
@@ -8,31 +8,6 @@ import { Client } from "./Client";
|
|
|
8
8
|
* @extends {Client}
|
|
9
9
|
*/
|
|
10
10
|
declare class UserClient extends Client {
|
|
11
|
-
/**
|
|
12
|
-
* Fetches basic information about the user identified by the given email address. Can be used while the user is logged out
|
|
13
|
-
* and is helpful in deciding which type of login to choose. For example, if the user's email is not verified, you may
|
|
14
|
-
* want to log in with a passcode, or if no WebAuthn credentials are registered, you may not want to use WebAuthn.
|
|
15
|
-
*
|
|
16
|
-
* @param {string} email - The user's email address.
|
|
17
|
-
* @return {Promise<UserInfo>}
|
|
18
|
-
* @throws {NotFoundError}
|
|
19
|
-
* @throws {RequestTimeoutError}
|
|
20
|
-
* @throws {TechnicalError}
|
|
21
|
-
* @see https://docs.hanko.io/api/public#tag/User-Management/operation/getUserId
|
|
22
|
-
*/
|
|
23
|
-
getInfo(email: string): Promise<UserInfo>;
|
|
24
|
-
/**
|
|
25
|
-
* Creates a new user. Afterwards, verify the email address via passcode. If a 'ConflictError'
|
|
26
|
-
* occurred, you may want to prompt the user to log in.
|
|
27
|
-
*
|
|
28
|
-
* @param {string} email - The email address of the user to be created.
|
|
29
|
-
* @return {Promise<UserCreated>}
|
|
30
|
-
* @throws {ConflictError}
|
|
31
|
-
* @throws {RequestTimeoutError}
|
|
32
|
-
* @throws {TechnicalError}
|
|
33
|
-
* @see https://docs.hanko.io/api/public#tag/User-Management/operation/createUser
|
|
34
|
-
*/
|
|
35
|
-
create(email: string): Promise<UserCreated>;
|
|
36
11
|
/**
|
|
37
12
|
* Fetches the current user.
|
|
38
13
|
*
|
|
@@ -44,15 +19,6 @@ declare class UserClient extends Client {
|
|
|
44
19
|
* @see https://docs.hanko.io/api/public#tag/User-Management/operation/listUser
|
|
45
20
|
*/
|
|
46
21
|
getCurrent(): Promise<User>;
|
|
47
|
-
/**
|
|
48
|
-
* Deletes the current user and expires the existing session cookie.
|
|
49
|
-
*
|
|
50
|
-
* @return {Promise<void>}
|
|
51
|
-
* @throws {RequestTimeoutError}
|
|
52
|
-
* @throws {TechnicalError}
|
|
53
|
-
* @throws {UnauthorizedError}
|
|
54
|
-
*/
|
|
55
|
-
delete(): Promise<void>;
|
|
56
22
|
/**
|
|
57
23
|
* Logs out the current user and expires the existing session cookie. A valid session cookie is required to call the logout endpoint.
|
|
58
24
|
*
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Claims } from "../Dto";
|
|
2
|
+
import { AnyState } from "../flow-api/types/flow";
|
|
2
3
|
/**
|
|
3
4
|
* The type of the `hanko-session-created` event.
|
|
4
5
|
* @typedef {string} sessionCreatedType
|
|
@@ -35,6 +36,24 @@ export declare const userLoggedInType: "hanko-user-logged-in";
|
|
|
35
36
|
* @memberOf Listener
|
|
36
37
|
*/
|
|
37
38
|
export declare const userCreatedType: "hanko-user-created";
|
|
39
|
+
/**
|
|
40
|
+
* The type of the `hanko-after-state-change` event.
|
|
41
|
+
* @typedef {string} flowAfterStateChangeType
|
|
42
|
+
* @memberOf Listener
|
|
43
|
+
*/
|
|
44
|
+
export declare const flowAfterStateChangeType: "hanko-after-state-change";
|
|
45
|
+
/**
|
|
46
|
+
* The type of the `hanko-before-state-change` event.
|
|
47
|
+
* @typedef {string} flowBeforeStateChangeType
|
|
48
|
+
* @memberOf Listener
|
|
49
|
+
*/
|
|
50
|
+
export declare const flowBeforeStateChangeType: "hanko-before-state-change";
|
|
51
|
+
/**
|
|
52
|
+
* The type of the `hanko-flow-error` event.
|
|
53
|
+
* @typedef {string} flowErrorType
|
|
54
|
+
* @memberOf Listener
|
|
55
|
+
*/
|
|
56
|
+
export declare const flowErrorType: "hanko-flow-error";
|
|
38
57
|
/**
|
|
39
58
|
* The data passed in the `hanko-session-created` or `hanko-session-resumed` event.
|
|
40
59
|
*
|
|
@@ -48,6 +67,12 @@ export interface SessionDetail {
|
|
|
48
67
|
claims: Claims;
|
|
49
68
|
expirationSeconds: number;
|
|
50
69
|
}
|
|
70
|
+
export interface FlowErrorDetail {
|
|
71
|
+
error: Error;
|
|
72
|
+
}
|
|
73
|
+
export interface FlowDetail {
|
|
74
|
+
state: AnyState;
|
|
75
|
+
}
|
|
51
76
|
/**
|
|
52
77
|
* A custom event that includes a detail object.
|
|
53
78
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SessionDetail } from "./CustomEvents";
|
|
1
|
+
import { SessionDetail, FlowDetail } from "./CustomEvents";
|
|
2
2
|
/**
|
|
3
3
|
* A class that dispatches custom events.
|
|
4
4
|
*
|
|
@@ -33,4 +33,12 @@ export declare class Dispatcher {
|
|
|
33
33
|
* Dispatches a "hanko-user-deleted" event to the document.
|
|
34
34
|
*/
|
|
35
35
|
dispatchUserDeletedEvent(): void;
|
|
36
|
+
/**
|
|
37
|
+
* Dispatches a "hanko-after-state-change" event to the document.
|
|
38
|
+
*/
|
|
39
|
+
dispatchAfterStateChangeEvent(detail: FlowDetail): void;
|
|
40
|
+
/**
|
|
41
|
+
* Dispatches a "hanko-before-state-change" event to the document.
|
|
42
|
+
*/
|
|
43
|
+
dispatchBeforeStateChangeEvent(detail: FlowDetail): void;
|
|
36
44
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Throttle } from "../Throttle";
|
|
2
|
-
import { SessionDetail } from "./CustomEvents";
|
|
2
|
+
import { SessionDetail, FlowDetail } from "./CustomEvents";
|
|
3
3
|
/**
|
|
4
4
|
* A callback function to be executed when an event is triggered.
|
|
5
5
|
*
|
|
@@ -102,5 +102,7 @@ export declare class Listener {
|
|
|
102
102
|
* @returns {CleanupFunc} This function can be called to remove the event listener.
|
|
103
103
|
*/
|
|
104
104
|
onUserDeleted(callback: CallbackFunc<null>, once?: boolean): CleanupFunc;
|
|
105
|
+
onAfterStateChange(callback: CallbackFunc<FlowDetail>, once?: boolean): CleanupFunc;
|
|
106
|
+
onBeforeStateChange(callback: CallbackFunc<FlowDetail>, once?: boolean): CleanupFunc;
|
|
105
107
|
}
|
|
106
108
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Listener } from "./Listener";
|
|
2
2
|
import { Dispatcher } from "./Dispatcher";
|
|
3
|
-
import {
|
|
3
|
+
import { HankoOptions } from "../../Hanko";
|
|
4
4
|
/**
|
|
5
5
|
* A class that manages session checks, dispatches events based on session status,
|
|
6
6
|
* and uses broadcast channels for inter-tab communication.
|
|
@@ -9,7 +9,7 @@ import { InternalOptions } from "../../Hanko";
|
|
|
9
9
|
* @subcategory Internal
|
|
10
10
|
* @extends Dispatcher
|
|
11
11
|
* @param {string} api - The API endpoint URL.
|
|
12
|
-
* @param {
|
|
12
|
+
* @param {HankoOptions} options - The internal configuration options of the SDK.
|
|
13
13
|
*/
|
|
14
14
|
export declare class Relay extends Dispatcher {
|
|
15
15
|
listener: Listener;
|
|
@@ -20,7 +20,7 @@ export declare class Relay extends Dispatcher {
|
|
|
20
20
|
private readonly scheduler;
|
|
21
21
|
private readonly sessionChannel;
|
|
22
22
|
private isLoggedIn;
|
|
23
|
-
constructor(api: string, options:
|
|
23
|
+
constructor(api: string, options: HankoOptions);
|
|
24
24
|
/**
|
|
25
25
|
* Sets up all event listeners and initializes session management.
|
|
26
26
|
* This method is crucial for ensuring the session is monitored across all tabs.
|