Skip to content

Signer

Defined in: src/signer.ts:282

Client for interacting with an ICRC-25 compliant signer.

Signers are applications that hold private keys and can sign messages on behalf of a user. They communicate over a Transport using JSON-RPC 2.0 messages as defined by the ICRC-25 standard.

https://github.com/dfinity/wg-identity-authentication/blob/main/topics/icrc_25_signer_interaction_standard.md

import { Signer } from "@icp-sdk/signer";
import { PostMessageTransport } from "@icp-sdk/signer/web";
const transport = new PostMessageTransport({ url: "https://oisy.com/sign" });
const signer = new Signer({ transport });
const standards = await signer.getSupportedStandards();
const accounts = await signer.getAccounts();

T extends Transport = Transport

new Signer<T>(options): Signer<T>

Defined in: src/signer.ts:290

SignerOptions<T>

Signer<T>

get autoCloseTransportChannel(): boolean

Defined in: src/signer.ts:318

Whether the transport channel auto-closes after a response is received. Can be toggled at runtime, which is useful for multi-step flows that need to await async work between requests without losing the channel. Setting this to false also cancels any auto-close already scheduled by a prior response.

boolean

set autoCloseTransportChannel(value): void

Defined in: src/signer.ts:322

boolean

void


get transport(): T

Defined in: src/signer.ts:307

The transport used to communicate with the signer.

T

callCanister(params): Promise<{ certificate: Uint8Array; contentMap: Uint8Array; }>

Defined in: src/signer.ts:681

Requests the signer to execute a canister call on behalf of the user. The signer will prompt the user for approval before signing and submitting the call to the Internet Computer.

The canister call parameters.

Uint8Array

The Candid-encoded call arguments.

Principal

The target canister.

string

The canister method to invoke.

Uint8Array<ArrayBufferLike>

Optional nonce (max 32 bytes) for replay protection.

Principal

The principal executing the call.

Promise<{ certificate: Uint8Array; contentMap: Uint8Array; }>

The CBOR-encoded content map and certificate from the IC, which can be used to verify the call’s execution.

https://github.com/dfinity/wg-identity-authentication/blob/main/topics/icrc_49_call_canister.md


closeChannel(): Promise<void>

Defined in: src/signer.ts:361

Closes the current communication channel, if open.

Promise<void>


getAccounts(): Promise<object[]>

Defined in: src/signer.ts:578

Requests the accounts managed by the signer. Each account has an owner Principal and an optional 32-byte subaccount.

Requires the icrc27_accounts permission scope.

Promise<object[]>

https://github.com/dfinity/wg-identity-authentication/blob/main/topics/icrc_27_accounts.md


getPermissions(): Promise<object[]>

Defined in: src/signer.ts:549

Queries the current state of all permission scopes.

Promise<object[]>

The current permission state for each scope the signer supports.


getSupportedStandards(): Promise<SupportedStandard[]>

Defined in: src/signer.ts:491

Queries which ICRC standards the signer supports. Use this to determine signer capabilities before calling other methods.

Promise<SupportedStandard[]>

https://github.com/dfinity/wg-identity-authentication/blob/main/topics/icrc_25_signer_interaction_standard.md


openChannel(): Promise<Channel>

Defined in: src/signer.ts:333

Opens a communication channel with the signer. Reuses an existing open channel if available.

Promise<Channel>


requestDelegation(params): Promise<DelegationChain>

Defined in: src/signer.ts:616

Requests a delegation chain from the signer for session-based authentication. This allows the relying party to sign canister calls without requiring user approval for each individual call.

The delegation request parameters.

bigint

Optional maximum delegation lifetime in nanoseconds.

PublicKey

The session’s public key to delegate to.

Principal[]

Optional canister IDs to restrict the delegation to. When provided, the signer creates an account delegation; otherwise a relying party delegation.

Promise<DelegationChain>

A DelegationChain that can be used with DelegationIdentity.

https://github.com/dfinity/wg-identity-authentication/blob/main/topics/icrc_34_delegation.md


requestPermissions(scopes): Promise<object[]>

Defined in: src/signer.ts:519

Requests the signer to grant permission for the given scopes. The signer may prompt the user for approval.

PermissionScope[]

The permission scopes to request.

Promise<object[]>

The current state of each requested scope after the user’s decision.


sendRequest(request): Promise<JsonRpcResponse>

Defined in: src/signer.ts:369

Sends a JSON-RPC request over the transport channel.

JsonRpcRequest

The JSON-RPC request to send.

Promise<JsonRpcResponse>