@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 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;
@@ -503,6 +508,16 @@ var ModalRenderer = class {
503
508
  ${authMethods}
504
509
  <p class="switch-view">${subtitle} <a href="#" id="switch-link">${subtitleLink}</a></p>
505
510
  ${footer}
511
+ ${this.isTestMode ? `<div class="dev-teleport">
512
+ <div class="dev-teleport-label">
513
+ <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>
514
+ Dev Teleport
515
+ </div>
516
+ <div class="dev-teleport-row">
517
+ <input type="email" placeholder="test@example.com" id="dev-teleport-email" class="dev-teleport-input" value="dev@test.com" />
518
+ <button type="button" id="dev-teleport-btn" class="dev-teleport-btn">Go</button>
519
+ </div>
520
+ </div>` : ""}
506
521
  ${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
522
  `;
508
523
  }
@@ -679,6 +694,34 @@ var ModalRenderer = class {
679
694
  .secured-link { font-weight: 600; color: var(--authon-muted); text-decoration: none; }
680
695
  .secured-link:hover { text-decoration: underline; }
681
696
 
697
+ /* Dev Teleport */
698
+ .dev-teleport {
699
+ margin-top: 12px; padding: 10px;
700
+ border-radius: calc(var(--authon-radius) * 0.5);
701
+ background: rgba(251,191,36,0.06);
702
+ border: 1px dashed rgba(251,191,36,0.25);
703
+ }
704
+ .dev-teleport-label {
705
+ display: flex; align-items: center; gap: 4px;
706
+ font-size: 10px; font-weight: 600; color: #fbbf24;
707
+ margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.05em;
708
+ }
709
+ .dev-teleport-row { display: flex; gap: 6px; }
710
+ .dev-teleport-input {
711
+ flex: 1; padding: 6px 10px; font-size: 12px;
712
+ border-radius: calc(var(--authon-radius) * 0.4);
713
+ background: rgba(0,0,0,0.2); border: 1px solid rgba(251,191,36,0.2);
714
+ color: #fbbf24; outline: none; font-family: ui-monospace, monospace;
715
+ }
716
+ .dev-teleport-input:focus { border-color: rgba(251,191,36,0.5); }
717
+ .dev-teleport-btn {
718
+ padding: 6px 14px; font-size: 11px; font-weight: 700;
719
+ border-radius: calc(var(--authon-radius) * 0.4);
720
+ background: rgba(251,191,36,0.15); border: 1px solid rgba(251,191,36,0.3);
721
+ color: #fbbf24; cursor: pointer;
722
+ }
723
+ .dev-teleport-btn:hover { background: rgba(251,191,36,0.25); }
724
+
682
725
  /* Auth method buttons */
683
726
  .auth-methods { display: flex; flex-direction: column; gap: 8px; }
684
727
  .auth-method-btn {
@@ -1124,6 +1167,21 @@ var ModalRenderer = class {
1124
1167
  });
1125
1168
  }
1126
1169
  this.renderTurnstile();
1170
+ const devTeleportBtn = this.shadowRoot.getElementById("dev-teleport-btn");
1171
+ const devTeleportEmail = this.shadowRoot.getElementById("dev-teleport-email");
1172
+ if (devTeleportBtn && devTeleportEmail && this.onDevTeleport) {
1173
+ const handler = this.onDevTeleport;
1174
+ devTeleportBtn.addEventListener("click", () => {
1175
+ const email = devTeleportEmail.value.trim();
1176
+ if (email) handler(email);
1177
+ });
1178
+ devTeleportEmail.addEventListener("keydown", (e) => {
1179
+ if (e.key === "Enter") {
1180
+ const email = devTeleportEmail.value.trim();
1181
+ if (email) handler(email);
1182
+ }
1183
+ });
1184
+ }
1127
1185
  const backBtn = this.shadowRoot.getElementById("back-btn");
1128
1186
  if (backBtn) {
1129
1187
  backBtn.addEventListener("click", () => {
@@ -2078,6 +2136,17 @@ var Authon = class {
2078
2136
  containerId: this.config.containerId,
2079
2137
  branding: this.branding || void 0,
2080
2138
  captchaSiteKey: this.captchaEnabled ? this.turnstileSiteKey : void 0,
2139
+ isTestMode: this.publishableKey.startsWith("pk_test_"),
2140
+ onDevTeleport: this.publishableKey.startsWith("pk_test_") ? async (email) => {
2141
+ this.modal?.clearError();
2142
+ try {
2143
+ await this.testing.signIn({ email });
2144
+ this.modal?.close();
2145
+ } catch (err) {
2146
+ const msg = err instanceof Error ? err.message : String(err);
2147
+ this.modal?.showError(msg || "Dev teleport failed");
2148
+ }
2149
+ } : void 0,
2081
2150
  onProviderClick: (provider) => this.startOAuthFlow(provider),
2082
2151
  onEmailSubmit: (email, password, isSignUp) => {
2083
2152
  this.modal?.clearError();