@junobuild/core 3.0.0 → 3.0.1-next-2025-11-08
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/index.js +1 -1
- package/dist/browser/index.js.map +2 -2
- package/dist/node/index.mjs +1 -1
- package/dist/node/index.mjs.map +2 -2
- package/dist/types/auth/providers/_auth-client.providers.d.ts +4 -6
- package/dist/types/auth/providers/google.providers.d.ts +1 -8
- package/dist/types/auth/providers/internet-identity.providers.d.ts +2 -3
- package/dist/types/auth/providers/webauthn.providers.d.ts +1 -8
- package/dist/types/auth/services/_user.services.d.ts +2 -2
- package/dist/types/auth/services/sign-in.services.d.ts +2 -2
- package/dist/types/auth/types/provider.d.ts +43 -9
- package/dist/types/auth/types/user.d.ts +25 -11
- package/package.json +5 -5
- package/dist/types/auth/providers/_auth.providers.d.ts +0 -11
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { type AuthClient } from '@icp-sdk/auth/client';
|
|
2
2
|
import { type AuthClientSignInOptions } from '../types/auth-client';
|
|
3
|
-
import type {
|
|
4
|
-
import type { AuthProvider } from './_auth.providers';
|
|
3
|
+
import type { ProviderWithoutData } from '../types/provider';
|
|
5
4
|
/**
|
|
6
5
|
* Options for signing in with an authentication provider.
|
|
7
6
|
* @interface AuthProviderSignInOptions
|
|
@@ -21,9 +20,8 @@ export interface AuthProviderSignInOptions {
|
|
|
21
20
|
*
|
|
22
21
|
* @abstract
|
|
23
22
|
* @class AuthClientProvider
|
|
24
|
-
* @implements {AuthProvider}
|
|
25
23
|
*/
|
|
26
|
-
export declare abstract class AuthClientProvider
|
|
24
|
+
export declare abstract class AuthClientProvider {
|
|
27
25
|
#private;
|
|
28
26
|
/**
|
|
29
27
|
* The unique identifier of the provider.
|
|
@@ -31,7 +29,7 @@ export declare abstract class AuthClientProvider implements AuthProvider {
|
|
|
31
29
|
* @abstract
|
|
32
30
|
* @type {Provider}
|
|
33
31
|
*/
|
|
34
|
-
abstract get id():
|
|
32
|
+
abstract get id(): ProviderWithoutData;
|
|
35
33
|
/**
|
|
36
34
|
* Returns the sign-in options for the provider.
|
|
37
35
|
*
|
|
@@ -59,7 +57,7 @@ export declare abstract class AuthClientProvider implements AuthProvider {
|
|
|
59
57
|
options?: AuthClientSignInOptions;
|
|
60
58
|
authClient: AuthClient | undefined | null;
|
|
61
59
|
initAuth: (params: {
|
|
62
|
-
provider:
|
|
60
|
+
provider: ProviderWithoutData;
|
|
63
61
|
}) => Promise<void>;
|
|
64
62
|
}): Promise<void>;
|
|
65
63
|
}
|
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
import type { GoogleSignInRedirectOptions } from '../types/google';
|
|
2
|
-
|
|
3
|
-
import type { AuthProvider } from './_auth.providers';
|
|
4
|
-
export declare class GoogleProvider implements AuthProvider {
|
|
5
|
-
/**
|
|
6
|
-
* Gets the identifier of the provider.
|
|
7
|
-
* @returns {Provider} The identifier of the provider is google.
|
|
8
|
-
*/
|
|
9
|
-
get id(): Provider;
|
|
2
|
+
export declare class GoogleProvider {
|
|
10
3
|
/**
|
|
11
4
|
* Initiates a Google sign-in flow.
|
|
12
5
|
*
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import type { AuthClientSignInOptions } from '../types/auth-client';
|
|
2
2
|
import type { InternetIdentityConfig } from '../types/internet-identity';
|
|
3
|
-
import type {
|
|
3
|
+
import type { ProviderWithoutData } from '../types/provider';
|
|
4
4
|
import { AuthClientProvider, type AuthProviderSignInOptions } from './_auth-client.providers';
|
|
5
5
|
/**
|
|
6
6
|
* Internet Identity authentication provider.
|
|
7
7
|
* @class InternetIdentityProvider
|
|
8
|
-
* @implements {AuthProvider}
|
|
9
8
|
*/
|
|
10
9
|
export declare class InternetIdentityProvider extends AuthClientProvider {
|
|
11
10
|
#private;
|
|
@@ -18,7 +17,7 @@ export declare class InternetIdentityProvider extends AuthClientProvider {
|
|
|
18
17
|
* Gets the identifier of the provider.
|
|
19
18
|
* @returns {Provider} The identifier of the provider - `internet_identity`.
|
|
20
19
|
*/
|
|
21
|
-
get id():
|
|
20
|
+
get id(): ProviderWithoutData;
|
|
22
21
|
/**
|
|
23
22
|
* Gets the sign-in options for Internet Identity.
|
|
24
23
|
* @param {Pick<SignInOptions, 'windowed'>} options - The sign-in options.
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
import type { Provider } from '../types/provider';
|
|
2
1
|
import type { User } from '../types/user';
|
|
3
2
|
import { type WebAuthnSignInOptions, type WebAuthnSignUpOptions } from '../types/webauthn';
|
|
4
|
-
|
|
5
|
-
export declare class WebAuthnProvider implements AuthProvider {
|
|
3
|
+
export declare class WebAuthnProvider {
|
|
6
4
|
#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
5
|
/**
|
|
13
6
|
* Signs up a user by creating a new passkey.
|
|
14
7
|
*
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ProviderWithoutData } from '../types/provider';
|
|
2
2
|
import type { User } from '../types/user';
|
|
3
3
|
type UserId = string;
|
|
4
4
|
export declare const initUser: ({ provider }: {
|
|
5
|
-
provider:
|
|
5
|
+
provider: ProviderWithoutData;
|
|
6
6
|
}) => Promise<User>;
|
|
7
7
|
export declare const loadUser: () => Promise<{
|
|
8
8
|
userId: UserId;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SignInOptions } from '../types/auth';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ProviderWithoutData } from '../types/provider';
|
|
3
3
|
/**
|
|
4
4
|
* Initialize the authClient, load or create a new user.
|
|
5
5
|
* Executed on sign-in.
|
|
@@ -7,7 +7,7 @@ import type { Provider } from '../types/provider';
|
|
|
7
7
|
* ℹ️ Exposed for testing purpose only.
|
|
8
8
|
*/
|
|
9
9
|
export declare const createAuth: ({ provider }: {
|
|
10
|
-
provider:
|
|
10
|
+
provider: ProviderWithoutData;
|
|
11
11
|
}) => Promise<void>;
|
|
12
12
|
/**
|
|
13
13
|
* Signs in a user with the specified options.
|
|
@@ -7,6 +7,10 @@ export type DeprecatedNfid = 'nfid';
|
|
|
7
7
|
* @typedef {('internet_identity' | 'nfid' | 'webauthn' | 'google')} Provider
|
|
8
8
|
*/
|
|
9
9
|
export type Provider = 'internet_identity' | DeprecatedNfid | 'webauthn' | 'google';
|
|
10
|
+
/**
|
|
11
|
+
* Subset of authentication providers that do not include any provider-specific metadata.
|
|
12
|
+
*/
|
|
13
|
+
export type ProviderWithoutData = Extract<Provider, 'internet_identity' | DeprecatedNfid> | undefined;
|
|
10
14
|
/**
|
|
11
15
|
* Metadata for WebAuthn authentication.
|
|
12
16
|
* @interface ProviderDataWebAuthn
|
|
@@ -21,16 +25,46 @@ export interface ProviderDataWebAuthn {
|
|
|
21
25
|
aaguid: Uint8Array | number[];
|
|
22
26
|
}
|
|
23
27
|
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* Currently only `webauthn` is supported, but this type
|
|
27
|
-
* can be extended in the future.
|
|
28
|
-
*
|
|
29
|
-
* @interface ProviderData
|
|
28
|
+
* Metadata for OpenID (e.g. Google) authentication.
|
|
29
|
+
* @interface ProviderDataOpenId
|
|
30
30
|
*/
|
|
31
|
-
export interface
|
|
31
|
+
export interface ProviderDataOpenId {
|
|
32
32
|
/**
|
|
33
|
-
*
|
|
33
|
+
* Email address of the authenticated user.
|
|
34
34
|
*/
|
|
35
|
-
|
|
35
|
+
email?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Full name of the authenticated user.
|
|
38
|
+
*/
|
|
39
|
+
name?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Given name of the authenticated user.
|
|
42
|
+
*/
|
|
43
|
+
givenName?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Family name of the authenticated user.
|
|
46
|
+
*/
|
|
47
|
+
familyName?: string;
|
|
48
|
+
/**
|
|
49
|
+
* Profile picture URL of the authenticated user.
|
|
50
|
+
*/
|
|
51
|
+
picture?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Locale of the authenticated user.
|
|
54
|
+
*/
|
|
55
|
+
locale?: string;
|
|
36
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Metadata associated with a given authentication provider.
|
|
59
|
+
*
|
|
60
|
+
* For example:
|
|
61
|
+
* - `'webauthn'` → WebAuthn attestation details
|
|
62
|
+
* - `'openid'` → OpenID profile information (e.g. Google)
|
|
63
|
+
*
|
|
64
|
+
* Other providers have no associated metadata.
|
|
65
|
+
*/
|
|
66
|
+
export type ProviderData<P extends 'webauthn' | 'openid'> = P extends 'webauthn' ? {
|
|
67
|
+
webauthn: ProviderDataWebAuthn;
|
|
68
|
+
} : P extends 'openid' ? {
|
|
69
|
+
openid: ProviderDataOpenId;
|
|
70
|
+
} : never;
|
|
@@ -1,21 +1,35 @@
|
|
|
1
1
|
import type { Doc } from '../../datastore/types/doc';
|
|
2
|
-
import type {
|
|
2
|
+
import type { DeprecatedNfid, ProviderData, ProviderWithoutData } from './provider';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* @interface UserData
|
|
4
|
+
* Data about the signed-in user.
|
|
6
5
|
*/
|
|
7
|
-
export
|
|
6
|
+
export type UserData = {
|
|
8
7
|
/**
|
|
9
|
-
*
|
|
10
|
-
* @type {Provider}
|
|
8
|
+
* Sign-in via WebAuthn.
|
|
11
9
|
*/
|
|
12
|
-
provider
|
|
10
|
+
provider: 'webauthn';
|
|
11
|
+
providerData: ProviderData<'webauthn'>;
|
|
12
|
+
} | {
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
15
|
-
* @type {ProviderData}
|
|
14
|
+
* Sign-in via Google.
|
|
16
15
|
*/
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
provider: 'google';
|
|
17
|
+
providerData: ProviderData<'openid'>;
|
|
18
|
+
} | {
|
|
19
|
+
/**
|
|
20
|
+
* Sign-in via another provider. There is no absolute guarantee that the information can be set by the browser
|
|
21
|
+
* during the sign-in flow, therefore it is optional.
|
|
22
|
+
*/
|
|
23
|
+
provider?: 'internet_identity' | DeprecatedNfid | undefined;
|
|
24
|
+
providerData?: never;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* A simplified version of {@link UserData} for users signed in with providers
|
|
28
|
+
* that don't include any extra metadata.
|
|
29
|
+
*/
|
|
30
|
+
export type UserDataWithoutProviderData = Extract<UserData, {
|
|
31
|
+
provider?: ProviderWithoutData;
|
|
32
|
+
}>;
|
|
19
33
|
/**
|
|
20
34
|
* Type representing a user document.
|
|
21
35
|
* @typedef {Doc<UserData>} User
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@junobuild/core",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.1-next-2025-11-08",
|
|
4
4
|
"description": "JavaScript core client for Juno",
|
|
5
5
|
"author": "David Dal Busco (https://daviddalbusco.com)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -59,8 +59,8 @@
|
|
|
59
59
|
"@junobuild/utils": "*"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
|
-
"@dfinity/utils": "
|
|
63
|
-
"@icp-sdk/auth": "
|
|
64
|
-
"@icp-sdk/core": "
|
|
62
|
+
"@dfinity/utils": "*",
|
|
63
|
+
"@icp-sdk/auth": "*",
|
|
64
|
+
"@icp-sdk/core": "*"
|
|
65
65
|
}
|
|
66
|
-
}
|
|
66
|
+
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { Provider } from '../types/provider';
|
|
2
|
-
/**
|
|
3
|
-
* Common traits for all authentication providers
|
|
4
|
-
* @interface AuthProvider
|
|
5
|
-
*/
|
|
6
|
-
export interface AuthProvider {
|
|
7
|
-
/**
|
|
8
|
-
* The unique identifier of the provider.
|
|
9
|
-
*/
|
|
10
|
-
readonly id: Provider;
|
|
11
|
-
}
|