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.
Example
Section titled “Example”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();Type Parameters
Section titled “Type Parameters”T extends Transport = Transport
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Signer<
T>(options):Signer<T>
Defined in: src/signer.ts:290
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”Signer<T>
Accessors
Section titled “Accessors”autoCloseTransportChannel
Section titled “autoCloseTransportChannel”Get Signature
Section titled “Get Signature”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.
Returns
Section titled “Returns”boolean
Set Signature
Section titled “Set Signature”set autoCloseTransportChannel(
value):void
Defined in: src/signer.ts:322
Parameters
Section titled “Parameters”boolean
Returns
Section titled “Returns”void
transport
Section titled “transport”Get Signature
Section titled “Get Signature”get transport():
T
Defined in: src/signer.ts:307
The transport used to communicate with the signer.
Returns
Section titled “Returns”T
Methods
Section titled “Methods”callCanister()
Section titled “callCanister()”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.
Parameters
Section titled “Parameters”params
Section titled “params”The canister call parameters.
Uint8Array
The Candid-encoded call arguments.
canisterId
Section titled “canisterId”Principal
The target canister.
method
Section titled “method”string
The canister method to invoke.
nonce?
Section titled “nonce?”Uint8Array<ArrayBufferLike>
Optional nonce (max 32 bytes) for replay protection.
sender
Section titled “sender”Principal
The principal executing the call.
Returns
Section titled “Returns”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()
Section titled “closeChannel()”closeChannel():
Promise<void>
Defined in: src/signer.ts:361
Closes the current communication channel, if open.
Returns
Section titled “Returns”Promise<void>
getAccounts()
Section titled “getAccounts()”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.
Returns
Section titled “Returns”Promise<object[]>
https://github.com/dfinity/wg-identity-authentication/blob/main/topics/icrc_27_accounts.md
getPermissions()
Section titled “getPermissions()”getPermissions():
Promise<object[]>
Defined in: src/signer.ts:549
Queries the current state of all permission scopes.
Returns
Section titled “Returns”Promise<object[]>
The current permission state for each scope the signer supports.
getSupportedStandards()
Section titled “getSupportedStandards()”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.
Returns
Section titled “Returns”Promise<SupportedStandard[]>
openChannel()
Section titled “openChannel()”openChannel():
Promise<Channel>
Defined in: src/signer.ts:333
Opens a communication channel with the signer. Reuses an existing open channel if available.
Returns
Section titled “Returns”Promise<Channel>
requestDelegation()
Section titled “requestDelegation()”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.
Parameters
Section titled “Parameters”params
Section titled “params”The delegation request parameters.
maxTimeToLive?
Section titled “maxTimeToLive?”bigint
Optional maximum delegation lifetime in nanoseconds.
publicKey
Section titled “publicKey”PublicKey
The session’s public key to delegate to.
targets?
Section titled “targets?”Principal[]
Optional canister IDs to restrict the delegation to. When provided, the signer creates an account delegation; otherwise a relying party delegation.
Returns
Section titled “Returns”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()
Section titled “requestPermissions()”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.
Parameters
Section titled “Parameters”scopes
Section titled “scopes”The permission scopes to request.
Returns
Section titled “Returns”Promise<object[]>
The current state of each requested scope after the user’s decision.
sendRequest()
Section titled “sendRequest()”sendRequest(
request):Promise<JsonRpcResponse>
Defined in: src/signer.ts:369
Sends a JSON-RPC request over the transport channel.
Parameters
Section titled “Parameters”request
Section titled “request”JsonRpcRequest
The JSON-RPC request to send.
Returns
Section titled “Returns”Promise<JsonRpcResponse>