@junobuild/core-standalone 1.2.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/dist/browser/canisterStatus-ENEUF6W6.js +2 -0
- package/dist/browser/{chunk-EMF4NSTU.js → chunk-GGU5IQIJ.js} +11 -11
- package/dist/browser/{chunk-EMF4NSTU.js.map → chunk-GGU5IQIJ.js.map} +2 -2
- package/dist/browser/index.js +15 -15
- package/dist/browser/index.js.map +4 -4
- package/dist/node/index.mjs +27 -27
- package/dist/node/index.mjs.map +4 -4
- package/dist/types/{constants → auth/constants}/auth.constants.d.ts +1 -0
- package/dist/types/auth/helpers/progress.helpers.d.ts +6 -0
- package/dist/types/auth/helpers/window.helpers.d.ts +3 -0
- package/dist/types/auth/providers/_auth-client.providers.d.ts +74 -0
- package/dist/types/auth/providers/internet-identity.providers.d.ts +28 -0
- package/dist/types/auth/providers/nfid.providers.d.ts +28 -0
- package/dist/types/auth/providers/webauthn.providers.d.ts +40 -0
- package/dist/types/auth/services/_user.services.d.ts +11 -0
- package/dist/types/auth/services/auth-timout.services.d.ts +3 -0
- package/dist/types/{services → auth/services}/auth.services.d.ts +25 -6
- package/dist/types/auth/services/user-webauthn.services.d.ts +8 -0
- package/dist/types/{stores → auth/stores}/auth.store.d.ts +3 -3
- package/dist/types/auth/types/auth-client.d.ts +43 -0
- package/dist/types/auth/types/auth.d.ts +63 -0
- package/dist/types/{types → auth/types}/errors.d.ts +6 -0
- package/dist/types/auth/types/internet-identity.d.ts +23 -0
- package/dist/types/auth/types/nfid.d.ts +22 -0
- package/dist/types/auth/types/progress.d.ts +20 -0
- package/dist/types/auth/types/provider.d.ts +32 -0
- package/dist/types/auth/types/user.d.ts +23 -0
- package/dist/types/auth/types/webauthn.d.ts +74 -0
- package/dist/types/{utils → auth/utils}/auth.utils.d.ts +1 -0
- package/dist/types/{api → datastore/api}/doc.api.d.ts +2 -2
- package/dist/types/{services → datastore/services}/doc.services.d.ts +3 -3
- package/dist/types/{types → datastore/types}/doc.d.ts +1 -1
- package/dist/types/{services → functions/services}/functions.services.d.ts +1 -1
- package/dist/types/index.d.ts +32 -22
- package/dist/types/{api → storage/api}/storage.api.d.ts +2 -2
- package/dist/types/{services → storage/services}/storage.services.d.ts +4 -4
- package/dist/types/{types/storage.types.d.ts → storage/types/storage.d.ts} +1 -1
- package/dist/workers/auth.worker.js +4 -4
- package/dist/workers/auth.worker.js.map +3 -3
- package/package.json +3 -3
- package/dist/browser/canisterStatus-72I5GDMD.js +0 -2
- package/dist/types/providers/auth.providers.d.ts +0 -79
- package/dist/types/services/_user.services.d.ts +0 -2
- package/dist/types/services/auth-timout.services.d.ts +0 -3
- package/dist/types/types/auth.d.ts +0 -90
- package/dist/workers/_auth.worker.handler.js +0 -43
- package/dist/workers/_auth.worker.handler.js.map +0 -7
- /package/dist/browser/{canisterStatus-72I5GDMD.js.map → canisterStatus-ENEUF6W6.js.map} +0 -0
- /package/dist/types/{types → auth/types}/post-message.d.ts +0 -0
- /package/dist/types/{utils → auth/utils}/events.utils.d.ts +0 -0
- /package/dist/types/{utils → auth/utils}/window.utils.d.ts +0 -0
- /package/dist/types/{workers/_auth.worker.handler.d.ts → auth/workers/auth.worker.d.ts} +0 -0
- /package/dist/types/{api → core/api}/actor.api.d.ts +0 -0
- /package/dist/types/{constants → core/constants}/call-options.constants.d.ts +0 -0
- /package/dist/types/{constants → core/constants}/container.constants.d.ts +0 -0
- /package/dist/types/{services/_identity.services.d.ts → core/services/identity.services.d.ts} +0 -0
- /package/dist/types/{stores → core/stores}/_agent.factory.d.ts +0 -0
- /package/dist/types/{stores → core/stores}/_store.d.ts +0 -0
- /package/dist/types/{stores → core/stores}/actor.store.d.ts +0 -0
- /package/dist/types/{stores → core/stores}/agent.store.d.ts +0 -0
- /package/dist/types/{stores → core/stores}/env.store.d.ts +0 -0
- /package/dist/types/{types → core/types}/actor.d.ts +0 -0
- /package/dist/types/{types → core/types}/call-options.d.ts +0 -0
- /package/dist/types/{types → core/types}/env.d.ts +0 -0
- /package/dist/types/{types → core/types}/list.d.ts +0 -0
- /package/dist/types/{types → core/types}/satellite.d.ts +0 -0
- /package/dist/types/{types → core/types}/subscription.d.ts +0 -0
- /package/dist/types/{types → core/types}/utility.d.ts +0 -0
- /package/dist/types/{utils → core/utils}/env.utils.d.ts +0 -0
- /package/dist/types/{utils → core/utils}/list.utils.d.ts +0 -0
- /package/dist/types/{utils → core/utils}/window.env.utils.d.ts +0 -0
- /package/dist/types/{utils → datastore/utils}/data.utils.d.ts +0 -0
- /package/dist/types/{utils → datastore/utils}/doc.utils.d.ts +0 -0
- /package/dist/types/{utils → storage/utils}/crypto.utils.d.ts +0 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { type AuthClient } from '@dfinity/auth-client';
|
|
2
|
+
import { type AuthClientSignInOptions } from '../types/auth-client';
|
|
3
|
+
import type { Provider } from '../types/provider';
|
|
4
|
+
/**
|
|
5
|
+
* Common traits for all authentication providers
|
|
6
|
+
* @interface AuthProvider
|
|
7
|
+
*/
|
|
8
|
+
export interface AuthProvider {
|
|
9
|
+
/**
|
|
10
|
+
* The unique identifier of the provider.
|
|
11
|
+
*/
|
|
12
|
+
readonly id: Provider;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Options for signing in with an authentication provider.
|
|
16
|
+
* @interface AuthProviderSignInOptions
|
|
17
|
+
*/
|
|
18
|
+
export interface AuthProviderSignInOptions {
|
|
19
|
+
/**
|
|
20
|
+
* The URL of the identity provider - commonly Internet Identity.
|
|
21
|
+
*/
|
|
22
|
+
identityProvider: string;
|
|
23
|
+
/**
|
|
24
|
+
* Optional features for the window opener.
|
|
25
|
+
*/
|
|
26
|
+
windowOpenerFeatures?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Abstract base class for all authentication providers that integrate with the `@dfinity/auth-client`.
|
|
30
|
+
*
|
|
31
|
+
* @abstract
|
|
32
|
+
* @class AuthClientProvider
|
|
33
|
+
* @implements {AuthProvider}
|
|
34
|
+
*/
|
|
35
|
+
export declare abstract class AuthClientProvider implements AuthProvider {
|
|
36
|
+
#private;
|
|
37
|
+
/**
|
|
38
|
+
* The unique identifier of the provider.
|
|
39
|
+
*
|
|
40
|
+
* @abstract
|
|
41
|
+
* @type {Provider}
|
|
42
|
+
*/
|
|
43
|
+
abstract get id(): Provider;
|
|
44
|
+
/**
|
|
45
|
+
* Returns the sign-in options for the provider.
|
|
46
|
+
*
|
|
47
|
+
* Note: set as public instead of protected for testing purposes.
|
|
48
|
+
*
|
|
49
|
+
* @abstract
|
|
50
|
+
* @param {Pick<SignInOptions, 'windowed'>} options - Options controlling window behavior.
|
|
51
|
+
* @returns {AuthProviderSignInOptions} Provider-specific sign-in options.
|
|
52
|
+
*/
|
|
53
|
+
abstract signInOptions(options: Pick<AuthClientSignInOptions, 'windowed'>): AuthProviderSignInOptions;
|
|
54
|
+
/**
|
|
55
|
+
* Signs in a user with the given authentication provider.
|
|
56
|
+
*
|
|
57
|
+
* @param {Object} params - The sign-in parameters.
|
|
58
|
+
* @param {AuthClientSignInOptions} [params.options] - Optional configuration for the login request.
|
|
59
|
+
* @param {AuthClient | undefined | null} params.authClient - The AuthClient instance in its current state.
|
|
60
|
+
* @param {initAuth} params.initAuth - The function to load or initialize the user. Provided as a callback to avoid recursive import.
|
|
61
|
+
*
|
|
62
|
+
* @returns {Promise<void>} Resolves if the sign-in is successful. Rejects with:
|
|
63
|
+
* - {@link SignInInitError} if no AuthClient is available.
|
|
64
|
+
* - {@link SignInUserInterruptError} if the user cancels the login.
|
|
65
|
+
* - {@link SignInError} for other errors during sign-in.
|
|
66
|
+
*/
|
|
67
|
+
signIn({ options, authClient, initAuth }: {
|
|
68
|
+
options?: AuthClientSignInOptions;
|
|
69
|
+
authClient: AuthClient | undefined | null;
|
|
70
|
+
initAuth: (params: {
|
|
71
|
+
provider: Provider;
|
|
72
|
+
}) => Promise<void>;
|
|
73
|
+
}): Promise<void>;
|
|
74
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { AuthClientSignInOptions } from '../types/auth-client';
|
|
2
|
+
import type { InternetIdentityConfig } from '../types/internet-identity';
|
|
3
|
+
import type { Provider } from '../types/provider';
|
|
4
|
+
import { AuthClientProvider, type AuthProviderSignInOptions } from './_auth-client.providers';
|
|
5
|
+
/**
|
|
6
|
+
* Internet Identity authentication provider.
|
|
7
|
+
* @class InternetIdentityProvider
|
|
8
|
+
* @implements {AuthProvider}
|
|
9
|
+
*/
|
|
10
|
+
export declare class InternetIdentityProvider extends AuthClientProvider {
|
|
11
|
+
#private;
|
|
12
|
+
/**
|
|
13
|
+
* Creates an instance of InternetIdentityProvider.
|
|
14
|
+
* @param {InternetIdentityConfig} config - The configuration for Internet Identity.
|
|
15
|
+
*/
|
|
16
|
+
constructor({ domain }: InternetIdentityConfig);
|
|
17
|
+
/**
|
|
18
|
+
* Gets the identifier of the provider.
|
|
19
|
+
* @returns {Provider} The identifier of the provider - `internet_identity`.
|
|
20
|
+
*/
|
|
21
|
+
get id(): Provider;
|
|
22
|
+
/**
|
|
23
|
+
* Gets the sign-in options for Internet Identity.
|
|
24
|
+
* @param {Pick<SignInOptions, 'windowed'>} options - The sign-in options.
|
|
25
|
+
* @returns {AuthProviderSignInOptions} The sign-in options for Internet Identity.
|
|
26
|
+
*/
|
|
27
|
+
signInOptions({ windowed }: Pick<AuthClientSignInOptions, 'windowed'>): AuthProviderSignInOptions;
|
|
28
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { AuthClientSignInOptions } from '../types/auth-client';
|
|
2
|
+
import type { NFIDConfig } from '../types/nfid';
|
|
3
|
+
import type { Provider } from '../types/provider';
|
|
4
|
+
import { AuthClientProvider, type AuthProviderSignInOptions } from './_auth-client.providers';
|
|
5
|
+
/**
|
|
6
|
+
* NFID authentication provider.
|
|
7
|
+
* @class NFIDProvider
|
|
8
|
+
* @implements {AuthProvider}
|
|
9
|
+
*/
|
|
10
|
+
export declare class NFIDProvider extends AuthClientProvider {
|
|
11
|
+
#private;
|
|
12
|
+
/**
|
|
13
|
+
* Creates an instance of NFIDProvider.
|
|
14
|
+
* @param {NFIDConfig} config - The configuration for NFID.
|
|
15
|
+
*/
|
|
16
|
+
constructor({ appName, logoUrl }: NFIDConfig);
|
|
17
|
+
/**
|
|
18
|
+
* Gets the identifier of the provider.
|
|
19
|
+
* @returns {Provider} The identifier of the provider- nfid.
|
|
20
|
+
*/
|
|
21
|
+
get id(): Provider;
|
|
22
|
+
/**
|
|
23
|
+
* Gets the sign-in options for NFID.
|
|
24
|
+
* @param {Pick<SignInOptions, 'windowed'>} options - The sign-in options.
|
|
25
|
+
* @returns {AuthProviderSignInOptions} The sign-in options to effectively sign-in with NFID.
|
|
26
|
+
*/
|
|
27
|
+
signInOptions({ windowed }: Pick<AuthClientSignInOptions, 'windowed'>): AuthProviderSignInOptions;
|
|
28
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Provider } from '../types/provider';
|
|
2
|
+
import type { User } from '../types/user';
|
|
3
|
+
import { type WebAuthnSignInOptions, type WebAuthnSignUpOptions } from '../types/webauthn';
|
|
4
|
+
import type { AuthProvider } from './_auth-client.providers';
|
|
5
|
+
export declare class WebAuthnProvider implements AuthProvider {
|
|
6
|
+
#private;
|
|
7
|
+
/**
|
|
8
|
+
* Gets the identifier of the provider.
|
|
9
|
+
* @returns {Provider} The identifier of the provider is webauthn.
|
|
10
|
+
*/
|
|
11
|
+
get id(): Provider;
|
|
12
|
+
/**
|
|
13
|
+
* Signs up a user by creating a new passkey.
|
|
14
|
+
*
|
|
15
|
+
* @param {Object} params - The sign-up parameters.
|
|
16
|
+
* @param {WebAuthnSignUpOptions} [params.options] - Optional configuration for the login request.
|
|
17
|
+
* @param {loadAuth} params.loadAuthWithUser - The function to load the authentication with the user. Provided as a callback to avoid recursive import.
|
|
18
|
+
*
|
|
19
|
+
* @returns {Promise<void>} Resolves if the sign-up is successful.
|
|
20
|
+
*/
|
|
21
|
+
signUp({ options: { onProgress, maxTimeToLiveInMilliseconds, passkey: passkeyOptions }, loadAuthWithUser }: {
|
|
22
|
+
options?: WebAuthnSignUpOptions;
|
|
23
|
+
loadAuthWithUser: (params: {
|
|
24
|
+
user: User;
|
|
25
|
+
}) => Promise<void>;
|
|
26
|
+
}): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Signs in a user with an existing passkey.
|
|
29
|
+
*
|
|
30
|
+
* @param {Object} params - The sign-in parameters.
|
|
31
|
+
* @param {WebAuthnSignInOptions} [params.options] - Optional configuration for the login request.
|
|
32
|
+
* @param {loadAuth} params.loadAuth - The function to load the user. Provided as a callback to avoid recursive import.
|
|
33
|
+
*
|
|
34
|
+
* @returns {Promise<void>} Resolves if the sign-in is successful.
|
|
35
|
+
*/
|
|
36
|
+
signIn({ options: { onProgress, maxTimeToLiveInMilliseconds }, loadAuth }: {
|
|
37
|
+
options?: WebAuthnSignInOptions;
|
|
38
|
+
loadAuth: () => Promise<void>;
|
|
39
|
+
}): Promise<void>;
|
|
40
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Provider } from '../types/provider';
|
|
2
|
+
import type { User } from '../types/user';
|
|
3
|
+
type UserId = string;
|
|
4
|
+
export declare const initUser: ({ provider }: {
|
|
5
|
+
provider: Provider;
|
|
6
|
+
}) => Promise<User>;
|
|
7
|
+
export declare const loadUser: () => Promise<{
|
|
8
|
+
userId: UserId;
|
|
9
|
+
user: User | undefined;
|
|
10
|
+
}>;
|
|
11
|
+
export {};
|
|
@@ -1,19 +1,38 @@
|
|
|
1
1
|
import type { Identity } from '@dfinity/agent';
|
|
2
|
-
import type {
|
|
3
|
-
|
|
2
|
+
import type { SignInOptions, SignOutOptions, SignUpOptions } from '../types/auth';
|
|
3
|
+
import type { Provider } from '../types/provider';
|
|
4
|
+
/**
|
|
5
|
+
* Initialize the authClient and load the existing user.
|
|
6
|
+
* Executed when the library is initialized through initSatellite.
|
|
7
|
+
*/
|
|
8
|
+
export declare const loadAuth: () => Promise<void>;
|
|
9
|
+
/**
|
|
10
|
+
* Initialize the authClient, load or create a new user.
|
|
11
|
+
* Executed on sign-in.
|
|
12
|
+
*/
|
|
13
|
+
export declare const createAuth: ({ provider }: {
|
|
14
|
+
provider: Provider;
|
|
15
|
+
}) => Promise<void>;
|
|
4
16
|
/**
|
|
5
17
|
* Signs in a user with the specified options.
|
|
6
18
|
*
|
|
7
|
-
* @
|
|
19
|
+
* @default Signs in by default with Internet Identity
|
|
20
|
+
* @param {SignInOptions} [options] - The options for signing in including the provider to use for the process.
|
|
8
21
|
* @returns {Promise<void>} A promise that resolves when the sign-in process is complete and the authenticated user is initialized.
|
|
9
|
-
* @throws {SignInError} If the sign-in process fails or no authentication client is available.
|
|
10
22
|
*/
|
|
11
|
-
export declare const signIn: (options
|
|
23
|
+
export declare const signIn: (options: SignInOptions) => Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Signs up to create a new user with the specified options.
|
|
26
|
+
*
|
|
27
|
+
* @param {SignUpOptions} [options] - The options for signing up including the provider to use for the process.
|
|
28
|
+
* @returns {Promise<void>} A promise that resolves when the sign-up process is complete and the user is authenticated.
|
|
29
|
+
*/
|
|
30
|
+
export declare const signUp: (options: SignUpOptions) => Promise<void>;
|
|
12
31
|
/**
|
|
13
32
|
* Signs out the current user.
|
|
14
33
|
* @returns {Promise<void>} A promise that resolves when the sign-out process is complete.
|
|
15
34
|
*/
|
|
16
|
-
export declare const signOut: () => Promise<void>;
|
|
35
|
+
export declare const signOut: (options?: SignOutOptions) => Promise<void>;
|
|
17
36
|
/**
|
|
18
37
|
* ℹ️ Exposed for testing purpose only. Should not be leaked to consumer or used by the library.
|
|
19
38
|
*/
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Identity } from '@dfinity/agent';
|
|
2
|
+
import type { WebAuthnIdentity, WebAuthnNewCredential } from '@junobuild/ic-client/webauthn';
|
|
3
|
+
import type { Environment } from '../../core/types/env';
|
|
4
|
+
import type { User } from '../types/user';
|
|
5
|
+
export declare const createWebAuthnUser: ({ delegationIdentity, passkeyIdentity, satelliteId }: {
|
|
6
|
+
delegationIdentity: Identity;
|
|
7
|
+
passkeyIdentity: WebAuthnIdentity<WebAuthnNewCredential>;
|
|
8
|
+
} & Pick<Environment, "satelliteId">) => Promise<User>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { Unsubscribe } from '
|
|
3
|
-
import {
|
|
1
|
+
import { Store } from '../../core/stores/_store';
|
|
2
|
+
import type { Unsubscribe } from '../../core/types/subscription';
|
|
3
|
+
import type { User } from '../types/user';
|
|
4
4
|
export declare class AuthStore extends Store<User | null> {
|
|
5
5
|
private static instance;
|
|
6
6
|
private authUser;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { SignProgressFn } from './progress';
|
|
2
|
+
/**
|
|
3
|
+
* Enum representing the different steps of the sign-in flow with Internet Identity or NFID.
|
|
4
|
+
*/
|
|
5
|
+
export declare enum AuthClientSignInProgressStep {
|
|
6
|
+
/** User is authenticating with the identity provider (II / NFID). */
|
|
7
|
+
AuthorizingWithProvider = 0,
|
|
8
|
+
/** App is creating a new user or retrieving an existing one after authorization. */
|
|
9
|
+
CreatingOrRetrievingUser = 1
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Interface representing sign-in options when using an AuthClient based provider.
|
|
13
|
+
* @interface AuthClientSignInOptions
|
|
14
|
+
*/
|
|
15
|
+
export interface AuthClientSignInOptions {
|
|
16
|
+
/**
|
|
17
|
+
* Maximum time to live for the session in nanoseconds. Cannot be extended.
|
|
18
|
+
* @type {bigint}
|
|
19
|
+
*/
|
|
20
|
+
maxTimeToLiveInNanoseconds?: bigint;
|
|
21
|
+
/**
|
|
22
|
+
* Origin for derivation. Useful when sign-in using the same domain - e.g. sign-in on www.hello.com for hello.com.
|
|
23
|
+
* @type {(string | URL)}
|
|
24
|
+
*/
|
|
25
|
+
derivationOrigin?: string | URL;
|
|
26
|
+
/**
|
|
27
|
+
* Whether to open the sign-in window.
|
|
28
|
+
* @default true
|
|
29
|
+
* @type {boolean}
|
|
30
|
+
*/
|
|
31
|
+
windowed?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Whether to allow the infamous PIN authentication.
|
|
34
|
+
* @default false
|
|
35
|
+
* @type {boolean}
|
|
36
|
+
*/
|
|
37
|
+
allowPin?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Optional callback to receive progress updates about the sign-in flow.
|
|
40
|
+
* Useful for showing UI feedback such as loading indicators or status messages.
|
|
41
|
+
*/
|
|
42
|
+
onProgress?: SignProgressFn<AuthClientSignInProgressStep>;
|
|
43
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { InternetIdentitySignInOptions } from './internet-identity';
|
|
2
|
+
import type { NFIDSignInOptions } from './nfid';
|
|
3
|
+
import type { WebAuthnSignInOptions, WebAuthnSignUpOptions } from './webauthn';
|
|
4
|
+
/**
|
|
5
|
+
* Options for the context of the sign-in flow.
|
|
6
|
+
*/
|
|
7
|
+
export interface SignInContext {
|
|
8
|
+
/**
|
|
9
|
+
* Opt out of the beforeunload window guard for the sign-in which prevents
|
|
10
|
+
* the user to closing the current window/tab while the sign-in flow is in progress.
|
|
11
|
+
*
|
|
12
|
+
* Disabling it is discouraged.
|
|
13
|
+
*
|
|
14
|
+
* @default true
|
|
15
|
+
*/
|
|
16
|
+
windowGuard?: boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The options for sign-in.
|
|
20
|
+
*
|
|
21
|
+
* - `internetIdentity`: Internet Identity options
|
|
22
|
+
* - `nfid`: NFID options
|
|
23
|
+
* - `webauthn`: WebAuthn/Passkey options
|
|
24
|
+
*/
|
|
25
|
+
export type SignInOptions = {
|
|
26
|
+
internet_identity: {
|
|
27
|
+
options?: InternetIdentitySignInOptions;
|
|
28
|
+
context?: SignInContext;
|
|
29
|
+
};
|
|
30
|
+
} | {
|
|
31
|
+
nfid: {
|
|
32
|
+
options: NFIDSignInOptions;
|
|
33
|
+
context?: SignInContext;
|
|
34
|
+
};
|
|
35
|
+
} | {
|
|
36
|
+
webauthn: {
|
|
37
|
+
options?: WebAuthnSignInOptions;
|
|
38
|
+
context?: SignInContext;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* The options for sign-up.
|
|
43
|
+
*
|
|
44
|
+
* - `webauthn`: WebAuthn/Passkey options
|
|
45
|
+
*/
|
|
46
|
+
export interface SignUpOptions {
|
|
47
|
+
webauthn: {
|
|
48
|
+
options?: WebAuthnSignUpOptions;
|
|
49
|
+
context?: SignInContext;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The options for sign-out.
|
|
54
|
+
*/
|
|
55
|
+
export interface SignOutOptions {
|
|
56
|
+
/**
|
|
57
|
+
* Opt out of reloading the window after state and authentication
|
|
58
|
+
* have been successfully cleared.
|
|
59
|
+
*
|
|
60
|
+
* @default true
|
|
61
|
+
*/
|
|
62
|
+
windowReload?: boolean;
|
|
63
|
+
}
|
|
@@ -4,6 +4,12 @@ export declare class SignInInitError extends Error {
|
|
|
4
4
|
}
|
|
5
5
|
export declare class SignInUserInterruptError extends Error {
|
|
6
6
|
}
|
|
7
|
+
export declare class SignInProviderNotSupportedError extends Error {
|
|
8
|
+
}
|
|
9
|
+
export declare class WebAuthnSignInRetrievePublicKeyError extends Error {
|
|
10
|
+
}
|
|
11
|
+
export declare class SignUpProviderNotSupportedError extends Error {
|
|
12
|
+
}
|
|
7
13
|
export declare class InitError extends Error {
|
|
8
14
|
}
|
|
9
15
|
export declare class ListError extends Error {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { AuthClientSignInOptions } from './auth-client';
|
|
2
|
+
/**
|
|
3
|
+
* Type representing the available Internet Identity domains.
|
|
4
|
+
* @typedef {('internetcomputer.org' | 'ic0.app')} InternetIdentityDomain
|
|
5
|
+
*/
|
|
6
|
+
export type InternetIdentityDomain = 'internetcomputer.org' | 'ic0.app';
|
|
7
|
+
/**
|
|
8
|
+
* Interface representing the specific configuration for Internet Identity.
|
|
9
|
+
* @interface InternetIdentityConfig
|
|
10
|
+
*/
|
|
11
|
+
export interface InternetIdentityConfig {
|
|
12
|
+
/**
|
|
13
|
+
* The domain for Internet Identity.
|
|
14
|
+
* @default internetcomputer.org
|
|
15
|
+
* @type {InternetIdentityDomain}
|
|
16
|
+
*/
|
|
17
|
+
domain?: InternetIdentityDomain;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Interface representing sign-in options when using the Internet Identity provider.
|
|
21
|
+
* @interface InternetIdentitySignInOptions
|
|
22
|
+
*/
|
|
23
|
+
export type InternetIdentitySignInOptions = InternetIdentityConfig & AuthClientSignInOptions;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { AuthClientSignInOptions } from './auth-client';
|
|
2
|
+
/**
|
|
3
|
+
* Interface representing the specific configuration for NFID.
|
|
4
|
+
* @interface NFIDConfig
|
|
5
|
+
*/
|
|
6
|
+
export interface NFIDConfig {
|
|
7
|
+
/**
|
|
8
|
+
* The name of the application.
|
|
9
|
+
* @type {string}
|
|
10
|
+
*/
|
|
11
|
+
appName: string;
|
|
12
|
+
/**
|
|
13
|
+
* The URL of the application's logo.
|
|
14
|
+
* @type {string}
|
|
15
|
+
*/
|
|
16
|
+
logoUrl: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Interface representing sign-in options when using the NFID provider.
|
|
20
|
+
* @interface NFIDSignInOptions
|
|
21
|
+
*/
|
|
22
|
+
export type NFIDSignInOptions = NFIDConfig & AuthClientSignInOptions;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents the state of a sign-in or sign-up progress step.
|
|
3
|
+
* - `in_progress`: The step is currently being executed.
|
|
4
|
+
* - `success`: The step completed successfully.
|
|
5
|
+
* - `error`: The step failed.
|
|
6
|
+
*/
|
|
7
|
+
export type SignProgressState = 'in_progress' | 'success' | 'error';
|
|
8
|
+
/**
|
|
9
|
+
* Progress event emitted during a sign-in or sign-up flow.
|
|
10
|
+
*/
|
|
11
|
+
export interface SignProgress<Step> {
|
|
12
|
+
/** Current step in the flow */
|
|
13
|
+
step: Step;
|
|
14
|
+
/** State of the current step */
|
|
15
|
+
state: SignProgressState;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Callback type for receiving progress updates during the sign-in or sign-up process.
|
|
19
|
+
*/
|
|
20
|
+
export type SignProgressFn<Step> = (progress: SignProgress<Step>) => void;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type representing the available authentication providers.
|
|
3
|
+
* @typedef {('internet_identity' | 'nfid' | 'webauthn')} Provider
|
|
4
|
+
*/
|
|
5
|
+
export type Provider = 'internet_identity' | 'nfid' | 'webauthn';
|
|
6
|
+
/**
|
|
7
|
+
* Metadata for WebAuthn authentication.
|
|
8
|
+
* @interface ProviderDataWebAuthn
|
|
9
|
+
*/
|
|
10
|
+
export interface ProviderDataWebAuthn {
|
|
11
|
+
/**
|
|
12
|
+
* Authenticator Attestation GUID (AAGUID).
|
|
13
|
+
*
|
|
14
|
+
* If available, a 16-byte identifier that uniquely represents the model of the authenticator,
|
|
15
|
+
* unlesss the provider explicitly set it to zeros.
|
|
16
|
+
*/
|
|
17
|
+
aaguid: Uint8Array | number[];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Container for provider-specific metadata.
|
|
21
|
+
*
|
|
22
|
+
* Currently only `webauthn` is supported, but this type
|
|
23
|
+
* can be extended in the future.
|
|
24
|
+
*
|
|
25
|
+
* @interface ProviderData
|
|
26
|
+
*/
|
|
27
|
+
export interface ProviderData {
|
|
28
|
+
/**
|
|
29
|
+
* Metadata specific to WebAuthn (passkey) authentication.
|
|
30
|
+
*/
|
|
31
|
+
webauthn: ProviderDataWebAuthn;
|
|
32
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Doc } from '../../datastore/types/doc';
|
|
2
|
+
import type { Provider, ProviderData } from './provider';
|
|
3
|
+
/**
|
|
4
|
+
* Interface representing user data.
|
|
5
|
+
* @interface UserData
|
|
6
|
+
*/
|
|
7
|
+
export interface UserData {
|
|
8
|
+
/**
|
|
9
|
+
* The potential provider used to sign-in. There is no absolute guarantee that the information can be set by the browser during the sign-in flow, therefore it is optional.
|
|
10
|
+
* @type {Provider}
|
|
11
|
+
*/
|
|
12
|
+
provider?: Provider;
|
|
13
|
+
/**
|
|
14
|
+
* The optional provider-specific metadata. This is only set if the frontend was able to supply it during the sign-in flow.
|
|
15
|
+
* @type {ProviderData}
|
|
16
|
+
*/
|
|
17
|
+
providerData?: ProviderData;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Type representing a user document.
|
|
21
|
+
* @typedef {Doc<UserData>} User
|
|
22
|
+
*/
|
|
23
|
+
export type User = Doc<UserData>;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { CreatePasskeyOptions } from '@junobuild/ic-client/webauthn';
|
|
2
|
+
import type { SignProgressFn } from './progress';
|
|
3
|
+
/**
|
|
4
|
+
* Enum representing the different steps of the WebAuthn sign-in flow.
|
|
5
|
+
*/
|
|
6
|
+
export declare enum WebAuthnSignInProgressStep {
|
|
7
|
+
/** Requesting a passkey (credential) from the user */
|
|
8
|
+
RequestingUserCredential = 0,
|
|
9
|
+
/** Validating and finalizing the credential provided by the user */
|
|
10
|
+
FinalizingCredential = 1,
|
|
11
|
+
/** Signing the authentication challenge with the user's credential */
|
|
12
|
+
Signing = 2,
|
|
13
|
+
/** Completing the session setup after signing */
|
|
14
|
+
FinalizingSession = 3,
|
|
15
|
+
/** Retrieving the authenticated user information */
|
|
16
|
+
RetrievingUser = 4
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Enum representing the different steps of the WebAuthn sign-up (registration) flow.
|
|
20
|
+
*/
|
|
21
|
+
export declare enum WebAuthnSignUpProgressStep {
|
|
22
|
+
/** Creating a new passkey (credential) for the user */
|
|
23
|
+
CreatingUserCredential = 0,
|
|
24
|
+
/** Validating the created credential */
|
|
25
|
+
ValidatingUserCredential = 1,
|
|
26
|
+
/** Finalizing the credential for use */
|
|
27
|
+
FinalizingCredential = 2,
|
|
28
|
+
/** Signing the registration challenge. Requires the user to interact again with the authenticator for confirmation. */
|
|
29
|
+
Signing = 3,
|
|
30
|
+
/** Completing the session setup after signing */
|
|
31
|
+
FinalizingSession = 4,
|
|
32
|
+
/** Registering the new user in the system */
|
|
33
|
+
RegisteringUser = 5
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Interface representing common sign-in and sing-up options when using a WebAuthn (passkey) based provider.
|
|
37
|
+
* @interface WebAuthnSignOptions
|
|
38
|
+
*/
|
|
39
|
+
export interface WebAuthnSignOptions {
|
|
40
|
+
/**
|
|
41
|
+
* Maximum time to live for the session in milliseconds. Cannot be extended.
|
|
42
|
+
* @type {number}
|
|
43
|
+
*/
|
|
44
|
+
maxTimeToLiveInMilliseconds?: number;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Interface representing sign-in options when using a WebAuthn (passkey) based provider.
|
|
48
|
+
* @interface WebAuthnSignInOptions
|
|
49
|
+
*/
|
|
50
|
+
export interface WebAuthnSignInOptions extends WebAuthnSignOptions {
|
|
51
|
+
/**
|
|
52
|
+
* Optional callback to receive progress updates about the sign-in flow.
|
|
53
|
+
* Useful for showing UI feedback such as loading indicators or status messages.
|
|
54
|
+
*/
|
|
55
|
+
onProgress?: SignProgressFn<WebAuthnSignInProgressStep>;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Interface representing sign-up options when using a WebAuthn (passkey) based provider.
|
|
59
|
+
* @interface WebAuthnSignUpSessionOptions
|
|
60
|
+
*/
|
|
61
|
+
export interface WebAuthnSignUpOptions extends WebAuthnSignOptions {
|
|
62
|
+
/**
|
|
63
|
+
* Optional callback to receive progress updates about the sign-up flow.
|
|
64
|
+
* Useful for showing UI feedback such as loading indicators or status messages.
|
|
65
|
+
*/
|
|
66
|
+
onProgress?: SignProgressFn<WebAuthnSignUpProgressStep>;
|
|
67
|
+
/**
|
|
68
|
+
* Options for creating the passkey credential.
|
|
69
|
+
*
|
|
70
|
+
* For example, you can provide a user-friendly display name so the passkey
|
|
71
|
+
* is easier to recognize later.
|
|
72
|
+
*/
|
|
73
|
+
passkey?: CreatePasskeyOptions;
|
|
74
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ActorReadParams, ActorUpdateParams } from '
|
|
1
|
+
import type { ActorReadParams, ActorUpdateParams } from '../../core/types/actor';
|
|
2
|
+
import type { ListParams, ListResults } from '../../core/types/list';
|
|
2
3
|
import type { Doc } from '../types/doc';
|
|
3
|
-
import type { ListParams, ListResults } from '../types/list';
|
|
4
4
|
export declare const getDoc: <D>({ collection, key, ...rest }: {
|
|
5
5
|
collection: string;
|
|
6
6
|
} & ActorReadParams & Pick<Doc<D>, "key">) => Promise<Doc<D> | undefined>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { ReadOptions } from '
|
|
1
|
+
import type { ReadOptions } from '../../core/types/call-options';
|
|
2
|
+
import type { ListParams, ListResults } from '../../core/types/list';
|
|
3
|
+
import type { SatelliteOptions } from '../../core/types/satellite';
|
|
2
4
|
import type { Doc } from '../types/doc';
|
|
3
|
-
import type { ListParams, ListResults } from '../types/list';
|
|
4
|
-
import type { SatelliteOptions } from '../types/satellite';
|
|
5
5
|
/**
|
|
6
6
|
* Retrieves a single document from a collection.
|
|
7
7
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ActorSubclass } from '@dfinity/agent';
|
|
2
2
|
import type { ActorMethod } from '@dfinity/agent/lib/esm/actor';
|
|
3
3
|
import type { IDL } from '@dfinity/candid';
|
|
4
|
-
import type { SatelliteOptions } from '
|
|
4
|
+
import type { SatelliteOptions } from '../../core/types/satellite';
|
|
5
5
|
/**
|
|
6
6
|
* Returns an extended satellite actor instance using the provided IDL factory and satellite options.
|
|
7
7
|
*
|