@fourt/sdk 1.1.7 → 1.2.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.cjs +238 -120
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +60 -40
- package/dist/index.d.ts +60 -40
- package/dist/index.js +240 -122
- package/dist/index.js.map +1 -1
- package/package.json +14 -15
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { getWebAuthnAttestation, TSignedRequest, TurnkeyClient } from '@turnkey/
|
|
|
3
3
|
import * as viem_account_abstraction from 'viem/account-abstraction';
|
|
4
4
|
import { Hex } from '../types/misc.js';
|
|
5
5
|
import * as viem from 'viem';
|
|
6
|
-
import { LocalAccount, Client, SignableMessage, Hex as Hex$1, TypedData, TypedDataDefinition, SerializeTransactionFn, TransactionSerializable, IsNarrowable, TransactionSerialized, GetTransactionType } from 'viem';
|
|
6
|
+
import { LocalAccount, Client, Transport, Chain, JsonRpcAccount, SignableMessage, Hex as Hex$1, TypedData, TypedDataDefinition, SerializeTransactionFn, TransactionSerializable, IsNarrowable, TransactionSerialized, GetTransactionType } from 'viem';
|
|
7
7
|
import { toLightSmartAccount } from 'permissionless/accounts';
|
|
8
8
|
|
|
9
9
|
declare enum SessionType {
|
|
@@ -16,9 +16,6 @@ declare enum SessionType {
|
|
|
16
16
|
*/
|
|
17
17
|
declare class SessionStore {
|
|
18
18
|
private readonly _store;
|
|
19
|
-
/**
|
|
20
|
-
* Initializes a new instance of the `SessionStore` class by creating a new `zustand`store with the initial state.
|
|
21
|
-
*/
|
|
22
19
|
constructor();
|
|
23
20
|
/**
|
|
24
21
|
* Gets the type from the session state.
|
|
@@ -128,7 +125,7 @@ type AuthenticationServiceEndpoints = [
|
|
|
128
125
|
};
|
|
129
126
|
Response: {
|
|
130
127
|
user: User;
|
|
131
|
-
token
|
|
128
|
+
token?: string;
|
|
132
129
|
};
|
|
133
130
|
},
|
|
134
131
|
{
|
|
@@ -160,13 +157,30 @@ type AuthenticationServiceEndpoints = [
|
|
|
160
157
|
};
|
|
161
158
|
},
|
|
162
159
|
{
|
|
163
|
-
Route: 'v1/oauth/init';
|
|
160
|
+
Route: '/v1/oauth/init';
|
|
164
161
|
Body: {
|
|
165
162
|
provider: string;
|
|
166
163
|
};
|
|
167
164
|
Response: {
|
|
168
165
|
url: string;
|
|
169
166
|
};
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
Route: '/v1/refresh';
|
|
170
|
+
Body: {};
|
|
171
|
+
Response: {
|
|
172
|
+
token: string;
|
|
173
|
+
};
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
Route: '/v1/logout';
|
|
177
|
+
Body: {};
|
|
178
|
+
Response: {};
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
Route: '/v1/me';
|
|
182
|
+
Body: {};
|
|
183
|
+
Response: User;
|
|
170
184
|
}
|
|
171
185
|
];
|
|
172
186
|
|
|
@@ -184,20 +198,24 @@ declare abstract class SignerClient {
|
|
|
184
198
|
protected readonly _turnkeyClient: TurnkeyClient;
|
|
185
199
|
protected readonly _configuration: Required<SignerClientConstructorParams['configuration']>;
|
|
186
200
|
protected readonly _sessionStore: SessionStore;
|
|
187
|
-
private
|
|
201
|
+
private _refreshPromise?;
|
|
202
|
+
private _refreshTimer?;
|
|
188
203
|
constructor({ stamper, configuration: { apiUrl, paymasterRpcUrl, ...requiredConfiguration }, }: SignerClientConstructorParams);
|
|
189
|
-
logout(): void;
|
|
190
204
|
get configuration(): Required<SignerClientConfiguration>;
|
|
191
|
-
|
|
192
|
-
|
|
205
|
+
getUser(): Promise<User>;
|
|
206
|
+
isLoggedIn(): Promise<boolean>;
|
|
207
|
+
getToken(): Promise<string>;
|
|
208
|
+
private _isTokenExpired;
|
|
209
|
+
logout(): Promise<void>;
|
|
210
|
+
signRawMessage<Into extends string>(msg: string): Promise<Into>;
|
|
193
211
|
protected set stamper(stamper: TurnkeyClient['stamper']);
|
|
194
212
|
protected get stamper(): TurnkeyClient['stamper'];
|
|
195
|
-
protected get sessionStore(): SessionStore;
|
|
196
|
-
signRawMessage<Into extends string>(msg: string): Promise<Into>;
|
|
197
|
-
getToken(): string | undefined;
|
|
198
213
|
protected lookUpUser(email: string): Promise<string | null>;
|
|
199
214
|
protected whoAmI(subOrgId?: string): Promise<void>;
|
|
200
215
|
protected request<Route extends AuthenticationServiceRoutes>(route: Route, body?: AuthenticationServiceBody<Route>): Promise<AuthenticationServiceResponse<Route>>;
|
|
216
|
+
protected _scheduleRefresh(token: string): void;
|
|
217
|
+
private _refreshToken;
|
|
218
|
+
private _getCookie;
|
|
201
219
|
}
|
|
202
220
|
|
|
203
221
|
type WebauthnSignInParams = {
|
|
@@ -246,13 +264,14 @@ declare class WebSignerClient extends SignerClient {
|
|
|
246
264
|
* @param {WebSignerClientConstructorParams} params params for the constructor
|
|
247
265
|
*/
|
|
248
266
|
constructor({ configuration, webauthn, iframe, oauth, }: WebSignerClientConstructorParams);
|
|
249
|
-
signRawMessage<Into extends string>(msg: string): Promise<Into>;
|
|
250
267
|
logout(): Promise<void>;
|
|
268
|
+
signRawMessage<Into extends string>(msg: string): Promise<Into>;
|
|
251
269
|
/**
|
|
252
|
-
*
|
|
270
|
+
* Get the pre-filled URL for initiating oauth with a specific provider.
|
|
253
271
|
*
|
|
272
|
+
* @param {string} provider provider for which we are getting the URL, currently google or apple
|
|
254
273
|
*/
|
|
255
|
-
|
|
274
|
+
getOAuthInitUrl(provider: string): Promise<string>;
|
|
256
275
|
/**
|
|
257
276
|
* Signs in a user with webauthn.
|
|
258
277
|
*
|
|
@@ -266,18 +285,22 @@ declare class WebSignerClient extends SignerClient {
|
|
|
266
285
|
*/
|
|
267
286
|
emailAuth(params: EmailInitializeAuthParams): Promise<void>;
|
|
268
287
|
getIframePublicKey(): Promise<string>;
|
|
269
|
-
/**
|
|
270
|
-
* Signs in a user with email.
|
|
271
|
-
*
|
|
272
|
-
* @param {EmailInitializeAuthParams} params params for the sign in
|
|
273
|
-
*/
|
|
274
|
-
private _signInWithEmail;
|
|
275
288
|
/**
|
|
276
289
|
* Completes the authentication process with a credential bundle.
|
|
277
290
|
*
|
|
278
291
|
* @param {CompleteAuthWithBundleParams} params params for the completion of the auth process
|
|
279
292
|
*/
|
|
280
293
|
completeAuthWithBundle({ bundle, subOrgId, sessionType, }: CompleteAuthWithBundleParams): Promise<void>;
|
|
294
|
+
/**
|
|
295
|
+
* Checks for an existing session and if exists, updates the stamper accordingly.
|
|
296
|
+
*/
|
|
297
|
+
private _updateStamper;
|
|
298
|
+
/**
|
|
299
|
+
* Signs in a user with email.
|
|
300
|
+
*
|
|
301
|
+
* @param {EmailInitializeAuthParams} params params for the sign in
|
|
302
|
+
*/
|
|
303
|
+
private _signInWithEmail;
|
|
281
304
|
/**
|
|
282
305
|
* Creates a passkey account using the webauthn stamper.
|
|
283
306
|
*
|
|
@@ -298,12 +321,6 @@ declare class WebSignerClient extends SignerClient {
|
|
|
298
321
|
private _createAccount;
|
|
299
322
|
private _webauthnGenerateAttestation;
|
|
300
323
|
private _initIframeStamper;
|
|
301
|
-
/**
|
|
302
|
-
* Get the pre-filled URL for initiating oauth with a specific provider.
|
|
303
|
-
*
|
|
304
|
-
* @param {string} provider provider for which we are getting the URL, currently google or apple
|
|
305
|
-
*/
|
|
306
|
-
getOAuthInitUrl(provider: string): Promise<string>;
|
|
307
324
|
}
|
|
308
325
|
|
|
309
326
|
/**
|
|
@@ -426,20 +443,21 @@ declare class UserModule {
|
|
|
426
443
|
*/
|
|
427
444
|
constructor(_webSignerClient: WebSignerClient);
|
|
428
445
|
/**
|
|
429
|
-
*
|
|
430
|
-
*
|
|
431
|
-
* @returns {User | undefined} user information.
|
|
446
|
+
* Retrieves information for the authenticated user.
|
|
447
|
+
* Assumes a user is already logged in, otherwise it will throw an error.
|
|
432
448
|
*/
|
|
433
|
-
|
|
434
|
-
/**
|
|
435
|
-
*
|
|
436
|
-
* @returns {string | undefined} user token.
|
|
449
|
+
getInfo(): Promise<User>;
|
|
450
|
+
/**
|
|
451
|
+
* Checks if a user is currently logged in to the fourt.io SDK.
|
|
437
452
|
*/
|
|
438
|
-
|
|
453
|
+
isLoggedIn(): Promise<boolean>;
|
|
454
|
+
/**
|
|
455
|
+
* Generates an access token with a lifespan of 15 minutes.
|
|
456
|
+
* Assumes a user is already logged in, otherwise it will throw an error.
|
|
457
|
+
*/
|
|
458
|
+
getToken(): Promise<string>;
|
|
439
459
|
/**
|
|
440
460
|
* Logs out the user.
|
|
441
|
-
*
|
|
442
|
-
* @returns {void}
|
|
443
461
|
*/
|
|
444
462
|
logout(): Promise<void>;
|
|
445
463
|
}
|
|
@@ -448,7 +466,7 @@ type CcipRequestReturnType = Hex;
|
|
|
448
466
|
|
|
449
467
|
type CurrentUserToLightSmartAccountParams = {
|
|
450
468
|
owner: LocalAccount;
|
|
451
|
-
client: Client
|
|
469
|
+
client: Client<Transport, Chain | undefined, JsonRpcAccount | LocalAccount | undefined>;
|
|
452
470
|
};
|
|
453
471
|
declare class ViemModule {
|
|
454
472
|
private readonly _signerClient;
|
|
@@ -465,6 +483,7 @@ declare class ViemModule {
|
|
|
465
483
|
request?: (parameters: viem.CcipRequestParameters) => Promise<CcipRequestReturnType>;
|
|
466
484
|
} | undefined;
|
|
467
485
|
chain: undefined;
|
|
486
|
+
experimental_blockTag?: viem.BlockTag | undefined;
|
|
468
487
|
key: string;
|
|
469
488
|
name: string;
|
|
470
489
|
pollingInterval: number;
|
|
@@ -484,6 +503,7 @@ declare class ViemModule {
|
|
|
484
503
|
cacheTime?: undefined;
|
|
485
504
|
ccipRead?: undefined;
|
|
486
505
|
chain?: undefined;
|
|
506
|
+
experimental_blockTag?: undefined;
|
|
487
507
|
key?: undefined;
|
|
488
508
|
name?: undefined;
|
|
489
509
|
pollingInterval?: undefined;
|
|
@@ -491,7 +511,7 @@ declare class ViemModule {
|
|
|
491
511
|
transport?: undefined;
|
|
492
512
|
type?: undefined;
|
|
493
513
|
uid?: undefined;
|
|
494
|
-
} & viem.ExactPartial<Pick<viem.PublicActions<viem.HttpTransport, undefined, undefined>, "call" | "createContractEventFilter" | "createEventFilter" | "estimateContractGas" | "estimateGas" | "getBlock" | "getBlockNumber" | "
|
|
514
|
+
} & viem.ExactPartial<Pick<viem.PublicActions<viem.HttpTransport<undefined, false>, undefined, undefined>, "getChainId" | "prepareTransactionRequest" | "sendRawTransaction" | "call" | "createContractEventFilter" | "createEventFilter" | "estimateContractGas" | "estimateGas" | "getBlock" | "getBlockNumber" | "getContractEvents" | "getEnsText" | "getFilterChanges" | "getGasPrice" | "getLogs" | "getTransaction" | "getTransactionCount" | "getTransactionReceipt" | "readContract" | "simulateContract" | "uninstallFilter" | "watchBlockNumber" | "watchContractEvent"> & Pick<viem.WalletActions<undefined, undefined>, "sendTransaction" | "writeContract">>>(fn: (client: Client<viem.HttpTransport<undefined, false>, undefined, undefined, viem.PaymasterRpcSchema, viem_account_abstraction.PaymasterActions>) => client) => Client<viem.HttpTransport<undefined, false>, undefined, undefined, viem.PaymasterRpcSchema, { [K in keyof client]: client[K]; } & viem_account_abstraction.PaymasterActions>;
|
|
495
515
|
}>;
|
|
496
516
|
signMessage(msg: SignableMessage): Promise<Hex$1>;
|
|
497
517
|
signTypedData<TTypedData extends TypedData | Record<string, unknown>, TPrimaryType extends keyof TTypedData | 'EIP712Domain' = keyof TTypedData>(params: TypedDataDefinition<TTypedData, TPrimaryType>): Promise<Hex$1>;
|