isa-auth 0.0.0-stage → 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.
package/package.json CHANGED
@@ -1,6 +1,76 @@
1
1
  {
2
2
  "name": "isa-auth",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
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
+ "keywords": [
6
+ "auth",
7
+ "authentication",
8
+ "oauth",
9
+ "oauth2",
10
+ "google-auth",
11
+ "apple-auth",
12
+ "meta-auth",
13
+ "kakao-auth",
14
+ "naver-auth",
15
+ "line-auth",
16
+ "github-auth",
17
+ "discord-auth",
18
+ "web3",
19
+ "siwe",
20
+ "world-id",
21
+ "worldcoin",
22
+ "passkey",
23
+ "webauthn",
24
+ "fido2",
25
+ "jwt",
26
+ "rbac",
27
+ "headless",
28
+ "react",
29
+ "vue",
30
+ "svelte",
31
+ "skills",
32
+ "agent-skill"
33
+ ],
34
+ "author": "Isa <yunjonglyu@gmail.com> (yunjongryu)",
35
+ "homepage": "https://github.com/yoonjonglyu/isa-auth#readme",
36
+ "license": "MIT",
37
+ "main": "./dist/index.js",
38
+ "module": "./dist/index.mjs",
39
+ "types": "./dist/index.d.ts",
40
+ "exports": {
41
+ ".": {
42
+ "types": "./dist/index.d.ts",
43
+ "import": "./dist/index.mjs",
44
+ "require": "./dist/index.js"
45
+ },
46
+ "./package.json": "./package.json"
47
+ },
48
+ "files": [
49
+ "dist",
50
+ "skills",
51
+ ".agents",
52
+ "README.md",
53
+ "LICENSE"
54
+ ],
55
+ "repository": {
56
+ "type": "git",
57
+ "url": "git+https://github.com/yoonjonglyu/isa-auth.git"
58
+ },
59
+ "scripts": {
60
+ "build": "tsup",
61
+ "dev": "tsup --watch"
62
+ },
63
+ "bugs": {
64
+ "url": "https://github.com/yoonjonglyu/isa-auth/issues"
65
+ },
66
+ "dependencies": {
67
+ "isa-util": "^1.1.1"
68
+ },
69
+ "devDependencies": {
70
+ "@swc/cli": "^0.7.7",
71
+ "@swc/core": "^1.11.29",
72
+ "rimraf": "^6.0.1",
73
+ "tsup": "^8.5.1",
74
+ "typescript": "^5.8.3"
75
+ }
76
+ }
@@ -0,0 +1,167 @@
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: Storage Security & Development Modes
131
+ ```typescript
132
+ import { IsaAuth } from 'isa-auth';
133
+
134
+ // 1. [PRODUCTION DEFAULT] Zero XSS In-Memory Storage (Recommended for SPA)
135
+ const secureAuth = new IsaAuth({
136
+ provider: 'jwt',
137
+ storage: 'memory', // Default! Tokens never touch localStorage.
138
+ });
139
+
140
+ // 2. [PRODUCTION RECOMMENDED] HttpOnly Cookie / BFF Architecture
141
+ const cookieAuth = new IsaAuth({
142
+ provider: 'base',
143
+ storage: 'cookie', // CookieSessionStorageAdapter omits client JWT persistence
144
+ });
145
+
146
+ // 3. [LOCAL DEV ONLY] Insecure LocalStorage for F5 Refresh Convenience
147
+ const devAuth = new IsaAuth({
148
+ provider: 'google',
149
+ clientId: 'dev-client-id',
150
+ storage: 'dev_insecure_localStorage', // Explicitly warns in console that this is NOT for production!
151
+ });
152
+ ```
153
+
154
+ ---
155
+
156
+ ## 🛠️ 3. Monorepo Build & Test Commands
157
+
158
+ ```bash
159
+ # 1. Full Monorepo Build (SWC core compilation + tsup inline bundling)
160
+ yarn build # On Windows: yarn.cmd build
161
+
162
+ # 2. Run Comprehensive Test Suite (22 automated test cases)
163
+ node scratch/test_enhanced_features.js
164
+
165
+ # 3. Launch Local Demo Playground
166
+ yarn demo # Serves http://localhost:3000
167
+ ```