isa-auth 0.1.0 β†’ 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,154 @@
1
+ ---
2
+ name: isa-auth-guide
3
+ description: Complete developer and architecture guide for using and extending the isa-auth multi-provider authentication framework, covering OAuth (Google, Apple, Meta, Line, Kakao, Naver), Developer (GitHub, Discord), Web3 (SIWE), Identity (World ID Orb, Passkey WebAuthn), reactive store, Axios/Fetch interceptors, and RBAC/ABAC guards.
4
+ ---
5
+
6
+ # ISA-AUTH Comprehensive Guide & Developer Skill
7
+
8
+ This skill provides full reference, architecture details, and copy-paste recipes for working with the `isa-auth` suite.
9
+
10
+ ---
11
+
12
+ ## πŸ“Œ 1. Architecture & Provider Taxonomy
13
+
14
+ `isa-auth` is a **zero-Node-dependency, framework-agnostic client authentication suite** published under the single package `isa-auth`.
15
+
16
+ ### 4 Provider Categories
17
+ | Category | Providers | Key Features |
18
+ | :--- | :--- | :--- |
19
+ | **`social`** | Google, Apple, Meta/Facebook, Kakao, Naver, LINE | Native SDK wrappers, OpenID Connect, OAuth 2.0 PKCE |
20
+ | **`developer`** | GitHub, Discord | Developer OAuth 2.0 PKCE, Bot/Server authorization |
21
+ | **`web3`** | Ethereum SIWE (EIP-4361) | EIP-1193 wallet detection, `personal_sign` signature |
22
+ | **`identity`** | World ID (Orb), Passkey (WebAuthn/FIDO2) | ZK-SNARK Proof of Personhood, Face ID / Touch ID / Windows Hello |
23
+
24
+ ---
25
+
26
+ ## πŸš€ 2. Code Recipes
27
+
28
+ ### Recipe A: World ID (World Network / Orb Verification)
29
+ ```typescript
30
+ import { IsaAuth } from 'isa-auth';
31
+
32
+ const worldAuth = new IsaAuth({
33
+ provider: 'world',
34
+ clientId: 'app_staging_your_app_id',
35
+ extraOptions: {
36
+ action: 'vote',
37
+ verificationLevel: 'orb', // 'orb' (Biometric iris scan) or 'device'
38
+ signal: 'user_wallet_0x123',
39
+ onSuccess: (proof) => {
40
+ console.log('ZK Proof generated:', proof.nullifier_hash, proof.proof);
41
+ },
42
+ },
43
+ });
44
+
45
+ await worldAuth.signIn();
46
+ const userInfo = await worldAuth.getUserInfo();
47
+ // { id: '0x...', isHuman: true, verificationLevel: 'orb', ... }
48
+ ```
49
+
50
+ ### Recipe B: Passkey (FIDO2 / WebAuthn Biometrics)
51
+ ```typescript
52
+ import { IsaAuth } from 'isa-auth';
53
+
54
+ const passkeyAuth = new IsaAuth({
55
+ provider: 'passkey',
56
+ extraOptions: {
57
+ rpName: 'My Financial App',
58
+ rpId: window.location.hostname,
59
+ userName: 'alice@example.com',
60
+ },
61
+ });
62
+
63
+ // Authenticate via Face ID / Touch ID / Windows Hello
64
+ await passkeyAuth.signIn();
65
+
66
+ // Register new biometric credential
67
+ await passkeyAuth.providerInstance.registerCredential();
68
+ ```
69
+
70
+ ### Recipe C: Axios Interceptor with Automatic 401 Refresh & Queue
71
+ ```typescript
72
+ import axios from 'axios';
73
+ import { IsaAuth } from 'isa-auth';
74
+
75
+ const auth = new IsaAuth({ provider: 'jwt' });
76
+ const apiClient = axios.create({ baseURL: 'https://api.example.com' });
77
+
78
+ // Applies Authorization: Bearer <token> & deduplicated 401 token refresh queue
79
+ auth.applyAxiosInterceptor(apiClient, {
80
+ refreshFn: async () => {
81
+ const res = await axios.post('/api/auth/refresh');
82
+ return res.data.accessToken;
83
+ },
84
+ onUnauthorized: () => {
85
+ window.location.href = '/login';
86
+ },
87
+ });
88
+ ```
89
+
90
+ ### Recipe D: Backend Token Exchange Adapter
91
+ ```typescript
92
+ import { IsaAuth, HttpTokenExchangeAdapter } from 'isa-auth';
93
+
94
+ const auth = new IsaAuth({ provider: 'github' });
95
+ const exchange = auth.createTokenExchange('/api/auth/token-exchange');
96
+
97
+ // 1. Exchange OAuth code for JWT
98
+ const tokenRes = await exchange.exchangeOAuthCode('github', 'auth-code-123');
99
+ auth.setAccessToken(tokenRes.accessToken);
100
+
101
+ // 2. Exchange World ID ZK-proof for session
102
+ const worldRes = await exchange.exchangeWorldProof(worldProofResult);
103
+ auth.setAccessToken(worldRes.accessToken);
104
+ ```
105
+
106
+ ### Recipe E: Wildcard RBAC / ABAC Guards & Router Redirection
107
+ ```typescript
108
+ import { IsaAuth } from 'isa-auth';
109
+
110
+ const auth = new IsaAuth({ provider: 'jwt' });
111
+
112
+ // Instant wildcard permission check
113
+ const canEdit = auth.can('users:edit'); // Matches 'users:*' or '*'
114
+
115
+ // Navigation Guard for React Router / Vue Router
116
+ const guard = auth.createNavigationGuard({
117
+ requireAuth: true,
118
+ roles: ['ADMIN'],
119
+ roleHierarchy: {
120
+ SUPERUSER: ['ADMIN', 'EDITOR'],
121
+ ADMIN: ['USER'],
122
+ },
123
+ permissions: ['reports:*'],
124
+ redirectToOnUnauthenticated: '/login',
125
+ redirectToOnUnauthorized: '/403',
126
+ onRedirect: (path) => router.push(path),
127
+ });
128
+ ```
129
+
130
+ ### Recipe F: HttpOnly Cookie / Hybrid Session Storage
131
+ ```typescript
132
+ import { IsaAuth } from 'isa-auth';
133
+
134
+ // In BFF setups where tokens live exclusively in HttpOnly cookies:
135
+ const auth = new IsaAuth({
136
+ provider: 'base',
137
+ storage: 'cookie', // CookieSessionStorageAdapter omits client JWT persistence
138
+ });
139
+ ```
140
+
141
+ ---
142
+
143
+ ## πŸ› οΈ 3. Monorepo Build & Test Commands
144
+
145
+ ```bash
146
+ # 1. Full Monorepo Build (SWC core compilation + tsup inline bundling)
147
+ yarn build # On Windows: yarn.cmd build
148
+
149
+ # 2. Run Comprehensive Test Suite (22 automated test cases)
150
+ node scratch/test_enhanced_features.js
151
+
152
+ # 3. Launch Local Demo Playground
153
+ yarn demo # Serves http://localhost:3000
154
+ ```
package/README.md CHANGED
@@ -1,25 +1,30 @@
1
1
  # πŸš€ ISA AUTH
