@dfinity/oisy-wallet-signer
Version:
A library designed to facilitate communication between a dApp and the OISY Wallet on the Internet Computer.
283 lines (282 loc) • 12.8 kB
TypeScript
import * as z from 'zod';
import type { Icrc21Did } from '../declarations';
export declare const PromptMethodSchema: z.ZodEnum<{
icrc21_call_consent_message: "icrc21_call_consent_message";
icrc25_request_permissions: "icrc25_request_permissions";
icrc27_accounts: "icrc27_accounts";
icrc49_call_canister: "icrc49_call_canister";
}>;
export interface Prompts {
[PromptMethodSchema.enum.icrc21_call_consent_message]: ConsentMessagePrompt;
[PromptMethodSchema.enum.icrc25_request_permissions]: PermissionsPrompt;
[PromptMethodSchema.enum.icrc27_accounts]: AccountsPrompt;
[PromptMethodSchema.enum.icrc49_call_canister]: CallCanisterPrompt;
}
export interface RegisterPrompts<T extends keyof Prompts> {
method: T;
prompt: Prompts[T];
}
declare const PayloadOriginSchema: z.ZodObject<{
origin: z.ZodURL;
}, z.core.$strip>;
export type PayloadOrigin = z.infer<typeof PayloadOriginSchema>;
declare const RejectionSchema: z.ZodFunction<z.core.$ZodFunctionArgs, z.ZodVoid>;
export type Rejection = z.infer<typeof RejectionSchema>;
declare const PermissionsConfirmationSchema: z.ZodFunction<z.ZodTuple<[z.ZodArray<z.ZodObject<{
scope: z.ZodObject<{
method: z.ZodEnum<{
icrc27_accounts: "icrc27_accounts";
icrc49_call_canister: "icrc49_call_canister";
}>;
}, z.core.$strip>;
state: z.ZodEnum<{
denied: "denied";
granted: "granted";
ask_on_use: "ask_on_use";
}>;
}, z.core.$strict>>], null>, z.ZodVoid>;
export type PermissionsConfirmation = z.infer<typeof PermissionsConfirmationSchema>;
declare const PermissionsPromptPayloadSchema: z.ZodObject<{
origin: z.ZodURL;
requestedScopes: z.ZodArray<z.ZodObject<{
scope: z.ZodObject<{
method: z.ZodEnum<{
icrc27_accounts: "icrc27_accounts";
icrc49_call_canister: "icrc49_call_canister";
}>;
}, z.core.$strip>;
state: z.ZodEnum<{
denied: "denied";
granted: "granted";
ask_on_use: "ask_on_use";
}>;
}, z.core.$strict>>;
confirm: z.ZodFunction<z.ZodTuple<[z.ZodArray<z.ZodObject<{
scope: z.ZodObject<{
method: z.ZodEnum<{
icrc27_accounts: "icrc27_accounts";
icrc49_call_canister: "icrc49_call_canister";
}>;
}, z.core.$strip>;
state: z.ZodEnum<{
denied: "denied";
granted: "granted";
ask_on_use: "ask_on_use";
}>;
}, z.core.$strict>>], null>, z.ZodVoid>;
}, z.core.$strip>;
export type PermissionsPromptPayload = z.infer<typeof PermissionsPromptPayloadSchema>;
/**
* A function that is invoked when the signer requires the user to confirm (grant or deny) requested permissions.
*
* This function may be triggered in two scenarios:
* 1. When the relying party explicitly requests permissions.
* 2. When the relying party attempts to access a feature that requires permissions that have not yet been granted by the user.
*
* @param {PermissionsPromptPayload} params - An object containing the requested permissions and a function to confirm them.
* @param {IcrcScopes[]} params.requestedScopes - An array of IcrcScopes representing the permissions being requested.
* @param {PermissionsConfirmation} params.confirm - A function to be called by the consumer to confirm (grant or deny) the requested, a subset, or none of the permissions. Skipping a permission is equivalent to preserving its current state.
*/
export declare const PermissionsPromptSchema: z.ZodFunction<z.ZodTuple<[z.ZodObject<{
origin: z.ZodURL;
requestedScopes: z.ZodArray<z.ZodObject<{
scope: z.ZodObject<{
method: z.ZodEnum<{
icrc27_accounts: "icrc27_accounts";
icrc49_call_canister: "icrc49_call_canister";
}>;
}, z.core.$strip>;
state: z.ZodEnum<{
denied: "denied";
granted: "granted";
ask_on_use: "ask_on_use";
}>;
}, z.core.$strict>>;
confirm: z.ZodFunction<z.ZodTuple<[z.ZodArray<z.ZodObject<{
scope: z.ZodObject<{
method: z.ZodEnum<{
icrc27_accounts: "icrc27_accounts";
icrc49_call_canister: "icrc49_call_canister";
}>;
}, z.core.$strip>;
state: z.ZodEnum<{
denied: "denied";
granted: "granted";
ask_on_use: "ask_on_use";
}>;
}, z.core.$strict>>], null>, z.ZodVoid>;
}, z.core.$strip>], null>, z.ZodVoid>;
export type PermissionsPrompt = z.infer<typeof PermissionsPromptSchema>;
declare const AccountsApprovalSchema: z.ZodFunction<z.ZodTuple<[z.ZodArray<z.ZodObject<{
owner: z.ZodString;
subaccount: z.ZodOptional<z.ZodString>;
}, z.core.$strict>>], null>, z.ZodVoid>;
export type AccountsApproval = z.infer<typeof AccountsApprovalSchema>;
declare const AccountsPromptPayloadSchema: z.ZodObject<{
origin: z.ZodURL;
approve: z.ZodFunction<z.ZodTuple<[z.ZodArray<z.ZodObject<{
owner: z.ZodString;
subaccount: z.ZodOptional<z.ZodString>;
}, z.core.$strict>>], null>, z.ZodVoid>;
reject: z.ZodFunction<z.core.$ZodFunctionArgs, z.ZodVoid>;
}, z.core.$strip>;
export type AccountsPromptPayload = z.infer<typeof AccountsPromptPayloadSchema>;
/**
* A function that is invoked when the signer requires the user - or consumer of the library - to confirm (select or reject) accounts.
*
* @param {AccountsPromptPayload} params - An object containing a function to confirm the accounts.
* @param {IcrcAccounts[]} params.approve - A function to be called by the consumer to confirm (select or reject) the provided accounts.
*/
export declare const AccountsPromptSchema: z.ZodFunction<z.ZodTuple<[z.ZodObject<{
origin: z.ZodURL;
approve: z.ZodFunction<z.ZodTuple<[z.ZodArray<z.ZodObject<{
owner: z.ZodString;
subaccount: z.ZodOptional<z.ZodString>;
}, z.core.$strict>>], null>, z.ZodVoid>;
reject: z.ZodFunction<z.core.$ZodFunctionArgs, z.ZodVoid>;
}, z.core.$strip>], null>, z.ZodVoid>;
export type AccountsPrompt = z.infer<typeof AccountsPromptSchema>;
declare const ConsentMessageApprovalSchema: z.ZodFunction<z.core.$ZodFunctionArgs, z.ZodVoid>;
export type ConsentMessageApproval = z.infer<typeof ConsentMessageApprovalSchema>;
declare const ConsentMessageStatusSchema: z.ZodUnion<[z.ZodEnum<{
loading: "loading";
}>, z.ZodEnum<{
error: "error";
result: "result";
}>]>;
export type ConsentMessageStatus = z.infer<typeof ConsentMessageStatusSchema>;
declare const ConsentInfoOkSchema: z.ZodObject<{
Ok: z.ZodCustom<Icrc21Did.icrc21_consent_info, Icrc21Did.icrc21_consent_info>;
}, z.core.$strip>;
export type ConsentInfoOk = z.infer<typeof ConsentInfoOkSchema>;
declare const ConsentInfoWarnSchema: z.ZodObject<{
Warn: z.ZodObject<{
method: z.ZodString;
arg: z.ZodString;
canisterId: z.ZodString;
consentInfo: z.ZodCustom<Icrc21Did.icrc21_consent_info, Icrc21Did.icrc21_consent_info>;
}, z.core.$strip>;
}, z.core.$strip>;
export type ConsentInfoWarn = z.infer<typeof ConsentInfoWarnSchema>;
declare const ResultConsentInfoSchema: z.ZodUnion<readonly [z.ZodObject<{
Ok: z.ZodCustom<Icrc21Did.icrc21_consent_info, Icrc21Did.icrc21_consent_info>;
}, z.core.$strip>, z.ZodObject<{
Warn: z.ZodObject<{
method: z.ZodString;
arg: z.ZodString;
canisterId: z.ZodString;
consentInfo: z.ZodCustom<Icrc21Did.icrc21_consent_info, Icrc21Did.icrc21_consent_info>;
}, z.core.$strip>;
}, z.core.$strip>]>;
export type ResultConsentInfo = z.infer<typeof ResultConsentInfoSchema>;
declare const ResultConsentMessageSchema: z.ZodObject<{
origin: z.ZodURL;
status: z.ZodLiteral<"result">;
consentInfo: z.ZodUnion<readonly [z.ZodObject<{
Ok: z.ZodCustom<Icrc21Did.icrc21_consent_info, Icrc21Did.icrc21_consent_info>;
}, z.core.$strip>, z.ZodObject<{
Warn: z.ZodObject<{
method: z.ZodString;
arg: z.ZodString;
canisterId: z.ZodString;
consentInfo: z.ZodCustom<Icrc21Did.icrc21_consent_info, Icrc21Did.icrc21_consent_info>;
}, z.core.$strip>;
}, z.core.$strip>]>;
approve: z.ZodFunction<z.core.$ZodFunctionArgs, z.ZodVoid>;
reject: z.ZodFunction<z.core.$ZodFunctionArgs, z.ZodVoid>;
}, z.core.$strip>;
export type ResultConsentMessage = z.infer<typeof ResultConsentMessageSchema>;
declare const ConsentMessagePromptPayloadSchema: z.ZodUnion<readonly [z.ZodObject<{
origin: z.ZodURL;
status: z.ZodLiteral<"loading">;
}, z.core.$strip>, z.ZodObject<{
origin: z.ZodURL;
status: z.ZodLiteral<"result">;
consentInfo: z.ZodUnion<readonly [z.ZodObject<{
Ok: z.ZodCustom<Icrc21Did.icrc21_consent_info, Icrc21Did.icrc21_consent_info>;
}, z.core.$strip>, z.ZodObject<{
Warn: z.ZodObject<{
method: z.ZodString;
arg: z.ZodString;
canisterId: z.ZodString;
consentInfo: z.ZodCustom<Icrc21Did.icrc21_consent_info, Icrc21Did.icrc21_consent_info>;
}, z.core.$strip>;
}, z.core.$strip>]>;
approve: z.ZodFunction<z.core.$ZodFunctionArgs, z.ZodVoid>;
reject: z.ZodFunction<z.core.$ZodFunctionArgs, z.ZodVoid>;
}, z.core.$strip>, z.ZodObject<{
origin: z.ZodURL;
status: z.ZodLiteral<"error">;
details: z.ZodOptional<z.ZodUnknown>;
}, z.core.$strip>]>;
export type ConsentMessagePromptPayload = z.infer<typeof ConsentMessagePromptPayloadSchema>;
/**
* A function that is invoked when the signer requires the user - or consumer of the library - to approve or reject a consent message.
*
* @param {ConsentMessagePromptPayload} params - An object containing the consent information and functions to handle approval or rejection.
* @param {icrc21_consent_info} params.consentInfo - An object containing the consent information that needs to be approved or rejected.
* @param {() => void} params.approve - A function to be called by the consumer to approve the consent message.
* @param {() => void} params.reject - A function to be called by the consumer to reject the consent message.
*/
export declare const ConsentMessagePromptSchema: z.ZodFunction<z.ZodTuple<[z.ZodUnion<readonly [z.ZodObject<{
origin: z.ZodURL;
status: z.ZodLiteral<"loading">;
}, z.core.$strip>, z.ZodObject<{
origin: z.ZodURL;
status: z.ZodLiteral<"result">;
consentInfo: z.ZodUnion<readonly [z.ZodObject<{
Ok: z.ZodCustom<Icrc21Did.icrc21_consent_info, Icrc21Did.icrc21_consent_info>;
}, z.core.$strip>, z.ZodObject<{
Warn: z.ZodObject<{
method: z.ZodString;
arg: z.ZodString;
canisterId: z.ZodString;
consentInfo: z.ZodCustom<Icrc21Did.icrc21_consent_info, Icrc21Did.icrc21_consent_info>;
}, z.core.$strip>;
}, z.core.$strip>]>;
approve: z.ZodFunction<z.core.$ZodFunctionArgs, z.ZodVoid>;
reject: z.ZodFunction<z.core.$ZodFunctionArgs, z.ZodVoid>;
}, z.core.$strip>, z.ZodObject<{
origin: z.ZodURL;
status: z.ZodLiteral<"error">;
details: z.ZodOptional<z.ZodUnknown>;
}, z.core.$strip>]>], null>, z.ZodVoid>;
export type ConsentMessagePrompt = z.infer<typeof ConsentMessagePromptSchema>;
declare const CallCanisterStatusSchema: z.ZodUnion<[z.ZodEnum<{
executing: "executing";
}>, z.ZodEnum<{
error: "error";
result: "result";
}>]>;
export type CallCanisterStatus = z.infer<typeof CallCanisterStatusSchema>;
declare const CallCanisterPromptPayloadSchema: z.ZodUnion<readonly [z.ZodObject<{
origin: z.ZodURL;
status: z.ZodLiteral<"executing">;
}, z.core.$strip>, z.ZodIntersection<z.ZodObject<{
origin: z.ZodURL;
status: z.ZodLiteral<"result">;
}, z.core.$strip>, z.ZodObject<{
contentMap: z.ZodString;
certificate: z.ZodString;
}, z.core.$strict>>, z.ZodObject<{
origin: z.ZodURL;
status: z.ZodLiteral<"error">;
details: z.ZodOptional<z.ZodUnknown>;
}, z.core.$strip>]>;
export type CallCanisterPromptPayload = z.infer<typeof CallCanisterPromptPayloadSchema>;
export declare const CallCanisterPromptSchema: z.ZodFunction<z.ZodTuple<[z.ZodUnion<readonly [z.ZodObject<{
origin: z.ZodURL;
status: z.ZodLiteral<"executing">;
}, z.core.$strip>, z.ZodIntersection<z.ZodObject<{
origin: z.ZodURL;
status: z.ZodLiteral<"result">;
}, z.core.$strip>, z.ZodObject<{
contentMap: z.ZodString;
certificate: z.ZodString;
}, z.core.$strict>>, z.ZodObject<{
origin: z.ZodURL;
status: z.ZodLiteral<"error">;
details: z.ZodOptional<z.ZodUnknown>;
}, z.core.$strip>]>], null>, z.ZodVoid>;
export type CallCanisterPrompt = z.infer<typeof CallCanisterPromptSchema>;
export {};