@bagelink/auth 1.12.3 → 1.12.8

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.
Files changed (43) hide show
  1. package/dist/api.d.ts +54 -1
  2. package/dist/index.cjs +154 -1181
  3. package/dist/index.d.ts +0 -9
  4. package/dist/index.mjs +155 -1182
  5. package/dist/routes.d.ts +0 -36
  6. package/dist/types.d.ts +68 -1
  7. package/dist/useAuth.d.ts +17 -1
  8. package/package.json +1 -1
  9. package/src/api.ts +118 -0
  10. package/src/index.ts +0 -13
  11. package/src/routes.ts +0 -96
  12. package/src/types.ts +81 -1
  13. package/src/useAuth.ts +103 -0
  14. package/dist/Callback-BHqVaZZm.cjs +0 -4
  15. package/dist/Callback-C-XghN_z.js +0 -4
  16. package/dist/ForgotPasswordPage-BV9tyhHl.cjs +0 -4
  17. package/dist/ForgotPasswordPage-DvttMGb0.js +0 -4
  18. package/dist/LoginPage-hv1wc54S.cjs +0 -4
  19. package/dist/LoginPage-klj1NV4J.js +0 -4
  20. package/dist/ResetPasswordPage-COPrJmW8.cjs +0 -4
  21. package/dist/ResetPasswordPage-nvQ4uupb.js +0 -4
  22. package/dist/SignupPage-m36w9PLJ.cjs +0 -4
  23. package/dist/SignupPage-oUFYApYW.js +0 -4
  24. package/dist/components/auth/ForgotPasswordForm.vue.d.ts +0 -23
  25. package/dist/components/auth/LoginForm.vue.d.ts +0 -58
  26. package/dist/components/auth/ResetPasswordForm.vue.d.ts +0 -28
  27. package/dist/components/auth/SignupForm.vue.d.ts +0 -34
  28. package/dist/components/index.d.ts +0 -4
  29. package/dist/pages/Callback.vue.d.ts +0 -2
  30. package/dist/pages/ForgotPasswordPage.vue.d.ts +0 -13
  31. package/dist/pages/LoginPage.vue.d.ts +0 -38
  32. package/dist/pages/ResetPasswordPage.vue.d.ts +0 -13
  33. package/dist/pages/SignupPage.vue.d.ts +0 -16
  34. package/src/components/auth/ForgotPasswordForm.vue +0 -97
  35. package/src/components/auth/LoginForm.vue +0 -258
  36. package/src/components/auth/ResetPasswordForm.vue +0 -156
  37. package/src/components/auth/SignupForm.vue +0 -231
  38. package/src/components/index.ts +0 -5
  39. package/src/pages/Callback.vue +0 -196
  40. package/src/pages/ForgotPasswordPage.vue +0 -42
  41. package/src/pages/LoginPage.vue +0 -68
  42. package/src/pages/ResetPasswordPage.vue +0 -47
  43. package/src/pages/SignupPage.vue +0 -46
package/dist/index.mjs CHANGED
@@ -2,9 +2,7 @@ var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
4
  import axios from "axios";
