@mrgnw/anahtar 0.0.15 → 0.0.17

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.
@@ -204,22 +204,27 @@ function handlePasskeySkip() {
204
204
  }}
205
205
  class="anahtar-auth-form"
206
206
  >
207
- <input
208
- type="email"
209
- bind:value={email}
210
- required
211
- autocomplete="username webauthn"
212
- placeholder={m.emailPlaceholder}
213
- class="anahtar-input"
214
- />
207
+ <div class="anahtar-input-row">
208
+ <input
209
+ type="email"
210
+ bind:value={email}
211
+ required
212
+ autocomplete="username webauthn"
213
+ placeholder={m.emailPlaceholder}
214
+ class="anahtar-input"
215
+ />
216
+ <button type="submit" disabled={loading} class="anahtar-submit-icon" aria-label={m.continue}>
217
+ {#if loading}
218
+ <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="anahtar-spinner"><path d="M21 12a9 9 0 1 1-6.219-8.56"/></svg>
219
+ {:else}
220
+ <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12h14"/><path d="m12 5 7 7-7 7"/></svg>
221
+ {/if}
222
+ </button>
223
+ </div>
215
224
 
216
225
  {#if error}
217
226
  <p class="anahtar-error">{error}</p>
218
227
  {/if}
219
-
220
- <button type="submit" disabled={loading} class="anahtar-button">
221
- {loading ? '...' : m.continue}
222
- </button>
223
228
  </form>
224
229
  {:else if step === 2}
225
230
  <div class="anahtar-otp-step">
@@ -280,22 +285,64 @@ function handlePasskeySkip() {
280
285
  .anahtar-auth-form {
281
286
  display: flex;
282
287
  flex-direction: column;
283
- gap: 1rem;
288
+ gap: 0.75rem;
289
+ }
290
+
291
+ .anahtar-input-row {
292
+ display: flex;
293
+ align-items: center;
294
+ border: 1px solid var(--anahtar-border, #d1d5db);
295
+ border-radius: 0.5rem;
296
+ overflow: hidden;
297
+ transition: box-shadow 0.15s;
298
+ }
299
+
300
+ .anahtar-input-row:focus-within {
301
+ box-shadow: 0 0 0 2px var(--anahtar-ring, #3b82f6);
284
302
  }
285
303
 
286
304
  .anahtar-input {
287
- width: 100%;
288
- padding: 0.5rem 0.75rem;
305
+ flex: 1;
306
+ min-width: 0;
307
+ padding: 0.625rem 0.75rem;
289
308
  font-size: 0.875rem;
290
- border: 1px solid var(--anahtar-border, #d1d5db);
291
- border-radius: 0.375rem;
309
+ border: none;
292
310
  background: var(--anahtar-bg, transparent);
293
311
  color: var(--anahtar-fg, inherit);
294
312
  }
295
313
 
296
314
  .anahtar-input:focus {
297
315
  outline: none;
298
- box-shadow: 0 0 0 2px var(--anahtar-ring, #3b82f6);
316
+ }
317
+
318
+ .anahtar-submit-icon {
319
+ display: flex;
320
+ align-items: center;
321
+ justify-content: center;
322
+ width: 2.5rem;
323
+ height: 2.5rem;
324
+ flex-shrink: 0;
325
+ background: var(--anahtar-primary, #3b82f6);
326
+ color: var(--anahtar-primary-fg, #fff);
327
+ border: none;
328
+ cursor: pointer;
329
+ transition: opacity 0.15s;
330
+ }
331
+
332
+ .anahtar-submit-icon:hover {
333
+ opacity: 0.85;
334
+ }
335
+
336
+ .anahtar-submit-icon:disabled {
337
+ opacity: 0.5;
338
+ }
339
+
340
+ @keyframes anahtar-spin {
341
+ to { transform: rotate(360deg); }
342
+ }
343
+
344
+ .anahtar-spinner {
345
+ animation: anahtar-spin 0.8s linear infinite;
299
346
  }
300
347
 
301
348
  .anahtar-button {
@@ -37,7 +37,13 @@ export function createHandlers(config) {
37
37
  return json({ error: m.errorInvalidEmail }, { status: 400 });
38
38
  }
39
39
  const { code } = await generateOTP(config.db, body.email, config);
40
- await config.onSendOTP(body.email, code);
40
+ try {
41
+ await config.onSendOTP(body.email, code);
42
+ }
43
+ catch (err) {
44
+ const message = err instanceof Error ? err.message : m.errorGeneric;
45
+ return json({ error: message }, { status: 400 });
46
+ }
41
47
  return json({ success: true });
42
48
  },
43
49
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrgnw/anahtar",
3
- "version": "0.0.15",
3
+ "version": "0.0.17",
4
4
  "description": "Opinionated, reusable auth for SvelteKit. Email+OTP + passkeys.",
5
5
  "license": "MIT",
6
6
  "type": "module",