@authon/js 0.4.0 → 0.4.2
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/README.ko.md +1 -4
- package/README.md +7 -14
- package/dist/index.cjs +71 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +71 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.ko.md
CHANGED
|
@@ -23,9 +23,7 @@ npm install @authon/js
|
|
|
23
23
|
<script type="module">
|
|
24
24
|
import { Authon } from '@authon/js';
|
|
25
25
|
|
|
26
|
-
const authon = new Authon('pk_live_YOUR_PUBLISHABLE_KEY'
|
|
27
|
-
apiUrl: 'https://your-authon-server.com',
|
|
28
|
-
});
|
|
26
|
+
const authon = new Authon('pk_live_YOUR_PUBLISHABLE_KEY');
|
|
29
27
|
|
|
30
28
|
document.getElementById('sign-in-btn').addEventListener('click', () => {
|
|
31
29
|
authon.openSignIn();
|
|
@@ -80,7 +78,6 @@ await authon.signOut();
|
|
|
80
78
|
|
|
81
79
|
| 변수 | 필수 | 설명 |
|
|
82
80
|
|------|------|------|
|
|
83
|
-
| `AUTHON_API_URL` | Yes | Authon 서버 URL |
|
|
84
81
|
| `AUTHON_PUBLISHABLE_KEY` | Yes | 프로젝트 퍼블리셔블 키 |
|
|
85
82
|
|
|
86
83
|
## 비교
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# @authon/js
|
|
4
4
|
|
|
5
|
-
> Drop-in browser authentication SDK —
|
|
5
|
+
> Drop-in browser authentication SDK — Auth0 alternative, open-source auth
|
|
6
6
|
|
|
7
7
|
[](https://www.npmjs.com/package/@authon/js)
|
|
8
8
|
[](../../LICENSE)
|
|
@@ -16,8 +16,8 @@ Before installing the SDK, create an Authon project and get your API keys:
|
|
|
16
16
|
- Select the authentication methods you want (Email/Password, OAuth providers, etc.)
|
|
17
17
|
|
|
18
18
|
2. **Get your API keys** from Project Settings → API Keys
|
|
19
|
-
- **Publishable Key** (`pk_live_...`
|
|
20
|
-
- **
|
|
19
|
+
- **Publishable Key** (`pk_live_...`) — use in your frontend code
|
|
20
|
+
- **Test Key** (`pk_test_...`) — for development, enables Dev Teleport
|
|
21
21
|
|
|
22
22
|
3. **Configure OAuth providers** (optional) in Project Settings → OAuth
|
|
23
23
|
- Add Google, Apple, GitHub, etc. with their respective Client ID and Secret
|
|
@@ -45,9 +45,7 @@ npm install @authon/js
|
|
|
45
45
|
<script type="module">
|
|
46
46
|
import { Authon } from '@authon/js';
|
|
47
47
|
|
|
48
|
-
const authon = new Authon('pk_live_YOUR_PUBLISHABLE_KEY'
|
|
49
|
-
apiUrl: 'https://your-authon-server.com',
|
|
50
|
-
});
|
|
48
|
+
const authon = new Authon('pk_live_YOUR_PUBLISHABLE_KEY');
|
|
51
49
|
|
|
52
50
|
document.getElementById('sign-in-btn').addEventListener('click', () => {
|
|
53
51
|
authon.openSignIn();
|
|
@@ -69,9 +67,7 @@ npm install @authon/js
|
|
|
69
67
|
```ts
|
|
70
68
|
import { Authon } from '@authon/js';
|
|
71
69
|
|
|
72
|
-
const authon = new Authon('pk_live_YOUR_PUBLISHABLE_KEY'
|
|
73
|
-
apiUrl: 'https://your-authon-server.com',
|
|
74
|
-
});
|
|
70
|
+
const authon = new Authon('pk_live_YOUR_PUBLISHABLE_KEY');
|
|
75
71
|
|
|
76
72
|
// Opens popup, falls back to redirect if blocked
|
|
77
73
|
await authon.signInWithOAuth('google');
|
|
@@ -88,9 +84,7 @@ await authon.signInWithOAuth('google', { flowMode: 'redirect' });
|
|
|
88
84
|
```ts
|
|
89
85
|
import { Authon } from '@authon/js';
|
|
90
86
|
|
|
91
|
-
const authon = new Authon('pk_live_YOUR_PUBLISHABLE_KEY'
|
|
92
|
-
apiUrl: 'https://your-authon-server.com',
|
|
93
|
-
});
|
|
87
|
+
const authon = new Authon('pk_live_YOUR_PUBLISHABLE_KEY');
|
|
94
88
|
|
|
95
89
|
// Sign up
|
|
96
90
|
const user = await authon.signUpWithEmail('user@example.com', 'MyP@ssw0rd', {
|
|
@@ -181,8 +175,8 @@ authon.on('tokenRefreshed', (token) => { /* update API client */ });
|
|
|
181
175
|
|
|
182
176
|
| Variable | Required | Description |
|
|
183
177
|
|----------|----------|-------------|
|
|
184
|
-
| `AUTHON_API_URL` | Yes | Your Authon server URL (e.g. `https://your-authon-server.com`) |
|
|
185
178
|
| `AUTHON_PUBLISHABLE_KEY` | Yes | Project publishable key (`pk_live_...` or `pk_test_...`) |
|
|
179
|
+
| `AUTHON_API_URL` | No | Optional — defaults to `api.authon.dev` |
|
|
186
180
|
|
|
187
181
|
## API Reference
|
|
188
182
|
|
|
@@ -280,7 +274,6 @@ new Authon(publishableKey: string, config?: AuthonConfig)
|
|
|
280
274
|
|
|
281
275
|
| Feature | Authon | Clerk | Auth.js |
|
|
282
276
|
|---------|--------|-------|---------|
|
|
283
|
-
| Self-hosted | Yes | No | Partial |
|
|
284
277
|
| Pricing | Free | $25/mo+ | Free |
|
|
285
278
|
| OAuth providers | 10+ | 20+ | 80+ |
|
|
286
279
|
| ShadowDOM modal | Yes | No | No |
|
package/dist/index.cjs
CHANGED
|
@@ -155,11 +155,16 @@ var ModalRenderer = class {
|
|
|
155
155
|
turnstileWidgetId = null;
|
|
156
156
|
turnstileToken = "";
|
|
157
157
|
turnstileWrapper = null;
|
|
158
|
+
// Dev Teleport (test mode)
|
|
159
|
+
isTestMode = false;
|
|
160
|
+
onDevTeleport = null;
|
|
158
161
|
constructor(options) {
|
|
159
162
|
this.mode = options.mode;
|
|
160
163
|
this.theme = options.theme || "auto";
|
|
161
164
|
this.branding = { ...DEFAULT_BRANDING, ...options.branding };
|
|
162
165
|
this.captchaSiteKey = options.captchaSiteKey || "";
|
|
166
|
+
this.isTestMode = options.isTestMode || false;
|
|
167
|
+
this.onDevTeleport = options.onDevTeleport || null;
|
|
163
168
|
this.onProviderClick = options.onProviderClick;
|
|
164
169
|
this.onEmailSubmit = options.onEmailSubmit;
|
|
165
170
|
this.onClose = options.onClose;
|
|
@@ -445,7 +450,8 @@ var ModalRenderer = class {
|
|
|
445
450
|
<span>${config.label}</span>
|
|
446
451
|
</button>`;
|
|
447
452
|
}).join("") : "";
|
|
448
|
-
const
|
|
453
|
+
const hasVisibleProviders = showProviders && this.enabledProviders.filter((p) => !b.hiddenProviders?.includes(p)).length > 0;
|
|
454
|
+
const divider = hasVisibleProviders && b.showDivider !== false && b.showEmailPassword !== false ? `<div class="divider"><span>or</span></div>` : "";
|
|
449
455
|
const emailForm = b.showEmailPassword !== false ? `<form class="email-form" id="email-form">
|
|
450
456
|
<input type="email" placeholder="Email address" name="email" required class="input" autocomplete="email" />
|
|
451
457
|
<input type="password" placeholder="Password" name="password" required class="input" autocomplete="${isSignUp ? "new-password" : "current-password"}" />
|
|
@@ -503,6 +509,16 @@ var ModalRenderer = class {
|
|
|
503
509
|
${authMethods}
|
|
504
510
|
<p class="switch-view">${subtitle} <a href="#" id="switch-link">${subtitleLink}</a></p>
|
|
505
511
|
${footer}
|
|
512
|
+
${this.isTestMode ? `<div class="dev-teleport">
|
|
513
|
+
<div class="dev-teleport-label">
|
|
514
|
+
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M13 2L3 14h9l-1 8 10-12h-9l1-8z"/></svg>
|
|
515
|
+
Dev Teleport
|
|
516
|
+
</div>
|
|
517
|
+
<div class="dev-teleport-row">
|
|
518
|
+
<input type="email" placeholder="test@example.com" id="dev-teleport-email" class="dev-teleport-input" value="dev@test.com" />
|
|
519
|
+
<button type="button" id="dev-teleport-btn" class="dev-teleport-btn">Go</button>
|
|
520
|
+
</div>
|
|
521
|
+
</div>` : ""}
|
|
506
522
|
${b.showSecuredBy !== false ? `<div class="secured-by">Secured by <a href="https://authon.dev" target="_blank" rel="noopener noreferrer" class="secured-link">Authon</a></div>` : ""}
|
|
507
523
|
`;
|
|
508
524
|
}
|
|
@@ -679,6 +695,34 @@ var ModalRenderer = class {
|
|
|
679
695
|
.secured-link { font-weight: 600; color: var(--authon-muted); text-decoration: none; }
|
|
680
696
|
.secured-link:hover { text-decoration: underline; }
|
|
681
697
|
|
|
698
|
+
/* Dev Teleport */
|
|
699
|
+
.dev-teleport {
|
|
700
|
+
margin-top: 12px; padding: 10px;
|
|
701
|
+
border-radius: calc(var(--authon-radius) * 0.5);
|
|
702
|
+
background: rgba(251,191,36,0.06);
|
|
703
|
+
border: 1px dashed rgba(251,191,36,0.25);
|
|
704
|
+
}
|
|
705
|
+
.dev-teleport-label {
|
|
706
|
+
display: flex; align-items: center; gap: 4px;
|
|
707
|
+
font-size: 10px; font-weight: 600; color: #fbbf24;
|
|
708
|
+
margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.05em;
|
|
709
|
+
}
|
|
710
|
+
.dev-teleport-row { display: flex; gap: 6px; }
|
|
711
|
+
.dev-teleport-input {
|
|
712
|
+
flex: 1; padding: 6px 10px; font-size: 12px;
|
|
713
|
+
border-radius: calc(var(--authon-radius) * 0.4);
|
|
714
|
+
background: rgba(0,0,0,0.2); border: 1px solid rgba(251,191,36,0.2);
|
|
715
|
+
color: #fbbf24; outline: none; font-family: ui-monospace, monospace;
|
|
716
|
+
}
|
|
717
|
+
.dev-teleport-input:focus { border-color: rgba(251,191,36,0.5); }
|
|
718
|
+
.dev-teleport-btn {
|
|
719
|
+
padding: 6px 14px; font-size: 11px; font-weight: 700;
|
|
720
|
+
border-radius: calc(var(--authon-radius) * 0.4);
|
|
721
|
+
background: rgba(251,191,36,0.15); border: 1px solid rgba(251,191,36,0.3);
|
|
722
|
+
color: #fbbf24; cursor: pointer;
|
|
723
|
+
}
|
|
724
|
+
.dev-teleport-btn:hover { background: rgba(251,191,36,0.25); }
|
|
725
|
+
|
|
682
726
|
/* Auth method buttons */
|
|
683
727
|
.auth-methods { display: flex; flex-direction: column; gap: 8px; }
|
|
684
728
|
.auth-method-btn {
|
|
@@ -1124,6 +1168,21 @@ var ModalRenderer = class {
|
|
|
1124
1168
|
});
|
|
1125
1169
|
}
|
|
1126
1170
|
this.renderTurnstile();
|
|
1171
|
+
const devTeleportBtn = this.shadowRoot.getElementById("dev-teleport-btn");
|
|
1172
|
+
const devTeleportEmail = this.shadowRoot.getElementById("dev-teleport-email");
|
|
1173
|
+
if (devTeleportBtn && devTeleportEmail && this.onDevTeleport) {
|
|
1174
|
+
const handler = this.onDevTeleport;
|
|
1175
|
+
devTeleportBtn.addEventListener("click", () => {
|
|
1176
|
+
const email = devTeleportEmail.value.trim();
|
|
1177
|
+
if (email) handler(email);
|
|
1178
|
+
});
|
|
1179
|
+
devTeleportEmail.addEventListener("keydown", (e) => {
|
|
1180
|
+
if (e.key === "Enter") {
|
|
1181
|
+
const email = devTeleportEmail.value.trim();
|
|
1182
|
+
if (email) handler(email);
|
|
1183
|
+
}
|
|
1184
|
+
});
|
|
1185
|
+
}
|
|
1127
1186
|
const backBtn = this.shadowRoot.getElementById("back-btn");
|
|
1128
1187
|
if (backBtn) {
|
|
1129
1188
|
backBtn.addEventListener("click", () => {
|
|
@@ -2078,6 +2137,17 @@ var Authon = class {
|
|
|
2078
2137
|
containerId: this.config.containerId,
|
|
2079
2138
|
branding: this.branding || void 0,
|
|
2080
2139
|
captchaSiteKey: this.captchaEnabled ? this.turnstileSiteKey : void 0,
|
|
2140
|
+
isTestMode: this.publishableKey.startsWith("pk_test_"),
|
|
2141
|
+
onDevTeleport: this.publishableKey.startsWith("pk_test_") ? async (email) => {
|
|
2142
|
+
this.modal?.clearError();
|
|
2143
|
+
try {
|
|
2144
|
+
await this.testing.signIn({ email });
|
|
2145
|
+
this.modal?.close();
|
|
2146
|
+
} catch (err) {
|
|
2147
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
2148
|
+
this.modal?.showError(msg || "Dev teleport failed");
|
|
2149
|
+
}
|
|
2150
|
+
} : void 0,
|
|
2081
2151
|
onProviderClick: (provider) => this.startOAuthFlow(provider),
|
|
2082
2152
|
onEmailSubmit: (email, password, isSignUp) => {
|
|
2083
2153
|
this.modal?.clearError();
|