@authon/js 0.2.1 → 0.3.1
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.ko.md +99 -0
- package/README.md +249 -59
- package/dist/index.cjs +1451 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +82 -2
- package/dist/index.d.ts +82 -2
- package/dist/index.js +1445 -14
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BrandingConfig, AuthonUser, OAuthProviderType } from '@authon/shared';
|
|
1
|
+
import { BrandingConfig, AuthonUser, PasskeyCredential, Web3Wallet, OAuthProviderType, MfaSetupResponse, MfaStatus, Web3Chain, Web3WalletType, Web3NonceResponse, SessionInfo, OrganizationListResponse, CreateOrganizationParams, AuthonOrganization, UpdateOrganizationParams, OrganizationMember, InviteMemberParams, OrganizationInvitation } from '@authon/shared';
|
|
2
2
|
|
|
3
3
|
type OAuthFlowMode = 'auto' | 'popup' | 'redirect';
|
|
4
4
|
interface AuthonConfig {
|
|
@@ -16,9 +16,16 @@ interface AuthonEvents {
|
|
|
16
16
|
signedIn: (user: AuthonUser) => void;
|
|
17
17
|
signedOut: () => void;
|
|
18
18
|
tokenRefreshed: (token: string) => void;
|
|
19
|
+
mfaRequired: (mfaToken: string) => void;
|
|
20
|
+
passkeyRegistered: (credential: PasskeyCredential) => void;
|
|
21
|
+
web3Connected: (wallet: Web3Wallet) => void;
|
|
19
22
|
error: (error: Error) => void;
|
|
20
23
|
}
|
|
21
24
|
type AuthonEventType = keyof AuthonEvents;
|
|
25
|
+
declare class AuthonMfaRequiredError extends Error {
|
|
26
|
+
readonly mfaToken: string;
|
|
27
|
+
constructor(mfaToken: string);
|
|
28
|
+
}
|
|
22
29
|
|
|
23
30
|
declare class Authon {
|
|
24
31
|
private publishableKey;
|
|
@@ -34,6 +41,8 @@ declare class Authon {
|
|
|
34
41
|
getProviders(): Promise<OAuthProviderType[]>;
|
|
35
42
|
openSignIn(): Promise<void>;
|
|
36
43
|
openSignUp(): Promise<void>;
|
|
44
|
+
/** Update theme at runtime without destroying form state */
|
|
45
|
+
setTheme(theme: 'light' | 'dark' | 'auto'): void;
|
|
37
46
|
signInWithOAuth(provider: OAuthProviderType, options?: OAuthSignInOptions): Promise<void>;
|
|
38
47
|
signInWithEmail(email: string, password: string): Promise<AuthonUser>;
|
|
39
48
|
signUpWithEmail(email: string, password: string, meta?: {
|
|
@@ -43,6 +52,61 @@ declare class Authon {
|
|
|
43
52
|
getUser(): AuthonUser | null;
|
|
44
53
|
getToken(): string | null;
|
|
45
54
|
on<K extends AuthonEventType>(event: K, listener: AuthonEvents[K]): () => void;
|
|
55
|
+
setupMfa(): Promise<MfaSetupResponse & {
|
|
56
|
+
qrCodeSvg: string;
|
|
57
|
+
}>;
|
|
58
|
+
verifyMfaSetup(code: string): Promise<void>;
|
|
59
|
+
verifyMfa(mfaToken: string, code: string): Promise<AuthonUser>;
|
|
60
|
+
disableMfa(code: string): Promise<void>;
|
|
61
|
+
getMfaStatus(): Promise<MfaStatus>;
|
|
62
|
+
regenerateBackupCodes(code: string): Promise<string[]>;
|
|
63
|
+
sendMagicLink(email: string): Promise<void>;
|
|
64
|
+
sendEmailOtp(email: string): Promise<void>;
|
|
65
|
+
verifyPasswordless(options: {
|
|
66
|
+
token?: string;
|
|
67
|
+
email?: string;
|
|
68
|
+
code?: string;
|
|
69
|
+
}): Promise<AuthonUser>;
|
|
70
|
+
registerPasskey(name?: string): Promise<PasskeyCredential>;
|
|
71
|
+
authenticateWithPasskey(email?: string): Promise<AuthonUser>;
|
|
72
|
+
listPasskeys(): Promise<PasskeyCredential[]>;
|
|
73
|
+
renamePasskey(passkeyId: string, name: string): Promise<PasskeyCredential>;
|
|
74
|
+
revokePasskey(passkeyId: string): Promise<void>;
|
|
75
|
+
web3GetNonce(address: string, chain: Web3Chain, walletType: Web3WalletType, chainId?: number): Promise<Web3NonceResponse>;
|
|
76
|
+
web3Verify(message: string, signature: string, address: string, chain: Web3Chain, walletType: Web3WalletType): Promise<AuthonUser>;
|
|
77
|
+
listWallets(): Promise<Web3Wallet[]>;
|
|
78
|
+
linkWallet(params: {
|
|
79
|
+
address: string;
|
|
80
|
+
chain: Web3Chain;
|
|
81
|
+
walletType: Web3WalletType;
|
|
82
|
+
chainId?: number;
|
|
83
|
+
message: string;
|
|
84
|
+
signature: string;
|
|
85
|
+
}): Promise<Web3Wallet>;
|
|
86
|
+
unlinkWallet(walletId: string): Promise<void>;
|
|
87
|
+
updateProfile(data: {
|
|
88
|
+
displayName?: string;
|
|
89
|
+
avatarUrl?: string;
|
|
90
|
+
phone?: string;
|
|
91
|
+
publicMetadata?: Record<string, unknown>;
|
|
92
|
+
}): Promise<AuthonUser>;
|
|
93
|
+
listSessions(): Promise<SessionInfo[]>;
|
|
94
|
+
revokeSession(sessionId: string): Promise<void>;
|
|
95
|
+
organizations: {
|
|
96
|
+
list: () => Promise<OrganizationListResponse>;
|
|
97
|
+
create: (params: CreateOrganizationParams) => Promise<AuthonOrganization>;
|
|
98
|
+
get: (orgId: string) => Promise<AuthonOrganization>;
|
|
99
|
+
update: (orgId: string, params: UpdateOrganizationParams) => Promise<AuthonOrganization>;
|
|
100
|
+
delete: (orgId: string) => Promise<void>;
|
|
101
|
+
getMembers: (orgId: string) => Promise<OrganizationMember[]>;
|
|
102
|
+
invite: (orgId: string, params: InviteMemberParams) => Promise<OrganizationInvitation>;
|
|
103
|
+
getInvitations: (orgId: string) => Promise<OrganizationInvitation[]>;
|
|
104
|
+
acceptInvitation: (token: string) => Promise<OrganizationMember>;
|
|
105
|
+
rejectInvitation: (token: string) => Promise<void>;
|
|
106
|
+
removeMember: (orgId: string, memberId: string) => Promise<void>;
|
|
107
|
+
updateMemberRole: (orgId: string, memberId: string, role: string) => Promise<OrganizationMember>;
|
|
108
|
+
leave: (orgId: string) => Promise<void>;
|
|
109
|
+
};
|
|
46
110
|
destroy(): void;
|
|
47
111
|
private emit;
|
|
48
112
|
private ensureInitialized;
|
|
@@ -54,6 +118,16 @@ declare class Authon {
|
|
|
54
118
|
private consumeRedirectResultFromUrl;
|
|
55
119
|
private apiGet;
|
|
56
120
|
private apiPost;
|
|
121
|
+
private apiPostAuth;
|
|
122
|
+
private apiGetAuth;
|
|
123
|
+
private apiPatchAuth;
|
|
124
|
+
private apiDeleteAuth;
|
|
125
|
+
private getWalletAddress;
|
|
126
|
+
private requestWalletSignature;
|
|
127
|
+
private bufferToBase64url;
|
|
128
|
+
private base64urlToBuffer;
|
|
129
|
+
private deserializeCreationOptions;
|
|
130
|
+
private deserializeRequestOptions;
|
|
57
131
|
private parseApiError;
|
|
58
132
|
}
|
|
59
133
|
|
|
@@ -66,4 +140,10 @@ interface ProviderButtonConfig {
|
|
|
66
140
|
}
|
|
67
141
|
declare function getProviderButtonConfig(provider: OAuthProviderType): ProviderButtonConfig;
|
|
68
142
|
|
|
69
|
-
|
|
143
|
+
/**
|
|
144
|
+
* Minimal QR Code SVG generator — byte mode, EC Level L, versions 1–13.
|
|
145
|
+
* Zero dependencies. Produces a standalone SVG string.
|
|
146
|
+
*/
|
|
147
|
+
declare function generateQrSvg(text: string, moduleSize?: number): string;
|
|
148
|
+
|
|
149
|
+
export { Authon, type AuthonConfig, type AuthonEventType, type AuthonEvents, AuthonMfaRequiredError, type OAuthFlowMode, type OAuthSignInOptions, type ProviderButtonConfig, generateQrSvg, getProviderButtonConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BrandingConfig, AuthonUser, OAuthProviderType } from '@authon/shared';
|
|
1
|
+
import { BrandingConfig, AuthonUser, PasskeyCredential, Web3Wallet, OAuthProviderType, MfaSetupResponse, MfaStatus, Web3Chain, Web3WalletType, Web3NonceResponse, SessionInfo, OrganizationListResponse, CreateOrganizationParams, AuthonOrganization, UpdateOrganizationParams, OrganizationMember, InviteMemberParams, OrganizationInvitation } from '@authon/shared';
|
|
2
2
|
|
|
3
3
|
type OAuthFlowMode = 'auto' | 'popup' | 'redirect';
|
|
4
4
|
interface AuthonConfig {
|
|
@@ -16,9 +16,16 @@ interface AuthonEvents {
|
|
|
16
16
|
signedIn: (user: AuthonUser) => void;
|
|
17
17
|
signedOut: () => void;
|
|
18
18
|
tokenRefreshed: (token: string) => void;
|
|
19
|
+
mfaRequired: (mfaToken: string) => void;
|
|
20
|
+
passkeyRegistered: (credential: PasskeyCredential) => void;
|
|
21
|
+
web3Connected: (wallet: Web3Wallet) => void;
|
|
19
22
|
error: (error: Error) => void;
|
|
20
23
|
}
|
|
21
24
|
type AuthonEventType = keyof AuthonEvents;
|
|
25
|
+
declare class AuthonMfaRequiredError extends Error {
|
|
26
|
+
readonly mfaToken: string;
|
|
27
|
+
constructor(mfaToken: string);
|
|
28
|
+
}
|
|
22
29
|
|
|
23
30
|
declare class Authon {
|
|
24
31
|
private publishableKey;
|
|
@@ -34,6 +41,8 @@ declare class Authon {
|
|
|
34
41
|
getProviders(): Promise<OAuthProviderType[]>;
|
|
35
42
|
openSignIn(): Promise<void>;
|
|
36
43
|
openSignUp(): Promise<void>;
|
|
44
|
+
/** Update theme at runtime without destroying form state */
|
|
45
|
+
setTheme(theme: 'light' | 'dark' | 'auto'): void;
|
|
37
46
|
signInWithOAuth(provider: OAuthProviderType, options?: OAuthSignInOptions): Promise<void>;
|
|
38
47
|
signInWithEmail(email: string, password: string): Promise<AuthonUser>;
|
|
39
48
|
signUpWithEmail(email: string, password: string, meta?: {
|
|
@@ -43,6 +52,61 @@ declare class Authon {
|
|
|
43
52
|
getUser(): AuthonUser | null;
|
|
44
53
|
getToken(): string | null;
|
|
45
54
|
on<K extends AuthonEventType>(event: K, listener: AuthonEvents[K]): () => void;
|
|
55
|
+
setupMfa(): Promise<MfaSetupResponse & {
|
|
56
|
+
qrCodeSvg: string;
|
|
57
|
+
}>;
|
|
58
|
+
verifyMfaSetup(code: string): Promise<void>;
|
|
59
|
+
verifyMfa(mfaToken: string, code: string): Promise<AuthonUser>;
|
|
60
|
+
disableMfa(code: string): Promise<void>;
|
|
61
|
+
getMfaStatus(): Promise<MfaStatus>;
|
|
62
|
+
regenerateBackupCodes(code: string): Promise<string[]>;
|
|
63
|
+
sendMagicLink(email: string): Promise<void>;
|
|
64
|
+
sendEmailOtp(email: string): Promise<void>;
|
|
65
|
+
verifyPasswordless(options: {
|
|
66
|
+
token?: string;
|
|
67
|
+
email?: string;
|
|
68
|
+
code?: string;
|
|
69
|
+
}): Promise<AuthonUser>;
|
|
70
|
+
registerPasskey(name?: string): Promise<PasskeyCredential>;
|
|
71
|
+
authenticateWithPasskey(email?: string): Promise<AuthonUser>;
|
|
72
|
+
listPasskeys(): Promise<PasskeyCredential[]>;
|
|
73
|
+
renamePasskey(passkeyId: string, name: string): Promise<PasskeyCredential>;
|
|
74
|
+
revokePasskey(passkeyId: string): Promise<void>;
|
|
75
|
+
web3GetNonce(address: string, chain: Web3Chain, walletType: Web3WalletType, chainId?: number): Promise<Web3NonceResponse>;
|
|
76
|
+
web3Verify(message: string, signature: string, address: string, chain: Web3Chain, walletType: Web3WalletType): Promise<AuthonUser>;
|
|
77
|
+
listWallets(): Promise<Web3Wallet[]>;
|
|
78
|
+
linkWallet(params: {
|
|
79
|
+
address: string;
|
|
80
|
+
chain: Web3Chain;
|
|
81
|
+
walletType: Web3WalletType;
|
|
82
|
+
chainId?: number;
|
|
83
|
+
message: string;
|
|
84
|
+
signature: string;
|
|
85
|
+
}): Promise<Web3Wallet>;
|
|
86
|
+
unlinkWallet(walletId: string): Promise<void>;
|
|
87
|
+
updateProfile(data: {
|
|
88
|
+
displayName?: string;
|
|
89
|
+
avatarUrl?: string;
|
|
90
|
+
phone?: string;
|
|
91
|
+
publicMetadata?: Record<string, unknown>;
|
|
92
|
+
}): Promise<AuthonUser>;
|
|
93
|
+
listSessions(): Promise<SessionInfo[]>;
|
|
94
|
+
revokeSession(sessionId: string): Promise<void>;
|
|
95
|
+
organizations: {
|
|
96
|
+
list: () => Promise<OrganizationListResponse>;
|
|
97
|
+
create: (params: CreateOrganizationParams) => Promise<AuthonOrganization>;
|
|
98
|
+
get: (orgId: string) => Promise<AuthonOrganization>;
|
|
99
|
+
update: (orgId: string, params: UpdateOrganizationParams) => Promise<AuthonOrganization>;
|
|
100
|
+
delete: (orgId: string) => Promise<void>;
|
|
101
|
+
getMembers: (orgId: string) => Promise<OrganizationMember[]>;
|
|
102
|
+
invite: (orgId: string, params: InviteMemberParams) => Promise<OrganizationInvitation>;
|
|
103
|
+
getInvitations: (orgId: string) => Promise<OrganizationInvitation[]>;
|
|
104
|
+
acceptInvitation: (token: string) => Promise<OrganizationMember>;
|
|
105
|
+
rejectInvitation: (token: string) => Promise<void>;
|
|
106
|
+
removeMember: (orgId: string, memberId: string) => Promise<void>;
|
|
107
|
+
updateMemberRole: (orgId: string, memberId: string, role: string) => Promise<OrganizationMember>;
|
|
108
|
+
leave: (orgId: string) => Promise<void>;
|
|
109
|
+
};
|
|
46
110
|
destroy(): void;
|
|
47
111
|
private emit;
|
|
48
112
|
private ensureInitialized;
|
|
@@ -54,6 +118,16 @@ declare class Authon {
|
|
|
54
118
|
private consumeRedirectResultFromUrl;
|
|
55
119
|
private apiGet;
|
|
56
120
|
private apiPost;
|
|
121
|
+
private apiPostAuth;
|
|
122
|
+
private apiGetAuth;
|
|
123
|
+
private apiPatchAuth;
|
|
124
|
+
private apiDeleteAuth;
|
|
125
|
+
private getWalletAddress;
|
|
126
|
+
private requestWalletSignature;
|
|
127
|
+
private bufferToBase64url;
|
|
128
|
+
private base64urlToBuffer;
|
|
129
|
+
private deserializeCreationOptions;
|
|
130
|
+
private deserializeRequestOptions;
|
|
57
131
|
private parseApiError;
|
|
58
132
|
}
|
|
59
133
|
|
|
@@ -66,4 +140,10 @@ interface ProviderButtonConfig {
|
|
|
66
140
|
}
|
|
67
141
|
declare function getProviderButtonConfig(provider: OAuthProviderType): ProviderButtonConfig;
|
|
68
142
|
|
|
69
|
-
|
|
143
|
+
/**
|
|
144
|
+
* Minimal QR Code SVG generator — byte mode, EC Level L, versions 1–13.
|
|
145
|
+
* Zero dependencies. Produces a standalone SVG string.
|
|
146
|
+
*/
|
|
147
|
+
declare function generateQrSvg(text: string, moduleSize?: number): string;
|
|
148
|
+
|
|
149
|
+
export { Authon, type AuthonConfig, type AuthonEventType, type AuthonEvents, AuthonMfaRequiredError, type OAuthFlowMode, type OAuthSignInOptions, type ProviderButtonConfig, generateQrSvg, getProviderButtonConfig };
|