@authon/js 0.2.0 → 0.3.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.ko.md +190 -0
- package/README.md +408 -51
- package/dist/index.cjs +782 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +79 -2
- package/dist/index.d.ts +79 -2
- package/dist/index.js +780 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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;
|
|
@@ -31,6 +38,7 @@ declare class Authon {
|
|
|
31
38
|
private providerFlowModes;
|
|
32
39
|
private initialized;
|
|
33
40
|
constructor(publishableKey: string, config?: AuthonConfig);
|
|
41
|
+
getProviders(): Promise<OAuthProviderType[]>;
|
|
34
42
|
openSignIn(): Promise<void>;
|
|
35
43
|
openSignUp(): Promise<void>;
|
|
36
44
|
signInWithOAuth(provider: OAuthProviderType, options?: OAuthSignInOptions): Promise<void>;
|
|
@@ -42,6 +50,61 @@ declare class Authon {
|
|
|
42
50
|
getUser(): AuthonUser | null;
|
|
43
51
|
getToken(): string | null;
|
|
44
52
|
on<K extends AuthonEventType>(event: K, listener: AuthonEvents[K]): () => void;
|
|
53
|
+
setupMfa(): Promise<MfaSetupResponse & {
|
|
54
|
+
qrCodeSvg: string;
|
|
55
|
+
}>;
|
|
56
|
+
verifyMfaSetup(code: string): Promise<void>;
|
|
57
|
+
verifyMfa(mfaToken: string, code: string): Promise<AuthonUser>;
|
|
58
|
+
disableMfa(code: string): Promise<void>;
|
|
59
|
+
getMfaStatus(): Promise<MfaStatus>;
|
|
60
|
+
regenerateBackupCodes(code: string): Promise<string[]>;
|
|
61
|
+
sendMagicLink(email: string): Promise<void>;
|
|
62
|
+
sendEmailOtp(email: string): Promise<void>;
|
|
63
|
+
verifyPasswordless(options: {
|
|
64
|
+
token?: string;
|
|
65
|
+
email?: string;
|
|
66
|
+
code?: string;
|
|
67
|
+
}): Promise<AuthonUser>;
|
|
68
|
+
registerPasskey(name?: string): Promise<PasskeyCredential>;
|
|
69
|
+
authenticateWithPasskey(email?: string): Promise<AuthonUser>;
|
|
70
|
+
listPasskeys(): Promise<PasskeyCredential[]>;
|
|
71
|
+
renamePasskey(passkeyId: string, name: string): Promise<PasskeyCredential>;
|
|
72
|
+
revokePasskey(passkeyId: string): Promise<void>;
|
|
73
|
+
web3GetNonce(address: string, chain: Web3Chain, walletType: Web3WalletType, chainId?: number): Promise<Web3NonceResponse>;
|
|
74
|
+
web3Verify(message: string, signature: string, address: string, chain: Web3Chain, walletType: Web3WalletType): Promise<AuthonUser>;
|
|
75
|
+
listWallets(): Promise<Web3Wallet[]>;
|
|
76
|
+
linkWallet(params: {
|
|
77
|
+
address: string;
|
|
78
|
+
chain: Web3Chain;
|
|
79
|
+
walletType: Web3WalletType;
|
|
80
|
+
chainId?: number;
|
|
81
|
+
message: string;
|
|
82
|
+
signature: string;
|
|
83
|
+
}): Promise<Web3Wallet>;
|
|
84
|
+
unlinkWallet(walletId: string): Promise<void>;
|
|
85
|
+
updateProfile(data: {
|
|
86
|
+
displayName?: string;
|
|
87
|
+
avatarUrl?: string;
|
|
88
|
+
phone?: string;
|
|
89
|
+
publicMetadata?: Record<string, unknown>;
|
|
90
|
+
}): Promise<AuthonUser>;
|
|
91
|
+
listSessions(): Promise<SessionInfo[]>;
|
|
92
|
+
revokeSession(sessionId: string): Promise<void>;
|
|
93
|
+
organizations: {
|
|
94
|
+
list: () => Promise<OrganizationListResponse>;
|
|
95
|
+
create: (params: CreateOrganizationParams) => Promise<AuthonOrganization>;
|
|
96
|
+
get: (orgId: string) => Promise<AuthonOrganization>;
|
|
97
|
+
update: (orgId: string, params: UpdateOrganizationParams) => Promise<AuthonOrganization>;
|
|
98
|
+
delete: (orgId: string) => Promise<void>;
|
|
99
|
+
getMembers: (orgId: string) => Promise<OrganizationMember[]>;
|
|
100
|
+
invite: (orgId: string, params: InviteMemberParams) => Promise<OrganizationInvitation>;
|
|
101
|
+
getInvitations: (orgId: string) => Promise<OrganizationInvitation[]>;
|
|
102
|
+
acceptInvitation: (token: string) => Promise<OrganizationMember>;
|
|
103
|
+
rejectInvitation: (token: string) => Promise<void>;
|
|
104
|
+
removeMember: (orgId: string, memberId: string) => Promise<void>;
|
|
105
|
+
updateMemberRole: (orgId: string, memberId: string, role: string) => Promise<OrganizationMember>;
|
|
106
|
+
leave: (orgId: string) => Promise<void>;
|
|
107
|
+
};
|
|
45
108
|
destroy(): void;
|
|
46
109
|
private emit;
|
|
47
110
|
private ensureInitialized;
|
|
@@ -53,6 +116,14 @@ declare class Authon {
|
|
|
53
116
|
private consumeRedirectResultFromUrl;
|
|
54
117
|
private apiGet;
|
|
55
118
|
private apiPost;
|
|
119
|
+
private apiPostAuth;
|
|
120
|
+
private apiGetAuth;
|
|
121
|
+
private apiPatchAuth;
|
|
122
|
+
private apiDeleteAuth;
|
|
123
|
+
private bufferToBase64url;
|
|
124
|
+
private base64urlToBuffer;
|
|
125
|
+
private deserializeCreationOptions;
|
|
126
|
+
private deserializeRequestOptions;
|
|
56
127
|
private parseApiError;
|
|
57
128
|
}
|
|
58
129
|
|
|
@@ -65,4 +136,10 @@ interface ProviderButtonConfig {
|
|
|
65
136
|
}
|
|
66
137
|
declare function getProviderButtonConfig(provider: OAuthProviderType): ProviderButtonConfig;
|
|
67
138
|
|
|
68
|
-
|
|
139
|
+
/**
|
|
140
|
+
* Minimal QR Code SVG generator — byte mode, EC Level L, versions 1–13.
|
|
141
|
+
* Zero dependencies. Produces a standalone SVG string.
|
|
142
|
+
*/
|
|
143
|
+
declare function generateQrSvg(text: string, moduleSize?: number): string;
|
|
144
|
+
|
|
145
|
+
export { Authon, type AuthonConfig, type AuthonEventType, type AuthonEvents, AuthonMfaRequiredError, type OAuthFlowMode, type OAuthSignInOptions, type ProviderButtonConfig, generateQrSvg, getProviderButtonConfig };
|