2
2
 
3
3
  > **A Unified, Framework-Agnostic Frontend Authentication Suite**
4
- > Supporting Multi-Provider OAuth (Google, Kakao, Naver), Web3 (SIWE), Reactive Store, JWT Management, and RBAC Route Guards.
4
+ > Supporting Multi-Provider OAuth (Google, Apple, Meta, Line, Kakao, Naver), Developer (GitHub, Discord), Web3 (SIWE), Identity (World ID Orb, Passkey WebAuthn), Reactive Store, Axios/Fetch Interceptors, and RBAC/ABAC Guards.
5
5
 
6
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
7
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.8-blue.svg)](https://www.typescriptlang.org/)
8
8
  [![SWC](https://img.shields.io/badge/Compiler-SWC-orange.svg)](https://swc.rs/)
9
+ [![Bundle Size](https://img.shields.io/badge/Zero_Node_Dependencies-Web_Crypto-green.svg)](https://w3c.github.io/webcrypto/)
9
10
 
10
11
  ---
11
12
 
12
13
  ## 🌟 Why ISA AUTH?
13
14
 
14
- Modern web applications frequently require diverse authentication methods β€” from global platforms (Google, Apple) and local providers (Kakao, Naver) to decentralized blockchain identity (SIWE) and standard JWT credentials.
15
+ Modern web applications frequently require diverse authentication methods β€” from global platforms (Google, Apple, Meta) and local portals (Kakao, Naver, Line) to developer communities (GitHub, Discord), decentralized Web3 wallets (SIWE), and next-generation biometric/identity systems (**World ID Orb & Passkey**).
15
16
 
16
17
  **ISA AUTH** provides an all-in-one, frontend-centric architecture that is:
17
18
 
18
19
  - **Framework-Agnostic**: Works seamlessly across Vanilla JS, React, Vue, Svelte, or Web Components.
19
20
  - **Zero Node.js Dependencies**: Pure browser-safe cryptographic & JWT utilities with zero Node runtime bloat.
20
- - **Built-in Reactive State & Persistence**: Lightweight pub/sub store with automatic `localStorage`/`sessionStorage` synchronization across browser tabs.
21
- - **Enterprise-Ready Authorization (RBAC)**: Fine-grained Role and Permission guards for protecting SPA routes and UI elements.
22
- - **Web3 & Modern OAuth Standard**: Native EIP-4361 (Sign-In with Ethereum) and OAuth 2.0 PKCE helpers out-of-the-box.
21
+ - **Categorized Provider Taxonomy**: Organized into `social`, `developer`, `web3`, and `identity` domains.
22
+ - **Next-Gen Identity & Biometrics**: Native support for **World ID (Orb Proof-of-Personhood)** and **Passkey (FIDO2 WebAuthn)**.
23
+ - **Enterprise-Ready RBAC/ABAC**: Wildcard permission matching (`users:*`), role hierarchy inheritance, and router navigation guards.
24
+ - **HTTP Interceptors (Axios & Fetch)**: Auto `Authorization: Bearer <token>` injection and deduplicated 401 refresh queues.
25
+ - **Token Exchange Standard**: Standardized adapter for exchanging OAuth codes, World ID proofs, and Passkey assertions with backend APIs.
26
+ - **Flexible Storage Modes**: Multi-tab synchronization, prefix isolation, and **HttpOnly Cookie / Hybrid BFF mode**.
27
+ - **AI Agent Skill Included**: Embedded `isa-auth-guide` skill directly bundled for agent-assisted development.
23
28
 
24
29
  ---
25
30
 
@@ -35,18 +40,52 @@ pnpm add isa-auth
35
40
 
36
41
  ---
37
42
 
38
- ## πŸš€ Quick Start
43
+ ## πŸ›οΈ Architecture & Provider Taxonomy
44
+
45
+ ```
46
+ [UI Layer] Vanilla DOM / React / Vue / Web Component (<isa-auth-button>)
47
+ β”‚
48
+ [Unified Facade] IsaAuth (packages/isa-auth)
49
+ β”‚
50
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
51
+ β–Ό β–Ό β–Ό β–Ό
52
+ [Providers] [Service] [Store] [Guards & HTTP]
53
+ β”œβ”€ Social - JwtService - Memory - createAuthGuard (RBAC/ABAC)
54
+ β”‚ (Google, Apple,- BaseService - Local - Wildcard & Hierarchy
55
+ β”‚ Meta/FB, - TokenExchange - Session - Navigation Guard
56
+ β”‚ Kakao, Naver,- AutoRefresh - Cookie - onUnauthorized Hook
57
+ β”‚ LINE) - PKCE Utils - Tab Sync - createAuthFetch (Auto 401)
58
+ β”œβ”€ Developer - applyAuthInterceptor (Axios)
59
+ β”‚ (GitHub, Discord)
60
+ β”œβ”€ Web3
61
+ β”‚ (Ethereum SIWE)
62
+ └─ Identity
63
+ (World ID Orb, Passkey FIDO2)
64
+ ```
65
+
66
+ | Category | Providers | Key Features |
67
+ | :--- | :--- | :--- |
68
+ | **`social`** | Google, Apple, Meta/Facebook, Kakao, Naver, LINE | Native SDK wrappers, OpenID Connect, OAuth 2.0 PKCE |
69
+ | **`developer`** | GitHub, Discord | Developer OAuth 2.0 PKCE, Bot/Server authorization |
70
+ | **`web3`** | Ethereum SIWE (EIP-4361) | EIP-1193 wallet detection, `personal_sign` signature |
71
+ | **`identity`** | World ID (Orb), Passkey (WebAuthn/FIDO2) | ZK-SNARK Proof of Personhood, Face ID / Touch ID / Windows Hello |
72
+
73
+ ---
74
+
75
+ ## πŸš€ Quick Start Recipes
39
76
 
40
77
  ### 1. Unified Authentication Instance
41
78
 
42
79
  ```typescript
43
80
  import { IsaAuth } from 'isa-auth';
44
81
 
45
- // Initialize with your desired provider
82
+ // Initialize with any provider
46
83
  const auth = new IsaAuth({
47
- provider: 'google', // 'google' | 'kakao' | 'naver' | 'web3' | 'jwt' | 'base'
48
- clientId: 'YOUR_GOOGLE_CLIENT_ID.apps.googleusercontent.com',
49
- storage: 'localStorage', // 'localStorage' | 'sessionStorage' | 'memory'
84
+ provider: 'google', // 'google' | 'apple' | 'meta' | 'github' | 'discord' | 'web3' | 'world' | 'passkey'
85
+ clientId: 'YOUR_CLIENT_ID',
86
+ callbackUrl: 'https://myapp.com/auth/callback',
87
+ storage: 'localStorage', // 'localStorage' | 'sessionStorage' | 'memory' | 'cookie'
88
+ storagePrefix: 'myapp',
50
89
  });
51
90
 
52
91
  // Render headless button to a DOM container
@@ -54,7 +93,6 @@ auth.renderButton(document.getElementById('login-container'));
54
93
 
55
94
  // Listen to authentication changes
56
95
  auth.subscribe((isAuthenticated) => {
57
- console.log('Auth state changed:', isAuthenticated);
58
96
  if (isAuthenticated) {
59
97
  console.log('User Profile:', auth.getUserInfo());
60
98
  console.log('Access Token:', auth.getAccessToken());
@@ -64,96 +102,87 @@ auth.subscribe((isAuthenticated) => {
64
102
 
65
103
  ---
66
104
 
67
- ## πŸ”‘ 5 Core Pillars
105
+ ### 2. 🌐 World ID (World Network / Orb Verification)
68
106
 
69
- ### 1. πŸ“¦ Reactive Store & Multi-Tab Synchronization
70
- Built-in pub/sub store without heavyweight external dependencies. Changes in one tab automatically synchronize across all open browser tabs.
107
+ Verify unique humanness using **World ID Orb** Proof-of-Personhood:
71
108
 
72
109
  ```typescript
73
- import { configureStorage, getAuthState, setAccessToken } from 'isa-auth';
110
+ import { IsaAuth } from 'isa-auth';
74
111
 
75
- // Switch storage adapter
76
- configureStorage('localStorage');
112
+ const worldAuth = new IsaAuth({
113
+ provider: 'world',
114
+ clientId: 'app_staging_your_app_id',
115
+ extraOptions: {
116
+ action: 'vote',
117
+ verificationLevel: 'orb', // 'orb' (Biometric iris scan) or 'device'
118
+ signal: 'user_wallet_address',
119
+ onSuccess: (proof) => {
120
+ console.log('Proof nullifier:', proof.nullifier_hash);
121
+ console.log('ZK-SNARK proof:', proof.proof);
122
+ },
123
+ },
124
+ });
77
125
 
78
- // Set token - automatically parses payload, updates reactive store and syncs across tabs
79
- setAccessToken('eyJhbGciOi...');
126
+ await worldAuth.signIn();
127
+ const user = await worldAuth.getUserInfo();
128
+ console.log(user.isHuman); // true
80
129
  ```
81
130
 
82
- ### 2. πŸ›‘οΈ RBAC & Route Guards
83
- Protect routes and UI components based on JWT claims (`roles` and `permissions`).
131
+ ---
132
+
133
+ ### 3. πŸ”‘ Passkey (FIDO2 / WebAuthn Biometrics)
134
+
135
+ Seamless passwordless authentication via **Face ID, Touch ID, or Windows Hello**:
84
136
 
85
137
  ```typescript
86
- import { createAuthGuard } from 'isa-auth';
138
+ import { IsaAuth } from 'isa-auth';
87
139
 
88
- const adminGuard = createAuthGuard({
89
- requireAuth: true,
90
- roles: ['ADMIN'],
91
- onUnauthorized: () => {
92
- alert('403 Forbidden: Administrator access required.');
93
- },
94
- onUnauthenticated: () => {
95
- window.location.href = '/login';
140
+ const passkeyAuth = new IsaAuth({
141
+ provider: 'passkey',
142
+ extraOptions: {
143
+ rpName: 'My Enterprise Bank',
144
+ userName: 'alice@example.com',
96
145
  },
97
146
  });
98
147
 
99
- // Use inside your router (React Router, Vue Router, etc.)
100
- const canAccess = await adminGuard({
101
- isAuthenticated: auth.isAuthenticated(),
102
- roles: auth.getUserInfo()?.roles,
103
- });
104
- ```
148
+ // Authenticate with device biometrics
149
+ await passkeyAuth.signIn();
105
150
 
106
- ### 3. 🌐 Multi-Provider OAuth (Google, Kakao, Naver)
107
- Standardized provider lifecycle with automatic SDK injection and popup/redirect workflows.
151
+ // Register a new passkey credential
152
+ await passkeyAuth.providerInstance.registerCredential();
153
+ ```
108
154
 
109
- ```typescript
110
- // Kakao Provider
111
- const kakaoAuth = new IsaAuth({
112
- provider: 'kakao',
113
- clientId: 'YOUR_KAKAO_JAVASCRIPT_KEY',
114
- callbackUrl: 'https://your-domain.com/oauth/callback',
115
- });
155
+ ---
116
156
 
117
- // Trigger login
118
- await kakaoAuth.signIn();
119
- ```
157
+ ### 4. πŸ”„ HTTP Interceptors (Axios & Fetch) with 401 Auto-Retry
120
158
 
121
- ### 4. ⛓️ Web3 (Sign-In with Ethereum - SIWE)
122
- Native support for EIP-4361 compliant wallet authentication.
159
+ Automatically attaches `Authorization: Bearer <token>` and queues concurrent requests while refreshing expired tokens:
123
160
 
161
+ #### Axios Interceptor:
124
162
  ```typescript
125
- const web3Auth = new IsaAuth({
126
- provider: 'web3',
127
- extraOptions: {
128
- statement: 'Sign in with Ethereum to access the dashboard.',
129
- chainId: 1,
163
+ import axios from 'axios';
164
+ import { IsaAuth } from 'isa-auth';
165
+
166
+ const auth = new IsaAuth({ provider: 'jwt' });
167
+ const apiClient = axios.create({ baseURL: 'https://api.example.com' });
168
+
169
+ // Applies request/response interceptors to Axios
170
+ auth.applyAxiosInterceptor(apiClient, {
171
+ refreshFn: async () => {
172
+ const res = await axios.post('/api/auth/refresh');
173
+ return res.data.accessToken;
174
+ },
175
+ onUnauthorized: () => {
176
+ window.location.href = '/login';
130
177
  },
131
178
  });
132
179
 
133
- // Prompts MetaMask / browser wallet to connect and sign message
134
- await web3Auth.signIn();
180
+ // All requests now have automatic Bearer token injection and 401 recovery
181
+ const response = await apiClient.get('/users/me');
135
182
  ```
136
183
 
137
- ### 5. πŸ› οΈ Authentication Utilities & Auto-Refresh HTTP Client
138
-
184
+ #### Fetch Interceptor:
139
185
  ```typescript
140
- import {
141
- createAuthFetch,
142
- decodeToken,
143
- isExpiredToken,
144
- generateCodeVerifier,
145
- generateCodeChallenge
146
- } from 'isa-auth';
147
-
148
- // 1. Safe JWT decoding (pure browser)
149
- const { payload } = decodeToken(token);
150
- const expired = isExpiredToken(token);
151
-
152
- // 2. PKCE generators for secure OAuth 2.0
153
- const verifier = generateCodeVerifier();
154
- const challenge = await generateCodeChallenge(verifier);
155
-
156
- // 3. HTTP fetch with auto Bearer token and 401 refresh retry
157
186
  const authFetch = auth.createFetch({
158
187
  baseUrl: 'https://api.example.com',
159
188
  refreshFn: async () => {
@@ -163,75 +192,102 @@ const authFetch = auth.createFetch({
163
192
  },
164
193
  });
165
194
 
166
- // Automatically adds "Authorization: Bearer <token>" and refreshes upon 401
167
- const response = await authFetch('/v1/protected-data');
195
+ const res = await authFetch('/protected/data');
168
196
  ```
169
197
 
170
198
  ---
171
199
 
172
- ## 🎨 Framework Adapters
200
+ ### 5. πŸ›‘οΈ Advanced RBAC/ABAC Guards & Navigation Guards
201
+
202
+ Supports **wildcard permission rules** (`users:*`, `*:read`, `*`) and **hierarchical role inheritance**:
173
203
 
174
- ### Vanilla JavaScript
175
204
  ```typescript
176
- import { renderers } from 'isa-auth';
205
+ import { IsaAuth } from 'isa-auth';
177
206
 
178
- const btn = renderers.renderByJs({
179
- label: 'Google 둜그인',
180
- onClick: () => auth.signIn(),
181
- });
182
- document.body.appendChild(btn);
183
- ```
207
+ const auth = new IsaAuth({ provider: 'jwt' });
208
+
209
+ // Instant wildcard check
210
+ auth.can('users:read'); // true if user has 'users:*' or '*'
211
+ auth.is('ADMIN'); // role check
184
212
 
185
- ### React
186
- ```tsx
187
- import { renderers } from 'isa-auth';
213
+ // Navigation Guard for React Router / Vue Router
214
+ const navGuard = auth.createNavigationGuard({
215
+ requireAuth: true,
216
+ roles: ['ADMIN'],
217
+ roleHierarchy: {
218
+ SUPERUSER: ['ADMIN', 'MANAGER'],
219
+ ADMIN: ['USER'],
220
+ },
221
+ permissions: ['reports:read'],
222
+ redirectToOnUnauthenticated: '/login',
223
+ redirectToOnUnauthorized: '/403',
224
+ onRedirect: (path) => router.push(path),
225
+ });
188
226
 
189
- export function LoginButton() {
190
- return renderers.renderByReact({
191
- label: 'Sign In',
192
- onClick: () => auth.signIn(),
193
- });
227
+ // Use inside router beforeEach hook
228
+ const result = await navGuard();
229
+ if (!result.allowed) {
230
+ console.warn('Denied reason:', result.reason);
194
231
  }
195
232
  ```
196
233
 
197
- ### Web Component
198
- ```html
199
- <script type="module">
200
- import { renderers } from 'isa-auth';
201
- renderers.registerWebComponent();
202
- </script>
234
+ ---
235
+
236
+ ### 6. πŸ”Œ Backend Token Exchange Adapter
203
237
 
204
- <isa-auth-button label="Sign In with ISA"></isa-auth-button>
238
+ Standardized bridge for exchanging OAuth authorization codes, World ID proofs, and Passkey assertions with your backend API:
239
+
240
+ ```typescript
241
+ import { IsaAuth } from 'isa-auth';
242
+
243
+ const auth = new IsaAuth({ provider: 'github' });
244
+ const exchange = auth.createTokenExchange('/api/auth/token-exchange');
245
+
246
+ // 1. Exchange OAuth code for backend JWT
247
+ const tokenRes = await exchange.exchangeOAuthCode('github', 'oauth_code_123');
248
+ auth.setAccessToken(tokenRes.accessToken);
249
+
250
+ // 2. Exchange World ID ZK-Proof for backend session
251
+ const worldRes = await exchange.exchangeWorldProof(worldProof);
252
+ auth.setAccessToken(worldRes.accessToken);
205
253
  ```
206
254
 
207
255
  ---
208
256
 
209
- ## πŸ§ͺ Testing the Playground
257
+ ### 7. πŸ›‘οΈ Storage Modes: Security-First Defaults
210
258
 
211
- Run the interactive local demo to experiment with all features:
259
+ By default, `isa-auth` uses **`'memory'`** storage to ensure sensitive tokens are never exposed to XSS attacks via browser localStorage:
212
260
 
213
- ```bash
214
- # Build packages
215
- yarn build
261
+ ```typescript
262
+ // 1. [PRODUCTION DEFAULT] Zero XSS In-Memory Storage
263
+ const secureAuth = new IsaAuth({
264
+ provider: 'jwt',
265
+ storage: 'memory', // Default! (No tokens in localStorage)
266
+ });
267
+
268
+ // 2. [PRODUCTION RECOMMENDED] HttpOnly Cookie / BFF Mode
269
+ const cookieAuth = new IsaAuth({
270
+ provider: 'base',
271
+ storage: 'cookie', // CookieSessionStorageAdapter (BFF architecture)
272
+ });
216
273
 
217
- # Start interactive playground
218
- yarn demo
219
- # Visit http://localhost:3000 in your browser
274
+ // 3. [LOCAL DEV ONLY] Insecure LocalStorage for F5 Refresh Convenience
275
+ const devAuth = new IsaAuth({
276
+ provider: 'google',
277
+ clientId: 'dev-client-id',
278
+ storage: 'dev_insecure_localStorage', // Explicitly warns in console that this is NOT for production!
279
+ });
220
280
  ```
221
281
 
222
282
  ---
223
283
 
224
- ## πŸ“ Repository Structure
284
+ ## πŸ€– Bundled Agent Skill
225
285
 
226
- ```
227
- isa-auth/
228
- β”œβ”€β”€ packages/
229
- β”‚ β”œβ”€β”€ core/ # @isa-auth/core: JWT, Store, Providers, Guards, HTTP Interceptor
230
- β”‚ β”œβ”€β”€ isa-auth/ # isa-auth: Unified Facade, Multi-Framework Renderers
231
- β”‚ └── demo/ # Interactive Web Playground
232
- β”œβ”€β”€ package.json # Workspace Monorepo
233
- └── README.md
234
- ```
286
+ This package comes pre-packaged with an AI Agent Skill under:
287
+ - `skills/isa-auth-guide/SKILL.md`
288
+ - `.agents/skills/isa-auth-guide/SKILL.md`
289
+
290
+ Supported AI coding agents (Antigravity, Cursor, Windsurf, Claude Code) automatically discover and use this skill for code generation and configuration guidance.
235
291
 
236
292
  ---
237
293