@hiai-gg/docsmint 0.7.4 → 0.7.6
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.md +2 -2
- package/dist/backend/index.js +130026 -129609
- package/dist/backend-account-runtime-cleanup.js +2 -0
- package/dist/backend-api-key-facade.js +2 -0
- package/dist/backend-pipeline-cancellation.js +2 -0
- package/dist/frontend/CategoryDialog-D_xFSWGh.js +630 -0
- package/dist/frontend/ConfirmDialog-Cfq3D2Di.js +221 -0
- package/dist/frontend/{CreateSnapshotDialog-CojnWChs.js → CreateSnapshotDialog-BHODxZWK.js} +53 -52
- package/dist/frontend/{DatePicker-7FAbIOGg.js → DatePicker-CZyCnQ1q.js} +62 -64
- package/dist/frontend/{DeleteDialog-BIlqRb1u.js → DeleteDialog-DaJOO6SB.js} +17 -17
- package/dist/frontend/FolderNode-C_91NlEO.js +307 -0
- package/dist/frontend/{FolderTreeSelector-BMB1MS9N.js → FolderTreeSelector-DqO-f0nt.js} +7 -7
- package/dist/frontend/HiAiEditor-DtUGbQg6.js +3160 -0
- package/dist/frontend/{HiaiDocsExtensionProvider-OSn96BBw.js → HiaiDocsExtensionProvider-Cc3yzW5I.js} +5 -3
- package/dist/frontend/{Icon-Db-o32_E.js → Icon-y7xxAIC6.js} +1 -1
- package/dist/frontend/{SettingsDialog-DatuxOVX.js → SettingsDialog-BlIZqk2-.js} +169 -158
- package/dist/frontend/ShareDialog-CmX-VoJ9.js +273 -0
- package/dist/frontend/Sidebar-BVGm5BRR.js +2147 -0
- package/dist/frontend/{TagCreateDialog-Ch21yuWV.js → TagCreateDialog-BlGz4O9Z.js} +45 -36
- package/dist/frontend/action_cancel-Cuxsznzz.js +5 -0
- package/dist/frontend/action_close-BJm_52wm.js +5 -0
- package/dist/frontend/action_create-CtBQrRuj.js +5 -0
- package/dist/frontend/action_delete-BXBIzvn0.js +5 -0
- package/dist/frontend/action_go_to-VmK5jmEk.js +5 -0
- package/dist/frontend/action_loading-BLCGJVA9.js +5 -0
- package/dist/frontend/action_save-BRN2Z_GP.js +5 -0
- package/dist/frontend/api/attachments.js +1 -1
- package/dist/frontend/api/categories.js +1 -1
- package/dist/frontend/api/folders.js +1 -1
- package/dist/frontend/api/settings.js +1 -1
- package/dist/frontend/api/share.js +1 -1
- package/dist/frontend/api/tags.js +1 -1
- package/dist/frontend/app-shell.js +8 -8
- package/dist/frontend/{attachments-B2aH3hXF.js → attachments-C225gTA7.js} +2 -2
- package/dist/frontend/{auth-client-CnDZwPfp.js → auth-client-DCMne8vd.js} +630 -615
- package/dist/frontend/{bundle-mjs-DllmqUxV.js → bundle-mjs-CZ3g1Uzr.js} +35 -42
- package/dist/frontend/{camera-CzCxBOpc.js → camera-BI-BtnIm.js} +2 -2
- package/dist/frontend/{categories-X7gK8azc.js → categories-Bjcc41We.js} +1 -1
- package/dist/frontend/categories_update_error-4aSI8PTr.js +5 -0
- package/dist/frontend/{check-BIi-Ghti.js → check-sdTlLwi9.js} +2 -2
- package/dist/frontend/{chevron-down-C2ft7XUV.js → chevron-down-DlBnIE7Y.js} +2 -2
- package/dist/frontend/{circle-check-BrqfiQH1.js → circle-check-hWC-HeKu.js} +2 -2
- package/dist/frontend/{clock-Dz86E4Kz.js → clock-C4FHq-9q.js} +2 -2
- package/dist/frontend/collaboration.js +208 -103
- package/dist/frontend/components/category-dialog.js +1 -1
- package/dist/frontend/components/create-snapshot-dialog.js +1 -1
- package/dist/frontend/components/delete-dialog.js +1 -1
- package/dist/frontend/components/editor/compact-editor.js +1 -1
- package/dist/frontend/components/editor/document-editor.js +1 -1
- package/dist/frontend/components/editor/document-title.js +3 -2
- package/dist/frontend/components/editor/docx-serializer.js +140 -125
- package/dist/frontend/components/editor/extensions.js +1 -1
- package/dist/frontend/components/editor/markdown-toggle.js +9 -9
- package/dist/frontend/components/editor/markdown.js +1 -1
- package/dist/frontend/components/folder-node.js +1 -1
- package/dist/frontend/components/folder-tree-selector.js +1 -1
- package/dist/frontend/components/save-as-dialog.js +34 -25
- package/dist/frontend/components/settings.js +1 -1
- package/dist/frontend/components/share-dialog.js +1 -1
- package/dist/frontend/components/sidebar.js +1 -1
- package/dist/frontend/components/tag-create-dialog.js +1 -1
- package/dist/frontend/components/version-history.js +181 -176
- package/dist/frontend/{confirm-dialog-8T6vsWL7.js → confirm-dialog-BFTxjLv-.js} +46 -37
- package/dist/frontend/{copy-CvCh4ZVt.js → copy-4H99lwAQ.js} +2 -2
- package/dist/frontend/dashboard.js +462 -456
- package/dist/frontend/{db-Bo1t_76T.js → db-CbFRFAm2.js} +40 -38
- package/dist/frontend/{dialog-CiSwD-_v.js → dialog-tHAH3-9M.js} +10 -10
- package/dist/frontend/dist-Cg1BpNS7.js +2262 -0
- package/dist/frontend/dndzone-BrakBHwm.js +1375 -0
- package/dist/frontend/doc_title_label-DS9jSIh2.js +5 -0
- package/dist/frontend/doc_title_placeholder-DBQpM1aH.js +5 -0
- package/dist/frontend/{document-drop-coordinator-C4xHMjwC.js → document-drop-coordinator-Da7HcXgv.js} +1 -1
- package/dist/frontend/document-drop-coordinator.js +1 -1
- package/dist/frontend/{dropdown-menu-Bi5Iipwf.js → dropdown-menu-AJYeFPHu.js} +145 -145
- package/dist/frontend/{editor-content-sanitizer-CC_A8aaI.js → editor-content-sanitizer-CWjqiz0T.js} +30 -30
- package/dist/frontend/{editorExtensions--HusV819.js → editorExtensions-B-mKiWqq.js} +5085 -6220
- package/dist/frontend/editor_markdown_placeholder-BIWDUF1E.js +5 -0
- package/dist/frontend/error_dismiss-Dx_JbRjs.js +5 -0
- package/dist/frontend/error_generic-CzNtmBT4.js +5 -0
- package/dist/frontend/extension.js +1 -1
- package/dist/frontend/{folder-Cx60MRpi.js → folder-BAX6qBYy.js} +3 -3
- package/dist/frontend/{folders-ONG03Dkv.js → folders-CC0UWkZH.js} +3 -3
- package/dist/frontend/folders_rename-BJo4Gipq.js +5 -0
- package/dist/frontend/i18n.js +1007 -6
- package/dist/frontend/{identity-Ynrglr5i.js → identity-O4lAuchv.js} +2 -2
- package/dist/frontend/{input-N9dNSOWF.js → input-CrlYAH2S.js} +2 -2
- package/dist/frontend/{label-CK72_fw8.js → label-B0syEfns.js} +2 -2
- package/dist/frontend/{markdown-H6QB53zu.js → markdown-CMij27Gg.js} +1 -1
- package/dist/frontend/offline/identity.js +1 -1
- package/dist/frontend/{floating-layer-anchor-BGIndLY-.js → popper-layer-force-mount-BAYjg6Pp.js} +2476 -2564
- package/dist/frontend/{rolldown-runtime-CWhphoD1.js → rolldown-runtime-DArdT4gl.js} +2 -2
- package/dist/frontend/{rotate-ccw-ta4NosZ0.js → rotate-ccw-DtZDfSK3.js} +2 -2
- package/dist/frontend/runtime-CwWSo6c9.js +128 -0
- package/dist/frontend/{schemas-DwtKylCJ.js → schemas-CdPhcuru.js} +6 -7
- package/dist/frontend/scroll_to_top_aria-CvkNF_Hu.js +5 -0
- package/dist/frontend/search.js +237 -265
- package/dist/frontend/search_title-DOC0cPlQ.js +5 -0
- package/dist/frontend/{select-value-BD1DToYs.js → select-value-D9VqY5n5.js} +575 -572
- package/dist/frontend/{settings-BR48ihB4.js → settings-DJW8JkdF.js} +1 -1
- package/dist/frontend/{share-D7JtkC85.js → share-D5yo0JOh.js} +2 -1
- package/dist/frontend/share_copied-DPxVzfWh.js +5 -0
- package/dist/frontend/share_toggle_password-DdxfIjj1.js +5 -0
- package/dist/frontend/shared-document.js +1 -1
- package/dist/frontend/sidebar_uncategorized-qJ2_Aonf.js +5 -0
- package/dist/frontend/sort_relevance-DwYX5MO9.js +5 -0
- package/dist/frontend/{tag-DhVFHMcV.js → tag-ChpMfbfa.js} +3 -3
- package/dist/frontend/{tags-BdCaMGfj.js → tags-CzPNUoFw.js} +1 -1
- package/dist/frontend/tags_load_error-BKjA1pI0.js +5 -0
- package/dist/frontend/tags_new-BiNAJ9Bx.js +5 -0
- package/dist/frontend/{textarea-pl_fDBre.js → textarea-l_gRXsrH.js} +2 -2
- package/dist/frontend/theme.js +1 -1
- package/dist/frontend/{theme.svelte-DG3RS7wv.js → theme.svelte-Bzitjfh9.js} +2 -2
- package/dist/frontend/theme_system-BBNUhYKh.js +5 -0
- package/dist/frontend/utils/dndzone.js +1 -1
- package/dist/frontend/utils-B4LKx7VS.js +7 -0
- package/dist/frontend/{utils-DrfHTcei.js → utils-BovMJHdA.js} +2 -2
- package/dist/frontend/utils.js +1 -1
- package/dist/frontend/version_create_snapshot-3bu-0qzH.js +5 -0
- package/dist/frontend/version_restored_from-dVRN3Zdk.js +5 -0
- package/dist/frontend/version_snapshot_label_placeholder-DrMikux0.js +5 -0
- package/dist/frontend/weekday_we-C5H_M-df.js +5 -0
- package/dist/frontend/{x-cfdlccjs.js → x-B2ifxSH7.js} +2 -2
- package/dist/frontend/{awareness-snQ3RD9f.js → yjs-VUcKqaKW.js} +835 -944
- package/dist/frontend-ssr/api/attachments.js +92 -1
- package/dist/frontend-ssr/api/categories.js +1 -1
- package/dist/frontend-ssr/api/documents.js +1 -1
- package/dist/frontend-ssr/api/folders.js +1 -1
- package/dist/frontend-ssr/api/settings.js +1 -1
- package/dist/frontend-ssr/api/share.js +30 -1
- package/dist/frontend-ssr/api/tags.js +1 -1
- package/dist/frontend-ssr/app-shell.js +25 -18
- package/dist/frontend-ssr/assets/{CategoryDialog-DsXe54EF.js → CategoryDialog-C41IBNWG.js} +26 -35
- package/dist/frontend-ssr/assets/ConfirmDialog-CWO0HBaS.js +424 -0
- package/dist/frontend-ssr/assets/{CreateSnapshotDialog-D3-PjXVr.js → CreateSnapshotDialog-CECCRK0d.js} +12 -18
- package/dist/frontend-ssr/assets/{DatePicker-C9suIA1S.js → DatePicker-TZVeMZ2S.js} +32 -20
- package/dist/frontend-ssr/assets/{DeleteDialog-DxtMrS1O.js → DeleteDialog-BVnmzR2e.js} +5 -7
- package/dist/frontend-ssr/assets/{FolderNode-ChD10Elp.js → FolderNode-CClgk8BL.js} +7 -7
- package/dist/frontend-ssr/assets/{FolderTreeSelector-Bxi8EqMm.js → FolderTreeSelector-DnrKCYtl.js} +17 -20
- package/dist/frontend-ssr/assets/{HiAiEditor-2X3Uyg1B.js → HiAiEditor-_-m7MJDd.js} +330 -254
- package/dist/frontend-ssr/assets/{Icon-QwirKi9Y.js → Icon-Clqe8D8X.js} +28 -16
- package/dist/frontend-ssr/assets/{SettingsDialog-DDy0hN8x.js → SettingsDialog-BdvHRAxF.js} +45 -49
- package/dist/frontend-ssr/assets/{ShareDialog-BwW_wF4G.js → ShareDialog-DHPbSHZg.js} +5 -6
- package/dist/frontend-ssr/assets/{Sidebar-Dy-5gXOf.js → Sidebar-B3Saqn0O.js} +90 -93
- package/dist/frontend-ssr/assets/{TagCreateDialog-BPzgOaX8.js → TagCreateDialog-CPg-nG0D.js} +14 -14
- package/dist/frontend-ssr/assets/action_cancel-OVgQDP5Q.js +22 -0
- package/dist/frontend-ssr/assets/action_close-DagDyMXk.js +22 -0
- package/dist/frontend-ssr/assets/action_create-hqJWjyqh.js +22 -0
- package/dist/frontend-ssr/assets/action_delete-B1-16jSo.js +22 -0
- package/dist/frontend-ssr/assets/action_go_to-DQScgw7P.js +22 -0
- package/dist/frontend-ssr/assets/action_save-Bx7vlLZI.js +22 -0
- package/dist/frontend-ssr/assets/{api-keys-DIbclwj5.js → api-keys-CHOrbU-Q.js} +1 -1
- package/dist/frontend-ssr/assets/{auth-client-CojKIzqy.js → auth-client-DzkZlSQ8.js} +295 -261
- package/dist/frontend-ssr/assets/{camera-D6s20LDi.js → camera-Dwwtgvfn.js} +10 -6
- package/dist/frontend-ssr/assets/{categories-av9xjeg5.js → categories-C_dxFoHi.js} +1 -1
- package/dist/frontend-ssr/assets/categories_update_error-DkKgsqdD.js +202 -0
- package/dist/frontend-ssr/assets/{chevron-down-CvqKATjM.js → chevron-down-C6BTPJFz.js} +10 -6
- package/dist/frontend-ssr/assets/{chevron-right-DKD7WXjz.js → chevron-right-CseGE1qd.js} +10 -6
- package/dist/frontend-ssr/assets/{circle-check-CPS9dKEo.js → circle-check-BRhWPZo1.js} +10 -6
- package/dist/frontend-ssr/assets/{client-DZMkDkDn.js → client-rfwQYYHY.js} +4 -2
- package/dist/frontend-ssr/assets/{clock-CzsE58TH.js → clock-DpP_Y7WP.js} +10 -6
- package/dist/frontend-ssr/assets/{confirm-dialog-wYC07DPx.js → confirm-dialog-DeOR0SnQ.js} +44 -31
- package/dist/frontend-ssr/assets/{copy-DkkCPkBL.js → copy-DRMKiRZ0.js} +10 -6
- package/dist/frontend-ssr/assets/{db-BhwJPEkn.js → db-CUkQe9AU.js} +1 -1
- package/dist/frontend-ssr/assets/{dialog-ClcuF7nD.js → dialog--tDgDGw9.js} +12 -15
- package/dist/frontend-ssr/assets/{dndzone-DMvTO_Jz.js → dndzone-WtNaDxoQ.js} +309 -77
- package/dist/frontend-ssr/assets/doc_title_label-Ev_ltlh3.js +22 -0
- package/dist/frontend-ssr/assets/doc_title_placeholder-DSHpUb7w.js +22 -0
- package/dist/frontend-ssr/assets/{documents-CZ-wQohy.js → documents-CEuA1V6N.js} +1 -1
- package/dist/frontend-ssr/assets/{dropdown-menu-BKMGVNLL.js → dropdown-menu-CdEpn_LT.js} +74 -75
- package/dist/frontend-ssr/assets/editor_markdown_placeholder-BpezdkOr.js +42 -0
- package/dist/frontend-ssr/assets/editor_toolbar_undo-CKJAOqv2.js +562 -0
- package/dist/frontend-ssr/assets/error_generic-DTK0kwxT.js +42 -0
- package/dist/frontend-ssr/assets/{folder-DYIE-XPP.js → folder-DszunwKc.js} +10 -6
- package/dist/frontend-ssr/assets/{folders-BX30gHv6.js → folders-BOXeb9hz.js} +3 -2
- package/dist/frontend-ssr/assets/folders_rename-DvciOb6K.js +122 -0
- package/dist/frontend-ssr/assets/{identity-DcMMBKWg.js → identity-veXobEfE.js} +2 -2
- package/dist/frontend-ssr/assets/{input-DcDR8L8M.js → input-BlAj7LzC.js} +2 -2
- package/dist/frontend-ssr/assets/{label-Cz0_svJx.js → label-BRToaMg9.js} +2 -2
- package/dist/frontend-ssr/assets/{loader-circle-CIEWGyfP.js → loader-circle-BpRVrMZg.js} +10 -6
- package/dist/frontend-ssr/assets/{floating-layer-anchor-BoiiIEiK.js → popper-layer-force-mount-Djnq7l7a.js} +3684 -3674
- package/dist/frontend-ssr/assets/{rotate-ccw-dJSqPyTd.js → rotate-ccw-1GOD_yt_.js} +10 -6
- package/dist/frontend-ssr/assets/runtime-O78RzRqx.js +559 -0
- package/dist/frontend-ssr/assets/scroll_to_top_aria-BN4ZfOnM.js +22 -0
- package/dist/frontend-ssr/assets/search_title-CKUsQDT0.js +22 -0
- package/dist/frontend-ssr/assets/search_toggle_filters-hS9rvQhC.js +282 -0
- package/dist/frontend-ssr/assets/{select-value-CaDktvDW.js → select-value-BCWSsoTd.js} +204 -218
- package/dist/frontend-ssr/assets/{settings-Mp8EuFSn.js → settings-DwAcLGM1.js} +2 -2
- package/dist/frontend-ssr/assets/share_copied-BxU9rjXG.js +602 -0
- package/dist/frontend-ssr/assets/share_toggle_password-C6OmroqR.js +202 -0
- package/dist/frontend-ssr/assets/sidebar_uncategorized-Dx-LTd5w.js +102 -0
- package/dist/frontend-ssr/assets/{tag-BmiVU_Ej.js → tag-DFh6nF9R.js} +19 -11
- package/dist/frontend-ssr/assets/{tag-store.svelte-BM1lUI_P.js → tag-store.svelte-QRysvGKe.js} +1 -1
- package/dist/frontend-ssr/assets/{tags-BQsI_6OW.js → tags-BBCoFYro.js} +1 -1
- package/dist/frontend-ssr/assets/tags_load_error-CPrc6Gzs.js +362 -0
- package/dist/frontend-ssr/assets/tags_new-VmMr9v2V.js +62 -0
- package/dist/frontend-ssr/assets/{textarea-BGrjPOgU.js → textarea-BuszTo9i.js} +2 -2
- package/dist/frontend-ssr/assets/{theme.svelte-CN3BUhJG.js → theme.svelte-shZrSxz8.js} +1 -1
- package/dist/frontend-ssr/assets/theme_system-BucaNntV.js +362 -0
- package/dist/frontend-ssr/assets/{utils-Cg_R05dR.js → utils-BK35BJKQ.js} +1 -1
- package/dist/frontend-ssr/assets/version_create_snapshot-COHzwjle.js +22 -0
- package/dist/frontend-ssr/assets/version_restored_from-CertjFDl.js +242 -0
- package/dist/frontend-ssr/assets/version_snapshot_label_placeholder-Cy_rMCij.js +222 -0
- package/dist/frontend-ssr/assets/weekday_we-DrI3U230.js +422 -0
- package/dist/frontend-ssr/components/category-dialog.js +1 -1
- package/dist/frontend-ssr/components/create-snapshot-dialog.js +1 -1
- package/dist/frontend-ssr/components/delete-dialog.js +1 -1
- package/dist/frontend-ssr/components/editor/compact-editor.js +1 -1
- package/dist/frontend-ssr/components/editor/document-editor.js +1 -1
- package/dist/frontend-ssr/components/editor/document-title.js +2 -1
- package/dist/frontend-ssr/components/editor/markdown-toggle.js +2 -2
- package/dist/frontend-ssr/components/folder-node.js +1 -1
- package/dist/frontend-ssr/components/folder-tree-selector.js +1 -1
- package/dist/frontend-ssr/components/save-as-dialog.js +12 -14
- package/dist/frontend-ssr/components/settings.js +1 -1
- package/dist/frontend-ssr/components/share-dialog.js +1 -1
- package/dist/frontend-ssr/components/sidebar.js +1 -1
- package/dist/frontend-ssr/components/tag-create-dialog.js +1 -1
- package/dist/frontend-ssr/components/version-history.js +47 -51
- package/dist/frontend-ssr/dashboard.js +243 -232
- package/dist/frontend-ssr/i18n.js +6698 -1
- package/dist/frontend-ssr/offline/identity.js +1 -1
- package/dist/frontend-ssr/search.js +28 -31
- package/dist/frontend-ssr/shared-document.js +1 -2
- package/dist/frontend-ssr/theme.js +1 -1
- package/dist/frontend-ssr/utils/dndzone.js +1 -1
- package/dist/lifecycle-runtime.js +4437 -2019
- package/dist/mcp-cli.js +1 -1
- package/dist/mcp-server.js +1 -1
- package/package.json +7 -7
- package/packages/cli/src/index.ts +1 -1
- package/packages/db/src/schema.ts +2 -0
- package/server.json +2 -2
- package/dist/frontend/CategoryDialog-bQKMpVFD.js +0 -631
- package/dist/frontend/ConfirmDialog-DF7kgkyq.js +0 -139
- package/dist/frontend/FolderNode-Cf443LBa.js +0 -298
- package/dist/frontend/HiAiEditor-CMZ-eL8s.js +0 -2992
- package/dist/frontend/ShareDialog-Bwz2y3Le.js +0 -281
- package/dist/frontend/Sidebar-C_t5RrOJ.js +0 -2101
- package/dist/frontend/dist-DQa_OHOa.js +0 -268
- package/dist/frontend/dndzone-BzsOINtP.js +0 -1199
- package/dist/frontend/messages-DTRe4U2V.js +0 -1093
- package/dist/frontend/utils-CMQRlxbx.js +0 -7
- package/dist/frontend-ssr/assets/ConfirmDialog-DrH653ua.js +0 -136
- package/dist/frontend-ssr/assets/attachments-BdkOp8ha.js +0 -93
- package/dist/frontend-ssr/assets/messages-B1TjVIH8.js +0 -11147
- package/dist/frontend-ssr/assets/share-qTqvd6Lu.js +0 -30
|
@@ -1,171 +1,52 @@
|
|
|
1
|
+
import { STORE_UNMOUNT_DELAY, atom, onMount, onSet } from "nanostores";
|
|
1
2
|
import { env } from "@better-auth/core/env";
|
|
2
3
|
import { BetterAuthError } from "@better-auth/core/error";
|
|
3
4
|
import { isSafeUrlScheme } from "@better-auth/core/utils/url";
|
|
4
|
-
import { atom, onMount, onSet } from "nanostores";
|
|
5
5
|
import { capitalizeFirstLetter, toKebabCase } from "@better-auth/core/utils/string";
|
|
6
|
-
//#region ../node_modules/.bun/better-auth@1.
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
try {
|
|
15
|
-
return (trimTrailingSlashes(new URL(url).pathname) || "/") !== "/";
|
|
16
|
-
} catch {
|
|
17
|
-
throw new BetterAuthError(`Invalid base URL: ${url}. Please provide a valid base URL.`);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
function assertHasProtocol(url) {
|
|
21
|
-
try {
|
|
22
|
-
const parsedUrl = new URL(url);
|
|
23
|
-
if (parsedUrl.protocol !== "http:" && parsedUrl.protocol !== "https:") throw new BetterAuthError(`Invalid base URL: ${url}. URL must include 'http://' or 'https://'`);
|
|
24
|
-
} catch (error) {
|
|
25
|
-
if (error instanceof BetterAuthError) throw error;
|
|
26
|
-
throw new BetterAuthError(`Invalid base URL: ${url}. Please provide a valid base URL.`, { cause: error });
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
function withPath(url, path = "/api/auth") {
|
|
30
|
-
assertHasProtocol(url);
|
|
31
|
-
if (checkHasPath(url)) return url;
|
|
32
|
-
const trimmedUrl = trimTrailingSlashes(url);
|
|
33
|
-
if (!path || path === "/") return trimmedUrl;
|
|
34
|
-
path = path.startsWith("/") ? path : `/${path}`;
|
|
35
|
-
return `${trimmedUrl}${path}`;
|
|
36
|
-
}
|
|
37
|
-
function validateProxyHeader(header, type) {
|
|
38
|
-
if (!header || header.trim() === "") return false;
|
|
39
|
-
if (type === "proto") return header === "http" || header === "https";
|
|
40
|
-
if (type === "host") {
|
|
41
|
-
if ([
|
|
42
|
-
/\.\./,
|
|
43
|
-
/\0/,
|
|
44
|
-
/[\s]/,
|
|
45
|
-
/^[.]/,
|
|
46
|
-
/[<>'"]/,
|
|
47
|
-
/javascript:/i,
|
|
48
|
-
/file:/i,
|
|
49
|
-
/data:/i
|
|
50
|
-
].some((pattern) => pattern.test(header))) return false;
|
|
51
|
-
return /^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*(:[0-9]{1,5})?$/.test(header) || /^(\d{1,3}\.){3}\d{1,3}(:[0-9]{1,5})?$/.test(header) || /^\[[0-9a-fA-F:]+\](:[0-9]{1,5})?$/.test(header) || /^localhost(:[0-9]{1,5})?$/i.test(header);
|
|
52
|
-
}
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
function getBaseURL(url, path, request, loadEnv, trustedProxyHeaders) {
|
|
56
|
-
if (url) return withPath(url, path);
|
|
57
|
-
if (loadEnv !== false) {
|
|
58
|
-
const fromEnv = env.BETTER_AUTH_URL || env.NEXT_PUBLIC_BETTER_AUTH_URL || env.PUBLIC_BETTER_AUTH_URL || env.NUXT_PUBLIC_BETTER_AUTH_URL || env.NUXT_PUBLIC_AUTH_URL || (env.BASE_URL !== "/" ? env.BASE_URL : void 0);
|
|
59
|
-
if (fromEnv) return withPath(fromEnv, path);
|
|
60
|
-
}
|
|
61
|
-
const fromRequest = request?.headers.get("x-forwarded-host");
|
|
62
|
-
const fromRequestProto = request?.headers.get("x-forwarded-proto");
|
|
63
|
-
if (fromRequest && fromRequestProto && trustedProxyHeaders) {
|
|
64
|
-
if (validateProxyHeader(fromRequestProto, "proto") && validateProxyHeader(fromRequest, "host")) try {
|
|
65
|
-
return withPath(`${fromRequestProto}://${fromRequest}`, path);
|
|
66
|
-
} catch (_error) {}
|
|
67
|
-
}
|
|
68
|
-
if (request) {
|
|
69
|
-
const url = getOrigin(request.url);
|
|
70
|
-
if (!url) throw new BetterAuthError("Could not get origin from request. Please provide a valid base URL.");
|
|
71
|
-
return withPath(url, path);
|
|
72
|
-
}
|
|
73
|
-
if (typeof window !== "undefined" && window.location) return withPath(window.location.origin, path);
|
|
74
|
-
}
|
|
75
|
-
function getOrigin(url) {
|
|
76
|
-
try {
|
|
77
|
-
const parsedUrl = new URL(url);
|
|
78
|
-
return parsedUrl.origin === "null" ? null : parsedUrl.origin;
|
|
79
|
-
} catch {
|
|
80
|
-
return null;
|
|
6
|
+
//#region ../node_modules/.bun/better-auth@1.7.2+a913405242b7eb5a/node_modules/better-auth/dist/client/broadcast-channel.mjs
|
|
7
|
+
var kBroadcastChannel = Symbol.for("better-auth:broadcast-channel");
|
|
8
|
+
var now$1 = () => Math.floor(Date.now() / 1e3);
|
|
9
|
+
var WindowBroadcastChannel = class {
|
|
10
|
+
listeners = /* @__PURE__ */ new Set();
|
|
11
|
+
name;
|
|
12
|
+
constructor(name = "better-auth.message") {
|
|
13
|
+
this.name = name;
|
|
81
14
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
constructor: /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,
|
|
88
|
-
protoShort: /"__proto__"\s*:/,
|
|
89
|
-
constructorShort: /"constructor"\s*:/
|
|
90
|
-
};
|
|
91
|
-
var JSON_SIGNATURE = /^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;
|
|
92
|
-
var SPECIAL_VALUES = {
|
|
93
|
-
true: true,
|
|
94
|
-
false: false,
|
|
95
|
-
null: null,
|
|
96
|
-
undefined: void 0,
|
|
97
|
-
nan: NaN,
|
|
98
|
-
infinity: Number.POSITIVE_INFINITY,
|
|
99
|
-
"-infinity": Number.NEGATIVE_INFINITY
|
|
100
|
-
};
|
|
101
|
-
var ISO_DATE_REGEX = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;
|
|
102
|
-
function isValidDate(date) {
|
|
103
|
-
return date instanceof Date && !isNaN(date.getTime());
|
|
104
|
-
}
|
|
105
|
-
function parseISODate(value) {
|
|
106
|
-
const match = ISO_DATE_REGEX.exec(value);
|
|
107
|
-
if (!match) return null;
|
|
108
|
-
const [, year, month, day, hour, minute, second, ms, offsetSign, offsetHour, offsetMinute] = match;
|
|
109
|
-
const date = new Date(Date.UTC(parseInt(year, 10), parseInt(month, 10) - 1, parseInt(day, 10), parseInt(hour, 10), parseInt(minute, 10), parseInt(second, 10), ms ? parseInt(ms.padEnd(3, "0"), 10) : 0));
|
|
110
|
-
if (offsetSign) {
|
|
111
|
-
const offset = (parseInt(offsetHour, 10) * 60 + parseInt(offsetMinute, 10)) * (offsetSign === "+" ? -1 : 1);
|
|
112
|
-
date.setUTCMinutes(date.getUTCMinutes() + offset);
|
|
15
|
+
subscribe(listener) {
|
|
16
|
+
this.listeners.add(listener);
|
|
17
|
+
return () => {
|
|
18
|
+
this.listeners.delete(listener);
|
|
19
|
+
};
|
|
113
20
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
if (!JSON_SIGNATURE.test(trimmed)) {
|
|
123
|
-
if (strict) throw new SyntaxError("[better-json] Invalid JSON");
|
|
124
|
-
return value;
|
|
21
|
+
post(message) {
|
|
22
|
+
if (typeof window === "undefined") return;
|
|
23
|
+
try {
|
|
24
|
+
localStorage.setItem(this.name, JSON.stringify({
|
|
25
|
+
...message,
|
|
26
|
+
timestamp: now$1()
|
|
27
|
+
}));
|
|
28
|
+
} catch {}
|
|
125
29
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
if (parseDates && typeof value === "string") {
|
|
138
|
-
const date = parseISODate(value);
|
|
139
|
-
if (date) return date;
|
|
140
|
-
}
|
|
141
|
-
return reviver ? reviver(key, value) : value;
|
|
30
|
+
setup() {
|
|
31
|
+
if (typeof window === "undefined" || typeof window.addEventListener === "undefined") return () => {};
|
|
32
|
+
const handler = (event) => {
|
|
33
|
+
if (event.key !== this.name) return;
|
|
34
|
+
const message = JSON.parse(event.newValue ?? "{}");
|
|
35
|
+
if (message?.event !== "session" || !message?.data) return;
|
|
36
|
+
this.listeners.forEach((listener) => listener(message));
|
|
37
|
+
};
|
|
38
|
+
window.addEventListener("storage", handler);
|
|
39
|
+
return () => {
|
|
40
|
+
window.removeEventListener("storage", handler);
|
|
142
41
|
};
|
|
143
|
-
return JSON.parse(trimmed, secureReviver);
|
|
144
|
-
} catch (error) {
|
|
145
|
-
if (strict) throw error;
|
|
146
|
-
return value;
|
|
147
42
|
}
|
|
148
|
-
}
|
|
149
|
-
function parseJSON(value, options = { strict: true }) {
|
|
150
|
-
return betterJSONParse(value, options);
|
|
151
|
-
}
|
|
152
|
-
//#endregion
|
|
153
|
-
//#region ../node_modules/.bun/better-auth@1.6.22+81bceec6070f2f33/node_modules/better-auth/dist/client/fetch-plugins.mjs
|
|
154
|
-
var redirectPlugin = {
|
|
155
|
-
id: "redirect",
|
|
156
|
-
name: "Redirect",
|
|
157
|
-
hooks: { onSuccess(context) {
|
|
158
|
-
if (context.data?.url && context.data?.redirect && isSafeUrlScheme(context.data.url)) {
|
|
159
|
-
if (typeof window !== "undefined" && window.location) {
|
|
160
|
-
if (window.location) try {
|
|
161
|
-
window.location.href = context.data.url;
|
|
162
|
-
} catch {}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
} }
|
|
166
43
|
};
|
|
44
|
+
function getGlobalBroadcastChannel(name = "better-auth.message") {
|
|
45
|
+
if (!globalThis[kBroadcastChannel]) globalThis[kBroadcastChannel] = new WindowBroadcastChannel(name);
|
|
46
|
+
return globalThis[kBroadcastChannel];
|
|
47
|
+
}
|
|
167
48
|
//#endregion
|
|
168
|
-
//#region ../node_modules/.bun/better-auth@1.
|
|
49
|
+
//#region ../node_modules/.bun/better-auth@1.7.2+a913405242b7eb5a/node_modules/better-auth/dist/client/equality.mjs
|
|
169
50
|
function isPlainObject$1(value) {
|
|
170
51
|
if (typeof value !== "object" || value === null) return false;
|
|
171
52
|
const prototype = Object.getPrototypeOf(value);
|
|
@@ -205,50 +86,7 @@ function withEquality(store, isEqual) {
|
|
|
205
86
|
});
|
|
206
87
|
}
|
|
207
88
|
//#endregion
|
|
208
|
-
//#region ../node_modules/.bun/better-auth@1.
|
|
209
|
-
var kBroadcastChannel = Symbol.for("better-auth:broadcast-channel");
|
|
210
|
-
var now$1 = () => Math.floor(Date.now() / 1e3);
|
|
211
|
-
var WindowBroadcastChannel = class {
|
|
212
|
-
listeners = /* @__PURE__ */ new Set();
|
|
213
|
-
name;
|
|
214
|
-
constructor(name = "better-auth.message") {
|
|
215
|
-
this.name = name;
|
|
216
|
-
}
|
|
217
|
-
subscribe(listener) {
|
|
218
|
-
this.listeners.add(listener);
|
|
219
|
-
return () => {
|
|
220
|
-
this.listeners.delete(listener);
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
post(message) {
|
|
224
|
-
if (typeof window === "undefined") return;
|
|
225
|
-
try {
|
|
226
|
-
localStorage.setItem(this.name, JSON.stringify({
|
|
227
|
-
...message,
|
|
228
|
-
timestamp: now$1()
|
|
229
|
-
}));
|
|
230
|
-
} catch {}
|
|
231
|
-
}
|
|
232
|
-
setup() {
|
|
233
|
-
if (typeof window === "undefined" || typeof window.addEventListener === "undefined") return () => {};
|
|
234
|
-
const handler = (event) => {
|
|
235
|
-
if (event.key !== this.name) return;
|
|
236
|
-
const message = JSON.parse(event.newValue ?? "{}");
|
|
237
|
-
if (message?.event !== "session" || !message?.data) return;
|
|
238
|
-
this.listeners.forEach((listener) => listener(message));
|
|
239
|
-
};
|
|
240
|
-
window.addEventListener("storage", handler);
|
|
241
|
-
return () => {
|
|
242
|
-
window.removeEventListener("storage", handler);
|
|
243
|
-
};
|
|
244
|
-
}
|
|
245
|
-
};
|
|
246
|
-
function getGlobalBroadcastChannel(name = "better-auth.message") {
|
|
247
|
-
if (!globalThis[kBroadcastChannel]) globalThis[kBroadcastChannel] = new WindowBroadcastChannel(name);
|
|
248
|
-
return globalThis[kBroadcastChannel];
|
|
249
|
-
}
|
|
250
|
-
//#endregion
|
|
251
|
-
//#region ../node_modules/.bun/better-auth@1.6.22+81bceec6070f2f33/node_modules/better-auth/dist/client/focus-manager.mjs
|
|
89
|
+
//#region ../node_modules/.bun/better-auth@1.7.2+a913405242b7eb5a/node_modules/better-auth/dist/client/focus-manager.mjs
|
|
252
90
|
var kFocusManager = Symbol.for("better-auth:focus-manager");
|
|
253
91
|
var WindowFocusManager = class {
|
|
254
92
|
listeners = /* @__PURE__ */ new Set();
|
|
@@ -277,7 +115,7 @@ function getGlobalFocusManager() {
|
|
|
277
115
|
return globalThis[kFocusManager];
|
|
278
116
|
}
|
|
279
117
|
//#endregion
|
|
280
|
-
//#region ../node_modules/.bun/better-auth@1.
|
|
118
|
+
//#region ../node_modules/.bun/better-auth@1.7.2+a913405242b7eb5a/node_modules/better-auth/dist/client/online-manager.mjs
|
|
281
119
|
var kOnlineManager = Symbol.for("better-auth:online-manager");
|
|
282
120
|
var WindowOnlineManager = class {
|
|
283
121
|
listeners = /* @__PURE__ */ new Set();
|
|
@@ -309,7 +147,76 @@ function getGlobalOnlineManager() {
|
|
|
309
147
|
return globalThis[kOnlineManager];
|
|
310
148
|
}
|
|
311
149
|
//#endregion
|
|
312
|
-
//#region ../node_modules/.bun/better-auth@1.
|
|
150
|
+
//#region ../node_modules/.bun/better-auth@1.7.2+a913405242b7eb5a/node_modules/better-auth/dist/client/parser.mjs
|
|
151
|
+
var PROTO_POLLUTION_PATTERNS = {
|
|
152
|
+
proto: /"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,
|
|
153
|
+
constructor: /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,
|
|
154
|
+
protoShort: /"__proto__"\s*:/,
|
|
155
|
+
constructorShort: /"constructor"\s*:/
|
|
156
|
+
};
|
|
157
|
+
var JSON_SIGNATURE = /^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;
|
|
158
|
+
var SPECIAL_VALUES = {
|
|
159
|
+
true: true,
|
|
160
|
+
false: false,
|
|
161
|
+
null: null,
|
|
162
|
+
undefined: void 0,
|
|
163
|
+
nan: NaN,
|
|
164
|
+
infinity: Number.POSITIVE_INFINITY,
|
|
165
|
+
"-infinity": Number.NEGATIVE_INFINITY
|
|
166
|
+
};
|
|
167
|
+
var ISO_DATE_REGEX = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;
|
|
168
|
+
function isValidDate(date) {
|
|
169
|
+
return date instanceof Date && !isNaN(date.getTime());
|
|
170
|
+
}
|
|
171
|
+
function parseISODate(value) {
|
|
172
|
+
const match = ISO_DATE_REGEX.exec(value);
|
|
173
|
+
if (!match) return null;
|
|
174
|
+
const [, year, month, day, hour, minute, second, ms, offsetSign, offsetHour, offsetMinute] = match;
|
|
175
|
+
const date = new Date(Date.UTC(parseInt(year, 10), parseInt(month, 10) - 1, parseInt(day, 10), parseInt(hour, 10), parseInt(minute, 10), parseInt(second, 10), ms ? parseInt(ms.padEnd(3, "0"), 10) : 0));
|
|
176
|
+
if (offsetSign) {
|
|
177
|
+
const offset = (parseInt(offsetHour, 10) * 60 + parseInt(offsetMinute, 10)) * (offsetSign === "+" ? -1 : 1);
|
|
178
|
+
date.setUTCMinutes(date.getUTCMinutes() + offset);
|
|
179
|
+
}
|
|
180
|
+
return isValidDate(date) ? date : null;
|
|
181
|
+
}
|
|
182
|
+
function betterJSONParse(value, options = {}) {
|
|
183
|
+
const { strict = false, warnings = false, reviver, parseDates = true } = options;
|
|
184
|
+
if (typeof value !== "string") return value;
|
|
185
|
+
const trimmed = value.trim();
|
|
186
|
+
const lowerValue = trimmed.toLowerCase();
|
|
187
|
+
if (lowerValue.length <= 9 && lowerValue in SPECIAL_VALUES) return SPECIAL_VALUES[lowerValue];
|
|
188
|
+
if (!JSON_SIGNATURE.test(trimmed)) {
|
|
189
|
+
if (strict) throw new SyntaxError("[better-json] Invalid JSON");
|
|
190
|
+
return value;
|
|
191
|
+
}
|
|
192
|
+
if (Object.entries(PROTO_POLLUTION_PATTERNS).some(([key, pattern]) => {
|
|
193
|
+
const matches = pattern.test(trimmed);
|
|
194
|
+
if (matches && warnings) console.warn(`[better-json] Detected potential prototype pollution attempt using ${key} pattern`);
|
|
195
|
+
return matches;
|
|
196
|
+
}) && strict) throw new Error("[better-json] Potential prototype pollution attempt detected");
|
|
197
|
+
try {
|
|
198
|
+
const secureReviver = (key, value) => {
|
|
199
|
+
if (key === "__proto__" || key === "constructor" && value && typeof value === "object" && "prototype" in value) {
|
|
200
|
+
if (warnings) console.warn(`[better-json] Dropping "${key}" key to prevent prototype pollution`);
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
if (parseDates && typeof value === "string") {
|
|
204
|
+
const date = parseISODate(value);
|
|
205
|
+
if (date) return date;
|
|
206
|
+
}
|
|
207
|
+
return reviver ? reviver(key, value) : value;
|
|
208
|
+
};
|
|
209
|
+
return JSON.parse(trimmed, secureReviver);
|
|
210
|
+
} catch (error) {
|
|
211
|
+
if (strict) throw error;
|
|
212
|
+
return value;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
function parseJSON(value, options = { strict: true }) {
|
|
216
|
+
return betterJSONParse(value, options);
|
|
217
|
+
}
|
|
218
|
+
//#endregion
|
|
219
|
+
//#region ../node_modules/.bun/better-auth@1.7.2+a913405242b7eb5a/node_modules/better-auth/dist/client/session-refresh.mjs
|
|
313
220
|
var now = () => Math.floor(Date.now() / 1e3);
|
|
314
221
|
/**
|
|
315
222
|
* Rate limit: don't refetch on focus if a session request was made within this many seconds
|
|
@@ -436,8 +343,113 @@ function createSessionRefreshManager(opts) {
|
|
|
436
343
|
};
|
|
437
344
|
}
|
|
438
345
|
//#endregion
|
|
439
|
-
//#region ../node_modules/.bun/better-auth@1.
|
|
346
|
+
//#region ../node_modules/.bun/better-auth@1.7.2+a913405242b7eb5a/node_modules/better-auth/dist/utils/url.mjs
|
|
347
|
+
var SLASH_CHAR_CODE = "/".charCodeAt(0);
|
|
348
|
+
function trimTrailingSlashes(value) {
|
|
349
|
+
let end = value.length;
|
|
350
|
+
while (end > 0 && value.charCodeAt(end - 1) === SLASH_CHAR_CODE) end--;
|
|
351
|
+
return end === value.length ? value : value.slice(0, end);
|
|
352
|
+
}
|
|
353
|
+
function checkHasPath(url) {
|
|
354
|
+
try {
|
|
355
|
+
return (trimTrailingSlashes(new URL(url).pathname) || "/") !== "/";
|
|
356
|
+
} catch {
|
|
357
|
+
throw new BetterAuthError(`Invalid base URL: ${url}. Please provide a valid base URL.`);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
function assertHasProtocol(url) {
|
|
361
|
+
try {
|
|
362
|
+
const parsedUrl = new URL(url);
|
|
363
|
+
if (parsedUrl.protocol !== "http:" && parsedUrl.protocol !== "https:") throw new BetterAuthError(`Invalid base URL: ${url}. URL must include 'http://' or 'https://'`);
|
|
364
|
+
} catch (error) {
|
|
365
|
+
if (error instanceof BetterAuthError) throw error;
|
|
366
|
+
throw new BetterAuthError(`Invalid base URL: ${url}. Please provide a valid base URL.`, { cause: error });
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
function withPath(url, path = "/api/auth") {
|
|
370
|
+
assertHasProtocol(url);
|
|
371
|
+
if (checkHasPath(url)) return url;
|
|
372
|
+
const trimmedUrl = trimTrailingSlashes(url);
|
|
373
|
+
if (!path || path === "/") return trimmedUrl;
|
|
374
|
+
path = path.startsWith("/") ? path : `/${path}`;
|
|
375
|
+
return `${trimmedUrl}${path}`;
|
|
376
|
+
}
|
|
377
|
+
function validateProxyHeader(header, type) {
|
|
378
|
+
if (!header || header.trim() === "") return false;
|
|
379
|
+
if (type === "proto") return header === "http" || header === "https";
|
|
380
|
+
if (type === "host") {
|
|
381
|
+
if ([
|
|
382
|
+
/\.\./,
|
|
383
|
+
/\0/,
|
|
384
|
+
/[\s]/,
|
|
385
|
+
/^[.]/,
|
|
386
|
+
/[<>'"]/,
|
|
387
|
+
/javascript:/i,
|
|
388
|
+
/file:/i,
|
|
389
|
+
/data:/i
|
|
390
|
+
].some((pattern) => pattern.test(header))) return false;
|
|
391
|
+
return /^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*(:[0-9]{1,5})?$/.test(header) || /^(\d{1,3}\.){3}\d{1,3}(:[0-9]{1,5})?$/.test(header) || /^\[[0-9a-fA-F:]+\](:[0-9]{1,5})?$/.test(header) || /^localhost(:[0-9]{1,5})?$/i.test(header);
|
|
392
|
+
}
|
|
393
|
+
return false;
|
|
394
|
+
}
|
|
395
|
+
function getBaseURL(url, path, request, loadEnv, trustedProxyHeaders) {
|
|
396
|
+
if (url) return withPath(url, path);
|
|
397
|
+
if (loadEnv !== false) {
|
|
398
|
+
const fromEnv = env.BETTER_AUTH_URL || env.NEXT_PUBLIC_BETTER_AUTH_URL || env.PUBLIC_BETTER_AUTH_URL || env.NUXT_PUBLIC_BETTER_AUTH_URL || env.NUXT_PUBLIC_AUTH_URL || (env.BASE_URL !== "/" ? env.BASE_URL : void 0);
|
|
399
|
+
if (fromEnv) return withPath(fromEnv, path);
|
|
400
|
+
}
|
|
401
|
+
const fromRequest = request?.headers.get("x-forwarded-host");
|
|
402
|
+
const fromRequestProto = request?.headers.get("x-forwarded-proto");
|
|
403
|
+
if (fromRequest && fromRequestProto && trustedProxyHeaders) {
|
|
404
|
+
if (validateProxyHeader(fromRequestProto, "proto") && validateProxyHeader(fromRequest, "host")) try {
|
|
405
|
+
return withPath(`${fromRequestProto}://${fromRequest}`, path);
|
|
406
|
+
} catch (_error) {}
|
|
407
|
+
}
|
|
408
|
+
if (request) {
|
|
409
|
+
const url = getOrigin(request.url);
|
|
410
|
+
if (!url) throw new BetterAuthError("Could not get origin from request. Please provide a valid base URL.");
|
|
411
|
+
return withPath(url, path);
|
|
412
|
+
}
|
|
413
|
+
if (typeof window !== "undefined" && window.location) return withPath(window.location.origin, path);
|
|
414
|
+
}
|
|
415
|
+
function getOrigin(url) {
|
|
416
|
+
try {
|
|
417
|
+
const parsedUrl = new URL(url);
|
|
418
|
+
return parsedUrl.origin === "null" ? null : parsedUrl.origin;
|
|
419
|
+
} catch {
|
|
420
|
+
return null;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
//#endregion
|
|
424
|
+
//#region ../node_modules/.bun/better-auth@1.7.2+a913405242b7eb5a/node_modules/better-auth/dist/client/fetch-plugins.mjs
|
|
425
|
+
var redirectPlugin = {
|
|
426
|
+
id: "redirect",
|
|
427
|
+
name: "Redirect",
|
|
428
|
+
hooks: { onSuccess(context) {
|
|
429
|
+
if (context.data?.url && context.data?.redirect && isSafeUrlScheme(context.data.url)) {
|
|
430
|
+
if (typeof window !== "undefined" && window.location) {
|
|
431
|
+
if (window.location) try {
|
|
432
|
+
window.location.href = context.data.url;
|
|
433
|
+
} catch {}
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
} }
|
|
437
|
+
};
|
|
438
|
+
//#endregion
|
|
439
|
+
//#region ../node_modules/.bun/better-auth@1.7.2+a913405242b7eb5a/node_modules/better-auth/dist/client/session-atom.mjs
|
|
440
440
|
var isServer = () => typeof window === "undefined";
|
|
441
|
+
var SESSION_MOUNT_DEDUPE_INTERVAL = STORE_UNMOUNT_DELAY;
|
|
442
|
+
function hydrateSessionAtom(sessionAtom, session) {
|
|
443
|
+
if (typeof window === "undefined") return;
|
|
444
|
+
const currentSession = sessionAtom.get();
|
|
445
|
+
if (currentSession.data !== null || session === null) return;
|
|
446
|
+
sessionAtom.set({
|
|
447
|
+
...currentSession,
|
|
448
|
+
data: session,
|
|
449
|
+
error: null,
|
|
450
|
+
isPending: false
|
|
451
|
+
});
|
|
452
|
+
}
|
|
441
453
|
/**
|
|
442
454
|
* Normalize $fetch response: `throw: true` returns data directly,
|
|
443
455
|
* otherwise `{ data, error }`.
|
|
@@ -459,7 +471,13 @@ function isSessionAtomEqual(a, b) {
|
|
|
459
471
|
}
|
|
460
472
|
function getSessionAtom($fetch, options) {
|
|
461
473
|
const $signal = atom(false);
|
|
462
|
-
let
|
|
474
|
+
let flight;
|
|
475
|
+
let freshUntil = 0;
|
|
476
|
+
let sessionRevision = 0;
|
|
477
|
+
$signal.listen(() => {
|
|
478
|
+
sessionRevision++;
|
|
479
|
+
freshUntil = 0;
|
|
480
|
+
});
|
|
463
481
|
const refetch = (queryParams) => fetchSession(queryParams);
|
|
464
482
|
const session = atom({
|
|
465
483
|
data: null,
|
|
@@ -469,23 +487,8 @@ function getSessionAtom($fetch, options) {
|
|
|
469
487
|
refetch
|
|
470
488
|
});
|
|
471
489
|
withEquality(session, isSessionAtomEqual);
|
|
472
|
-
const
|
|
473
|
-
|
|
474
|
-
const current = session.get();
|
|
475
|
-
abortController = void 0;
|
|
476
|
-
if (!current.isPending && !current.isRefetching) return;
|
|
477
|
-
session.set({
|
|
478
|
-
...current,
|
|
479
|
-
isPending: false,
|
|
480
|
-
isRefetching: false,
|
|
481
|
-
refetch
|
|
482
|
-
});
|
|
483
|
-
};
|
|
484
|
-
const fetchSession = async (queryParams) => {
|
|
485
|
-
abortController?.abort();
|
|
486
|
-
const controller = new AbortController();
|
|
487
|
-
abortController = controller;
|
|
488
|
-
const current = session.get();
|
|
490
|
+
const executeSessionFetch = async (signal, queryParams) => {
|
|
491
|
+
const current = session.value;
|
|
489
492
|
session.set({
|
|
490
493
|
...current,
|
|
491
494
|
isPending: current.data === null,
|
|
@@ -493,35 +496,29 @@ function getSessionAtom($fetch, options) {
|
|
|
493
496
|
error: null,
|
|
494
497
|
refetch
|
|
495
498
|
});
|
|
499
|
+
if (signal.aborted) return "aborted";
|
|
496
500
|
try {
|
|
497
501
|
const res = await $fetch("/get-session", {
|
|
498
502
|
method: "GET",
|
|
499
503
|
query: queryParams?.query,
|
|
500
|
-
signal
|
|
504
|
+
signal
|
|
501
505
|
});
|
|
502
|
-
if (
|
|
503
|
-
settleAbortedFetch(controller);
|
|
504
|
-
return;
|
|
505
|
-
}
|
|
506
|
+
if (signal.aborted) return "aborted";
|
|
506
507
|
let { data, error } = normalizeSessionResponse(res);
|
|
508
|
+
let outcome = "fresh";
|
|
507
509
|
if (data?.needsRefresh) try {
|
|
508
510
|
const refreshRes = await $fetch("/get-session", {
|
|
509
511
|
method: "POST",
|
|
510
|
-
signal
|
|
512
|
+
signal
|
|
511
513
|
});
|
|
512
|
-
if (
|
|
513
|
-
settleAbortedFetch(controller);
|
|
514
|
-
return;
|
|
515
|
-
}
|
|
514
|
+
if (signal.aborted) return "aborted";
|
|
516
515
|
({data, error} = normalizeSessionResponse(refreshRes));
|
|
517
516
|
} catch {
|
|
518
|
-
if (
|
|
519
|
-
|
|
520
|
-
return;
|
|
521
|
-
}
|
|
517
|
+
if (signal.aborted) return "aborted";
|
|
518
|
+
outcome = "stale";
|
|
522
519
|
}
|
|
523
520
|
if (error) {
|
|
524
|
-
const latest = session.
|
|
521
|
+
const latest = session.value;
|
|
525
522
|
const isUnauthorized = error?.status === 401;
|
|
526
523
|
session.set({
|
|
527
524
|
data: isUnauthorized ? null : latest.data,
|
|
@@ -530,10 +527,10 @@ function getSessionAtom($fetch, options) {
|
|
|
530
527
|
isRefetching: false,
|
|
531
528
|
refetch
|
|
532
529
|
});
|
|
533
|
-
return;
|
|
530
|
+
return "failed";
|
|
534
531
|
}
|
|
535
532
|
const sessionData = normalizeSessionData(data);
|
|
536
|
-
const current = session.
|
|
533
|
+
const current = session.value;
|
|
537
534
|
const stableData = current.data != null && sessionData != null && isJsonEqual(current.data, sessionData) ? current.data : sessionData;
|
|
538
535
|
session.set({
|
|
539
536
|
data: stableData,
|
|
@@ -542,12 +539,10 @@ function getSessionAtom($fetch, options) {
|
|
|
542
539
|
isRefetching: false,
|
|
543
540
|
refetch
|
|
544
541
|
});
|
|
542
|
+
return outcome;
|
|
545
543
|
} catch (fetchError) {
|
|
546
|
-
if (
|
|
547
|
-
|
|
548
|
-
return;
|
|
549
|
-
}
|
|
550
|
-
const latest = session.get();
|
|
544
|
+
if (signal.aborted) return "aborted";
|
|
545
|
+
const latest = session.value;
|
|
551
546
|
session.set({
|
|
552
547
|
data: latest.data,
|
|
553
548
|
error: fetchError,
|
|
@@ -555,17 +550,49 @@ function getSessionAtom($fetch, options) {
|
|
|
555
550
|
isRefetching: false,
|
|
556
551
|
refetch
|
|
557
552
|
});
|
|
553
|
+
return "failed";
|
|
558
554
|
}
|
|
559
555
|
};
|
|
556
|
+
const getFreshUntil = () => {
|
|
557
|
+
const expiresAt = session.value.data?.session?.expiresAt;
|
|
558
|
+
const sessionExpiresAt = expiresAt instanceof Date ? expiresAt.getTime() : Number.POSITIVE_INFINITY;
|
|
559
|
+
return Math.min(Date.now() + SESSION_MOUNT_DEDUPE_INTERVAL, sessionExpiresAt);
|
|
560
|
+
};
|
|
561
|
+
const fetchSession = (queryParams) => {
|
|
562
|
+
freshUntil = 0;
|
|
563
|
+
flight?.cancel();
|
|
564
|
+
const controller = new AbortController();
|
|
565
|
+
const request = {
|
|
566
|
+
cancel: () => controller.abort(),
|
|
567
|
+
promise: Promise.resolve().then(() => {
|
|
568
|
+
if (controller.signal.aborted) return "aborted";
|
|
569
|
+
return executeSessionFetch(controller.signal, queryParams);
|
|
570
|
+
}),
|
|
571
|
+
revision: sessionRevision
|
|
572
|
+
};
|
|
573
|
+
flight = request;
|
|
574
|
+
const settleFlight = (outcome) => {
|
|
575
|
+
if (flight !== request) return;
|
|
576
|
+
flight = void 0;
|
|
577
|
+
if (outcome === "fresh" && request.revision === sessionRevision) freshUntil = getFreshUntil();
|
|
578
|
+
};
|
|
579
|
+
request.promise.then(settleFlight, () => settleFlight("failed"));
|
|
580
|
+
return request.promise.then(() => void 0);
|
|
581
|
+
};
|
|
582
|
+
const fetchSessionOnMount = () => {
|
|
583
|
+
if (flight?.revision === sessionRevision) return flight.promise.then(() => void 0);
|
|
584
|
+
if (Date.now() < freshUntil) return Promise.resolve();
|
|
585
|
+
return fetchSession();
|
|
586
|
+
};
|
|
560
587
|
let broadcastSessionUpdate = () => {};
|
|
561
588
|
onMount(session, () => {
|
|
562
589
|
let timeoutId;
|
|
563
590
|
if (!isServer()) timeoutId = setTimeout(() => {
|
|
564
|
-
|
|
591
|
+
fetchSessionOnMount();
|
|
565
592
|
}, 0);
|
|
566
593
|
const refreshManager = createSessionRefreshManager({
|
|
567
594
|
fetchSession,
|
|
568
|
-
shouldPollSession: () => session.
|
|
595
|
+
shouldPollSession: () => session.value.data != null,
|
|
569
596
|
sessionSignal: $signal,
|
|
570
597
|
options
|
|
571
598
|
});
|
|
@@ -573,9 +600,6 @@ function getSessionAtom($fetch, options) {
|
|
|
573
600
|
broadcastSessionUpdate = refreshManager.broadcastSessionUpdate;
|
|
574
601
|
return () => {
|
|
575
602
|
if (timeoutId) clearTimeout(timeoutId);
|
|
576
|
-
const controller = abortController;
|
|
577
|
-
controller?.abort();
|
|
578
|
-
if (controller) settleAbortedFetch(controller);
|
|
579
603
|
refreshManager.cleanup();
|
|
580
604
|
};
|
|
581
605
|
});
|
|
@@ -979,13 +1003,15 @@ function getURL2(url, option) {
|
|
|
979
1003
|
queryParams.set(key, serializedValue);
|
|
980
1004
|
}
|
|
981
1005
|
const pathParams = /* @__PURE__ */ new Map();
|
|
982
|
-
if (params)
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
const
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
1006
|
+
if (params) {
|
|
1007
|
+
if (Array.isArray(params)) {
|
|
1008
|
+
const paramPaths = path.split("/").filter((p) => p.startsWith(":"));
|
|
1009
|
+
for (const [index, key] of paramPaths.entries()) {
|
|
1010
|
+
const value = params[index];
|
|
1011
|
+
pathParams.set(key, String(value));
|
|
1012
|
+
}
|
|
1013
|
+
} else for (const [key, value] of Object.entries(params)) pathParams.set(`:${key}`, String(value));
|
|
1014
|
+
}
|
|
989
1015
|
path = path.split("/").map((segment) => encodePathSegment(segment, pathParams)).join("/");
|
|
990
1016
|
path = path.replace(/^\/+/, "");
|
|
991
1017
|
let queryParamString = queryParams.toString();
|
|
@@ -1088,7 +1114,7 @@ var betterFetch = async (url, options) => {
|
|
|
1088
1114
|
};
|
|
1089
1115
|
};
|
|
1090
1116
|
//#endregion
|
|
1091
|
-
//#region ../node_modules/.bun/better-auth@1.
|
|
1117
|
+
//#region ../node_modules/.bun/better-auth@1.7.2+a913405242b7eb5a/node_modules/better-auth/dist/client/config.mjs
|
|
1092
1118
|
var resolvePublicAuthUrl = (basePath) => {
|
|
1093
1119
|
if (typeof process === "undefined") return void 0;
|
|
1094
1120
|
const path = basePath ?? "/api/auth";
|
|
@@ -1136,6 +1162,12 @@ var getClientConfig = (options, loadEnv) => {
|
|
|
1136
1162
|
]
|
|
1137
1163
|
});
|
|
1138
1164
|
const { $sessionSignal, session, broadcastSessionUpdate } = getSessionAtom($fetch, options);
|
|
1165
|
+
let hasHydrated = false;
|
|
1166
|
+
const hydrateSession = (sessionData) => {
|
|
1167
|
+
if (hasHydrated || sessionData === null) return;
|
|
1168
|
+
hasHydrated = true;
|
|
1169
|
+
hydrateSessionAtom(session, sessionData);
|
|
1170
|
+
};
|
|
1139
1171
|
const plugins = options?.plugins || [];
|
|
1140
1172
|
let pluginsActions = {};
|
|
1141
1173
|
const pluginsAtoms = {
|
|
@@ -1181,17 +1213,18 @@ var getClientConfig = (options, loadEnv) => {
|
|
|
1181
1213
|
pluginsAtoms,
|
|
1182
1214
|
pluginPathMethods,
|
|
1183
1215
|
atomListeners,
|
|
1216
|
+
hydrateSession,
|
|
1184
1217
|
$fetch,
|
|
1185
1218
|
$store
|
|
1186
1219
|
};
|
|
1187
1220
|
};
|
|
1188
1221
|
//#endregion
|
|
1189
|
-
//#region ../node_modules/.bun/better-auth@1.
|
|
1222
|
+
//#region ../node_modules/.bun/better-auth@1.7.2+a913405242b7eb5a/node_modules/better-auth/dist/utils/is-atom.mjs
|
|
1190
1223
|
function isAtom(value) {
|
|
1191
1224
|
return typeof value === "object" && value !== null && "get" in value && typeof value.get === "function" && "lc" in value && typeof value.lc === "number";
|
|
1192
1225
|
}
|
|
1193
1226
|
//#endregion
|
|
1194
|
-
//#region ../node_modules/.bun/better-auth@1.
|
|
1227
|
+
//#region ../node_modules/.bun/better-auth@1.7.2+a913405242b7eb5a/node_modules/better-auth/dist/client/proxy.mjs
|
|
1195
1228
|
function getMethod(path, knownPathMethods, args) {
|
|
1196
1229
|
const method = knownPathMethods[path];
|
|
1197
1230
|
const { fetchOptions, query: _query, ...body } = args || {};
|
|
@@ -1266,14 +1299,15 @@ function createDynamicPathProxy(routes, client, knownPathMethods, atoms, atomLis
|
|
|
1266
1299
|
return createProxy();
|
|
1267
1300
|
}
|
|
1268
1301
|
//#endregion
|
|
1269
|
-
//#region ../node_modules/.bun/better-auth@1.
|
|
1302
|
+
//#region ../node_modules/.bun/better-auth@1.7.2+a913405242b7eb5a/node_modules/better-auth/dist/client/vanilla.mjs
|
|
1270
1303
|
function createAuthClient(options) {
|
|
1271
|
-
const { pluginPathMethods, pluginsActions, pluginsAtoms, $fetch, atomListeners, $store } = getClientConfig(options);
|
|
1304
|
+
const { pluginPathMethods, pluginsActions, pluginsAtoms, hydrateSession, $fetch, atomListeners, $store } = getClientConfig(options);
|
|
1272
1305
|
const resolvedHooks = {};
|
|
1273
1306
|
for (const [key, value] of Object.entries(pluginsAtoms)) resolvedHooks[`use${capitalizeFirstLetter(key)}`] = value;
|
|
1274
1307
|
return createDynamicPathProxy({
|
|
1275
1308
|
...pluginsActions,
|
|
1276
1309
|
...resolvedHooks,
|
|
1310
|
+
hydrateSession,
|
|
1277
1311
|
$fetch,
|
|
1278
1312
|
$store
|
|
1279
1313
|
}, $fetch, pluginPathMethods, pluginsAtoms, atomListeners);
|