5
- import { defineComponent, ref, computed, createElementBlock, openBlock, normalizeClass, createVNode, createElementVNode, unref, toDisplayString, withModifiers, resolveDirective, createCommentVNode, Fragment, createBlock, withDirectives, normalizeStyle, onMounted, withCtx, renderList } from "vue";
6
- import { Icon, Btn, TextInput, PasswordInput, Card, Loading } from "@bagelink/vue";
7
- import { useRoute, useRouter } from "vue-router";
5
+ import { computed, ref } from "vue";
8
6
  function createAxiosInstance(baseURL) {
9
7
  return axios.create({
10
8
  baseURL,
@@ -299,743 +297,92 @@ class AuthApi {
299
297
  async getTenants() {
300
298
  return this.api.get("tenants");
301
299
  }
302
- }
303
- const _hoisted_1$8 = { class: "txt20 bold mb-1" };
304
- const _hoisted_2$4 = { class: "txt-center opacity-7" };
305
- const _hoisted_3$4 = { class: "txt20 bold txt-center mb-1" };
306
- const _sfc_main$8 = /* @__PURE__ */ defineComponent({
307
- __name: "ForgotPasswordForm",
308
- props: {
309
- emailSent: { type: Boolean, default: false },
310
- useHebrewDefaults: { type: Boolean, default: false },
311
- texts: { default: () => ({}) }
312
- },
313
- emits: ["switchForm"],
314
- setup(__props) {
315
- const props = __props;
316
- const { forgotPassword } = useAuth();
317
- const email = ref("");
318
- const internalEmailSent = ref(false);
319
- const showEmailSent = computed(() => props.emailSent || internalEmailSent.value);
320
- const texts = computed(() => {
321
- var _a, _b, _c, _d, _e, _f;
322
- const hebrewDefaults = {
323
- title: "שכחתם סיסמה",
324
- emailLabel: "איימיל",
325
- submitButton: "שליחת איימיל איפוס",
326
- backToLogin: "חזרה להתחברות",
327
- emailSentTitle: "איימיל נשלח!",
328
- emailSentMessage: "יש לבדוק את תיבת הדואר שלכם לקישור איפוס הסיסמה"
329
- };
330
- const englishDefaults = {
331
- title: "Forgot Password",
332
- emailLabel: "Email",
333
- submitButton: "Send Reset Email",
334
- backToLogin: "Back to Login",
335
- emailSentTitle: "Email Sent!",
336
- emailSentMessage: "Check your inbox for a password reset link"
337
- };
338
- const defaults = props.useHebrewDefaults ? hebrewDefaults : englishDefaults;
339
- return {
340
- title: ((_a = props.texts) == null ? void 0 : _a.title) ?? defaults.title,
341
- emailLabel: ((_b = props.texts) == null ? void 0 : _b.emailLabel) ?? defaults.emailLabel,
342
- submitButton: ((_c = props.texts) == null ? void 0 : _c.submitButton) ?? defaults.submitButton,
343
- backToLogin: ((_d = props.texts) == null ? void 0 : _d.backToLogin) ?? defaults.backToLogin,
344
- emailSentTitle: ((_e = props.texts) == null ? void 0 : _e.emailSentTitle) ?? defaults.emailSentTitle,
345
- emailSentMessage: ((_f = props.texts) == null ? void 0 : _f.emailSentMessage) ?? defaults.emailSentMessage
346
- };
347
- });
348
- const textDirection = computed(() => ({ "auth-rtl": props.useHebrewDefaults }));
349
- async function handleRecoverPassword() {
350
- await forgotPassword(email.value);
351
- internalEmailSent.value = true;
352
- }
353
- return (_ctx, _cache) => {
354
- return showEmailSent.value ? (openBlock(), createElementBlock("div", {
355
- key: 0,
356
- class: normalizeClass(["txt-center", [textDirection.value]])
357
- }, [
358
- createVNode(unref(Icon), {
359
- name: "email",
360
- size: "4",
361
- class: "opacity-3 mb-1"
362
- }),
363
- createElementVNode("h1", _hoisted_1$8, toDisplayString(texts.value.emailSentTitle), 1),
364
- createElementVNode("p", _hoisted_2$4, toDisplayString(texts.value.emailSentMessage), 1),
365
- createVNode(unref(Btn), {
366
- thin: "",
367
- flat: "",
368
- class: "txt-12 mt-2 underline",
369
- value: texts.value.backToLogin,
370
- onClick: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("switchForm", "login"))
371
- }, null, 8, ["value"])
372
- ], 2)) : (openBlock(), createElementBlock("form", {
373
- key: 1,
374
- class: normalizeClass(textDirection.value),
375
- onSubmit: withModifiers(handleRecoverPassword, ["prevent"])
376
- }, [
377
- createElementVNode("h1", _hoisted_3$4, toDisplayString(texts.value.title), 1),
378
- createVNode(unref(TextInput), {
379
- modelValue: email.value,
380
- "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => email.value = $event),
381
- label: texts.value.emailLabel,
382
- autocomplete: "email",
383
- type: "email"
384
- }, null, 8, ["modelValue", "label"]),
385
- createVNode(unref(Btn), {
386
- type: "submit",
387
- class: "w-100 mt-05",
388
- value: texts.value.submitButton
389
- }, null, 8, ["value"]),
390
- createVNode(unref(Btn), {
391
- thin: "",
392
- flat: "",
393
- class: "txt-12 mt-075 underline block",
394
- value: texts.value.backToLogin,
395
- onClick: _cache[2] || (_cache[2] = ($event) => _ctx.$emit("switchForm", "login"))
396
- }, null, 8, ["value"])
397
- ], 34));
398
- };
300
+ /**
301
+ * Get a single tenant by ID or slug
302
+ */
303
+ async getTenant(idOrSlug) {
304
+ return this.api.get(`tenants/${idOrSlug}`);
399
305
  }
400
- });
401
- const _hoisted_1$7 = { class: "txt20 bold txt-center mb-1" };
402
- const _hoisted_2$3 = { key: 1 };
403
- const _hoisted_3$3 = {
404
- key: 0,
405
- class: "flex gap-1 opacity-6"
406
- };
407
- const _hoisted_4$2 = { class: "txt-center my-05" };
408
- const _hoisted_5$2 = { class: "h-20px pt-075" };
409
- const _hoisted_6$2 = {
410
- key: 0,
411
- class: "txt-center color-red txt-12"
412
- };
413
- const _sfc_main$7 = /* @__PURE__ */ defineComponent({
414
- __name: "LoginForm",
415
- props: {
416
- hideRegularLogin: { type: Boolean, default: false },
417
- showForgotPassword: { type: Boolean, default: true },
418
- showSignupButton: { type: Boolean, default: true },
419
- github: { type: Boolean, default: false },
420
- google: { type: Boolean, default: false },
421
- microsoft: { type: Boolean, default: false },
422
- apple: { type: Boolean, default: false },
423
- okta: { type: Boolean, default: false },
424
- facebook: { type: Boolean, default: false },
425
- ssoOutline: { type: Boolean, default: true },
426
- ssoShowValue: { type: Boolean, default: true },
427
- ssoSize: { default: void 0 },
428
- ssoAlign: { type: Boolean, default: false },
429
- ssoBrandBackground: { type: Boolean, default: true },
430
- useHebrewDefaults: { type: Boolean, default: false },
431
- errorState: { default: "normal" },
432
- texts: { default: () => ({}) }
433
- },
434
- emits: ["switchForm"],
435
- setup(__props) {
436
- const props = __props;
437
- const { login, sso: sso2 } = useAuth();
438
- const form = ref({
439
- email: "",
440
- password: ""
441
- });
442
- const internalError = ref("");
443
- const texts = computed(() => {
444
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
445
- const hebrewDefaults = {
446
- title: "התחברות",
447
- emailLabel: "אימייל",
448
- passwordLabel: "סיסמה",
449
- forgotPassword: "שכחתם סיסמה?",
450
- loginButton: "התחברות",
451
- signupButton: "יצירת חשבון",
452
- orText: "או",
453
- githubButton: "התחברות עם GitHub",
454
- googleButton: "התחברות עם Google",
455
- microsoftButton: "התחברות עם Microsoft",
456
- appleButton: "התחברות עם Apple",
457
- oktaButton: "התחברות עם Okta",
458
- facebookButton: "התחברות עם Facebook"
459
- };
460
- const englishDefaults = {
461
- title: "Login",
462
- emailLabel: "Email",
463
- passwordLabel: "Password",
464
- forgotPassword: "Forgot Password",
465
- loginButton: "Login",
466
- signupButton: "Create Account",
467
- orText: "or",
468
- githubButton: "Continue with GitHub",
469
- googleButton: "Continue with Google",
470
- microsoftButton: "Continue with Microsoft",
471
- appleButton: "Continue with Apple",
472
- oktaButton: "Continue with Okta",
473
- facebookButton: "Continue with Facebook"
474
- };
475
- const defaults = props.useHebrewDefaults ? hebrewDefaults : englishDefaults;
476
- return {
477
- title: ((_a = props.texts) == null ? void 0 : _a.title) ?? defaults.title,
478
- emailLabel: ((_b = props.texts) == null ? void 0 : _b.emailLabel) ?? defaults.emailLabel,
479
- passwordLabel: ((_c = props.texts) == null ? void 0 : _c.passwordLabel) ?? defaults.passwordLabel,
480
- forgotPassword: ((_d = props.texts) == null ? void 0 : _d.forgotPassword) ?? defaults.forgotPassword,
481
- loginButton: ((_e = props.texts) == null ? void 0 : _e.loginButton) ?? defaults.loginButton,
482
- signupButton: ((_f = props.texts) == null ? void 0 : _f.signupButton) ?? defaults.signupButton,
483
- orText: ((_g = props.texts) == null ? void 0 : _g.orText) ?? defaults.orText,
484
- githubButton: ((_h = props.texts) == null ? void 0 : _h.githubButton) ?? defaults.githubButton,
485
- googleButton: ((_i = props.texts) == null ? void 0 : _i.googleButton) ?? defaults.googleButton,
486
- microsoftButton: ((_j = props.texts) == null ? void 0 : _j.microsoftButton) ?? defaults.microsoftButton,
487
- appleButton: ((_k = props.texts) == null ? void 0 : _k.appleButton) ?? defaults.appleButton,
488
- oktaButton: ((_l = props.texts) == null ? void 0 : _l.oktaButton) ?? defaults.oktaButton,
489
- facebookButton: ((_m = props.texts) == null ? void 0 : _m.facebookButton) ?? defaults.facebookButton
490
- };
491
- });
492
- const showAnySso = computed(
493
- () => props.github || props.google || props.microsoft || props.apple || props.okta || props.facebook
494
- );
495
- const textDirection = computed(() => ({ "auth-rtl": props.useHebrewDefaults }));
496
- const error = computed(() => getDevError() || internalError.value);
497
- function getDevError() {
498
- switch (props.errorState) {
499
- case "email-required":
500
- return props.useHebrewDefaults ? "איימיל נדרש" : "Email is required";
501
- case "email-invalid":
502
- return props.useHebrewDefaults ? "יש להזין כתובת איימיל תקינה" : "Please enter a valid email address";
503
- case "password-required":
504
- return props.useHebrewDefaults ? "סיסמה נדרשת" : "Password is required";
505
- case "invalid-credentials":
506
- return props.useHebrewDefaults ? "איימיל או סיסמה לא נכונים" : "Invalid email or password";
507
- case "server-error":
508
- return props.useHebrewDefaults ? "ההתחברות נכשלה. אנא נסה שוב." : "Login failed. Please try again.";
509
- default:
510
- return null;
511
- }
512
- }
513
- async function handleLogin() {
514
- internalError.value = "";
515
- if (props.errorState !== "normal") {
516
- return;
517
- }
518
- const { message } = await login(form.value);
519
- internalError.value = message;
520
- }
521
- return (_ctx, _cache) => {
522
- const _directive_tooltip = resolveDirective("tooltip");
523
- return openBlock(), createElementBlock("form", {
524
- class: normalizeClass(textDirection.value),
525
- onSubmit: withModifiers(handleLogin, ["prevent"])
526
- }, [
527
- createElementVNode("h1", _hoisted_1$7, toDisplayString(texts.value.title), 1),
528
- !props.hideRegularLogin ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
529
- createVNode(unref(TextInput), {
530
- modelValue: form.value.email,
531
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => form.value.email = $event),
532
- type: "email",
533
- label: texts.value.emailLabel,
534
- autocomplete: "email"
535
- }, null, 8, ["modelValue", "label"]),
536
- createVNode(unref(PasswordInput), {
537
- modelValue: form.value.password,
538
- "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => form.value.password = $event),
539
- label: texts.value.passwordLabel
540
- }, null, 8, ["modelValue", "label"]),
541
- props.showForgotPassword ? (openBlock(), createBlock(unref(Btn), {
542
- key: 0,
543
- thin: "",
544
- flat: "",
545
- class: "txt-12 mt-075 underline block",
546
- value: texts.value.forgotPassword,
547
- onClick: _cache[2] || (_cache[2] = ($event) => _ctx.$emit("switchForm", "forgot-password"))
548
- }, null, 8, ["value"])) : createCommentVNode("", true),
549
- createVNode(unref(Btn), {
550
- type: "submit",
551
- class: "w-100 mt-1",
552
- value: texts.value.loginButton
553
- }, null, 8, ["value"]),
554
- props.showSignupButton ? (openBlock(), createBlock(unref(Btn), {
555
- key: 1,
556
- outline: "",
557
- color: "primary",
558
- class: "w-100 mt-05",
559
- value: texts.value.signupButton,
560
- onClick: _cache[3] || (_cache[3] = ($event) => _ctx.$emit("switchForm", "signup"))
561
- }, null, 8, ["value"])) : createCommentVNode("", true)
562
- ], 64)) : createCommentVNode("", true),
563
- showAnySso.value ? (openBlock(), createElementBlock("div", _hoisted_2$3, [
564
- !props.hideRegularLogin ? (openBlock(), createElementBlock("div", _hoisted_3$3, [
565
- _cache[10] || (_cache[10] = createElementVNode("div", { class: "line" }, null, -1)),
566
- createElementVNode("p", _hoisted_4$2, toDisplayString(texts.value.orText), 1),
567
- _cache[11] || (_cache[11] = createElementVNode("div", { class: "line" }, null, -1))
568
- ])) : createCommentVNode("", true),
569
- createElementVNode("div", {
570
- class: normalizeClass(["gap-05", { "grid grid-wrap-1": props.ssoShowValue, "flex justify-content-center gap-05 flex-wrap": !props.ssoShowValue }])
571
- }, [
572
- props.github ? withDirectives((openBlock(), createBlock(unref(Btn), {
573
- key: 0,
574
- outline: props.ssoOutline,
575
- "full-width": props.ssoAlign,
576
- "align-txt": props.ssoAlign ? "start" : void 0,
577
- style: normalizeStyle(props.ssoOutline ? "color: #24292F;" : `color: #FFFFFF; ${props.ssoBrandBackground ? "background: #24292F;" : ""}`),
578
- icon: "github",
579
- class: normalizeClass({ "px-075": props.ssoAlign ? "px-075" : "" }),
580
- value: props.ssoShowValue ? texts.value.githubButton : void 0,
581
- size: props.ssoSize,
582
- onClick: _cache[4] || (_cache[4] = ($event) => unref(sso2).github.redirect())
583
- }, null, 8, ["outline", "full-width", "align-txt", "style", "class", "value", "size"])), [
584
- [_directive_tooltip, !props.ssoShowValue ? texts.value.githubButton : void 0]
585
- ]) : createCommentVNode("", true),
586
- props.google ? withDirectives((openBlock(), createBlock(unref(Btn), {
587
- key: 1,
588
- outline: props.ssoOutline,
589
- "full-width": props.ssoAlign,
590
- "align-txt": props.ssoAlign ? "start" : void 0,
591
- style: normalizeStyle(props.ssoOutline ? "color: #DB4437;" : `color: #FFFFFF; ${props.ssoBrandBackground ? "background: #DB4437;" : ""}`),
592
- icon: "google",
593
- class: normalizeClass({ "px-075": props.ssoAlign ? "px-075" : "" }),
594
- value: props.ssoShowValue ? texts.value.googleButton : void 0,
595
- size: props.ssoSize,
596
- onClick: _cache[5] || (_cache[5] = ($event) => unref(sso2).google.redirect())
597
- }, null, 8, ["outline", "full-width", "align-txt", "style", "class", "value", "size"])), [
598
- [_directive_tooltip, !props.ssoShowValue ? texts.value.googleButton : void 0]
599
- ]) : createCommentVNode("", true),
600
- props.microsoft ? withDirectives((openBlock(), createBlock(unref(Btn), {
601
- key: 2,
602
- outline: props.ssoOutline,
603
- "full-width": props.ssoAlign,
604
- "align-txt": props.ssoAlign ? "start" : void 0,
605
- style: normalizeStyle(props.ssoOutline ? "color: #2F2FEE;" : `color: #FFFFFF; ${props.ssoBrandBackground ? "background: #2F2FEE;" : ""}`),
606
- icon: "microsoft",
607
- class: normalizeClass({ "px-075": props.ssoAlign ? "px-075" : "" }),
608
- value: props.ssoShowValue ? texts.value.microsoftButton : void 0,
609
- size: props.ssoSize,
610
- onClick: _cache[6] || (_cache[6] = ($event) => unref(sso2).microsoft.redirect())
611
- }, null, 8, ["outline", "full-width", "align-txt", "style", "class", "value", "size"])), [
612
- [_directive_tooltip, !props.ssoShowValue ? texts.value.microsoftButton : void 0]
613
- ]) : createCommentVNode("", true),
614
- props.apple ? withDirectives((openBlock(), createBlock(unref(Btn), {
615
- key: 3,
616
- outline: props.ssoOutline,
617
- "full-width": props.ssoAlign,
618
- "align-txt": props.ssoAlign ? "start" : void 0,
619
- style: normalizeStyle(props.ssoOutline ? "color: #000000;" : `color: #FFFFFF; ${props.ssoBrandBackground ? "background: #000000;" : ""}`),
620
- icon: "apple",
621
- class: normalizeClass({ "px-075": props.ssoAlign ? "px-075" : "" }),
622
- value: props.ssoShowValue ? texts.value.appleButton : void 0,
623
- size: props.ssoSize,
624
- onClick: _cache[7] || (_cache[7] = ($event) => unref(sso2).apple.redirect())
625
- }, null, 8, ["outline", "full-width", "align-txt", "style", "class", "value", "size"])), [
626
- [_directive_tooltip, !props.ssoShowValue ? texts.value.appleButton : void 0]
627
- ]) : createCommentVNode("", true),
628
- props.okta ? withDirectives((openBlock(), createBlock(unref(Btn), {
629
- key: 4,
630
- outline: props.ssoOutline,
631
- "full-width": props.ssoAlign,
632
- "align-txt": props.ssoAlign ? "start" : void 0,
633
- style: normalizeStyle(props.ssoOutline ? "color: #FFB600;" : `color: #FFFFFF; ${props.ssoBrandBackground ? "background: #FFB600;" : ""}`),
634
- icon: "sun",
635
- class: normalizeClass({ "px-075": props.ssoAlign ? "px-075" : "" }),
636
- value: props.ssoShowValue ? texts.value.oktaButton : void 0,
637
- size: props.ssoSize,
638
- onClick: _cache[8] || (_cache[8] = ($event) => unref(sso2).okta.redirect())
639
- }, null, 8, ["outline", "full-width", "align-txt", "style", "class", "value", "size"])), [
640
- [_directive_tooltip, !props.ssoShowValue ? texts.value.oktaButton : void 0]
641
- ]) : createCommentVNode("", true),
642
- props.facebook ? withDirectives((openBlock(), createBlock(unref(Btn), {
643
- key: 5,
644
- outline: props.ssoOutline,
645
- "full-width": props.ssoAlign,
646
- "align-txt": props.ssoAlign ? "start" : void 0,
647
- style: normalizeStyle(props.ssoOutline ? "color: #1877F3;" : `color: #FFFFFF; ${props.ssoBrandBackground ? "background: #1877F3;" : ""}`),
648
- icon: "facebook",
649
- class: normalizeClass({ "px-075": props.ssoAlign ? "px-075" : "" }),
650
- value: props.ssoShowValue ? texts.value.facebookButton : void 0,
651
- size: props.ssoSize,
652
- onClick: _cache[9] || (_cache[9] = ($event) => unref(sso2).facebook.redirect())
653
- }, null, 8, ["outline", "full-width", "align-txt", "style", "class", "value", "size"])), [
654
- [_directive_tooltip, !props.ssoShowValue ? texts.value.facebookButton : void 0]
655
- ]) : createCommentVNode("", true)
656
- ], 2),
657
- createElementVNode("div", _hoisted_5$2, [
658
- error.value ? (openBlock(), createElementBlock("p", _hoisted_6$2, toDisplayString(error.value), 1)) : createCommentVNode("", true)
659
- ])
660
- ])) : createCommentVNode("", true)
661
- ], 34);
662
- };
306
+ /**
307
+ * Create a new tenant (caller is auto-added as admin)
308
+ */
309
+ async createTenant(data) {
310
+ return this.api.post("tenants/", data);
663
311
  }
664
- });
665
- const _hoisted_1$6 = { class: "txt20 bold mb-1" };
666
- const _hoisted_2$2 = { class: "opacity-7 mb-2" };
667
- const _hoisted_3$2 = { class: "txt20 bold mb-1" };
668
- const _hoisted_4$1 = { class: "opacity-7 mb-2" };
669
- const _hoisted_5$1 = { class: "txt20 bold txt-center mb-1" };
670
- const _hoisted_6$1 = { class: "h-20px pt-075" };
671
- const _hoisted_7$1 = {
672
- key: 0,
673
- class: "txt-center color-red txt-12"
674
- };
675
- const _sfc_main$6 = /* @__PURE__ */ defineComponent({
676
- __name: "ResetPasswordForm",
677
- props: {
678
- token: {},
679
- showSuccess: { type: Boolean },
680
- useHebrewDefaults: { type: Boolean, default: false },
681
- texts: {}
682
- },
683
- emits: ["switchForm"],
684
- setup(__props) {
685
- const props = __props;
686
- const { resetPassword } = useAuth();
687
- const error = ref("");
688
- const internalSuccess = ref(false);
689
- const newPassword = ref("");
690
- const confirmPassword = ref("");
691
- const isValidToken = computed(() => !!props.token);
692
- const isSuccess = computed(() => props.showSuccess || internalSuccess.value);
693
- const texts = computed(() => {
694
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
695
- const hebrewDefaults = {
696
- title: "איפוס סיסמה",
697
- invalidLinkTitle: "קישור לא תקין",
698
- invalidLinkMessage: "קישור איפוס הסיסמה לא תקין או פג תוקף",
699
- newPasswordLabel: "סיסמה חדשה",
700
- confirmPasswordLabel: "אימות סיסמה",
701
- submitButton: "איפוס סיסמה",
702
- backToLogin: "חזרה להתחברות",
703
- passwordMismatchError: "הסיסמאות לא תואמות",
704
- invalidTokenError: "אסימון לא תקין",
705
- successTitle: "הסיסמה אופסה בהצלחה!",
706
- successMessage: "הסיסמה שלכם אופסה. כעת תוכלו להתחברות עם הסיסמה החדשה.",
707
- goToLogin: "מעבר להתחברות"
708
- };
709
- const englishDefaults = {
710
- title: "Reset Password",
711
- invalidLinkTitle: "Invalid Link",
712
- invalidLinkMessage: "This reset link is invalid or has expired",
713
- newPasswordLabel: "New Password",
714
- confirmPasswordLabel: "Confirm Password",
715
- submitButton: "Reset Password",
716
- backToLogin: "Back to Login",
717
- passwordMismatchError: "Passwords do not match",
718
- invalidTokenError: "Invalid token",
719
- successTitle: "Password Reset Successfully!",
720
- successMessage: "Your password has been reset. You can now log in with your new password.",
721
- goToLogin: "Go to Login"
722
- };
723
- const defaults = props.useHebrewDefaults ? hebrewDefaults : englishDefaults;
724
- return {
725
- title: ((_a = props.texts) == null ? void 0 : _a.title) ?? defaults.title,
726
- invalidLinkTitle: ((_b = props.texts) == null ? void 0 : _b.invalidLinkTitle) ?? defaults.invalidLinkTitle,
727
- invalidLinkMessage: ((_c = props.texts) == null ? void 0 : _c.invalidLinkMessage) ?? defaults.invalidLinkMessage,
728
- newPasswordLabel: ((_d = props.texts) == null ? void 0 : _d.newPasswordLabel) ?? defaults.newPasswordLabel,
729
- confirmPasswordLabel: ((_e = props.texts) == null ? void 0 : _e.confirmPasswordLabel) ?? defaults.confirmPasswordLabel,
730
- submitButton: ((_f = props.texts) == null ? void 0 : _f.submitButton) ?? defaults.submitButton,
731
- backToLogin: ((_g = props.texts) == null ? void 0 : _g.backToLogin) ?? defaults.backToLogin,
732
- passwordMismatchError: ((_h = props.texts) == null ? void 0 : _h.passwordMismatchError) ?? defaults.passwordMismatchError,
733
- invalidTokenError: ((_i = props.texts) == null ? void 0 : _i.invalidTokenError) ?? defaults.invalidTokenError,
734
- successTitle: ((_j = props.texts) == null ? void 0 : _j.successTitle) ?? defaults.successTitle,
735
- successMessage: ((_k = props.texts) == null ? void 0 : _k.successMessage) ?? defaults.successMessage,
736
- goToLogin: ((_l = props.texts) == null ? void 0 : _l.goToLogin) ?? defaults.goToLogin
737
- };
738
- });
739
- const textDirection = computed(() => ({ "auth-rtl": props.useHebrewDefaults }));
740
- async function handleResetPassword() {
741
- if (newPassword.value !== confirmPassword.value) {
742
- error.value = texts.value.passwordMismatchError;
743
- return;
744
- }
745
- if (!props.token) {
746
- error.value = texts.value.invalidTokenError;
747
- return;
748
- }
749
- try {
750
- await resetPassword(props.token, newPassword.value);
751
- internalSuccess.value = true;
752
- error.value = "";
753
- } catch (err) {
754
- error.value = err instanceof Error ? err.message : "Reset failed";
755
- }
756
- }
757
- return (_ctx, _cache) => {
758
- return !isValidToken.value ? (openBlock(), createElementBlock("div", {
759
- key: 0,
760
- class: normalizeClass(["txt-center", textDirection.value])
761
- }, [
762
- createElementVNode("h1", _hoisted_1$6, toDisplayString(texts.value.invalidLinkTitle), 1),
763
- createElementVNode("p", _hoisted_2$2, toDisplayString(texts.value.invalidLinkMessage), 1),
764
- createVNode(unref(Btn), {
765
- value: texts.value.backToLogin,
766
- onClick: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("switchForm", "login"))
767
- }, null, 8, ["value"])
768
- ], 2)) : isSuccess.value ? (openBlock(), createElementBlock("div", {
769
- key: 1,
770
- class: normalizeClass(["txt-center", textDirection.value])
771
- }, [
772
- createVNode(unref(Icon), {
773
- name: "check_circle",
774
- size: "4",
775
- class: "txt-green mb-1"
776
- }),
777
- createElementVNode("h1", _hoisted_3$2, toDisplayString(texts.value.successTitle), 1),
778
- createElementVNode("p", _hoisted_4$1, toDisplayString(texts.value.successMessage), 1),
779
- createVNode(unref(Btn), {
780
- value: texts.value.goToLogin,
781
- onClick: _cache[1] || (_cache[1] = ($event) => _ctx.$emit("switchForm", "login"))
782
- }, null, 8, ["value"])
783
- ], 2)) : (openBlock(), createElementBlock("form", {
784
- key: 2,
785
- class: normalizeClass(textDirection.value),
786
- onSubmit: withModifiers(handleResetPassword, ["prevent"])
787
- }, [
788
- createElementVNode("h1", _hoisted_5$1, toDisplayString(texts.value.title), 1),
789
- createVNode(unref(PasswordInput), {
790
- modelValue: newPassword.value,
791
- "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => newPassword.value = $event),
792
- class: "mb-05",
793
- label: texts.value.newPasswordLabel,
794
- autocomplete: "new-password"
795
- }, null, 8, ["modelValue", "label"]),
796
- createVNode(unref(PasswordInput), {
797
- modelValue: confirmPassword.value,
798
- "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => confirmPassword.value = $event),
799
- label: texts.value.confirmPasswordLabel,
800
- autocomplete: "new-password"
801
- }, null, 8, ["modelValue", "label"]),
802
- createVNode(unref(Btn), {
803
- type: "submit",
804
- class: "w-100 mt-2",
805
- value: texts.value.submitButton
806
- }, null, 8, ["value"]),
807
- createVNode(unref(Btn), {
808
- thin: "",
809
- flat: "",
810
- class: "txt-12 mt-075 underline block",
811
- value: texts.value.backToLogin,
812
- onClick: _cache[4] || (_cache[4] = ($event) => _ctx.$emit("switchForm", "login"))
813
- }, null, 8, ["value"]),
814
- createElementVNode("div", _hoisted_6$1, [
815
- error.value ? (openBlock(), createElementBlock("p", _hoisted_7$1, toDisplayString(error.value), 1)) : createCommentVNode("", true)
816
- ])
817
- ], 34));
818
- };
312
+ /**
313
+ * Update a tenant
314
+ */
315
+ async updateTenant(tenantId, data) {
316
+ return this.api.put(`tenants/${tenantId}`, data);
819
317
  }
820
- });
821
- const _hoisted_1$5 = { class: "txt20 bold txt-center mb-1" };
822
- const _hoisted_2$1 = { class: "h-20px pt-075" };
823
- const _hoisted_3$1 = {
824
- key: 0,
825
- class: "txt-center color-red txt-12"
826
- };
827
- const _sfc_main$5 = /* @__PURE__ */ defineComponent({
828
- __name: "SignupForm",
829
- props: {
830
- showNames: { type: Boolean, default: true },
831
- useHebrewDefaults: { type: Boolean, default: false },
832
- errorState: { default: "normal" },
833
- texts: { default: () => ({}) }
834
- },
835
- emits: ["switchForm"],
836
- setup(__props) {
837
- const props = __props;
838
- const { signup, login } = useAuth();
839
- const internalError = ref("");
840
- const error = computed(() => {
841
- if (props.errorState !== "normal") {
842
- return getDevError();
843
- }
844
- return internalError.value;
845
- });
846
- const form = ref({
847
- email: "",
848
- password: "",
849
- confirmPassword: "",
850
- first_name: "",
851
- last_name: ""
852
- });
853
- const texts = computed(() => {
854
- const hebrewDefaults = {
855
- title: "יצירת חשבון",
856
- firstNameLabel: "שם פרטי",
857
- lastNameLabel: "שם משפחה",
858
- emailLabel: "איימיל",
859
- passwordLabel: "סיסמה",
860
- confirmPasswordLabel: "אימות סיסמה",
861
- signupButton: "יצירת חשבון",
862
- alreadyHaveAccount: "יש לך כבר חשבון?",
863
- // Validation errors
864
- emailRequiredError: "איימיל נדרש",
865
- emailInvalidError: "יש להזין כתובת איימיל תקינה",
866
- passwordRequiredError: "סיסמה נדרשת",
867
- passwordTooShortError: "הסיסמה חייבת להיות לפחות 8 תווים",
868
- passwordMismatchError: "הסיסמאות לא תואמות",
869
- firstNameRequiredError: "שם פרטי נדרש",
870
- lastNameRequiredError: "שם משפחה נדרש"
871
- };
872
- const englishDefaults = {
873
- title: "Create Account",
874
- firstNameLabel: "First Name",
875
- lastNameLabel: "Last Name",
876
- emailLabel: "Email",
877
- passwordLabel: "Password",
878
- confirmPasswordLabel: "Confirm Password",
879
- signupButton: "Create Account",
880
- alreadyHaveAccount: "Already have an account?",
881
- // Validation errors
882
- emailRequiredError: "Email is required",
883
- emailInvalidError: "Please enter a valid email address",
884
- passwordRequiredError: "Password is required",
885
- passwordTooShortError: "Password must be at least 8 characters",
886
- passwordMismatchError: "Passwords do not match",
887
- firstNameRequiredError: "First name is required",
888
- lastNameRequiredError: "Last name is required"
889
- };
890
- const defaults = props.useHebrewDefaults ? hebrewDefaults : englishDefaults;
891
- return {
892
- title: props.texts.title || defaults.title,
893
- firstNameLabel: props.texts.firstNameLabel || defaults.firstNameLabel,
894
- lastNameLabel: props.texts.lastNameLabel || defaults.lastNameLabel,
895
- emailLabel: props.texts.emailLabel || defaults.emailLabel,
896
- passwordLabel: props.texts.passwordLabel || defaults.passwordLabel,
897
- confirmPasswordLabel: props.texts.confirmPasswordLabel || defaults.confirmPasswordLabel,
898
- signupButton: props.texts.signupButton || defaults.signupButton,
899
- alreadyHaveAccount: props.texts.alreadyHaveAccount || defaults.alreadyHaveAccount,
900
- // Validation errors
901
- emailRequiredError: props.texts.emailRequiredError || defaults.emailRequiredError,
902
- emailInvalidError: props.texts.emailInvalidError || defaults.emailInvalidError,
903
- passwordRequiredError: props.texts.passwordRequiredError || defaults.passwordRequiredError,
904
- passwordTooShortError: props.texts.passwordTooShortError || defaults.passwordTooShortError,
905
- passwordMismatchError: props.texts.passwordMismatchError || defaults.passwordMismatchError,
906
- firstNameRequiredError: props.texts.firstNameRequiredError || defaults.firstNameRequiredError,
907
- lastNameRequiredError: props.texts.lastNameRequiredError || defaults.lastNameRequiredError
908
- };
909
- });
910
- const textDirection = computed(() => ({ "auth-rtl": props.useHebrewDefaults }));
911
- function getDevError() {
912
- switch (props.errorState) {
913
- case "email-required":
914
- return texts.value.emailRequiredError;
915
- case "email-invalid":
916
- return texts.value.emailInvalidError;
917
- case "password-short":
918
- return texts.value.passwordTooShortError;
919
- case "password-mismatch":
920
- return texts.value.passwordMismatchError;
921
- case "name-required":
922
- return props.showNames ? texts.value.firstNameRequiredError : null;
923
- case "server-error":
924
- return props.useHebrewDefaults ? "כתובת האימייל כבר קיימת או שגיאת שרת" : "Email already exists or server error";
925
- default:
926
- return null;
927
- }
928
- }
929
- function validateForm() {
930
- if (!form.value.email.trim()) {
931
- return texts.value.emailRequiredError;
932
- }
933
- const emailRegex = /^[^\s@]+@[^\s@][^\s.@]*\.[^\s@]+$/;
934
- if (!emailRegex.test(form.value.email)) {
935
- return texts.value.emailInvalidError;
936
- }
937
- if (!form.value.password) {
938
- return texts.value.passwordRequiredError;
939
- }
940
- if (form.value.password.length < 8) {
941
- return texts.value.passwordTooShortError;
942
- }
943
- if (form.value.password !== form.value.confirmPassword) {
944
- return texts.value.passwordMismatchError;
945
- }
946
- if (props.showNames) {
947
- if (!form.value.first_name.trim()) {
948
- return texts.value.firstNameRequiredError;
949
- }
950
- if (!form.value.last_name.trim()) {
951
- return texts.value.lastNameRequiredError;
952
- }
953
- }
954
- return null;
955
- }
956
- async function handleSignup() {
957
- if (props.errorState !== "normal") {
958
- return;
959
- }
960
- internalError.value = "";
961
- const validationError = validateForm();
962
- if (validationError) {
963
- internalError.value = validationError;
964
- return;
965
- }
966
- const { message, success } = await signup(form.value).catch((error2) => {
967
- var _a, _b;
968
- console.error(error2);
969
- const errorMessage = (_b = (_a = error2.response) == null ? void 0 : _a.data) == null ? void 0 : _b.detail;
970
- if (errorMessage == null ? void 0 : errorMessage.toLowerCase().includes("email")) {
971
- return { success: false, message: "Email already exists or invalid" };
972
- }
973
- if (errorMessage == null ? void 0 : errorMessage.toLowerCase().includes("password")) {
974
- return { success: false, message: "Password does not meet requirements" };
975
- }
976
- return { success: false, message: errorMessage || "Registration failed. Please try again." };
977
- });
978
- if (!success) {
979
- internalError.value = message;
980
- return;
981
- }
982
- await login({ email: form.value.email, password: form.value.password });
983
- }
984
- return (_ctx, _cache) => {
985
- return openBlock(), createElementBlock("form", {
986
- class: normalizeClass(textDirection.value),
987
- onSubmit: withModifiers(handleSignup, ["prevent"])
988
- }, [
989
- createElementVNode("h1", _hoisted_1$5, toDisplayString(texts.value.title), 1),
990
- props.showNames ? (openBlock(), createBlock(unref(TextInput), {
991
- key: 0,
992
- modelValue: form.value.first_name,
993
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => form.value.first_name = $event),
994
- label: texts.value.firstNameLabel
995
- }, null, 8, ["modelValue", "label"])) : createCommentVNode("", true),
996
- props.showNames ? (openBlock(), createBlock(unref(TextInput), {
997
- key: 1,
998
- modelValue: form.value.last_name,
999
- "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => form.value.last_name = $event),
1000
- label: texts.value.lastNameLabel
1001
- }, null, 8, ["modelValue", "label"])) : createCommentVNode("", true),
1002
- createVNode(unref(TextInput), {
1003
- modelValue: form.value.email,
1004
- "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => form.value.email = $event),
1005
- type: "email",
1006
- label: texts.value.emailLabel,
1007
- autocomplete: "username"
1008
- }, null, 8, ["modelValue", "label"]),
1009
- createVNode(unref(PasswordInput), {
1010
- modelValue: form.value.password,
1011
- "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => form.value.password = $event),
1012
- class: "mb-05",
1013
- label: texts.value.passwordLabel
1014
- }, null, 8, ["modelValue", "label"]),
1015
- createVNode(unref(PasswordInput), {
1016
- modelValue: form.value.confirmPassword,
1017
- "onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => form.value.confirmPassword = $event),
1018
- label: texts.value.confirmPasswordLabel
1019
- }, null, 8, ["modelValue", "label"]),
1020
- createVNode(unref(Btn), {
1021
- class: "w-100 mt-2",
1022
- value: texts.value.signupButton,
1023
- type: "submit"
1024
- }, null, 8, ["value"]),
1025
- createVNode(unref(Btn), {
1026
- thin: "",
1027
- flat: "",
1028
- class: "txt-12 mt-075 underline block",
1029
- value: texts.value.alreadyHaveAccount,
1030
- onClick: _cache[5] || (_cache[5] = ($event) => _ctx.$emit("switchForm", "login"))
1031
- }, null, 8, ["value"]),
1032
- createElementVNode("div", _hoisted_2$1, [
1033
- error.value ? (openBlock(), createElementBlock("p", _hoisted_3$1, toDisplayString(error.value), 1)) : createCommentVNode("", true)
1034
- ])
1035
- ], 34);
1036
- };
318
+ /**
319
+ * Delete a tenant
320
+ */
321
+ async deleteTenant(tenantId) {
322
+ return this.api.delete(`tenants/${tenantId}`);
323
+ }
324
+ // ============================================
325
+ // Tenant Member Methods
326
+ // ============================================
327
+ /**
328
+ * List members of a tenant
329
+ */
330
+ async getTenantMembers(tenantId, status) {
331
+ return this.api.get(`tenants/${tenantId}/members`, { params: status ? { status } : void 0 });
332
+ }
333
+ /**
334
+ * Add a member to a tenant by identity_id
335
+ */
336
+ async addTenantMember(tenantId, data) {
337
+ return this.api.post(`tenants/${tenantId}/members`, data);
338
+ }
339
+ /**
340
+ * Update a tenant member's roles/status/metadata
341
+ */
342
+ async updateTenantMember(tenantId, identityId, data) {
343
+ return this.api.put(`tenants/${tenantId}/members/${identityId}`, data);
344
+ }
345
+ /**
346
+ * Activate a pending membership
347
+ */
348
+ async activateTenantMember(tenantId, identityId) {
349
+ return this.api.post(`tenants/${tenantId}/members/${identityId}/activate`, {});
350
+ }
351
+ /**
352
+ * Remove a member from a tenant
353
+ */
354
+ async removeTenantMember(tenantId, identityId) {
355
+ return this.api.delete(`tenants/${tenantId}/members/${identityId}`);
356
+ }
357
+ /**
358
+ * List available roles
359
+ */
360
+ async getTenantRoles() {
361
+ return this.api.get("tenants/roles");
1037
362
  }
1038
- });
363
+ // ============================================
364
+ // Invitation Methods
365
+ // ============================================
366
+ /**
367
+ * Create an invitation for a new user to join a tenant
368
+ * Requires X-Tenant-ID header (set via setTenantId)
369
+ */
370
+ async createInvitation(data) {
371
+ return this.api.post("invitations/", data);
372
+ }
373
+ /**
374
+ * Get invitation metadata by token (no auth required)
375
+ */
376
+ async getInvitation(token) {
377
+ return this.api.get(`invitations/${token}`);
378
+ }
379
+ /**
380
+ * Accept an invitation — creates TenantMembership for the authenticated user
381
+ */
382
+ async acceptInvitation(token, data) {
383
+ return this.api.post(`invitations/${token}/accept`, data ?? {});
384
+ }
385
+ }
1039
386
  const INTAKE_WORKFLOW_ID = "fdba1933-0964-4850-b52a-7a4324175790";
