Skip to content

Commit 207349b

Browse files
committed
feat(internet-identity): use sign-in terminology in prose, keep logout API
1 parent 0c6605b commit 207349b

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

skills/internet-identity/SKILL.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
name: internet-identity
3-
description: "Integrate Internet Identity authentication. Covers passkey and OpenID login flows, delegation handling, and principal-per-app isolation. Use when adding login, sign-in, auth, passkeys, or Internet Identity to a frontend or canister. Do NOT use for wallet integration or ICRC signer flows — use wallet-integration instead."
3+
description: "Integrate Internet Identity authentication. Covers passkey and OpenID sign-in flows, delegation handling, and principal-per-app isolation. Use when adding sign-in, login, auth, passkeys, or Internet Identity to a frontend or canister. Do NOT use for wallet integration or ICRC signer flows — use wallet-integration instead."
44
license: Apache-2.0
55
compatibility: "icp-cli >= 0.2.2, Node.js >= 22"
66
metadata:
@@ -12,7 +12,7 @@ metadata:
1212

1313
## What This Is
1414

15-
Internet Identity (II) is the Internet Computer's native authentication system. Users authenticate into II-powered apps either with passkeys stored in their devices or thorugh OpenID accounts (e.g., Google, Apple, Microsoft) -- no login or passwords required. Each user gets a unique principal per app, preventing cross-app tracking.
15+
Internet Identity (II) is the Internet Computer's native authentication system. Users authenticate into II-powered apps either with passkeys stored in their devices or thorugh OpenID accounts (e.g., Google, Apple, Microsoft) -- no usernames or passwords required. Each user gets a unique principal per app, preventing cross-app tracking.
1616

1717
## Prerequisites
1818

@@ -35,7 +35,7 @@ Internet Identity (II) is the Internet Computer's native authentication system.
3535

3636
4. **Using `shouldFetchRootKey` or `fetchRootKey()` instead of the `ic_env` cookie.** The `ic_env` cookie (set by the asset canister or the Vite dev server) already contains the root key as `IC_ROOT_KEY`. Pass it via the `rootKey` option to `HttpAgent.create()` — this works in both local and production environments without environment branching. See the icp-cli skill's `references/binding-generation.md` for the pattern. Never call `fetchRootKey()` — it fetches the root key from the replica at runtime, which lets a man-in-the-middle substitute a fake key on mainnet.
3737

38-
5. **Getting `2vxsx-fae` as the principal after login.** That is the anonymous principal -- it means authentication silently failed. Common causes: wrong `identityProvider` URL passed to the `AuthClient` constructor, an unhandled rejection from `signIn()`, or reading `getIdentity()` before `signIn()` resolved.
38+
5. **Getting `2vxsx-fae` as the principal after sign-in.** That is the anonymous principal -- it means authentication silently failed. Common causes: wrong `identityProvider` URL passed to the `AuthClient` constructor, an unhandled rejection from `signIn()`, or reading `getIdentity()` before `signIn()` resolved.
3939

4040
6. **Passing principal as string to backend.** The `AuthClient` gives you an `Identity` object. Backend canister methods receive the caller principal automatically via the IC protocol -- you do not pass it as a function argument. The caller principal is available on the backend via `shared(msg) { msg.caller }` in Motoko or `ic_cdk::api::msg_caller()` in Rust. For backend access control patterns, see the **canister-security** skill.
4141

@@ -66,7 +66,7 @@ This deploys the II canisters automatically when the local network is started. B
6666
No canister entry needed — II is not part of your project's canisters.
6767
For the full `icp.yaml` canister configuration, see the **icp-cli** and **asset-canister** skills.
6868

69-
### Frontend: Vanilla JavaScript/TypeScript Login Flow
69+
### Frontend: Vanilla JavaScript/TypeScript Sign-In Flow
7070

7171
This is framework-agnostic. Adapt the DOM manipulation to your framework.
7272

@@ -99,22 +99,22 @@ const authClient = new AuthClient({
9999
identityProvider: getIdentityProviderUrl(),
100100
});
101101
102-
// Login: signIn() returns the new Identity directly and rejects if the user
102+
// Sign in: signIn() returns the new Identity directly and rejects if the user
103103
// closes the popup or authentication fails.
104-
async function login() {
104+
async function signIn() {
105105
try {
106106
const identity = await authClient.signIn({
107107
maxTimeToLive: BigInt(8) * BigInt(3_600_000_000_000), // 8 hours in nanoseconds
108108
});
109-
console.log("Logged in as:", identity.getPrincipal().toText());
109+
console.log("Signed in as:", identity.getPrincipal().toText());
110110
return identity;
111111
} catch (error) {
112-
console.error("Login failed:", error);
112+
console.error("Sign-in failed:", error);
113113
throw error;
114114
}
115115
}
116116
117-
// Logout
117+
// Log out
118118
async function logout() {
119119
await authClient.logout();
120120
// Optionally reload or reset UI state

0 commit comments

Comments
 (0)