isa-auth 0.1.0 → 0.2.1

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.
package/package.json CHANGED
@@ -1,23 +1,35 @@
1
1
  {
2
2
  "name": "isa-auth",
3
- "version": "0.1.0",
4
- "description": "Unified, framework-agnostic frontend authentication library supporting OAuth (Google, Kakao, Naver), Web3 (SIWE), JWT, reactive store, and RBAC guards",
3
+ "version": "0.2.1",
4
+ "description": "Unified, framework-agnostic frontend authentication library supporting OAuth (Google, Apple, Meta, Line, Kakao, Naver), Developer (GitHub, Discord), Web3 (SIWE), Identity (World ID Orb, Passkey WebAuthn), reactive store, and RBAC guards with AI Agent skills",
5
5
  "keywords": [
6
6
  "auth",
7
7
  "authentication",
8
8
  "oauth",
9
9
  "oauth2",
10
10
  "google-auth",
11
+ "apple-auth",
12
+ "meta-auth",
11
13
  "kakao-auth",
12
14
  "naver-auth",
15
+ "line-auth",
16
+ "github-auth",
17
+ "discord-auth",
13
18
  "web3",
14
19
  "siwe",
20
+ "world-id",
21
+ "worldcoin",
22
+ "passkey",
23
+ "webauthn",
24
+ "fido2",
15
25
  "jwt",
16
26
  "rbac",
17
27
  "headless",
18
28
  "react",
19
29
  "vue",
20
- "svelte"
30
+ "svelte",
31
+ "skills",
32
+ "agent-skill"
21
33
  ],
22
34
  "author": "Isa <yunjonglyu@gmail.com> (yunjongryu)",
23
35
  "homepage": "https://github.com/yoonjonglyu/isa-auth#readme",
@@ -30,10 +42,15 @@
30
42
  "types": "./dist/index.d.ts",
31
43
  "import": "./dist/index.mjs",
32
44
  "require": "./dist/index.js"
33
- }
45
+ },
46
+ "./package.json": "./package.json"
34
47
  },
35
48
  "files": [
36
- "dist"
49
+ "dist",
50
+ "skills",
51
+ ".agents",
52
+ "README.md",
53
+ "LICENSE"
37
54
  ],
38
55
  "repository": {
39
56
  "type": "git",
@@ -47,7 +64,7 @@
47
64
  "url": "https://github.com/yoonjonglyu/isa-auth/issues"
48
65
  },
49
66
  "dependencies": {
50
- "isa-util": "latest"
67
+ "isa-util": "^1.1.1"
51
68
  },
