@fourt/sdk 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.cjs +13 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +13 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -182,6 +182,10 @@ var SignerClient = class {
|
|
|
182
182
|
};
|
|
183
183
|
this._sessionStore = new SessionStore();
|
|
184
184
|
}
|
|
185
|
+
logout() {
|
|
186
|
+
this._user = void 0;
|
|
187
|
+
this.sessionStore.clearAll();
|
|
188
|
+
}
|
|
185
189
|
get user() {
|
|
186
190
|
if (this._user) return this._user;
|
|
187
191
|
if (!this.sessionStore.token) {
|
|
@@ -290,8 +294,7 @@ var SignerClient = class {
|
|
|
290
294
|
if (error) {
|
|
291
295
|
switch (error.kind) {
|
|
292
296
|
case "UnauthorizedError": {
|
|
293
|
-
this.
|
|
294
|
-
this.sessionStore.clearAll();
|
|
297
|
+
this.logout();
|
|
295
298
|
throw new UnauthorizedError({ message: error.message });
|
|
296
299
|
}
|
|
297
300
|
case "NotFoundError": {
|
|
@@ -558,6 +561,14 @@ var UserModule = class {
|
|
|
558
561
|
get info() {
|
|
559
562
|
return this._webSignerClient.user;
|
|
560
563
|
}
|
|
564
|
+
/**
|
|
565
|
+
* Logs out the user.
|
|
566
|
+
*
|
|
567
|
+
* @returns {void}
|
|
568
|
+
*/
|
|
569
|
+
logout() {
|
|
570
|
+
return this._webSignerClient.logout();
|
|
571
|
+
}
|
|
561
572
|
};
|
|
562
573
|
|
|
563
574
|
// src/index.ts
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/signer/web.ts","../src/signer/index.ts","../src/errors/SDKError.ts","../src/errors/UnauthorizedError.ts","../src/errors/NotFoundError.ts","../src/errors/GenericError.ts","../src/errors/UnauthenticatedError.ts","../src/errors/BadRequestError.ts","../src/session/index.ts","../src/types/Routes.ts","../src/lib/base64.ts","../src/lib/bytes.ts","../src/third-party/viem.ts","../src/modules/auth/passkeys.ts","../src/modules/auth/index.ts","../src/modules/user/index.ts"],"sourcesContent":["import { SignerClientConstructorParams } from './signer/index.js'\nimport {\n WebauthnSignInParams,\n WebSignerClient,\n WebSignerClientConstructorParams,\n} from './signer/web.js'\nimport { ViemModule } from './third-party/viem.js'\nimport { AuthModule, UserModule } from './modules/index.js'\n\ntype FourtWebSignerConstructorParams = {\n configuration: SignerClientConstructorParams['configuration']\n auth: Pick<WebSignerClientConstructorParams, 'webauthn'>\n}\n\n/**\n * A client for interacting with the Fourt Web Signer.\n */\nclass FourtWebSigner {\n private readonly _webSignerClient: WebSignerClient\n private readonly _modules: {\n viem: ViemModule\n auth: AuthModule\n user: UserModule\n }\n\n /**\n * Initializes a new instance of the `FourtWebSigner` class.\n * Sets up the underlying modules.\n *\n *\n * @example\n * ```ts\n * const fourtWebSigner = new FourtWebSigner({\n * auth: {\n * webauthn: {\n * rpId: 'localhost',\n * },\n * },\n * configuration: {\n * apiKey: '927d603c-6775-4210-8e13-8904ca985e78',\n * },\n * })\n * ```\n *\n * @param {FourtWebSignerConstructorParams} params the required parameters to initialize the client\n */\n constructor({\n configuration,\n auth: { webauthn },\n }: FourtWebSignerConstructorParams) {\n this._webSignerClient = new WebSignerClient({\n configuration,\n webauthn,\n })\n\n this._modules = {\n viem: new ViemModule(this._webSignerClient),\n auth: new AuthModule(this._webSignerClient),\n user: new UserModule(this._webSignerClient),\n }\n }\n\n /**\n * A module for interacting with the Viem library.\n */\n get viem() {\n return this._modules.viem\n }\n\n /**\n * A module for interacting with the authentication methods.\n */\n get auth() {\n return this._modules.auth\n }\n\n /**\n * A module for interacting with the user methods.\n */\n get user() {\n return this._modules.user\n }\n}\n\nexport { FourtWebSigner }\n","import { WebauthnStamper } from '@turnkey/webauthn-stamper'\nimport {\n type SignerClientInheritedConstructorParams,\n SignerClient,\n} from './index.js'\nimport { LibBase64 } from '../lib/base64.js'\nimport { LibBytes } from '../lib/bytes.js'\nimport { getWebAuthnAttestation } from '@turnkey/http'\n\ntype WebauthnSignInParams = {\n email: string\n}\n\ntype WebSignerClientConstructorParams = SignerClientInheritedConstructorParams<{\n webauthn: {\n rpId: string\n }\n}>\n\ntype CreateAccountParams = {\n method: 'webauthn'\n email: string\n}\n\n/**\n * A signer client for web applications.\n */\nclass WebSignerClient extends SignerClient {\n private readonly _stampers: {\n webauthn: WebauthnStamper\n }\n\n /**\n * Initializes a new instance of the `WebSignerClient` class.\n *\n * @param {WebSignerClientConstructorParams} params params for the constructor\n */\n constructor({ configuration, webauthn }: WebSignerClientConstructorParams) {\n const webauthnStamper = new WebauthnStamper({ rpId: webauthn.rpId })\n\n super({\n stamper: webauthnStamper,\n configuration: configuration,\n })\n\n this._stampers = {\n webauthn: webauthnStamper,\n }\n }\n\n /**\n * Signs in a user with webauthn.\n *\n * @param {WebauthnSignInParams} params params for the sign in\n */\n async webauthnSignIn({ email }: WebauthnSignInParams) {\n const existingUserSubOrgId = await this.lookUpUser(email)\n\n if (!existingUserSubOrgId) {\n await this._createAccount({ method: 'webauthn', email })\n } else {\n await this.whoAmI(existingUserSubOrgId)\n\n // We should assure that the user and its credentialId are set\n if (!this.user || !this.user.credentialId) {\n return\n }\n\n this.stamper = this._stampers.webauthn\n this._stampers.webauthn.allowCredentials = [\n {\n id: LibBase64.toBuffer(this.user.credentialId),\n type: 'public-key',\n transports: ['internal', 'usb'],\n },\n ]\n }\n }\n\n private async _createAccount(params: CreateAccountParams) {\n const { challenge, attestation } = await this._webauthnGenerateAttestation(\n params.email,\n )\n\n const {\n token,\n user: { id, email, subOrgId, walletAddress, salt, smartAccountAddress },\n } = await this.request('/v1/signup', {\n passkey: {\n challenge: LibBase64.fromBuffer(challenge),\n attestation,\n },\n email: params.email,\n })\n\n this.user = {\n id,\n email,\n subOrgId,\n walletAddress,\n salt,\n smartAccountAddress,\n credentialId: attestation.credentialId,\n }\n\n this._sessionStore.token = token\n }\n\n private async _webauthnGenerateAttestation(email: string) {\n const challenge = LibBytes.generateRandomBuffer()\n const authenticatorUserId = LibBytes.generateRandomBuffer()\n\n const attestation = await getWebAuthnAttestation({\n publicKey: {\n authenticatorSelection: {\n residentKey: 'preferred',\n requireResidentKey: false,\n userVerification: 'preferred',\n },\n challenge,\n rp: {\n id: window.location.hostname,\n name: window.location.hostname,\n },\n pubKeyCredParams: [\n {\n type: 'public-key',\n alg: -7,\n },\n {\n type: 'public-key',\n alg: -257,\n },\n ],\n user: {\n id: authenticatorUserId,\n name: email,\n displayName: email,\n },\n },\n })\n\n return { challenge, attestation, authenticatorUserId }\n }\n}\n\nexport { WebSignerClient }\nexport type {\n WebSignerClientConstructorParams,\n WebauthnSignInParams,\n CreateAccountParams,\n}\n","import { TurnkeyClient } from '@turnkey/http'\nimport {\n BadRequestError,\n GenericError,\n NotFoundError,\n UnauthorizedError,\n} from '../errors/index.js'\nimport { SDKError } from '../errors/SDKError.js'\nimport { SessionStore } from '../session/index.js'\nimport { User } from '../types/entities.js'\nimport { APIResponse } from '../types/rest.js'\nimport {\n AuthenticationServiceBody,\n AuthenticationServiceResponse,\n AuthenticationServiceRoutes,\n ROUTE_METHOD_MAP,\n} from '../types/Routes.js'\nimport { jwtDecode, JwtPayload } from 'jwt-decode'\nimport { isPast, secondsToMilliseconds } from 'date-fns'\n\ntype SignerClientConfiguration = {\n apiKey: string\n apiUrl?: string\n}\n\ntype SignerClientConstructorParams = {\n stamper: TurnkeyClient['stamper']\n configuration: SignerClientConfiguration\n}\n\ntype SignerClientInheritedConstructorParams<\n Extended extends Record<string, unknown>,\n> = Pick<SignerClientConstructorParams, 'configuration'> & Extended\n\nabstract class SignerClient {\n protected readonly _turnkeyClient: TurnkeyClient\n protected readonly _configuration: Required<SignerClientConfiguration>\n protected readonly _sessionStore: SessionStore\n\n private _user?: User\n\n constructor({\n stamper,\n configuration: { apiUrl, ...requiredConfiguration },\n }: SignerClientConstructorParams) {\n this._turnkeyClient = new TurnkeyClient(\n { baseUrl: 'https://api.turnkey.com' },\n stamper,\n )\n\n this._configuration = {\n ...requiredConfiguration,\n apiUrl: apiUrl ?? 'https://auth.api.dev.fourt.io/',\n }\n\n this._sessionStore = new SessionStore()\n }\n\n get user(): User | undefined {\n if (this._user) return this._user\n\n // Check if there's a token\n if (!this.sessionStore.token) {\n this.sessionStore.clearAll()\n return undefined\n }\n\n const decodedToken = jwtDecode<JwtPayload>(this.sessionStore.token)\n // Check if the token has expired\n if (\n decodedToken.exp &&\n isPast(new Date(secondsToMilliseconds(decodedToken.exp)))\n ) {\n this.sessionStore.clearAll()\n return undefined\n }\n\n if (this.sessionStore.user) this._user = this.sessionStore.user\n\n return this._user\n }\n\n protected set user(value: User | undefined) {\n this._user = value\n }\n\n protected set stamper(stamper: TurnkeyClient['stamper']) {\n this._turnkeyClient.stamper = stamper\n }\n\n protected get stamper(): TurnkeyClient['stamper'] {\n return this._turnkeyClient.stamper\n }\n\n protected get sessionStore(): SessionStore {\n return this._sessionStore\n }\n\n async signRawMessage<Into extends string>(msg: string): Promise<Into> {\n if (!this._user) {\n throw new UnauthorizedError({\n message: 'SignerClient must be authenticated to sign a message',\n })\n }\n\n const stampedRequest = await this._turnkeyClient.stampSignRawPayload({\n organizationId: this._user.subOrgId,\n type: 'ACTIVITY_TYPE_SIGN_RAW_PAYLOAD_V2',\n timestampMs: Date.now().toString(),\n parameters: {\n encoding: 'PAYLOAD_ENCODING_HEXADECIMAL',\n hashFunction: 'HASH_FUNCTION_NO_OP',\n payload: msg,\n signWith: this._user.walletAddress,\n },\n })\n\n const { signature } = await this.request('/v1/sign', {\n stampedRequest,\n })\n\n return <Into>signature\n }\n\n protected async lookUpUser(email: string): Promise<string | null> {\n try {\n const { subOrgId } = await this.request('/v1/lookup', { email })\n return subOrgId\n } catch (error) {\n if (!(error instanceof SDKError)) throw error\n\n const sdkError: SDKError = error\n\n switch (sdkError.constructor.name) {\n case NotFoundError.name: {\n return null\n }\n default: {\n throw sdkError\n }\n }\n }\n }\n\n protected async whoAmI(subOrgId?: string) {\n const orgId = subOrgId || this._user?.subOrgId\n\n if (!orgId) throw new BadRequestError({ message: 'No orgId provided' })\n\n const stampedRequest = await this._turnkeyClient.stampGetWhoami({\n organizationId: orgId,\n })\n\n const { user, token } = await this.request('/v1/signin', {\n stampedRequest,\n })\n\n const credentialId = (() => {\n try {\n return JSON.parse(stampedRequest?.stamp.stampHeaderValue)\n .credentialId as string\n } catch (e) {\n return undefined\n }\n })()\n\n this._user = {\n ...user,\n credentialId: credentialId,\n }\n\n this.sessionStore.user = this.user!\n this.sessionStore.token = token\n }\n\n protected async request<Route extends AuthenticationServiceRoutes>(\n route: Route,\n body?: AuthenticationServiceBody<Route>,\n ): Promise<AuthenticationServiceResponse<Route>> {\n const url = new URL(`${route}`, this._configuration.apiUrl)\n const token = this.sessionStore.token\n\n const headers: Record<string, string> = {\n 'Content-Type': 'application/json',\n 'X-FOURT-KEY': this._configuration.apiKey,\n }\n\n // Add Authorization header if token exists\n if (token) {\n headers['Authorization'] = `Bearer ${token}`\n }\n\n const response = await fetch(url, {\n method: ROUTE_METHOD_MAP[route],\n body: JSON.stringify(body),\n headers,\n credentials: 'include',\n })\n\n const { data, error } = (await response.json()) as APIResponse<\n AuthenticationServiceResponse<Route>\n >\n\n if (error) {\n switch (error.kind) {\n case 'UnauthorizedError': {\n // TODO: workaround! this need to be cleaned up and moved into the web signer\n this.user = undefined\n this.sessionStore.clearAll()\n throw new UnauthorizedError({ message: error.message })\n }\n case 'NotFoundError': {\n throw new NotFoundError({ message: error.message })\n }\n case 'BadRequestError': {\n throw new BadRequestError({ message: error.message })\n }\n default: {\n throw new GenericError({ message: error.message })\n }\n }\n }\n\n return { ...data } as AuthenticationServiceResponse<Route>\n }\n}\n\nexport { SignerClient }\nexport type {\n SignerClientConstructorParams,\n SignerClientInheritedConstructorParams,\n}\n","type SDKErrorProps = {\n message: string\n}\n\nabstract class SDKError extends Error {\n private readonly _props: SDKErrorProps\n\n constructor(message: string, props: SDKErrorProps) {\n super(message)\n this._props = props\n }\n\n get message() {\n return this._props.message\n }\n}\n\nexport { SDKError }\nexport type { SDKErrorProps }\n","import { SDKErrorProps, SDKError } from './SDKError.js'\n\nclass UnauthorizedError extends SDKError {\n constructor(props: SDKErrorProps) {\n super(UnauthorizedError.name, props)\n }\n}\n\nexport { UnauthorizedError }\n","import { SDKErrorProps, SDKError } from './SDKError.js'\n\nclass NotFoundError extends SDKError {\n constructor(props: SDKErrorProps) {\n super(NotFoundError.name, props)\n }\n}\n\nexport { NotFoundError }\n","import { SDKErrorProps, SDKError } from './SDKError.js'\n\nclass GenericError extends SDKError {\n constructor(props: SDKErrorProps) {\n super(GenericError.name, props)\n }\n}\n\nexport { GenericError }\n","import { SDKErrorProps, SDKError } from './SDKError.js'\n\nclass UnauthenticatedError extends SDKError {\n constructor(props: SDKErrorProps) {\n super(UnauthenticatedError.name, props)\n }\n}\n\nexport { UnauthenticatedError }\n","import { SDKErrorProps, SDKError } from './SDKError.js'\n\nclass BadRequestError extends SDKError {\n constructor(props: SDKErrorProps) {\n super(BadRequestError.name, props)\n }\n}\n\nexport { BadRequestError }\n","import { createStore, type StoreApi } from 'zustand'\nimport { createJSONStorage, persist } from 'zustand/middleware'\nimport { User } from '../types/entities.js'\n\n/**\n * The state of the session.\n */\ntype SessionState = {\n user?: User\n expirationDate?: Date\n token?: string\n}\n\n/**\n * A store for the session state.\n */\nclass SessionStore {\n private readonly _store: StoreApi<SessionState>\n\n /**\n * Initializes a new instance of the `SessionStore` class by creating a new `zustand`store with the initial state.\n */\n constructor() {\n this._store = createStore<SessionState>()(\n persist(this._getInitialState, {\n name: 'fourt.io-signer-session',\n storage: createJSONStorage<SessionState>(() => localStorage),\n }),\n )\n }\n\n /**\n * Gets the token from the session state.\n *\n * @returns {string | undefined} the token.\n */\n get token(): string | undefined {\n return this._store.getState().token\n }\n\n /**\n * Sets the token in the session state.\n *\n * @param {string} token the token to set.\n */\n set token(token: string) {\n this._store.setState({ token })\n }\n\n /**\n * Gets the user from the session state.\n *\n * @returns {User | undefined} the user.\n */\n get user(): User | undefined {\n return this._store.getState().user\n }\n\n /**\n * Sets the user in the session state.\n *\n * @param {User} user the user to set.\n */\n set user(user: User) {\n this._store.setState({ ...this._store.getState(), user })\n }\n\n /**\n * Clears the user from the session state.\n */\n clearUser() {\n this._store.setState({ ...this._store.getState(), user: undefined })\n }\n\n /**\n * Clears the token from the session state.\n */\n clearToken() {\n this._store.setState({ ...this._store.getState(), token: undefined })\n }\n\n /**\n * Clears the token and user from the session state.\n */\n clearAll() {\n this.clearToken()\n this.clearUser()\n }\n\n private _getInitialState(): SessionState {\n return {\n user: undefined,\n token: undefined,\n }\n }\n}\n\nexport { SessionStore }\nexport type { SessionState }\n","import { getWebAuthnAttestation, TSignedRequest } from '@turnkey/http'\nimport { User } from './entities.js'\n\ntype AuthenticationServiceRoutes =\n AuthenticationServiceEndpoints[number]['Route']\n\ntype AuthenticationServiceBody<Route extends AuthenticationServiceRoutes> =\n Extract<AuthenticationServiceEndpoints[number], { Route: Route }>['Body']\n\ntype AuthenticationServiceResponse<Route extends AuthenticationServiceRoutes> =\n Extract<AuthenticationServiceEndpoints[number], { Route: Route }>['Response']\n\ntype AuthenticationServiceEndpoints = [\n {\n Route: '/v1/signup'\n Body: {\n passkey: {\n challenge: string\n attestation: Awaited<ReturnType<typeof getWebAuthnAttestation>>\n }\n email: string\n }\n Response: {\n user: User\n token: string\n }\n },\n {\n Route: '/v1/lookup'\n Body: {\n email: string\n }\n Response: {\n subOrgId: string\n }\n },\n {\n Route: '/v1/signin'\n Body: {\n stampedRequest: TSignedRequest\n }\n Response: {\n user: User\n token: string\n }\n },\n {\n Route: '/v1/sign'\n Body: {\n stampedRequest: TSignedRequest\n }\n Response: {\n signature: string\n }\n },\n]\n\nconst ROUTE_METHOD_MAP = {\n '/v1/signup': 'POST',\n '/v1/lookup': 'POST',\n '/v1/signin': 'POST',\n '/v1/sign': 'POST',\n} satisfies Record<AuthenticationServiceRoutes, 'POST' | 'GET'>\n\nexport type {\n AuthenticationServiceEndpoints,\n AuthenticationServiceResponse,\n AuthenticationServiceBody,\n AuthenticationServiceRoutes,\n}\n\nexport { ROUTE_METHOD_MAP }\n","import { Buffer } from 'buffer'\n\nclass LibBase64 {\n static fromBuffer(buffer: ArrayBuffer): string {\n return Buffer.from(buffer)\n .toString('base64')\n .replace(/\\+/g, '-')\n .replace(/\\//g, '_')\n .replace(/=/g, '')\n }\n\n static toBuffer(base64: string): ArrayBuffer {\n return Buffer.from(base64, 'base64')\n }\n}\n\nexport { LibBase64 }\n","type TakeBytesParams = Partial<{\n count: number\n offset: number\n}>\n\ntype ByteString = `0x${string}`\n\nclass LibBytes {\n static generateRandomBuffer = (): ArrayBuffer => {\n const arr = new Uint8Array(32)\n crypto.getRandomValues(arr)\n return arr.buffer\n }\n\n static takeBytes = (\n bytes: ByteString,\n params: TakeBytesParams = {},\n ): ByteString => {\n const { offset, count } = params\n const start = (offset ? offset * 2 : 0) + 2 // add 2 to skip the 0x prefix\n const end = count ? start + count * 2 : undefined\n\n return `0x${bytes.slice(start, end)}`\n }\n}\n\nexport { LibBytes }\n","import {\n LocalAccount,\n TypedData,\n TypedDataDefinition,\n SignableMessage,\n Hex,\n hashMessage,\n hashTypedData,\n SerializeTransactionFn,\n TransactionSerializable,\n IsNarrowable,\n TransactionSerialized,\n GetTransactionType,\n serializeTransaction,\n keccak256,\n Client,\n hexToBigInt,\n} from 'viem'\nimport { toAccount } from 'viem/accounts'\nimport { SignerClient } from '../signer/index.js'\nimport { LibBytes } from '../lib/bytes.js'\nimport { toLightSmartAccount } from 'permissionless/accounts'\nimport { entryPoint07Address } from 'viem/account-abstraction'\nimport { UnauthenticatedError } from '../errors/UnauthenticatedError.js'\n\ntype ViemModuleConstructorParams = {\n refs: {\n signerClient: SignerClient\n }\n}\n\ntype CurrentUserToLightSmartAccountParams = {\n owner: LocalAccount\n client: Client\n}\n\nclass ViemModule {\n constructor(private readonly _signerClient: SignerClient) {}\n\n async toLocalAccount(): Promise<LocalAccount> {\n const user = this._signerClient.user\n\n if (!user) {\n throw new UnauthenticatedError({ message: 'Signer not authenticated' })\n }\n\n return toAccount({\n address: user.walletAddress,\n signMessage: (msg) => this.signMessage(msg.message),\n signTypedData: <\n const typedData extends TypedData | Record<string, unknown>,\n primaryType extends keyof typedData | 'EIP712Domain' = keyof typedData,\n >(\n typedDataDefinition: TypedDataDefinition<typedData, primaryType>,\n ) => this.signTypedData<typedData, primaryType>(typedDataDefinition),\n signTransaction: this.signTransaction,\n })\n }\n\n async toSmartAccount({\n client,\n owner,\n }: CurrentUserToLightSmartAccountParams): ReturnType<\n typeof toLightSmartAccount<'0.7'>\n > {\n const user = this._signerClient.user\n\n if (!user) {\n throw new UnauthenticatedError({ message: 'Signer not authenticated' })\n }\n\n return toLightSmartAccount({\n client: client,\n owner,\n version: '2.0.0',\n entryPoint: {\n address: entryPoint07Address,\n version: '0.7',\n },\n address: user.smartAccountAddress,\n index: hexToBigInt(user.salt),\n })\n }\n\n async signMessage(msg: SignableMessage): Promise<Hex> {\n const messageHash = hashMessage(msg)\n const result = await this._signerClient.signRawMessage<Hex>(messageHash)\n return result\n }\n\n async signTypedData<\n TTypedData extends TypedData | Record<string, unknown>,\n TPrimaryType extends keyof TTypedData | 'EIP712Domain' = keyof TTypedData,\n >(params: TypedDataDefinition<TTypedData, TPrimaryType>): Promise<Hex> {\n const messageHash = hashTypedData(params)\n return this._signerClient.signRawMessage(messageHash)\n }\n\n async signTransaction<\n serializer extends SerializeTransactionFn<TransactionSerializable> = SerializeTransactionFn<TransactionSerializable>,\n transaction extends Parameters<serializer>[0] = Parameters<serializer>[0],\n >(\n transaction: transaction,\n options?:\n | {\n serializer?: serializer | undefined\n }\n | undefined,\n ): Promise<\n IsNarrowable<\n TransactionSerialized<GetTransactionType<transaction>>,\n Hex\n > extends true\n ? TransactionSerialized<GetTransactionType<transaction>>\n : Hex\n > {\n const serializeFn = options?.serializer ?? serializeTransaction\n const serializedTx = serializeFn(transaction)\n const signatureHex = await this._signerClient.signRawMessage<Hex>(\n keccak256(serializedTx),\n )\n\n const signature = {\n r: LibBytes.takeBytes(signatureHex, { count: 32 }),\n s: LibBytes.takeBytes(signatureHex, { count: 32, offset: 32 }),\n v: BigInt(LibBytes.takeBytes(signatureHex, { count: 1, offset: 64 })),\n }\n\n return serializeFn(transaction, signature)\n }\n}\n\nexport { ViemModule }\n","import type { WebSignerClient, WebauthnSignInParams } from '../../signer/web.js'\n\n/**\n * A module for interacting with the Passkeys authentication methods.\n * Available through the `auth.passkeys` property on a `FourtWebSigner` instance.\n */\nclass PasskeysModule {\n constructor(private readonly _webSignerClient: WebSignerClient) {}\n\n /**\n * Signs in a user using Passkeys.\n *\n * @param params {WebauthnSignInParams} params for the sign-in process.\n * @returns {Promise<void>} promise that resolves to the result of the sign-in process.\n */\n async signIn(params: WebauthnSignInParams) {\n return this._webSignerClient.webauthnSignIn(params)\n }\n}\n\nexport { PasskeysModule }\n","import type { WebSignerClient } from '../../signer/web.js'\nimport { PasskeysModule } from './passkeys.js'\n\n/**\n * A module for interacting with the authentication methods.\n * Available through the `auth` property on a `FourtWebSigner` instance.\n */\nclass AuthModule {\n private readonly _passkeys: PasskeysModule\n\n /**\n * Initializes a new instance of the `AuthModule` class.\n *\n * @param {WebSignerClient} _webSignerClient underlying WebSigner client instance.\n */\n constructor(private readonly _webSignerClient: WebSignerClient) {\n this._passkeys = new PasskeysModule(this._webSignerClient)\n }\n\n /**\n * A module for interacting with the Passkeys authentication methods.\n */\n get passkeys() {\n return this._passkeys\n }\n}\n\nexport { AuthModule }\nexport { PasskeysModule } from './passkeys.js'\n","import { WebSignerClient } from '../../signer/web.js'\nimport { User } from '../../types/entities.js'\n\n/**\n * A module for interacting with the user methods.\n * Available through the `user` property on a `FourtWebSigner` instance.\n */\nclass UserModule {\n /**\n * Initializes a new instance of the `UserModule` class.\n *\n * @param {WebSignerClient} _webSignerClient underlying WebSigner client instance.\n */\n constructor(private readonly _webSignerClient: WebSignerClient) {}\n\n /**\n * Gets the user information.\n *\n * @returns {User | undefined} user information.\n */\n get info() {\n return this._webSignerClient.user\n }\n}\n\nexport { UserModule }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,8BAAgC;;;ACAhC,kBAA8B;;;ACI9B,IAAe,WAAf,cAAgC,MAAM;AAAA,EACnB;AAAA,EAEjB,YAAY,SAAiB,OAAsB;AACjD,UAAM,OAAO;AACb,SAAK,SAAS;AAAA,EAChB;AAAA,EAEA,IAAI,UAAU;AACZ,WAAO,KAAK,OAAO;AAAA,EACrB;AACF;;;ACbA,IAAM,oBAAN,MAAM,2BAA0B,SAAS;AAAA,EACvC,YAAY,OAAsB;AAChC,UAAM,mBAAkB,MAAM,KAAK;AAAA,EACrC;AACF;;;ACJA,IAAM,gBAAN,MAAM,uBAAsB,SAAS;AAAA,EACnC,YAAY,OAAsB;AAChC,UAAM,eAAc,MAAM,KAAK;AAAA,EACjC;AACF;;;ACJA,IAAM,eAAN,MAAM,sBAAqB,SAAS;AAAA,EAClC,YAAY,OAAsB;AAChC,UAAM,cAAa,MAAM,KAAK;AAAA,EAChC;AACF;;;ACJA,IAAM,uBAAN,MAAM,8BAA6B,SAAS;AAAA,EAC1C,YAAY,OAAsB;AAChC,UAAM,sBAAqB,MAAM,KAAK;AAAA,EACxC;AACF;;;ACJA,IAAM,kBAAN,MAAM,yBAAwB,SAAS;AAAA,EACrC,YAAY,OAAsB;AAChC,UAAM,iBAAgB,MAAM,KAAK;AAAA,EACnC;AACF;;;ACNA,qBAA2C;AAC3C,wBAA2C;AAe3C,IAAM,eAAN,MAAmB;AAAA,EACA;AAAA;AAAA;AAAA;AAAA,EAKjB,cAAc;AACZ,SAAK,aAAS,4BAA0B;AAAA,UACtC,2BAAQ,KAAK,kBAA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,EACnB,GAAoC;AAClC,SAAK,mBAAmB,IAAI,gBAAgB;AAAA,MAC1C;AAAA,MACA;AAAA,IACF,CAAC;AAED,SAAK,WAAW;AAAA,MACd,MAAM,IAAI,WAAW,KAAK,gBAAgB;AAAA,MAC1C,MAAM,IAAI,WAAW,KAAK,gBAAgB;AAAA,MAC1C,MAAM,IAAI,WAAW,KAAK,gBAAgB;AAAA,IAC5C;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,OAAO;AACT,WAAO,KAAK,SAAS;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,OAAO;AACT,WAAO,KAAK,SAAS;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,OAAO;AACT,WAAO,KAAK,SAAS;AAAA,EACvB;AACF;","names":["import_http","import_accounts"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/signer/web.ts","../src/signer/index.ts","../src/errors/SDKError.ts","../src/errors/UnauthorizedError.ts","../src/errors/NotFoundError.ts","../src/errors/GenericError.ts","../src/errors/UnauthenticatedError.ts","../src/errors/BadRequestError.ts","../src/session/index.ts","../src/types/Routes.ts","../src/lib/base64.ts","../src/lib/bytes.ts","../src/third-party/viem.ts","../src/modules/auth/passkeys.ts","../src/modules/auth/index.ts","../src/modules/user/index.ts"],"sourcesContent":["import { SignerClientConstructorParams } from './signer/index.js'\nimport {\n WebauthnSignInParams,\n WebSignerClient,\n WebSignerClientConstructorParams,\n} from './signer/web.js'\nimport { ViemModule } from './third-party/viem.js'\nimport { AuthModule, UserModule } from './modules/index.js'\n\ntype FourtWebSignerConstructorParams = {\n configuration: SignerClientConstructorParams['configuration']\n auth: Pick<WebSignerClientConstructorParams, 'webauthn'>\n}\n\n/**\n * A client for interacting with the Fourt Web Signer.\n */\nclass FourtWebSigner {\n private readonly _webSignerClient: WebSignerClient\n private readonly _modules: {\n viem: ViemModule\n auth: AuthModule\n user: UserModule\n }\n\n /**\n * Initializes a new instance of the `FourtWebSigner` class.\n * Sets up the underlying modules.\n *\n *\n * @example\n * ```ts\n * const fourtWebSigner = new FourtWebSigner({\n * auth: {\n * webauthn: {\n * rpId: 'localhost',\n * },\n * },\n * configuration: {\n * apiKey: '927d603c-6775-4210-8e13-8904ca985e78',\n * },\n * })\n * ```\n *\n * @param {FourtWebSignerConstructorParams} params the required parameters to initialize the client\n */\n constructor({\n configuration,\n auth: { webauthn },\n }: FourtWebSignerConstructorParams) {\n this._webSignerClient = new WebSignerClient({\n configuration,\n webauthn,\n })\n\n this._modules = {\n viem: new ViemModule(this._webSignerClient),\n auth: new AuthModule(this._webSignerClient),\n user: new UserModule(this._webSignerClient),\n }\n }\n\n /**\n * A module for interacting with the Viem library.\n */\n get viem() {\n return this._modules.viem\n }\n\n /**\n * A module for interacting with the authentication methods.\n */\n get auth() {\n return this._modules.auth\n }\n\n /**\n * A module for interacting with the user methods.\n */\n get user() {\n return this._modules.user\n }\n}\n\nexport { FourtWebSigner }\n","import { WebauthnStamper } from '@turnkey/webauthn-stamper'\nimport {\n type SignerClientInheritedConstructorParams,\n SignerClient,\n} from './index.js'\nimport { LibBase64 } from '../lib/base64.js'\nimport { LibBytes } from '../lib/bytes.js'\nimport { getWebAuthnAttestation } from '@turnkey/http'\n\ntype WebauthnSignInParams = {\n email: string\n}\n\ntype WebSignerClientConstructorParams = SignerClientInheritedConstructorParams<{\n webauthn: {\n rpId: string\n }\n}>\n\ntype CreateAccountParams = {\n method: 'webauthn'\n email: string\n}\n\n/**\n * A signer client for web applications.\n */\nclass WebSignerClient extends SignerClient {\n private readonly _stampers: {\n webauthn: WebauthnStamper\n }\n\n /**\n * Initializes a new instance of the `WebSignerClient` class.\n *\n * @param {WebSignerClientConstructorParams} params params for the constructor\n */\n constructor({ configuration, webauthn }: WebSignerClientConstructorParams) {\n const webauthnStamper = new WebauthnStamper({ rpId: webauthn.rpId })\n\n super({\n stamper: webauthnStamper,\n configuration: configuration,\n })\n\n this._stampers = {\n webauthn: webauthnStamper,\n }\n }\n\n /**\n * Signs in a user with webauthn.\n *\n * @param {WebauthnSignInParams} params params for the sign in\n */\n async webauthnSignIn({ email }: WebauthnSignInParams) {\n const existingUserSubOrgId = await this.lookUpUser(email)\n\n if (!existingUserSubOrgId) {\n await this._createAccount({ method: 'webauthn', email })\n } else {\n await this.whoAmI(existingUserSubOrgId)\n\n // We should assure that the user and its credentialId are set\n if (!this.user || !this.user.credentialId) {\n return\n }\n\n this.stamper = this._stampers.webauthn\n this._stampers.webauthn.allowCredentials = [\n {\n id: LibBase64.toBuffer(this.user.credentialId),\n type: 'public-key',\n transports: ['internal', 'usb'],\n },\n ]\n }\n }\n\n private async _createAccount(params: CreateAccountParams) {\n const { challenge, attestation } = await this._webauthnGenerateAttestation(\n params.email,\n )\n\n const {\n token,\n user: { id, email, subOrgId, walletAddress, salt, smartAccountAddress },\n } = await this.request('/v1/signup', {\n passkey: {\n challenge: LibBase64.fromBuffer(challenge),\n attestation,\n },\n email: params.email,\n })\n\n this.user = {\n id,\n email,\n subOrgId,\n walletAddress,\n salt,\n smartAccountAddress,\n credentialId: attestation.credentialId,\n }\n\n this._sessionStore.token = token\n }\n\n private async _webauthnGenerateAttestation(email: string) {\n const challenge = LibBytes.generateRandomBuffer()\n const authenticatorUserId = LibBytes.generateRandomBuffer()\n\n const attestation = await getWebAuthnAttestation({\n publicKey: {\n authenticatorSelection: {\n residentKey: 'preferred',\n requireResidentKey: false,\n userVerification: 'preferred',\n },\n challenge,\n rp: {\n id: window.location.hostname,\n name: window.location.hostname,\n },\n pubKeyCredParams: [\n {\n type: 'public-key',\n alg: -7,\n },\n {\n type: 'public-key',\n alg: -257,\n },\n ],\n user: {\n id: authenticatorUserId,\n name: email,\n displayName: email,\n },\n },\n })\n\n return { challenge, attestation, authenticatorUserId }\n }\n}\n\nexport { WebSignerClient }\nexport type {\n WebSignerClientConstructorParams,\n WebauthnSignInParams,\n CreateAccountParams,\n}\n","import { TurnkeyClient } from '@turnkey/http'\nimport {\n BadRequestError,\n GenericError,\n NotFoundError,\n UnauthorizedError,\n} from '../errors/index.js'\nimport { SDKError } from '../errors/SDKError.js'\nimport { SessionStore } from '../session/index.js'\nimport { User } from '../types/entities.js'\nimport { APIResponse } from '../types/rest.js'\nimport {\n AuthenticationServiceBody,\n AuthenticationServiceResponse,\n AuthenticationServiceRoutes,\n ROUTE_METHOD_MAP,\n} from '../types/Routes.js'\nimport { jwtDecode, JwtPayload } from 'jwt-decode'\nimport { isPast, secondsToMilliseconds } from 'date-fns'\n\ntype SignerClientConfiguration = {\n apiKey: string\n apiUrl?: string\n}\n\ntype SignerClientConstructorParams = {\n stamper: TurnkeyClient['stamper']\n configuration: SignerClientConfiguration\n}\n\ntype SignerClientInheritedConstructorParams<\n Extended extends Record<string, unknown>,\n> = Pick<SignerClientConstructorParams, 'configuration'> & Extended\n\nabstract class SignerClient {\n protected readonly _turnkeyClient: TurnkeyClient\n protected readonly _configuration: Required<SignerClientConfiguration>\n protected readonly _sessionStore: SessionStore\n\n private _user?: User\n\n constructor({\n stamper,\n configuration: { apiUrl, ...requiredConfiguration },\n }: SignerClientConstructorParams) {\n this._turnkeyClient = new TurnkeyClient(\n { baseUrl: 'https://api.turnkey.com' },\n stamper,\n )\n\n this._configuration = {\n ...requiredConfiguration,\n apiUrl: apiUrl ?? 'https://auth.api.dev.fourt.io/',\n }\n\n this._sessionStore = new SessionStore()\n }\n\n logout() {\n this._user = undefined\n this.sessionStore.clearAll()\n }\n\n get user(): User | undefined {\n if (this._user) return this._user\n\n // Check if there's a token\n if (!this.sessionStore.token) {\n this.sessionStore.clearAll()\n return undefined\n }\n\n const decodedToken = jwtDecode<JwtPayload>(this.sessionStore.token)\n // Check if the token has expired\n if (\n decodedToken.exp &&\n isPast(new Date(secondsToMilliseconds(decodedToken.exp)))\n ) {\n this.sessionStore.clearAll()\n return undefined\n }\n\n if (this.sessionStore.user) this._user = this.sessionStore.user\n\n return this._user\n }\n\n protected set user(value: User | undefined) {\n this._user = value\n }\n\n protected set stamper(stamper: TurnkeyClient['stamper']) {\n this._turnkeyClient.stamper = stamper\n }\n\n protected get stamper(): TurnkeyClient['stamper'] {\n return this._turnkeyClient.stamper\n }\n\n protected get sessionStore(): SessionStore {\n return this._sessionStore\n }\n\n async signRawMessage<Into extends string>(msg: string): Promise<Into> {\n if (!this._user) {\n throw new UnauthorizedError({\n message: 'SignerClient must be authenticated to sign a message',\n })\n }\n\n const stampedRequest = await this._turnkeyClient.stampSignRawPayload({\n organizationId: this._user.subOrgId,\n type: 'ACTIVITY_TYPE_SIGN_RAW_PAYLOAD_V2',\n timestampMs: Date.now().toString(),\n parameters: {\n encoding: 'PAYLOAD_ENCODING_HEXADECIMAL',\n hashFunction: 'HASH_FUNCTION_NO_OP',\n payload: msg,\n signWith: this._user.walletAddress,\n },\n })\n\n const { signature } = await this.request('/v1/sign', {\n stampedRequest,\n })\n\n return <Into>signature\n }\n\n protected async lookUpUser(email: string): Promise<string | null> {\n try {\n const { subOrgId } = await this.request('/v1/lookup', { email })\n return subOrgId\n } catch (error) {\n if (!(error instanceof SDKError)) throw error\n\n const sdkError: SDKError = error\n\n switch (sdkError.constructor.name) {\n case NotFoundError.name: {\n return null\n }\n default: {\n throw sdkError\n }\n }\n }\n }\n\n protected async whoAmI(subOrgId?: string) {\n const orgId = subOrgId || this._user?.subOrgId\n\n if (!orgId) throw new BadRequestError({ message: 'No orgId provided' })\n\n const stampedRequest = await this._turnkeyClient.stampGetWhoami({\n organizationId: orgId,\n })\n\n const { user, token } = await this.request('/v1/signin', {\n stampedRequest,\n })\n\n const credentialId = (() => {\n try {\n return JSON.parse(stampedRequest?.stamp.stampHeaderValue)\n .credentialId as string\n } catch (e) {\n return undefined\n }\n })()\n\n this._user = {\n ...user,\n credentialId: credentialId,\n }\n\n this.sessionStore.user = this.user!\n this.sessionStore.token = token\n }\n\n protected async request<Route extends AuthenticationServiceRoutes>(\n route: Route,\n body?: AuthenticationServiceBody<Route>,\n ): Promise<AuthenticationServiceResponse<Route>> {\n const url = new URL(`${route}`, this._configuration.apiUrl)\n const token = this.sessionStore.token\n\n const headers: Record<string, string> = {\n 'Content-Type': 'application/json',\n 'X-FOURT-KEY': this._configuration.apiKey,\n }\n\n // Add Authorization header if token exists\n if (token) {\n headers['Authorization'] = `Bearer ${token}`\n }\n\n const response = await fetch(url, {\n method: ROUTE_METHOD_MAP[route],\n body: JSON.stringify(body),\n headers,\n credentials: 'include',\n })\n\n const { data, error } = (await response.json()) as APIResponse<\n AuthenticationServiceResponse<Route>\n >\n\n if (error) {\n switch (error.kind) {\n case 'UnauthorizedError': {\n // TODO: workaround! this need to be cleaned up and moved into the web signer\n this.logout()\n throw new UnauthorizedError({ message: error.message })\n }\n case 'NotFoundError': {\n throw new NotFoundError({ message: error.message })\n }\n case 'BadRequestError': {\n throw new BadRequestError({ message: error.message })\n }\n default: {\n throw new GenericError({ message: error.message })\n }\n }\n }\n\n return { ...data } as AuthenticationServiceResponse<Route>\n }\n}\n\nexport { SignerClient }\nexport type {\n SignerClientConstructorParams,\n SignerClientInheritedConstructorParams,\n}\n","type SDKErrorProps = {\n message: string\n}\n\nabstract class SDKError extends Error {\n private readonly _props: SDKErrorProps\n\n constructor(message: string, props: SDKErrorProps) {\n super(message)\n this._props = props\n }\n\n get message() {\n return this._props.message\n }\n}\n\nexport { SDKError }\nexport type { SDKErrorProps }\n","import { SDKErrorProps, SDKError } from './SDKError.js'\n\nclass UnauthorizedError extends SDKError {\n constructor(props: SDKErrorProps) {\n super(UnauthorizedError.name, props)\n }\n}\n\nexport { UnauthorizedError }\n","import { SDKErrorProps, SDKError } from './SDKError.js'\n\nclass NotFoundError extends SDKError {\n constructor(props: SDKErrorProps) {\n super(NotFoundError.name, props)\n }\n}\n\nexport { NotFoundError }\n","import { SDKErrorProps, SDKError } from './SDKError.js'\n\nclass GenericError extends SDKError {\n constructor(props: SDKErrorProps) {\n super(GenericError.name, props)\n }\n}\n\nexport { GenericError }\n","import { SDKErrorProps, SDKError } from './SDKError.js'\n\nclass UnauthenticatedError extends SDKError {\n constructor(props: SDKErrorProps) {\n super(UnauthenticatedError.name, props)\n }\n}\n\nexport { UnauthenticatedError }\n","import { SDKErrorProps, SDKError } from './SDKError.js'\n\nclass BadRequestError extends SDKError {\n constructor(props: SDKErrorProps) {\n super(BadRequestError.name, props)\n }\n}\n\nexport { BadRequestError }\n","import { createStore, type StoreApi } from 'zustand'\nimport { createJSONStorage, persist } from 'zustand/middleware'\nimport { User } from '../types/entities.js'\n\n/**\n * The state of the session.\n */\ntype SessionState = {\n user?: User\n expirationDate?: Date\n token?: string\n}\n\n/**\n * A store for the session state.\n */\nclass SessionStore {\n private readonly _store: StoreApi<SessionState>\n\n /**\n * Initializes a new instance of the `SessionStore` class by creating a new `zustand`store with the initial state.\n */\n constructor() {\n this._store = createStore<SessionState>()(\n persist(this._getInitialState, {\n name: 'fourt.io-signer-session',\n storage: createJSONStorage<SessionState>(() => localStorage),\n }),\n )\n }\n\n /**\n * Gets the token from the session state.\n *\n * @returns {string | undefined} the token.\n */\n get token(): string | undefined {\n return this._store.getState().token\n }\n\n /**\n * Sets the token in the session state.\n *\n * @param {string} token the token to set.\n */\n set token(token: string) {\n this._store.setState({ token })\n }\n\n /**\n * Gets the user from the session state.\n *\n * @returns {User | undefined} the user.\n */\n get user(): User | undefined {\n return this._store.getState().user\n }\n\n /**\n * Sets the user in the session state.\n *\n * @param {User} user the user to set.\n */\n set user(user: User) {\n this._store.setState({ ...this._store.getState(), user })\n }\n\n /**\n * Clears the user from the session state.\n */\n clearUser() {\n this._store.setState({ ...this._store.getState(), user: undefined })\n }\n\n /**\n * Clears the token from the session state.\n */\n clearToken() {\n this._store.setState({ ...this._store.getState(), token: undefined })\n }\n\n /**\n * Clears the token and user from the session state.\n */\n clearAll() {\n this.clearToken()\n this.clearUser()\n }\n\n private _getInitialState(): SessionState {\n return {\n user: undefined,\n token: undefined,\n }\n }\n}\n\nexport { SessionStore }\nexport type { SessionState }\n","import { getWebAuthnAttestation, TSignedRequest } from '@turnkey/http'\nimport { User } from './entities.js'\n\ntype AuthenticationServiceRoutes =\n AuthenticationServiceEndpoints[number]['Route']\n\ntype AuthenticationServiceBody<Route extends AuthenticationServiceRoutes> =\n Extract<AuthenticationServiceEndpoints[number], { Route: Route }>['Body']\n\ntype AuthenticationServiceResponse<Route extends AuthenticationServiceRoutes> =\n Extract<AuthenticationServiceEndpoints[number], { Route: Route }>['Response']\n\ntype AuthenticationServiceEndpoints = [\n {\n Route: '/v1/signup'\n Body: {\n passkey: {\n challenge: string\n attestation: Awaited<ReturnType<typeof getWebAuthnAttestation>>\n }\n email: string\n }\n Response: {\n user: User\n token: string\n }\n },\n {\n Route: '/v1/lookup'\n Body: {\n email: string\n }\n Response: {\n subOrgId: string\n }\n },\n {\n Route: '/v1/signin'\n Body: {\n stampedRequest: TSignedRequest\n }\n Response: {\n user: User\n token: string\n }\n },\n {\n Route: '/v1/sign'\n Body: {\n stampedRequest: TSignedRequest\n }\n Response: {\n signature: string\n }\n },\n]\n\nconst ROUTE_METHOD_MAP = {\n '/v1/signup': 'POST',\n '/v1/lookup': 'POST',\n '/v1/signin': 'POST',\n '/v1/sign': 'POST',\n} satisfies Record<AuthenticationServiceRoutes, 'POST' | 'GET'>\n\nexport type {\n AuthenticationServiceEndpoints,\n AuthenticationServiceResponse,\n AuthenticationServiceBody,\n AuthenticationServiceRoutes,\n}\n\nexport { ROUTE_METHOD_MAP }\n","import { Buffer } from 'buffer'\n\nclass LibBase64 {\n static fromBuffer(buffer: ArrayBuffer): string {\n return Buffer.from(buffer)\n .toString('base64')\n .replace(/\\+/g, '-')\n .replace(/\\//g, '_')\n .replace(/=/g, '')\n }\n\n static toBuffer(base64: string): ArrayBuffer {\n return Buffer.from(base64, 'base64')\n }\n}\n\nexport { LibBase64 }\n","type TakeBytesParams = Partial<{\n count: number\n offset: number\n}>\n\ntype ByteString = `0x${string}`\n\nclass LibBytes {\n static generateRandomBuffer = (): ArrayBuffer => {\n const arr = new Uint8Array(32)\n crypto.getRandomValues(arr)\n return arr.buffer\n }\n\n static takeBytes = (\n bytes: ByteString,\n params: TakeBytesParams = {},\n ): ByteString => {\n const { offset, count } = params\n const start = (offset ? offset * 2 : 0) + 2 // add 2 to skip the 0x prefix\n const end = count ? start + count * 2 : undefined\n\n return `0x${bytes.slice(start, end)}`\n }\n}\n\nexport { LibBytes }\n","import {\n LocalAccount,\n TypedData,\n TypedDataDefinition,\n SignableMessage,\n Hex,\n hashMessage,\n hashTypedData,\n SerializeTransactionFn,\n TransactionSerializable,\n IsNarrowable,\n TransactionSerialized,\n GetTransactionType,\n serializeTransaction,\n keccak256,\n Client,\n hexToBigInt,\n} from 'viem'\nimport { toAccount } from 'viem/accounts'\nimport { SignerClient } from '../signer/index.js'\nimport { LibBytes } from '../lib/bytes.js'\nimport { toLightSmartAccount } from 'permissionless/accounts'\nimport { entryPoint07Address } from 'viem/account-abstraction'\nimport { UnauthenticatedError } from '../errors/UnauthenticatedError.js'\n\ntype ViemModuleConstructorParams = {\n refs: {\n signerClient: SignerClient\n }\n}\n\ntype CurrentUserToLightSmartAccountParams = {\n owner: LocalAccount\n client: Client\n}\n\nclass ViemModule {\n constructor(private readonly _signerClient: SignerClient) {}\n\n async toLocalAccount(): Promise<LocalAccount> {\n const user = this._signerClient.user\n\n if (!user) {\n throw new UnauthenticatedError({ message: 'Signer not authenticated' })\n }\n\n return toAccount({\n address: user.walletAddress,\n signMessage: (msg) => this.signMessage(msg.message),\n signTypedData: <\n const typedData extends TypedData | Record<string, unknown>,\n primaryType extends keyof typedData | 'EIP712Domain' = keyof typedData,\n >(\n typedDataDefinition: TypedDataDefinition<typedData, primaryType>,\n ) => this.signTypedData<typedData, primaryType>(typedDataDefinition),\n signTransaction: this.signTransaction,\n })\n }\n\n async toSmartAccount({\n client,\n owner,\n }: CurrentUserToLightSmartAccountParams): ReturnType<\n typeof toLightSmartAccount<'0.7'>\n > {\n const user = this._signerClient.user\n\n if (!user) {\n throw new UnauthenticatedError({ message: 'Signer not authenticated' })\n }\n\n return toLightSmartAccount({\n client: client,\n owner,\n version: '2.0.0',\n entryPoint: {\n address: entryPoint07Address,\n version: '0.7',\n },\n address: user.smartAccountAddress,\n index: hexToBigInt(user.salt),\n })\n }\n\n async signMessage(msg: SignableMessage): Promise<Hex> {\n const messageHash = hashMessage(msg)\n const result = await this._signerClient.signRawMessage<Hex>(messageHash)\n return result\n }\n\n async signTypedData<\n TTypedData extends TypedData | Record<string, unknown>,\n TPrimaryType extends keyof TTypedData | 'EIP712Domain' = keyof TTypedData,\n >(params: TypedDataDefinition<TTypedData, TPrimaryType>): Promise<Hex> {\n const messageHash = hashTypedData(params)\n return this._signerClient.signRawMessage(messageHash)\n }\n\n async signTransaction<\n serializer extends SerializeTransactionFn<TransactionSerializable> = SerializeTransactionFn<TransactionSerializable>,\n transaction extends Parameters<serializer>[0] = Parameters<serializer>[0],\n >(\n transaction: transaction,\n options?:\n | {\n serializer?: serializer | undefined\n }\n | undefined,\n ): Promise<\n IsNarrowable<\n TransactionSerialized<GetTransactionType<transaction>>,\n Hex\n > extends true\n ? TransactionSerialized<GetTransactionType<transaction>>\n : Hex\n > {\n const serializeFn = options?.serializer ?? serializeTransaction\n const serializedTx = serializeFn(transaction)\n const signatureHex = await this._signerClient.signRawMessage<Hex>(\n keccak256(serializedTx),\n )\n\n const signature = {\n r: LibBytes.takeBytes(signatureHex, { count: 32 }),\n s: LibBytes.takeBytes(signatureHex, { count: 32, offset: 32 }),\n v: BigInt(LibBytes.takeBytes(signatureHex, { count: 1, offset: 64 })),\n }\n\n return serializeFn(transaction, signature)\n }\n}\n\nexport { ViemModule }\n","import type { WebSignerClient, WebauthnSignInParams } from '../../signer/web.js'\n\n/**\n * A module for interacting with the Passkeys authentication methods.\n * Available through the `auth.passkeys` property on a `FourtWebSigner` instance.\n */\nclass PasskeysModule {\n constructor(private readonly _webSignerClient: WebSignerClient) {}\n\n /**\n * Signs in a user using Passkeys.\n *\n * @param params {WebauthnSignInParams} params for the sign-in process.\n * @returns {Promise<void>} promise that resolves to the result of the sign-in process.\n */\n async signIn(params: WebauthnSignInParams) {\n return this._webSignerClient.webauthnSignIn(params)\n }\n}\n\nexport { PasskeysModule }\n","import type { WebSignerClient } from '../../signer/web.js'\nimport { PasskeysModule } from './passkeys.js'\n\n/**\n * A module for interacting with the authentication methods.\n * Available through the `auth` property on a `FourtWebSigner` instance.\n */\nclass AuthModule {\n private readonly _passkeys: PasskeysModule\n\n /**\n * Initializes a new instance of the `AuthModule` class.\n *\n * @param {WebSignerClient} _webSignerClient underlying WebSigner client instance.\n */\n constructor(private readonly _webSignerClient: WebSignerClient) {\n this._passkeys = new PasskeysModule(this._webSignerClient)\n }\n\n /**\n * A module for interacting with the Passkeys authentication methods.\n */\n get passkeys() {\n return this._passkeys\n }\n}\n\nexport { AuthModule }\nexport { PasskeysModule } from './passkeys.js'\n","import { WebSignerClient } from '../../signer/web.js'\nimport { User } from '../../types/entities.js'\n\n/**\n * A module for interacting with the user methods.\n * Available through the `user` property on a `FourtWebSigner` instance.\n */\nclass UserModule {\n /**\n * Initializes a new instance of the `UserModule` class.\n *\n * @param {WebSignerClient} _webSignerClient underlying WebSigner client instance.\n */\n constructor(private readonly _webSignerClient: WebSignerClient) {}\n\n /**\n * Gets the user information.\n *\n * @returns {User | undefined} user information.\n */\n get info() {\n return this._webSignerClient.user\n }\n\n /**\n * Logs out the user.\n *\n * @returns {void}\n */\n logout() {\n return this._webSignerClient.logout()\n }\n}\n\nexport { UserModule }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,8BAAgC;;;ACAhC,kBAA8B;;;ACI9B,IAAe,WAAf,cAAgC,MAAM;AAAA,EACnB;AAAA,EAEjB,YAAY,SAAiB,OAAsB;AACjD,UAAM,OAAO;AACb,SAAK,SAAS;AAAA,EAChB;AAAA,EAEA,IAAI,UAAU;AACZ,WAAO,KAAK,OAAO;AAAA,EACrB;AACF;;;ACbA,IAAM,oBA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AKA,IAAI,OAAO;AACT,WAAO,KAAK,SAAS;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,OAAO;AACT,WAAO,KAAK,SAAS;AAAA,EACvB;AACF;","names":["import_http","import_accounts"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -118,6 +118,7 @@ declare abstract class SignerClient {
|
|
|
118
118
|
protected readonly _sessionStore: SessionStore;
|
|
119
119
|
private _user?;
|
|
120
120
|
constructor({ stamper, configuration: { apiUrl, ...requiredConfiguration }, }: SignerClientConstructorParams);
|
|
121
|
+
logout(): void;
|
|
121
122
|
get user(): User | undefined;
|
|
122
123
|
protected set user(value: User | undefined);
|
|
123
124
|
protected set stamper(stamper: TurnkeyClient['stamper']);
|
|
@@ -227,6 +228,12 @@ declare class UserModule {
|
|
|
227
228
|
* @returns {User | undefined} user information.
|
|
228
229
|
*/
|
|
229
230
|
get info(): User | undefined;
|
|
231
|
+
/**
|
|
232
|
+
* Logs out the user.
|
|
233
|
+
*
|
|
234
|
+
* @returns {void}
|
|
235
|
+
*/
|
|
236
|
+
logout(): void;
|
|
230
237
|
}
|
|
231
238
|
|
|
232
239
|
type FourtWebSignerConstructorParams = {
|
package/dist/index.d.ts
CHANGED
|
@@ -118,6 +118,7 @@ declare abstract class SignerClient {
|
|
|
118
118
|
protected readonly _sessionStore: SessionStore;
|
|
119
119
|
private _user?;
|
|
120
120
|
constructor({ stamper, configuration: { apiUrl, ...requiredConfiguration }, }: SignerClientConstructorParams);
|
|
121
|
+
logout(): void;
|
|
121
122
|
get user(): User | undefined;
|
|
122
123
|
protected set user(value: User | undefined);
|
|
123
124
|
protected set stamper(stamper: TurnkeyClient['stamper']);
|
|
@@ -227,6 +228,12 @@ declare class UserModule {
|
|
|
227
228
|
* @returns {User | undefined} user information.
|
|
228
229
|
*/
|
|
229
230
|
get info(): User | undefined;
|
|
231
|
+
/**
|
|
232
|
+
* Logs out the user.
|
|
233
|
+
*
|
|
234
|
+
* @returns {void}
|
|
235
|
+
*/
|
|
236
|
+
logout(): void;
|
|
230
237
|
}
|
|
231
238
|
|
|
232
239
|
type FourtWebSignerConstructorParams = {
|
package/dist/index.js
CHANGED
|
@@ -156,6 +156,10 @@ var SignerClient = class {
|
|
|
156
156
|
};
|
|
157
157
|
this._sessionStore = new SessionStore();
|
|
158
158
|
}
|
|
159
|
+
logout() {
|
|
160
|
+
this._user = void 0;
|
|
161
|
+
this.sessionStore.clearAll();
|
|
162
|
+
}
|
|
159
163
|
get user() {
|
|
160
164
|
if (this._user) return this._user;
|
|
161
165
|
if (!this.sessionStore.token) {
|
|
@@ -264,8 +268,7 @@ var SignerClient = class {
|
|
|
264
268
|
if (error) {
|
|
265
269
|
switch (error.kind) {
|
|
266
270
|
case "UnauthorizedError": {
|
|
267
|
-
this.
|
|
268
|
-
this.sessionStore.clearAll();
|
|
271
|
+
this.logout();
|
|
269
272
|
throw new UnauthorizedError({ message: error.message });
|
|
270
273
|
}
|
|
271
274
|
case "NotFoundError": {
|
|
@@ -538,6 +541,14 @@ var UserModule = class {
|
|
|
538
541
|
get info() {
|
|
539
542
|
return this._webSignerClient.user;
|
|
540
543
|
}
|
|
544
|
+
/**
|
|
545
|
+
* Logs out the user.
|
|
546
|
+
*
|
|
547
|
+
* @returns {void}
|
|
548
|
+
*/
|
|
549
|
+
logout() {
|
|
550
|
+
return this._webSignerClient.logout();
|
|
551
|
+
}
|
|
541
552
|
};
|
|
542
553
|
|
|
543
554
|
// src/index.ts
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/signer/web.ts","../src/signer/index.ts","../src/errors/SDKError.ts","../src/errors/UnauthorizedError.ts","../src/errors/NotFoundError.ts","../src/errors/GenericError.ts","../src/errors/UnauthenticatedError.ts","../src/errors/BadRequestError.ts","../src/session/index.ts","../src/types/Routes.ts","../src/lib/base64.ts","../src/lib/bytes.ts","../src/third-party/viem.ts","../src/modules/auth/passkeys.ts","../src/modules/auth/index.ts","../src/modules/user/index.ts","../src/index.ts"],"sourcesContent":["import { WebauthnStamper } from '@turnkey/webauthn-stamper'\nimport {\n type SignerClientInheritedConstructorParams,\n SignerClient,\n} from './index.js'\nimport { LibBase64 } from '../lib/base64.js'\nimport { LibBytes } from '../lib/bytes.js'\nimport { getWebAuthnAttestation } from '@turnkey/http'\n\ntype WebauthnSignInParams = {\n email: string\n}\n\ntype WebSignerClientConstructorParams = SignerClientInheritedConstructorParams<{\n webauthn: {\n rpId: string\n }\n}>\n\ntype CreateAccountParams = {\n method: 'webauthn'\n email: string\n}\n\n/**\n * A signer client for web applications.\n */\nclass WebSignerClient extends SignerClient {\n private readonly _stampers: {\n webauthn: WebauthnStamper\n }\n\n /**\n * Initializes a new instance of the `WebSignerClient` class.\n *\n * @param {WebSignerClientConstructorParams} params params for the constructor\n */\n constructor({ configuration, webauthn }: WebSignerClientConstructorParams) {\n const webauthnStamper = new WebauthnStamper({ rpId: webauthn.rpId })\n\n super({\n stamper: webauthnStamper,\n configuration: configuration,\n })\n\n this._stampers = {\n webauthn: webauthnStamper,\n }\n }\n\n /**\n * Signs in a user with webauthn.\n *\n * @param {WebauthnSignInParams} params params for the sign in\n */\n async webauthnSignIn({ email }: WebauthnSignInParams) {\n const existingUserSubOrgId = await this.lookUpUser(email)\n\n if (!existingUserSubOrgId) {\n await this._createAccount({ method: 'webauthn', email })\n } else {\n await this.whoAmI(existingUserSubOrgId)\n\n // We should assure that the user and its credentialId are set\n if (!this.user || !this.user.credentialId) {\n return\n }\n\n this.stamper = this._stampers.webauthn\n this._stampers.webauthn.allowCredentials = [\n {\n id: LibBase64.toBuffer(this.user.credentialId),\n type: 'public-key',\n transports: ['internal', 'usb'],\n },\n ]\n }\n }\n\n private async _createAccount(params: CreateAccountParams) {\n const { challenge, attestation } = await this._webauthnGenerateAttestation(\n params.email,\n )\n\n const {\n token,\n user: { id, email, subOrgId, walletAddress, salt, smartAccountAddress },\n } = await this.request('/v1/signup', {\n passkey: {\n challenge: LibBase64.fromBuffer(challenge),\n attestation,\n },\n email: params.email,\n })\n\n this.user = {\n id,\n email,\n subOrgId,\n walletAddress,\n salt,\n smartAccountAddress,\n credentialId: attestation.credentialId,\n }\n\n this._sessionStore.token = token\n }\n\n private async _webauthnGenerateAttestation(email: string) {\n const challenge = LibBytes.generateRandomBuffer()\n const authenticatorUserId = LibBytes.generateRandomBuffer()\n\n const attestation = await getWebAuthnAttestation({\n publicKey: {\n authenticatorSelection: {\n residentKey: 'preferred',\n requireResidentKey: false,\n userVerification: 'preferred',\n },\n challenge,\n rp: {\n id: window.location.hostname,\n name: window.location.hostname,\n },\n pubKeyCredParams: [\n {\n type: 'public-key',\n alg: -7,\n },\n {\n type: 'public-key',\n alg: -257,\n },\n ],\n user: {\n id: authenticatorUserId,\n name: email,\n displayName: email,\n },\n },\n })\n\n return { challenge, attestation, authenticatorUserId }\n }\n}\n\nexport { WebSignerClient }\nexport type {\n WebSignerClientConstructorParams,\n WebauthnSignInParams,\n CreateAccountParams,\n}\n","import { TurnkeyClient } from '@turnkey/http'\nimport {\n BadRequestError,\n GenericError,\n NotFoundError,\n UnauthorizedError,\n} from '../errors/index.js'\nimport { SDKError } from '../errors/SDKError.js'\nimport { SessionStore } from '../session/index.js'\nimport { User } from '../types/entities.js'\nimport { APIResponse } from '../types/rest.js'\nimport {\n AuthenticationServiceBody,\n AuthenticationServiceResponse,\n AuthenticationServiceRoutes,\n ROUTE_METHOD_MAP,\n} from '../types/Routes.js'\nimport { jwtDecode, JwtPayload } from 'jwt-decode'\nimport { isPast, secondsToMilliseconds } from 'date-fns'\n\ntype SignerClientConfiguration = {\n apiKey: string\n apiUrl?: string\n}\n\ntype SignerClientConstructorParams = {\n stamper: TurnkeyClient['stamper']\n configuration: SignerClientConfiguration\n}\n\ntype SignerClientInheritedConstructorParams<\n Extended extends Record<string, unknown>,\n> = Pick<SignerClientConstructorParams, 'configuration'> & Extended\n\nabstract class SignerClient {\n protected readonly _turnkeyClient: TurnkeyClient\n protected readonly _configuration: Required<SignerClientConfiguration>\n protected readonly _sessionStore: SessionStore\n\n private _user?: User\n\n constructor({\n stamper,\n configuration: { apiUrl, ...requiredConfiguration },\n }: SignerClientConstructorParams) {\n this._turnkeyClient = new TurnkeyClient(\n { baseUrl: 'https://api.turnkey.com' },\n stamper,\n )\n\n this._configuration = {\n ...requiredConfiguration,\n apiUrl: apiUrl ?? 'https://auth.api.dev.fourt.io/',\n }\n\n this._sessionStore = new SessionStore()\n }\n\n get user(): User | undefined {\n if (this._user) return this._user\n\n // Check if there's a token\n if (!this.sessionStore.token) {\n this.sessionStore.clearAll()\n return undefined\n }\n\n const decodedToken = jwtDecode<JwtPayload>(this.sessionStore.token)\n // Check if the token has expired\n if (\n decodedToken.exp &&\n isPast(new Date(secondsToMilliseconds(decodedToken.exp)))\n ) {\n this.sessionStore.clearAll()\n return undefined\n }\n\n if (this.sessionStore.user) this._user = this.sessionStore.user\n\n return this._user\n }\n\n protected set user(value: User | undefined) {\n this._user = value\n }\n\n protected set stamper(stamper: TurnkeyClient['stamper']) {\n this._turnkeyClient.stamper = stamper\n }\n\n protected get stamper(): TurnkeyClient['stamper'] {\n return this._turnkeyClient.stamper\n }\n\n protected get sessionStore(): SessionStore {\n return this._sessionStore\n }\n\n async signRawMessage<Into extends string>(msg: string): Promise<Into> {\n if (!this._user) {\n throw new UnauthorizedError({\n message: 'SignerClient must be authenticated to sign a message',\n })\n }\n\n const stampedRequest = await this._turnkeyClient.stampSignRawPayload({\n organizationId: this._user.subOrgId,\n type: 'ACTIVITY_TYPE_SIGN_RAW_PAYLOAD_V2',\n timestampMs: Date.now().toString(),\n parameters: {\n encoding: 'PAYLOAD_ENCODING_HEXADECIMAL',\n hashFunction: 'HASH_FUNCTION_NO_OP',\n payload: msg,\n signWith: this._user.walletAddress,\n },\n })\n\n const { signature } = await this.request('/v1/sign', {\n stampedRequest,\n })\n\n return <Into>signature\n }\n\n protected async lookUpUser(email: string): Promise<string | null> {\n try {\n const { subOrgId } = await this.request('/v1/lookup', { email })\n return subOrgId\n } catch (error) {\n if (!(error instanceof SDKError)) throw error\n\n const sdkError: SDKError = error\n\n switch (sdkError.constructor.name) {\n case NotFoundError.name: {\n return null\n }\n default: {\n throw sdkError\n }\n }\n }\n }\n\n protected async whoAmI(subOrgId?: string) {\n const orgId = subOrgId || this._user?.subOrgId\n\n if (!orgId) throw new BadRequestError({ message: 'No orgId provided' })\n\n const stampedRequest = await this._turnkeyClient.stampGetWhoami({\n organizationId: orgId,\n })\n\n const { user, token } = await this.request('/v1/signin', {\n stampedRequest,\n })\n\n const credentialId = (() => {\n try {\n return JSON.parse(stampedRequest?.stamp.stampHeaderValue)\n .credentialId as string\n } catch (e) {\n return undefined\n }\n })()\n\n this._user = {\n ...user,\n credentialId: credentialId,\n }\n\n this.sessionStore.user = this.user!\n this.sessionStore.token = token\n }\n\n protected async request<Route extends AuthenticationServiceRoutes>(\n route: Route,\n body?: AuthenticationServiceBody<Route>,\n ): Promise<AuthenticationServiceResponse<Route>> {\n const url = new URL(`${route}`, this._configuration.apiUrl)\n const token = this.sessionStore.token\n\n const headers: Record<string, string> = {\n 'Content-Type': 'application/json',\n 'X-FOURT-KEY': this._configuration.apiKey,\n }\n\n // Add Authorization header if token exists\n if (token) {\n headers['Authorization'] = `Bearer ${token}`\n }\n\n const response = await fetch(url, {\n method: ROUTE_METHOD_MAP[route],\n body: JSON.stringify(body),\n headers,\n credentials: 'include',\n })\n\n const { data, error } = (await response.json()) as APIResponse<\n AuthenticationServiceResponse<Route>\n >\n\n if (error) {\n switch (error.kind) {\n case 'UnauthorizedError': {\n // TODO: workaround! this need to be cleaned up and moved into the web signer\n this.user = undefined\n this.sessionStore.clearAll()\n throw new UnauthorizedError({ message: error.message })\n }\n case 'NotFoundError': {\n throw new NotFoundError({ message: error.message })\n }\n case 'BadRequestError': {\n throw new BadRequestError({ message: error.message })\n }\n default: {\n throw new GenericError({ message: error.message })\n }\n }\n }\n\n return { ...data } as AuthenticationServiceResponse<Route>\n }\n}\n\nexport { SignerClient }\nexport type {\n SignerClientConstructorParams,\n SignerClientInheritedConstructorParams,\n}\n","type SDKErrorProps = {\n message: string\n}\n\nabstract class SDKError extends Error {\n private readonly _props: SDKErrorProps\n\n constructor(message: string, props: SDKErrorProps) {\n super(message)\n this._props = props\n }\n\n get message() {\n return this._props.message\n }\n}\n\nexport { SDKError }\nexport type { SDKErrorProps }\n","import { SDKErrorProps, SDKError } from './SDKError.js'\n\nclass UnauthorizedError extends SDKError {\n constructor(props: SDKErrorProps) {\n super(UnauthorizedError.name, props)\n }\n}\n\nexport { UnauthorizedError }\n","import { SDKErrorProps, SDKError } from './SDKError.js'\n\nclass NotFoundError extends SDKError {\n constructor(props: SDKErrorProps) {\n super(NotFoundError.name, props)\n }\n}\n\nexport { NotFoundError }\n","import { SDKErrorProps, SDKError } from './SDKError.js'\n\nclass GenericError extends SDKError {\n constructor(props: SDKErrorProps) {\n super(GenericError.name, props)\n }\n}\n\nexport { GenericError }\n","import { SDKErrorProps, SDKError } from './SDKError.js'\n\nclass UnauthenticatedError extends SDKError {\n constructor(props: SDKErrorProps) {\n super(UnauthenticatedError.name, props)\n }\n}\n\nexport { UnauthenticatedError }\n","import { SDKErrorProps, SDKError } from './SDKError.js'\n\nclass BadRequestError extends SDKError {\n constructor(props: SDKErrorProps) {\n super(BadRequestError.name, props)\n }\n}\n\nexport { BadRequestError }\n","import { createStore, type StoreApi } from 'zustand'\nimport { createJSONStorage, persist } from 'zustand/middleware'\nimport { User } from '../types/entities.js'\n\n/**\n * The state of the session.\n */\ntype SessionState = {\n user?: User\n expirationDate?: Date\n token?: string\n}\n\n/**\n * A store for the session state.\n */\nclass SessionStore {\n private readonly _store: StoreApi<SessionState>\n\n /**\n * Initializes a new instance of the `SessionStore` class by creating a new `zustand`store with the initial state.\n */\n constructor() {\n this._store = createStore<SessionState>()(\n persist(this._getInitialState, {\n name: 'fourt.io-signer-session',\n storage: createJSONStorage<SessionState>(() => localStorage),\n }),\n )\n }\n\n /**\n * Gets the token from the session state.\n *\n * @returns {string | undefined} the token.\n */\n get token(): string | undefined {\n return this._store.getState().token\n }\n\n /**\n * Sets the token in the session state.\n *\n * @param {string} token the token to set.\n */\n set token(token: string) {\n this._store.setState({ token })\n }\n\n /**\n * Gets the user from the session state.\n *\n * @returns {User | undefined} the user.\n */\n get user(): User | undefined {\n return this._store.getState().user\n }\n\n /**\n * Sets the user in the session state.\n *\n * @param {User} user the user to set.\n */\n set user(user: User) {\n this._store.setState({ ...this._store.getState(), user })\n }\n\n /**\n * Clears the user from the session state.\n */\n clearUser() {\n this._store.setState({ ...this._store.getState(), user: undefined })\n }\n\n /**\n * Clears the token from the session state.\n */\n clearToken() {\n this._store.setState({ ...this._store.getState(), token: undefined })\n }\n\n /**\n * Clears the token and user from the session state.\n */\n clearAll() {\n this.clearToken()\n this.clearUser()\n }\n\n private _getInitialState(): SessionState {\n return {\n user: undefined,\n token: undefined,\n }\n }\n}\n\nexport { SessionStore }\nexport type { SessionState }\n","import { getWebAuthnAttestation, TSignedRequest } from '@turnkey/http'\nimport { User } from './entities.js'\n\ntype AuthenticationServiceRoutes =\n AuthenticationServiceEndpoints[number]['Route']\n\ntype AuthenticationServiceBody<Route extends AuthenticationServiceRoutes> =\n Extract<AuthenticationServiceEndpoints[number], { Route: Route }>['Body']\n\ntype AuthenticationServiceResponse<Route extends AuthenticationServiceRoutes> =\n Extract<AuthenticationServiceEndpoints[number], { Route: Route }>['Response']\n\ntype AuthenticationServiceEndpoints = [\n {\n Route: '/v1/signup'\n Body: {\n passkey: {\n challenge: string\n attestation: Awaited<ReturnType<typeof getWebAuthnAttestation>>\n }\n email: string\n }\n Response: {\n user: User\n token: string\n }\n },\n {\n Route: '/v1/lookup'\n Body: {\n email: string\n }\n Response: {\n subOrgId: string\n }\n },\n {\n Route: '/v1/signin'\n Body: {\n stampedRequest: TSignedRequest\n }\n Response: {\n user: User\n token: string\n }\n },\n {\n Route: '/v1/sign'\n Body: {\n stampedRequest: TSignedRequest\n }\n Response: {\n signature: string\n }\n },\n]\n\nconst ROUTE_METHOD_MAP = {\n '/v1/signup': 'POST',\n '/v1/lookup': 'POST',\n '/v1/signin': 'POST',\n '/v1/sign': 'POST',\n} satisfies Record<AuthenticationServiceRoutes, 'POST' | 'GET'>\n\nexport type {\n AuthenticationServiceEndpoints,\n AuthenticationServiceResponse,\n AuthenticationServiceBody,\n AuthenticationServiceRoutes,\n}\n\nexport { ROUTE_METHOD_MAP }\n","import { Buffer } from 'buffer'\n\nclass LibBase64 {\n static fromBuffer(buffer: ArrayBuffer): string {\n return Buffer.from(buffer)\n .toString('base64')\n .replace(/\\+/g, '-')\n .replace(/\\//g, '_')\n .replace(/=/g, '')\n }\n\n static toBuffer(base64: string): ArrayBuffer {\n return Buffer.from(base64, 'base64')\n }\n}\n\nexport { LibBase64 }\n","type TakeBytesParams = Partial<{\n count: number\n offset: number\n}>\n\ntype ByteString = `0x${string}`\n\nclass LibBytes {\n static generateRandomBuffer = (): ArrayBuffer => {\n const arr = new Uint8Array(32)\n crypto.getRandomValues(arr)\n return arr.buffer\n }\n\n static takeBytes = (\n bytes: ByteString,\n params: TakeBytesParams = {},\n ): ByteString => {\n const { offset, count } = params\n const start = (offset ? offset * 2 : 0) + 2 // add 2 to skip the 0x prefix\n const end = count ? start + count * 2 : undefined\n\n return `0x${bytes.slice(start, end)}`\n }\n}\n\nexport { LibBytes }\n","import {\n LocalAccount,\n TypedData,\n TypedDataDefinition,\n SignableMessage,\n Hex,\n hashMessage,\n hashTypedData,\n SerializeTransactionFn,\n TransactionSerializable,\n IsNarrowable,\n TransactionSerialized,\n GetTransactionType,\n serializeTransaction,\n keccak256,\n Client,\n hexToBigInt,\n} from 'viem'\nimport { toAccount } from 'viem/accounts'\nimport { SignerClient } from '../signer/index.js'\nimport { LibBytes } from '../lib/bytes.js'\nimport { toLightSmartAccount } from 'permissionless/accounts'\nimport { entryPoint07Address } from 'viem/account-abstraction'\nimport { UnauthenticatedError } from '../errors/UnauthenticatedError.js'\n\ntype ViemModuleConstructorParams = {\n refs: {\n signerClient: SignerClient\n }\n}\n\ntype CurrentUserToLightSmartAccountParams = {\n owner: LocalAccount\n client: Client\n}\n\nclass ViemModule {\n constructor(private readonly _signerClient: SignerClient) {}\n\n async toLocalAccount(): Promise<LocalAccount> {\n const user = this._signerClient.user\n\n if (!user) {\n throw new UnauthenticatedError({ message: 'Signer not authenticated' })\n }\n\n return toAccount({\n address: user.walletAddress,\n signMessage: (msg) => this.signMessage(msg.message),\n signTypedData: <\n const typedData extends TypedData | Record<string, unknown>,\n primaryType extends keyof typedData | 'EIP712Domain' = keyof typedData,\n >(\n typedDataDefinition: TypedDataDefinition<typedData, primaryType>,\n ) => this.signTypedData<typedData, primaryType>(typedDataDefinition),\n signTransaction: this.signTransaction,\n })\n }\n\n async toSmartAccount({\n client,\n owner,\n }: CurrentUserToLightSmartAccountParams): ReturnType<\n typeof toLightSmartAccount<'0.7'>\n > {\n const user = this._signerClient.user\n\n if (!user) {\n throw new UnauthenticatedError({ message: 'Signer not authenticated' })\n }\n\n return toLightSmartAccount({\n client: client,\n owner,\n version: '2.0.0',\n entryPoint: {\n address: entryPoint07Address,\n version: '0.7',\n },\n address: user.smartAccountAddress,\n index: hexToBigInt(user.salt),\n })\n }\n\n async signMessage(msg: SignableMessage): Promise<Hex> {\n const messageHash = hashMessage(msg)\n const result = await this._signerClient.signRawMessage<Hex>(messageHash)\n return result\n }\n\n async signTypedData<\n TTypedData extends TypedData | Record<string, unknown>,\n TPrimaryType extends keyof TTypedData | 'EIP712Domain' = keyof TTypedData,\n >(params: TypedDataDefinition<TTypedData, TPrimaryType>): Promise<Hex> {\n const messageHash = hashTypedData(params)\n return this._signerClient.signRawMessage(messageHash)\n }\n\n async signTransaction<\n serializer extends SerializeTransactionFn<TransactionSerializable> = SerializeTransactionFn<TransactionSerializable>,\n transaction extends Parameters<serializer>[0] = Parameters<serializer>[0],\n >(\n transaction: transaction,\n options?:\n | {\n serializer?: serializer | undefined\n }\n | undefined,\n ): Promise<\n IsNarrowable<\n TransactionSerialized<GetTransactionType<transaction>>,\n Hex\n > extends true\n ? TransactionSerialized<GetTransactionType<transaction>>\n : Hex\n > {\n const serializeFn = options?.serializer ?? serializeTransaction\n const serializedTx = serializeFn(transaction)\n const signatureHex = await this._signerClient.signRawMessage<Hex>(\n keccak256(serializedTx),\n )\n\n const signature = {\n r: LibBytes.takeBytes(signatureHex, { count: 32 }),\n s: LibBytes.takeBytes(signatureHex, { count: 32, offset: 32 }),\n v: BigInt(LibBytes.takeBytes(signatureHex, { count: 1, offset: 64 })),\n }\n\n return serializeFn(transaction, signature)\n }\n}\n\nexport { ViemModule }\n","import type { WebSignerClient, WebauthnSignInParams } from '../../signer/web.js'\n\n/**\n * A module for interacting with the Passkeys authentication methods.\n * Available through the `auth.passkeys` property on a `FourtWebSigner` instance.\n */\nclass PasskeysModule {\n constructor(private readonly _webSignerClient: WebSignerClient) {}\n\n /**\n * Signs in a user using Passkeys.\n *\n * @param params {WebauthnSignInParams} params for the sign-in process.\n * @returns {Promise<void>} promise that resolves to the result of the sign-in process.\n */\n async signIn(params: WebauthnSignInParams) {\n return this._webSignerClient.webauthnSignIn(params)\n }\n}\n\nexport { PasskeysModule }\n","import type { WebSignerClient } from '../../signer/web.js'\nimport { PasskeysModule } from './passkeys.js'\n\n/**\n * A module for interacting with the authentication methods.\n * Available through the `auth` property on a `FourtWebSigner` instance.\n */\nclass AuthModule {\n private readonly _passkeys: PasskeysModule\n\n /**\n * Initializes a new instance of the `AuthModule` class.\n *\n * @param {WebSignerClient} _webSignerClient underlying WebSigner client instance.\n */\n constructor(private readonly _webSignerClient: WebSignerClient) {\n this._passkeys = new PasskeysModule(this._webSignerClient)\n }\n\n /**\n * A module for interacting with the Passkeys authentication methods.\n */\n get passkeys() {\n return this._passkeys\n }\n}\n\nexport { AuthModule }\nexport { PasskeysModule } from './passkeys.js'\n","import { WebSignerClient } from '../../signer/web.js'\nimport { User } from '../../types/entities.js'\n\n/**\n * A module for interacting with the user methods.\n * Available through the `user` property on a `FourtWebSigner` instance.\n */\nclass UserModule {\n /**\n * Initializes a new instance of the `UserModule` class.\n *\n * @param {WebSignerClient} _webSignerClient underlying WebSigner client instance.\n */\n constructor(private readonly _webSignerClient: WebSignerClient) {}\n\n /**\n * Gets the user information.\n *\n * @returns {User | undefined} user information.\n */\n get info() {\n return this._webSignerClient.user\n }\n}\n\nexport { UserModule }\n","import { SignerClientConstructorParams } from './signer/index.js'\nimport {\n WebauthnSignInParams,\n WebSignerClient,\n WebSignerClientConstructorParams,\n} from './signer/web.js'\nimport { ViemModule } from './third-party/viem.js'\nimport { AuthModule, UserModule } from './modules/index.js'\n\ntype FourtWebSignerConstructorParams = {\n configuration: SignerClientConstructorParams['configuration']\n auth: Pick<WebSignerClientConstructorParams, 'webauthn'>\n}\n\n/**\n * A client for interacting with the Fourt Web Signer.\n */\nclass FourtWebSigner {\n private readonly _webSignerClient: WebSignerClient\n private readonly _modules: {\n viem: ViemModule\n auth: AuthModule\n user: UserModule\n }\n\n /**\n * Initializes a new instance of the `FourtWebSigner` class.\n * Sets up the underlying modules.\n *\n *\n * @example\n * ```ts\n * const fourtWebSigner = new FourtWebSigner({\n * auth: {\n * webauthn: {\n * rpId: 'localhost',\n * },\n * },\n * configuration: {\n * apiKey: '927d603c-6775-4210-8e13-8904ca985e78',\n * },\n * })\n * ```\n *\n * @param {FourtWebSignerConstructorParams} params the required parameters to initialize the client\n */\n constructor({\n configuration,\n auth: { webauthn },\n }: FourtWebSignerConstructorParams) {\n this._webSignerClient = new WebSignerClient({\n configuration,\n webauthn,\n })\n\n this._modules = {\n viem: new ViemModule(this._webSignerClient),\n auth: new AuthModule(this._webSignerClient),\n user: new UserModule(this._webSignerClient),\n }\n }\n\n /**\n * A module for interacting with the Viem library.\n */\n get viem() {\n return this._modules.viem\n }\n\n /**\n * A module for interacting with the authentication methods.\n */\n get auth() {\n return this._modules.auth\n }\n\n /**\n * A module for interacting with the user methods.\n */\n get user() {\n return this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ACd,MAAM,IAAI,WAAW,KAAK,gBAAgB;AAAA,MAC1C,MAAM,IAAI,WAAW,KAAK,gBAAgB;AAAA,MAC1C,MAAM,IAAI,WAAW,KAAK,gBAAgB;AAAA,IAC5C;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,OAAO;AACT,WAAO,KAAK,SAAS;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,OAAO;AACT,WAAO,KAAK,SAAS;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,OAAO;AACT,WAAO,KAAK,SAAS;AAAA,EACvB;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/signer/web.ts","../src/signer/index.ts","../src/errors/SDKError.ts","../src/errors/UnauthorizedError.ts","../src/errors/NotFoundError.ts","../src/errors/GenericError.ts","../src/errors/UnauthenticatedError.ts","../src/errors/BadRequestError.ts","../src/session/index.ts","../src/types/Routes.ts","../src/lib/base64.ts","../src/lib/bytes.ts","../src/third-party/viem.ts","../src/modules/auth/passkeys.ts","../src/modules/auth/index.ts","../src/modules/user/index.ts","../src/index.ts"],"sourcesContent":["import { WebauthnStamper } from '@turnkey/webauthn-stamper'\nimport {\n type SignerClientInheritedConstructorParams,\n SignerClient,\n} from './index.js'\nimport { LibBase64 } from '../lib/base64.js'\nimport { LibBytes } from '../lib/bytes.js'\nimport { getWebAuthnAttestation } from '@turnkey/http'\n\ntype WebauthnSignInParams = {\n email: string\n}\n\ntype WebSignerClientConstructorParams = SignerClientInheritedConstructorParams<{\n webauthn: {\n rpId: string\n }\n}>\n\ntype CreateAccountParams = {\n method: 'webauthn'\n email: string\n}\n\n/**\n * A signer client for web applications.\n */\nclass WebSignerClient extends SignerClient {\n private readonly _stampers: {\n webauthn: WebauthnStamper\n }\n\n /**\n * Initializes a new instance of the `WebSignerClient` class.\n *\n * @param {WebSignerClientConstructorParams} params params for the constructor\n */\n constructor({ configuration, webauthn }: WebSignerClientConstructorParams) {\n const webauthnStamper = new WebauthnStamper({ rpId: webauthn.rpId })\n\n super({\n stamper: webauthnStamper,\n configuration: configuration,\n })\n\n this._stampers = {\n webauthn: webauthnStamper,\n }\n }\n\n /**\n * Signs in a user with webauthn.\n *\n * @param {WebauthnSignInParams} params params for the sign in\n */\n async webauthnSignIn({ email }: WebauthnSignInParams) {\n const existingUserSubOrgId = await this.lookUpUser(email)\n\n if (!existingUserSubOrgId) {\n await this._createAccount({ method: 'webauthn', email })\n } else {\n await this.whoAmI(existingUserSubOrgId)\n\n // We should assure that the user and its credentialId are set\n if (!this.user || !this.user.credentialId) {\n return\n }\n\n this.stamper = this._stampers.webauthn\n this._stampers.webauthn.allowCredentials = [\n {\n id: LibBase64.toBuffer(this.user.credentialId),\n type: 'public-key',\n transports: ['internal', 'usb'],\n },\n ]\n }\n }\n\n private async _createAccount(params: CreateAccountParams) {\n const { challenge, attestation } = await this._webauthnGenerateAttestation(\n params.email,\n )\n\n const {\n token,\n user: { id, email, subOrgId, walletAddress, salt, smartAccountAddress },\n } = await this.request('/v1/signup', {\n passkey: {\n challenge: LibBase64.fromBuffer(challenge),\n attestation,\n },\n email: params.email,\n })\n\n this.user = {\n id,\n email,\n subOrgId,\n walletAddress,\n salt,\n smartAccountAddress,\n credentialId: attestation.credentialId,\n }\n\n this._sessionStore.token = token\n }\n\n private async _webauthnGenerateAttestation(email: string) {\n const challenge = LibBytes.generateRandomBuffer()\n const authenticatorUserId = LibBytes.generateRandomBuffer()\n\n const attestation = await getWebAuthnAttestation({\n publicKey: {\n authenticatorSelection: {\n residentKey: 'preferred',\n requireResidentKey: false,\n userVerification: 'preferred',\n },\n challenge,\n rp: {\n id: window.location.hostname,\n name: window.location.hostname,\n },\n pubKeyCredParams: [\n {\n type: 'public-key',\n alg: -7,\n },\n {\n type: 'public-key',\n alg: -257,\n },\n ],\n user: {\n id: authenticatorUserId,\n name: email,\n displayName: email,\n },\n },\n })\n\n return { challenge, attestation, authenticatorUserId }\n }\n}\n\nexport { WebSignerClient }\nexport type {\n WebSignerClientConstructorParams,\n WebauthnSignInParams,\n CreateAccountParams,\n}\n","import { TurnkeyClient } from '@turnkey/http'\nimport {\n BadRequestError,\n GenericError,\n NotFoundError,\n UnauthorizedError,\n} from '../errors/index.js'\nimport { SDKError } from '../errors/SDKError.js'\nimport { SessionStore } from '../session/index.js'\nimport { User } from '../types/entities.js'\nimport { APIResponse } from '../types/rest.js'\nimport {\n AuthenticationServiceBody,\n AuthenticationServiceResponse,\n AuthenticationServiceRoutes,\n ROUTE_METHOD_MAP,\n} from '../types/Routes.js'\nimport { jwtDecode, JwtPayload } from 'jwt-decode'\nimport { isPast, secondsToMilliseconds } from 'date-fns'\n\ntype SignerClientConfiguration = {\n apiKey: string\n apiUrl?: string\n}\n\ntype SignerClientConstructorParams = {\n stamper: TurnkeyClient['stamper']\n configuration: SignerClientConfiguration\n}\n\ntype SignerClientInheritedConstructorParams<\n Extended extends Record<string, unknown>,\n> = Pick<SignerClientConstructorParams, 'configuration'> & Extended\n\nabstract class SignerClient {\n protected readonly _turnkeyClient: TurnkeyClient\n protected readonly _configuration: Required<SignerClientConfiguration>\n protected readonly _sessionStore: SessionStore\n\n private _user?: User\n\n constructor({\n stamper,\n configuration: { apiUrl, ...requiredConfiguration },\n }: SignerClientConstructorParams) {\n this._turnkeyClient = new TurnkeyClient(\n { baseUrl: 'https://api.turnkey.com' },\n stamper,\n )\n\n this._configuration = {\n ...requiredConfiguration,\n apiUrl: apiUrl ?? 'https://auth.api.dev.fourt.io/',\n }\n\n this._sessionStore = new SessionStore()\n }\n\n logout() {\n this._user = undefined\n this.sessionStore.clearAll()\n }\n\n get user(): User | undefined {\n if (this._user) return this._user\n\n // Check if there's a token\n if (!this.sessionStore.token) {\n this.sessionStore.clearAll()\n return undefined\n }\n\n const decodedToken = jwtDecode<JwtPayload>(this.sessionStore.token)\n // Check if the token has expired\n if (\n decodedToken.exp &&\n isPast(new Date(secondsToMilliseconds(decodedToken.exp)))\n ) {\n this.sessionStore.clearAll()\n return undefined\n }\n\n if (this.sessionStore.user) this._user = this.sessionStore.user\n\n return this._user\n }\n\n protected set user(value: User | undefined) {\n this._user = value\n }\n\n protected set stamper(stamper: TurnkeyClient['stamper']) {\n this._turnkeyClient.stamper = stamper\n }\n\n protected get stamper(): TurnkeyClient['stamper'] {\n return this._turnkeyClient.stamper\n }\n\n protected get sessionStore(): SessionStore {\n return this._sessionStore\n }\n\n async signRawMessage<Into extends string>(msg: string): Promise<Into> {\n if (!this._user) {\n throw new UnauthorizedError({\n message: 'SignerClient must be authenticated to sign a message',\n })\n }\n\n const stampedRequest = await this._turnkeyClient.stampSignRawPayload({\n organizationId: this._user.subOrgId,\n type: 'ACTIVITY_TYPE_SIGN_RAW_PAYLOAD_V2',\n timestampMs: Date.now().toString(),\n parameters: {\n encoding: 'PAYLOAD_ENCODING_HEXADECIMAL',\n hashFunction: 'HASH_FUNCTION_NO_OP',\n payload: msg,\n signWith: this._user.walletAddress,\n },\n })\n\n const { signature } = await this.request('/v1/sign', {\n stampedRequest,\n })\n\n return <Into>signature\n }\n\n protected async lookUpUser(email: string): Promise<string | null> {\n try {\n const { subOrgId } = await this.request('/v1/lookup', { email })\n return subOrgId\n } catch (error) {\n if (!(error instanceof SDKError)) throw error\n\n const sdkError: SDKError = error\n\n switch (sdkError.constructor.name) {\n case NotFoundError.name: {\n return null\n }\n default: {\n throw sdkError\n }\n }\n }\n }\n\n protected async whoAmI(subOrgId?: string) {\n const orgId = subOrgId || this._user?.subOrgId\n\n if (!orgId) throw new BadRequestError({ message: 'No orgId provided' })\n\n const stampedRequest = await this._turnkeyClient.stampGetWhoami({\n organizationId: orgId,\n })\n\n const { user, token } = await this.request('/v1/signin', {\n stampedRequest,\n })\n\n const credentialId = (() => {\n try {\n return JSON.parse(stampedRequest?.stamp.stampHeaderValue)\n .credentialId as string\n } catch (e) {\n return undefined\n }\n })()\n\n this._user = {\n ...user,\n credentialId: credentialId,\n }\n\n this.sessionStore.user = this.user!\n this.sessionStore.token = token\n }\n\n protected async request<Route extends AuthenticationServiceRoutes>(\n route: Route,\n body?: AuthenticationServiceBody<Route>,\n ): Promise<AuthenticationServiceResponse<Route>> {\n const url = new URL(`${route}`, this._configuration.apiUrl)\n const token = this.sessionStore.token\n\n const headers: Record<string, string> = {\n 'Content-Type': 'application/json',\n 'X-FOURT-KEY': this._configuration.apiKey,\n }\n\n // Add Authorization header if token exists\n if (token) {\n headers['Authorization'] = `Bearer ${token}`\n }\n\n const response = await fetch(url, {\n method: ROUTE_METHOD_MAP[route],\n body: JSON.stringify(body),\n headers,\n credentials: 'include',\n })\n\n const { data, error } = (await response.json()) as APIResponse<\n AuthenticationServiceResponse<Route>\n >\n\n if (error) {\n switch (error.kind) {\n case 'UnauthorizedError': {\n // TODO: workaround! this need to be cleaned up and moved into the web signer\n this.logout()\n throw new UnauthorizedError({ message: error.message })\n }\n case 'NotFoundError': {\n throw new NotFoundError({ message: error.message })\n }\n case 'BadRequestError': {\n throw new BadRequestError({ message: error.message })\n }\n default: {\n throw new GenericError({ message: error.message })\n }\n }\n }\n\n return { ...data } as AuthenticationServiceResponse<Route>\n }\n}\n\nexport { SignerClient }\nexport type {\n SignerClientConstructorParams,\n SignerClientInheritedConstructorParams,\n}\n","type SDKErrorProps = {\n message: string\n}\n\nabstract class SDKError extends Error {\n private readonly _props: SDKErrorProps\n\n constructor(message: string, props: SDKErrorProps) {\n super(message)\n this._props = props\n }\n\n get message() {\n return this._props.message\n }\n}\n\nexport { SDKError }\nexport type { SDKErrorProps }\n","import { SDKErrorProps, SDKError } from './SDKError.js'\n\nclass UnauthorizedError extends SDKError {\n constructor(props: SDKErrorProps) {\n super(UnauthorizedError.name, props)\n }\n}\n\nexport { UnauthorizedError }\n","import { SDKErrorProps, SDKError } from './SDKError.js'\n\nclass NotFoundError extends SDKError {\n constructor(props: SDKErrorProps) {\n super(NotFoundError.name, props)\n }\n}\n\nexport { NotFoundError }\n","import { SDKErrorProps, SDKError } from './SDKError.js'\n\nclass GenericError extends SDKError {\n constructor(props: SDKErrorProps) {\n super(GenericError.name, props)\n }\n}\n\nexport { GenericError }\n","import { SDKErrorProps, SDKError } from './SDKError.js'\n\nclass UnauthenticatedError extends SDKError {\n constructor(props: SDKErrorProps) {\n super(UnauthenticatedError.name, props)\n }\n}\n\nexport { UnauthenticatedError }\n","import { SDKErrorProps, SDKError } from './SDKError.js'\n\nclass BadRequestError extends SDKError {\n constructor(props: SDKErrorProps) {\n super(BadRequestError.name, props)\n }\n}\n\nexport { BadRequestError }\n","import { createStore, type StoreApi } from 'zustand'\nimport { createJSONStorage, persist } from 'zustand/middleware'\nimport { User } from '../types/entities.js'\n\n/**\n * The state of the session.\n */\ntype SessionState = {\n user?: User\n expirationDate?: Date\n token?: string\n}\n\n/**\n * A store for the session state.\n */\nclass SessionStore {\n private readonly _store: StoreApi<SessionState>\n\n /**\n * Initializes a new instance of the `SessionStore` class by creating a new `zustand`store with the initial state.\n */\n constructor() {\n this._store = createStore<SessionState>()(\n persist(this._getInitialState, {\n name: 'fourt.io-signer-session',\n storage: createJSONStorage<SessionState>(() => localStorage),\n }),\n )\n }\n\n /**\n * Gets the token from the session state.\n *\n * @returns {string | undefined} the token.\n */\n get token(): string | undefined {\n return this._store.getState().token\n }\n\n /**\n * Sets the token in the session state.\n *\n * @param {string} token the token to set.\n */\n set token(token: string) {\n this._store.setState({ token })\n }\n\n /**\n * Gets the user from the session state.\n *\n * @returns {User | undefined} the user.\n */\n get user(): User | undefined {\n return this._store.getState().user\n }\n\n /**\n * Sets the user in the session state.\n *\n * @param {User} user the user to set.\n */\n set user(user: User) {\n this._store.setState({ ...this._store.getState(), user })\n }\n\n /**\n * Clears the user from the session state.\n */\n clearUser() {\n this._store.setState({ ...this._store.getState(), user: undefined })\n }\n\n /**\n * Clears the token from the session state.\n */\n clearToken() {\n this._store.setState({ ...this._store.getState(), token: undefined })\n }\n\n /**\n * Clears the token and user from the session state.\n */\n clearAll() {\n this.clearToken()\n this.clearUser()\n }\n\n private _getInitialState(): SessionState {\n return {\n user: undefined,\n token: undefined,\n }\n }\n}\n\nexport { SessionStore }\nexport type { SessionState }\n","import { getWebAuthnAttestation, TSignedRequest } from '@turnkey/http'\nimport { User } from './entities.js'\n\ntype AuthenticationServiceRoutes =\n AuthenticationServiceEndpoints[number]['Route']\n\ntype AuthenticationServiceBody<Route extends AuthenticationServiceRoutes> =\n Extract<AuthenticationServiceEndpoints[number], { Route: Route }>['Body']\n\ntype AuthenticationServiceResponse<Route extends AuthenticationServiceRoutes> =\n Extract<AuthenticationServiceEndpoints[number], { Route: Route }>['Response']\n\ntype AuthenticationServiceEndpoints = [\n {\n Route: '/v1/signup'\n Body: {\n passkey: {\n challenge: string\n attestation: Awaited<ReturnType<typeof getWebAuthnAttestation>>\n }\n email: string\n }\n Response: {\n user: User\n token: string\n }\n },\n {\n Route: '/v1/lookup'\n Body: {\n email: string\n }\n Response: {\n subOrgId: string\n }\n },\n {\n Route: '/v1/signin'\n Body: {\n stampedRequest: TSignedRequest\n }\n Response: {\n user: User\n token: string\n }\n },\n {\n Route: '/v1/sign'\n Body: {\n stampedRequest: TSignedRequest\n }\n Response: {\n signature: string\n }\n },\n]\n\nconst ROUTE_METHOD_MAP = {\n '/v1/signup': 'POST',\n '/v1/lookup': 'POST',\n '/v1/signin': 'POST',\n '/v1/sign': 'POST',\n} satisfies Record<AuthenticationServiceRoutes, 'POST' | 'GET'>\n\nexport type {\n AuthenticationServiceEndpoints,\n AuthenticationServiceResponse,\n AuthenticationServiceBody,\n AuthenticationServiceRoutes,\n}\n\nexport { ROUTE_METHOD_MAP }\n","import { Buffer } from 'buffer'\n\nclass LibBase64 {\n static fromBuffer(buffer: ArrayBuffer): string {\n return Buffer.from(buffer)\n .toString('base64')\n .replace(/\\+/g, '-')\n .replace(/\\//g, '_')\n .replace(/=/g, '')\n }\n\n static toBuffer(base64: string): ArrayBuffer {\n return Buffer.from(base64, 'base64')\n }\n}\n\nexport { LibBase64 }\n","type TakeBytesParams = Partial<{\n count: number\n offset: number\n}>\n\ntype ByteString = `0x${string}`\n\nclass LibBytes {\n static generateRandomBuffer = (): ArrayBuffer => {\n const arr = new Uint8Array(32)\n crypto.getRandomValues(arr)\n return arr.buffer\n }\n\n static takeBytes = (\n bytes: ByteString,\n params: TakeBytesParams = {},\n ): ByteString => {\n const { offset, count } = params\n const start = (offset ? offset * 2 : 0) + 2 // add 2 to skip the 0x prefix\n const end = count ? start + count * 2 : undefined\n\n return `0x${bytes.slice(start, end)}`\n }\n}\n\nexport { LibBytes }\n","import {\n LocalAccount,\n TypedData,\n TypedDataDefinition,\n SignableMessage,\n Hex,\n hashMessage,\n hashTypedData,\n SerializeTransactionFn,\n TransactionSerializable,\n IsNarrowable,\n TransactionSerialized,\n GetTransactionType,\n serializeTransaction,\n keccak256,\n Client,\n hexToBigInt,\n} from 'viem'\nimport { toAccount } from 'viem/accounts'\nimport { SignerClient } from '../signer/index.js'\nimport { LibBytes } from '../lib/bytes.js'\nimport { toLightSmartAccount } from 'permissionless/accounts'\nimport { entryPoint07Address } from 'viem/account-abstraction'\nimport { UnauthenticatedError } from '../errors/UnauthenticatedError.js'\n\ntype ViemModuleConstructorParams = {\n refs: {\n signerClient: SignerClient\n }\n}\n\ntype CurrentUserToLightSmartAccountParams = {\n owner: LocalAccount\n client: Client\n}\n\nclass ViemModule {\n constructor(private readonly _signerClient: SignerClient) {}\n\n async toLocalAccount(): Promise<LocalAccount> {\n const user = this._signerClient.user\n\n if (!user) {\n throw new UnauthenticatedError({ message: 'Signer not authenticated' })\n }\n\n return toAccount({\n address: user.walletAddress,\n signMessage: (msg) => this.signMessage(msg.message),\n signTypedData: <\n const typedData extends TypedData | Record<string, unknown>,\n primaryType extends keyof typedData | 'EIP712Domain' = keyof typedData,\n >(\n typedDataDefinition: TypedDataDefinition<typedData, primaryType>,\n ) => this.signTypedData<typedData, primaryType>(typedDataDefinition),\n signTransaction: this.signTransaction,\n })\n }\n\n async toSmartAccount({\n client,\n owner,\n }: CurrentUserToLightSmartAccountParams): ReturnType<\n typeof toLightSmartAccount<'0.7'>\n > {\n const user = this._signerClient.user\n\n if (!user) {\n throw new UnauthenticatedError({ message: 'Signer not authenticated' })\n }\n\n return toLightSmartAccount({\n client: client,\n owner,\n version: '2.0.0',\n entryPoint: {\n address: entryPoint07Address,\n version: '0.7',\n },\n address: user.smartAccountAddress,\n index: hexToBigInt(user.salt),\n })\n }\n\n async signMessage(msg: SignableMessage): Promise<Hex> {\n const messageHash = hashMessage(msg)\n const result = await this._signerClient.signRawMessage<Hex>(messageHash)\n return result\n }\n\n async signTypedData<\n TTypedData extends TypedData | Record<string, unknown>,\n TPrimaryType extends keyof TTypedData | 'EIP712Domain' = keyof TTypedData,\n >(params: TypedDataDefinition<TTypedData, TPrimaryType>): Promise<Hex> {\n const messageHash = hashTypedData(params)\n return this._signerClient.signRawMessage(messageHash)\n }\n\n async signTransaction<\n serializer extends SerializeTransactionFn<TransactionSerializable> = SerializeTransactionFn<TransactionSerializable>,\n transaction extends Parameters<serializer>[0] = Parameters<serializer>[0],\n >(\n transaction: transaction,\n options?:\n | {\n serializer?: serializer | undefined\n }\n | undefined,\n ): Promise<\n IsNarrowable<\n TransactionSerialized<GetTransactionType<transaction>>,\n Hex\n > extends true\n ? TransactionSerialized<GetTransactionType<transaction>>\n : Hex\n > {\n const serializeFn = options?.serializer ?? serializeTransaction\n const serializedTx = serializeFn(transaction)\n const signatureHex = await this._signerClient.signRawMessage<Hex>(\n keccak256(serializedTx),\n )\n\n const signature = {\n r: LibBytes.takeBytes(signatureHex, { count: 32 }),\n s: LibBytes.takeBytes(signatureHex, { count: 32, offset: 32 }),\n v: BigInt(LibBytes.takeBytes(signatureHex, { count: 1, offset: 64 })),\n }\n\n return serializeFn(transaction, signature)\n }\n}\n\nexport { ViemModule }\n","import type { WebSignerClient, WebauthnSignInParams } from '../../signer/web.js'\n\n/**\n * A module for interacting with the Passkeys authentication methods.\n * Available through the `auth.passkeys` property on a `FourtWebSigner` instance.\n */\nclass PasskeysModule {\n constructor(private readonly _webSignerClient: WebSignerClient) {}\n\n /**\n * Signs in a user using Passkeys.\n *\n * @param params {WebauthnSignInParams} params for the sign-in process.\n * @returns {Promise<void>} promise that resolves to the result of the sign-in process.\n */\n async signIn(params: WebauthnSignInParams) {\n return this._webSignerClient.webauthnSignIn(params)\n }\n}\n\nexport { PasskeysModule }\n","import type { WebSignerClient } from '../../signer/web.js'\nimport { PasskeysModule } from './passkeys.js'\n\n/**\n * A module for interacting with the authentication methods.\n * Available through the `auth` property on a `FourtWebSigner` instance.\n */\nclass AuthModule {\n private readonly _passkeys: PasskeysModule\n\n /**\n * Initializes a new instance of the `AuthModule` class.\n *\n * @param {WebSignerClient} _webSignerClient underlying WebSigner client instance.\n */\n constructor(private readonly _webSignerClient: WebSignerClient) {\n this._passkeys = new PasskeysModule(this._webSignerClient)\n }\n\n /**\n * A module for interacting with the Passkeys authentication methods.\n */\n get passkeys() {\n return this._passkeys\n }\n}\n\nexport { AuthModule }\nexport { PasskeysModule } from './passkeys.js'\n","import { WebSignerClient } from '../../signer/web.js'\nimport { User } from '../../types/entities.js'\n\n/**\n * A module for interacting with the user methods.\n * Available through the `user` property on a `FourtWebSigner` instance.\n */\nclass UserModule {\n /**\n * Initializes a new instance of the `UserModule` class.\n *\n * @param {WebSignerClient} _webSignerClient underlying WebSigner client instance.\n */\n constructor(private readonly _webSignerClient: WebSignerClient) {}\n\n /**\n * Gets the user information.\n *\n * @returns {User | undefined} user information.\n */\n get info() {\n return this._webSignerClient.user\n }\n\n /**\n * Logs out the user.\n *\n * @returns {void}\n */\n logout() {\n return this._webSignerClient.logout()\n }\n}\n\nexport { UserModule }\n","import { SignerClientConstructorParams } from './signer/index.js'\nimport {\n WebauthnSignInParams,\n WebSignerClient,\n WebSignerClientConstructorParams,\n} from './signer/web.js'\nimport { ViemModule } from './third-party/viem.js'\nimport { AuthModule, UserModule } from './modules/index.js'\n\ntype FourtWebSignerConstructorParams = {\n configuration: SignerClientConstructorParams['configuration']\n auth: Pick<WebSignerClientConstructorParams, 'webauthn'>\n}\n\n/**\n * A client for interacting with the Fourt Web Signer.\n */\nclass FourtWebSigner {\n private readonly _webSignerClient: WebSignerClient\n private readonly _modules: {\n viem: ViemModule\n auth: AuthModule\n user: UserModule\n }\n\n /**\n * Initializes a new instance of the `FourtWebSigner` class.\n * Sets up the underlying modules.\n *\n *\n * @example\n * ```ts\n * const fourtWebSigner = new FourtWebSigner({\n * auth: {\n * webauthn: {\n * rpId: 'localhost',\n * },\n * },\n * configuration: {\n * apiKey: '927d603c-6775-4210-8e13-8904ca985e78',\n * },\n * })\n * ```\n *\n * @param {FourtWebSignerConstructorParams} params the required parameters to initialize the client\n */\n constructor({\n configuration,\n auth: { webauthn },\n }: FourtWebSignerConstructorParams) {\n this._webSignerClient = new WebSignerClient({\n configuration,\n webauthn,\n })\n\n this._modules = {\n viem: new ViemModule(this._webSignerClient),\n auth: new AuthModule(this._webSignerClient),\n user: new UserModule(this._webSignerClient),\n }\n }\n\n /**\n * A module for interacting with the Viem library.\n */\n get viem() {\n return this._modules.viem\n }\n\n /**\n * A module for interacting with the authentication methods.\n */\n get auth() {\n return this._modules.auth\n }\n\n /**\n * A module for interacting with the user methods.\n */\n get user() {\n return this._modules.user\n }\n}\n\nexport { FourtWebSigner }\n"],"mappings":";AAAA,SAAS,uBAAuB;;;ACAhC,SAAS,qBAAqB;;;ACI9B,IAAe,WAAf,cAAgC,MAAM;AAAA,EACnB;AAAA,EAEjB,YAAY,SAAiB,OAAsB;AACjD,UAAM,OAAO;AACb,SAAK,SAAS;AAAA,EAChB;AAAA,EAEA,IAAI,UAAU;AACZ,WAAO,KAAK,OAAO;AAAA,EACrB;AACF;;;ACbA,IAAM,oBAAN,MAAM,2BAA0B,SAAS;AAAA,EACvC,YAAY,OAAsB;AAChC,UAAM,mBAAkB,MAAM,KAAK;AAAA,EACrC;AACF;;;ACJA,IAAM,gBAAN,MAAM,uBAAsB,SAAS;AAAA,EACnC,YAAY,OAAsB;AACh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