UNPKG

@osiris-ai/turnkey-sdk

Version:
468 lines (463 loc) 13.6 kB
import { ApiKeyStamper } from '@turnkey/api-key-stamper'; import { WalletAuthenticator, GetWalletRequest, GetWalletResponse, AddAccountRequest, AddAccountResponse, CreateWalletRequest as CreateWalletRequest$1, CreateWalletResponse as CreateWalletResponse$1, ActionParams, Web3ActionData, ActionResponse } from '@osiris-ai/sdk'; declare const getChainIdFromAddressFormat: (addressFormat: string) => "evm:eip155:1" | "solana:mainnet-beta"; type ChainId = 'evm' | 'solana'; interface Vote { id: string; userId: string; user: { userId: string; userName: string; userEmail: string; authenticators: { transports: string[]; attestationType: string; aaguid: string; credentialId: string; model: string; credential: { publicKey: string; type: string; }; authenticatorId: string; authenticatorName: string; createdAt: Timestamp; updatedAt: Timestamp; }[]; apiKeys: { credential: { publicKey: string; type: string; }; apiKeyId: string; apiKeyName: string; createdAt: Timestamp; updatedAt: Timestamp; }[]; userTags: string[]; oauthProviders: { providerName: string; oidcToken: string; }[]; createdAt: Timestamp; updatedAt: Timestamp; }; activityId: string; selection: string; message: string; publicKey: string; signature: string; scheme: string; createdAt: Timestamp; } interface ListWalletsRequest { organizationId: string; } interface ListWalletsResponse { activity: { id: string; status: string; type: string; organizationId: string; timestampMs: string; result: { wallets: { walletId: string; walletName: string; createdAt: Timestamp; updatedAt: Timestamp; exported: boolean; imported: boolean; }[]; }; votes: Vote[]; fingerprint: string; canApprove: boolean; canReject: boolean; createdAt: Timestamp; updatedAt: Timestamp; failure: null | any; }; } interface ListWalletAccountsRequest { organizationId: string; walletId: string; paginationOptions: { limit: string; before: string; after: string; }; } interface ListWalletAccountsResponse { accounts: { walletAccountId: string; organizationId: string; walletId: string; curve: string; pathFormat: string; path: string; addressFormat: string; address: string; createdAt: { seconds: string; nanos: string; }; updatedAt: { seconds: string; nanos: string; }; publicKey: string; }[]; } interface ApiKey { apiKeyName: string; publicKey: string; curveType: string; } interface Authenticator { authenticatorName: string; challenge: string; attestation: any; } interface OauthProvider { oauthProviderName: string; oidcToken: string; } interface RootUser { userName: string; apiKeys: ApiKey[]; authenticators: Authenticator[]; oauthProviders: OauthProvider[]; } interface Account { pathFormat: string; path: string; curve: string; addressFormat: string; } interface Wallet { walletName: string; accounts: Account[]; mnemonicLength: number; } interface CreateWalletRequest { subOrganizationName: string; rootUsers: RootUser[]; rootQuorumThreshold: number; wallet: Wallet; } interface Timestamp { seconds: string; nanos: string; } interface Timestamp { seconds: string; nanos: string; } interface CreateWalletResponse { activity: { id: string; organizationId: string; status: string; type: "ACTIVITY_TYPE_CREATE_SUB_ORGANIZATION_V7"; intent: { createSubOrganizationIntentV7: { subOrganizationName: string; rootUsers: { userName: string; apiKeys: { apiKeyName: string; publicKey: string; curveType: string; }[]; authenticators: { transports: string[]; attestationType: string; aaguid: string; credentialId: string; model: string; credential: { publicKey: string; type: string; }; authenticatorId: string; authenticatorName: string; createdAt: Timestamp; updatedAt: Timestamp; }[]; oauthProviders: { providerName: string; oidcToken: string; }[]; }[]; rootQuorumThreshold: number; wallet: { walletName: string; accounts: { curve: string; pathFormat: string; path: string; addressFormat: string; }[]; mnemonicLength: number; }; }; }; result: { createSubOrganizationResultV7: { subOrganizationId: string; wallet: { walletId: string; addresses: string[]; }; rootUserIds: string[]; }; }; votes: Vote[]; fingerprint: string; canApprove: boolean; canReject: boolean; createdAt: Timestamp; updatedAt: Timestamp; failure: null | any; }; } interface AddWalletAccountsRequest { type: "ACTIVITY_TYPE_CREATE_WALLET_ACCOUNTS"; timestampMs: string; organizationId: string; parameters: { walletId: string; accounts: { curve: string; pathFormat: string; path: string; addressFormat: string; }[]; }; } interface AddWalletAccountsResponse { activity: { id: string; status: string; type: "ACTIVITY_TYPE_CREATE_WALLET_ACCOUNTS"; organizationId: string; timestampMs: string; intent: { createWalletAccountsIntent: { walletId: string; accounts: { curve: string; pathFormat: string; path: string; addressFormat: string; }[]; }; }; result: { createWalletAccountsResult: { addresses: string[]; }; }; votes: Vote[]; fingerprint: string; canApprove: boolean; canReject: boolean; createdAt: Timestamp; updatedAt: Timestamp; failure: null | any; }; } interface SignRawPayloadRequest { type: "ACTIVITY_TYPE_SIGN_RAW_PAYLOAD_V2"; timestampMs: string; organizationId: string; parameters: { signWith: string; payload: string; encoding: string; hashFunction: string; }; } interface SignRawPayloadResponse { activity: { id: string; status: string; type: "ACTIVITY_TYPE_SIGN_RAW_PAYLOAD_V2"; organizationId: string; timestampMs: string; intent: { signRawPayloadIntent: { privateKeyId: string; payload: string; encoding: string; hashFunction: string; }; }; result: { signRawPayloadResult: { r: string; s: string; v: string; }; }; votes: Vote[]; fingerprint: string; canApprove: boolean; canReject: boolean; createdAt: Timestamp; updatedAt: Timestamp; failure: null | any; }; } interface SignRawPayloadsRequest { type: "ACTIVITY_TYPE_SIGN_RAW_PAYLOADS"; timestampMs: string; organizationId: string; parameters: { signWith: string; payloads: string[]; encoding: string; hashFunction: string; }; } interface SignRawPayloadsResponse { activity: { id: string; status: string; type: "ACTIVITY_TYPE_SIGN_RAW_PAYLOADS"; organizationId: string; timestampMs: string; intent: { signRawPayloadsIntent: { signWith: string; payloads: string[]; encoding: string; hashFunction: string; }; }; result: { signRawPayloadsResult: { signatures: { r: string; s: string; v: string; }[]; }; }; votes: Vote[]; fingerprint: string; canApprove: boolean; canReject: boolean; createdAt: Timestamp; updatedAt: Timestamp; failure: null | any; }; } interface SignTransactionRequest { type: "ACTIVITY_TYPE_SIGN_TRANSACTION_V2"; timestampMs: string; organizationId: string; parameters: { signWith: string; unsignedTransaction: string; type: string; }; } interface SignTransactionResponse { activity: { id: string; status: string; type: "ACTIVITY_TYPE_SIGN_TRANSACTION_V2"; organizationId: string; timestampMs: string; intent: { signTransactionIntent: { privateKeyId: string; unsignedTransaction: string; type: string; }; }; result: { signTransactionResult: { signedTransaction: string; }; }; votes: Vote[]; fingerprint: string; canApprove: boolean; canReject: boolean; createdAt: Timestamp; updatedAt: Timestamp; failure: null | any; }; } interface ABISpec { url?: string; abi?: any[]; cacheTTL?: number; } interface IDLSpec { url?: string; idl?: any; cacheTTL?: number; } interface TurnkeyConfig { organizationId: string; apiPublicKey: string; apiPrivateKey: string; baseUrl: string; } interface TurnkeyConfig { organizationId: string; apiPublicKey: string; apiPrivateKey: string; baseUrl: string; } interface ValidationResult { isValid: boolean; errors: string[]; warnings: string[]; decodedContent?: { evmFunction?: { functionName: string; functionSignature: string; args: Record<string, any>; }; solanaInstructions?: Array<{ instruction: string; programName?: string; data: Record<string, any>; }>; }; riskAssessment?: { level: 'low' | 'medium' | 'high'; factors: string[]; recommendations?: string[]; }; } declare class TurnkeyAuthenticator extends WalletAuthenticator { sdk: TurnkeySDK; constructor(config: TurnkeyConfig); getWallet(params: GetWalletRequest): Promise<GetWalletResponse>; addAccount(params: AddAccountRequest): Promise<AddAccountResponse>; createWallet(params: CreateWalletRequest$1): Promise<CreateWalletResponse$1>; action(params: ActionParams<Web3ActionData>): Promise<ActionResponse>; private handleSignMessage; private handleSignTypedData; private handleSignTransaction; private handleSignRawPayloads; } declare class TurnkeySDK { private readonly config; protected stamper: ApiKeyStamper; constructor(config: TurnkeyConfig); listWallets(request: ListWalletsRequest): Promise<ListWalletsResponse>; listWalletAccounts(request: ListWalletAccountsRequest): Promise<ListWalletAccountsResponse>; createWallet(request: CreateWalletRequest): Promise<CreateWalletResponse>; addWalletAccount(request: AddWalletAccountsRequest): Promise<AddWalletAccountsResponse>; signRawPayload(request: SignRawPayloadRequest): Promise<SignRawPayloadResponse>; signRawPayloads(request: SignRawPayloadsRequest): Promise<SignRawPayloadsResponse>; signTransaction(request: SignTransactionRequest): Promise<SignTransactionResponse>; } export { type ABISpec, type Account, type AddWalletAccountsRequest, type AddWalletAccountsResponse, type ApiKey, type Authenticator, type ChainId, type CreateWalletRequest, type CreateWalletResponse, type IDLSpec, type ListWalletAccountsRequest, type ListWalletAccountsResponse, type ListWalletsRequest, type ListWalletsResponse, type OauthProvider, type RootUser, type SignRawPayloadRequest, type SignRawPayloadResponse, type SignRawPayloadsRequest, type SignRawPayloadsResponse, type SignTransactionRequest, type SignTransactionResponse, type Timestamp, TurnkeyAuthenticator, type TurnkeyConfig, TurnkeySDK, type ValidationResult, type Vote, type Wallet, getChainIdFromAddressFormat };