Skip to content

Request: expose callerInfoData / callerInfoSigner via mo:core #495

@marc0olo

Description

@marc0olo

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions