@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/dist/index.js
CHANGED
|
@@ -126,11 +126,16 @@ var ModalRenderer = class {
|
|
|
126
126
|
turnstileWidgetId = null;
|
|
127
127
|
turnstileToken = "";
|
|
128
128
|
turnstileWrapper = null;
|
|
129
|
+
// Dev Teleport (test mode)
|
|
130
|
+
isTestMode = false;
|
|
131
|
+
onDevTeleport = null;
|
|
129
132
|
constructor(options) {
|
|
130
133
|
this.mode = options.mode;
|
|
131
134
|
this.theme = options.theme || "auto";
|
|
132
135
|
this.branding = { ...DEFAULT_BRANDING, ...options.branding };
|
|
133
136
|
this.captchaSiteKey = options.captchaSiteKey || "";
|
|
137
|
+
this.isTestMode = options.isTestMode || false;
|
|
138
|
+
this.onDevTeleport = options.onDevTeleport || null;
|
|
134
139
|
this.onProviderClick = options.onProviderClick;
|
|
135
140
|
this.onEmailSubmit = options.onEmailSubmit;
|
|
136
141
|
this.onClose = options.onClose;
|
|
@@ -416,7 +421,8 @@ var ModalRenderer = class {
|
|
|
416
421
|
<span>${config.label}</span>
|
|
417
422
|
</button>`;
|
|
418
423
|
}).join("") : "";
|
|
419
|
-
const
|
|
424
|
+
const hasVisibleProviders = showProviders && this.enabledProviders.filter((p) => !b.hiddenProviders?.includes(p)).length > 0;
|
|
425
|
+
const divider = hasVisibleProviders && b.showDivider !== false && b.showEmailPassword !== false ? `<div class="divider"><span>or</span></div>` : "";
|
|
420
426
|
const emailForm = b.showEmailPassword !== false ? `<form class="email-form" id="email-form">
|
|
421
427
|
<input type="email" placeholder="Email address" name="email" required class="input" autocomplete="email" />
|
|
422
428
|
<input type="password" placeholder="Password" name="password" required class="input" autocomplete="${isSignUp ? "new-password" : "current-password"}" />
|
|
@@ -474,6 +480,16 @@ var ModalRenderer = class {
|
|
|
474
480
|
${authMethods}
|
|
475
481
|
<p class="switch-view">${subtitle} <a href="#" id="switch-link">${subtitleLink}</a></p>
|
|
476
482
|
${footer}
|
|
483
|
+
${this.isTestMode ? `<div class="dev-teleport">
|
|
484
|
+
<div class="dev-teleport-label">
|
|
485
|
+
<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>
|
|
486
|
+
Dev Teleport
|
|
487
|
+
</div>
|
|
488
|
+
<div class="dev-teleport-row">
|
|
489
|
+
<input type="email" placeholder="test@example.com" id="dev-teleport-email" class="dev-teleport-input" value="dev@test.com" />
|
|
490
|
+
<button type="button" id="dev-teleport-btn" class="dev-teleport-btn">Go</button>
|
|
491
|
+
</div>
|
|
492
|
+
</div>` : ""}
|
|
477
493
|
${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>` : ""}
|
|
478
494
|
`;
|
|
479
495
|
}
|
|
@@ -650,6 +666,34 @@ var ModalRenderer = class {
|
|
|
650
666
|
.secured-link { font-weight: 600; color: var(--authon-muted); text-decoration: none; }
|
|
651
667
|
.secured-link:hover { text-decoration: underline; }
|
|
652
668
|
|
|
669
|
+
/* Dev Teleport */
|
|
670
|
+
.dev-teleport {
|
|
671
|
+
margin-top: 12px; padding: 10px;
|
|
672
|
+
border-radius: calc(var(--authon-radius) * 0.5);
|
|
673
|
+
background: rgba(251,191,36,0.06);
|
|
674
|
+
border: 1px dashed rgba(251,191,36,0.25);
|
|
675
|
+
}
|
|
676
|
+
.dev-teleport-label {
|
|
677
|
+
display: flex; align-items: center; gap: 4px;
|
|
678
|
+
font-size: 10px; font-weight: 600; color: #fbbf24;
|
|
679
|
+
margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.05em;
|
|
680
|
+
}
|
|
681
|
+
.dev-teleport-row { display: flex; gap: 6px; }
|
|
682
|
+
.dev-teleport-input {
|
|
683
|
+
flex: 1; padding: 6px 10px; font-size: 12px;
|
|
684
|
+
border-radius: calc(var(--authon-radius) * 0.4);
|
|
685
|
+
background: rgba(0,0,0,0.2); border: 1px solid rgba(251,191,36,0.2);
|
|
686
|
+
color: #fbbf24; outline: none; font-family: ui-monospace, monospace;
|
|
687
|
+
}
|
|
688
|
+
.dev-teleport-input:focus { border-color: rgba(251,191,36,0.5); }
|
|
689
|
+
.dev-teleport-btn {
|
|
690
|
+
padding: 6px 14px; font-size: 11px; font-weight: 700;
|
|
691
|
+
border-radius: calc(var(--authon-radius) * 0.4);
|
|
692
|
+
background: rgba(251,191,36,0.15); border: 1px solid rgba(251,191,36,0.3);
|
|
693
|
+
color: #fbbf24; cursor: pointer;
|
|
694
|
+
}
|
|
695
|
+
.dev-teleport-btn:hover { background: rgba(251,191,36,0.25); }
|
|
696
|
+
|
|
653
697
|
/* Auth method buttons */
|
|
654
698
|
.auth-methods { display: flex; flex-direction: column; gap: 8px; }
|
|
655
699
|
.auth-method-btn {
|
|
@@ -1095,6 +1139,21 @@ var ModalRenderer = class {
|
|
|
1095
1139
|
});
|
|
1096
1140
|
}
|
|
1097
1141
|
this.renderTurnstile();
|
|
1142
|
+
const devTeleportBtn = this.shadowRoot.getElementById("dev-teleport-btn");
|
|
1143
|
+
const devTeleportEmail = this.shadowRoot.getElementById("dev-teleport-email");
|
|
1144
|
+
if (devTeleportBtn && devTeleportEmail && this.onDevTeleport) {
|
|
1145
|
+
const handler = this.onDevTeleport;
|
|
1146
|
+
devTeleportBtn.addEventListener("click", () => {
|
|
1147
|
+
const email = devTeleportEmail.value.trim();
|
|
1148
|
+
if (email) handler(email);
|
|
1149
|
+
});
|
|
1150
|
+
devTeleportEmail.addEventListener("keydown", (e) => {
|
|
1151
|
+
if (e.key === "Enter") {
|
|
1152
|
+
const email = devTeleportEmail.value.trim();
|
|
1153
|
+
if (email) handler(email);
|
|
1154
|
+
}
|
|
1155
|
+
});
|
|
1156
|
+
}
|
|
1098
1157
|
const backBtn = this.shadowRoot.getElementById("back-btn");
|
|
1099
1158
|
if (backBtn) {
|
|
1100
1159
|
backBtn.addEventListener("click", () => {
|
|
@@ -2049,6 +2108,17 @@ var Authon = class {
|
|
|
2049
2108
|
containerId: this.config.containerId,
|
|
2050
2109
|
branding: this.branding || void 0,
|
|
2051
2110
|
captchaSiteKey: this.captchaEnabled ? this.turnstileSiteKey : void 0,
|
|
2111
|
+
isTestMode: this.publishableKey.startsWith("pk_test_"),
|
|
2112
|
+
onDevTeleport: this.publishableKey.startsWith("pk_test_") ? async (email) => {
|
|
2113
|
+
this.modal?.clearError();
|
|
2114
|
+
try {
|
|
2115
|
+
await this.testing.signIn({ email });
|
|
2116
|
+
this.modal?.close();
|
|
2117
|
+
} catch (err) {
|
|
2118
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
2119
|
+
this.modal?.showError(msg || "Dev teleport failed");
|
|
2120
|
+
}
|
|
2121
|
+
} : void 0,
|
|
2052
2122
|
onProviderClick: (provider) => this.startOAuthFlow(provider),
|
|
2053
2123
|
onEmailSubmit: (email, password, isSignUp) => {
|
|
2054
2124
|
this.modal?.clearError();
|