@blimu/react 0.6.0
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 +552 -0
- package/dist/_virtual/index.cjs +2 -0
- package/dist/_virtual/index.cjs.map +1 -0
- package/dist/_virtual/index.js +6 -0
- package/dist/_virtual/index.js.map +1 -0
- package/dist/_virtual/index2.cjs +2 -0
- package/dist/_virtual/index2.cjs.map +1 -0
- package/dist/_virtual/index2.js +5 -0
- package/dist/_virtual/index2.js.map +1 -0
- package/dist/_virtual/use-sync-external-store-shim.development.cjs +2 -0
- package/dist/_virtual/use-sync-external-store-shim.development.cjs.map +1 -0
- package/dist/_virtual/use-sync-external-store-shim.development.js +5 -0
- package/dist/_virtual/use-sync-external-store-shim.development.js.map +1 -0
- package/dist/_virtual/use-sync-external-store-shim.production.cjs +2 -0
- package/dist/_virtual/use-sync-external-store-shim.production.cjs.map +1 -0
- package/dist/_virtual/use-sync-external-store-shim.production.js +5 -0
- package/dist/_virtual/use-sync-external-store-shim.production.js.map +1 -0
- package/dist/client/auth.service.cjs +2 -0
- package/dist/client/auth.service.cjs.map +1 -0
- package/dist/client/auth.service.d.ts +50 -0
- package/dist/client/auth.service.d.ts.map +1 -0
- package/dist/client/auth.service.js +153 -0
- package/dist/client/auth.service.js.map +1 -0
- package/dist/client/auth.service.test-service.d.ts +39 -0
- package/dist/client/auth.service.test-service.d.ts.map +1 -0
- package/dist/client/external-store.cjs +2 -0
- package/dist/client/external-store.cjs.map +1 -0
- package/dist/client/external-store.d.ts +20 -0
- package/dist/client/external-store.d.ts.map +1 -0
- package/dist/client/external-store.js +13 -0
- package/dist/client/external-store.js.map +1 -0
- package/dist/client/runtime-client.cjs +2 -0
- package/dist/client/runtime-client.cjs.map +1 -0
- package/dist/client/runtime-client.d.ts +49 -0
- package/dist/client/runtime-client.d.ts.map +1 -0
- package/dist/client/runtime-client.js +103 -0
- package/dist/client/runtime-client.js.map +1 -0
- package/dist/components/index.d.ts +11 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/members-list.cjs +2 -0
- package/dist/components/members-list.cjs.map +1 -0
- package/dist/components/members-list.d.ts +70 -0
- package/dist/components/members-list.d.ts.map +1 -0
- package/dist/components/members-list.js +111 -0
- package/dist/components/members-list.js.map +1 -0
- package/dist/components/redirect-to-sign-in.cjs +2 -0
- package/dist/components/redirect-to-sign-in.cjs.map +1 -0
- package/dist/components/redirect-to-sign-in.d.ts +39 -0
- package/dist/components/redirect-to-sign-in.d.ts.map +1 -0
- package/dist/components/redirect-to-sign-in.js +27 -0
- package/dist/components/redirect-to-sign-in.js.map +1 -0
- package/dist/components/sign-in-button/styles.d.ts +7 -0
- package/dist/components/sign-in-button/styles.d.ts.map +1 -0
- package/dist/components/sign-in-button.cjs +2 -0
- package/dist/components/sign-in-button.cjs.map +1 -0
- package/dist/components/sign-in-button.d.ts +47 -0
- package/dist/components/sign-in-button.d.ts.map +1 -0
- package/dist/components/sign-in-button.js +33 -0
- package/dist/components/sign-in-button.js.map +1 -0
- package/dist/components/ui/avatar.cjs +2 -0
- package/dist/components/ui/avatar.cjs.map +1 -0
- package/dist/components/ui/avatar.d.ts +7 -0
- package/dist/components/ui/avatar.d.ts.map +1 -0
- package/dist/components/ui/avatar.js +43 -0
- package/dist/components/ui/avatar.js.map +1 -0
- package/dist/components/ui/badge.d.ts +10 -0
- package/dist/components/ui/badge.d.ts.map +1 -0
- package/dist/components/ui/dropdown-menu.cjs +2 -0
- package/dist/components/ui/dropdown-menu.cjs.map +1 -0
- package/dist/components/ui/dropdown-menu.d.ts +28 -0
- package/dist/components/ui/dropdown-menu.d.ts.map +1 -0
- package/dist/components/ui/dropdown-menu.js +130 -0
- package/dist/components/ui/dropdown-menu.js.map +1 -0
- package/dist/components/ui/popover.d.ts +8 -0
- package/dist/components/ui/popover.d.ts.map +1 -0
- package/dist/components/ui/separator.d.ts +5 -0
- package/dist/components/ui/separator.d.ts.map +1 -0
- package/dist/components/user-avatar/styles.d.ts +7 -0
- package/dist/components/user-avatar/styles.d.ts.map +1 -0
- package/dist/components/user-avatar.cjs +2 -0
- package/dist/components/user-avatar.cjs.map +1 -0
- package/dist/components/user-avatar.d.ts +41 -0
- package/dist/components/user-avatar.d.ts.map +1 -0
- package/dist/components/user-avatar.js +23 -0
- package/dist/components/user-avatar.js.map +1 -0
- package/dist/components/user-button/styles.cjs +2 -0
- package/dist/components/user-button/styles.cjs.map +1 -0
- package/dist/components/user-button/styles.d.ts +17 -0
- package/dist/components/user-button/styles.d.ts.map +1 -0
- package/dist/components/user-button/styles.js +39 -0
- package/dist/components/user-button/styles.js.map +1 -0
- package/dist/components/user-button/user-button.cjs +2 -0
- package/dist/components/user-button/user-button.cjs.map +1 -0
- package/dist/components/user-button/user-button.d.ts +15 -0
- package/dist/components/user-button/user-button.d.ts.map +1 -0
- package/dist/components/user-button/user-button.js +93 -0
- package/dist/components/user-button/user-button.js.map +1 -0
- package/dist/components.cjs +2 -0
- package/dist/components.cjs.map +1 -0
- package/dist/components.js +13 -0
- package/dist/components.js.map +1 -0
- package/dist/hooks/index.d.ts +7 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/use-auth.cjs +2 -0
- package/dist/hooks/use-auth.cjs.map +1 -0
- package/dist/hooks/use-auth.d.ts +92 -0
- package/dist/hooks/use-auth.d.ts.map +1 -0
- package/dist/hooks/use-auth.js +41 -0
- package/dist/hooks/use-auth.js.map +1 -0
- package/dist/hooks/use-client.cjs +2 -0
- package/dist/hooks/use-client.cjs.map +1 -0
- package/dist/hooks/use-client.d.ts +27 -0
- package/dist/hooks/use-client.d.ts.map +1 -0
- package/dist/hooks/use-client.js +9 -0
- package/dist/hooks/use-client.js.map +1 -0
- package/dist/hooks/use-members.cjs +2 -0
- package/dist/hooks/use-members.cjs.map +1 -0
- package/dist/hooks/use-members.d.ts +50 -0
- package/dist/hooks/use-members.d.ts.map +1 -0
- package/dist/hooks/use-members.js +49 -0
- package/dist/hooks/use-members.js.map +1 -0
- package/dist/hooks/use-store.cjs +2 -0
- package/dist/hooks/use-store.cjs.map +1 -0
- package/dist/hooks/use-store.d.ts +24 -0
- package/dist/hooks/use-store.d.ts.map +1 -0
- package/dist/hooks/use-store.js +18 -0
- package/dist/hooks/use-store.js.map +1 -0
- package/dist/hooks.cjs +2 -0
- package/dist/hooks.cjs.map +1 -0
- package/dist/hooks.js +14 -0
- package/dist/hooks.js.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +38 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/utils.cjs +2 -0
- package/dist/lib/utils.cjs.map +1 -0
- package/dist/lib/utils.d.ts +7 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +9 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/lib/variants.cjs +2 -0
- package/dist/lib/variants.cjs.map +1 -0
- package/dist/lib/variants.d.ts +37 -0
- package/dist/lib/variants.d.ts.map +1 -0
- package/dist/lib/variants.js +46 -0
- package/dist/lib/variants.js.map +1 -0
- package/dist/node_modules/@floating-ui/core/dist/floating-ui.core.cjs +2 -0
- package/dist/node_modules/@floating-ui/core/dist/floating-ui.core.cjs.map +1 -0
- package/dist/node_modules/@floating-ui/core/dist/floating-ui.core.js +528 -0
- package/dist/node_modules/@floating-ui/core/dist/floating-ui.core.js.map +1 -0
- package/dist/node_modules/@floating-ui/dom/dist/floating-ui.dom.cjs +2 -0
- package/dist/node_modules/@floating-ui/dom/dist/floating-ui.dom.cjs.map +1 -0
- package/dist/node_modules/@floating-ui/dom/dist/floating-ui.dom.js +403 -0
- package/dist/node_modules/@floating-ui/dom/dist/floating-ui.dom.js.map +1 -0
- package/dist/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.cjs +2 -0
- package/dist/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.cjs.map +1 -0
- package/dist/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.js +209 -0
- package/dist/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.js.map +1 -0
- package/dist/node_modules/@floating-ui/utils/dist/floating-ui.utils.cjs +2 -0
- package/dist/node_modules/@floating-ui/utils/dist/floating-ui.utils.cjs.map +1 -0
- package/dist/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.cjs +2 -0
- package/dist/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.cjs.map +1 -0
- package/dist/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js +137 -0
- package/dist/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js.map +1 -0
- package/dist/node_modules/@floating-ui/utils/dist/floating-ui.utils.js +131 -0
- package/dist/node_modules/@floating-ui/utils/dist/floating-ui.utils.js.map +1 -0
- package/dist/node_modules/@radix-ui/primitive/dist/index.cjs +2 -0
- package/dist/node_modules/@radix-ui/primitive/dist/index.cjs.map +1 -0
- package/dist/node_modules/@radix-ui/primitive/dist/index.js +10 -0
- package/dist/node_modules/@radix-ui/primitive/dist/index.js.map +1 -0
- package/dist/node_modules/@radix-ui/react-arrow/dist/index.cjs +2 -0
- package/dist/node_modules/@radix-ui/react-arrow/dist/index.cjs.map +1 -0
- package/dist/node_modules/@radix-ui/react-arrow/dist/index.js +25 -0
- package/dist/node_modules/@radix-ui/react-arrow/dist/index.js.map +1 -0
- package/dist/node_modules/@radix-ui/react-avatar/dist/index.cjs +2 -0
- package/dist/node_modules/@radix-ui/react-avatar/dist/index.cjs.map +1 -0
- package/dist/node_modules/@radix-ui/react-avatar/dist/index.js +76 -0
- package/dist/node_modules/@radix-ui/react-avatar/dist/index.js.map +1 -0
- package/dist/node_modules/@radix-ui/react-avatar/node_modules/@radix-ui/react-context/dist/index.cjs +2 -0
- package/dist/node_modules/@radix-ui/react-avatar/node_modules/@radix-ui/react-context/dist/index.cjs.map +1 -0
- package/dist/node_modules/@radix-ui/react-avatar/node_modules/@radix-ui/react-context/dist/index.js +56 -0
- package/dist/node_modules/@radix-ui/react-avatar/node_modules/@radix-ui/react-context/dist/index.js.map +1 -0
- package/dist/node_modules/@radix-ui/react-avatar/node_modules/@radix-ui/react-primitive/dist/index.cjs +2 -0
- package/dist/node_modules/@radix-ui/react-avatar/node_modules/@radix-ui/react-primitive/dist/index.cjs.map +1 -0
- package/dist/node_modules/@radix-ui/react-avatar/node_modules/@radix-ui/react-primitive/dist/index.js +33 -0
- package/dist/node_modules/@radix-ui/react-avatar/node_modules/@radix-ui/react-primitive/dist/index.js.map +1 -0
- package/dist/node_modules/@radix-ui/react-avatar/node_modules/@radix-ui/react-slot/dist/index.cjs +2 -0
- package/dist/node_modules/@radix-ui/react-avatar/node_modules/@radix-ui/react-slot/dist/index.cjs.map +1 -0
- package/dist/node_modules/@radix-ui/react-avatar/node_modules/@radix-ui/react-slot/dist/index.js +59 -0
- package/dist/node_modules/@radix-ui/react-avatar/node_modules/@radix-ui/react-slot/dist/index.js.map +1 -0
- package/dist/node_modules/@radix-ui/react-collection/dist/index.cjs +2 -0
- package/dist/node_modules/@radix-ui/react-collection/dist/index.cjs.map +1 -0
- package/dist/node_modules/@radix-ui/react-collection/dist/index.js +51 -0
- package/dist/node_modules/@radix-ui/react-collection/dist/index.js.map +1 -0
- package/dist/node_modules/@radix-ui/react-compose-refs/dist/index.cjs +2 -0
- package/dist/node_modules/@radix-ui/react-compose-refs/dist/index.cjs.map +1 -0
- package/dist/node_modules/@radix-ui/react-compose-refs/dist/index.js +30 -0
- package/dist/node_modules/@radix-ui/react-compose-refs/dist/index.js.map +1 -0
- package/dist/node_modules/@radix-ui/react-context/dist/index.cjs +2 -0
- package/dist/node_modules/@radix-ui/react-context/dist/index.cjs.map +1 -0
- package/dist/node_modules/@radix-ui/react-context/dist/index.js +54 -0
- package/dist/node_modules/@radix-ui/react-context/dist/index.js.map +1 -0
- package/dist/node_modules/@radix-ui/react-direction/dist/index.cjs +2 -0
- package/dist/node_modules/@radix-ui/react-direction/dist/index.cjs.map +1 -0
- package/dist/node_modules/@radix-ui/react-direction/dist/index.js +11 -0
- package/dist/node_modules/@radix-ui/react-direction/dist/index.js.map +1 -0
- package/dist/node_modules/@radix-ui/react-dismissable-layer/dist/index.cjs +2 -0
- package/dist/node_modules/@radix-ui/react-dismissable-layer/dist/index.cjs.map +1 -0
- package/dist/node_modules/@radix-ui/react-dismissable-layer/dist/index.js +128 -0
- package/dist/node_modules/@radix-ui/react-dismissable-layer/dist/index.js.map +1 -0
- package/dist/node_modules/@radix-ui/react-dropdown-menu/dist/index.cjs +2 -0
- package/dist/node_modules/@radix-ui/react-dropdown-menu/dist/index.cjs.map +1 -0
- package/dist/node_modules/@radix-ui/react-dropdown-menu/dist/index.js +215 -0
- package/dist/node_modules/@radix-ui/react-dropdown-menu/dist/index.js.map +1 -0
- package/dist/node_modules/@radix-ui/react-focus-guards/dist/index.cjs +2 -0
- package/dist/node_modules/@radix-ui/react-focus-guards/dist/index.cjs.map +1 -0
- package/dist/node_modules/@radix-ui/react-focus-guards/dist/index.js +18 -0
- package/dist/node_modules/@radix-ui/react-focus-guards/dist/index.js.map +1 -0
- package/dist/node_modules/@radix-ui/react-focus-scope/dist/index.cjs +2 -0
- package/dist/node_modules/@radix-ui/react-focus-scope/dist/index.cjs.map +1 -0
- package/dist/node_modules/@radix-ui/react-focus-scope/dist/index.js +137 -0
- package/dist/node_modules/@radix-ui/react-focus-scope/dist/index.js.map +1 -0
- package/dist/node_modules/@radix-ui/react-id/dist/index.cjs +2 -0
- package/dist/node_modules/@radix-ui/react-id/dist/index.cjs.map +1 -0
- package/dist/node_modules/@radix-ui/react-id/dist/index.js +14 -0
- package/dist/node_modules/@radix-ui/react-id/dist/index.js.map +1 -0
- package/dist/node_modules/@radix-ui/react-menu/dist/index.cjs +2 -0
- package/dist/node_modules/@radix-ui/react-menu/dist/index.cjs.map +1 -0
- package/dist/node_modules/@radix-ui/react-menu/dist/index.js +609 -0
- package/dist/node_modules/@radix-ui/react-menu/dist/index.js.map +1 -0
- package/dist/node_modules/@radix-ui/react-popper/dist/index.cjs +2 -0
- package/dist/node_modules/@radix-ui/react-popper/dist/index.cjs.map +1 -0
- package/dist/node_modules/@radix-ui/react-popper/dist/index.js +220 -0
- package/dist/node_modules/@radix-ui/react-popper/dist/index.js.map +1 -0
- package/dist/node_modules/@radix-ui/react-portal/dist/index.cjs +2 -0
- package/dist/node_modules/@radix-ui/react-portal/dist/index.cjs.map +1 -0
- package/dist/node_modules/@radix-ui/react-portal/dist/index.js +16 -0
- package/dist/node_modules/@radix-ui/react-portal/dist/index.js.map +1 -0
- package/dist/node_modules/@radix-ui/react-presence/dist/index.cjs +2 -0
- package/dist/node_modules/@radix-ui/react-presence/dist/index.cjs.map +1 -0
- package/dist/node_modules/@radix-ui/react-presence/dist/index.js +71 -0
- package/dist/node_modules/@radix-ui/react-presence/dist/index.js.map +1 -0
- package/dist/node_modules/@radix-ui/react-primitive/dist/index.cjs +2 -0
- package/dist/node_modules/@radix-ui/react-primitive/dist/index.cjs.map +1 -0
- package/dist/node_modules/@radix-ui/react-primitive/dist/index.js +37 -0
- package/dist/node_modules/@radix-ui/react-primitive/dist/index.js.map +1 -0
- package/dist/node_modules/@radix-ui/react-roving-focus/dist/index.cjs +2 -0
- package/dist/node_modules/@radix-ui/react-roving-focus/dist/index.cjs.map +1 -0
- package/dist/node_modules/@radix-ui/react-roving-focus/dist/index.js +184 -0
- package/dist/node_modules/@radix-ui/react-roving-focus/dist/index.js.map +1 -0
- package/dist/node_modules/@radix-ui/react-slot/dist/index.cjs +2 -0
- package/dist/node_modules/@radix-ui/react-slot/dist/index.cjs.map +1 -0
- package/dist/node_modules/@radix-ui/react-slot/dist/index.js +50 -0
- package/dist/node_modules/@radix-ui/react-slot/dist/index.js.map +1 -0
- package/dist/node_modules/@radix-ui/react-use-callback-ref/dist/index.cjs +2 -0
- package/dist/node_modules/@radix-ui/react-use-callback-ref/dist/index.cjs.map +1 -0
- package/dist/node_modules/@radix-ui/react-use-callback-ref/dist/index.js +11 -0
- package/dist/node_modules/@radix-ui/react-use-callback-ref/dist/index.js.map +1 -0
- package/dist/node_modules/@radix-ui/react-use-controllable-state/dist/index.cjs +2 -0
- package/dist/node_modules/@radix-ui/react-use-controllable-state/dist/index.cjs.map +1 -0
- package/dist/node_modules/@radix-ui/react-use-controllable-state/dist/index.js +53 -0
- package/dist/node_modules/@radix-ui/react-use-controllable-state/dist/index.js.map +1 -0
- package/dist/node_modules/@radix-ui/react-use-escape-keydown/dist/index.cjs +2 -0
- package/dist/node_modules/@radix-ui/react-use-escape-keydown/dist/index.cjs.map +1 -0
- package/dist/node_modules/@radix-ui/react-use-escape-keydown/dist/index.js +15 -0
- package/dist/node_modules/@radix-ui/react-use-escape-keydown/dist/index.js.map +1 -0
- package/dist/node_modules/@radix-ui/react-use-is-hydrated/dist/index.cjs +2 -0
- package/dist/node_modules/@radix-ui/react-use-is-hydrated/dist/index.cjs.map +1 -0
- package/dist/node_modules/@radix-ui/react-use-is-hydrated/dist/index.js +16 -0
- package/dist/node_modules/@radix-ui/react-use-is-hydrated/dist/index.js.map +1 -0
- package/dist/node_modules/@radix-ui/react-use-layout-effect/dist/index.cjs +2 -0
- package/dist/node_modules/@radix-ui/react-use-layout-effect/dist/index.cjs.map +1 -0
- package/dist/node_modules/@radix-ui/react-use-layout-effect/dist/index.js +7 -0
- package/dist/node_modules/@radix-ui/react-use-layout-effect/dist/index.js.map +1 -0
- package/dist/node_modules/@radix-ui/react-use-size/dist/index.cjs +2 -0
- package/dist/node_modules/@radix-ui/react-use-size/dist/index.cjs.map +1 -0
- package/dist/node_modules/@radix-ui/react-use-size/dist/index.js +28 -0
- package/dist/node_modules/@radix-ui/react-use-size/dist/index.js.map +1 -0
- package/dist/node_modules/aria-hidden/dist/es2015/index.cjs +2 -0
- package/dist/node_modules/aria-hidden/dist/es2015/index.cjs.map +1 -0
- package/dist/node_modules/aria-hidden/dist/es2015/index.js +53 -0
- package/dist/node_modules/aria-hidden/dist/es2015/index.js.map +1 -0
- package/dist/node_modules/class-variance-authority/dist/index.cjs +2 -0
- package/dist/node_modules/class-variance-authority/dist/index.cjs.map +1 -0
- package/dist/node_modules/class-variance-authority/dist/index.js +36 -0
- package/dist/node_modules/class-variance-authority/dist/index.js.map +1 -0
- package/dist/node_modules/clsx/dist/clsx.cjs +2 -0
- package/dist/node_modules/clsx/dist/clsx.cjs.map +1 -0
- package/dist/node_modules/clsx/dist/clsx.js +18 -0
- package/dist/node_modules/clsx/dist/clsx.js.map +1 -0
- package/dist/node_modules/get-nonce/dist/es2015/index.cjs +2 -0
- package/dist/node_modules/get-nonce/dist/es2015/index.cjs.map +1 -0
- package/dist/node_modules/get-nonce/dist/es2015/index.js +8 -0
- package/dist/node_modules/get-nonce/dist/es2015/index.js.map +1 -0
- package/dist/node_modules/js-cookie/dist/js.cookie.cjs +2 -0
- package/dist/node_modules/js-cookie/dist/js.cookie.cjs.map +1 -0
- package/dist/node_modules/js-cookie/dist/js.cookie.js +74 -0
- package/dist/node_modules/js-cookie/dist/js.cookie.js.map +1 -0
- package/dist/node_modules/jwt-decode/build/esm/index.cjs +2 -0
- package/dist/node_modules/jwt-decode/build/esm/index.cjs.map +1 -0
- package/dist/node_modules/jwt-decode/build/esm/index.js +53 -0
- package/dist/node_modules/jwt-decode/build/esm/index.js.map +1 -0
- package/dist/node_modules/lucide-react/dist/esm/Icon.cjs +2 -0
- package/dist/node_modules/lucide-react/dist/esm/Icon.cjs.map +1 -0
- package/dist/node_modules/lucide-react/dist/esm/Icon.js +36 -0
- package/dist/node_modules/lucide-react/dist/esm/Icon.js.map +1 -0
- package/dist/node_modules/lucide-react/dist/esm/createLucideIcon.cjs +2 -0
- package/dist/node_modules/lucide-react/dist/esm/createLucideIcon.cjs.map +1 -0
- package/dist/node_modules/lucide-react/dist/esm/createLucideIcon.js +22 -0
- package/dist/node_modules/lucide-react/dist/esm/createLucideIcon.js.map +1 -0
- package/dist/node_modules/lucide-react/dist/esm/defaultAttributes.cjs +2 -0
- package/dist/node_modules/lucide-react/dist/esm/defaultAttributes.cjs.map +1 -0
- package/dist/node_modules/lucide-react/dist/esm/defaultAttributes.js +15 -0
- package/dist/node_modules/lucide-react/dist/esm/defaultAttributes.js.map +1 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/check.cjs +2 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/check.cjs.map +1 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/check.js +7 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/check.js.map +1 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/chevron-right.cjs +2 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/chevron-right.cjs.map +1 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/chevron-right.js +7 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/chevron-right.js.map +1 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/circle.cjs +2 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/circle.cjs.map +1 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/circle.js +7 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/circle.js.map +1 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/log-out.cjs +2 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/log-out.cjs.map +1 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/log-out.js +11 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/log-out.js.map +1 -0
- package/dist/node_modules/lucide-react/dist/esm/shared/src/utils.cjs +2 -0
- package/dist/node_modules/lucide-react/dist/esm/shared/src/utils.cjs.map +1 -0
- package/dist/node_modules/lucide-react/dist/esm/shared/src/utils.js +19 -0
- package/dist/node_modules/lucide-react/dist/esm/shared/src/utils.js.map +1 -0
- package/dist/node_modules/react-remove-scroll/dist/es2015/Combination.cjs +2 -0
- package/dist/node_modules/react-remove-scroll/dist/es2015/Combination.cjs.map +1 -0
- package/dist/node_modules/react-remove-scroll/dist/es2015/Combination.js +12 -0
- package/dist/node_modules/react-remove-scroll/dist/es2015/Combination.js.map +1 -0
- package/dist/node_modules/react-remove-scroll/dist/es2015/SideEffect.cjs +5 -0
- package/dist/node_modules/react-remove-scroll/dist/es2015/SideEffect.cjs.map +1 -0
- package/dist/node_modules/react-remove-scroll/dist/es2015/SideEffect.js +116 -0
- package/dist/node_modules/react-remove-scroll/dist/es2015/SideEffect.js.map +1 -0
- package/dist/node_modules/react-remove-scroll/dist/es2015/UI.cjs +2 -0
- package/dist/node_modules/react-remove-scroll/dist/es2015/UI.cjs.map +1 -0
- package/dist/node_modules/react-remove-scroll/dist/es2015/UI.js +32 -0
- package/dist/node_modules/react-remove-scroll/dist/es2015/UI.js.map +1 -0
- package/dist/node_modules/react-remove-scroll/dist/es2015/aggresiveCapture.cjs +2 -0
- package/dist/node_modules/react-remove-scroll/dist/es2015/aggresiveCapture.cjs.map +1 -0
- package/dist/node_modules/react-remove-scroll/dist/es2015/aggresiveCapture.js +17 -0
- package/dist/node_modules/react-remove-scroll/dist/es2015/aggresiveCapture.js.map +1 -0
- package/dist/node_modules/react-remove-scroll/dist/es2015/handleScroll.cjs +2 -0
- package/dist/node_modules/react-remove-scroll/dist/es2015/handleScroll.cjs.map +1 -0
- package/dist/node_modules/react-remove-scroll/dist/es2015/handleScroll.js +69 -0
- package/dist/node_modules/react-remove-scroll/dist/es2015/handleScroll.js.map +1 -0
- package/dist/node_modules/react-remove-scroll/dist/es2015/medium.cjs +2 -0
- package/dist/node_modules/react-remove-scroll/dist/es2015/medium.cjs.map +1 -0
- package/dist/node_modules/react-remove-scroll/dist/es2015/medium.js +6 -0
- package/dist/node_modules/react-remove-scroll/dist/es2015/medium.js.map +1 -0
- package/dist/node_modules/react-remove-scroll/dist/es2015/sidecar.cjs +2 -0
- package/dist/node_modules/react-remove-scroll/dist/es2015/sidecar.cjs.map +1 -0
- package/dist/node_modules/react-remove-scroll/dist/es2015/sidecar.js +8 -0
- package/dist/node_modules/react-remove-scroll/dist/es2015/sidecar.js.map +1 -0
- package/dist/node_modules/react-remove-scroll-bar/dist/es2015/component.cjs +39 -0
- package/dist/node_modules/react-remove-scroll-bar/dist/es2015/component.cjs.map +1 -0
- package/dist/node_modules/react-remove-scroll-bar/dist/es2015/component.js +72 -0
- package/dist/node_modules/react-remove-scroll-bar/dist/es2015/component.js.map +1 -0
- package/dist/node_modules/react-remove-scroll-bar/dist/es2015/constants.cjs +2 -0
- package/dist/node_modules/react-remove-scroll-bar/dist/es2015/constants.cjs.map +1 -0
- package/dist/node_modules/react-remove-scroll-bar/dist/es2015/constants.js +8 -0
- package/dist/node_modules/react-remove-scroll-bar/dist/es2015/constants.js.map +1 -0
- package/dist/node_modules/react-remove-scroll-bar/dist/es2015/utils.cjs +2 -0
- package/dist/node_modules/react-remove-scroll-bar/dist/es2015/utils.cjs.map +1 -0
- package/dist/node_modules/react-remove-scroll-bar/dist/es2015/utils.js +26 -0
- package/dist/node_modules/react-remove-scroll-bar/dist/es2015/utils.js.map +1 -0
- package/dist/node_modules/react-style-singleton/dist/es2015/component.cjs +2 -0
- package/dist/node_modules/react-style-singleton/dist/es2015/component.cjs.map +1 -0
- package/dist/node_modules/react-style-singleton/dist/es2015/component.js +12 -0
- package/dist/node_modules/react-style-singleton/dist/es2015/component.js.map +1 -0
- package/dist/node_modules/react-style-singleton/dist/es2015/hook.cjs +2 -0
- package/dist/node_modules/react-style-singleton/dist/es2015/hook.cjs.map +1 -0
- package/dist/node_modules/react-style-singleton/dist/es2015/hook.js +16 -0
- package/dist/node_modules/react-style-singleton/dist/es2015/hook.js.map +1 -0
- package/dist/node_modules/react-style-singleton/dist/es2015/singleton.cjs +2 -0
- package/dist/node_modules/react-style-singleton/dist/es2015/singleton.cjs.map +1 -0
- package/dist/node_modules/react-style-singleton/dist/es2015/singleton.js +31 -0
- package/dist/node_modules/react-style-singleton/dist/es2015/singleton.js.map +1 -0
- package/dist/node_modules/tailwind-merge/dist/bundle-mjs.cjs +2 -0
- package/dist/node_modules/tailwind-merge/dist/bundle-mjs.cjs.map +1 -0
- package/dist/node_modules/tailwind-merge/dist/bundle-mjs.js +2766 -0
- package/dist/node_modules/tailwind-merge/dist/bundle-mjs.js.map +1 -0
- package/dist/node_modules/tailwindcss/dist/plugin.cjs +2 -0
- package/dist/node_modules/tailwindcss/dist/plugin.cjs.map +1 -0
- package/dist/node_modules/tailwindcss/dist/plugin.js +14 -0
- package/dist/node_modules/tailwindcss/dist/plugin.js.map +1 -0
- package/dist/node_modules/tslib/tslib.es6.cjs +2 -0
- package/dist/node_modules/tslib/tslib.es6.cjs.map +1 -0
- package/dist/node_modules/tslib/tslib.es6.js +28 -0
- package/dist/node_modules/tslib/tslib.es6.js.map +1 -0
- package/dist/node_modules/use-callback-ref/dist/es2015/assignRef.cjs +2 -0
- package/dist/node_modules/use-callback-ref/dist/es2015/assignRef.cjs.map +1 -0
- package/dist/node_modules/use-callback-ref/dist/es2015/assignRef.js +7 -0
- package/dist/node_modules/use-callback-ref/dist/es2015/assignRef.js.map +1 -0
- package/dist/node_modules/use-callback-ref/dist/es2015/useMergeRef.cjs +2 -0
- package/dist/node_modules/use-callback-ref/dist/es2015/useMergeRef.cjs.map +1 -0
- package/dist/node_modules/use-callback-ref/dist/es2015/useMergeRef.js +27 -0
- package/dist/node_modules/use-callback-ref/dist/es2015/useMergeRef.js.map +1 -0
- package/dist/node_modules/use-callback-ref/dist/es2015/useRef.cjs +2 -0
- package/dist/node_modules/use-callback-ref/dist/es2015/useRef.cjs.map +1 -0
- package/dist/node_modules/use-callback-ref/dist/es2015/useRef.js +26 -0
- package/dist/node_modules/use-callback-ref/dist/es2015/useRef.js.map +1 -0
- package/dist/node_modules/use-sidecar/dist/es2015/exports.cjs +2 -0
- package/dist/node_modules/use-sidecar/dist/es2015/exports.cjs.map +1 -0
- package/dist/node_modules/use-sidecar/dist/es2015/exports.js +19 -0
- package/dist/node_modules/use-sidecar/dist/es2015/exports.js.map +1 -0
- package/dist/node_modules/use-sidecar/dist/es2015/medium.cjs +2 -0
- package/dist/node_modules/use-sidecar/dist/es2015/medium.cjs.map +1 -0
- package/dist/node_modules/use-sidecar/dist/es2015/medium.js +68 -0
- package/dist/node_modules/use-sidecar/dist/es2015/medium.js.map +1 -0
- package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.cjs +2 -0
- package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.cjs.map +1 -0
- package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +59 -0
- package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js.map +1 -0
- package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.cjs +2 -0
- package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.cjs.map +1 -0
- package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js +47 -0
- package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js.map +1 -0
- package/dist/node_modules/use-sync-external-store/shim/index.cjs +2 -0
- package/dist/node_modules/use-sync-external-store/shim/index.cjs.map +1 -0
- package/dist/node_modules/use-sync-external-store/shim/index.js +11 -0
- package/dist/node_modules/use-sync-external-store/shim/index.js.map +1 -0
- package/dist/providers/auth/auth.context.cjs +2 -0
- package/dist/providers/auth/auth.context.cjs.map +1 -0
- package/dist/providers/auth/auth.context.d.ts +3 -0
- package/dist/providers/auth/auth.context.d.ts.map +1 -0
- package/dist/providers/auth/auth.context.js +6 -0
- package/dist/providers/auth/auth.context.js.map +1 -0
- package/dist/providers/auth/auth.hook.cjs +2 -0
- package/dist/providers/auth/auth.hook.cjs.map +1 -0
- package/dist/providers/auth/auth.hook.d.ts +7 -0
- package/dist/providers/auth/auth.hook.d.ts.map +1 -0
- package/dist/providers/auth/auth.hook.js +12 -0
- package/dist/providers/auth/auth.hook.js.map +1 -0
- package/dist/providers/auth/auth.provider.cjs +2 -0
- package/dist/providers/auth/auth.provider.cjs.map +1 -0
- package/dist/providers/auth/auth.provider.d.ts +7 -0
- package/dist/providers/auth/auth.provider.d.ts.map +1 -0
- package/dist/providers/auth/auth.provider.js +29 -0
- package/dist/providers/auth/auth.provider.js.map +1 -0
- package/dist/providers/blimu/blimu.context.cjs +2 -0
- package/dist/providers/blimu/blimu.context.cjs.map +1 -0
- package/dist/providers/blimu/blimu.context.d.ts +27 -0
- package/dist/providers/blimu/blimu.context.d.ts.map +1 -0
- package/dist/providers/blimu/blimu.context.js +6 -0
- package/dist/providers/blimu/blimu.context.js.map +1 -0
- package/dist/providers/blimu/blimu.hook.cjs +2 -0
- package/dist/providers/blimu/blimu.hook.cjs.map +1 -0
- package/dist/providers/blimu/blimu.hook.d.ts +19 -0
- package/dist/providers/blimu/blimu.hook.d.ts.map +1 -0
- package/dist/providers/blimu/blimu.hook.js +12 -0
- package/dist/providers/blimu/blimu.hook.js.map +1 -0
- package/dist/providers/blimu/blimu.provider.cjs +2 -0
- package/dist/providers/blimu/blimu.provider.cjs.map +1 -0
- package/dist/providers/blimu/blimu.provider.d.ts +47 -0
- package/dist/providers/blimu/blimu.provider.d.ts.map +1 -0
- package/dist/providers/blimu/blimu.provider.js +67 -0
- package/dist/providers/blimu/blimu.provider.js.map +1 -0
- package/dist/providers/index.d.ts +7 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/theme/index.d.ts +4 -0
- package/dist/providers/theme/index.d.ts.map +1 -0
- package/dist/providers/theme/theme.context.cjs +2 -0
- package/dist/providers/theme/theme.context.cjs.map +1 -0
- package/dist/providers/theme/theme.context.d.ts +8 -0
- package/dist/providers/theme/theme.context.d.ts.map +1 -0
- package/dist/providers/theme/theme.context.js +6 -0
- package/dist/providers/theme/theme.context.js.map +1 -0
- package/dist/providers/theme/theme.hook.cjs +2 -0
- package/dist/providers/theme/theme.hook.cjs.map +1 -0
- package/dist/providers/theme/theme.hook.d.ts +18 -0
- package/dist/providers/theme/theme.hook.d.ts.map +1 -0
- package/dist/providers/theme/theme.hook.js +12 -0
- package/dist/providers/theme/theme.hook.js.map +1 -0
- package/dist/providers/theme/theme.provider.cjs +2 -0
- package/dist/providers/theme/theme.provider.cjs.map +1 -0
- package/dist/providers/theme/theme.provider.d.ts +28 -0
- package/dist/providers/theme/theme.provider.d.ts.map +1 -0
- package/dist/providers/theme/theme.provider.js +68 -0
- package/dist/providers/theme/theme.provider.js.map +1 -0
- package/dist/providers.cjs +2 -0
- package/dist/providers.cjs.map +1 -0
- package/dist/providers.js +13 -0
- package/dist/providers.js.map +1 -0
- package/dist/styles/styles.css +1351 -0
- package/dist/styles/tw-styles.css +120 -0
- package/dist/tailwind.plugin.cjs +2 -0
- package/dist/tailwind.plugin.cjs.map +1 -0
- package/dist/tailwind.plugin.d.ts +19 -0
- package/dist/tailwind.plugin.d.ts.map +1 -0
- package/dist/tailwind.plugin.js +200 -0
- package/dist/tailwind.plugin.js.map +1 -0
- package/dist/types/index.cjs +2 -0
- package/dist/types/index.cjs.map +1 -0
- package/dist/types/index.d.ts +128 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +12 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/publishable-key.cjs +2 -0
- package/dist/utils/publishable-key.cjs.map +1 -0
- package/dist/utils/publishable-key.d.ts +38 -0
- package/dist/utils/publishable-key.d.ts.map +1 -0
- package/dist/utils/publishable-key.js +38 -0
- package/dist/utils/publishable-key.js.map +1 -0
- package/package.json +128 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Blimu } from '@blimu/client';
|
|
2
|
+
import type { AuthState, User } from '../types';
|
|
3
|
+
import { ExternalStore } from './external-store';
|
|
4
|
+
export declare const SESSION_COOKIE_NAME = "__bli_session";
|
|
5
|
+
export declare const LOCALHOST_JWT_URL_PARAM_NAME = "__lh_jwt";
|
|
6
|
+
export declare const LOCALHOST_JWT_COOKIE_NAME = "__lh_jwt";
|
|
7
|
+
export declare const SESSION_EXPIRATION_BUFFER = 10;
|
|
8
|
+
/**
|
|
9
|
+
* Check if a JWT expiration time (in seconds) is expired or will expire within the buffer
|
|
10
|
+
* @param expiration - JWT exp claim in seconds (Unix timestamp)
|
|
11
|
+
* @param buffer - Buffer time in seconds before expiration to consider it expired
|
|
12
|
+
* @returns true if expired or will expire within buffer
|
|
13
|
+
*/
|
|
14
|
+
export declare const isExpiredIn: (expiration: number, buffer: number) => boolean;
|
|
15
|
+
export declare class AuthSessionService {
|
|
16
|
+
private readonly isLive;
|
|
17
|
+
private readonly client;
|
|
18
|
+
private readonly store;
|
|
19
|
+
private pendingRefresher;
|
|
20
|
+
private refreshPromise;
|
|
21
|
+
private refreshingSignals;
|
|
22
|
+
private refreshingSignalAbortController;
|
|
23
|
+
private localClient;
|
|
24
|
+
constructor(isLive: boolean, client: Blimu, store: ExternalStore<AuthState>, baseURL: string, publishableKey: string);
|
|
25
|
+
/**
|
|
26
|
+
* Set cookie with appropriate security settings based on environment
|
|
27
|
+
*/
|
|
28
|
+
private setCookie;
|
|
29
|
+
getSessionPayload(): {
|
|
30
|
+
sub: string;
|
|
31
|
+
environmentId: string;
|
|
32
|
+
type: string;
|
|
33
|
+
iat: number;
|
|
34
|
+
exp: number;
|
|
35
|
+
} | null;
|
|
36
|
+
getSessionToken(): Promise<string | undefined>;
|
|
37
|
+
handleRequestError(error: unknown): Promise<{
|
|
38
|
+
error: string;
|
|
39
|
+
user: null;
|
|
40
|
+
}>;
|
|
41
|
+
initialize({ signal }?: {
|
|
42
|
+
signal?: AbortSignal;
|
|
43
|
+
}): Promise<{
|
|
44
|
+
error: string | null;
|
|
45
|
+
user: User | null;
|
|
46
|
+
}>;
|
|
47
|
+
scheduleRefresh(): () => void;
|
|
48
|
+
private refreshSession;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=auth.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.service.d.ts","sourceRoot":"","sources":["../../src/client/auth.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAc,MAAM,eAAe,CAA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E,UAAU,CAAC,EAAE,MAAM,EAAE,GAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAA;KAAO,GAAG,OAAO,CAAC;QACnE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;QACrB,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;KACnB,CAAC;IAgDF,eAAe;YAwFD,cAAc;CA6D7B"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { Blimu as _, BlimuError as A } from "@blimu/client";
|
|
2
|
+
import o from "../node_modules/js-cookie/dist/js.cookie.js";
|
|
3
|
+
import { jwtDecode as C } from "../node_modules/jwt-decode/build/esm/index.js";
|
|
4
|
+
const h = "__bli_session", S = "__lh_jwt", u = "__lh_jwt", w = 10, m = 1e3, E = (t) => Math.floor(t * m), b = (t) => Math.floor(t / m), p = () => b(Date.now()), P = (t) => E(t), T = (t, e) => {
|
|
5
|
+
const s = P(t), r = E(e), n = Date.now();
|
|
6
|
+
return Math.max(s - r - n, 0);
|
|
7
|
+
}, f = (t, e) => {
|
|
8
|
+
const s = p();
|
|
9
|
+
return t - e < s;
|
|
10
|
+
};
|
|
11
|
+
class v {
|
|
12
|
+
constructor(e, s, r, n, l) {
|
|
13
|
+
this.isLive = e, this.client = s, this.store = r, this.pendingRefresher = null, this.refreshPromise = null, this.refreshingSignals = /* @__PURE__ */ new Set(), this.refreshingSignalAbortController = null, this.localClient = new _({
|
|
14
|
+
baseURL: n,
|
|
15
|
+
credentials: "include",
|
|
16
|
+
headers: { "x-blimu-publishable-key": l }
|
|
17
|
+
}), this.handleRequestError = this.handleRequestError.bind(this);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Set cookie with appropriate security settings based on environment
|
|
21
|
+
*/
|
|
22
|
+
setCookie(e, s, r = {}) {
|
|
23
|
+
const n = {
|
|
24
|
+
secure: this.isLive,
|
|
25
|
+
// true for live environments, false for localhost
|
|
26
|
+
sameSite: "lax",
|
|
27
|
+
path: "/"
|
|
28
|
+
};
|
|
29
|
+
r.maxAge !== void 0 && (n.expires = r.maxAge / (1440 * 60)), o.set(e, s, n);
|
|
30
|
+
}
|
|
31
|
+
getSessionPayload() {
|
|
32
|
+
const e = o.get(h);
|
|
33
|
+
return e ? C(e) : null;
|
|
34
|
+
}
|
|
35
|
+
async getSessionToken() {
|
|
36
|
+
const e = this.getSessionPayload();
|
|
37
|
+
if (e)
|
|
38
|
+
return this.refreshPromise ? (await this.refreshPromise, o.get(h)) : (f(e.exp, 0) && await this.refreshSession(), o.get(h));
|
|
39
|
+
}
|
|
40
|
+
async handleRequestError(e) {
|
|
41
|
+
return e instanceof A && [401, 500].includes(e.status) ? (o.remove(h), o.remove(u), {
|
|
42
|
+
error: e.message,
|
|
43
|
+
user: null
|
|
44
|
+
}) : e instanceof DOMException ? {
|
|
45
|
+
error: e.message,
|
|
46
|
+
user: null
|
|
47
|
+
} : e instanceof Error ? {
|
|
48
|
+
error: e.message,
|
|
49
|
+
user: null
|
|
50
|
+
} : {
|
|
51
|
+
error: "unknown error",
|
|
52
|
+
user: null
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
async initialize({ signal: e } = {}) {
|
|
56
|
+
const s = new URL(window.location.href), r = s.searchParams.get(S) ?? void 0;
|
|
57
|
+
if (r && (s.searchParams.delete(S), window.history.replaceState({}, "", s.toString())), r && this.setCookie(u, r, {
|
|
58
|
+
maxAge: 720 * 60 * 60
|
|
59
|
+
// 30 days
|
|
60
|
+
}), o.get(u) && !o.get(h)) {
|
|
61
|
+
const i = await this.refreshSession({ signal: e }).catch(this.handleRequestError);
|
|
62
|
+
if ("error" in i) return i;
|
|
63
|
+
}
|
|
64
|
+
const l = this.getSessionPayload();
|
|
65
|
+
if (!l)
|
|
66
|
+
return {
|
|
67
|
+
error: null,
|
|
68
|
+
user: null
|
|
69
|
+
};
|
|
70
|
+
if (f(l.exp, w)) {
|
|
71
|
+
const i = await this.refreshSession().catch(this.handleRequestError);
|
|
72
|
+
if ("error" in i) return i;
|
|
73
|
+
}
|
|
74
|
+
const a = await this.client.auth.getSession().catch(this.handleRequestError);
|
|
75
|
+
return "error" in a ? a : {
|
|
76
|
+
error: null,
|
|
77
|
+
user: a.user
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
scheduleRefresh() {
|
|
81
|
+
const e = new AbortController();
|
|
82
|
+
let s = !0, r = null;
|
|
83
|
+
const n = () => {
|
|
84
|
+
s = !0, this.pendingRefresher && (this.pendingRefresher(), this.pendingRefresher = null);
|
|
85
|
+
}, l = () => {
|
|
86
|
+
s = !1;
|
|
87
|
+
};
|
|
88
|
+
window.addEventListener("online", n), window.addEventListener("offline", l);
|
|
89
|
+
const a = () => {
|
|
90
|
+
r !== null && (window.clearTimeout(r), r = null);
|
|
91
|
+
const i = this.getSessionPayload();
|
|
92
|
+
if (!i || f(i.exp, 0)) return;
|
|
93
|
+
const d = T(i.exp, w);
|
|
94
|
+
if (d < 0)
|
|
95
|
+
return;
|
|
96
|
+
const g = async () => {
|
|
97
|
+
if (r = null, !s) {
|
|
98
|
+
this.pendingRefresher = g;
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const c = await this.refreshSession({ signal: e.signal });
|
|
102
|
+
if ("error" in c) {
|
|
103
|
+
if (c.error === "aborted")
|
|
104
|
+
return;
|
|
105
|
+
this.store.setState({
|
|
106
|
+
status: "error",
|
|
107
|
+
user: null,
|
|
108
|
+
error: c.error
|
|
109
|
+
});
|
|
110
|
+
return;
|
|
111
|
+
} else
|
|
112
|
+
a();
|
|
113
|
+
};
|
|
114
|
+
r = window.setTimeout(g, d);
|
|
115
|
+
};
|
|
116
|
+
return a(), () => {
|
|
117
|
+
r && window.clearTimeout(r), e.abort(), window.removeEventListener("online", n), window.removeEventListener("offline", l);
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
async refreshSession({ signal: e } = {}) {
|
|
121
|
+
if (e && (this.refreshingSignals.add(e), e.addEventListener("abort", () => {
|
|
122
|
+
this.refreshingSignals.delete(e), this.refreshingSignals.size === 0 && this.refreshingSignalAbortController?.abort();
|
|
123
|
+
})), this.refreshPromise)
|
|
124
|
+
return this.refreshPromise;
|
|
125
|
+
this.refreshingSignalAbortController = new AbortController(), this.refreshingSignalAbortController.signal.addEventListener("abort", () => {
|
|
126
|
+
this.refreshPromise = null, this.refreshingSignalAbortController = null, this.refreshingSignals.clear();
|
|
127
|
+
});
|
|
128
|
+
const s = o.get(u);
|
|
129
|
+
this.refreshPromise = this.localClient.auth.refresh(
|
|
130
|
+
{ __lh_jwt: s },
|
|
131
|
+
{
|
|
132
|
+
signal: this.refreshingSignalAbortController.signal
|
|
133
|
+
}
|
|
134
|
+
).then((r) => (r.sessionToken && this.setCookie(h, r.sessionToken, {
|
|
135
|
+
maxAge: 720 * 60 * 60
|
|
136
|
+
// 30 days
|
|
137
|
+
}), r)).catch(this.handleRequestError);
|
|
138
|
+
try {
|
|
139
|
+
return await this.refreshPromise;
|
|
140
|
+
} finally {
|
|
141
|
+
this.refreshPromise = null, this.refreshingSignalAbortController = null, this.refreshingSignals.clear();
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
export {
|
|
146
|
+
v as AuthSessionService,
|
|
147
|
+
u as LOCALHOST_JWT_COOKIE_NAME,
|
|
148
|
+
S as LOCALHOST_JWT_URL_PARAM_NAME,
|
|
149
|
+
h as SESSION_COOKIE_NAME,
|
|
150
|
+
w as SESSION_EXPIRATION_BUFFER,
|
|
151
|
+
f as isExpiredIn
|
|
152
|
+
};
|
|
153
|
+
//# sourceMappingURL=auth.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.service.js","sources":["../../src/client/auth.service.ts"],"sourcesContent":["import { Blimu, BlimuError } from '@blimu/client';\nimport type { RefreshResponse } from '@blimu/client/schema';\nimport Cookies from 'js-cookie';\nimport { jwtDecode } from 'jwt-decode';\n\nimport type { AuthState, User } from '../types';\nimport { ExternalStore } from './external-store';\n\nexport const SESSION_COOKIE_NAME = '__bli_session';\nexport const LOCALHOST_JWT_URL_PARAM_NAME = '__lh_jwt';\nexport const LOCALHOST_JWT_COOKIE_NAME = '__lh_jwt';\nexport const SESSION_EXPIRATION_BUFFER = 10;\n\n/**\n * Time conversion utilities\n * JWT tokens use seconds (Unix timestamp), JavaScript Date uses milliseconds\n */\nconst SECONDS_TO_MS = 1000;\n\n/**\n * Convert seconds to milliseconds\n */\nconst secondsToMilliseconds = (seconds: number): number => Math.floor(seconds * SECONDS_TO_MS);\n\n/**\n * Convert milliseconds to seconds\n */\nconst millisecondsToSeconds = (ms: number): number => Math.floor(ms / SECONDS_TO_MS);\n\n/**\n * Get current time in seconds (Unix timestamp)\n */\nconst nowInSeconds = (): number => millisecondsToSeconds(Date.now());\n\n/**\n * Convert JWT expiration time (seconds) to milliseconds\n */\nconst jwtExpToMilliseconds = (exp: number): number => secondsToMilliseconds(exp);\n\n/**\n * Calculate timeout delay in milliseconds for refreshing before expiration\n * @param expirationSeconds - JWT exp claim in seconds\n * @param bufferSeconds - Buffer time in seconds before expiration\n * @returns Timeout delay in milliseconds\n */\nconst calculateTimeoutDelay = (expirationSeconds: number, bufferSeconds: number): number => {\n const expirationMS = jwtExpToMilliseconds(expirationSeconds);\n const bufferMS = secondsToMilliseconds(bufferSeconds);\n const nowMS = Date.now();\n return Math.max(expirationMS - bufferMS - nowMS, 0);\n};\n\n/**\n * Check if a JWT expiration time (in seconds) is expired or will expire within the buffer\n * @param expiration - JWT exp claim in seconds (Unix timestamp)\n * @param buffer - Buffer time in seconds before expiration to consider it expired\n * @returns true if expired or will expire within buffer\n */\nexport const isExpiredIn = (expiration: number, buffer: number): boolean => {\n const now = nowInSeconds();\n return expiration - buffer < now;\n};\n\nexport class AuthSessionService {\n private pendingRefresher: (() => void) | null = null;\n private refreshPromise: Promise<RefreshResponse | { error: string; user: null }> | null = null;\n private refreshingSignals: Set<AbortSignal> = new Set();\n private refreshingSignalAbortController: AbortController | null = null;\n // A local client that doesn't call getSessionToken() which calls refreshSession().\n private localClient: Blimu;\n\n constructor(\n private readonly isLive: boolean,\n private readonly client: Blimu,\n private readonly store: ExternalStore<AuthState>,\n baseURL: string,\n publishableKey: string,\n ) {\n this.localClient = new Blimu({\n baseURL,\n credentials: 'include',\n headers: { 'x-blimu-publishable-key': publishableKey },\n });\n this.handleRequestError = this.handleRequestError.bind(this);\n }\n\n /**\n * Set cookie with appropriate security settings based on environment\n */\n private setCookie(name: string, value: string, options: { maxAge?: number } = {}): void {\n const cookieOptions: Cookies.CookieAttributes = {\n secure: this.isLive, // true for live environments, false for localhost\n sameSite: 'lax',\n path: '/',\n };\n\n if (options.maxAge !== undefined) {\n cookieOptions.expires = options.maxAge / (24 * 60 * 60); // Convert seconds to days\n }\n\n Cookies.set(name, value, cookieOptions);\n }\n\n getSessionPayload(): {\n sub: string;\n environmentId: string;\n type: string;\n iat: number;\n exp: number;\n } | null {\n const token = Cookies.get(SESSION_COOKIE_NAME);\n\n if (!token) {\n return null;\n }\n\n const decoded = jwtDecode<{\n sub: string;\n environmentId: string;\n type: string;\n iat: number;\n exp: number;\n }>(token);\n\n return decoded;\n }\n\n async getSessionToken(): Promise<string | undefined> {\n const sessionPayload = this.getSessionPayload();\n\n if (!sessionPayload) {\n return undefined;\n }\n\n // If a refresh is already in progress, wait for it to complete\n // This prevents infinite recursion when refreshSession() calls client.auth.refresh()\n // which triggers accessToken() which calls getSessionToken()\n if (this.refreshPromise) {\n await this.refreshPromise;\n // After refresh completes, return the updated token from cookie\n return Cookies.get(SESSION_COOKIE_NAME);\n }\n\n if (isExpiredIn(sessionPayload.exp, 0)) {\n await this.refreshSession();\n }\n\n return Cookies.get(SESSION_COOKIE_NAME);\n }\n\n async handleRequestError(error: unknown): Promise<{ error: string; user: null }> {\n if (error instanceof BlimuError && [401, 500].includes(error.status)) {\n Cookies.remove(SESSION_COOKIE_NAME);\n Cookies.remove(LOCALHOST_JWT_COOKIE_NAME);\n\n return {\n error: error.message,\n user: null,\n };\n }\n\n if (error instanceof DOMException)\n return {\n error: error.message,\n user: null,\n };\n\n if (error instanceof Error) {\n return {\n error: error.message,\n user: null,\n };\n }\n\n return {\n error: 'unknown error',\n user: null,\n };\n }\n\n async initialize({ signal }: { signal?: AbortSignal } = {}): Promise<{\n error: string | null;\n user: User | null;\n }> {\n const url = new URL(window.location.href);\n const localhostJWT = url.searchParams.get(LOCALHOST_JWT_URL_PARAM_NAME) ?? undefined;\n\n // Clean up URL parameters immediately to prevent re-processing on re-renders\n if (localhostJWT) {\n url.searchParams.delete(LOCALHOST_JWT_URL_PARAM_NAME);\n window.history.replaceState({}, '', url.toString());\n }\n\n // Handle localhost JWT from URL parameter\n if (localhostJWT) {\n // Set localhost JWT cookie on customer app domain\n this.setCookie(LOCALHOST_JWT_COOKIE_NAME, localhostJWT, {\n maxAge: 30 * 24 * 60 * 60, // 30 days\n });\n }\n\n const localhostJWTCookie = Cookies.get(LOCALHOST_JWT_COOKIE_NAME);\n\n if (localhostJWTCookie && !Cookies.get(SESSION_COOKIE_NAME)) {\n const result = await this.refreshSession({ signal }).catch(this.handleRequestError);\n if ('error' in result) return result;\n }\n\n const sessionPayload = this.getSessionPayload();\n\n if (!sessionPayload) {\n return {\n error: null,\n user: null,\n };\n }\n\n if (isExpiredIn(sessionPayload.exp, SESSION_EXPIRATION_BUFFER)) {\n const result = await this.refreshSession().catch(this.handleRequestError);\n if ('error' in result) return result;\n }\n\n const result = await this.client.auth.getSession().catch(this.handleRequestError);\n if ('error' in result) return result;\n\n return {\n error: null,\n user: result.user,\n };\n }\n\n scheduleRefresh() {\n const abortController = new AbortController();\n let isOnline = true;\n let timeoutId: number | null = null;\n\n const onlineHandler = () => {\n isOnline = true;\n if (this.pendingRefresher) {\n this.pendingRefresher();\n this.pendingRefresher = null;\n }\n };\n const offlineHandler = () => {\n isOnline = false;\n };\n\n window.addEventListener('online', onlineHandler);\n window.addEventListener('offline', offlineHandler);\n\n const refresh = () => {\n // Clear any existing timeout before scheduling a new one\n // This prevents infinite loops when refresh() is called recursively\n if (timeoutId !== null) {\n window.clearTimeout(timeoutId);\n timeoutId = null;\n }\n\n const sessionPayload = this.getSessionPayload();\n\n if (!sessionPayload || isExpiredIn(sessionPayload.exp, 0)) return;\n\n // Calculate timeout delay: refresh SESSION_EXPIRATION_BUFFER seconds before expiration\n const timeoutDelayMS = calculateTimeoutDelay(sessionPayload.exp, SESSION_EXPIRATION_BUFFER);\n\n // Prevent scheduling if timeout is negative (token already expired)\n // Allow 0ms delays to handle edge cases where we're exactly at the refresh point\n // This prevents immediate re-scheduling that could cause infinite loops\n if (timeoutDelayMS < 0) {\n return;\n }\n\n // Having this function outside timeout, allows us to call refresh immediately when back online\n const refresher = async () => {\n // Clear timeoutId since we're executing now\n timeoutId = null;\n\n if (!isOnline) {\n // Keep closure of refresh function alive\n this.pendingRefresher = refresher;\n return;\n }\n\n const result = await this.refreshSession({ signal: abortController.signal });\n\n if ('error' in result) {\n // If the refresh was aborted (e.g., due to React strict mode unmounting),\n // don't treat it as an error - just return and let the component remount handle it\n if (result.error === 'aborted') {\n return;\n }\n // For real errors, update the store\n this.store.setState({\n status: 'error',\n user: null,\n error: result.error,\n });\n return;\n } else {\n // After successful refresh, schedule the next refresh with the new token\n refresh();\n }\n };\n\n timeoutId = window.setTimeout(refresher, timeoutDelayMS);\n };\n\n refresh();\n\n return () => {\n if (timeoutId) {\n window.clearTimeout(timeoutId);\n }\n abortController.abort();\n window.removeEventListener('online', onlineHandler);\n window.removeEventListener('offline', offlineHandler);\n };\n }\n\n private async refreshSession({ signal }: { signal?: AbortSignal } = {}) {\n if (signal) {\n // Add signal to tracking set (was using .has() instead of .add() - bug fix)\n this.refreshingSignals.add(signal);\n\n signal.addEventListener('abort', () => {\n this.refreshingSignals.delete(signal);\n\n if (this.refreshingSignals.size === 0) {\n this.refreshingSignalAbortController?.abort();\n }\n });\n }\n\n if (this.refreshPromise) {\n return this.refreshPromise;\n }\n\n this.refreshingSignalAbortController = new AbortController();\n\n this.refreshingSignalAbortController.signal.addEventListener('abort', () => {\n this.refreshPromise = null;\n this.refreshingSignalAbortController = null;\n this.refreshingSignals.clear();\n });\n\n // Get localhost_jwt from cookie to send as query parameter\n const localhostJWT = Cookies.get(LOCALHOST_JWT_COOKIE_NAME);\n\n // Use local client to avoid infinite recursion. Regular client calls getSessionToken() which calls refreshSession().\n // There are hacks to avoid infinite recursion, but they are not reliable.\n // The localhost_jwt is sent as a query parameter\n // Note: Type assertion needed because the generated SDK type doesn't include 'query' in RequestInit,\n // but the underlying CoreClient.request() method does support it\n this.refreshPromise = this.localClient.auth\n .refresh(\n { __lh_jwt: localhostJWT },\n {\n signal: this.refreshingSignalAbortController.signal,\n },\n )\n .then((response) => {\n // Update cookie with new session token from response body\n // Server also sets it via Set-Cookie header on auth domain, but we set it manually on customer domain\n if (response.sessionToken) {\n this.setCookie(SESSION_COOKIE_NAME, response.sessionToken, {\n maxAge: 30 * 24 * 60 * 60, // 30 days\n });\n }\n return response;\n })\n .catch(this.handleRequestError);\n\n try {\n return await this.refreshPromise;\n } finally {\n this.refreshPromise = null;\n this.refreshingSignalAbortController = null;\n this.refreshingSignals.clear();\n }\n }\n}\n"],"names":["SESSION_COOKIE_NAME","LOCALHOST_JWT_URL_PARAM_NAME","LOCALHOST_JWT_COOKIE_NAME","SESSION_EXPIRATION_BUFFER","SECONDS_TO_MS","secondsToMilliseconds","seconds","millisecondsToSeconds","ms","nowInSeconds","jwtExpToMilliseconds","exp","calculateTimeoutDelay","expirationSeconds","bufferSeconds","expirationMS","bufferMS","nowMS","isExpiredIn","expiration","buffer","now","AuthSessionService","isLive","client","store","baseURL","publishableKey","Blimu","name","value","options","cookieOptions","Cookies","token","jwtDecode","sessionPayload","error","BlimuError","signal","url","localhostJWT","result","abortController","isOnline","timeoutId","onlineHandler","offlineHandler","refresh","timeoutDelayMS","refresher","response"],"mappings":";;;AAQO,MAAMA,IAAsB,iBACtBC,IAA+B,YAC/BC,IAA4B,YAC5BC,IAA4B,IAMnC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AA;AAAA,IAAA,CACxB,GAEIA,EACR,EACA,MAAM,KAAK,kBAAkB;AAEhC,QAAI;AACF,aAAO,MAAM,KAAK;AAAA,IACpB,UAAA;AACE,WAAK,iBAAiB,MACtB,KAAK,kCAAkC,MACvC,KAAK,kBAAkB,MAAA;AAAA,IACzB;AAAA,EACF;AACF;"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { AuthState } from '../types';
|
|
2
|
+
import { Blimu } from '@blimu/client';
|
|
3
|
+
import { ExternalStore } from './external-store';
|
|
4
|
+
import { BaseAuthSessionService } from './auth.service.base';
|
|
5
|
+
export declare const LOCALHOST_JWT_URL_PARAM_NAME = "__lh_jwt";
|
|
6
|
+
export declare const LOCALHOST_JWT_COOKIE_NAME = "__lh_jwt";
|
|
7
|
+
/**
|
|
8
|
+
* Test/development authentication session service.
|
|
9
|
+
* Handles non-secure cookies and supports localhost JWT handling for development.
|
|
10
|
+
*/
|
|
11
|
+
export declare class TestAuthSessionService extends BaseAuthSessionService {
|
|
12
|
+
constructor(client: Blimu, store: ExternalStore<AuthState>, baseURL: string, publishableKey: string);
|
|
13
|
+
/**
|
|
14
|
+
* Set cookie with secure flag disabled for localhost development.
|
|
15
|
+
*/
|
|
16
|
+
protected setCookie(name: string, value: string, options?: {
|
|
17
|
+
maxAge?: number;
|
|
18
|
+
}): void;
|
|
19
|
+
/**
|
|
20
|
+
* Get localhost JWT from cookie.
|
|
21
|
+
* This method only exists in TestAuthSessionService - not in base class or live service.
|
|
22
|
+
* Note: URL parameter handling is done in initialize() and stored in cookie.
|
|
23
|
+
*/
|
|
24
|
+
private getLocalhostJWT;
|
|
25
|
+
/**
|
|
26
|
+
* Build refresh request parameters.
|
|
27
|
+
* Test services include localhost JWT if available.
|
|
28
|
+
*/
|
|
29
|
+
protected buildRefreshParams(): Record<string, string | undefined>;
|
|
30
|
+
/**
|
|
31
|
+
* Test services handle localhost JWT.
|
|
32
|
+
*/
|
|
33
|
+
protected shouldHandleLocalhostJWT(): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Remove localhost JWT cookie on errors.
|
|
36
|
+
*/
|
|
37
|
+
protected cleanupLocalhostJWT(): void;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=auth.service.test-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.service.test-service.d.ts","sourceRoot":"","sources":["../../src/client/auth.service.test-service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,eAAO,MAAM,4BAA4B,aAAa,CAAC;AACvD,eAAO,MAAM,yBAAyB,aAAa,CAAC;AAEpD;;;GAGG;AACH,qBAAa,sBAAuB,SAAQ,sBAAsB;gBAE9D,MAAM,EAAE,KAAK,EACb,KAAK,EAAE,aAAa,CAAC,SAAS,CAAC,EAC/B,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,MAAM;IAKxB;;OAEG;IACH,SAAS,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,IAAI;IAczF;;;;OAIG;IACH,OAAO,CAAC,eAAe;IAIvB;;;OAGG;IACH,SAAS,CAAC,kBAAkB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAKlE;;OAEG;IACH,SAAS,CAAC,wBAAwB,IAAI,OAAO;IAI7C;;OAEG;IACH,SAAS,CAAC,mBAAmB,IAAI,IAAI;CAGtC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class i{constructor(e){this.listeners=new Set,this.subscribe=t=>(this.listeners.add(t),()=>{this.listeners.delete(t)}),this.setState=t=>{typeof t=="function"?this.state=t(this.state):this.state=t,this.listeners.forEach(s=>s(this.state))},this.getSnapshot=()=>this.state,this.state=e}}exports.ExternalStore=i;
|
|
2
|
+
//# sourceMappingURL=external-store.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"external-store.cjs","sources":["../../src/client/external-store.ts"],"sourcesContent":["export class ExternalStore<T> {\n private state: T;\n private listeners: Set<(state: T) => void> = new Set();\n\n constructor(initialState: T) {\n this.state = initialState;\n }\n\n /**\n * Subscribe to state changes\n * Returns an unsubscribe function\n */\n subscribe = (listener: (state: T) => void): (() => void) => {\n this.listeners.add(listener);\n // Return unsubscribe function\n return () => {\n this.listeners.delete(listener);\n };\n };\n\n /**\n * Update state and notify all listeners\n * Accepts either a new state value or a function updater\n */\n setState = (state: T | ((state: T) => T)) => {\n if (typeof state === 'function') {\n this.state = (state as (prev: T) => T)(this.state);\n } else {\n this.state = state;\n }\n // Notify all listeners\n this.listeners.forEach((listener) => listener(this.state));\n };\n\n /**\n * Get current state without subscribing\n */\n getSnapshot = (): T => {\n return this.state;\n };\n}\n"],"names":["ExternalStore","initialState","listener","state"],"mappings":"gFAAO,MAAMA,CAAiB,CAI5B,YAAYC,EAAiB,CAF7B,KAAQ,cAAyC,IAUjD,KAAA,UAAaC,IACX,KAAK,UAAU,IAAIA,CAAQ,EAEpB,IAAM,CACX,KAAK,UAAU,OAAOA,CAAQ,CAChC,GAOF,KAAA,SAAYC,GAAiC,CACvC,OAAOA,GAAU,WACnB,KAAK,MAASA,EAAyB,KAAK,KAAK,EAEjD,KAAK,MAAQA,EAGf,KAAK,UAAU,QAASD,GAAaA,EAAS,KAAK,KAAK,CAAC,CAC3D,EAKA,KAAA,YAAc,IACL,KAAK,MAjCZ,KAAK,MAAQD,CACf,CAkCF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare class ExternalStore<T> {
|
|
2
|
+
private state;
|
|
3
|
+
private listeners;
|
|
4
|
+
constructor(initialState: T);
|
|
5
|
+
/**
|
|
6
|
+
* Subscribe to state changes
|
|
7
|
+
* Returns an unsubscribe function
|
|
8
|
+
*/
|
|
9
|
+
subscribe: (listener: (state: T) => void) => (() => void);
|
|
10
|
+
/**
|
|
11
|
+
* Update state and notify all listeners
|
|
12
|
+
* Accepts either a new state value or a function updater
|
|
13
|
+
*/
|
|
14
|
+
setState: (state: T | ((state: T) => T)) => void;
|
|
15
|
+
/**
|
|
16
|
+
* Get current state without subscribing
|
|
17
|
+
*/
|
|
18
|
+
getSnapshot: () => T;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=external-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"external-store.d.ts","sourceRoot":"","sources":["../../src/client/external-store.ts"],"names":[],"mappings":"AAAA,qBAAa,aAAa,CAAC,CAAC;IAC1B,OAAO,CAAC,KAAK,CAAI;IACjB,OAAO,CAAC,SAAS,CAAsC;gBAE3C,YAAY,EAAE,CAAC;IAI3B;;;OAGG;IACH,SAAS,GAAI,UAAU,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,KAAG,CAAC,MAAM,IAAI,CAAC,CAMtD;IAEF;;;OAGG;IACH,QAAQ,GAAI,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,UAQtC;IAEF;;OAEG;IACH,WAAW,QAAO,CAAC,CAEjB;CACH"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
class h {
|
|
2
|
+
constructor(s) {
|
|
3
|
+
this.listeners = /* @__PURE__ */ new Set(), this.subscribe = (t) => (this.listeners.add(t), () => {
|
|
4
|
+
this.listeners.delete(t);
|
|
5
|
+
}), this.setState = (t) => {
|
|
6
|
+
typeof t == "function" ? this.state = t(this.state) : this.state = t, this.listeners.forEach((e) => e(this.state));
|
|
7
|
+
}, this.getSnapshot = () => this.state, this.state = s;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
h as ExternalStore
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=external-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"external-store.js","sources":["../../src/client/external-store.ts"],"sourcesContent":["export class ExternalStore<T> {\n private state: T;\n private listeners: Set<(state: T) => void> = new Set();\n\n constructor(initialState: T) {\n this.state = initialState;\n }\n\n /**\n * Subscribe to state changes\n * Returns an unsubscribe function\n */\n subscribe = (listener: (state: T) => void): (() => void) => {\n this.listeners.add(listener);\n // Return unsubscribe function\n return () => {\n this.listeners.delete(listener);\n };\n };\n\n /**\n * Update state and notify all listeners\n * Accepts either a new state value or a function updater\n */\n setState = (state: T | ((state: T) => T)) => {\n if (typeof state === 'function') {\n this.state = (state as (prev: T) => T)(this.state);\n } else {\n this.state = state;\n }\n // Notify all listeners\n this.listeners.forEach((listener) => listener(this.state));\n };\n\n /**\n * Get current state without subscribing\n */\n getSnapshot = (): T => {\n return this.state;\n };\n}\n"],"names":["ExternalStore","initialState","listener","state"],"mappings":"AAAO,MAAMA,EAAiB;AAAA,EAI5B,YAAYC,GAAiB;AAF7B,SAAQ,gCAAyC,IAAA,GAUjD,KAAA,YAAY,CAACC,OACX,KAAK,UAAU,IAAIA,CAAQ,GAEpB,MAAM;AACX,WAAK,UAAU,OAAOA,CAAQ;AAAA,IAChC,IAOF,KAAA,WAAW,CAACC,MAAiC;AAC3C,MAAI,OAAOA,KAAU,aACnB,KAAK,QAASA,EAAyB,KAAK,KAAK,IAEjD,KAAK,QAAQA,GAGf,KAAK,UAAU,QAAQ,CAACD,MAAaA,EAAS,KAAK,KAAK,CAAC;AAAA,IAC3D,GAKA,KAAA,cAAc,MACL,KAAK,OAjCZ,KAAK,QAAQD;AAAA,EACf;AAkCF;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("@blimu/client"),r=require("../utils/publishable-key.cjs"),o=require("./auth.service.cjs"),a=require("./external-store.cjs");class u{constructor(e){if(this.authDomain=null,this.initialized=!1,this.initializePromise=null,this.initializeAbortController=null,this.redirectToAuth=i=>{const n=i||window.location.href,s=new URL(`${this.authDomain}/login`);s.searchParams.set("redirect_url",encodeURIComponent(n)),window.location.href=s.toString()},this.logout=async()=>{try{const i=this.session.getSessionToken();i&&await this.client.auth.logout({headers:{"x-blimu-publishable-key":this.config.publishableKey,Authorization:`Bearer ${i}`}})}catch(i){console.error("Logout error:",i)}finally{this.store.setState({user:null,error:null,status:"unauthenticated"})}},this.getAccessToken=async i=>await this.session.getSessionToken()??null,this.config=e,this.store=new a.ExternalStore({user:null,error:null,status:"idle"}),this.isLive=e.publishableKey.includes("live"),this.authDomain=r.getAuthDomainFromPublishableKey(e.publishableKey),!this.authDomain)throw new Error("Failed to determine auth domain from publishable key");const t=r.getAuthApiUrl(e.publishableKey);if(!t)throw new Error("Failed to determine auth API URL from publishable key");this.client=new l.Blimu({baseURL:t,accessToken:()=>this.session.getSessionToken(),headers:{"x-blimu-publishable-key":e.publishableKey}}),this.session=new o.AuthSessionService(this.isLive,this.client,this.store,t,e.publishableKey),this.initialize=this.initialize.bind(this)}initialize(){if(!this.initialized&&!this.initializePromise)return this.initializeAbortController=new AbortController,this.initializePromise=this.session.initialize({signal:this.initializeAbortController.signal}).then(e=>{e.error?this.store.setState({user:null,error:e.error,status:"error"}):e.user?this.store.setState({user:e.user,error:null,status:"authenticated"}):this.store.setState({user:null,error:null,status:"unauthenticated"})}).catch(e=>{console.error("Initialize error:",e),this.store.setState({user:null,error:e instanceof Error?e.message:"Initialization failed",status:"error"})}).finally(()=>{this.initialized=!0,this.initializePromise=null}),()=>{console.log("aborting initialize"),this.initializeAbortController?.abort("unmounting"),this.initializePromise=null}}scheduleRefresh(){return this.session.scheduleRefresh()}getClient(){return this.client}}exports.BlimuRuntimeClientWrapper=u;
|
|
2
|
+
//# sourceMappingURL=runtime-client.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-client.cjs","sources":["../../src/client/runtime-client.ts"],"sourcesContent":["import { Blimu } from '@blimu/client';\n\nimport type { AuthState, BlimuConfig, User } from '../types';\nimport { getAuthApiUrl, getAuthDomainFromPublishableKey } from '../utils/publishable-key';\nimport { AuthSessionService, LOCALHOST_JWT_URL_PARAM_NAME } from './auth.service';\nimport { ExternalStore } from './external-store';\n\nexport class BlimuRuntimeClientWrapper {\n private client: Blimu;\n private authDomain: string | null = null;\n private initialized: boolean = false;\n private readonly session: AuthSessionService;\n\n public config: BlimuConfig;\n public isLive: boolean;\n private initializePromise: Promise<void> | null = null;\n private initializeAbortController: AbortController | null = null;\n\n public readonly store: ExternalStore<AuthState>;\n\n constructor(config: BlimuConfig) {\n this.config = config;\n this.store = new ExternalStore<AuthState>({\n user: null,\n error: null,\n status: 'idle',\n });\n this.isLive = config.publishableKey.includes('live');\n\n // Get auth UI domain from publishable key\n this.authDomain = getAuthDomainFromPublishableKey(config.publishableKey);\n if (!this.authDomain) {\n throw new Error('Failed to determine auth domain from publishable key');\n }\n\n // Get auth API URL from publishable key\n const authApiUrl = getAuthApiUrl(config.publishableKey);\n\n if (!authApiUrl) {\n throw new Error('Failed to determine auth API URL from publishable key');\n }\n\n this.client = new Blimu({\n baseURL: authApiUrl,\n accessToken: () => this.session.getSessionToken(),\n headers: { 'x-blimu-publishable-key': config.publishableKey },\n });\n\n this.session = new AuthSessionService(\n this.isLive,\n this.client,\n this.store,\n authApiUrl,\n config.publishableKey,\n );\n\n this.initialize = this.initialize.bind(this);\n }\n\n /**\n * Initialize authentication by checking for existing session\n * Reads session token from cookie and validates it\n * This method is idempotent - if initialization is already in progress, it will wait for that to complete\n */\n initialize(): (() => void) | void {\n // If already initialized, return early\n if (this.initialized) return;\n\n // If initialization is in progress, return early (prevents concurrent calls)\n if (this.initializePromise) return;\n\n this.initializeAbortController = new AbortController();\n\n this.initializePromise = this.session\n .initialize({\n signal: this.initializeAbortController.signal,\n })\n .then((result) => {\n if (result.error) {\n this.store.setState({\n user: null,\n error: result.error,\n status: 'error',\n });\n } else if (result.user) {\n this.store.setState({\n user: result.user,\n error: null,\n status: 'authenticated',\n });\n } else {\n this.store.setState({\n user: null,\n error: null,\n status: 'unauthenticated',\n });\n }\n })\n .catch((error) => {\n console.error('Initialize error:', error);\n this.store.setState({\n user: null,\n error: error instanceof Error ? error.message : 'Initialization failed',\n status: 'error',\n });\n })\n .finally(() => {\n // Mark as initialized after completion (success or failure)\n // This prevents infinite loops from re-renders\n this.initialized = true;\n this.initializePromise = null;\n });\n\n return () => {\n console.log('aborting initialize');\n this.initializeAbortController?.abort('unmounting');\n this.initializePromise = null;\n // Don't reset initialized flag here - let the promise handle it\n };\n }\n\n /**\n * Refresh session token using the client token from httpOnly cookie\n * The client token is stored in an httpOnly cookie and sent automatically\n * Note: The auth worker should extract the __bli_client cookie and include it in the request body\n * This method is idempotent - if a refresh is already in progress, it will wait for that refresh to complete\n */\n public scheduleRefresh() {\n return this.session.scheduleRefresh();\n }\n\n /**\n * Redirect user to auth domain for authentication\n * Uses the auth domain derived from the publishable key\n */\n public redirectToAuth = (returnUrl?: string): void => {\n const redirectUrl = returnUrl || window.location.href;\n\n // Build auth URL on the auth domain\n const authUrl = new URL(`${this.authDomain}/login`);\n authUrl.searchParams.set('redirect_url', encodeURIComponent(redirectUrl));\n\n // Redirect to auth domain\n window.location.href = authUrl.toString();\n };\n\n /**\n * Logout user\n * Calls the logout endpoint on the API domain using this.client\n */\n public logout = async (): Promise<void> => {\n try {\n const sessionToken = this.session.getSessionToken();\n\n if (sessionToken) {\n await this.client.auth.logout({\n headers: {\n 'x-blimu-publishable-key': this.config.publishableKey,\n Authorization: `Bearer ${sessionToken}`,\n },\n });\n }\n } catch (error) {\n console.error('Logout error:', error);\n } finally {\n this.store.setState({\n user: null,\n error: null,\n status: 'unauthenticated',\n });\n }\n };\n\n /**\n * Get the current session token\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n getAccessToken = async (_options: { template: 'web' }): Promise<string | null> => {\n return (await this.session.getSessionToken()) ?? null;\n };\n\n /**\n * Get the runtime client for direct API calls\n */\n getClient(): Blimu {\n return this.client;\n }\n}\n"],"names":["BlimuRuntimeClientWrapper","config","returnUrl","redirectUrl","authUrl","sessionToken","error","_options","ExternalStore","getAuthDomainFromPublishableKey","authApiUrl","getAuthApiUrl","Blimu","AuthSessionService","result"],"mappings":"6NAOO,MAAMA,CAA0B,CAarC,YAAYC,EAAqB,CAW/B,GAtBF,KAAQ,WAA4B,KACpC,KAAQ,YAAuB,GAK/B,KAAQ,kBAA0C,KAClD,KAAQ,0BAAoD,KAuH5D,KAAO,eAAkBC,GAA6B,CACpD,MAAMC,EAAcD,GAAa,OAAO,SAAS,KAG3CE,EAAU,IAAI,IAAI,GAAG,KAAK,UAAU,QAAQ,EAClDA,EAAQ,aAAa,IAAI,eAAgB,mBAAmBD,CAAW,CAAC,EAGxE,OAAO,SAAS,KAAOC,EAAQ,SAAA,CACjC,EAMA,KAAO,OAAS,SAA2B,CACzC,GAAI,CACF,MAAMC,EAAe,KAAK,QAAQ,gBAAA,EAE9BA,GACF,MAAM,KAAK,OAAO,KAAK,OAAO,CAC5B,QAAS,CACP,0BAA2B,KAAK,OAAO,eACvC,cAAe,UAAUA,CAAY,EAAA,CACvC,CACD,CAEL,OAASC,EAAO,CACd,QAAQ,MAAM,gBAAiBA,CAAK,CACtC,QAAA,CACE,KAAK,MAAM,SAAS,CAClB,KAAM,KACN,MAAO,KACP,OAAQ,iBAAA,CACT,CACH,CACF,EAMA,KAAA,eAAiB,MAAOC,GACd,MAAM,KAAK,QAAQ,gBAAA,GAAsB,KA7JjD,KAAK,OAASN,EACd,KAAK,MAAQ,IAAIO,gBAAyB,CACxC,KAAM,KACN,MAAO,KACP,OAAQ,MAAA,CACT,EACD,KAAK,OAASP,EAAO,eAAe,SAA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,CACF,CAQO,iBAAkB,CACvB,OAAO,KAAK,QAAQ,gBAAA,CACtB,CAuDA,WAAmB,CACjB,OAAO,KAAK,MACd,CACF"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Blimu } from '@blimu/client';
|
|
2
|
+
import type { AuthState, BlimuConfig } from '../types';
|
|
3
|
+
import { ExternalStore } from './external-store';
|
|
4
|
+
export declare class BlimuRuntimeClientWrapper {
|
|
5
|
+
private client;
|
|
6
|
+
private authDomain;
|
|
7
|
+
private initialized;
|
|
8
|
+
private readonly session;
|
|
9
|
+
config: BlimuConfig;
|
|
10
|
+
isLive: boolean;
|
|
11
|
+
private initializePromise;
|
|
12
|
+
private initializeAbortController;
|
|
13
|
+
readonly store: ExternalStore<AuthState>;
|
|
14
|
+
constructor(config: BlimuConfig);
|
|
15
|
+
/**
|
|
16
|
+
* Initialize authentication by checking for existing session
|
|
17
|
+
* Reads session token from cookie and validates it
|
|
18
|
+
* This method is idempotent - if initialization is already in progress, it will wait for that to complete
|
|
19
|
+
*/
|
|
20
|
+
initialize(): (() => void) | void;
|
|
21
|
+
/**
|
|
22
|
+
* Refresh session token using the client token from httpOnly cookie
|
|
23
|
+
* The client token is stored in an httpOnly cookie and sent automatically
|
|
24
|
+
* Note: The auth worker should extract the __bli_client cookie and include it in the request body
|
|
25
|
+
* This method is idempotent - if a refresh is already in progress, it will wait for that refresh to complete
|
|
26
|
+
*/
|
|
27
|
+
scheduleRefresh(): () => void;
|
|
28
|
+
/**
|
|
29
|
+
* Redirect user to auth domain for authentication
|
|
30
|
+
* Uses the auth domain derived from the publishable key
|
|
31
|
+
*/
|
|
32
|
+
redirectToAuth: (returnUrl?: string) => void;
|
|
33
|
+
/**
|
|
34
|
+
* Logout user
|
|
35
|
+
* Calls the logout endpoint on the API domain using this.client
|
|
36
|
+
*/
|
|
37
|
+
logout: () => Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Get the current session token
|
|
40
|
+
*/
|
|
41
|
+
getAccessToken: (_options: {
|
|
42
|
+
template: "web";
|
|
43
|
+
}) => Promise<string | null>;
|
|
44
|
+
/**
|
|
45
|
+
* Get the runtime client for direct API calls
|
|
46
|
+
*/
|
|
47
|
+
getClient(): Blimu;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=runtime-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-client.d.ts","sourceRoot":"","sources":["../../src/client/runtime-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAQ,MAAM,UAAU,CAAC;AAG7D,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,qBAAa,yBAAyB;IACpC,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,UAAU,CAAuB;IACzC,OAAO,CAAC,WAAW,CAAkB;IACrC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;IAEtC,MAAM,EAAE,WAAW,CAAC;IACpB,MAAM,EAAE,OAAO,CAAC;IACvB,OAAO,CAAC,iBAAiB,CAA8B;IACvD,OAAO,CAAC,yBAAyB,CAAgC;IAEjE,SAAgB,KAAK,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;gBAEpC,MAAM,EAAE,WAAW;IAuC/B;;;;OAIG;IACH,UAAU,IAAI,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI;IAyDjC;;;;;OAKG;IACI,eAAe;IAItB;;;OAGG;IACI,cAAc,GAAI,YAAY,MAAM,KAAG,IAAI,CAShD;IAEF;;;OAGG;IACI,MAAM,QAAa,OAAO,CAAC,IAAI,CAAC,CAqBrC;IAEF;;OAEG;IAEH,cAAc,GAAU,UAAU;QAAE,QAAQ,EAAE,KAAK,CAAA;KAAE,KAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAE5E;IAEF;;OAEG;IACH,SAAS,IAAI,KAAK;CAGnB"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { Blimu as n } from "@blimu/client";
|
|
2
|
+
import { getAuthDomainFromPublishableKey as l, getAuthApiUrl as o } from "../utils/publishable-key.js";
|
|
3
|
+
import { AuthSessionService as a } from "./auth.service.js";
|
|
4
|
+
import { ExternalStore as h } from "./external-store.js";
|
|
5
|
+
class p {
|
|
6
|
+
constructor(i) {
|
|
7
|
+
if (this.authDomain = null, this.initialized = !1, this.initializePromise = null, this.initializeAbortController = null, this.redirectToAuth = (e) => {
|
|
8
|
+
const r = e || window.location.href, s = new URL(`${this.authDomain}/login`);
|
|
9
|
+
s.searchParams.set("redirect_url", encodeURIComponent(r)), window.location.href = s.toString();
|
|
10
|
+
}, this.logout = async () => {
|
|
11
|
+
try {
|
|
12
|
+
const e = this.session.getSessionToken();
|
|
13
|
+
e && await this.client.auth.logout({
|
|
14
|
+
headers: {
|
|
15
|
+
"x-blimu-publishable-key": this.config.publishableKey,
|
|
16
|
+
Authorization: `Bearer ${e}`
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
} catch (e) {
|
|
20
|
+
console.error("Logout error:", e);
|
|
21
|
+
} finally {
|
|
22
|
+
this.store.setState({
|
|
23
|
+
user: null,
|
|
24
|
+
error: null,
|
|
25
|
+
status: "unauthenticated"
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}, this.getAccessToken = async (e) => await this.session.getSessionToken() ?? null, this.config = i, this.store = new h({
|
|
29
|
+
user: null,
|
|
30
|
+
error: null,
|
|
31
|
+
status: "idle"
|
|
32
|
+
}), this.isLive = i.publishableKey.includes("live"), this.authDomain = l(i.publishableKey), !this.authDomain)
|
|
33
|
+
throw new Error("Failed to determine auth domain from publishable key");
|
|
34
|
+
const t = o(i.publishableKey);
|
|
35
|
+
if (!t)
|
|
36
|
+
throw new Error("Failed to determine auth API URL from publishable key");
|
|
37
|
+
this.client = new n({
|
|
38
|
+
baseURL: t,
|
|
39
|
+
accessToken: () => this.session.getSessionToken(),
|
|
40
|
+
headers: { "x-blimu-publishable-key": i.publishableKey }
|
|
41
|
+
}), this.session = new a(
|
|
42
|
+
this.isLive,
|
|
43
|
+
this.client,
|
|
44
|
+
this.store,
|
|
45
|
+
t,
|
|
46
|
+
i.publishableKey
|
|
47
|
+
), this.initialize = this.initialize.bind(this);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Initialize authentication by checking for existing session
|
|
51
|
+
* Reads session token from cookie and validates it
|
|
52
|
+
* This method is idempotent - if initialization is already in progress, it will wait for that to complete
|
|
53
|
+
*/
|
|
54
|
+
initialize() {
|
|
55
|
+
if (!this.initialized && !this.initializePromise)
|
|
56
|
+
return this.initializeAbortController = new AbortController(), this.initializePromise = this.session.initialize({
|
|
57
|
+
signal: this.initializeAbortController.signal
|
|
58
|
+
}).then((i) => {
|
|
59
|
+
i.error ? this.store.setState({
|
|
60
|
+
user: null,
|
|
61
|
+
error: i.error,
|
|
62
|
+
status: "error"
|
|
63
|
+
}) : i.user ? this.store.setState({
|
|
64
|
+
user: i.user,
|
|
65
|
+
error: null,
|
|
66
|
+
status: "authenticated"
|
|
67
|
+
}) : this.store.setState({
|
|
68
|
+
user: null,
|
|
69
|
+
error: null,
|
|
70
|
+
status: "unauthenticated"
|
|
71
|
+
});
|
|
72
|
+
}).catch((i) => {
|
|
73
|
+
console.error("Initialize error:", i), this.store.setState({
|
|
74
|
+
user: null,
|
|
75
|
+
error: i instanceof Error ? i.message : "Initialization failed",
|
|
76
|
+
status: "error"
|
|
77
|
+
});
|
|
78
|
+
}).finally(() => {
|
|
79
|
+
this.initialized = !0, this.initializePromise = null;
|
|
80
|
+
}), () => {
|
|
81
|
+
console.log("aborting initialize"), this.initializeAbortController?.abort("unmounting"), this.initializePromise = null;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Refresh session token using the client token from httpOnly cookie
|
|
86
|
+
* The client token is stored in an httpOnly cookie and sent automatically
|
|
87
|
+
* Note: The auth worker should extract the __bli_client cookie and include it in the request body
|
|
88
|
+
* This method is idempotent - if a refresh is already in progress, it will wait for that refresh to complete
|
|
89
|
+
*/
|
|
90
|
+
scheduleRefresh() {
|
|
91
|
+
return this.session.scheduleRefresh();
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Get the runtime client for direct API calls
|
|
95
|
+
*/
|
|
96
|
+
getClient() {
|
|
97
|
+
return this.client;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
export {
|
|
101
|
+
p as BlimuRuntimeClientWrapper
|
|
102
|
+
};
|
|
103
|
+
//# sourceMappingURL=runtime-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-client.js","sources":["../../src/client/runtime-client.ts"],"sourcesContent":["import { Blimu } from '@blimu/client';\n\nimport type { AuthState, BlimuConfig, User } from '../types';\nimport { getAuthApiUrl, getAuthDomainFromPublishableKey } from '../utils/publishable-key';\nimport { AuthSessionService, LOCALHOST_JWT_URL_PARAM_NAME } from './auth.service';\nimport { ExternalStore } from './external-store';\n\nexport class BlimuRuntimeClientWrapper {\n private client: Blimu;\n private authDomain: string | null = null;\n private initialized: boolean = false;\n private readonly session: AuthSessionService;\n\n public config: BlimuConfig;\n public isLive: boolean;\n private initializePromise: Promise<void> | null = null;\n private initializeAbortController: AbortController | null = null;\n\n public readonly store: ExternalStore<AuthState>;\n\n constructor(config: BlimuConfig) {\n this.config = config;\n this.store = new ExternalStore<AuthState>({\n user: null,\n error: null,\n status: 'idle',\n });\n this.isLive = config.publishableKey.includes('live');\n\n // Get auth UI domain from publishable key\n this.authDomain = getAuthDomainFromPublishableKey(config.publishableKey);\n if (!this.authDomain) {\n throw new Error('Failed to determine auth domain from publishable key');\n }\n\n // Get auth API URL from publishable key\n const authApiUrl = getAuthApiUrl(config.publishableKey);\n\n if (!authApiUrl) {\n throw new Error('Failed to determine auth API URL from publishable key');\n }\n\n this.client = new Blimu({\n baseURL: authApiUrl,\n accessToken: () => this.session.getSessionToken(),\n headers: { 'x-blimu-publishable-key': config.publishableKey },\n });\n\n this.session = new AuthSessionService(\n this.isLive,\n this.client,\n this.store,\n authApiUrl,\n config.publishableKey,\n );\n\n this.initialize = this.initialize.bind(this);\n }\n\n /**\n * Initialize authentication by checking for existing session\n * Reads session token from cookie and validates it\n * This method is idempotent - if initialization is already in progress, it will wait for that to complete\n */\n initialize(): (() => void) | void {\n // If already initialized, return early\n if (this.initialized) return;\n\n // If initialization is in progress, return early (prevents concurrent calls)\n if (this.initializePromise) return;\n\n this.initializeAbortController = new AbortController();\n\n this.initializePromise = this.session\n .initialize({\n signal: this.initializeAbortController.signal,\n })\n .then((result) => {\n if (result.error) {\n this.store.setState({\n user: null,\n error: result.error,\n status: 'error',\n });\n } else if (result.user) {\n this.store.setState({\n user: result.user,\n error: null,\n status: 'authenticated',\n });\n } else {\n this.store.setState({\n user: null,\n error: null,\n status: 'unauthenticated',\n });\n }\n })\n .catch((error) => {\n console.error('Initialize error:', error);\n this.store.setState({\n user: null,\n error: error instanceof Error ? error.message : 'Initialization failed',\n status: 'error',\n });\n })\n .finally(() => {\n // Mark as initialized after completion (success or failure)\n // This prevents infinite loops from re-renders\n this.initialized = true;\n this.initializePromise = null;\n });\n\n return () => {\n console.log('aborting initialize');\n this.initializeAbortController?.abort('unmounting');\n this.initializePromise = null;\n // Don't reset initialized flag here - let the promise handle it\n };\n }\n\n /**\n * Refresh session token using the client token from httpOnly cookie\n * The client token is stored in an httpOnly cookie and sent automatically\n * Note: The auth worker should extract the __bli_client cookie and include it in the request body\n * This method is idempotent - if a refresh is already in progress, it will wait for that refresh to complete\n */\n public scheduleRefresh() {\n return this.session.scheduleRefresh();\n }\n\n /**\n * Redirect user to auth domain for authentication\n * Uses the auth domain derived from the publishable key\n */\n public redirectToAuth = (returnUrl?: string): void => {\n const redirectUrl = returnUrl || window.location.href;\n\n // Build auth URL on the auth domain\n const authUrl = new URL(`${this.authDomain}/login`);\n authUrl.searchParams.set('redirect_url', encodeURIComponent(redirectUrl));\n\n // Redirect to auth domain\n window.location.href = authUrl.toString();\n };\n\n /**\n * Logout user\n * Calls the logout endpoint on the API domain using this.client\n */\n public logout = async (): Promise<void> => {\n try {\n const sessionToken = this.session.getSessionToken();\n\n if (sessionToken) {\n await this.client.auth.logout({\n headers: {\n 'x-blimu-publishable-key': this.config.publishableKey,\n Authorization: `Bearer ${sessionToken}`,\n },\n });\n }\n } catch (error) {\n console.error('Logout error:', error);\n } finally {\n this.store.setState({\n user: null,\n error: null,\n status: 'unauthenticated',\n });\n }\n };\n\n /**\n * Get the current session token\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n getAccessToken = async (_options: { template: 'web' }): Promise<string | null> => {\n return (await this.session.getSessionToken()) ?? null;\n };\n\n /**\n * Get the runtime client for direct API calls\n */\n getClient(): Blimu {\n return this.client;\n }\n}\n"],"names":["BlimuRuntimeClientWrapper","config","returnUrl","redirectUrl","authUrl","sessionToken","error","_options","ExternalStore","getAuthDomainFromPublishableKey","authApiUrl","getAuthApiUrl","Blimu","AuthSessionService","result"],"mappings":";;;;AAOO,MAAMA,EAA0B;AAAA,EAarC,YAAYC,GAAqB;AAW/B,QAtBF,KAAQ,aAA4B,MACpC,KAAQ,cAAuB,IAK/B,KAAQ,oBAA0C,MAClD,KAAQ,4BAAoD,MAuH5D,KAAO,iBAAiB,CAACC,MAA6B;AACpD,YAAMC,IAAcD,KAAa,OAAO,SAAS,MAG3CE,IAAU,IAAI,IAAI,GAAG,KAAK,UAAU,QAAQ;AAClD,MAAAA,EAAQ,aAAa,IAAI,gBAAgB,mBAAmBD,CAAW,CAAC,GAGxE,OAAO,SAAS,OAAOC,EAAQ,SAAA;AAAA,IACjC,GAMA,KAAO,SAAS,YAA2B;AACzC,UAAI;AACF,cAAMC,IAAe,KAAK,QAAQ,gBAAA;AAElC,QAAIA,KACF,MAAM,KAAK,OAAO,KAAK,OAAO;AAAA,UAC5B,SAAS;AAAA,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AAK,CAACa,MAAW;AAChB,QAAIA,EAAO,QACT,KAAK,MAAM,SAAS;AAAA,UAClB,MAAM;AAAA,UACN,OAAOA,EAAO;AAAA,UACd,QAAQ;AAAA,QAAA,CACT,IACQA,EAAO,OAChB,KAAK,MAAM,SAAS;AAAA,UAClB,MAAMA,EAAO;AAAA,UACb,OAAO;AAAA,UACP,QAAQ;AAAA,QAAA,CACT,IAED,KAAK,MAAM,SAAS;AAAA,UAClB,MAAM;AAAA,UACN,OAAO;AAAA,UACP,QAAQ;AAAA,QAAA,CACT;AAAA,MAEL,CAAC,EACA,MAAM,CAACR,MAAU;AAChB,gBAAQ,MAAM,qBAAqBA,CAAK,GACxC,KAAK,MAAM,SAAS;AAAA,UAClB,MAAM;AAAA,UACN,OAAOA,aAAiB,QAAQA,EAAM,UAAU;AAAA,UAChD,QAAQ;AAAA,QAAA,CACT;AAAA,MACH,CAAC,EACA,QAAQ,MAAM;AAGb,aAAK,cAAc,IACnB,KAAK,oBAAoB;AAAA,MAC3B,CAAC,GAEI,MAAM;AACX,gBAAQ,IAAI,qBAAqB,GACjC,KAAK,2BAA2B,MAAM,YAAY,GAClD,KAAK,oBAAoB;AAAA,MAE3B;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQO,kBAAkB;AACvB,WAAO,KAAK,QAAQ,gBAAA;AAAA,EACtB;AAAA;AAAA;AAAA;AAAA,EAuDA,YAAmB;AACjB,WAAO,KAAK;AAAA,EACd;AACF;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type { RedirectToSignInProps } from './redirect-to-sign-in';
|
|
2
|
+
export { RedirectToSignIn } from './redirect-to-sign-in';
|
|
3
|
+
export type { UserButtonProps } from './user-button/user-button';
|
|
4
|
+
export { UserButton } from './user-button/user-button';
|
|
5
|
+
export type { UserAvatarProps } from './user-avatar';
|
|
6
|
+
export { UserAvatar } from './user-avatar';
|
|
7
|
+
export type { SignInButtonProps } from './sign-in-button';
|
|
8
|
+
export { SignInButton } from './sign-in-button';
|
|
9
|
+
export type { MembersListProps } from './members-list';
|
|
10
|
+
export { MembersList } from './members-list';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,YAAY,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,YAAY,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),M=require("react"),P=require("./user-avatar.cjs"),d=require("../lib/utils.cjs"),k=require("../hooks/use-members.cjs");function w(s){const l=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const i in s)if(i!=="default"){const r=Object.getOwnPropertyDescriptor(s,i);Object.defineProperty(l,i,r.get?r:{enumerable:!0,get:()=>s[i]})}}return l.default=s,Object.freeze(l)}const O=w(M);function q({resourceType:s,resourceId:l,initialPage:i=1,pageSize:r=20,search:g,renderMember:x,className:n,showPagination:p=!0}){const[a,b]=O.useState(i),{members:c,total:u,isLoading:o,error:f,hasNextPage:j,hasPreviousPage:N,refetch:v}=k.useMembers({resourceType:s,resourceId:l,page:a,limit:r,search:g}),y=t=>{const h=t.user.firstName&&t.user.lastName?`${t.user.firstName} ${t.user.lastName}`:t.user.firstName||t.user.email?.split("@")[0]||"User";return e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-blimu hover:bg-blimu-accent transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(P.UserAvatar,{src:t.user.avatarUrl||void 0,alt:t.user.email,fallback:h,size:"default"}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("p",{className:"text-sm font-medium text-blimu-foreground",children:h}),e.jsx("p",{className:"text-xs text-blimu-muted-foreground",children:t.user.email})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[t.inherited&&e.jsx("span",{className:"text-xs text-blimu-muted-foreground",children:"(inherited)"}),e.jsx("span",{className:"text-xs font-medium text-blimu-foreground bg-blimu-muted px-2 py-1 rounded-blimu-sm",children:t.role})]})]})};if(f)return e.jsxs("div",{className:d.cn("p-4 text-center",n),children:[e.jsxs("p",{className:"text-sm text-blimu-destructive",children:["Error loading members: ",f.message]}),e.jsx("button",{onClick:()=>v(),className:"mt-2 text-sm text-blimu-primary hover:underline",children:"Retry"})]});if(o&&c.length===0)return e.jsx("div",{className:d.cn("p-4 text-center",n),children:e.jsx("p",{className:"text-sm text-blimu-muted-foreground",children:"Loading members..."})});if(c.length===0)return e.jsx("div",{className:d.cn("p-4 text-center",n),children:e.jsx("p",{className:"text-sm text-blimu-muted-foreground",children:"No members found"})});const m=Math.ceil(u/r);return e.jsxs("div",{className:d.cn("flex flex-col",n),children:[e.jsx("div",{className:"flex flex-col divide-y divide-blimu-border",children:c.map(t=>e.jsx("div",{children:x?x(t):y(t)},t.userId))}),p&&m>1&&e.jsxs("div",{className:"flex items-center justify-between mt-4 pt-4 border-t border-blimu-border",children:[e.jsxs("div",{className:"text-sm text-blimu-muted-foreground",children:["Showing ",(a-1)*r+1," to ",Math.min(a*r,u)," of ",u," ","members"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>b(t=>Math.max(1,t-1)),disabled:!N||o,className:"px-3 py-1 text-sm rounded-blimu border border-blimu-input bg-blimu-background hover:bg-blimu-accent disabled:opacity-50 disabled:cursor-not-allowed",children:"Previous"}),e.jsxs("span",{className:"text-sm text-blimu-foreground",children:["Page ",a," of ",m]}),e.jsx("button",{onClick:()=>b(t=>Math.min(m,t+1)),disabled:!j||o,className:"px-3 py-1 text-sm rounded-blimu border border-blimu-input bg-blimu-background hover:bg-blimu-accent disabled:opacity-50 disabled:cursor-not-allowed",children:"Next"})]})]})]})}exports.MembersList=q;
|
|
2
|
+
//# sourceMappingURL=members-list.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"members-list.cjs","sources":["../../src/components/members-list.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { UserAvatar } from './user-avatar';\nimport { cn } from '../lib/utils';\n\nimport { useMembers, type ResourceMember } from '../hooks/use-members';\n\nexport interface MembersListProps {\n /**\n * Resource type (e.g., 'organization', 'workspace')\n */\n resourceType: string;\n\n /**\n * Resource ID\n */\n resourceId: string;\n\n /**\n * Initial page number\n * @default 1\n */\n initialPage?: number;\n\n /**\n * Items per page\n * @default 20\n */\n pageSize?: number;\n\n /**\n * Search query\n */\n search?: string;\n\n /**\n * Custom render function for each member\n */\n renderMember?: (member: ResourceMember) => React.ReactNode;\n\n /**\n * Custom className\n */\n className?: string;\n\n /**\n * Show pagination controls\n * @default true\n */\n showPagination?: boolean;\n}\n\n/**\n * Paginated list of organization/resource members\n *\n * @example\n * ```tsx\n * <MembersList\n * resourceType=\"organization\"\n * resourceId=\"org_123\"\n * />\n * ```\n *\n * @example With custom rendering\n * ```tsx\n * <MembersList\n * resourceType=\"workspace\"\n * resourceId=\"ws_456\"\n * renderMember={(member) => (\n * <div className=\"flex items-center gap-2\">\n * <UserAvatar src={member.user.avatarUrl} alt={member.user.email} />\n * <div>\n * <p>{member.user.firstName} {member.user.lastName}</p>\n * <p className=\"text-sm text-muted-foreground\">{member.user.email}</p>\n * </div>\n * <Badge>{member.role}</Badge>\n * </div>\n * )}\n * />\n * ```\n */\nexport function MembersList({\n resourceType,\n resourceId,\n initialPage = 1,\n pageSize = 20,\n search,\n renderMember,\n className,\n showPagination = true,\n}: MembersListProps) {\n const [page, setPage] = React.useState(initialPage);\n const { members, total, isLoading, error, hasNextPage, hasPreviousPage, refetch } = useMembers({\n resourceType,\n resourceId,\n page,\n limit: pageSize,\n search,\n });\n\n const defaultRenderMember = (member: ResourceMember) => {\n const displayName =\n member.user.firstName && member.user.lastName\n ? `${member.user.firstName} ${member.user.lastName}`\n : member.user.firstName || member.user.email?.split('@')[0] || 'User';\n\n return (\n <div className=\"flex items-center justify-between p-3 rounded-blimu hover:bg-blimu-accent transition-colors\">\n <div className=\"flex items-center gap-3\">\n <UserAvatar\n src={member.user.avatarUrl || undefined}\n alt={member.user.email}\n fallback={displayName}\n size=\"default\"\n />\n <div className=\"flex flex-col\">\n <p className=\"text-sm font-medium text-blimu-foreground\">{displayName}</p>\n <p className=\"text-xs text-blimu-muted-foreground\">{member.user.email}</p>\n </div>\n </div>\n <div className=\"flex items-center gap-2\">\n {member.inherited && (\n <span className=\"text-xs text-blimu-muted-foreground\">(inherited)</span>\n )}\n <span className=\"text-xs font-medium text-blimu-foreground bg-blimu-muted px-2 py-1 rounded-blimu-sm\">\n {member.role}\n </span>\n </div>\n </div>\n );\n };\n\n if (error) {\n return (\n <div className={cn('p-4 text-center', className)}>\n <p className=\"text-sm text-blimu-destructive\">Error loading members: {error.message}</p>\n <button\n onClick={() => refetch()}\n className=\"mt-2 text-sm text-blimu-primary hover:underline\"\n >\n Retry\n </button>\n </div>\n );\n }\n\n if (isLoading && members.length === 0) {\n return (\n <div className={cn('p-4 text-center', className)}>\n <p className=\"text-sm text-blimu-muted-foreground\">Loading members...</p>\n </div>\n );\n }\n\n if (members.length === 0) {\n return (\n <div className={cn('p-4 text-center', className)}>\n <p className=\"text-sm text-blimu-muted-foreground\">No members found</p>\n </div>\n );\n }\n\n const totalPages = Math.ceil(total / pageSize);\n\n return (\n <div className={cn('flex flex-col', className)}>\n <div className=\"flex flex-col divide-y divide-blimu-border\">\n {members.map((member) => (\n <div key={member.userId}>\n {renderMember ? renderMember(member) : defaultRenderMember(member)}\n </div>\n ))}\n </div>\n\n {showPagination && totalPages > 1 && (\n <div className=\"flex items-center justify-between mt-4 pt-4 border-t border-blimu-border\">\n <div className=\"text-sm text-blimu-muted-foreground\">\n Showing {(page - 1) * pageSize + 1} to {Math.min(page * pageSize, total)} of {total}{' '}\n members\n </div>\n <div className=\"flex items-center gap-2\">\n <button\n onClick={() => setPage((p) => Math.max(1, p - 1))}\n disabled={!hasPreviousPage || isLoading}\n className=\"px-3 py-1 text-sm rounded-blimu border border-blimu-input bg-blimu-background hover:bg-blimu-accent disabled:opacity-50 disabled:cursor-not-allowed\"\n >\n Previous\n </button>\n <span className=\"text-sm text-blimu-foreground\">\n Page {page} of {totalPages}\n </span>\n <button\n onClick={() => setPage((p) => Math.min(totalPages, p + 1))}\n disabled={!hasNextPage || isLoading}\n className=\"px-3 py-1 text-sm rounded-blimu border border-blimu-input bg-blimu-background hover:bg-blimu-accent disabled:opacity-50 disabled:cursor-not-allowed\"\n >\n Next\n </button>\n </div>\n </div>\n )}\n </div>\n );\n}\n"],"names":["MembersList","resourceType","resourceId","initialPage","pageSize","search","renderMember","className","showPagination","page","setPage","React","members","total","isLoading","error","hasNextPage","hasPreviousPage","refetch","useMembers","defaultRenderMember","member","displayName","jsxs","jsx","UserAvatar","cn","totalPages","p"],"mappings":"qgBAiFO,SAASA,EAAY,CAC1B,aAAAC,EACA,WAAAC,EACA,YAAAC,EAAc,EACd,SAAAC,EAAW,GACX,OAAAC,EACA,aAAAC,EACA,UAAAC,EACA,eAAAC,EAAiB,EACnB,EAAqB,CACnB,KAAM,CAACC,EAAMC,CAAO,EAAIC,EAAM,SAASR,CAAW,EAC5C,CAAE,QA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