@teamhanko/hanko-frontend-sdk 0.1.0-alpha → 0.1.1-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.
@@ -0,0 +1,22 @@
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
+ import { EmailClient } from "./lib/client/EmailClient";
7
+ /**
8
+ * A class that bundles all available SDK functions.
9
+ *
10
+ * @param {string} api - The URL of your Hanko API instance
11
+ * @param {number=} timeout - The request timeout in milliseconds
12
+ */
13
+ declare class Hanko {
14
+ config: ConfigClient;
15
+ user: UserClient;
16
+ webauthn: WebauthnClient;
17
+ password: PasswordClient;
18
+ passcode: PasscodeClient;
19
+ email: EmailClient;
20
+ constructor(api: string, timeout?: number);
21
+ }
22
+ export { Hanko };
@@ -0,0 +1,15 @@
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
+ import { EmailClient } from "./lib/client/EmailClient";
9
+ export { ConfigClient, UserClient, WebauthnClient, PasswordClient, PasscodeClient, EmailClient, };
10
+ import { WebauthnSupport } from "./lib/WebauthnSupport";
11
+ export { WebauthnSupport };
12
+ import { PasswordConfig, Config, WebauthnFinalized, Credential, UserInfo, User, Email, Emails, WebauthnCredential, WebauthnCredentials, Passcode } from "./lib/Dto";
13
+ export type { PasswordConfig, Config, WebauthnFinalized, Credential, UserInfo, User, Email, Emails, WebauthnCredential, WebauthnCredentials, Passcode, };
14
+ import { HankoError, ConflictError, EmailAddressAlreadyExistsError, InvalidPasswordError, InvalidPasscodeError, InvalidWebauthnCredentialError, MaxNumOfEmailAddressesReachedError, MaxNumOfPasscodeAttemptsReachedError, NotFoundError, PasscodeExpiredError, RequestTimeoutError, TechnicalError, TooManyRequestsError, UnauthorizedError, UserVerificationError, WebauthnRequestCancelledError } from "./lib/Errors";
15
+ export { HankoError, ConflictError, EmailAddressAlreadyExistsError, InvalidPasswordError, InvalidPasscodeError, InvalidWebauthnCredentialError, MaxNumOfEmailAddressesReachedError, MaxNumOfPasscodeAttemptsReachedError, NotFoundError, PasscodeExpiredError, RequestTimeoutError, TechnicalError, TooManyRequestsError, UnauthorizedError, UserVerificationError, WebauthnRequestCancelledError, };
@@ -0,0 +1,173 @@
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
+ 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
+ interface EmailConfig {
21
+ require_verification: boolean;
22
+ max_num_of_addresses: number;
23
+ }
24
+ /**
25
+ * @interface
26
+ * @category SDK
27
+ * @subcategory DTO
28
+ * @property {PasswordConfig} password - The password configuration.
29
+ */
30
+ interface Config {
31
+ password: PasswordConfig;
32
+ emails: EmailConfig;
33
+ }
34
+ /**
35
+ * @interface
36
+ * @category SDK
37
+ * @subcategory DTO
38
+ * @property {string} credential_id - The ID of the credential that was used.
39
+ * @property {string} user_id - The ID of the user that was used.
40
+ */
41
+ interface WebauthnFinalized {
42
+ credential_id: string;
43
+ user_id: string;
44
+ }
45
+ /**
46
+ * @interface
47
+ * @category SDK
48
+ * @subcategory DTO
49
+ * @property {string} id - The UUID of the user.
50
+ * @property {boolean} verified - Indicates whether the user's email address is verified.
51
+ * @property {string} email_id - The UUID of the email address.
52
+ * @property {boolean} has_webauthn_credential - Indicates that the user has registered a WebAuthn credential in the past.
53
+ */
54
+ interface UserInfo {
55
+ id: string;
56
+ verified: boolean;
57
+ email_id: string;
58
+ has_webauthn_credential: boolean;
59
+ }
60
+ /**
61
+ * @interface
62
+ * @category SDK
63
+ * @subcategory DTO
64
+ * @property {string} id - The UUID of the current user.
65
+ * @ignore
66
+ */
67
+ interface Me {
68
+ id: string;
69
+ }
70
+ /**
71
+ * @interface
72
+ * @category SDK
73
+ * @subcategory DTO
74
+ * @property {string} id - The WebAuthn credential ID.
75
+ */
76
+ interface Credential {
77
+ id: string;
78
+ }
79
+ /**
80
+ * @interface
81
+ * @category SDK
82
+ * @subcategory DTO
83
+ * @property {string} id - The user's UUID.
84
+ * @property {string} email - The user's email.
85
+ * @property {Credential[]} webauthn_credentials - A list of credentials that have been registered.
86
+ */
87
+ interface User {
88
+ id: string;
89
+ email_id: string;
90
+ webauthn_credentials: Credential[];
91
+ }
92
+ /**
93
+ * @interface
94
+ * @category SDK
95
+ * @subcategory DTO
96
+ * @property {string} id - The UUID of the passcode.
97
+ * @property {number} ttl - How long the code is active in seconds.
98
+ */
99
+ interface Passcode {
100
+ id: string;
101
+ ttl: number;
102
+ }
103
+ /**
104
+ * @interface
105
+ * @category SDK
106
+ * @subcategory DTO
107
+ * @property {string[]} - Transports which may be used by the authenticator. E.g. "internal", "ble",...
108
+ */
109
+ interface WebauthnTransports extends Array<string> {
110
+ }
111
+ /**
112
+ * @interface
113
+ * @category SDK
114
+ * @subcategory DTO
115
+ * @property {WebauthnTransports} transports
116
+ * @ignore
117
+ */
118
+ interface Attestation extends PublicKeyCredentialWithAttestationJSON {
119
+ transports: WebauthnTransports;
120
+ }
121
+ /**
122
+ * @interface
123
+ * @category SDK
124
+ * @subcategory DTO
125
+ * @property {string} id - The UUID of the email address.
126
+ * @property {string} address - The email address.
127
+ * @property {boolean} is_verified - Indicates whether the email address is verified.
128
+ * @property {boolean} is_primary - Indicates it's the primary email address.
129
+ */
130
+ interface Email {
131
+ id: string;
132
+ address: string;
133
+ is_verified: boolean;
134
+ is_primary: boolean;
135
+ }
136
+ /**
137
+ * @interface
138
+ * @category SDK
139
+ * @subcategory DTO
140
+ * @property {Email[]} - A list of emails assigned to the current user.
141
+ */
142
+ interface Emails extends Array<Email> {
143
+ }
144
+ /**
145
+ * @interface
146
+ * @category SDK
147
+ * @subcategory DTO
148
+ * @property {string} id - The credential id.
149
+ * @property {string=} name - The credential name.
150
+ * @property {string} public_key - The public key.
151
+ * @property {string} attestation_type - The attestation type.
152
+ * @property {string} aaguid - The AAGUID of the authenticator.
153
+ * @property {string} created_at - Time of credential creation.
154
+ * @property {WebauthnTransports} transports
155
+ */
156
+ interface WebauthnCredential {
157
+ id: string;
158
+ name?: string;
159
+ public_key: string;
160
+ attestation_type: string;
161
+ aaguid: string;
162
+ created_at: string;
163
+ transports: WebauthnTransports;
164
+ }
165
+ /**
166
+ * @interface
167
+ * @category SDK
168
+ * @subcategory DTO
169
+ * @property {WebauthnCredential[]} - A list of WebAuthn credential assigned to the current user.
170
+ */
171
+ interface WebauthnCredentials extends Array<WebauthnCredential> {
172
+ }
173
+ export type { PasswordConfig, Config, WebauthnFinalized, Credential, UserInfo, Me, User, Email, Emails, Passcode, Attestation, WebauthnCredential, WebauthnCredentials, };
@@ -0,0 +1,171 @@
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
+ /**
151
+ * A 'MaxNumOfEmailAddressesReachedError' occurs when the user tries to add a new email address while the maximum number
152
+ * of email addresses (see backend configuration) equals the number of email addresses already registered.
153
+ *
154
+ * @category SDK
155
+ * @subcategory Errors
156
+ * @extends {HankoError}
157
+ */
158
+ declare class MaxNumOfEmailAddressesReachedError extends HankoError {
159
+ constructor(cause?: Error);
160
+ }
161
+ /**
162
+ * An 'EmailAddressAlreadyExistsError' occurs when the user tries to add a new email address which already exists.
163
+ *
164
+ * @category SDK
165
+ * @subcategory Errors
166
+ * @extends {HankoError}
167
+ */
168
+ declare class EmailAddressAlreadyExistsError extends HankoError {
169
+ constructor(cause?: Error);
170
+ }
171
+ export { HankoError, TechnicalError, ConflictError, RequestTimeoutError, WebauthnRequestCancelledError, InvalidPasswordError, InvalidPasscodeError, InvalidWebauthnCredentialError, PasscodeExpiredError, MaxNumOfPasscodeAttemptsReachedError, NotFoundError, TooManyRequestsError, UnauthorizedError, UserVerificationError, MaxNumOfEmailAddressesReachedError, EmailAddressAlreadyExistsError, };
@@ -0,0 +1,36 @@
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 };
@@ -0,0 +1,15 @@
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 };
@@ -0,0 +1,20 @@
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 };
@@ -0,0 +1,58 @@
1
+ import { Client } from "./Client";
2
+ import { Email, Emails } from "../Dto";
3
+ /**
4
+ * Manages email addresses of the current user.
5
+ *
6
+ * @constructor
7
+ * @category SDK
8
+ * @subcategory Clients
9
+ * @extends {Client}
10
+ */
11
+ declare class EmailClient extends Client {
12
+ /**
13
+ * Returns a list of all email addresses assigned to the current user.
14
+ *
15
+ * @return {Promise<Emails>}
16
+ * @throws {UnauthorizedError}
17
+ * @throws {RequestTimeoutError}
18
+ * @throws {TechnicalError}
19
+ * @see https://docs.hanko.io/api/public#tag/Email-Management/operation/listEmails
20
+ */
21
+ list(): Promise<Emails>;
22
+ /**
23
+ * Adds a new email address to the current user.
24
+ *
25
+ * @param {string} address - The email address to be added.
26
+ * @return {Promise<Email>}
27
+ * @throws {EmailAddressAlreadyExistsError}
28
+ * @throws {MaxNumOfEmailAddressesReachedError}
29
+ * @throws {UnauthorizedError}
30
+ * @throws {RequestTimeoutError}
31
+ * @throws {TechnicalError}
32
+ * @see https://docs.hanko.io/api/public#tag/Email-Management/operation/createEmail
33
+ */
34
+ create(address: string): Promise<Email>;
35
+ /**
36
+ * Marks the specified email address as primary.
37
+ *
38
+ * @param {string} emailID - The ID of the email address to be updated
39
+ * @return {Promise<void>}
40
+ * @throws {UnauthorizedError}
41
+ * @throws {RequestTimeoutError}
42
+ * @throws {TechnicalError}
43
+ * @see https://docs.hanko.io/api/public#tag/Email-Management/operation/setPrimaryEmail
44
+ */
45
+ setPrimaryEmail(emailID: string): Promise<void>;
46
+ /**
47
+ * Deletes the specified email address.
48
+ *
49
+ * @param {string} emailID - The ID of the email address to be deleted
50
+ * @return {Promise<void>}
51
+ * @throws {UnauthorizedError}
52
+ * @throws {RequestTimeoutError}
53
+ * @throws {TechnicalError}
54
+ * @see https://docs.hanko.io/api/public#tag/Email-Management/operation/deleteEmail
55
+ */
56
+ delete(emailID: string): Promise<void>;
57
+ }
58
+ export { EmailClient };
@@ -0,0 +1,118 @@
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
+ private xhr;
36
+ constructor(xhr: XMLHttpRequest);
37
+ /**
38
+ * Returns the JSON decoded response.
39
+ *
40
+ * @return {any}
41
+ */
42
+ json(): any;
43
+ /**
44
+ * Returns the value for Retry-After contained in the response header.
45
+ *
46
+ * @return {number}
47
+ */
48
+ parseRetryAfterHeader(): number;
49
+ }
50
+ /**
51
+ * Internally used for communication with the Hanko API. It also handles authorization tokens to enable authorized
52
+ * requests.
53
+ *
54
+ * Currently, there is an issue with Safari and on iOS 15 devices where decoding a JSON response via the fetch API
55
+ * breaks the user gesture and the user is not able to use the authenticator. Therefore, this class uses XMLHttpRequests
56
+ * instead of the fetch API, but maintains compatibility by wrapping the XMLHttpRequests. So, if the issues are fixed,
57
+ * we can easily return to the fetch API.
58
+ *
59
+ * @category SDK
60
+ * @subcategory Internal
61
+ * @param {string} api - The URL of your Hanko API instance
62
+ * @param {number=} timeout - The request timeout in milliseconds
63
+ */
64
+ declare class HttpClient {
65
+ timeout: number;
66
+ api: string;
67
+ constructor(api: string, timeout?: number);
68
+ _fetch(path: string, options: RequestInit, xhr?: XMLHttpRequest): Promise<Response>;
69
+ /**
70
+ * Performs a GET request.
71
+ *
72
+ * @param {string} path - The path to the requested resource.
73
+ * @return {Promise<Response>}
74
+ * @throws {RequestTimeoutError}
75
+ * @throws {TechnicalError}
76
+ */
77
+ get(path: string): Promise<Response>;
78
+ /**
79
+ * Performs a POST request.
80
+ *
81
+ * @param {string} path - The path to the requested resource.
82
+ * @param {any=} body - The request body.
83
+ * @return {Promise<Response>}
84
+ * @throws {RequestTimeoutError}
85
+ * @throws {TechnicalError}
86
+ */
87
+ post(path: string, body?: any): Promise<Response>;
88
+ /**
89
+ * Performs a PUT request.
90
+ *
91
+ * @param {string} path - The path to the requested resource.
92
+ * @param {any=} body - The request body.
93
+ * @return {Promise<Response>}
94
+ * @throws {RequestTimeoutError}
95
+ * @throws {TechnicalError}
96
+ */
97
+ put(path: string, body?: any): Promise<Response>;
98
+ /**
99
+ * Performs a PATCH request.
100
+ *
101
+ * @param {string} path - The path to the requested resource.
102
+ * @param {any=} body - The request body.
103
+ * @return {Promise<Response>}
104
+ * @throws {RequestTimeoutError}
105
+ * @throws {TechnicalError}
106
+ */
107
+ patch(path: string, body?: any): Promise<Response>;
108
+ /**
109
+ * Performs a DELETE request.
110
+ *
111
+ * @param {string} path - The path to the requested resource.
112
+ * @return {Promise<Response>}
113
+ * @throws {RequestTimeoutError}
114
+ * @throws {TechnicalError}
115
+ */
116
+ delete(path: string): Promise<Response>;
117
+ }
118
+ export { Headers, Response, HttpClient };
@@ -0,0 +1,57 @@
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
+ * @param {string=} emailID - The UUID of the email address. If unspecified, the email will be sent to the primary email address.
20
+ * @param {boolean=} force - Indicates the passcode should be sent, even if there is another active passcode.
21
+ * @return {Promise<Passcode>}
22
+ * @throws {TooManyRequestsError}
23
+ * @throws {RequestTimeoutError}
24
+ * @throws {UnauthorizedError}
25
+ * @throws {TechnicalError}
26
+ * @see https://docs.hanko.io/api/public#tag/Passcode/operation/passcodeInit
27
+ */
28
+ initialize(userID: string, emailID?: string, force?: boolean): Promise<Passcode>;
29
+ /**
30
+ * Validates the passcode obtained from the email.
31
+ *
32
+ * @param {string} userID - The UUID of the user.
33
+ * @param {string} code - The passcode digests.
34
+ * @return {Promise<void>}
35
+ * @throws {InvalidPasscodeError}
36
+ * @throws {MaxNumOfPasscodeAttemptsReachedError}
37
+ * @throws {RequestTimeoutError}
38
+ * @throws {TechnicalError}
39
+ * @see https://docs.hanko.io/api/public#tag/Passcode/operation/passcodeFinal
40
+ */
41
+ finalize(userID: string, code: string): Promise<void>;
42
+ /**
43
+ * Returns the number of seconds the current passcode is active for.
44
+ *
45
+ * @param {string} userID - The UUID of the user.
46
+ * @return {number}
47
+ */
48
+ getTTL(userID: string): number;
49
+ /**
50
+ * Returns the number of seconds the rate limiting is active for.
51
+ *
52
+ * @param {string} userID - The UUID of the user.
53
+ * @return {number}
54
+ */
55
+ getResendAfter(userID: string): number;
56
+ }
57
+ export { PasscodeClient };