@teamhanko/hanko-frontend-sdk 1.5.1 → 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 +59 -27
- 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/SessionStorage.d.ts +38 -0
- package/dist/lib/client/HttpClient.d.ts +24 -8
- 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 +17 -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/package.json
CHANGED
|
@@ -1,58 +0,0 @@
|
|
|
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 {RequestTimeoutError}
|
|
30
|
-
* @throws {TechnicalError}
|
|
31
|
-
* @throws {UnauthorizedError}
|
|
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 {RequestTimeoutError}
|
|
41
|
-
* @throws {TechnicalError}
|
|
42
|
-
* @throws {UnauthorizedError}
|
|
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 {RequestTimeoutError}
|
|
52
|
-
* @throws {TechnicalError}
|
|
53
|
-
* @throws {UnauthorizedError}
|
|
54
|
-
* @see https://docs.hanko.io/api/public#tag/Email-Management/operation/deleteEmail
|
|
55
|
-
*/
|
|
56
|
-
delete(emailID: string): Promise<void>;
|
|
57
|
-
}
|
|
58
|
-
export { EmailClient };
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { Client } from "./Client";
|
|
2
|
-
import { ThirdPartyError } from "../Errors";
|
|
3
|
-
/**
|
|
4
|
-
* A class that handles communication with the Hanko API for the purposes
|
|
5
|
-
* of authenticating through a third party provider.
|
|
6
|
-
*
|
|
7
|
-
* @constructor
|
|
8
|
-
* @category SDK
|
|
9
|
-
* @subcategory Clients
|
|
10
|
-
* @extends {Client}
|
|
11
|
-
*/
|
|
12
|
-
export declare class EnterpriseClient extends Client {
|
|
13
|
-
/**
|
|
14
|
-
* Extracts the domain from an email address
|
|
15
|
-
* @param {string} email E-Mail address of the user from which the domain will be extracted.
|
|
16
|
-
* @throws {ThirdPartyError}
|
|
17
|
-
* @private
|
|
18
|
-
*/
|
|
19
|
-
private getDomain;
|
|
20
|
-
/**
|
|
21
|
-
* Performs a request to the Hanko API to check if there is a provider for the users e-mail domain
|
|
22
|
-
*
|
|
23
|
-
* @param {string} email - E-Mail address of the user to login
|
|
24
|
-
*/
|
|
25
|
-
hasProvider(email: string): Promise<boolean>;
|
|
26
|
-
/**
|
|
27
|
-
* Performs a request to the Hanko API that redirects to the given
|
|
28
|
-
* third party provider.
|
|
29
|
-
*
|
|
30
|
-
* @param {string} email - E-Mail address of the user
|
|
31
|
-
* @param {string} redirectTo - The URL to redirect to after a successful third party authentication
|
|
32
|
-
* @throws {ThirdPartyError}
|
|
33
|
-
* @see http://docs.hanko.io/api/public#tag/Third-Party/operation/enterpriseAuth
|
|
34
|
-
*/
|
|
35
|
-
auth(email: string, redirectTo: string): void;
|
|
36
|
-
/**
|
|
37
|
-
* Get a third party error from the current location's query params.
|
|
38
|
-
* @returns {(ThirdPartyError|undefined)} The ThirdPartyError.
|
|
39
|
-
*/
|
|
40
|
-
getError(): ThirdPartyError;
|
|
41
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { Client } from "./Client";
|
|
2
|
-
import { ThirdPartyError } from "../Errors";
|
|
3
|
-
/**
|
|
4
|
-
* A class that handles communication with the Hanko API for the purposes
|
|
5
|
-
* of authenticating through a third party provider.
|
|
6
|
-
*
|
|
7
|
-
* @constructor
|
|
8
|
-
* @category SDK
|
|
9
|
-
* @subcategory Clients
|
|
10
|
-
* @extends {Client}
|
|
11
|
-
*/
|
|
12
|
-
export declare class ThirdPartyClient extends Client {
|
|
13
|
-
/**
|
|
14
|
-
* Performs a request to the Hanko API that redirects to the given
|
|
15
|
-
* third party provider.
|
|
16
|
-
*
|
|
17
|
-
* @param {string} provider - The name of the third party provider
|
|
18
|
-
* @param {string} redirectTo - The URL to redirect to after a successful third party authentication
|
|
19
|
-
* @throws {ThirdPartyError}
|
|
20
|
-
* @see http://docs.hanko.io/api/public#tag/Third-Party/operation/thirdPartyAuth
|
|
21
|
-
*/
|
|
22
|
-
auth(provider: string, redirectTo: string): Promise<void>;
|
|
23
|
-
/**
|
|
24
|
-
* Get a third party error from the current location's query params.
|
|
25
|
-
* @returns {(ThirdPartyError|undefined)} The ThirdPartyError.
|
|
26
|
-
*/
|
|
27
|
-
getError(): ThirdPartyError;
|
|
28
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Client } from "./Client";
|
|
2
|
-
/**
|
|
3
|
-
* Client responsible for exchanging one time tokens for session JWTs.
|
|
4
|
-
*
|
|
5
|
-
* @constructor
|
|
6
|
-
* @category SDK
|
|
7
|
-
* @subcategory Clients
|
|
8
|
-
* @extends {Client}
|
|
9
|
-
*/
|
|
10
|
-
export declare class TokenClient extends Client {
|
|
11
|
-
/**
|
|
12
|
-
* Validate a one time token to retrieve a session JWT. Does nothing
|
|
13
|
-
* if the current window location does not contain a 'hanko_token' in the
|
|
14
|
-
* search query.
|
|
15
|
-
*
|
|
16
|
-
* @return {Promise<void>}
|
|
17
|
-
* @throws {TechnicalError}
|
|
18
|
-
* https://docs.hanko.io/api/api/public#tag/Token/operation/token
|
|
19
|
-
*/
|
|
20
|
-
validate(): Promise<void>;
|
|
21
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { Client } from "../client/Client";
|
|
2
|
-
import { State } from "./State";
|
|
3
|
-
import { Action } from "./types/action";
|
|
4
|
-
import { FlowPath, Handlers } from "./types/state-handling";
|
|
5
|
-
import { HankoError } from "../Errors";
|
|
6
|
-
type ExtendedHandlers = Handlers & {
|
|
7
|
-
onError?: (e: unknown) => any;
|
|
8
|
-
};
|
|
9
|
-
declare class Flow extends Client {
|
|
10
|
-
init(initPath: FlowPath, handlers: ExtendedHandlers): Promise<void>;
|
|
11
|
-
fromString(init: string, handlers: ExtendedHandlers): Promise<void>;
|
|
12
|
-
/**
|
|
13
|
-
* Runs a handler for a given state.
|
|
14
|
-
*
|
|
15
|
-
* If the handler returns an action or a state, this method will run the next
|
|
16
|
-
* appropriate handler for that state. (Recursively)
|
|
17
|
-
*
|
|
18
|
-
* If the handlers passed to `init` do not contain an `onError` handler,
|
|
19
|
-
* this method will throw.
|
|
20
|
-
*
|
|
21
|
-
* @see InvalidStateError
|
|
22
|
-
* @see HandlerNotFoundError
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* const handlerResult = await run("/login", {
|
|
26
|
-
* // all login handlers are in here, one of which will be called
|
|
27
|
-
* // based on what the /login endpoint returns
|
|
28
|
-
* });
|
|
29
|
-
*/
|
|
30
|
-
run: (state: State<any>, handlers: ExtendedHandlers) => Promise<unknown>;
|
|
31
|
-
}
|
|
32
|
-
export declare class HandlerNotFoundError extends HankoError {
|
|
33
|
-
state: State<any>;
|
|
34
|
-
constructor(state: State<any>);
|
|
35
|
-
}
|
|
36
|
-
export declare class InvalidStateError extends Error {
|
|
37
|
-
state: State<any>;
|
|
38
|
-
constructor(state: State<any>);
|
|
39
|
-
}
|
|
40
|
-
export declare function isAction(x: any): x is Action<unknown>;
|
|
41
|
-
export { Flow };
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @interface
|
|
3
|
-
* @category SDK
|
|
4
|
-
* @subcategory Internal
|
|
5
|
-
*/
|
|
6
|
-
interface LocalStorage {
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* A class to read and write local storage contents.
|
|
10
|
-
*
|
|
11
|
-
* @abstract
|
|
12
|
-
* @param {string} key - The local storage key.
|
|
13
|
-
* @category SDK
|
|
14
|
-
* @subcategory Internal
|
|
15
|
-
*/
|
|
16
|
-
declare abstract class State {
|
|
17
|
-
key: string;
|
|
18
|
-
ls: LocalStorage;
|
|
19
|
-
constructor(key: string);
|
|
20
|
-
/**
|
|
21
|
-
* Reads and decodes the locally stored data.
|
|
22
|
-
*
|
|
23
|
-
* @return {State}
|
|
24
|
-
*/
|
|
25
|
-
read(): State;
|
|
26
|
-
/**
|
|
27
|
-
* Encodes and writes the data to the local storage.
|
|
28
|
-
*
|
|
29
|
-
* @return {State}
|
|
30
|
-
*/
|
|
31
|
-
write(): State;
|
|
32
|
-
/**
|
|
33
|
-
* Converts a timestamp into remaining seconds that you can count down.
|
|
34
|
-
*
|
|
35
|
-
* @static
|
|
36
|
-
* @param {number} time - Timestamp in seconds (since January 1, 1970 00:00:00 UTC).
|
|
37
|
-
* @return {number}
|
|
38
|
-
*/
|
|
39
|
-
static timeToRemainingSeconds(time?: number): number;
|
|
40
|
-
/**
|
|
41
|
-
* Converts a number of seconds into a timestamp.
|
|
42
|
-
*
|
|
43
|
-
* @static
|
|
44
|
-
* @param {number} seconds - Remaining seconds to be converted into a timestamp.
|
|
45
|
-
* @return {number}
|
|
46
|
-
*/
|
|
47
|
-
static remainingSecondsToTime(seconds?: number): number;
|
|
48
|
-
}
|
|
49
|
-
export { State };
|
|
50
|
-
export type { LocalStorage };
|