@authon/js 0.4.0 → 0.4.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/dist/index.cjs +69 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +69 -0
- 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;
|
|
@@ -474,6 +479,16 @@ var ModalRenderer = class {
|
|
|
474
479
|
${authMethods}
|
|
475
480
|
<p class="switch-view">${subtitle} <a href="#" id="switch-link">${subtitleLink}</a></p>
|
|
476
481
|
${footer}
|
|
482
|
+
${this.isTestMode ? `<div class="dev-teleport">
|
|
483
|
+
<div class="dev-teleport-label">
|
|
484
|
+
<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>
|
|
485
|
+
Dev Teleport
|
|
486
|
+
</div>
|
|
487
|
+
<div class="dev-teleport-row">
|
|
488
|
+
<input type="email" placeholder="test@example.com" id="dev-teleport-email" class="dev-teleport-input" value="dev@test.com" />
|
|
489
|
+
<button type="button" id="dev-teleport-btn" class="dev-teleport-btn">Go</button>
|
|
490
|
+
</div>
|
|
491
|
+
</div>` : ""}
|
|
477
492
|
${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
493
|
`;
|
|
479
494
|
}
|
|
@@ -650,6 +665,34 @@ var ModalRenderer = class {
|
|
|
650
665
|
.secured-link { font-weight: 600; color: var(--authon-muted); text-decoration: none; }
|
|
651
666
|
.secured-link:hover { text-decoration: underline; }
|
|
652
667
|
|
|
668
|
+
/* Dev Teleport */
|
|
669
|
+
.dev-teleport {
|
|
670
|
+
margin-top: 12px; padding: 10px;
|
|
671
|
+
border-radius: calc(var(--authon-radius) * 0.5);
|
|
672
|
+
background: rgba(251,191,36,0.06);
|
|
673
|
+
border: 1px dashed rgba(251,191,36,0.25);
|
|
674
|
+
}
|
|
675
|
+
.dev-teleport-label {
|
|
676
|
+
display: flex; align-items: center; gap: 4px;
|
|
677
|
+
font-size: 10px; font-weight: 600; color: #fbbf24;
|
|
678
|
+
margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.05em;
|
|
679
|
+
}
|
|
680
|
+
.dev-teleport-row { display: flex; gap: 6px; }
|
|
681
|
+
.dev-teleport-input {
|
|
682
|
+
flex: 1; padding: 6px 10px; font-size: 12px;
|
|
683
|
+
border-radius: calc(var(--authon-radius) * 0.4);
|
|
684
|
+
background: rgba(0,0,0,0.2); border: 1px solid rgba(251,191,36,0.2);
|
|
685
|
+
color: #fbbf24; outline: none; font-family: ui-monospace, monospace;
|
|
686
|
+
}
|
|
687
|
+
.dev-teleport-input:focus { border-color: rgba(251,191,36,0.5); }
|
|
688
|
+
.dev-teleport-btn {
|
|
689
|
+
padding: 6px 14px; font-size: 11px; font-weight: 700;
|
|
690
|
+
border-radius: calc(var(--authon-radius) * 0.4);
|
|
691
|
+
background: rgba(251,191,36,0.15); border: 1px solid rgba(251,191,36,0.3);
|
|
692
|
+
color: #fbbf24; cursor: pointer;
|
|
693
|
+
}
|
|
694
|
+
.dev-teleport-btn:hover { background: rgba(251,191,36,0.25); }
|
|
695
|
+
|
|
653
696
|
/* Auth method buttons */
|
|
654
697
|
.auth-methods { display: flex; flex-direction: column; gap: 8px; }
|
|
655
698
|
.auth-method-btn {
|
|
@@ -1095,6 +1138,21 @@ var ModalRenderer = class {
|
|
|
1095
1138
|
});
|
|
1096
1139
|
}
|
|
1097
1140
|
this.renderTurnstile();
|
|
1141
|
+
const devTeleportBtn = this.shadowRoot.getElementById("dev-teleport-btn");
|
|
1142
|
+
const devTeleportEmail = this.shadowRoot.getElementById("dev-teleport-email");
|
|
1143
|
+
if (devTeleportBtn && devTeleportEmail && this.onDevTeleport) {
|
|
1144
|
+
const handler = this.onDevTeleport;
|
|
1145
|
+
devTeleportBtn.addEventListener("click", () => {
|
|
1146
|
+
const email = devTeleportEmail.value.trim();
|
|
1147
|
+
if (email) handler(email);
|
|
1148
|
+
});
|
|
1149
|
+
devTeleportEmail.addEventListener("keydown", (e) => {
|
|
1150
|
+
if (e.key === "Enter") {
|
|
1151
|
+
const email = devTeleportEmail.value.trim();
|
|
1152
|
+
if (email) handler(email);
|
|
1153
|
+
}
|
|
1154
|
+
});
|
|
1155
|
+
}
|
|
1098
1156
|
const backBtn = this.shadowRoot.getElementById("back-btn");
|
|
1099
1157
|
if (backBtn) {
|
|
1100
1158
|
backBtn.addEventListener("click", () => {
|
|
@@ -2049,6 +2107,17 @@ var Authon = class {
|
|
|
2049
2107
|
containerId: this.config.containerId,
|
|
2050
2108
|
branding: this.branding || void 0,
|
|
2051
2109
|
captchaSiteKey: this.captchaEnabled ? this.turnstileSiteKey : void 0,
|
|
2110
|
+
isTestMode: this.publishableKey.startsWith("pk_test_"),
|
|
2111
|
+
onDevTeleport: this.publishableKey.startsWith("pk_test_") ? async (email) => {
|
|
2112
|
+
this.modal?.clearError();
|
|
2113
|
+
try {
|
|
2114
|
+
await this.testing.signIn({ email });
|
|
2115
|
+
this.modal?.close();
|
|
2116
|
+
} catch (err) {
|
|
2117
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
2118
|
+
this.modal?.showError(msg || "Dev teleport failed");
|
|
2119
|
+
}
|
|
2120
|
+
} : void 0,
|
|
2052
2121
|
onProviderClick: (provider) => this.startOAuthFlow(provider),
|
|
2053
2122
|
onEmailSubmit: (email, password, isSignUp) => {
|
|
2054
2123
|
this.modal?.clearError();
|