w3pk 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/dist/index.d.mts +19 -28
- package/dist/index.d.ts +19 -28
- package/dist/index.js +1 -35
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -35
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -3
package/dist/index.d.mts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
interface UserInfo {
|
|
5
5
|
id: string;
|
|
6
6
|
username: string;
|
|
7
|
+
displayName: string;
|
|
7
8
|
ethereumAddress: string;
|
|
8
9
|
}
|
|
9
10
|
interface WalletInfo {
|
|
@@ -70,22 +71,13 @@ interface Web3PasskeyConfig {
|
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
/**
|
|
73
|
-
*
|
|
74
|
+
* Main Web3Passkey SDK class
|
|
74
75
|
*/
|
|
75
76
|
|
|
76
77
|
interface AuthResult {
|
|
77
78
|
verified: boolean;
|
|
78
|
-
user?:
|
|
79
|
-
id: string;
|
|
80
|
-
username: string;
|
|
81
|
-
ethereumAddress: string;
|
|
82
|
-
};
|
|
79
|
+
user?: UserInfo;
|
|
83
80
|
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Main Web3Passkey SDK class
|
|
87
|
-
*/
|
|
88
|
-
|
|
89
81
|
declare class Web3Passkey {
|
|
90
82
|
private config;
|
|
91
83
|
private apiClient;
|
|
@@ -99,6 +91,7 @@ declare class Web3Passkey {
|
|
|
99
91
|
private saveAuthState;
|
|
100
92
|
private clearAuthState;
|
|
101
93
|
private notifyAuthStateChange;
|
|
94
|
+
private createUserInfo;
|
|
102
95
|
/**
|
|
103
96
|
* Generate a new BIP39 wallet
|
|
104
97
|
* @returns Wallet info with mnemonic (user MUST backup)
|
|
@@ -110,23 +103,22 @@ declare class Web3Passkey {
|
|
|
110
103
|
hasWallet(): Promise<boolean>;
|
|
111
104
|
/**
|
|
112
105
|
* Register a new user with WebAuthn
|
|
106
|
+
* Handles the complete registration flow internally
|
|
107
|
+
* Automatically generates wallet if not provided
|
|
108
|
+
*
|
|
113
109
|
* @param username Username for the account
|
|
114
|
-
* @param ethereumAddress Ethereum address
|
|
115
|
-
* @param mnemonic BIP39 mnemonic
|
|
116
|
-
* @
|
|
117
|
-
* @param challenge Challenge used in registration
|
|
110
|
+
* @param ethereumAddress Optional: Ethereum address (will generate if not provided)
|
|
111
|
+
* @param mnemonic Optional: BIP39 mnemonic (will generate if not provided)
|
|
112
|
+
* @returns Object containing ethereumAddress and mnemonic (only if generated)
|
|
118
113
|
*/
|
|
119
114
|
register(options: {
|
|
120
115
|
username: string;
|
|
116
|
+
ethereumAddress?: string;
|
|
117
|
+
mnemonic?: string;
|
|
118
|
+
}): Promise<{
|
|
121
119
|
ethereumAddress: string;
|
|
122
|
-
mnemonic
|
|
123
|
-
|
|
124
|
-
challenge: string;
|
|
125
|
-
}): Promise<void>;
|
|
126
|
-
/**
|
|
127
|
-
* Authenticate with Ethereum address
|
|
128
|
-
*/
|
|
129
|
-
authenticate(ethereumAddress: string): Promise<AuthResult>;
|
|
120
|
+
mnemonic?: string;
|
|
121
|
+
}>;
|
|
130
122
|
/**
|
|
131
123
|
* Authenticate without username (usernameless flow)
|
|
132
124
|
*/
|
|
@@ -137,12 +129,11 @@ declare class Web3Passkey {
|
|
|
137
129
|
logout(): void;
|
|
138
130
|
/**
|
|
139
131
|
* Sign a message with encrypted wallet
|
|
140
|
-
*
|
|
132
|
+
* Handles fresh WebAuthn authentication internally
|
|
133
|
+
*
|
|
141
134
|
* @param message Message to sign
|
|
142
|
-
* @param credentialId WebAuthn credential ID (from fresh auth)
|
|
143
|
-
* @param challenge Challenge from fresh auth
|
|
144
135
|
*/
|
|
145
|
-
signMessage(message: string
|
|
136
|
+
signMessage(message: string): Promise<string>;
|
|
146
137
|
/**
|
|
147
138
|
* Check if user is authenticated
|
|
148
139
|
*/
|
|
@@ -168,4 +159,4 @@ declare class Web3Passkey {
|
|
|
168
159
|
|
|
169
160
|
declare function createWeb3Passkey(config: Web3PasskeyConfig): Web3Passkey;
|
|
170
161
|
|
|
171
|
-
export { ApiError,
|
|
162
|
+
export { ApiError, AuthenticationError, CryptoError, RegistrationError, StorageError, type UserInfo, WalletError, type WalletInfo, Web3Passkey, type Web3PasskeyConfig, Web3PasskeyError, createWeb3Passkey, createWeb3Passkey as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
interface UserInfo {
|
|
5
5
|
id: string;
|
|
6
6
|
username: string;
|
|
7
|
+
displayName: string;
|
|
7
8
|
ethereumAddress: string;
|
|
8
9
|
}
|
|
9
10
|
interface WalletInfo {
|
|
@@ -70,22 +71,13 @@ interface Web3PasskeyConfig {
|
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
/**
|
|
73
|
-
*
|
|
74
|
+
* Main Web3Passkey SDK class
|
|
74
75
|
*/
|
|
75
76
|
|
|
76
77
|
interface AuthResult {
|
|
77
78
|
verified: boolean;
|
|
78
|
-
user?:
|
|
79
|
-
id: string;
|
|
80
|
-
username: string;
|
|
81
|
-
ethereumAddress: string;
|
|
82
|
-
};
|
|
79
|
+
user?: UserInfo;
|
|
83
80
|
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Main Web3Passkey SDK class
|
|
87
|
-
*/
|
|
88
|
-
|
|
89
81
|
declare class Web3Passkey {
|
|
90
82
|
private config;
|
|
91
83
|
private apiClient;
|
|
@@ -99,6 +91,7 @@ declare class Web3Passkey {
|
|
|
99
91
|
private saveAuthState;
|
|
100
92
|
private clearAuthState;
|
|
101
93
|
private notifyAuthStateChange;
|
|
94
|
+
private createUserInfo;
|
|
102
95
|
/**
|
|
103
96
|
* Generate a new BIP39 wallet
|
|
104
97
|
* @returns Wallet info with mnemonic (user MUST backup)
|
|
@@ -110,23 +103,22 @@ declare class Web3Passkey {
|
|
|
110
103
|
hasWallet(): Promise<boolean>;
|
|
111
104
|
/**
|
|
112
105
|
* Register a new user with WebAuthn
|
|
106
|
+
* Handles the complete registration flow internally
|
|
107
|
+
* Automatically generates wallet if not provided
|
|
108
|
+
*
|
|
113
109
|
* @param username Username for the account
|
|
114
|
-
* @param ethereumAddress Ethereum address
|
|
115
|
-
* @param mnemonic BIP39 mnemonic
|
|
116
|
-
* @
|
|
117
|
-
* @param challenge Challenge used in registration
|
|
110
|
+
* @param ethereumAddress Optional: Ethereum address (will generate if not provided)
|
|
111
|
+
* @param mnemonic Optional: BIP39 mnemonic (will generate if not provided)
|
|
112
|
+
* @returns Object containing ethereumAddress and mnemonic (only if generated)
|
|
118
113
|
*/
|
|
119
114
|
register(options: {
|
|
120
115
|
username: string;
|
|
116
|
+
ethereumAddress?: string;
|
|
117
|
+
mnemonic?: string;
|
|
118
|
+
}): Promise<{
|
|
121
119
|
ethereumAddress: string;
|
|
122
|
-
mnemonic
|
|
123
|
-
|
|
124
|
-
challenge: string;
|
|
125
|
-
}): Promise<void>;
|
|
126
|
-
/**
|
|
127
|
-
* Authenticate with Ethereum address
|
|
128
|
-
*/
|
|
129
|
-
authenticate(ethereumAddress: string): Promise<AuthResult>;
|
|
120
|
+
mnemonic?: string;
|
|
121
|
+
}>;
|
|
130
122
|
/**
|
|
131
123
|
* Authenticate without username (usernameless flow)
|
|
132
124
|
*/
|
|
@@ -137,12 +129,11 @@ declare class Web3Passkey {
|
|
|
137
129
|
logout(): void;
|
|
138
130
|
/**
|
|
139
131
|
* Sign a message with encrypted wallet
|
|
140
|
-
*
|
|
132
|
+
* Handles fresh WebAuthn authentication internally
|
|
133
|
+
*
|
|
141
134
|
* @param message Message to sign
|
|
142
|
-
* @param credentialId WebAuthn credential ID (from fresh auth)
|
|
143
|
-
* @param challenge Challenge from fresh auth
|
|
144
135
|
*/
|
|
145
|
-
signMessage(message: string
|
|
136
|
+
signMessage(message: string): Promise<string>;
|
|
146
137
|
/**
|
|
147
138
|
* Check if user is authenticated
|
|
148
139
|
*/
|
|
@@ -168,4 +159,4 @@ declare class Web3Passkey {
|
|
|
168
159
|
|
|
169
160
|
declare function createWeb3Passkey(config: Web3PasskeyConfig): Web3Passkey;
|
|
170
161
|
|
|
171
|
-
export { ApiError,
|
|
162
|
+
export { ApiError, AuthenticationError, CryptoError, RegistrationError, StorageError, type UserInfo, WalletError, type WalletInfo, Web3Passkey, type Web3PasskeyConfig, Web3PasskeyError, createWeb3Passkey, createWeb3Passkey as default };
|