@teamhanko/hanko-frontend-sdk 0.0.1-alpha → 0.0.2-alpha
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 +1 -1
- 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.d.ts +0 -305
- package/dist/lib/State.d.ts +0 -55
package/dist/lib/Client.d.ts
DELETED
|
@@ -1,305 +0,0 @@
|
|
|
1
|
-
import { Config, Passcode, User, UserInfo } from "./Dto";
|
|
2
|
-
/**
|
|
3
|
-
* This class wraps an XMLHttpRequest to maintain compatibility with the fetch API.
|
|
4
|
-
*
|
|
5
|
-
* @category SDK
|
|
6
|
-
* @subcategory Internal
|
|
7
|
-
* @param {XMLHttpRequest} xhr - The request to be wrapped.
|
|
8
|
-
* @see HttpClient
|
|
9
|
-
*/
|
|
10
|
-
declare class Headers {
|
|
11
|
-
_xhr: XMLHttpRequest;
|
|
12
|
-
constructor(xhr: XMLHttpRequest);
|
|
13
|
-
get(name: string): string;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* This class wraps an XMLHttpRequest to maintain compatibility with the fetch API.
|
|
17
|
-
*
|
|
18
|
-
* @category SDK
|
|
19
|
-
* @subcategory Internal
|
|
20
|
-
* @param {XMLHttpRequest} xhr - The request to be wrapped.
|
|
21
|
-
* @see HttpClient
|
|
22
|
-
*/
|
|
23
|
-
declare class Response {
|
|
24
|
-
headers: Headers;
|
|
25
|
-
ok: boolean;
|
|
26
|
-
status: number;
|
|
27
|
-
statusText: string;
|
|
28
|
-
url: string;
|
|
29
|
-
_decodedJSON: any;
|
|
30
|
-
constructor(xhr: XMLHttpRequest);
|
|
31
|
-
/**
|
|
32
|
-
* Returns the JSON decoded response.
|
|
33
|
-
*
|
|
34
|
-
* @return {any}
|
|
35
|
-
*/
|
|
36
|
-
json(): any;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Internally used for communication with the Hanko API. It also handles authorization tokens to enable authorized
|
|
40
|
-
* requests.
|
|
41
|
-
*
|
|
42
|
-
* Currently, there is an issue with Safari and on iOS 15 devices where decoding a JSON response via the fetch API
|
|
43
|
-
* breaks the user gesture and the user is not able to use the authenticator. Therefore, this class uses XMLHttpRequests
|
|
44
|
-
* instead of the fetch API, but maintains compatibility by wrapping the XMLHttpRequests. So, if the issues are fixed,
|
|
45
|
-
* we can easily return to the fetch API.
|
|
46
|
-
*
|
|
47
|
-
* @category SDK
|
|
48
|
-
* @subcategory Internal
|
|
49
|
-
* @param {string} api - The URL of your Hanko API instance
|
|
50
|
-
* @param {number=} timeout - The request timeout in milliseconds
|
|
51
|
-
*/
|
|
52
|
-
declare class HttpClient {
|
|
53
|
-
timeout: number;
|
|
54
|
-
api: string;
|
|
55
|
-
constructor(api: string, timeout?: number);
|
|
56
|
-
_fetch(path: string, options: RequestInit): Promise<Response>;
|
|
57
|
-
/**
|
|
58
|
-
* Performs a GET request.
|
|
59
|
-
*
|
|
60
|
-
* @param {string} path - The path to the requested resource.
|
|
61
|
-
* @return {Promise<Response>}
|
|
62
|
-
* @throws {RequestTimeoutError}
|
|
63
|
-
* @throws {TechnicalError}
|
|
64
|
-
*/
|
|
65
|
-
get(path: string): Promise<Response>;
|
|
66
|
-
/**
|
|
67
|
-
* Performs a POST request.
|
|
68
|
-
*
|
|
69
|
-
* @param {string} path - The path to the requested resource.
|
|
70
|
-
* @param {any=} body - The request body.
|
|
71
|
-
* @return {Promise<Response>}
|
|
72
|
-
* @throws {RequestTimeoutError}
|
|
73
|
-
* @throws {TechnicalError}
|
|
74
|
-
*/
|
|
75
|
-
post(path: string, body?: any): Promise<Response>;
|
|
76
|
-
/**
|
|
77
|
-
* Performs a PUT request.
|
|
78
|
-
*
|
|
79
|
-
* @param {string} path - The path to the requested resource.
|
|
80
|
-
* @param {any=} body - The request body.
|
|
81
|
-
* @return {Promise<Response>}
|
|
82
|
-
* @throws {RequestTimeoutError}
|
|
83
|
-
* @throws {TechnicalError}
|
|
84
|
-
*/
|
|
85
|
-
put(path: string, body?: any): Promise<Response>;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* A class to be extended by the other client classes.
|
|
89
|
-
*
|
|
90
|
-
* @abstract
|
|
91
|
-
* @category SDK
|
|
92
|
-
* @subcategory Internal
|
|
93
|
-
* @param {string} api - The URL of your Hanko API instance
|
|
94
|
-
* @param {number=} timeout - The request timeout in milliseconds
|
|
95
|
-
*/
|
|
96
|
-
declare abstract class Client {
|
|
97
|
-
protected client: HttpClient;
|
|
98
|
-
constructor(api: string, timeout?: number);
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* A class for retrieving configurations from the API.
|
|
102
|
-
*
|
|
103
|
-
* @category SDK
|
|
104
|
-
* @subcategory Clients
|
|
105
|
-
* @extends {Client}
|
|
106
|
-
*/
|
|
107
|
-
declare class ConfigClient extends Client {
|
|
108
|
-
/**
|
|
109
|
-
* Retrieves the frontend configuration.
|
|
110
|
-
* @return {Promise<Config>}
|
|
111
|
-
* @throws {RequestTimeoutError}
|
|
112
|
-
* @throws {TechnicalError}
|
|
113
|
-
* @see https://teamhanko.github.io/hanko/#/.well-known/getConfig
|
|
114
|
-
*/
|
|
115
|
-
get(): Promise<Config>;
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* A class to manage user information.
|
|
119
|
-
*
|
|
120
|
-
* @category SDK
|
|
121
|
-
* @subcategory Clients
|
|
122
|
-
* @extends {Client}
|
|
123
|
-
*/
|
|
124
|
-
declare class UserClient extends Client {
|
|
125
|
-
/**
|
|
126
|
-
* Fetches basic information about the user by providing an email address. Can be used while the user is logged out
|
|
127
|
-
* and is helpful in deciding which type of login to choose. For example, if the user's email is not verified, you may
|
|
128
|
-
* want to log in with a passcode, or if no WebAuthN credentials are registered, you may not want to use WebAuthN.
|
|
129
|
-
*
|
|
130
|
-
* @param {string} email - The user's email address.
|
|
131
|
-
* @return {Promise<UserInfo>}
|
|
132
|
-
* @throws {NotFoundError}
|
|
133
|
-
* @throws {RequestTimeoutError}
|
|
134
|
-
* @throws {TechnicalError}
|
|
135
|
-
* @see https://teamhanko.github.io/hanko/#/authentication/getUserId
|
|
136
|
-
*/
|
|
137
|
-
getInfo(email: string): Promise<UserInfo>;
|
|
138
|
-
/**
|
|
139
|
-
* Creates a new user. Afterwards, the step should be to verify the email address via passcode. If a 'ConflictError'
|
|
140
|
-
* occurred, you may want to prompt the user to log in.
|
|
141
|
-
*
|
|
142
|
-
* @param {string} email - The email address of the user to be created.
|
|
143
|
-
* @return {Promise<User>}
|
|
144
|
-
* @throws {ConflictError}
|
|
145
|
-
* @throws {RequestTimeoutError}
|
|
146
|
-
* @throws {TechnicalError}
|
|
147
|
-
* @see https://teamhanko.github.io/hanko/#/management/createUser
|
|
148
|
-
*/
|
|
149
|
-
create(email: string): Promise<User>;
|
|
150
|
-
/**
|
|
151
|
-
* Fetches the current user.
|
|
152
|
-
*
|
|
153
|
-
* @return {Promise<User>}
|
|
154
|
-
* @throws {UnauthorizedError}
|
|
155
|
-
* @throws {RequestTimeoutError}
|
|
156
|
-
* @throws {TechnicalError}
|
|
157
|
-
* @see https://teamhanko.github.io/hanko/#/authentication/IsUserAuthorized
|
|
158
|
-
* @see https://teamhanko.github.io/hanko/#/management/listUser
|
|
159
|
-
*/
|
|
160
|
-
getCurrent(): Promise<User>;
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* A class that handles WebAuthN authentication and registration.
|
|
164
|
-
*
|
|
165
|
-
* @constructor
|
|
166
|
-
* @category SDK
|
|
167
|
-
* @subcategory Clients
|
|
168
|
-
* @extends {Client}
|
|
169
|
-
*/
|
|
170
|
-
declare class WebauthnClient extends Client {
|
|
171
|
-
private state;
|
|
172
|
-
constructor(api: string, timeout: number);
|
|
173
|
-
/**
|
|
174
|
-
* Performs a WebAuthN authentication ceremony. When 'userID' is specified, the API provides a list of
|
|
175
|
-
* allowed credentials and the browser is able to present a list of suitable credentials to the user.
|
|
176
|
-
*
|
|
177
|
-
* @param {string=} userID - The user's UUID.
|
|
178
|
-
* @return {Promise<void>}
|
|
179
|
-
* @throws {WebauthnRequestCancelledError}
|
|
180
|
-
* @throws {InvalidWebauthnCredentialError}
|
|
181
|
-
* @throws {RequestTimeoutError}
|
|
182
|
-
* @throws {TechnicalError}
|
|
183
|
-
* @see https://teamhanko.github.io/hanko/#/authentication/webauthnLoginInit
|
|
184
|
-
* @see https://teamhanko.github.io/hanko/#/authentication/webauthnLoginFinal
|
|
185
|
-
* @see https://www.w3.org/TR/webauthn-2/#authentication-ceremony
|
|
186
|
-
*/
|
|
187
|
-
login(userID?: string): Promise<void>;
|
|
188
|
-
/**
|
|
189
|
-
* Performs a WebAuthN registration ceremony.
|
|
190
|
-
*
|
|
191
|
-
* @return {Promise<void>}
|
|
192
|
-
* @throws {WebauthnRequestCancelledError}
|
|
193
|
-
* @throws {RequestTimeoutError}
|
|
194
|
-
* @throws {UnauthorizedError}
|
|
195
|
-
* @throws {TechnicalError}
|
|
196
|
-
* @see https://teamhanko.github.io/hanko/#/authentication/webauthnRegInit
|
|
197
|
-
* @see https://teamhanko.github.io/hanko/#/authentication/webauthnRegFinal
|
|
198
|
-
* @see https://www.w3.org/TR/webauthn-2/#sctn-registering-a-new-credential
|
|
199
|
-
*/
|
|
200
|
-
register(): Promise<void>;
|
|
201
|
-
/**
|
|
202
|
-
* Determines whether a credential registration ceremony should be performed. Returns 'true' when a platform
|
|
203
|
-
* authenticator is available and the user's credentials do not intersect with the credentials already known on the
|
|
204
|
-
* current browser/device.
|
|
205
|
-
*
|
|
206
|
-
* @param {User} user - The user object.
|
|
207
|
-
* @return {Promise<boolean>}
|
|
208
|
-
* @throws {TechnicalError}
|
|
209
|
-
*/
|
|
210
|
-
shouldRegister(user: User): Promise<boolean>;
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* A class to handle passwords.
|
|
214
|
-
*
|
|
215
|
-
* @constructor
|
|
216
|
-
* @category SDK
|
|
217
|
-
* @subcategory Clients
|
|
218
|
-
* @extends {Client}
|
|
219
|
-
*/
|
|
220
|
-
declare class PasswordClient extends Client {
|
|
221
|
-
private state;
|
|
222
|
-
constructor(api: string, timeout: number);
|
|
223
|
-
/**
|
|
224
|
-
* Logs in a user with a password.
|
|
225
|
-
*
|
|
226
|
-
* @param {string} userID - The UUID of the user.
|
|
227
|
-
* @param {string} password - The password.
|
|
228
|
-
* @return {Promise<void>}
|
|
229
|
-
* @throws {TooManyRequestsError}
|
|
230
|
-
* @throws {RequestTimeoutError}
|
|
231
|
-
* @throws {TechnicalError}
|
|
232
|
-
* @see https://teamhanko.github.io/hanko/#/authentication/passwordLogin
|
|
233
|
-
*/
|
|
234
|
-
login(userID: string, password: string): Promise<void>;
|
|
235
|
-
/**
|
|
236
|
-
* Updates a password.
|
|
237
|
-
*
|
|
238
|
-
* @param {string} userID - The UUID of the user.
|
|
239
|
-
* @param {string} password - The new password.
|
|
240
|
-
* @return {Promise<void>}
|
|
241
|
-
* @throws {RequestTimeoutError}
|
|
242
|
-
* @throws {UnauthorizedError}
|
|
243
|
-
* @throws {TechnicalError}
|
|
244
|
-
* @see https://teamhanko.github.io/hanko/#/authentication/password
|
|
245
|
-
*/
|
|
246
|
-
update(userID: string, password: string): Promise<void>;
|
|
247
|
-
/**
|
|
248
|
-
* Returns the seconds until the rate limiting is actives.
|
|
249
|
-
*
|
|
250
|
-
* @param {string} userID - The UUID of the user.
|
|
251
|
-
* @return {number}
|
|
252
|
-
*/
|
|
253
|
-
getRetryAfter(userID: string): number;
|
|
254
|
-
}
|
|
255
|
-
/**
|
|
256
|
-
* A class to handle passcodes.
|
|
257
|
-
*
|
|
258
|
-
* @constructor
|
|
259
|
-
* @category SDK
|
|
260
|
-
* @subcategory Clients
|
|
261
|
-
* @extends {Client}
|
|
262
|
-
*/
|
|
263
|
-
declare class PasscodeClient extends Client {
|
|
264
|
-
private state;
|
|
265
|
-
constructor(api: string, timeout: number);
|
|
266
|
-
/**
|
|
267
|
-
* Causes the API to send a new passcode to the user's email address.
|
|
268
|
-
*
|
|
269
|
-
* @param {string} userID - The UUID of the user.
|
|
270
|
-
* @return {Promise<Passcode>}
|
|
271
|
-
* @throws {TooManyRequestsError}
|
|
272
|
-
* @throws {RequestTimeoutError}
|
|
273
|
-
* @throws {TechnicalError}
|
|
274
|
-
* @see https://teamhanko.github.io/hanko/#/authentication/passcodeInit
|
|
275
|
-
*/
|
|
276
|
-
initialize(userID: string): Promise<Passcode>;
|
|
277
|
-
/**
|
|
278
|
-
* Validates the passcode obtained from the email.
|
|
279
|
-
*
|
|
280
|
-
* @param {string} userID - The UUID of the user.
|
|
281
|
-
* @param {string} code - The passcode digests.
|
|
282
|
-
* @return {Promise<void>}
|
|
283
|
-
* @throws {InvalidPasscodeError}
|
|
284
|
-
* @throws {MaxNumOfPasscodeAttemptsReachedError}
|
|
285
|
-
* @throws {RequestTimeoutError}
|
|
286
|
-
* @throws {TechnicalError}
|
|
287
|
-
* @see https://teamhanko.github.io/hanko/#/authentication/passcodeFinal
|
|
288
|
-
*/
|
|
289
|
-
finalize(userID: string, code: string): Promise<void>;
|
|
290
|
-
/**
|
|
291
|
-
* Returns the seconds until the current passcode is active.
|
|
292
|
-
*
|
|
293
|
-
* @param {string} userID - The UUID of the user.
|
|
294
|
-
* @return {number}
|
|
295
|
-
*/
|
|
296
|
-
getTTL(userID: string): number;
|
|
297
|
-
/**
|
|
298
|
-
* Returns the seconds until the rate limiting is active.
|
|
299
|
-
*
|
|
300
|
-
* @param {string} userID - The UUID of the user.
|
|
301
|
-
* @return {number}
|
|
302
|
-
*/
|
|
303
|
-
getResendAfter(userID: string): number;
|
|
304
|
-
}
|
|
305
|
-
export { HttpClient, ConfigClient, UserClient, WebauthnClient, PasswordClient, PasscodeClient, Headers, Response, };
|
package/dist/lib/State.d.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { LocalStorageUsers } from "./state/UserState";
|
|
2
|
-
/**
|
|
3
|
-
* @interface
|
|
4
|
-
* @category SDK
|
|
5
|
-
* @subcategory Internal
|
|
6
|
-
* @property {LocalStorageUsers=} users - The user states.
|
|
7
|
-
*/
|
|
8
|
-
interface LocalStorage {
|
|
9
|
-
users?: LocalStorageUsers;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* A class to read and write local storage contents.
|
|
13
|
-
*
|
|
14
|
-
* @abstract
|
|
15
|
-
* @param {string} key - The local storage key.
|
|
16
|
-
* @category SDK
|
|
17
|
-
* @subcategory Internal
|
|
18
|
-
*/
|
|
19
|
-
declare abstract class State {
|
|
20
|
-
private readonly key;
|
|
21
|
-
protected ls: LocalStorage;
|
|
22
|
-
constructor(key?: string);
|
|
23
|
-
/**
|
|
24
|
-
* Reads and decodes the locally stored data.
|
|
25
|
-
*
|
|
26
|
-
* @protected
|
|
27
|
-
* @return {State}
|
|
28
|
-
*/
|
|
29
|
-
protected read(): State;
|
|
30
|
-
/**
|
|
31
|
-
* Encodes and writes the data to the local storage.
|
|
32
|
-
*
|
|
33
|
-
* @return {State}
|
|
34
|
-
*/
|
|
35
|
-
write(): State;
|
|
36
|
-
/**
|
|
37
|
-
* Converts a timestamp into remaining seconds that you can count down.
|
|
38
|
-
*
|
|
39
|
-
* @static
|
|
40
|
-
* @protected
|
|
41
|
-
* @param {number} time - Timestamp in seconds (since January 1, 1970 00:00:00 UTC).
|
|
42
|
-
* @return {number}
|
|
43
|
-
*/
|
|
44
|
-
protected static timeToRemainingSeconds(time?: number): number;
|
|
45
|
-
/**
|
|
46
|
-
* Converts a number of seconds into a timestamp.
|
|
47
|
-
*
|
|
48
|
-
* @static
|
|
49
|
-
* @protected
|
|
50
|
-
* @param {number} seconds - Remaining seconds to be converted into a timestamp.
|
|
51
|
-
* @return {number}
|
|
52
|
-
*/
|
|
53
|
-
protected static remainingSecondsToTime(seconds?: number): number;
|
|
54
|
-
}
|
|
55
|
-
export { State };
|