@teamhanko/hanko-frontend-sdk 0.0.9-alpha → 0.1.0-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 +2 -0
- package/package.json +9 -9
- package/dist/Hanko.d.ts +0 -20
- package/dist/index.d.ts +0 -14
- package/dist/lib/Dto.d.ts +0 -97
- package/dist/lib/Errors.d.ts +0 -150
- package/dist/lib/WebauthnSupport.d.ts +0 -36
- package/dist/lib/client/Client.d.ts +0 -15
- package/dist/lib/client/ConfigClient.d.ts +0 -20
- package/dist/lib/client/HttpClient.d.ts +0 -92
- package/dist/lib/client/PasscodeClient.d.ts +0 -54
- package/dist/lib/client/PasswordClient.d.ts +0 -46
- package/dist/lib/client/UserClient.d.ts +0 -48
- package/dist/lib/client/WebauthnClient.d.ts +0 -60
- package/dist/lib/state/PasscodeState.d.ts +0 -91
- package/dist/lib/state/PasswordState.d.ts +0 -50
- package/dist/lib/state/State.d.ts +0 -53
- package/dist/lib/state/UserState.d.ts +0 -51
- package/dist/lib/state/WebauthnState.d.ts +0 -60
- package/dist/sdk.cjs +0 -2
- package/dist/sdk.cjs.map +0 -1
- package/dist/sdk.modern.js +0 -2
- package/dist/sdk.modern.js.map +0 -1
- package/dist/sdk.module.js +0 -2
- package/dist/sdk.module.js.map +0 -1
- package/dist/sdk.umd.js +0 -2
- package/dist/sdk.umd.js.map +0 -1
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teamhanko/hanko-frontend-sdk",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0-alpha",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -44,22 +44,22 @@
|
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@github/webauthn-json": "^2.0.1",
|
|
46
46
|
"@types/jest": "^29.2.3",
|
|
47
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
47
|
+
"@typescript-eslint/eslint-plugin": "^5.49.0",
|
|
48
48
|
"better-docs": "^2.7.2",
|
|
49
|
-
"eslint": "^8.
|
|
49
|
+
"eslint": "^8.32.0",
|
|
50
50
|
"eslint-config-google": "^0.14.0",
|
|
51
51
|
"eslint-config-preact": "^1.3.0",
|
|
52
|
-
"eslint-config-prettier": "^8.
|
|
52
|
+
"eslint-config-prettier": "^8.6.0",
|
|
53
53
|
"eslint-plugin-prettier": "^4.0.0",
|
|
54
54
|
"eslint-plugin-promise": "^6.1.1",
|
|
55
55
|
"jest": "^29.3.1",
|
|
56
|
-
"jest-environment-jsdom": "^29.
|
|
56
|
+
"jest-environment-jsdom": "^29.4.0",
|
|
57
57
|
"js-cookie": "^3.0.1",
|
|
58
|
-
"jsdoc": "^
|
|
58
|
+
"jsdoc": "^4.0.0",
|
|
59
59
|
"microbundle": "^0.15.1",
|
|
60
|
-
"ts-jest": "^29.0.
|
|
61
|
-
"ts-loader": "^9.4.
|
|
62
|
-
"typescript": "^4.9.
|
|
60
|
+
"ts-jest": "^29.0.5",
|
|
61
|
+
"ts-loader": "^9.4.2",
|
|
62
|
+
"typescript": "^4.9.4"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"@types/js-cookie": "^3.0.2"
|
package/dist/Hanko.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { ConfigClient } from "./lib/client/ConfigClient";
|
|
2
|
-
import { PasscodeClient } from "./lib/client/PasscodeClient";
|
|
3
|
-
import { PasswordClient } from "./lib/client/PasswordClient";
|
|
4
|
-
import { UserClient } from "./lib/client/UserClient";
|
|
5
|
-
import { WebauthnClient } from "./lib/client/WebauthnClient";
|
|
6
|
-
/**
|
|
7
|
-
* A class that bundles all available SDK functions.
|
|
8
|
-
*
|
|
9
|
-
* @param {string} api - The URL of your Hanko API instance
|
|
10
|
-
* @param {number=} timeout - The request timeout in milliseconds
|
|
11
|
-
*/
|
|
12
|
-
declare class Hanko {
|
|
13
|
-
config: ConfigClient;
|
|
14
|
-
user: UserClient;
|
|
15
|
-
webauthn: WebauthnClient;
|
|
16
|
-
password: PasswordClient;
|
|
17
|
-
passcode: PasscodeClient;
|
|
18
|
-
constructor(api: string, timeout?: number);
|
|
19
|
-
}
|
|
20
|
-
export { Hanko };
|
package/dist/index.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Hanko } from "./Hanko";
|
|
2
|
-
export { Hanko };
|
|
3
|
-
import { ConfigClient } from "./lib/client/ConfigClient";
|
|
4
|
-
import { PasscodeClient } from "./lib/client/PasscodeClient";
|
|
5
|
-
import { PasswordClient } from "./lib/client/PasswordClient";
|
|
6
|
-
import { UserClient } from "./lib/client/UserClient";
|
|
7
|
-
import { WebauthnClient } from "./lib/client/WebauthnClient";
|
|
8
|
-
export { ConfigClient, UserClient, WebauthnClient, PasswordClient, PasscodeClient, };
|
|
9
|
-
import { WebauthnSupport } from "./lib/WebauthnSupport";
|
|
10
|
-
export { WebauthnSupport };
|
|
11
|
-
import { PasswordConfig, Config, WebauthnFinalized, Credential, UserInfo, User, Passcode } from "./lib/Dto";
|
|
12
|
-
export type { PasswordConfig, Config, WebauthnFinalized, Credential, UserInfo, User, Passcode, };
|
|
13
|
-
import { HankoError, TechnicalError, ConflictError, RequestTimeoutError, WebauthnRequestCancelledError, InvalidPasswordError, InvalidPasscodeError, InvalidWebauthnCredentialError, PasscodeExpiredError, MaxNumOfPasscodeAttemptsReachedError, NotFoundError, TooManyRequestsError, UnauthorizedError, UserVerificationError } from "./lib/Errors";
|
|
14
|
-
export { HankoError, TechnicalError, ConflictError, RequestTimeoutError, WebauthnRequestCancelledError, InvalidPasswordError, InvalidPasscodeError, InvalidWebauthnCredentialError, PasscodeExpiredError, MaxNumOfPasscodeAttemptsReachedError, NotFoundError, TooManyRequestsError, UnauthorizedError, UserVerificationError, };
|
package/dist/lib/Dto.d.ts
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
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
|
-
*/
|
|
8
|
-
interface PasswordConfig {
|
|
9
|
-
enabled: boolean;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* @interface
|
|
13
|
-
* @category SDK
|
|
14
|
-
* @subcategory DTO
|
|
15
|
-
* @property {PasswordConfig} password - The password configuration.
|
|
16
|
-
*/
|
|
17
|
-
interface Config {
|
|
18
|
-
password: PasswordConfig;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* @interface
|
|
22
|
-
* @category SDK
|
|
23
|
-
* @subcategory DTO
|
|
24
|
-
* @property {string} credential_id - The ID of the credential that was used.
|
|
25
|
-
* @property {string} user_id - The ID of the user that was used.
|
|
26
|
-
*/
|
|
27
|
-
interface WebauthnFinalized {
|
|
28
|
-
credential_id: string;
|
|
29
|
-
user_id: string;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* @interface
|
|
33
|
-
* @category SDK
|
|
34
|
-
* @subcategory DTO
|
|
35
|
-
* @property {string} id - The UUID of the user.
|
|
36
|
-
* @property {boolean} verified - Indicates whether the user's email address is verified.
|
|
37
|
-
* @property {boolean} has_webauthn_credential - Indicates that the user has registered a WebAuthn credential in the past.
|
|
38
|
-
*/
|
|
39
|
-
interface UserInfo {
|
|
40
|
-
id: string;
|
|
41
|
-
verified: boolean;
|
|
42
|
-
has_webauthn_credential: boolean;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* @interface
|
|
46
|
-
* @category SDK
|
|
47
|
-
* @subcategory DTO
|
|
48
|
-
* @property {string} id - The UUID of the current user.
|
|
49
|
-
* @ignore
|
|
50
|
-
*/
|
|
51
|
-
interface Me {
|
|
52
|
-
id: string;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* @interface
|
|
56
|
-
* @category SDK
|
|
57
|
-
* @subcategory DTO
|
|
58
|
-
* @property {string} id - The WebAuthn credential ID.
|
|
59
|
-
*/
|
|
60
|
-
interface Credential {
|
|
61
|
-
id: string;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* @interface
|
|
65
|
-
* @category SDK
|
|
66
|
-
* @subcategory DTO
|
|
67
|
-
* @property {string} id - The user's UUID.
|
|
68
|
-
* @property {string} email - The user's email.
|
|
69
|
-
* @property {Credential[]} webauthn_credentials - A list of credentials that have been registered.
|
|
70
|
-
*/
|
|
71
|
-
interface User {
|
|
72
|
-
id: string;
|
|
73
|
-
email: string;
|
|
74
|
-
webauthn_credentials: Credential[];
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* @interface
|
|
78
|
-
* @category SDK
|
|
79
|
-
* @subcategory DTO
|
|
80
|
-
* @property {string} id - The UUID of the passcode.
|
|
81
|
-
* @property {number} ttl - How long the code is active in seconds.
|
|
82
|
-
*/
|
|
83
|
-
interface Passcode {
|
|
84
|
-
id: string;
|
|
85
|
-
ttl: number;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* @interface
|
|
89
|
-
* @category SDK
|
|
90
|
-
* @subcategory DTO
|
|
91
|
-
* @property {string[]} transports - A list of WebAuthn AuthenticatorTransport, e.g.: "usb", "internal",...
|
|
92
|
-
* @ignore
|
|
93
|
-
*/
|
|
94
|
-
interface Attestation extends PublicKeyCredentialWithAttestationJSON {
|
|
95
|
-
transports: string[];
|
|
96
|
-
}
|
|
97
|
-
export type { PasswordConfig, Config, WebauthnFinalized, Credential, UserInfo, Me, User, Passcode, Attestation, };
|
package/dist/lib/Errors.d.ts
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Every error thrown in the SDK is an instance of 'HankoError'. The value of the 'code' property is eligible to
|
|
3
|
-
* translate the error into an error message.
|
|
4
|
-
*
|
|
5
|
-
* @extends {Error}
|
|
6
|
-
* @category SDK
|
|
7
|
-
* @subcategory Errors
|
|
8
|
-
* @param code {string} - An error code that refers to the error instance.
|
|
9
|
-
* @param cause {Error=} - The original error
|
|
10
|
-
*/
|
|
11
|
-
declare abstract class HankoError extends Error {
|
|
12
|
-
code: string;
|
|
13
|
-
cause?: Error;
|
|
14
|
-
protected constructor(message: string, code: string, cause?: Error);
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Every error that doesn't need to be handled in a special way is a 'TechnicalError'. Whenever you catch one, there is
|
|
18
|
-
* usually nothing you can do but present an error to the user, e.g. "Something went wrong".
|
|
19
|
-
*
|
|
20
|
-
* @category SDK
|
|
21
|
-
* @subcategory Errors
|
|
22
|
-
* @extends {HankoError}
|
|
23
|
-
*/
|
|
24
|
-
declare class TechnicalError extends HankoError {
|
|
25
|
-
constructor(cause?: Error);
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Attempting to create a resource that already exists results in a 'ConflictError'.
|
|
29
|
-
*
|
|
30
|
-
* @category SDK
|
|
31
|
-
* @subcategory Errors
|
|
32
|
-
* @extends {HankoError}
|
|
33
|
-
*/
|
|
34
|
-
declare class ConflictError extends HankoError {
|
|
35
|
-
constructor(userID?: string, cause?: Error);
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* A 'RequestTimeoutError' occurs when the specified timeout has been reached.
|
|
39
|
-
*
|
|
40
|
-
* @category SDK
|
|
41
|
-
* @subcategory Errors
|
|
42
|
-
* @extends {HankoError}
|
|
43
|
-
*/
|
|
44
|
-
declare class RequestTimeoutError extends HankoError {
|
|
45
|
-
constructor(cause?: Error);
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* A 'WebauthnRequestCancelledError' occurs during WebAuthn authentication or registration, when the WebAuthn API throws
|
|
49
|
-
* an error. In most cases, this happens when the user cancels the browser's WebAuthn dialog.
|
|
50
|
-
*
|
|
51
|
-
* @category SDK
|
|
52
|
-
* @subcategory Errors
|
|
53
|
-
* @extends {HankoError}
|
|
54
|
-
*/
|
|
55
|
-
declare class WebauthnRequestCancelledError extends HankoError {
|
|
56
|
-
constructor(cause?: Error);
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* An 'InvalidPasswordError' occurs when invalid credentials are provided when logging in with a password.
|
|
60
|
-
*
|
|
61
|
-
* @category SDK
|
|
62
|
-
* @subcategory Errors
|
|
63
|
-
* @extends {HankoError}
|
|
64
|
-
*/
|
|
65
|
-
declare class InvalidPasswordError extends HankoError {
|
|
66
|
-
constructor(cause?: Error);
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* An 'InvalidPasswordError' occurs when an incorrect code is entered when logging in with a passcode.
|
|
70
|
-
*
|
|
71
|
-
* @category SDK
|
|
72
|
-
* @subcategory Errors
|
|
73
|
-
* @extends {HankoError}
|
|
74
|
-
*/
|
|
75
|
-
declare class InvalidPasscodeError extends HankoError {
|
|
76
|
-
constructor(cause?: Error);
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* An 'InvalidWebauthnCredentialError' occurs if invalid credentials were used when logging in with WebAuthn.
|
|
80
|
-
*
|
|
81
|
-
* @category SDK
|
|
82
|
-
* @subcategory Errors
|
|
83
|
-
* @extends {HankoError}
|
|
84
|
-
*/
|
|
85
|
-
declare class InvalidWebauthnCredentialError extends HankoError {
|
|
86
|
-
constructor(cause?: Error);
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* A 'PasscodeExpiredError' occurs when the passcode has expired.
|
|
90
|
-
*
|
|
91
|
-
* @category SDK
|
|
92
|
-
* @subcategory Errors
|
|
93
|
-
* @extends {HankoError}
|
|
94
|
-
*/
|
|
95
|
-
declare class PasscodeExpiredError extends HankoError {
|
|
96
|
-
constructor(cause?: Error);
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* A 'MaxNumOfPasscodeAttemptsReachedError' occurs when an incorrect passcode is provided too many times.
|
|
100
|
-
*
|
|
101
|
-
* @category SDK
|
|
102
|
-
* @subcategory Errors
|
|
103
|
-
* @extends {HankoError}
|
|
104
|
-
*/
|
|
105
|
-
declare class MaxNumOfPasscodeAttemptsReachedError extends HankoError {
|
|
106
|
-
constructor(cause?: Error);
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* A 'NotFoundError' occurs when the requested resource was not found.
|
|
110
|
-
*
|
|
111
|
-
* @category SDK
|
|
112
|
-
* @subcategory Errors
|
|
113
|
-
* @extends {HankoError}
|
|
114
|
-
*/
|
|
115
|
-
declare class NotFoundError extends HankoError {
|
|
116
|
-
constructor(cause?: Error);
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* A 'TooManyRequestsError' occurs due to rate limiting when too many requests are made.
|
|
120
|
-
*
|
|
121
|
-
* @category SDK
|
|
122
|
-
* @subcategory Errors
|
|
123
|
-
* @extends {HankoError}
|
|
124
|
-
*/
|
|
125
|
-
declare class TooManyRequestsError extends HankoError {
|
|
126
|
-
retryAfter?: number;
|
|
127
|
-
constructor(retryAfter?: number, cause?: Error);
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* An 'UnauthorizedError' occurs when the user is not authorized to access the resource.
|
|
131
|
-
*
|
|
132
|
-
* @category SDK
|
|
133
|
-
* @subcategory Errors
|
|
134
|
-
* @extends {HankoError}
|
|
135
|
-
*/
|
|
136
|
-
declare class UnauthorizedError extends HankoError {
|
|
137
|
-
constructor(cause?: Error);
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* A 'UserVerificationError' occurs when the user verification requirements
|
|
141
|
-
* for a WebAuthn ceremony are not met.
|
|
142
|
-
*
|
|
143
|
-
* @category SDK
|
|
144
|
-
* @subcategory Errors
|
|
145
|
-
* @extends {HankoError}
|
|
146
|
-
*/
|
|
147
|
-
declare class UserVerificationError extends HankoError {
|
|
148
|
-
constructor(cause?: Error);
|
|
149
|
-
}
|
|
150
|
-
export { HankoError, TechnicalError, ConflictError, RequestTimeoutError, WebauthnRequestCancelledError, InvalidPasswordError, InvalidPasscodeError, InvalidWebauthnCredentialError, PasscodeExpiredError, MaxNumOfPasscodeAttemptsReachedError, NotFoundError, TooManyRequestsError, UnauthorizedError, UserVerificationError };
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A class to check the browser's WebAuthn support.
|
|
3
|
-
*
|
|
4
|
-
* @hideconstructor
|
|
5
|
-
* @category SDK
|
|
6
|
-
* @subcategory Utilities
|
|
7
|
-
*/
|
|
8
|
-
declare class WebauthnSupport {
|
|
9
|
-
/**
|
|
10
|
-
* Does a simple check to test for the credential management API functions we need, and an indication of
|
|
11
|
-
* public key credential authentication support.
|
|
12
|
-
*
|
|
13
|
-
* @see https://developers.google.com/web/updates/2018/03/webauthn-credential-management
|
|
14
|
-
* @return boolean
|
|
15
|
-
*/
|
|
16
|
-
static supported(): boolean;
|
|
17
|
-
/**
|
|
18
|
-
* Checks whether a user-verifying platform authenticator is available.
|
|
19
|
-
*
|
|
20
|
-
* @return Promise<boolean>
|
|
21
|
-
*/
|
|
22
|
-
static isPlatformAuthenticatorAvailable(): Promise<boolean>;
|
|
23
|
-
/**
|
|
24
|
-
* Checks whether external CTAP2 security keys are supported.
|
|
25
|
-
*
|
|
26
|
-
* @return Promise<boolean>
|
|
27
|
-
*/
|
|
28
|
-
static isSecurityKeySupported(): Promise<boolean>;
|
|
29
|
-
/**
|
|
30
|
-
* Checks whether autofill assisted requests are supported.
|
|
31
|
-
*
|
|
32
|
-
* @return Promise<boolean>
|
|
33
|
-
*/
|
|
34
|
-
static isConditionalMediationAvailable(): Promise<boolean>;
|
|
35
|
-
}
|
|
36
|
-
export { WebauthnSupport };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { HttpClient } from "./HttpClient";
|
|
2
|
-
/**
|
|
3
|
-
* A class to be extended by the other client classes.
|
|
4
|
-
*
|
|
5
|
-
* @abstract
|
|
6
|
-
* @category SDK
|
|
7
|
-
* @subcategory Internal
|
|
8
|
-
* @param {string} api - The URL of your Hanko API instance
|
|
9
|
-
* @param {number=} timeout - The request timeout in milliseconds
|
|
10
|
-
*/
|
|
11
|
-
declare abstract class Client {
|
|
12
|
-
client: HttpClient;
|
|
13
|
-
constructor(api: string, timeout?: number);
|
|
14
|
-
}
|
|
15
|
-
export { Client };
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Config } from "../Dto";
|
|
2
|
-
import { Client } from "./Client";
|
|
3
|
-
/**
|
|
4
|
-
* A class for retrieving configurations from the API.
|
|
5
|
-
*
|
|
6
|
-
* @category SDK
|
|
7
|
-
* @subcategory Clients
|
|
8
|
-
* @extends {Client}
|
|
9
|
-
*/
|
|
10
|
-
declare class ConfigClient extends Client {
|
|
11
|
-
/**
|
|
12
|
-
* Retrieves the frontend configuration.
|
|
13
|
-
* @return {Promise<Config>}
|
|
14
|
-
* @throws {RequestTimeoutError}
|
|
15
|
-
* @throws {TechnicalError}
|
|
16
|
-
* @see https://docs.hanko.io/api/public#tag/.well-known/operation/getConfig
|
|
17
|
-
*/
|
|
18
|
-
get(): Promise<Config>;
|
|
19
|
-
}
|
|
20
|
-
export { ConfigClient };
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This class wraps an XMLHttpRequest to maintain compatibility with the fetch API.
|
|
3
|
-
*
|
|
4
|
-
* @category SDK
|
|
5
|
-
* @subcategory Internal
|
|
6
|
-
* @param {XMLHttpRequest} xhr - The request to be wrapped.
|
|
7
|
-
* @see HttpClient
|
|
8
|
-
*/
|
|
9
|
-
declare class Headers {
|
|
10
|
-
_xhr: XMLHttpRequest;
|
|
11
|
-
constructor(xhr: XMLHttpRequest);
|
|
12
|
-
/**
|
|
13
|
-
* Returns the response header with the given name.
|
|
14
|
-
*
|
|
15
|
-
* @param {string} name
|
|
16
|
-
* @return {string}
|
|
17
|
-
*/
|
|
18
|
-
get(name: string): string;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* This class wraps an XMLHttpRequest to maintain compatibility with the fetch API.
|
|
22
|
-
*
|
|
23
|
-
* @category SDK
|
|
24
|
-
* @subcategory Internal
|
|
25
|
-
* @param {XMLHttpRequest} xhr - The request to be wrapped.
|
|
26
|
-
* @see HttpClient
|
|
27
|
-
*/
|
|
28
|
-
declare class Response {
|
|
29
|
-
headers: Headers;
|
|
30
|
-
ok: boolean;
|
|
31
|
-
status: number;
|
|
32
|
-
statusText: string;
|
|
33
|
-
url: string;
|
|
34
|
-
_decodedJSON: any;
|
|
35
|
-
constructor(xhr: XMLHttpRequest);
|
|
36
|
-
/**
|
|
37
|
-
* Returns the JSON decoded response.
|
|
38
|
-
*
|
|
39
|
-
* @return {any}
|
|
40
|
-
*/
|
|
41
|
-
json(): any;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Internally used for communication with the Hanko API. It also handles authorization tokens to enable authorized
|
|
45
|
-
* requests.
|
|
46
|
-
*
|
|
47
|
-
* Currently, there is an issue with Safari and on iOS 15 devices where decoding a JSON response via the fetch API
|
|
48
|
-
* breaks the user gesture and the user is not able to use the authenticator. Therefore, this class uses XMLHttpRequests
|
|
49
|
-
* instead of the fetch API, but maintains compatibility by wrapping the XMLHttpRequests. So, if the issues are fixed,
|
|
50
|
-
* we can easily return to the fetch API.
|
|
51
|
-
*
|
|
52
|
-
* @category SDK
|
|
53
|
-
* @subcategory Internal
|
|
54
|
-
* @param {string} api - The URL of your Hanko API instance
|
|
55
|
-
* @param {number=} timeout - The request timeout in milliseconds
|
|
56
|
-
*/
|
|
57
|
-
declare class HttpClient {
|
|
58
|
-
timeout: number;
|
|
59
|
-
api: string;
|
|
60
|
-
constructor(api: string, timeout?: number);
|
|
61
|
-
_fetch(path: string, options: RequestInit, xhr?: XMLHttpRequest): Promise<Response>;
|
|
62
|
-
/**
|
|
63
|
-
* Performs a GET request.
|
|
64
|
-
*
|
|
65
|
-
* @param {string} path - The path to the requested resource.
|
|
66
|
-
* @return {Promise<Response>}
|
|
67
|
-
* @throws {RequestTimeoutError}
|
|
68
|
-
* @throws {TechnicalError}
|
|
69
|
-
*/
|
|
70
|
-
get(path: string): Promise<Response>;
|
|
71
|
-
/**
|
|
72
|
-
* Performs a POST request.
|
|
73
|
-
*
|
|
74
|
-
* @param {string} path - The path to the requested resource.
|
|
75
|
-
* @param {any=} body - The request body.
|
|
76
|
-
* @return {Promise<Response>}
|
|
77
|
-
* @throws {RequestTimeoutError}
|
|
78
|
-
* @throws {TechnicalError}
|
|
79
|
-
*/
|
|
80
|
-
post(path: string, body?: any): Promise<Response>;
|
|
81
|
-
/**
|
|
82
|
-
* Performs a PUT request.
|
|
83
|
-
*
|
|
84
|
-
* @param {string} path - The path to the requested resource.
|
|
85
|
-
* @param {any=} body - The request body.
|
|
86
|
-
* @return {Promise<Response>}
|
|
87
|
-
* @throws {RequestTimeoutError}
|
|
88
|
-
* @throws {TechnicalError}
|
|
89
|
-
*/
|
|
90
|
-
put(path: string, body?: any): Promise<Response>;
|
|
91
|
-
}
|
|
92
|
-
export { Headers, Response, HttpClient };
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { PasscodeState } from "../state/PasscodeState";
|
|
2
|
-
import { Passcode } from "../Dto";
|
|
3
|
-
import { Client } from "./Client";
|
|
4
|
-
/**
|
|
5
|
-
* A class to handle passcodes.
|
|
6
|
-
*
|
|
7
|
-
* @constructor
|
|
8
|
-
* @category SDK
|
|
9
|
-
* @subcategory Clients
|
|
10
|
-
* @extends {Client}
|
|
11
|
-
*/
|
|
12
|
-
declare class PasscodeClient extends Client {
|
|
13
|
-
state: PasscodeState;
|
|
14
|
-
constructor(api: string, timeout?: number);
|
|
15
|
-
/**
|
|
16
|
-
* Causes the API to send a new passcode to the user's email address.
|
|
17
|
-
*
|
|
18
|
-
* @param {string} userID - The UUID of the user.
|
|
19
|
-
* @return {Promise<Passcode>}
|
|
20
|
-
* @throws {TooManyRequestsError}
|
|
21
|
-
* @throws {RequestTimeoutError}
|
|
22
|
-
* @throws {TechnicalError}
|
|
23
|
-
* @see https://docs.hanko.io/api/public#tag/Passcode/operation/passcodeInit
|
|
24
|
-
*/
|
|
25
|
-
initialize(userID: string): Promise<Passcode>;
|
|
26
|
-
/**
|
|
27
|
-
* Validates the passcode obtained from the email.
|
|
28
|
-
*
|
|
29
|
-
* @param {string} userID - The UUID of the user.
|
|
30
|
-
* @param {string} code - The passcode digests.
|
|
31
|
-
* @return {Promise<void>}
|
|
32
|
-
* @throws {InvalidPasscodeError}
|
|
33
|
-
* @throws {MaxNumOfPasscodeAttemptsReachedError}
|
|
34
|
-
* @throws {RequestTimeoutError}
|
|
35
|
-
* @throws {TechnicalError}
|
|
36
|
-
* @see https://docs.hanko.io/api/public#tag/Passcode/operation/passcodeFinal
|
|
37
|
-
*/
|
|
38
|
-
finalize(userID: string, code: string): Promise<void>;
|
|
39
|
-
/**
|
|
40
|
-
* Returns the number of seconds the current passcode is active for.
|
|
41
|
-
*
|
|
42
|
-
* @param {string} userID - The UUID of the user.
|
|
43
|
-
* @return {number}
|
|
44
|
-
*/
|
|
45
|
-
getTTL(userID: string): number;
|
|
46
|
-
/**
|
|
47
|
-
* Returns the number of seconds the rate limiting is active for.
|
|
48
|
-
*
|
|
49
|
-
* @param {string} userID - The UUID of the user.
|
|
50
|
-
* @return {number}
|
|
51
|
-
*/
|
|
52
|
-
getResendAfter(userID: string): number;
|
|
53
|
-
}
|
|
54
|
-
export { PasscodeClient };
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { PasswordState } from "../state/PasswordState";
|
|
2
|
-
import { Client } from "./Client";
|
|
3
|
-
/**
|
|
4
|
-
* A class to handle passwords.
|
|
5
|
-
*
|
|
6
|
-
* @constructor
|
|
7
|
-
* @category SDK
|
|
8
|
-
* @subcategory Clients
|
|
9
|
-
* @extends {Client}
|
|
10
|
-
*/
|
|
11
|
-
declare class PasswordClient extends Client {
|
|
12
|
-
state: PasswordState;
|
|
13
|
-
constructor(api: string, timeout?: number);
|
|
14
|
-
/**
|
|
15
|
-
* Logs in a user with a password.
|
|
16
|
-
*
|
|
17
|
-
* @param {string} userID - The UUID of the user.
|
|
18
|
-
* @param {string} password - The password.
|
|
19
|
-
* @return {Promise<void>}
|
|
20
|
-
* @throws {TooManyRequestsError}
|
|
21
|
-
* @throws {RequestTimeoutError}
|
|
22
|
-
* @throws {TechnicalError}
|
|
23
|
-
* @see https://docs.hanko.io/api/public#tag/Password/operation/passwordLogin
|
|
24
|
-
*/
|
|
25
|
-
login(userID: string, password: string): Promise<void>;
|
|
26
|
-
/**
|
|
27
|
-
* Updates a password.
|
|
28
|
-
*
|
|
29
|
-
* @param {string} userID - The UUID of the user.
|
|
30
|
-
* @param {string} password - The new password.
|
|
31
|
-
* @return {Promise<void>}
|
|
32
|
-
* @throws {RequestTimeoutError}
|
|
33
|
-
* @throws {UnauthorizedError}
|
|
34
|
-
* @throws {TechnicalError}
|
|
35
|
-
* @see https://docs.hanko.io/api/public#tag/Password/operation/password
|
|
36
|
-
*/
|
|
37
|
-
update(userID: string, password: string): Promise<void>;
|
|
38
|
-
/**
|
|
39
|
-
* Returns the number of seconds the rate limiting is active for.
|
|
40
|
-
*
|
|
41
|
-
* @param {string} userID - The UUID of the user.
|
|
42
|
-
* @return {number}
|
|
43
|
-
*/
|
|
44
|
-
getRetryAfter(userID: string): number;
|
|
45
|
-
}
|
|
46
|
-
export { PasswordClient };
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { User, UserInfo } from "../Dto";
|
|
2
|
-
import { Client } from "./Client";
|
|
3
|
-
/**
|
|
4
|
-
* A class to manage user information.
|
|
5
|
-
*
|
|
6
|
-
* @category SDK
|
|
7
|
-
* @subcategory Clients
|
|
8
|
-
* @extends {Client}
|
|
9
|
-
*/
|
|
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<User>}
|
|
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<User>;
|
|
36
|
-
/**
|
|
37
|
-
* Fetches the current user.
|
|
38
|
-
*
|
|
39
|
-
* @return {Promise<User>}
|
|
40
|
-
* @throws {UnauthorizedError}
|
|
41
|
-
* @throws {RequestTimeoutError}
|
|
42
|
-
* @throws {TechnicalError}
|
|
43
|
-
* @see https://docs.hanko.io/api/public#tag/User-Management/operation/IsUserAuthorized
|
|
44
|
-
* @see https://docs.hanko.io/api/public#tag/User-Management/operation/listUser
|
|
45
|
-
*/
|
|
46
|
-
getCurrent(): Promise<User>;
|
|
47
|
-
}
|
|
48
|
-
export { UserClient };
|