Summary
The Motoko compiler exposes two new system capabilities for reading IC caller-info attribute bundles (added alongside the msg_caller_info_* system APIs in ic-cdk >= 0.20.1):
Prim.callerInfoData<system>() : Blob — returns the Candid-encoded ICRC-3 Value::Map attribute bundle attached to the current call
Prim.callerInfoSigner<system>() : Blob — returns the principal (as a raw blob) of the canister that signed the bundle, or an empty blob if none
Both are currently only accessible via mo:prim. Since mo:prim is an internal surface that should be avoided in application code, these capabilities need a stable mo:core home.
Why this matters
Any canister that wants to verify signed identity attributes from Internet Identity (e.g. email, verified_email) must currently import mo:prim solely for these two functions. There is no mo:core alternative. This surfaced during a skill review for the IC Skills project: dfinity/icskills#182 — the Motoko backend example is forced to import Prim even though the project guideline is to minimise mo:prim usage.
Proposed API
A new module (e.g. mo:core/CallerInfo or mo:core/ExperimentalCallerInfo) exposing:
module {
/// Returns the Candid-encoded ICRC-3 Value::Map attribute bundle
/// attached to the current call, or an empty blob if none was provided.
public func data() : Blob;
/// Returns the principal of the canister that signed the attribute bundle,
/// or null if no bundle was attached.
public func signer() : ?Principal;
}
signer() returning ?Principal directly (rather than a raw blob that callers must convert) would also remove a footgun: the current Prim.callerInfoSigner returns an empty blob for "no signer", which is easy to mishandle.
References
Summary
The Motoko compiler exposes two new system capabilities for reading IC caller-info attribute bundles (added alongside the
msg_caller_info_*system APIs in ic-cdk >= 0.20.1):Prim.callerInfoData<system>() : Blob— returns the Candid-encoded ICRC-3Value::Mapattribute bundle attached to the current callPrim.callerInfoSigner<system>() : Blob— returns the principal (as a raw blob) of the canister that signed the bundle, or an empty blob if noneBoth are currently only accessible via
mo:prim. Sincemo:primis an internal surface that should be avoided in application code, these capabilities need a stablemo:corehome.Why this matters
Any canister that wants to verify signed identity attributes from Internet Identity (e.g. email, verified_email) must currently import
mo:primsolely for these two functions. There is nomo:corealternative. This surfaced during a skill review for the IC Skills project: dfinity/icskills#182 — the Motoko backend example is forced to importPrimeven though the project guideline is to minimisemo:primusage.Proposed API
A new module (e.g.
mo:core/CallerInfoormo:core/ExperimentalCallerInfo) exposing:signer()returning?Principaldirectly (rather than a raw blob that callers must convert) would also remove a footgun: the currentPrim.callerInfoSignerreturns an empty blob for "no signer", which is easy to mishandle.References
msg_caller_info_data/msg_caller_info_signer(Rust equivalents, ic-cdk >= 0.20.1)