import {z} from 'zod' export type GetApiUserMeWalletSignersArgs = {walletIndex?: number | undefined, wallet_index?: number | undefined, status?: ('active' | 'paused' | 'revoked') | undefined}; export type GetApiUserMeWalletSignersOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const getApiUserMeWalletSignersResponse = z.object({ok: z.literal(true), data: z.object({signers: z.array(z.object({id: z.string(), tenantId: z.string(), agentId: z.string(), signerType: z.enum(["owner", "delegated", "service", "quorum_member"]), subjectType: z.enum(["user", "wallet", "api_key", "external"]), subjectId: z.string(), keyType: z.enum(["hmac", "p256"]), publicKey: z.string().nullable(), address: z.string().nullable().optional(), chainFamily: z.enum(["evm", "solana", "null"]).nullable().optional(), label: z.string().nullable().optional(), permissions: z.array(z.string()), policyIds: z.array(z.string()).optional(), metadata: z.record(z.string(), z.unknown()), hasCredential: z.boolean().optional(), status: z.enum(["active", "paused", "revoked"]), createdBy: z.string().nullable().optional(), createdAt: z.string(), updatedAt: z.string()})).optional()})}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * List authenticated user wallet signers * * GET /user/me/wallet/signers */ export const getApiUserMeWalletSigners = async (args: GetApiUserMeWalletSignersArgs, options?: GetApiUserMeWalletSignersOptions) => { const {baseUrl = "http://localhost:3200", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.walletIndex != null) query.append("walletIndex", String(args.walletIndex)) if (args.wallet_index != null) query.append("wallet_index", String(args.wallet_index)) if (args.status != null) query.append("status", String(args.status)) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/user/me/wallet/signers${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(getApiUserMeWalletSignersResponse, await res.json()) };