[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M74BCQ2ZEKAX9VM7638Z1HDY":3,"skill-same:01M74BCQ2ZEKAX9VM7638Z1HDY":66},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":16,"sourceHtmlUrl":17,"categories":18,"keywords":19,"publishedAt":20,"linkOnly":21,"markdownContent":22,"markdownBody":23,"frontMatter":24,"refName":29,"commitSha":30,"skillDirectory":31,"forksCount":32,"repositoryHtmlUrl":33,"repositoryHomepageUrl":6,"ownerHtmlUrl":34,"ownerBlogUrl":35,"ownerDescription":36,"updatedAt":37,"install":38,"resources":51},"01M74BCQ2ZEKAX9VM7638Z1HDY","user-attributes",null,"Know a signed-in user's name, email or organization in a canister, not only their principal. Internet Identity signs an attribute bundle alongside the delegation, and the backend verifies the signer, the frontend origin and a nonce it issued itself before believing any of it. Use when a canister must know something about the caller beyond their principal: filling a profile, showing a name the user never typed into your app, contacting them, or gating access or an allowlist on an address the user provably controls; and when the backend rejects a bundle the frontend has just obtained. Covers the frontend request, scoping attributes to the account signed in with, and the identity-attributes library for Motoko and Rust. Assumes sign-in already works: load user-sign-in first. Do NOT use for the sign-in flow itself, for an email address the user typed in (that is ordinary app input, which II has not checked), or for an agent or CLI acting as a user (agent-web-identity).","jiayaoqijia\u002Fcryptoskill","jiayaoqijia","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F1453879?v=4","01M6GMYTX7Q7S504VC6E756ENR","YQ","01M6GMYV1QKJ1CC75MTTGT9PR0",81,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fchains\u002Fdfinity-official-user-attributes\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fchains\u002Fdfinity-official-user-attributes\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: user-attributes\ndescription: \"Know a signed-in user's name, email or organization in a canister, not only their principal. Internet Identity signs an attribute bundle alongside the delegation, and the backend verifies the signer, the frontend origin and a nonce it issued itself before believing any of it. Use when a canister must know something about the caller beyond their principal: filling a profile, showing a name the user never typed into your app, contacting them, or gating access or an allowlist on an address the user provably controls; and when the backend rejects a bundle the frontend has just obtained. Covers the frontend request, scoping attributes to the account signed in with, and the identity-attributes library for Motoko and Rust. Assumes sign-in already works: load user-sign-in first. Do NOT use for the sign-in flow itself, for an email address the user typed in (that is ordinary app input, which II has not checked), or for an agent or CLI acting as a user (agent-web-identity).\"\nlicense: Apache-2.0\ncompatibility: \"moc >= 1.6.0, ic-cdk >= 0.20.1\"\nmetadata:\n  title: User Attributes\n  category: Auth\n---\n\n# User Attributes\n\n## Prerequisites\n\nThis skill assumes a working Internet Identity sign-in built with `@icp-sdk\u002Fauth`: load the `user-sign-in` skill first. The attribute bundle travels alongside a delegation, so there is nothing here to request without one.\n\nThe `frontend_origins` value configured below must be the origin identities are derived for, the **primary origin** where the app has pinned one, not the origin the user happens to be visiting. A suite gets this wrong by default.\n\n- For a Motoko backend: `mo:identity-attributes` >= 0.4.0 (mops). It pulls in `mo:core` >= 2.5.0 and requires `moc` >= 1.6.0 for `include`.\n- For a Rust backend: the `identity-attributes` crate and `ic-cdk` >= 0.20.1.\n\n## How it works\n\nWhen the backend needs more than the principal, II returns a signed attribute bundle alongside the delegation. The backend exposes two methods: `_internet_identity_sign_in_start` issues a nonce, `_internet_identity_sign_in_finish` verifies the bundle. The `identity-attributes` library adds both, in Motoko and in Rust, with the same checks, the same environment variables and the same Candid types, so one frontend works against either backend.\n\n## Keys\n\n`requestAttributes({ keys, nonce })` requires both; there is no default key set.\n\n| Key | Meaning | Use for |\n|---|---|---|\n| `name` | Display name from the user's II-linked account | Personalisation |\n| `email` | Raw address from the II-linked account; **II does not check it** | Contact info, mailing lists |\n| `verified_email` | Present only when II established the user controls the address (an OpenID provider marked it verified, or the user verified it with II) | Access gating; the only email to authorise on |\n\nRequest both `email` and `verified_email` for fallback: when verified, both carry the same value; otherwise only `email` arrives.\n\n`scopedKeys` scopes keys to the account the user signs in with, so they are shared in the same step with no extra prompt:\n\n| Call | Keys | Default `keys` |\n|---|---|---|\n| `scopedKeys({ openIdProvider: 'google' })` | `openid:https:\u002F\u002Faccounts.google.com:\u003Ckey>` | `name`, `email`, `verified_email` |\n| `scopedKeys({ openIdProvider: 'apple' })` | `openid:https:\u002F\u002Fappleid.apple.com:\u003Ckey>` | same |\n| `scopedKeys({ openIdProvider: 'microsoft' })` | `openid:https:\u002F\u002Flogin.microsoftonline.com\u002F{tid}\u002Fv2.0:\u003Ckey>` (`{tid}` literal) | same |\n| `scopedKeys({ ssoDomain: 'acme.com' })` | `sso:acme.com:\u003Ckey>` | `name`, `email` (no `verified_email`) |\n\nPass `keys` to narrow, e.g. `scopedKeys({ openIdProvider: 'google', keys: ['name', 'verified_email'] })`.\n\n## Frontend\n\n```javascript\nimport { AuthClient } from \"@icp-sdk\u002Fauth\u002Fclient\";\nimport { AttributesIdentity } from \"@icp-sdk\u002Fcore\u002Fidentity\";\nimport { HttpAgent, Actor } from \"@icp-sdk\u002Fcore\u002Fagent\";\nimport { safeGetCanisterEnv } from \"@icp-sdk\u002Fcore\u002Fagent\u002Fcanister-env\";\nimport { Principal } from \"@icp-sdk\u002Fcore\u002Fprincipal\";\n\nconst II_PRINCIPAL = \"rdmx6-jaaaa-aaaaa-aaadq-cai\";\nconst rootKey = safeGetCanisterEnv()?.IC_ROOT_KEY;\n\nasync function signInWithAttributes(authClient, canisterId, idl) {\n  \u002F\u002F Anonymous handle, used only to ask for the nonce.\n  const anonymousActor = Actor.createActor(idl, { agent: await HttpAgent.create({ rootKey }), canisterId });\n\n  \u002F\u002F In parallel, one interaction for the user. `nonce` is a function the client\n  \u002F\u002F calls when it needs the value, so the request is in flight while II opens.\n  const signInPromise = authClient.signIn();\n  const attributesPromise = authClient.requestAttributes({\n    keys: [\"name\", \"verified_email\"],\n    nonce: () => anonymousActor._internet_identity_sign_in_start(),\n  });\n\n  const identity = await signInPromise;\n  const attributes = await attributesPromise;\n\n  \u002F\u002F The bundle travels as sender_info on each call made with this identity.\n  const verifiedAgent = await HttpAgent.create({\n    identity: new AttributesIdentity({\n      inner: identity,\n      attributes,\n      signer: { canisterId: Principal.fromText(II_PRINCIPAL) },\n    }),\n    rootKey,\n  });\n  const verifiedActor = Actor.createActor(idl, { agent: verifiedAgent, canisterId });\n\n  const result = await verifiedActor._internet_identity_sign_in_finish();\n  if (\"err\" in result) {\n    throw new Error(`Attribute verification failed: ${JSON.stringify(result.err)}`);\n  }\n  return identity;\n}\n```\n\nFor one-click sign-in, build the client with `openIdProvider` or `ssoDomain`, add `scopedKeys` to the `@icp-sdk\u002Fauth\u002Fclient` import, and request `scopedKeys({ openIdProvider: \"google\", keys: [\"name\", \"verified_email\"] })` or `scopedKeys({ ssoDomain: \"acme.com\" })` instead; the rest is unchanged.\n\nEvery bundle carries three implicit fields the backend MUST verify: `implicit:nonce` (one it issued and has not consumed), `implicit:origin` (a trusted frontend origin), `implicit:issued_at_timestamp_ns` (fresh, typically within five minutes).\n\n## Backend\n\n### Configuration\n\nEnvironment variables, the same for both languages:\n\n```yaml\ncanisters:\n  - name: backend\n    settings:\n      environment_variables:\n        # Required. A local II (`ii: true`) has the same principal.\n        trusted_attribute_signers: \"rdmx6-jaaaa-aaaaa-aaadq-cai\"\n        # Required, comma-separated. The origin identities are DERIVED for.\n        frontend_origins: \"https:\u002F\u002Fyour-app.icp.net\"\n        # Optional, comma-separated; omit to reject all sso:* keys.\n        trusted_sso_domains: \"your-org.com\"\n```\n\nA call carrying a bundle is rejected when `trusted_attribute_signers` is unset or does not list the bundle's signer. Unset `frontend_origins` makes the finish method return `FrontendOriginsNotConfigured`.\n\n### What the callback receives\n\nYour callback runs only for a bundle that passes every check below, and receives the caller with `{ name, email, sso }` (each optional):\n\n- OpenID and unscoped sources: `email` comes from `verified_email` (or `openid:\u003Cprovider>:verified_email`), which is why the frontend requests `verified_email`. The unverified `email` key is never read.\n- SSO sources: `name` and `email` come from `sso:\u003Cdomain>:name` \u002F `sso:\u003Cdomain>:email`, accepted only for a domain in `trusted_sso_domains`, and `sso` is that domain. Otherwise `sso` is empty.\n\n### Checks and errors\n\nThe finish method returns Candid `variant { ok; err : Error }`, so the frontend checks `\"err\" in result`. It checks, in order:\n\n| Check | Error |\n|---|---|\n| A bundle is attached | `NoAttributes` |\n| It decodes to an ICRC-3 `Value::Map` | `MalformedCandid` |\n| `frontend_origins` is set | `FrontendOriginsNotConfigured` |\n| `implicit:origin` is one of `frontend_origins` | `FrontendOriginMismatch { expected, got }` |\n| `implicit:issued_at_timestamp_ns` is at most five minutes old | `Stale { ageNs }` |\n| `implicit:nonce` was issued here and not consumed | `UnknownNonce` |\n| A required implicit field is present | `MissingField` |\n| Every `sso:\u003Cdomain>:*` key's domain is trusted | `UntrustedSsoSource { domain }` |\n| Name and email come from `sso:` keys or from others, never both | `MixedSsoSources { ssoKeys, otherKeys }` |\n| Each field comes from one key, and `sso:` keys from one domain | `AmbiguousAttribute { field, sources }` |\n\n`UnknownNonce` answers a nonce older than five minutes, one already spent, and, in Rust, one issued before an upgrade. Treat it as \"retry from `_internet_identity_sign_in_start` with a fresh nonce\", not as a bug.\n\n### Motoko\n\n```toml\n[dependencies]\nidentity-attributes = \"0.4.1\"\ncore                = \"2.5.0\"\n\n[toolchain]\nmoc = \"1.6.0\"\n```\n\n`include IdentityAttributes({ onVerified })` injects both methods:\n\n```motoko\nimport IdentityAttributes \"mo:identity-attributes\";\nimport Map \"mo:core\u002FMap\";\nimport Principal \"mo:core\u002FPrincipal\";\n\npersistent actor {\n  type Profile = { name : ?Text; email : ?Text; sso : ?Text };\n\n  let profiles = Map.empty\u003CPrincipal, Profile>();\n\n  include IdentityAttributes({\n    onVerified = func(caller, attrs) {\n      profiles.add(caller, attrs);\n    };\n  });\n\n  public query func getProfile(userId : Principal) : async ?Profile {\n    profiles.get(userId)\n  };\n};\n```\n\n### Rust\n\n```toml\n[dependencies]\ncandid = \"0.10\"\nic-cdk = \"0.20.1\"\nidentity-attributes = \"0.1\"\n```\n\n`#[identity_attributes]` marks the callback and adds both methods. The function cannot be `async` or generic:\n\n```rust\nuse candid::Principal;\nuse ic_cdk::query;\nuse identity_attributes::{identity_attributes, IdentityAttributes};\nuse std::cell::RefCell;\nuse std::collections::BTreeMap;\n\nthread_local! {\n    \u002F\u002F On the heap to keep the example short: an upgrade clears it.\n    static PROFILES: RefCell\u003CBTreeMap\u003CPrincipal, IdentityAttributes>> =\n        const { RefCell::new(BTreeMap::new()) };\n}\n\n#[identity_attributes]\nfn on_verified(caller: Principal, attributes: IdentityAttributes) {\n    PROFILES.with_borrow_mut(|profiles| profiles.insert(caller, attributes));\n}\n\n#[query]\nfn get_profile(user_id: Principal) -> Option\u003CIdentityAttributes> {\n    PROFILES.with_borrow(|profiles| profiles.get(&user_id).cloned())\n}\n\nic_cdk::export_candid!();\n```\n\n`identity_attributes::sign_in_start()` and `identity_attributes::sign_in_finish(on_verified)` are the functions behind the two methods, for a canister that defines them itself.\n\n## Mistakes That Break Your Build\n\n1. **Generating the attribute nonce on the frontend.** The nonce passed to `requestAttributes` MUST come from the backend (`_internet_identity_sign_in_start`), or the canister cannot check that the bundle's `implicit:nonce` is one it issued, and replay protection is gone.\n2. **Reading attribute data without verifying the signer.** The IC verifies the signature, not who signed: any canister can produce a valid bundle. The trusted signer is `rdmx6-jaaaa-aaaaa-aaadq-cai`. Use the `identity-attributes` library with `trusted_attribute_signers` and `frontend_origins` configured. Hand-written Rust must check `msg_caller_info_signer()` before reading `msg_caller_info_data()`, or an attacker canister can forge `email = \"admin@you.com\"`.\n3. **Substituting `{tid}` in the Microsoft scoped-key prefix.** The `microsoft` provider URL is the literal `https:\u002F\u002Flogin.microsoftonline.com\u002F{tid}\u002Fv2.0`; keys look like `openid:https:\u002F\u002Flogin.microsoftonline.com\u002F{tid}\u002Fv2.0:email` exactly. Filling in a tenant ID misses every lookup.\n4. **Treating `email` as verified.** `email` is the raw address from the user's II-linked account; II does not check it, so treat it as user input. `verified_email` is present only when II established that the user controls the address: an OpenID provider marked it verified, or the user verified it with II. Gate access on `verified_email` only. There is **no `verified_email` under `sso:`**: the organization's own provider asserts `sso:\u003Cdomain>:email`, so trust it only for domains in `trusted_sso_domains`. What an organization can and cannot assert about its own staff is the `organization-sign-in` skill.\n","# User Attributes\n\n## Prerequisites\n\nThis skill assumes a working Internet Identity sign-in built with `@icp-sdk\u002Fauth`: load the `user-sign-in` skill first. The attribute bundle travels alongside a delegation, so there is nothing here to request without one.\n\nThe `frontend_origins` value configured below must be the origin identities are derived for, the **primary origin** where the app has pinned one, not the origin the user happens to be visiting. A suite gets this wrong by default.\n\n- For a Motoko backend: `mo:identity-attributes` >= 0.4.0 (mops). It pulls in `mo:core` >= 2.5.0 and requires `moc` >= 1.6.0 for `include`.\n- For a Rust backend: the `identity-attributes` crate and `ic-cdk` >= 0.20.1.\n\n## How it works\n\nWhen the backend needs more than the principal, II returns a signed attribute bundle alongside the delegation. The backend exposes two methods: `_internet_identity_sign_in_start` issues a nonce, `_internet_identity_sign_in_finish` verifies the bundle. The `identity-attributes` library adds both, in Motoko and in Rust, with the same checks, the same environment variables and the same Candid types, so one frontend works against either backend.\n\n## Keys\n\n`requestAttributes({ keys, nonce })` requires both; there is no default key set.\n\n| Key | Meaning | Use for |\n|---|---|---|\n| `name` | Display name from the user's II-linked account | Personalisation |\n| `email` | Raw address from the II-linked account; **II does not check it** | Contact info, mailing lists |\n| `verified_email` | Present only when II established the user controls the address (an OpenID provider marked it verified, or the user verified it with II) | Access gating; the only email to authorise on |\n\nRequest both `email` and `verified_email` for fallback: when verified, both carry the same value; otherwise only `email` arrives.\n\n`scopedKeys` scopes keys to the account the user signs in with, so they are shared in the same step with no extra prompt:\n\n| Call | Keys | Default `keys` |\n|---|---|---|\n| `scopedKeys({ openIdProvider: 'google' })` | `openid:https:\u002F\u002Faccounts.google.com:\u003Ckey>` | `name`, `email`, `verified_email` |\n| `scopedKeys({ openIdProvider: 'apple' })` | `openid:https:\u002F\u002Fappleid.apple.com:\u003Ckey>` | same |\n| `scopedKeys({ openIdProvider: 'microsoft' })` | `openid:https:\u002F\u002Flogin.microsoftonline.com\u002F{tid}\u002Fv2.0:\u003Ckey>` (`{tid}` literal) | same |\n| `scopedKeys({ ssoDomain: 'acme.com' })` | `sso:acme.com:\u003Ckey>` | `name`, `email` (no `verified_email`) |\n\nPass `keys` to narrow, e.g. `scopedKeys({ openIdProvider: 'google', keys: ['name', 'verified_email'] })`.\n\n## Frontend\n\n```javascript\nimport { AuthClient } from \"@icp-sdk\u002Fauth\u002Fclient\";\nimport { AttributesIdentity } from \"@icp-sdk\u002Fcore\u002Fidentity\";\nimport { HttpAgent, Actor } from \"@icp-sdk\u002Fcore\u002Fagent\";\nimport { safeGetCanisterEnv } from \"@icp-sdk\u002Fcore\u002Fagent\u002Fcanister-env\";\nimport { Principal } from \"@icp-sdk\u002Fcore\u002Fprincipal\";\n\nconst II_PRINCIPAL = \"rdmx6-jaaaa-aaaaa-aaadq-cai\";\nconst rootKey = safeGetCanisterEnv()?.IC_ROOT_KEY;\n\nasync function signInWithAttributes(authClient, canisterId, idl) {\n  \u002F\u002F Anonymous handle, used only to ask for the nonce.\n  const anonymousActor = Actor.createActor(idl, { agent: await HttpAgent.create({ rootKey }), canisterId });\n\n  \u002F\u002F In parallel, one interaction for the user. `nonce` is a function the client\n  \u002F\u002F calls when it needs the value, so the request is in flight while II opens.\n  const signInPromise = authClient.signIn();\n  const attributesPromise = authClient.requestAttributes({\n    keys: [\"name\", \"verified_email\"],\n    nonce: () => anonymousActor._internet_identity_sign_in_start(),\n  });\n\n  const identity = await signInPromise;\n  const attributes = await attributesPromise;\n\n  \u002F\u002F The bundle travels as sender_info on each call made with this identity.\n  const verifiedAgent = await HttpAgent.create({\n    identity: new AttributesIdentity({\n      inner: identity,\n      attributes,\n      signer: { canisterId: Principal.fromText(II_PRINCIPAL) },\n    }),\n    rootKey,\n  });\n  const verifiedActor = Actor.createActor(idl, { agent: verifiedAgent, canisterId });\n\n  const result = await verifiedActor._internet_identity_sign_in_finish();\n  if (\"err\" in result) {\n    throw new Error(`Attribute verification failed: ${JSON.stringify(result.err)}`);\n  }\n  return identity;\n}\n```\n\nFor one-click sign-in, build the client with `openIdProvider` or `ssoDomain`, add `scopedKeys` to the `@icp-sdk\u002Fauth\u002Fclient` import, and request `scopedKeys({ openIdProvider: \"google\", keys: [\"name\", \"verified_email\"] })` or `scopedKeys({ ssoDomain: \"acme.com\" })` instead; the rest is unchanged.\n\nEvery bundle carries three implicit fields the backend MUST verify: `implicit:nonce` (one it issued and has not consumed), `implicit:origin` (a trusted frontend origin), `implicit:issued_at_timestamp_ns` (fresh, typically within five minutes).\n\n## Backend\n\n### Configuration\n\nEnvironment variables, the same for both languages:\n\n```yaml\ncanisters:\n  - name: backend\n    settings:\n      environment_variables:\n        # Required. A local II (`ii: true`) has the same principal.\n        trusted_attribute_signers: \"rdmx6-jaaaa-aaaaa-aaadq-cai\"\n        # Required, comma-separated. The origin identities are DERIVED for.\n        frontend_origins: \"https:\u002F\u002Fyour-app.icp.net\"\n        # Optional, comma-separated; omit to reject all sso:* keys.\n        trusted_sso_domains: \"your-org.com\"\n```\n\nA call carrying a bundle is rejected when `trusted_attribute_signers` is unset or does not list the bundle's signer. Unset `frontend_origins` makes the finish method return `FrontendOriginsNotConfigured`.\n\n### What the callback receives\n\nYour callback runs only for a bundle that passes every check below, and receives the caller with `{ name, email, sso }` (each optional):\n\n- OpenID and unscoped sources: `email` comes from `verified_email` (or `openid:\u003Cprovider>:verified_email`), which is why the frontend requests `verified_email`. The unverified `email` key is never read.\n- SSO sources: `name` and `email` come from `sso:\u003Cdomain>:name` \u002F `sso:\u003Cdomain>:email`, accepted only for a domain in `trusted_sso_domains`, and `sso` is that domain. Otherwise `sso` is empty.\n\n### Checks and errors\n\nThe finish method returns Candid `variant { ok; err : Error }`, so the frontend checks `\"err\" in result`. It checks, in order:\n\n| Check | Error |\n|---|---|\n| A bundle is attached | `NoAttributes` |\n| It decodes to an ICRC-3 `Value::Map` | `MalformedCandid` |\n| `frontend_origins` is set | `FrontendOriginsNotConfigured` |\n| `implicit:origin` is one of `frontend_origins` | `FrontendOriginMismatch { expected, got }` |\n| `implicit:issued_at_timestamp_ns` is at most five minutes old | `Stale { ageNs }` |\n| `implicit:nonce` was issued here and not consumed | `UnknownNonce` |\n| A required implicit field is present | `MissingField` |\n| Every `sso:\u003Cdomain>:*` key's domain is trusted | `UntrustedSsoSource { domain }` |\n| Name and email come from `sso:` keys or from others, never both | `MixedSsoSources { ssoKeys, otherKeys }` |\n| Each field comes from one key, and `sso:` keys from one domain | `AmbiguousAttribute { field, sources }` |\n\n`UnknownNonce` answers a nonce older than five minutes, one already spent, and, in Rust, one issued before an upgrade. Treat it as \"retry from `_internet_identity_sign_in_start` with a fresh nonce\", not as a bug.\n\n### Motoko\n\n```toml\n[dependencies]\nidentity-attributes = \"0.4.1\"\ncore                = \"2.5.0\"\n\n[toolchain]\nmoc = \"1.6.0\"\n```\n\n`include IdentityAttributes({ onVerified })` injects both methods:\n\n```motoko\nimport IdentityAttributes \"mo:identity-attributes\";\nimport Map \"mo:core\u002FMap\";\nimport Principal \"mo:core\u002FPrincipal\";\n\npersistent actor {\n  type Profile = { name : ?Text; email : ?Text; sso : ?Text };\n\n  let profiles = Map.empty\u003CPrincipal, Profile>();\n\n  include IdentityAttributes({\n    onVerified = func(caller, attrs) {\n      profiles.add(caller, attrs);\n    };\n  });\n\n  public query func getProfile(userId : Principal) : async ?Profile {\n    profiles.get(userId)\n  };\n};\n```\n\n### Rust\n\n```toml\n[dependencies]\ncandid = \"0.10\"\nic-cdk = \"0.20.1\"\nidentity-attributes = \"0.1\"\n```\n\n`#[identity_attributes]` marks the callback and adds both methods. The function cannot be `async` or generic:\n\n```rust\nuse candid::Principal;\nuse ic_cdk::query;\nuse identity_attributes::{identity_attributes, IdentityAttributes};\nuse std::cell::RefCell;\nuse std::collections::BTreeMap;\n\nthread_local! {\n    \u002F\u002F On the heap to keep the example short: an upgrade clears it.\n    static PROFILES: RefCell\u003CBTreeMap\u003CPrincipal, IdentityAttributes>> =\n        const { RefCell::new(BTreeMap::new()) };\n}\n\n#[identity_attributes]\nfn on_verified(caller: Principal, attributes: IdentityAttributes) {\n    PROFILES.with_borrow_mut(|profiles| profiles.insert(caller, attributes));\n}\n\n#[query]\nfn get_profile(user_id: Principal) -> Option\u003CIdentityAttributes> {\n    PROFILES.with_borrow(|profiles| profiles.get(&user_id).cloned())\n}\n\nic_cdk::export_candid!();\n```\n\n`identity_attributes::sign_in_start()` and `identity_attributes::sign_in_finish(on_verified)` are the functions behind the two methods, for a canister that defines them itself.\n\n## Mistakes That Break Your Build\n\n1. **Generating the attribute nonce on the frontend.** The nonce passed to `requestAttributes` MUST come from the backend (`_internet_identity_sign_in_start`), or the canister cannot check that the bundle's `implicit:nonce` is one it issued, and replay protection is gone.\n2. **Reading attribute data without verifying the signer.** The IC verifies the signature, not who signed: any canister can produce a valid bundle. The trusted signer is `rdmx6-jaaaa-aaaaa-aaadq-cai`. Use the `identity-attributes` library with `trusted_attribute_signers` and `frontend_origins` configured. Hand-written Rust must check `msg_caller_info_signer()` before reading `msg_caller_info_data()`, or an attacker canister can forge `email = \"admin@you.com\"`.\n3. **Substituting `{tid}` in the Microsoft scoped-key prefix.** The `microsoft` provider URL is the literal `https:\u002F\u002Flogin.microsoftonline.com\u002F{tid}\u002Fv2.0`; keys look like `openid:https:\u002F\u002Flogin.microsoftonline.com\u002F{tid}\u002Fv2.0:email` exactly. Filling in a tenant ID misses every lookup.\n4. **Treating `email` as verified.** `email` is the raw address from the user's II-linked account; II does not check it, so treat it as user input. `verified_email` is present only when II established that the user controls the address: an OpenID provider marked it verified, or the user verified it with II. Gate access on `verified_email` only. There is **no `verified_email` under `sso:`**: the organization's own provider asserts `sso:\u003Cdomain>:email`, so trust it only for domains in `trusted_sso_domains`. What an organization can and cannot assert about its own staff is the `organization-sign-in` skill.\n",{"name":5,"license":15,"metadata":25,"description":7,"compatibility":28},{"title":26,"category":27},"User Attributes","Auth","moc >= 1.6.0, ic-cdk >= 0.20.1","main","e981a10d43164675beb283a1ad10bc49ade686f1","skills\u002Fchains\u002Fdfinity-official-user-attributes",17,"https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia","https:\u002F\u002Feth2030.com","Hardcore infra. Building @alt-research and applied cryptography.","2026-11-15 02:28:10",{"source":8,"skillName":5,"commands":39,"prompt":49,"zipAvailable":50},[40,43,46],{"tool":41,"command":42},"npx","npx skills add jiayaoqijia\u002Fcryptoskill --skill user-attributes",{"tool":44,"command":45},"bunx","bunx skills add jiayaoqijia\u002Fcryptoskill --skill user-attributes",{"tool":47,"command":48},"pnpm","pnpm dlx skills add jiayaoqijia\u002Fcryptoskill --skill user-attributes","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fchains\u002Fdfinity-official-user-attributes\u002FSKILL.md",true,[52,56,62],{"path":53,"resourceType":53,"resourceTypeDesc":54,"sizeBytes":55,"sourceHtmlUrl":16},"LICENSE","许可证",10770,{"path":57,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":60,"sourceHtmlUrl":61},"SOURCE.md","REFERENCE","参考文档",333,"https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fchains\u002Fdfinity-official-user-attributes\u002FSOURCE.md",{"path":63,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":64,"sourceHtmlUrl":65},"TRUST.auto.yaml",2191,"https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fchains\u002Fdfinity-official-user-attributes\u002FTRUST.auto.yaml",[67,77,85,93,101,109],{"skillNo":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":71,"licenseFileUrl":72,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":76},"01M7DTKCERMV0RNX3HZJP4CZ26","troves","Deposit and withdraw from Troves DeFi yield vault strategies on Starknet. View available strategies, check positions, and manage vault deposits. Use this skill when the user mentions Troves, vault, yield vault, DeFi vault, strategy, yield farming, vault deposit, vault withdraw, earning yield through vaults, passive yield strategies, or wants to deposit into or withdraw from a yield strategy — even if they don't say \"Troves\" explicitly.","MIT","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-troves\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-troves\u002FSKILL.md",[],[],"2026-11-15 14:19:17",{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":71,"licenseFileUrl":81,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":76},"01M7DTK6CJSMGC8KCQHGNYFZBD","trade","Swap tokens on Starknet via Fibrous DEX aggregator. Supports per-provider selection (avnu, ekubo, or auto to race all). Use this skill when the user wants to swap, exchange, trade, convert, buy, or sell one token for another on Starknet. Also use when the user asks about token prices, exchange rates, DEX routing, best swap route, or wants to check how much they would receive for a given amount — even if they don't explicitly say \"swap\".","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-trade\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-trade\u002FSKILL.md",[],[],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":71,"licenseFileUrl":89,"sourceHtmlUrl":90,"categories":91,"keywords":92,"publishedAt":76},"01M7DTJZ6A0X4PAW3Y8W4J9K64","staking","Stake, unstake, claim, and compound rewards for STRK, WBTC, tBTC, SolvBTC, and LBTC on Starknet. View validators, pools, and staking positions. Use this skill when the user mentions staking, delegating, validators, staking pools, rewards, compounding, unstaking, earning yield, passive income on crypto, or wants to earn on their STRK or BTC tokens — even if they don't say \"stake\" explicitly.","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-staking\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-staking\u002FSKILL.md",[],[],{"skillNo":94,"name":95,"nameZh":6,"description":96,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":71,"licenseFileUrl":97,"sourceHtmlUrl":98,"categories":99,"keywords":100,"publishedAt":76},"01M7DTJSDZJKCDMW7GHRF4BRH5","send","Send STRK, ETH, or any ERC-20 token to a Starknet address. Supports simulation (dry-run) before execution. Use this skill when the user wants to send, transfer, pay, tip, or move tokens to another wallet address on Starknet. Also trigger when the user mentions sending funds to someone, making a payment, transferring assets, or moving crypto to a specific address — even if they just say \"pay 10 STRK to 0x...\".","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-send\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-send\u002FSKILL.md",[],[],{"skillNo":102,"name":103,"nameZh":6,"description":104,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":71,"licenseFileUrl":105,"sourceHtmlUrl":106,"categories":107,"keywords":108,"publishedAt":76},"01M7DTJG1E480D51ZQ7WKDQ26K","portfolio","View a comprehensive DeFi portfolio dashboard and optimize portfolio allocation via automated rebalancing. Use this skill when the user wants an overview, summary, dashboard, total value, net worth, portfolio rebalancing, target allocation, or wants to see all their DeFi positions across Starknet at once. Also trigger when the user asks \"what do I have\", \"show me everything\", \"how much am I worth\", \"my positions\", \"my investments\", \"rebalance my portfolio\", \"I want 50% ETH\", \"optimize my holdings\", or any request for a holistic view of their Starknet holdings — even if they don't explicitly say \"portfolio\".","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-portfolio\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-portfolio\u002FSKILL.md",[],[],{"skillNo":110,"name":111,"nameZh":6,"description":112,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":71,"licenseFileUrl":113,"sourceHtmlUrl":114,"categories":115,"keywords":116,"publishedAt":76},"01M7DTJ7M8TE9R2N36HFBZDGVD","multi-swap","Execute multiple token swaps in a single Starknet transaction via Fibrous (default). Supports per-provider selection (avnu, ekubo, or auto to race all). Supports 2-3 swap pairs bundled into one multicall. Use this skill when the user wants to swap multiple token pairs at once, do batch swaps, execute several trades simultaneously, perform parallel swaps, or do bulk trading in one transaction. Also trigger when the user mentions \"two swaps\", \"three swaps\", \"swap X and Y at the same time\", or wants to convert multiple tokens in a single call.","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-multi-swap\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-multi-swap\u002FSKILL.md",[],[]]