52
69
  "devDependencies": {
53
70
  "@swc/cli": "^0.7.7",
@@ -0,0 +1,199 @@
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 0: Multi-Provider All-in-One Configuration (Recommended)
29
+ ```typescript
30
+ import { IsaAuth } from 'isa-auth';
31
+
32
+ // 1. Initialize multiple providers simultaneously
33
+ const auth = new IsaAuth({
34
+ storage: 'memory', // Production security default
35
+ providers: {
36
+ google: { clientId: 'GOOGLE_CLIENT_ID', callbackUrl: 'https://myapp.com/callback' },
37
+ kakao: { clientId: 'KAKAO_JAVASCRIPT_KEY', callbackUrl: 'https://myapp.com/callback' },
38
+ apple: { clientId: 'com.myapp.service', callbackUrl: 'https://myapp.com/callback' },
39
+ github: { clientId: 'GITHUB_CLIENT_ID', callbackUrl: 'https://myapp.com/callback' },
40
+ passkey: { rpName: 'My Enterprise App', rpId: 'myapp.com' },
41
+ },
42
+ });
43
+
44
+ // 2. Trigger individual provider login
45
+ await auth.signIn('kakao');
46
+ // or
47
+ await auth.signIn('google');
48
+
49
+ // 3. Render buttons: individual or all at once
50
+ auth.renderButton('github', document.getElementById('gh-slot'));
51
+ auth.renderAllButtons(document.getElementById('social-login-grid'), {
52
+ direction: 'grid', // 'grid' | 'column' | 'row'
53
+ gap: '12px',
54
+ });
55
+
56
+ // 4. Query registered providers
57
+ console.log(auth.getRegisteredProviders()); // ['google', 'kakao', 'apple', 'github', 'passkey']
58
+ ```
59
+
60
+ ### Recipe A: World ID (World Network / Orb Verification)
61
+ ```typescript
62
+ import { IsaAuth } from 'isa-auth';
63
+
64
+ const worldAuth = new IsaAuth({
65
+ provider: 'world',
66
+ clientId: 'app_staging_your_app_id',
67
+ extraOptions: {
68
+ action: 'vote',
69
+ verificationLevel: 'orb', // 'orb' (Biometric iris scan) or 'device'
70
+ signal: 'user_wallet_0x123',
71
+ onSuccess: (proof) => {
72
+ console.log('ZK Proof generated:', proof.nullifier_hash, proof.proof);
73
+ },
74
+ },
75
+ });
76
+
77
+ await worldAuth.signIn();
78
+ const userInfo = await worldAuth.getUserInfo();
79
+ // { id: '0x...', isHuman: true, verificationLevel: 'orb', ... }
80
+ ```
81
+
82
+ ### Recipe B: Passkey (FIDO2 / WebAuthn Biometrics)
83
+ ```typescript
84
+ import { IsaAuth } from 'isa-auth';
85
+
86
+ const passkeyAuth = new IsaAuth({
87
+ provider: 'passkey',
88
+ extraOptions: {
89
+ rpName: 'My Financial App',
90
+ rpId: window.location.hostname,
91
+ userName: 'alice@example.com',
92
+ },
93
+ });
94
+
95
+ // Authenticate via Face ID / Touch ID / Windows Hello
96
+ await passkeyAuth.signIn();
97
+
98
+ // Register new biometric credential
99
+ await passkeyAuth.providerInstance.registerCredential();
100
+ ```
101
+
102
+ ### Recipe C: Axios Interceptor with Automatic 401 Refresh & Queue
103
+ ```typescript
104
+ import axios from 'axios';
105
+ import { IsaAuth } from 'isa-auth';
106
+
107
+ const auth = new IsaAuth({ provider: 'jwt' });
108
+ const apiClient = axios.create({ baseURL: 'https://api.example.com' });
109
+
110
+ // Applies Authorization: Bearer <token> & deduplicated 401 token refresh queue
111
+ auth.applyAxiosInterceptor(apiClient, {
112
+ refreshFn: async () => {
113
+ const res = await axios.post('/api/auth/refresh');
114
+ return res.data.accessToken;
115
+ },
116
+ onUnauthorized: () => {
117
+ window.location.href = '/login';
118
+ },
119
+ });
120
+ ```
121
+
122
+ ### Recipe D: Backend Token Exchange Adapter
123
+ ```typescript
124
+ import { IsaAuth, HttpTokenExchangeAdapter } from 'isa-auth';
125
+
126
+ const auth = new IsaAuth({ provider: 'github' });
127
+ const exchange = auth.createTokenExchange('/api/auth/token-exchange');
128
+
129
+ // 1. Exchange OAuth code for JWT
130
+ const tokenRes = await exchange.exchangeOAuthCode('github', 'auth-code-123');
131
+ auth.setAccessToken(tokenRes.accessToken);
132
+
133
+ // 2. Exchange World ID ZK-proof for session
134
+ const worldRes = await exchange.exchangeWorldProof(worldProofResult);
135
+ auth.setAccessToken(worldRes.accessToken);
136
+ ```
137
+
138
+ ### Recipe E: Wildcard RBAC / ABAC Guards & Router Redirection
139
+ ```typescript
140
+ import { IsaAuth } from 'isa-auth';
141
+
142
+ const auth = new IsaAuth({ provider: 'jwt' });
143
+
144
+ // Instant wildcard permission check
145
+ const canEdit = auth.can('users:edit'); // Matches 'users:*' or '*'
146
+
147
+ // Navigation Guard for React Router / Vue Router
148
+ const guard = auth.createNavigationGuard({
149
+ requireAuth: true,
150
+ roles: ['ADMIN'],
151
+ roleHierarchy: {
152
+ SUPERUSER: ['ADMIN', 'EDITOR'],
153
+ ADMIN: ['USER'],
154
+ },
155
+ permissions: ['reports:*'],
156
+ redirectToOnUnauthenticated: '/login',
157
+ redirectToOnUnauthorized: '/403',
158
+ onRedirect: (path) => router.push(path),
159
+ });
160
+ ```
161
+
162
+ ### Recipe F: Storage Security & Development Modes
163
+ ```typescript
164
+ import { IsaAuth } from 'isa-auth';
165
+
166
+ // 1. [PRODUCTION DEFAULT] Zero XSS In-Memory Storage (Recommended for SPA)
167
+ const secureAuth = new IsaAuth({
168
+ provider: 'jwt',
169
+ storage: 'memory', // Default! Tokens never touch localStorage.
170
+ });
171
+
172
+ // 2. [PRODUCTION RECOMMENDED] HttpOnly Cookie / BFF Architecture
173
+ const cookieAuth = new IsaAuth({
174
+ provider: 'base',
175
+ storage: 'cookie', // CookieSessionStorageAdapter omits client JWT persistence
176
+ });
177
+
178
+ // 3. [LOCAL DEV ONLY] Insecure LocalStorage for F5 Refresh Convenience
179
+ const devAuth = new IsaAuth({
180
+ provider: 'google',
181
+ clientId: 'dev-client-id',
182
+ storage: 'dev_insecure_localStorage', // Explicitly warns in console that this is NOT for production!
183
+ });
184
+ ```
185
+
186
+ ---
187
+
188
+ ## 🛠️ 3. Monorepo Build & Test Commands
189
+
190
+ ```bash
191
+ # 1. Full Monorepo Build (SWC core compilation + tsup inline bundling)
192
+ yarn build # On Windows: yarn.cmd build
193
+
194
+ # 2. Run Comprehensive Test Suite (22 automated test cases)
195
+ node scratch/test_enhanced_features.js
196
+
197
+ # 3. Launch Local Demo Playground
198
+ yarn demo # Serves http://localhost:3000
199
+ ```