1040
387
  const DEFAULT_AGENT_ID = "fdba1933-0964-4850-b52a-7a4324175790";
1041
388
  const providers = {
@@ -1046,387 +393,6 @@ const providers = {
1046
393
  okta: { name: "Okta", icon: "sun", color: "#FFB600" },
1047
394
  facebook: { name: "Facebook", icon: "facebook", color: "#1877F3" }
1048
395
  };
1049
- const _hoisted_1$4 = { class: "flex justify-content-center align-items-center vh-100 px-1" };
1050
- const _hoisted_2 = {
1051
- key: 0,
1052
- class: "flex column align-items-center gap-1"
1053
- };
1054
- const _hoisted_3 = { class: "mt-1" };
1055
- const _hoisted_4 = { class: "mb-05 pb-0 mt-0 txt24 m_txt20" };
1056
- const _hoisted_5 = { class: "opacity-7 txt-14" };
1057
- const _hoisted_6 = {
1058
- key: 1,
1059
- class: "flex column align-items-center gap-1"
1060
- };
1061
- const _hoisted_7 = { class: "flex justify-content-center align-items-center mb-1" };
1062
- const _hoisted_8 = { class: "relative" };
1063
- const _hoisted_9 = {
1064
- key: 0,
1065
- class: "absolute flex justify-content-center align-items-center bg-white rounded",
1066
- style: { "bottom": "-8px", "right": "-8px", "width": "40px", "height": "40px", "border": "3px solid white" }
1067
- };
1068
- const _hoisted_10 = { class: "mb-05 pb-0 mt-0 txt24 m_txt20" };
1069
- const _hoisted_11 = { class: "opacity-7 txt-14 mb-1" };
1070
- const _hoisted_12 = {
1071
- key: 0,
1072
- class: "bg-gray-light rounded p-1 mt-1"
1073
- };
1074
- const _hoisted_13 = { class: "flex column gap-05" };
1075
- const _hoisted_14 = {
1076
- key: 0,
1077
- class: "flex align-items-center gap-05 justify-content-center"
1078
- };
1079
- const _hoisted_15 = { class: "txt-14 bold" };
1080
- const _hoisted_16 = {
1081
- key: 1,
1082
- class: "flex align-items-center gap-05 justify-content-center"
1083
- };
1084
- const _hoisted_17 = { class: "txt-14 opacity-7" };
1085
- const _hoisted_18 = {
1086
- key: 2,
1087
- class: "flex gap-05 justify-content-center mt-05"
1088
- };
1089
- const _hoisted_19 = {
1090
- key: 2,
1091
- class: "flex column align-items-center gap-1"
1092
- };
1093
- const _hoisted_20 = { class: "opacity-7 txt-14 mb-1" };
1094
- const _hoisted_21 = { class: "flex gap-05 justify-content-center" };
1095
- const timeout = 4e3;
1096
- const _sfc_main$4 = /* @__PURE__ */ defineComponent({
1097
- __name: "Callback",
1098
- setup(__props) {
1099
- const isLoading = ref(true);
1100
- const error = ref(null);
1101
- const success = ref(false);
1102
- const isLinking = ref(false);
1103
- const provider = ref(null);
1104
- const authResponse = ref(null);
1105
- const { sso: sso2, user, accountInfo: accountInfo2 } = useAuth();
1106
- const route = useRoute();
1107
- const router2 = useRouter();
1108
- const providerInfo = computed(() => {
1109
- if (provider.value === null) return null;
1110
- return providers[provider.value];
1111
- });
1112
- async function linkCallback() {
1113
- isLinking.value = true;
1114
- const { redirect: redirect2 } = route.query;
1115
- try {
1116
- await sso2.handleLinkCallback();
1117
- success.value = true;
1118
- setTimeout(() => {
1119
- const redirectPath = typeof redirect2 === "string" ? redirect2 : "/";
1120
- router2.push(redirectPath);
1121
- }, timeout);
1122
- } catch (err) {
1123
- const errorMessage = err instanceof Error ? err.message : "Failed to link account";
1124
- error.value = errorMessage;
1125
- } finally {
1126
- isLoading.value = false;
1127
- }
1128
- }
1129
- async function handleCallback() {
1130
- var _a;
1131
- const { state, redirect: redirect2 } = route.query;
1132
- provider.value = sessionStorage.getItem(`oauth_provider:${state}`);
1133
- console.log("[Callback] Query params:", { state, redirect: redirect2 });
1134
- console.log("[Callback] Full route query:", route.query);
1135
- try {
1136
- const response = await sso2.handleCallback();
1137
- if (response === null) {
1138
- error.value = `Failed to authenticate with ${((_a = providerInfo.value) == null ? void 0 : _a.name) ?? "provider"}`;
1139
- } else {
1140
- authResponse.value = response;
1141
- success.value = true;
1142
- console.log("[Callback] Login successful, redirect param:", redirect2);
1143
- setTimeout(() => {
1144
- const redirectPath = typeof redirect2 === "string" ? redirect2 : "/";
1145
- console.log("[Callback] Manual fallback redirecting to:", redirectPath);
1146
- router2.push(redirectPath);
1147
- }, timeout);
1148
- }
1149
- } catch (err) {
1150
- const errorMessage = err instanceof Error ? err.message : "Authentication failed";
1151
- error.value = errorMessage;
1152
- } finally {
1153
- isLoading.value = false;
1154
- }
1155
- }
1156
- onMounted(async () => {
1157
- if (user.value) {
1158
- await linkCallback();
1159
- } else {
1160
- await handleCallback();
1161
- }
1162
- });
1163
- return (_ctx, _cache) => {
1164
- return openBlock(), createElementBlock("div", _hoisted_1$4, [
1165
- createVNode(unref(Card), { class: "p-2 txt-center w450px shadow" }, {
1166
- default: withCtx(() => {
1167
- var _a, _b, _c, _d, _e, _f;
1168
- return [
1169
- isLoading.value ? (openBlock(), createElementBlock("div", _hoisted_2, [
1170
- createVNode(unref(Loading)),
1171
- createElementVNode("div", _hoisted_3, [
1172
- createElementVNode("h2", _hoisted_4, toDisplayString(isLinking.value ? "Linking Account" : "Authenticating"), 1),
1173
- createElementVNode("p", _hoisted_5, " Please wait while we " + toDisplayString(isLinking.value ? "link your" : "complete the") + " " + toDisplayString(((_a = providerInfo.value) == null ? void 0 : _a.name) || "OAuth") + " " + toDisplayString(isLinking.value ? "account" : "authentication") + ". ", 1)
1174
- ])
1175
- ])) : success.value && !error.value ? (openBlock(), createElementBlock("div", _hoisted_6, [
1176
- createElementVNode("div", _hoisted_7, [
1177
- createElementVNode("div", _hoisted_8, [
1178
- createVNode(unref(Icon), {
1179
- name: "check_circle",
1180
- size: "5",
1181
- class: "txt-green line-height-1"
1182
- }),
1183
- providerInfo.value ? (openBlock(), createElementBlock("div", _hoisted_9, [
1184
- createVNode(unref(Icon), {
1185
- name: providerInfo.value.icon,
1186
- size: "1.5",
1187
- style: normalizeStyle({ color: providerInfo.value.color })
1188
- }, null, 8, ["name", "style"])
1189
- ])) : createCommentVNode("", true)
1190
- ])
1191
- ]),
1192
- createElementVNode("div", null, [
1193
- createElementVNode("h2", _hoisted_10, toDisplayString(isLinking.value ? "Account Linked!" : "Welcome Back!"), 1),
1194
- createElementVNode("p", _hoisted_11, toDisplayString(isLinking.value ? `Successfully linked your ${((_b = providerInfo.value) == null ? void 0 : _b.name) || "account"}.` : `You've successfully signed in with ${((_c = providerInfo.value) == null ? void 0 : _c.name) || "your account"}.`), 1),
1195
- unref(user) || unref(accountInfo2) ? (openBlock(), createElementBlock("div", _hoisted_12, [
1196
- createElementVNode("div", _hoisted_13, [
1197
- ((_d = unref(user)) == null ? void 0 : _d.name) ? (openBlock(), createElementBlock("div", _hoisted_14, [
1198
- createVNode(unref(Icon), {
1199
- name: "person",
1200
- size: "1.2",
1201
- class: "opacity-7"
1202
- }),
1203
- createElementVNode("span", _hoisted_15, toDisplayString(unref(user).name), 1)
1204
- ])) : createCommentVNode("", true),
1205
- ((_e = unref(user)) == null ? void 0 : _e.email) ? (openBlock(), createElementBlock("div", _hoisted_16, [
1206
- createVNode(unref(Icon), {
1207
- name: "email",
1208
- size: "1.2",
1209
- class: "opacity-7"
1210
- }),
1211
- createElementVNode("span", _hoisted_17, toDisplayString(unref(user).email), 1)
1212
- ])) : createCommentVNode("", true),
1213
- ((_f = unref(accountInfo2)) == null ? void 0 : _f.authentication_methods) ? (openBlock(), createElementBlock("div", _hoisted_18, [
1214
- (openBlock(true), createElementBlock(Fragment, null, renderList(unref(accountInfo2).authentication_methods, (method) => {
1215
- return openBlock(), createBlock(unref(Icon), {
1216
- key: method.id,
1217
- name: method.type === "sso" ? method.provider || "link" : "password",
1218
- size: "1.2",
1219
- class: "opacity-5"
1220
- }, null, 8, ["name"]);
1221
- }), 128))
1222
- ])) : createCommentVNode("", true)
1223
- ])
1224
- ])) : createCommentVNode("", true),
1225
- _cache[0] || (_cache[0] = createElementVNode("p", { class: "txt-12 opacity-5 mt-1" }, " Redirecting you to home... ", -1))
1226
- ])
1227
- ])) : error.value ? (openBlock(), createElementBlock("div", _hoisted_19, [
1228
- createVNode(unref(Icon), {
1229
- name: "error",
1230
- size: "5",
1231
- class: "txt-red mb-1 line-height-1"
1232
- }),
1233
- createElementVNode("div", null, [
1234
- _cache[1] || (_cache[1] = createElementVNode("h2", { class: "mb-05 pb-0 mt-0 txt24 m_txt20" }, " Authentication Failed ", -1)),
1235
- createElementVNode("p", _hoisted_20, toDisplayString(error.value), 1),
1236
- _cache[2] || (_cache[2] = createElementVNode("div", { class: "bg-red-light rounded p-1 mt-1 mb-1" }, [
1237
- createElementVNode("p", { class: "txt-12 opacity-7" }, " This could happen if: "),
1238
- createElementVNode("ul", {
1239
- class: "txt-12 opacity-7 txt-start mt-05",
1240
- style: { "list-style": "none", "padding-left": "0" }
1241
- }, [
1242
- createElementVNode("li", { class: "mb-025" }, " • The authorization was cancelled "),
1243
- createElementVNode("li", { class: "mb-025" }, " • The state parameter was invalid "),
1244
- createElementVNode("li", { class: "mb-025" }, " • The OAuth provider denied access "),
1245
- createElementVNode("li", { class: "mb-025" }, " • Network connectivity issues ")
1246
- ])
1247
- ], -1)),
1248
- createElementVNode("div", _hoisted_21, [
1249
- createVNode(unref(Btn), {
1250
- outline: "",
1251
- value: "Try Again",
1252
- to: "/login"
1253
- }),
1254
- createVNode(unref(Btn), {
1255
- value: "Go Home",
1256
- to: "/"
1257
- })
1258
- ])
1259
- ])
1260
- ])) : createCommentVNode("", true)
1261
- ];
1262
- }),
1263
- _: 1
1264
- })
1265
- ]);
1266
- };
1267
- }
1268
- });
1269
- const _hoisted_1$3 = { class: "flex justify-content-center align-items-center min-vh-100 px-1 py-2" };
1270
- const _sfc_main$3 = /* @__PURE__ */ defineComponent({
1271
- __name: "ForgotPasswordPage",
1272
- props: {
1273
- texts: {},
1274
- cardWidth: { default: "450px" },
1275
- cardShadow: { type: Boolean, default: true }
1276
- },
1277
- setup(__props) {
1278
- const router2 = useRouter();
1279
- function switchForm(form) {
1280
- if (form === "login") {
1281
- router2.push("/login");
1282
- }
1283
- }
1284
- return (_ctx, _cache) => {
1285
- return openBlock(), createElementBlock("div", _hoisted_1$3, [
1286
- createVNode(unref(Card), {
1287
- class: normalizeClass([{ shadow: _ctx.cardShadow }, "p-2"]),
1288
- style: normalizeStyle({ width: _ctx.cardWidth, maxWidth: "100%" })
1289
- }, {
1290
- default: withCtx(() => [
1291
- createVNode(_sfc_main$8, {
1292
- texts: _ctx.texts,
1293
- onSwitchForm: switchForm
1294
- }, null, 8, ["texts"])
1295
- ]),
1296
- _: 1
1297
- }, 8, ["class", "style"])
1298
- ]);
1299
- };
1300
- }
1301
- });
1302
- const _hoisted_1$2 = { class: "flex justify-content-center align-items-center min-vh-100 px-1 py-2" };
1303
- const _sfc_main$2 = /* @__PURE__ */ defineComponent({
1304
- __name: "LoginPage",
1305
- props: {
1306
- texts: {},
1307
- github: { type: Boolean, default: true },
1308
- google: { type: Boolean, default: true },
1309
- microsoft: { type: Boolean, default: true },
1310
- apple: { type: Boolean, default: true },
1311
- okta: { type: Boolean, default: true },
1312
- facebook: { type: Boolean, default: true },
1313
- ssoOutline: { type: Boolean, default: true },
1314
- ssoShowValue: { type: Boolean, default: true },
1315
- ssoBrandBackground: { type: Boolean, default: true },
1316
- showForgotPassword: { type: Boolean, default: true },
1317
- showSignupButton: { type: Boolean, default: true },
1318
- cardWidth: { default: "450px" },
1319
- cardShadow: { type: Boolean, default: true }
1320
- },
1321
- setup(__props) {
1322
- const router2 = useRouter();
1323
- function switchForm(form) {
1324
- if (form === "signup") {
1325
- router2.push("/signup");
1326
- } else if (form === "forgot-password") {
1327
- router2.push("/forgot-password");
1328
- }
1329
- }
1330
- return (_ctx, _cache) => {
1331
- return openBlock(), createElementBlock("div", _hoisted_1$2, [
1332
- createVNode(unref(Card), {
1333
- class: normalizeClass([{ shadow: _ctx.cardShadow }, "p-2"]),
1334
- style: normalizeStyle({ width: _ctx.cardWidth, maxWidth: "100%" })
1335
- }, {
1336
- default: withCtx(() => [
1337
- createVNode(_sfc_main$7, {
1338
- texts: _ctx.texts,
1339
- github: _ctx.github,
1340
- google: _ctx.google,
1341
- microsoft: _ctx.microsoft,
1342
- apple: _ctx.apple,
1343
- okta: _ctx.okta,
1344
- facebook: _ctx.facebook,
1345
- "sso-outline": _ctx.ssoOutline,
1346
- "sso-show-value": _ctx.ssoShowValue,
1347
- "sso-brand-background": _ctx.ssoBrandBackground,
1348
- "show-forgot-password": _ctx.showForgotPassword,
1349
- "show-signup-button": _ctx.showSignupButton,
1350
- onSwitchForm: switchForm
1351
- }, null, 8, ["texts", "github", "google", "microsoft", "apple", "okta", "facebook", "sso-outline", "sso-show-value", "sso-brand-background", "show-forgot-password", "show-signup-button"])
1352
- ]),
1353
- _: 1
1354
- }, 8, ["class", "style"])
1355
- ]);
1356
- };
1357
- }
1358
- });
1359
- const _hoisted_1$1 = { class: "flex justify-content-center align-items-center min-vh-100 px-1 py-2" };
1360
- const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1361
- __name: "ResetPasswordPage",
1362
- props: {
1363
- texts: {},
1364
- cardWidth: { default: "450px" },
1365
- cardShadow: { type: Boolean, default: true }
1366
- },
1367
- setup(__props) {
1368
- const router2 = useRouter();
1369
- const route = useRoute();
1370
- const token = computed(() => route.query.token);
1371
- function switchForm(form) {
1372
- if (form === "login") {
1373
- router2.push("/login");
1374
- }
1375
- }
1376
- return (_ctx, _cache) => {
1377
- return openBlock(), createElementBlock("div", _hoisted_1$1, [
1378
- createVNode(unref(Card), {
1379
- class: normalizeClass([{ shadow: _ctx.cardShadow }, "p-2"]),
1380
- style: normalizeStyle({ width: _ctx.cardWidth, maxWidth: "100%" })
1381
- }, {
1382
- default: withCtx(() => [
1383
- createVNode(_sfc_main$6, {
1384
- texts: _ctx.texts,
1385
- token: token.value,
1386
- onSwitchForm: switchForm
1387
- }, null, 8, ["texts", "token"])
1388
- ]),
1389
- _: 1
1390
- }, 8, ["class", "style"])
1391
- ]);
1392
- };
1393
- }
1394
- });
1395
- const _hoisted_1 = { class: "flex justify-content-center align-items-center min-vh-100 px-1 py-2" };
1396
- const _sfc_main = /* @__PURE__ */ defineComponent({
1397
- __name: "SignupPage",
1398
- props: {
1399
- texts: {},
1400
- showNames: { type: Boolean, default: true },
1401
- cardWidth: { default: "450px" },
1402
- cardShadow: { type: Boolean, default: true }
1403
- },
1404
- setup(__props) {
1405
- const router2 = useRouter();
1406
- function switchForm(form) {
1407
- if (form === "login") {
1408
- router2.push("/login");
1409
- }
1410
- }
1411
- return (_ctx, _cache) => {
1412
- return openBlock(), createElementBlock("div", _hoisted_1, [
1413
- createVNode(unref(Card), {
1414
- class: normalizeClass([{ shadow: _ctx.cardShadow }, "p-2"]),
1415
- style: normalizeStyle({ width: _ctx.cardWidth, maxWidth: "100%" })
1416
- }, {
1417
- default: withCtx(() => [
1418
- createVNode(_sfc_main$5, {
1419
- texts: _ctx.texts,
1420
- "show-names": _ctx.showNames,
1421
- onSwitchForm: switchForm
1422
- }, null, 8, ["texts", "show-names"])
1423
- ]),
1424
- _: 1
1425
- }, 8, ["class", "style"])
1426
- ]);
1427
- };
1428
- }
1429
- });
1430
396
  function getRedirectUrl(router2, config) {
1431
397
  const redirect2 = router2.currentRoute.value.query[config.queryKey];
1432
398
  return redirect2 || config.fallback;
@@ -1650,7 +616,7 @@ function createSSOProvider(config) {
1650
616
  const auth = getAuthApi();
1651
617
  const redirectUri = options.redirectUri ?? getDefaultRedirectUri();
1652
618
  const state = options.state ?? generateState();
1653
- const timeout2 = options.popupTimeout ?? 9e4;
619
+ const timeout = options.popupTimeout ?? 9e4;
1654
620
  if (typeof window !== "undefined" && typeof sessionStorage !== "undefined") {
1655
621
  const currentParams = queryParams();
1656
622
  const redirectUrl = currentParams.redirect;
@@ -1673,7 +639,7 @@ function createSSOProvider(config) {
1673
639
  if (!popupWindow) {
1674
640
  throw new PopupBlockedError();
1675
641
  }
1676
- const result = await waitForPopupCallback(popupWindow, config.id, timeout2);
642
+ const result = await waitForPopupCallback(popupWindow, config.id, timeout);
1677
643
  return auth.loginWithSSO(config.id, {
1678
644
  code: result.code,
1679
645
  state: result.state ?? generateState()
@@ -2242,6 +1208,60 @@ function useAuth() {
2242
1208
  function getCurrentTenant() {
2243
1209
  return currentTenant.value;
2244
1210
  }
1211
+ async function createTenant(data) {
1212
+ const { data: tenant } = await api.createTenant(data);
1213
+ await loadTenants();
1214
+ return tenant;
1215
+ }
1216
+ async function updateTenant(tenantId, data) {
1217
+ const { data: tenant } = await api.updateTenant(tenantId, data);
1218
+ await loadTenants();
1219
+ return tenant;
1220
+ }
1221
+ async function deleteTenant(tenantId) {
1222
+ var _a;
1223
+ await api.deleteTenant(tenantId);
1224
+ if (((_a = currentTenant.value) == null ? void 0 : _a.id) === tenantId) {
1225
+ currentTenant.value = null;
1226
+ api.setTenantId(null);
1227
+ }
1228
+ await loadTenants();
1229
+ }
1230
+ async function getTenantMembers(tenantId, status) {
1231
+ const { data } = await api.getTenantMembers(tenantId, status);
1232
+ return data;
1233
+ }
1234
+ async function addTenantMember(tenantId, member) {
1235
+ const { data } = await api.addTenantMember(tenantId, member);
1236
+ return data;
1237
+ }
1238
+ async function updateTenantMember(tenantId, identityId, updates) {
1239
+ const { data } = await api.updateTenantMember(tenantId, identityId, updates);
1240
+ return data;
1241
+ }
1242
+ async function activateTenantMember(tenantId, identityId) {
1243
+ const { data } = await api.activateTenantMember(tenantId, identityId);
1244
+ return data;
1245
+ }
1246
+ async function removeTenantMember(tenantId, identityId) {
1247
+ await api.removeTenantMember(tenantId, identityId);
1248
+ }
1249
+ async function getTenantRoles() {
1250
+ const { data } = await api.getTenantRoles();
1251
+ return data;
1252
+ }
1253
+ async function createInvitation(data) {
1254
+ const { data: invitation } = await api.createInvitation(data);
1255
+ return invitation;
1256
+ }
1257
+ async function getInvitation(token) {
1258
+ const { data } = await api.getInvitation(token);
1259
+ return data;
1260
+ }
1261
+ async function acceptInvitation(token, data) {
1262
+ await api.acceptInvitation(token, data);
1263
+ await checkAuth();
1264
+ }
2245
1265
  async function signup(newUser) {
2246
1266
  const hasPassword = newUser.password !== void 0 && newUser.password.length > 0;
2247
1267
  if (hasPassword && newUser.password !== newUser.confirmPassword) {
@@ -2378,7 +1398,22 @@ function useAuth() {
2378
1398
  // Multi-Tenancy Actions
2379
1399
  loadTenants,
2380
1400
  setTenant,
2381
- switchTenant
1401
+ switchTenant,
1402
+ // Tenant CRUD (requires tenancy: true)
1403
+ createTenant,
1404
+ updateTenant,
1405
+ deleteTenant,
1406
+ // Tenant Members
1407
+ getTenantMembers,
1408
+ addTenantMember,
1409
+ updateTenantMember,
1410
+ activateTenantMember,
1411
+ removeTenantMember,
1412
+ getTenantRoles,
1413
+ // Invitations
1414
+ createInvitation,
1415
+ getInvitation,
1416
+ acceptInvitation
2382
1417
  };
2383
1418
  }
2384
1419
  const useAuth$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
@@ -2449,58 +1484,6 @@ const router = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProper
2449
1484
  composeGuards,
2450
1485
  resetAuthState
2451
1486
  }, Symbol.toStringTag, { value: "Module" }));
2452
- function createAuthRoutes(config = {}) {
2453
- const {
2454
- basePath = "",
2455
- namePrefix = "",
2456
- routeNames = {},
2457
- layout
2458
- } = config;
2459
- const createRouteName = (name) => namePrefix ? `${namePrefix}${name}` : name;
2460
- const routes = [
2461
- {
2462
- path: `${basePath}/login`,
2463
- name: routeNames.login || createRouteName("Login"),
2464
- component: () => import("./LoginPage-klj1NV4J.js"),
2465
- meta: { requiresAuth: false }
2466
- },
2467
- {
2468
- path: `${basePath}/signup`,
2469
- name: routeNames.signup || createRouteName("Signup"),
2470
- component: () => import("./SignupPage-oUFYApYW.js"),
2471
- meta: { requiresAuth: false }
2472
- },
2473
- {
2474
- path: `${basePath}/forgot-password`,
2475
- name: routeNames.forgotPassword || createRouteName("ForgotPassword"),
2476
- component: () => import("./ForgotPasswordPage-DvttMGb0.js"),
2477
- meta: { requiresAuth: false }
2478
- },
2479
- {
2480
- path: `${basePath}/reset-password`,
2481
- name: routeNames.resetPassword || createRouteName("ResetPassword"),
2482
- component: () => import("./ResetPasswordPage-nvQ4uupb.js"),
2483
- meta: { requiresAuth: false }
2484
- },
2485
- {
2486
- path: `${basePath}/callback`,
2487
- name: routeNames.callback || createRouteName("AuthCallback"),
2488
- component: () => import("./Callback-C-XghN_z.js"),
2489
- meta: { requiresAuth: false }
2490
- }
2491
- ];
2492
- if (layout) {
2493
- return [{
2494
- path: basePath,
2495
- component: layout,
2496
- children: routes.map((route) => ({
2497
- ...route,
2498
- path: route.path.replace(basePath, "")
2499
- }))
2500
- }];
2501
- }
2502
- return routes;
2503
- }
2504
1487
  function createAuthGuard(config = {}) {
2505
1488
  const { redirectTo = "/" } = config;
2506
1489
  return async (to, _from, next) => {
@@ -2516,22 +1499,13 @@ function createAuthGuard(config = {}) {
2516
1499
  export {
2517
1500
  AuthApi,
2518
1501
  AuthState,
2519
- _sfc_main$4 as Callback,
2520
1502
  DEFAULT_AGENT_ID,
2521
1503
  DEFAULT_REDIRECT_CONFIG,
2522
- _sfc_main$8 as ForgotPasswordForm,
2523
- _sfc_main$3 as ForgotPasswordPage,
2524
1504
  INTAKE_WORKFLOW_ID,
2525
- _sfc_main$7 as LoginForm,
2526
- _sfc_main$2 as LoginPage,
2527
1505
  PopupBlockedError,
2528
1506
  PopupClosedError,
2529
1507
  PopupTimeoutError,
2530
- _sfc_main$6 as ResetPasswordForm,
2531
- _sfc_main$1 as ResetPasswordPage,
2532
1508
  SSOError,
2533
- _sfc_main$5 as SignupForm,
2534
- _sfc_main as SignupPage,
2535
1509
  StateMismatchError,
2536
1510
  accountToUser,
2537
1511
  authGuard,
@@ -2539,7 +1513,6 @@ export {
2539
1513
  composeGuards,
2540
1514
  createAuth,
2541
1515
  createAuthGuard,
2542
- createAuthRoutes,
2543
1516
  getAllSSOProviders,
2544
1517
  getRedirectConfig,
2545
1518
  getRedirectUrl,