UNPKG

better-near-auth

Version:

Sign in with NEAR (SIWN) plugin for Better Auth

296 lines 10.2 kB
import { z } from "zod"; import { type AccountId } from "near-kit/schemas"; import type { AccountState, Near, TransactionBuilder } from "near-kit"; export type { AccountId }; export interface NearAccount { id: string; userId: string; accountId: string; network: "mainnet" | "testnet"; publicKey: string; isPrimary: boolean; createdAt: Date; } export interface ListedNearAccount extends NearAccount { providerId: "siwn"; isActive: boolean; isAvailable: boolean; } export interface ListAccountsResponseT { accounts: ListedNearAccount[]; activeAccount: ListedNearAccount | null; availableAccounts: ListedNearAccount[]; } export interface SetPrimaryAccountResponseT extends ListAccountsResponseT { success: boolean; accountId: string; network: "mainnet" | "testnet"; message: string; } export declare const socialImageSchema: z.ZodObject<{ url: z.ZodOptional<z.ZodString>; ipfs_cid: z.ZodOptional<z.ZodString>; }, z.core.$strip>; export declare const profileSchema: z.ZodObject<{ name: z.ZodOptional<z.ZodString>; description: z.ZodOptional<z.ZodString>; image: z.ZodOptional<z.ZodObject<{ url: z.ZodOptional<z.ZodString>; ipfs_cid: z.ZodOptional<z.ZodString>; }, z.core.$strip>>; backgroundImage: z.ZodOptional<z.ZodObject<{ url: z.ZodOptional<z.ZodString>; ipfs_cid: z.ZodOptional<z.ZodString>; }, z.core.$strip>>; linktree: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>; }, z.core.$strip>; export type SocialImage = z.infer<typeof socialImageSchema>; export type Profile = z.infer<typeof profileSchema>; export declare const LinkAccountRequest: z.ZodObject<{ signedMessage: z.ZodObject<{ accountId: z.ZodString; publicKey: z.ZodString; signature: z.ZodString; state: z.ZodOptional<z.ZodString>; }, z.core.$strip>; message: z.ZodString; recipient: z.ZodString; nonce: z.ZodString; accountId: z.ZodString; callbackUrl: z.ZodOptional<z.ZodString>; }, z.core.$strip>; export declare const SetPrimaryAccountRequest: z.ZodObject<{ accountId: z.ZodString; network: z.ZodOptional<z.ZodEnum<{ mainnet: "mainnet"; testnet: "testnet"; }>>; }, z.core.$strip>; export declare const NonceRequest: z.ZodObject<{ accountId: z.ZodString; networkId: z.ZodUnion<readonly [z.ZodLiteral<"mainnet">, z.ZodLiteral<"testnet">]>; }, z.core.$strip>; export declare const VerifyRequest: z.ZodObject<{ signedMessage: z.ZodObject<{ accountId: z.ZodString; publicKey: z.ZodString; signature: z.ZodString; state: z.ZodOptional<z.ZodString>; }, z.core.$strip>; message: z.ZodString; recipient: z.ZodString; nonce: z.ZodString; accountId: z.ZodString; callbackUrl: z.ZodOptional<z.ZodString>; }, z.core.$strip>; export declare const RelayRequest: z.ZodObject<{ payload: z.ZodString; }, z.core.$strip>; export type RelayRequestT = z.infer<typeof RelayRequest>; export declare const RelayResponse: z.ZodObject<{ txHash: z.ZodString; status: z.ZodEnum<{ pending: "pending"; completed: "completed"; failed: "failed"; }>; }, z.core.$strip>; export type RelayResponseT = z.infer<typeof RelayResponse>; export declare const RelayStatusResponse: z.ZodObject<{ status: z.ZodEnum<{ pending: "pending"; completed: "completed"; failed: "failed"; }>; gasUsed: z.ZodOptional<z.ZodString>; outcome: z.ZodOptional<z.ZodUnknown>; }, z.core.$strip>; export type RelayStatusResponseT = z.infer<typeof RelayStatusResponse>; export declare const ViewContractRequest: z.ZodObject<{ contractId: z.ZodString; methodName: z.ZodString; args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>; }, z.core.$strip>; export type ViewContractRequestT = z.infer<typeof ViewContractRequest>; export declare const NonceResponse: z.ZodObject<{ nonce: z.ZodString; }, z.core.$strip>; export declare const VerifyResponse: z.ZodObject<{ token: z.ZodString; success: z.ZodLiteral<true>; user: z.ZodObject<{ id: z.ZodString; accountId: z.ZodString; network: z.ZodUnion<readonly [z.ZodLiteral<"mainnet">, z.ZodLiteral<"testnet">]>; }, z.core.$strip>; }, z.core.$strip>; export declare const ProfileResponse: z.ZodNullable<z.ZodObject<{ name: z.ZodOptional<z.ZodString>; description: z.ZodOptional<z.ZodString>; image: z.ZodOptional<z.ZodObject<{ url: z.ZodOptional<z.ZodString>; ipfs_cid: z.ZodOptional<z.ZodString>; }, z.core.$strip>>; backgroundImage: z.ZodOptional<z.ZodObject<{ url: z.ZodOptional<z.ZodString>; ipfs_cid: z.ZodOptional<z.ZodString>; }, z.core.$strip>>; linktree: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>; }, z.core.$strip>>; export declare const ViewContractResponse: z.ZodObject<{ result: z.ZodUnknown; }, z.core.$strip>; export declare const ProfileRequest: z.ZodObject<{ accountId: z.ZodOptional<z.ZodString>; }, z.core.$strip>; export type ProfileRequestT = z.infer<typeof ProfileRequest>; export type NonceRequestT = z.infer<typeof NonceRequest>; export type NonceResponseT = z.infer<typeof NonceResponse>; export type SetPrimaryAccountRequestT = z.infer<typeof SetPrimaryAccountRequest>; export type VerifyRequestT = z.infer<typeof VerifyRequest>; export type VerifyResponseT = z.infer<typeof VerifyResponse>; export type ProfileResponseT = z.infer<typeof ProfileResponse>; export type ViewContractResponseT = z.infer<typeof ViewContractResponse>; export declare const RelayedTransactionSchema: z.ZodObject<{ id: z.ZodString; userId: z.ZodString; txHash: z.ZodString; senderId: z.ZodString; receiverId: z.ZodString; network: z.ZodString; status: z.ZodString; gasUsed: z.ZodOptional<z.ZodString>; createdAt: z.ZodString; updatedAt: z.ZodOptional<z.ZodString>; }, z.core.$strip>; export type RelayedTransactionT = z.infer<typeof RelayedTransactionSchema>; export declare const RelayHistoryResponse: z.ZodObject<{ transactions: z.ZodArray<z.ZodObject<{ id: z.ZodString; userId: z.ZodString; txHash: z.ZodString; senderId: z.ZodString; receiverId: z.ZodString; network: z.ZodString; status: z.ZodString; gasUsed: z.ZodOptional<z.ZodString>; createdAt: z.ZodString; updatedAt: z.ZodOptional<z.ZodString>; }, z.core.$strip>>; }, z.core.$strip>; export type RelayHistoryResponseT = z.infer<typeof RelayHistoryResponse>; export interface RelayedTransactionRecord { id: string; userId: string; txHash: string; senderId: string; receiverId: string; network: "mainnet" | "testnet"; status: string; gasUsed?: string; createdAt: Date; updatedAt: Date; } export interface RelayerInfo extends AccountState { accountId: string; mode: "ephemeral" | "explicit"; network: "mainnet" | "testnet"; publicKey: string; hasKey: boolean; createdAt?: Date; lastUsedAt?: Date; parentAccount?: string; subAccountAvailable?: boolean; } export interface DualNetworkConfig<T> { mainnet: T; testnet: T; } export declare const GetRelayerInfoRequest: z.ZodObject<{ network: z.ZodOptional<z.ZodEnum<{ mainnet: "mainnet"; testnet: "testnet"; }>>; }, z.core.$strip>; export type GetRelayerInfoRequestT = z.infer<typeof GetRelayerInfoRequest>; export interface SubAccountRelayerFCAKConfig { receiverId: string; methodNames?: string[]; allowance?: string; } export interface SubAccountTxCtx { newAccountId: string; parentAccount: string; userPublicKey: string; userAccountId: string; userId: string; network: "mainnet" | "testnet"; } export interface SubAccountLifecycleCtx extends SubAccountTxCtx { near: Near; } export interface SubAccountConfig { parentAccount?: string; minDeposit?: string; parentHasFullAccess?: boolean; deploy?: { wasm: Uint8Array; } | { fromPublished: { accountId?: string; codeHash?: string; }; }; init?: { methodName: string; args: object | ((ctx: SubAccountTxCtx) => object); }; extendTx?: (tx: TransactionBuilder, ctx: SubAccountTxCtx) => TransactionBuilder; onCreated?: (ctx: SubAccountLifecycleCtx) => Promise<void>; onRollback?: (ctx: SubAccountLifecycleCtx) => Promise<void>; addRelayerFCAK?: boolean; relayerFCAK?: SubAccountRelayerFCAKConfig; } export declare const SUB_ACCOUNT_LABEL_REGEX: RegExp; export declare const SubAccountNameSchema: z.ZodString; export declare const CreateSubAccountRequest: z.ZodObject<{ subAccountName: z.ZodString; network: z.ZodOptional<z.ZodEnum<{ mainnet: "mainnet"; testnet: "testnet"; }>>; publicKey: z.ZodString; }, z.core.$strip>; export type CreateSubAccountRequestT = z.infer<typeof CreateSubAccountRequest>; export declare const CreateSubAccountResponse: z.ZodObject<{ success: z.ZodLiteral<true>; accountId: z.ZodString; network: z.ZodEnum<{ mainnet: "mainnet"; testnet: "testnet"; }>; publicKey: z.ZodString; message: z.ZodString; }, z.core.$strip>; export type CreateSubAccountResponseT = z.infer<typeof CreateSubAccountResponse>; export declare const CheckSubAccountAvailabilityRequest: z.ZodObject<{ subAccountName: z.ZodString; network: z.ZodOptional<z.ZodEnum<{ mainnet: "mainnet"; testnet: "testnet"; }>>; }, z.core.$strip>; export type CheckSubAccountAvailabilityRequestT = z.infer<typeof CheckSubAccountAvailabilityRequest>; export declare const CheckSubAccountAvailabilityResponse: z.ZodObject<{ available: z.ZodBoolean; accountId: z.ZodString; parentAccount: z.ZodOptional<z.ZodString>; reason: z.ZodOptional<z.ZodEnum<{ taken: "taken"; invalid: "invalid"; "too-long": "too-long"; "not-configured": "not-configured"; }>>; }, z.core.$strip>; export type CheckSubAccountAvailabilityResponseT = z.infer<typeof CheckSubAccountAvailabilityResponse>; //# sourceMappingURL=types.d.ts.map