Skip to content

Commit 5579b80

Browse files
docs: local development identities (#642)
* docs: local development identities Signed-off-by: David Dal Busco <david.dalbusco@outlook.com> * 📄 Update LLMs.txt snapshot for PR review --------- Signed-off-by: David Dal Busco <david.dalbusco@outlook.com> Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
1 parent bd0d373 commit 5579b80

4 files changed

Lines changed: 212 additions & 1 deletion

File tree

.llms-snapshots/llms-full.txt

Lines changed: 89 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,94 @@ juno.config.js
768768
import { defineConfig } from "@junobuild/config";export default defineConfig({ satellite: { ids: { production: "qsgjb-riaaa-aaaaa-aaaga-cai" }, source: "dist" }, orbiter: { ids: { production: "aaaa-bbbbb-ccccc-ddddd-cai", development: "ffff-eeee-ddddd-ccccc-cai" } }});
769769
```
770770

771+
# Local Development and E2E
772+
773+
Implementing Google, Internet Identity, or Passkeys requires some setup and doesn't always fit best in a local development environment or E2E test suite. For example, they take various steps to complete and therefore consume repetitive time.
774+
775+
Local dev identities skip all that.
776+
777+
They let you test authentication flows instantly - no setup, no external services, no waiting. Just one click with names like "alice" or "bob", and you're signed in.
778+
779+
**Caution:**
780+
781+
**For local development only** - works exclusively on `localhost` and `127.0.0.1`.
782+
783+
---
784+
785+
## How It Works
786+
787+
1. You optionally provide an identifier (e.g., "alice", "bob"). Default is "dev".
788+
2. A deterministic identity is generated on the client side from that identifier.
789+
3. The identifier is stored in IndexedDB and reused across sessions.
790+
4. You can switch between different dev identities easily.
791+
792+
**Note:**
793+
794+
Given the deterministic nature of these identities, as mentioned above, they cannot be used in production. That's why the library prevents any usage outside of localhost.
795+
796+
---
797+
798+
## Sign-In
799+
800+
```
801+
import { signIn } from "@junobuild/core";// ⚠️ LOCAL DEVELOPMENT ONLY - Replace with a real provider for productionawait signIn({ dev: {}});
802+
```
803+
804+
---
805+
806+
## Options
807+
808+
| Option | Type | Default | Description |
809+
| --- | --- | --- | --- |
810+
| `identifier` | `string` | `"dev"` | Unique identifier for this dev identity (max 32 characters) |
811+
| `maxTimeToLiveInMilliseconds` | `number` | 7 days | How long the session lasts in milliseconds |
812+
813+
Example:
814+
815+
```
816+
// ⚠️ LOCAL DEVELOPMENT ONLY - Replace with a real provider for productionawait signIn({ dev: { identifier: "alice", maxTimeToLiveInMilliseconds: 24 * 60 * 60 * 1000 // 1 day }});
817+
```
818+
819+
---
820+
821+
---
822+
823+
## Managing Identifiers
824+
825+
During development, you may want to see which identities you've used or clear them out.
826+
827+
---
828+
829+
### Load
830+
831+
Retrieve all previously used dev identifiers, sorted by most recent first:
832+
833+
```
834+
import { loadDevIdentifiers } from "@junobuild/ic-client/dev";// ⚠️ DEV UTILITY - Not needed for production appsconst identifiers = await loadDevIdentifiers();// [['alice', { createdAt: 1234567890, updatedAt: 1234567899 }], ...]// You can also limit resultsconst recent = await loadDevIdentifiers({ limit: 5 });
835+
```
836+
837+
---
838+
839+
### Clear
840+
841+
Remove all stored dev identifiers from browser's IndexedDB:
842+
843+
```
844+
import { clearDevIdentifiers } from "@junobuild/ic-client/dev";// ⚠️ DEV UTILITY - Not needed for production appsawait clearDevIdentifiers();
845+
```
846+
847+
**Note:**
848+
849+
Clearing identifiers only removes the usage history.
850+
851+
---
852+
853+
## Recommendations
854+
855+
* ⚠️ **Never use in production** - automatically blocked on non-localhost domains
856+
* Use different identifiers to test multi-user scenarios
857+
* Switch to real providers (Google, Internet Identity, Passkeys) before deploying
858+
771859
# Google
772860

773861
Google Sign-In lets users authenticate with their existing Google account using OpenID Connect (OIDC) - a modern, secure identity standard built on top of OAuth 2.0.
@@ -8720,7 +8808,7 @@ For most applications, we recommend using the default subnets and staying on the
87208808

87218809
| Subnet ID | Type | Canisters (Running/Stopped) | Nodes (Up/Total) |
87228810
| --- | --- | --- | --- |
8723-
| 6pbhf-qzpdk-kuqbr-pklfa-5ehhf-jfjps-zsj6q-57nrl-kzhpd-mu7hc-vae | Juno's Subnet | 36001/696 | 13/13 |
8811+
| 6pbhf-qzpdk-kuqbr-pklfa-5ehhf-jfjps-zsj6q-57nrl-kzhpd-mu7hc-vae | Juno's Subnet | 36101/703 | 13/13 |
87248812
| pzp6e-ekpqk-3c5x7-2h6so-njoeq-mt45d-h3h6c-q3mxf-vpeq5-fk5o7-yae | Fiduciary | 3564/12 | 34/34 |
87258813
| bkfrj-6k62g-dycql-7h53p-atvkj-zg4to-gaogh-netha-ptybj-ntsgw-rqe | European | 25096/663 | 13/13 |
87268814
| brlsh-zidhj-3yy3e-6vqbz-7xnih-xeq2l-as5oc-g32c4-i5pdn-2wwof-oae | | 35432/815 | 13/13 |

.llms-snapshots/llms.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Juno is your self-contained serverless platform for building full-stack web apps
1717

1818
## Build - Authentication
1919

20+
- [Development](https://juno.build/docs/build/authentication/dev.md): Learn how to use development identities for local testing or E2E with Juno without external authentication providers.
2021
- [Google](https://juno.build/docs/build/authentication/google.md): Learn how to integrate Google Sign-In with Juno using OpenID Connect for secure, standards-based authentication.
2122
- [Internet Identity](https://juno.build/docs/build/authentication/internet-identity.md): Learn how to integrate Internet Identity with Juno for decentralized, privacy-preserving authentication on the Internet Computer.
2223
- [Management](https://juno.build/docs/build/authentication/management.md): This page provides an overview of the administrative functions available in the Juno Console related to user management.

docs/build/authentication/dev.md

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
---
2+
title: Development
3+
description: Learn how to use development identities for local testing or E2E with Juno without external authentication providers.
4+
keywords: [dev, local development, testing, localhost]
5+
---
6+
7+
# Local Development and E2E
8+
9+
Implementing Google, Internet Identity, or Passkeys requires some setup and doesn't always fit best in a local development environment or E2E test suite. For example, they take various steps to complete and therefore consume repetitive time.
10+
11+
Local dev identities skip all that.
12+
13+
They let you test authentication flows instantly - no setup, no external services, no waiting. Just one click with names like "alice" or "bob", and you're signed in.
14+
15+
:::caution
16+
17+
**For local development only** - works exclusively on `localhost` and `127.0.0.1`.
18+
19+
:::
20+
21+
---
22+
23+
## How It Works
24+
25+
1. You optionally provide an identifier (e.g., "alice", "bob"). Default is "dev".
26+
2. A deterministic identity is generated on the client side from that identifier.
27+
3. The identifier is stored in IndexedDB and reused across sessions.
28+
4. You can switch between different dev identities easily.
29+
30+
:::note
31+
32+
Given the deterministic nature of these identities, as mentioned above, they cannot be used in production.
33+
That's why the library prevents any usage outside of localhost.
34+
35+
:::
36+
37+
---
38+
39+
## Sign-In
40+
41+
```typescript
42+
import { signIn } from "@junobuild/core";
43+
44+
// ⚠️ LOCAL DEVELOPMENT ONLY - Replace with a real provider for production
45+
await signIn({
46+
dev: {}
47+
});
48+
```
49+
50+
---
51+
52+
## Options
53+
54+
| Option | Type | Default | Description |
55+
| ----------------------------- | -------- | ------- | ----------------------------------------------------------- |
56+
| `identifier` | `string` | `"dev"` | Unique identifier for this dev identity (max 32 characters) |
57+
| `maxTimeToLiveInMilliseconds` | `number` | 7 days | How long the session lasts in milliseconds |
58+
59+
Example:
60+
61+
```typescript
62+
// ⚠️ LOCAL DEVELOPMENT ONLY - Replace with a real provider for production
63+
await signIn({
64+
dev: {
65+
identifier: "alice",
66+
maxTimeToLiveInMilliseconds: 24 * 60 * 60 * 1000 // 1 day
67+
}
68+
});
69+
```
70+
71+
---
72+
73+
---
74+
75+
## Managing Identifiers
76+
77+
During development, you may want to see which identities you've used or clear them out.
78+
79+
---
80+
81+
### Load
82+
83+
Retrieve all previously used dev identifiers, sorted by most recent first:
84+
85+
```typescript
86+
import { loadDevIdentifiers } from "@junobuild/ic-client/dev";
87+
88+
// ⚠️ DEV UTILITY - Not needed for production apps
89+
const identifiers = await loadDevIdentifiers();
90+
// [['alice', { createdAt: 1234567890, updatedAt: 1234567899 }], ...]
91+
92+
// You can also limit results
93+
const recent = await loadDevIdentifiers({ limit: 5 });
94+
```
95+
96+
---
97+
98+
### Clear
99+
100+
Remove all stored dev identifiers from browser's IndexedDB:
101+
102+
```typescript
103+
import { clearDevIdentifiers } from "@junobuild/ic-client/dev";
104+
105+
// ⚠️ DEV UTILITY - Not needed for production apps
106+
await clearDevIdentifiers();
107+
```
108+
109+
:::note
110+
111+
Clearing identifiers only removes the usage history.
112+
113+
:::
114+
115+
---
116+
117+
## Recommendations
118+
119+
- ⚠️ **Never use in production** - automatically blocked on non-localhost domains
120+
- Use different identifiers to test multi-user scenarios
121+
- Switch to real providers (Google, Internet Identity, Passkeys) before deploying

sidebars.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const sidebars: SidebarsConfig = {
3333
"build/authentication/google",
3434
"build/authentication/internet-identity",
3535
"build/authentication/passkeys",
36+
"build/authentication/dev",
3637
"build/authentication/utilities",
3738
"build/authentication/management"
3839
]

0 commit comments

Comments
 (0)