@openfort/openfort-js 0.7.7 → 0.7.8
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.cjs +312 -98
- package/dist/index.d.ts +260 -15
- package/dist/index.js +312 -99
- package/package.json +2 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SessionKey, AuthResponse, OAuthProvider as OAuthProvider$1, InitializeOAuthOptions as InitializeOAuthOptions$1, InitAuthResponse,
|
|
1
|
+
import { SessionKey, AuthResponse, AuthPlayerResponse as AuthPlayerResponse$1, OAuthProvider as OAuthProvider$1, InitializeOAuthOptions as InitializeOAuthOptions$1, InitAuthResponse, ThirdPartyOAuthProvider as ThirdPartyOAuthProvider$1, TokenType as TokenType$1, SIWEInitResponse, Auth, TransactionIntentResponse as TransactionIntentResponse$1, SessionResponse as SessionResponse$1, EmbeddedState as EmbeddedState$1, SDKOverrides as SDKOverrides$1 } from 'types';
|
|
2
2
|
import { SDKConfiguration as SDKConfiguration$1 } from 'config';
|
|
3
3
|
import { Provider as Provider$1 } from 'evm/types';
|
|
4
4
|
|
|
@@ -76,20 +76,55 @@ declare class Openfort {
|
|
|
76
76
|
private readonly iframeManager;
|
|
77
77
|
private readonly openfortEventEmitter;
|
|
78
78
|
constructor(sdkConfiguration: SDKConfiguration$1);
|
|
79
|
+
/**
|
|
80
|
+
* Logs the user out by flushing the signer and removing credentials.
|
|
81
|
+
*/
|
|
79
82
|
logout(): Promise<void>;
|
|
83
|
+
/**
|
|
84
|
+
* Returns an Ethereum provider using the configured signer.
|
|
85
|
+
*
|
|
86
|
+
* @param options - Configuration options for the Ethereum provider.
|
|
87
|
+
* @returns A Provider instance.
|
|
88
|
+
* @throws {OpenfortError} If the signer is not an EmbeddedSigner.
|
|
89
|
+
*/
|
|
80
90
|
getEthereumProvider(options?: {
|
|
81
91
|
announceProvider: boolean;
|
|
82
92
|
policy?: string;
|
|
83
93
|
}): Provider$1;
|
|
84
|
-
|
|
94
|
+
/**
|
|
95
|
+
* Configures a session key and returns the session key details.
|
|
96
|
+
*
|
|
97
|
+
* @returns A SessionKey object containing the address and registration status.
|
|
98
|
+
*/
|
|
85
99
|
configureSessionKey(): SessionKey;
|
|
100
|
+
/**
|
|
101
|
+
* Configures an embedded signer.
|
|
102
|
+
*
|
|
103
|
+
* @param chainId - The chain ID for the embedded signer.
|
|
104
|
+
* @param shieldAuthentication - Shield authentication details.
|
|
105
|
+
* @param recoveryPassword - Recovery password.
|
|
106
|
+
*/
|
|
86
107
|
configureEmbeddedSigner(chainId?: number, shieldAuthentication?: ShieldAuthentication, recoveryPassword?: string): Promise<void>;
|
|
87
|
-
|
|
88
|
-
|
|
108
|
+
/**
|
|
109
|
+
* Logs in a user with email and password.
|
|
110
|
+
*
|
|
111
|
+
* @param email - User's email.
|
|
112
|
+
* @param password - User's password.
|
|
113
|
+
* @returns An AuthResponse object containing authentication details.
|
|
114
|
+
*/
|
|
115
|
+
loginWithEmailPassword({ email, password }: {
|
|
89
116
|
email: string;
|
|
90
117
|
password: string;
|
|
91
118
|
}): Promise<AuthResponse>;
|
|
92
|
-
|
|
119
|
+
/**
|
|
120
|
+
* Signs up a new user with email and password.
|
|
121
|
+
*
|
|
122
|
+
* @param email - User's email.
|
|
123
|
+
* @param password - User's password.
|
|
124
|
+
* @param options - Additional options for the sign-up process.
|
|
125
|
+
* @returns An AuthResponse object containing authentication details.
|
|
126
|
+
*/
|
|
127
|
+
signUpWithEmailPassword({ email, password, options }: {
|
|
93
128
|
email: string;
|
|
94
129
|
password: string;
|
|
95
130
|
options?: {
|
|
@@ -98,63 +133,273 @@ declare class Openfort {
|
|
|
98
133
|
};
|
|
99
134
|
};
|
|
100
135
|
}): Promise<AuthResponse>;
|
|
136
|
+
/**
|
|
137
|
+
* Links an email and password to an existing account using an authentication token.
|
|
138
|
+
*
|
|
139
|
+
* @param email - User's email.
|
|
140
|
+
* @param password - User's password.
|
|
141
|
+
* @param authToken - Authentication token.
|
|
142
|
+
* @returns An AuthPlayerResponse object.
|
|
143
|
+
*/
|
|
144
|
+
linkEmailPassword({ email, password, authToken }: {
|
|
145
|
+
email: string;
|
|
146
|
+
password: string;
|
|
147
|
+
authToken: string;
|
|
148
|
+
}): Promise<AuthPlayerResponse$1>;
|
|
149
|
+
/**
|
|
150
|
+
* Unlinks an email and password from an existing account using an authentication token.
|
|
151
|
+
*
|
|
152
|
+
* @param email - User's email.
|
|
153
|
+
* @param authToken - Authentication token.
|
|
154
|
+
* @returns An AuthPlayerResponse object.
|
|
155
|
+
*/
|
|
156
|
+
unlinkEmailPassword({ email, authToken }: {
|
|
157
|
+
email: string;
|
|
158
|
+
authToken: string;
|
|
159
|
+
}): Promise<AuthPlayerResponse$1>;
|
|
160
|
+
/**
|
|
161
|
+
* Requests an email verification link.
|
|
162
|
+
*
|
|
163
|
+
* @param email - User's email.
|
|
164
|
+
* @param redirectUrl - Redirect URL after verification.
|
|
165
|
+
*/
|
|
101
166
|
requestEmailVerification({ email, redirectUrl }: {
|
|
102
167
|
email: string;
|
|
103
168
|
redirectUrl: string;
|
|
104
169
|
}): Promise<void>;
|
|
170
|
+
/**
|
|
171
|
+
* Resets the user's password.
|
|
172
|
+
*
|
|
173
|
+
* @param email - User's email.
|
|
174
|
+
* @param password - New password.
|
|
175
|
+
* @param state - Verification state.
|
|
176
|
+
*/
|
|
105
177
|
resetPassword({ email, password, state }: {
|
|
106
178
|
email: string;
|
|
107
179
|
password: string;
|
|
108
180
|
state: string;
|
|
109
181
|
}): Promise<void>;
|
|
182
|
+
/**
|
|
183
|
+
* Requests a password reset link.
|
|
184
|
+
*
|
|
185
|
+
* @param email - User's email.
|
|
186
|
+
* @param redirectUrl - Redirect URL after resetting password.
|
|
187
|
+
*/
|
|
110
188
|
requestResetPassword({ email, redirectUrl }: {
|
|
111
189
|
email: string;
|
|
112
190
|
redirectUrl: string;
|
|
113
191
|
}): Promise<void>;
|
|
192
|
+
/**
|
|
193
|
+
* Verifies the user's email.
|
|
194
|
+
*
|
|
195
|
+
* @param email - User's email.
|
|
196
|
+
* @param state - Verification state.
|
|
197
|
+
*/
|
|
114
198
|
verifyEmail({ email, state }: {
|
|
115
199
|
email: string;
|
|
116
200
|
state: string;
|
|
117
201
|
}): Promise<void>;
|
|
202
|
+
/**
|
|
203
|
+
* Initializes an OAuth authentication process.
|
|
204
|
+
*
|
|
205
|
+
* @param provider - OAuth provider.
|
|
206
|
+
* @param options - Additional options for initialization.
|
|
207
|
+
* @returns An InitAuthResponse object.
|
|
208
|
+
*/
|
|
118
209
|
initOAuth({ provider, options }: {
|
|
119
210
|
provider: OAuthProvider$1;
|
|
120
211
|
options?: InitializeOAuthOptions$1;
|
|
121
212
|
}): Promise<InitAuthResponse>;
|
|
122
|
-
|
|
213
|
+
/**
|
|
214
|
+
* Initializes an OAuth linking process.
|
|
215
|
+
*
|
|
216
|
+
* @param provider - OAuth provider.
|
|
217
|
+
* @param authToken - Authentication token.
|
|
218
|
+
* @param options - Additional options for initialization.
|
|
219
|
+
* @returns An InitAuthResponse object.
|
|
220
|
+
*/
|
|
221
|
+
initLinkOAuth({ provider, authToken, options }: {
|
|
123
222
|
provider: OAuthProvider$1;
|
|
124
|
-
|
|
223
|
+
authToken: string;
|
|
125
224
|
options?: InitializeOAuthOptions$1;
|
|
126
225
|
}): Promise<InitAuthResponse>;
|
|
226
|
+
/**
|
|
227
|
+
* Unlinks an OAuth provider from the account.
|
|
228
|
+
*
|
|
229
|
+
* @param provider - OAuth provider.
|
|
230
|
+
* @param authToken - Authentication token.
|
|
231
|
+
* @returns An AuthPlayerResponse object.
|
|
232
|
+
*/
|
|
233
|
+
unlinkOAuth({ provider, authToken }: {
|
|
234
|
+
provider: OAuthProvider$1;
|
|
235
|
+
authToken: string;
|
|
236
|
+
}): Promise<AuthPlayerResponse$1>;
|
|
237
|
+
/**
|
|
238
|
+
* Polls for OAuth authentication completion.
|
|
239
|
+
*
|
|
240
|
+
* @param key - OAuth polling key.
|
|
241
|
+
* @returns An AuthResponse object.
|
|
242
|
+
*/
|
|
127
243
|
poolOAuth(key: string): Promise<AuthResponse>;
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
244
|
+
/**
|
|
245
|
+
* Authenticates using a third-party OAuth provider.
|
|
246
|
+
*
|
|
247
|
+
* @param provider - Third-party OAuth provider.
|
|
248
|
+
* @param token - OAuth token.
|
|
249
|
+
* @param tokenType - Type of the OAuth token.
|
|
250
|
+
* @returns An AuthPlayerResponse object.
|
|
251
|
+
*/
|
|
131
252
|
authenticateWithThirdPartyProvider({ provider, token, tokenType }: {
|
|
132
253
|
provider: ThirdPartyOAuthProvider$1;
|
|
133
254
|
token: string;
|
|
134
255
|
tokenType: TokenType$1;
|
|
135
256
|
}): Promise<AuthPlayerResponse$1>;
|
|
257
|
+
/**
|
|
258
|
+
* Initializes Sign-In with Ethereum (SIWE).
|
|
259
|
+
*
|
|
260
|
+
* @param address - Ethereum address.
|
|
261
|
+
* @returns A SIWEInitResponse object.
|
|
262
|
+
*/
|
|
263
|
+
initSIWE({ address }: {
|
|
264
|
+
address: string;
|
|
265
|
+
}): Promise<SIWEInitResponse>;
|
|
266
|
+
/**
|
|
267
|
+
* Authenticates using Sign-In with Ethereum (SIWE).
|
|
268
|
+
*
|
|
269
|
+
* @param signature - SIWE signature.
|
|
270
|
+
* @param message - SIWE message.
|
|
271
|
+
* @param walletClientType - Wallet client type.
|
|
272
|
+
* @param connectorType - Connector type.
|
|
273
|
+
* @returns An AuthResponse object.
|
|
274
|
+
*/
|
|
136
275
|
authenticateWithSIWE({ signature, message, walletClientType, connectorType, }: {
|
|
137
276
|
signature: string;
|
|
138
277
|
message: string;
|
|
139
278
|
walletClientType: string;
|
|
140
279
|
connectorType: string;
|
|
141
280
|
}): Promise<AuthResponse>;
|
|
281
|
+
/**
|
|
282
|
+
* Links a wallet using SIWE.
|
|
283
|
+
*
|
|
284
|
+
* @param signature - SIWE signature.
|
|
285
|
+
* @param message - SIWE message.
|
|
286
|
+
* @param walletClientType - Wallet client type.
|
|
287
|
+
* @param connectorType - Connector type.
|
|
288
|
+
* @param authToken - Authentication token.
|
|
289
|
+
* @returns An AuthPlayerResponse object.
|
|
290
|
+
*/
|
|
291
|
+
linkWallet({ signature, message, walletClientType, connectorType, authToken, }: {
|
|
292
|
+
signature: string;
|
|
293
|
+
message: string;
|
|
294
|
+
walletClientType: string;
|
|
295
|
+
connectorType: string;
|
|
296
|
+
authToken: string;
|
|
297
|
+
}): Promise<AuthPlayerResponse$1>;
|
|
298
|
+
/**
|
|
299
|
+
* Unlinks a wallet.
|
|
300
|
+
*
|
|
301
|
+
* @param address - Wallet address.
|
|
302
|
+
* @param authToken - Authentication token.
|
|
303
|
+
* @returns An AuthPlayerResponse object.
|
|
304
|
+
*/
|
|
305
|
+
unlinkWallet({ address, authToken }: {
|
|
306
|
+
address: string;
|
|
307
|
+
authToken: string;
|
|
308
|
+
}): Promise<AuthPlayerResponse$1>;
|
|
309
|
+
/**
|
|
310
|
+
* Stores authentication credentials.
|
|
311
|
+
*
|
|
312
|
+
* @param auth - Authentication details.
|
|
313
|
+
*/
|
|
142
314
|
storeCredentials(auth: Auth): void;
|
|
315
|
+
/**
|
|
316
|
+
* Sends a signature transaction intent request.
|
|
317
|
+
*
|
|
318
|
+
* @param transactionIntentId - Transaction intent ID.
|
|
319
|
+
* @param userOperationHash - User operation hash.
|
|
320
|
+
* @param signature - Transaction signature.
|
|
321
|
+
* @returns A TransactionIntentResponse object.
|
|
322
|
+
* @throws {OpenfortError} If no userOperationHash or signature is provided.
|
|
323
|
+
*/
|
|
143
324
|
sendSignatureTransactionIntentRequest(transactionIntentId: string, userOperationHash?: string | null, signature?: string | null): Promise<TransactionIntentResponse$1>;
|
|
325
|
+
/**
|
|
326
|
+
* Signs a message.
|
|
327
|
+
*
|
|
328
|
+
* @param message - Message to sign.
|
|
329
|
+
* @param options - Additional options for signing.
|
|
330
|
+
* @returns The signature.
|
|
331
|
+
* @throws {OpenfortError} If no signer is configured.
|
|
332
|
+
*/
|
|
144
333
|
signMessage(message: string | Uint8Array, options?: {
|
|
145
334
|
hashMessage?: boolean;
|
|
146
335
|
arrayifyMessage?: boolean;
|
|
147
336
|
}): Promise<string>;
|
|
337
|
+
/**
|
|
338
|
+
* Signs typed data.
|
|
339
|
+
*
|
|
340
|
+
* @param domain - EIP-712 domain.
|
|
341
|
+
* @param types - Typed data types.
|
|
342
|
+
* @param value - Typed data value.
|
|
343
|
+
* @returns The signature.
|
|
344
|
+
* @throws {OpenfortError} If no signer is configured.
|
|
345
|
+
*/
|
|
148
346
|
signTypedData(domain: TypedDataDomain, types: Record<string, Array<TypedDataField>>, value: Record<string, any>): Promise<string>;
|
|
347
|
+
/**
|
|
348
|
+
* Sends a session registration request.
|
|
349
|
+
*
|
|
350
|
+
* @param sessionId - Session ID.
|
|
351
|
+
* @param signature - Session signature.
|
|
352
|
+
* @param optimistic - Whether the request is optimistic.
|
|
353
|
+
* @returns A SessionResponse object.
|
|
354
|
+
* @throws {OpenfortError} If no signer is configured.
|
|
355
|
+
* @throws {OpenfortError} If the signer is not a SessionSigner.
|
|
356
|
+
*/
|
|
149
357
|
sendRegisterSessionRequest(sessionId: string, signature: string, optimistic?: boolean): Promise<SessionResponse$1>;
|
|
150
|
-
|
|
151
|
-
|
|
358
|
+
/**
|
|
359
|
+
* Gets the embedded state of the current session.
|
|
360
|
+
*
|
|
361
|
+
* @returns The embedded state.
|
|
362
|
+
*/
|
|
152
363
|
getEmbeddedState(): EmbeddedState$1;
|
|
153
|
-
|
|
364
|
+
/**
|
|
365
|
+
* Gets the current access token.
|
|
366
|
+
*
|
|
367
|
+
* @returns The access token, or null if not available.
|
|
368
|
+
*/
|
|
154
369
|
getAccessToken(): string | null;
|
|
155
|
-
|
|
370
|
+
/**
|
|
371
|
+
* Retrieves the user details.
|
|
372
|
+
*
|
|
373
|
+
* @returns An AuthPlayerResponse object.
|
|
374
|
+
* @throws {OpenfortError} If no access token is found.
|
|
375
|
+
*/
|
|
156
376
|
getUser(): Promise<AuthPlayerResponse$1>;
|
|
377
|
+
/**
|
|
378
|
+
* Validates and refreshes the access token if needed.
|
|
379
|
+
*/
|
|
157
380
|
validateAndRefreshToken(): Promise<void>;
|
|
381
|
+
private credentialsProvided;
|
|
382
|
+
private recoverSigner;
|
|
383
|
+
private waitSigner;
|
|
384
|
+
private newEmbeddedSigner;
|
|
385
|
+
private flushSigner;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
declare enum OpenfortErrorType {
|
|
389
|
+
AUTHENTICATION_ERROR = "AUTHENTICATION_ERROR",
|
|
390
|
+
INVALID_CONFIGURATION = "INVALID_CONFIGURATION",
|
|
391
|
+
NOT_LOGGED_IN_ERROR = "NOT_LOGGED_IN_ERROR",
|
|
392
|
+
REFRESH_TOKEN_ERROR = "REFRESH_TOKEN_ERROR",
|
|
393
|
+
USER_REGISTRATION_ERROR = "USER_REGISTRATION_ERROR",
|
|
394
|
+
LOGOUT_ERROR = "LOGOUT_ERROR",
|
|
395
|
+
OPERATION_NOT_SUPPORTED_ERROR = "OPERATION_NOT_SUPPORTED_ERROR",
|
|
396
|
+
MISSING_SESSION_SIGNER_ERROR = "MISSING_SESSION_SIGNER_ERROR",
|
|
397
|
+
MISSING_EMBEDDED_SIGNER_ERROR = "MISSING_EMBEDDED_SIGNER_ERROR",
|
|
398
|
+
MISSING_SIGNER_ERROR = "MISSING_SIGNER_ERROR"
|
|
399
|
+
}
|
|
400
|
+
declare class OpenfortError extends Error {
|
|
401
|
+
type: OpenfortErrorType;
|
|
402
|
+
constructor(message: string, type: OpenfortErrorType);
|
|
158
403
|
}
|
|
159
404
|
|
|
160
405
|
declare enum ShieldAuthProvider {
|
|
@@ -594,4 +839,4 @@ declare class SDKConfiguration {
|
|
|
594
839
|
});
|
|
595
840
|
}
|
|
596
841
|
|
|
597
|
-
export { AuthPlayerResponse, AuthType, BasicAuthProvider, EmbeddedState, InitializeOAuthOptions, OAuthProvider, OpenfortConfiguration, Provider, SDKConfiguration, SDKOverrides, SessionResponse, ShieldAuthOptions, ShieldAuthentication, ShieldConfiguration, ShieldOptions, ThirdPartyOAuthProvider, TokenType, TransactionIntentResponse, TypedDataDomain, TypedDataField, Openfort as default };
|
|
842
|
+
export { AuthPlayerResponse, AuthType, BasicAuthProvider, EmbeddedState, InitializeOAuthOptions, OAuthProvider, OpenfortConfiguration, OpenfortError, Provider, SDKConfiguration, SDKOverrides, SessionResponse, ShieldAuthOptions, ShieldAuthentication, ShieldConfiguration, ShieldOptions, ThirdPartyOAuthProvider, TokenType, TransactionIntentResponse, TypedDataDomain, TypedDataField, Openfort as default };
|