@authdog/vue 0.0.1 → 0.0.2

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 CHANGED
@@ -26,7 +26,7 @@ pnpm add @authdog/vue
26
26
  </template>
27
27
 
28
28
  <script setup lang="ts">
29
- import { AuthdogProvider } from '@authdog/vue/client'
29
+ import { AuthdogProvider } from "@authdog/vue/client";
30
30
  </script>
31
31
  ```
32
32
 
@@ -34,22 +34,22 @@ import { AuthdogProvider } from '@authdog/vue/client'
34
34
 
35
35
  ```vue
36
36
  <script setup lang="ts">
37
- import { useSession, useUser } from '@authdog/vue'
37
+ import { useSession, useUser } from "@authdog/vue";
38
38
 
39
- const { session, isLoading } = useSession()
40
- const { user } = useUser()
39
+ const { session, isLoading } = useSession();
40
+ const { user } = useUser();
41
41
  </script>
42
42
  ```
43
43
 
44
44
  ### Server-side
45
45
 
46
46
  ```typescript
47
- import { createAuthdogServer } from '@authdog/vue/server'
47
+ import { createAuthdogServer } from "@authdog/vue/server";
48
48
 
49
49
  const authdog = createAuthdogServer({
50
50
  publicKey: process.env.AUTHDOG_PUBLIC_KEY!,
51
51
  secretKey: process.env.AUTHDOG_SECRET_KEY!,
52
- })
52
+ });
53
53
  ```
54
54
 
55
55
  ## API Reference
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/client.ts"],"sourcesContent":["export * from './client'\n"],"mappings":"+WAAA,IAAAA,EAAA,kBAAAC,EAAAD","names":["client_exports","__toCommonJS"]}
1
+ {"version":3,"sources":["../src/client.ts"],"sourcesContent":["export * from \"./client\";\n"],"mappings":"+WAAA,IAAAA,EAAA,kBAAAC,EAAAD","names":["client_exports","__toCommonJS"]}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/composables/use-session.ts","../src/client/provider.ts","../src/composables/use-user.ts","../src/commons.ts","../src/client/session.ts","../src/composables/use-signin.ts","../src/composables/use-signup.ts","../src/composables/use-signout.ts","../src/composables/use-organization.ts","../src/composables/use-organization-list.ts","../src/composables/use-authz.ts"],"sourcesContent":["export * from './client'\nexport * from './composables'\n","import { computed, inject } from 'vue'\nimport { AUTHDOG_CONTEXT_KEY, type AuthdogContext } from '../client/provider'\n\nexport const useSession = () => {\n const context = inject<AuthdogContext>(AUTHDOG_CONTEXT_KEY)\n\n if (!context) {\n throw new Error('useSession must be used within AuthdogProvider')\n }\n\n const session = computed(() => ({\n token: context.token,\n isAuthenticated: !!context.token,\n }))\n\n return {\n session: session.value,\n isLoading: context.isLoading,\n }\n}\n","import { defineComponent, onMounted, ref, provide, inject, type InjectionKey } from 'vue'\n\nexport interface AuthdogContext {\n isLoading: boolean\n token: string | null\n setToken: (token: string | null) => void\n}\n\nexport const AUTHDOG_CONTEXT_KEY: InjectionKey<AuthdogContext> = Symbol('authdog')\n\nexport const AuthdogProvider = defineComponent({\n name: 'AuthdogProvider',\n setup(_, { slots }) {\n const isLoading = ref(true)\n const token = ref<string | null>(null)\n\n const setToken = (newToken: string | null) => {\n token.value = newToken\n }\n\n onMounted(() => {\n // Check if we're in the browser\n if (typeof window !== 'undefined') {\n // Check if there's a token in the URL\n const url = new URL(window.location.href)\n const urlToken = url.searchParams.get('token')\n\n if (urlToken) {\n // Remove token from URL without triggering a page reload\n url.searchParams.delete('token')\n window.history.replaceState({}, document.title, url.toString())\n \n // Store token and reload to ensure server processes it\n localStorage.setItem('token', urlToken)\n setToken(urlToken)\n \n // Force a reload to ensure the server processes the token\n window.location.reload()\n return\n }\n\n // Check for existing token in localStorage\n const existingToken = localStorage.getItem('token')\n if (existingToken) {\n setToken(existingToken)\n }\n\n // If no token, we're done loading\n isLoading.value = false\n } else {\n // If we're on the server, don't show loading state\n isLoading.value = false\n }\n })\n\n const context: AuthdogContext = {\n isLoading: isLoading.value,\n token: token.value,\n setToken\n }\n\n provide(AUTHDOG_CONTEXT_KEY, context)\n\n return () => slots.default?.()\n }\n})\n","import { ref, computed, inject } from 'vue'\nimport { AUTHDOG_CONTEXT_KEY, type AuthdogContext } from '../client/provider'\nimport { fetchUserData, validatePublicKey } from '../client/session'\n\nexport const useUser = () => {\n const context = inject<AuthdogContext>(AUTHDOG_CONTEXT_KEY)\n const user = ref<any>(null)\n const isLoading = ref(false)\n const error = ref<Error | null>(null)\n\n if (!context) {\n throw new Error('useUser must be used within AuthdogProvider')\n }\n\n const fetchUser = async (publicKey: string) => {\n if (!context.token) {\n return null\n }\n\n isLoading.value = true\n error.value = null\n\n try {\n validatePublicKey(publicKey)\n const userData = await fetchUserData(publicKey, context.token)\n user.value = userData?.user || null\n return userData?.user || null\n } catch (err) {\n error.value = err as Error\n return null\n } finally {\n isLoading.value = false\n }\n }\n\n const isAuthenticated = computed(() => !!context.token && !!user.value)\n\n return {\n user: computed(() => user.value),\n isLoading: computed(() => isLoading.value),\n error: computed(() => error.value),\n isAuthenticated,\n fetchUser,\n }\n}\n","export interface PublicKeyPayload {\n environmentId: string\n identityHost: string\n}\n\nexport const getPublicKeyPayload = (publicKey: string): PublicKeyPayload => {\n if (!publicKey) {\n throw new Error('Public key is not defined')\n }\n\n if (!publicKey.startsWith('pk_')) {\n throw new Error('Invalid public key')\n }\n\n try {\n return JSON.parse(\n Buffer.from(publicKey.replace('pk_', ''), 'base64').toString('utf-8'),\n )\n } catch (e) {\n throw new Error('Failed to parse public key')\n }\n}\n","import { getPublicKeyPayload } from '../commons'\n\nexport const getTokenFromUri = (url: string): string | null => {\n return new URL(url).searchParams.get('token')\n}\n\ninterface IFetchUserData {\n user: {\n id: string\n environmentId: string\n externalId: string\n userName: string\n displayName: string\n nickName: string\n profileUrl: string\n title: string\n userType: string\n preferredLanguage: string | null\n locale: string | null\n timezone: string | null\n active: boolean\n provider: string\n lastLogin: string\n createdAt: string\n updatedAt: string\n names: {\n id: string\n userId: string\n formatted: string | null\n familyName: string\n givenName: string\n middleName: string | null\n honorificPrefix: string | null\n honorificSuffix: string | null\n createdAt: string\n updatedAt: string\n }\n addresses: []\n emails: {\n value: string\n primary: boolean\n type: string\n }[]\n phoneNumbers: []\n ims: []\n photos: {\n value: string\n type: string\n }[]\n }\n meta: {\n code: number\n message: string\n }\n}\n\nexport const validatePublicKey = (publicKey: string) => {\n if (!publicKey) {\n throw new Error('Public key is not defined')\n }\n\n if (!publicKey.startsWith('pk_')) {\n throw new Error('Invalid public key')\n }\n}\n\nexport const fetchUserData = async (\n publicKey: string,\n token: string,\n): Promise<IFetchUserData | null> => {\n validatePublicKey(publicKey)\n const publicKeyObj = getPublicKeyPayload(publicKey)\n const userData = await fetch(\n `${publicKeyObj?.identityHost}/oidc/${publicKeyObj?.environmentId}/userinfo`,\n {\n headers: {\n authorization: `Bearer ${token}`,\n },\n },\n )\n\n if (!userData.ok) {\n throw new Error('Failed to fetch user info')\n }\n\n return await userData.json()\n}\n\nexport const browserCookiesOptions = {\n maxAge: 60 * 60 * 24 * 7, // 1 week\n path: '/',\n httpOnly: true,\n}\n","import { ref, computed, inject } from 'vue'\nimport { AUTHDOG_CONTEXT_KEY, type AuthdogContext } from '../client/provider'\n\nexport const useSignIn = () => {\n const context = inject<AuthdogContext>(AUTHDOG_CONTEXT_KEY)\n const isLoading = ref(false)\n const error = ref<Error | null>(null)\n\n if (!context) {\n throw new Error('useSignIn must be used within AuthdogProvider')\n }\n\n const signIn = async (publicKey: string, redirectUrl?: string) => {\n isLoading.value = true\n error.value = null\n\n try {\n const publicKeyObj = JSON.parse(\n Buffer.from(publicKey.replace('pk_', ''), 'base64').toString('utf-8')\n )\n \n const authUrl = new URL(`${publicKeyObj.identityHost}/oidc/${publicKeyObj.environmentId}/authorize`)\n authUrl.searchParams.set('client_id', publicKey)\n authUrl.searchParams.set('response_type', 'code')\n authUrl.searchParams.set('scope', 'openid profile email')\n authUrl.searchParams.set('redirect_uri', redirectUrl || window.location.origin)\n \n window.location.href = authUrl.toString()\n } catch (err) {\n error.value = err as Error\n } finally {\n isLoading.value = false\n }\n }\n\n return {\n signIn,\n isLoading: computed(() => isLoading.value),\n error: computed(() => error.value),\n }\n}\n","import { ref, computed, inject } from 'vue'\nimport { AUTHDOG_CONTEXT_KEY, type AuthdogContext } from '../client/provider'\n\nexport const useSignUp = () => {\n const context = inject<AuthdogContext>(AUTHDOG_CONTEXT_KEY)\n const isLoading = ref(false)\n const error = ref<Error | null>(null)\n\n if (!context) {\n throw new Error('useSignUp must be used within AuthdogProvider')\n }\n\n const signUp = async (publicKey: string, redirectUrl?: string) => {\n isLoading.value = true\n error.value = null\n\n try {\n const publicKeyObj = JSON.parse(\n Buffer.from(publicKey.replace('pk_', ''), 'base64').toString('utf-8')\n )\n \n const authUrl = new URL(`${publicKeyObj.identityHost}/oidc/${publicKeyObj.environmentId}/authorize`)\n authUrl.searchParams.set('client_id', publicKey)\n authUrl.searchParams.set('response_type', 'code')\n authUrl.searchParams.set('scope', 'openid profile email')\n authUrl.searchParams.set('redirect_uri', redirectUrl || window.location.origin)\n authUrl.searchParams.set('prompt', 'signup')\n \n window.location.href = authUrl.toString()\n } catch (err) {\n error.value = err as Error\n } finally {\n isLoading.value = false\n }\n }\n\n return {\n signUp,\n isLoading: computed(() => isLoading.value),\n error: computed(() => error.value),\n }\n}\n","import { ref, computed, inject } from 'vue'\nimport { AUTHDOG_CONTEXT_KEY, type AuthdogContext } from '../client/provider'\n\nexport const useSignOut = () => {\n const context = inject<AuthdogContext>(AUTHDOG_CONTEXT_KEY)\n const isLoading = ref(false)\n const error = ref<Error | null>(null)\n\n if (!context) {\n throw new Error('useSignOut must be used within AuthdogProvider')\n }\n\n const signOut = async () => {\n isLoading.value = true\n error.value = null\n\n try {\n // Clear token from context\n context.setToken(null)\n \n // Clear token from localStorage\n if (typeof window !== 'undefined') {\n localStorage.removeItem('token')\n }\n \n // Redirect to logout endpoint or home page\n if (typeof window !== 'undefined') {\n window.location.href = '/logout'\n }\n } catch (err) {\n error.value = err as Error\n } finally {\n isLoading.value = false\n }\n }\n\n return {\n signOut,\n isLoading: computed(() => isLoading.value),\n error: computed(() => error.value),\n }\n}\n","import { ref, computed, inject } from 'vue'\nimport { AUTHDOG_CONTEXT_KEY, type AuthdogContext } from '../client/provider'\n\nexport const useOrganization = () => {\n const context = inject<AuthdogContext>(AUTHDOG_CONTEXT_KEY)\n const organization = ref<any>(null)\n const isLoading = ref(false)\n const error = ref<Error | null>(null)\n\n if (!context) {\n throw new Error('useOrganization must be used within AuthdogProvider')\n }\n\n const fetchOrganization = async (organizationId: string) => {\n if (!context.token) {\n return null\n }\n\n isLoading.value = true\n error.value = null\n\n try {\n // This would be implemented based on your organization API\n // For now, returning a placeholder\n const response = await fetch(`/api/organizations/${organizationId}`, {\n headers: {\n 'Authorization': `Bearer ${context.token}`,\n },\n })\n\n if (!response.ok) {\n throw new Error('Failed to fetch organization')\n }\n\n organization.value = await response.json()\n return organization.value\n } catch (err) {\n error.value = err as Error\n return null\n } finally {\n isLoading.value = false\n }\n }\n\n return {\n organization: computed(() => organization.value),\n isLoading: computed(() => isLoading.value),\n error: computed(() => error.value),\n fetchOrganization,\n }\n}\n","import { ref, computed, inject } from 'vue'\nimport { AUTHDOG_CONTEXT_KEY, type AuthdogContext } from '../client/provider'\n\nexport const useOrganizationList = () => {\n const context = inject<AuthdogContext>(AUTHDOG_CONTEXT_KEY)\n const organizations = ref<any[]>([])\n const isLoading = ref(false)\n const error = ref<Error | null>(null)\n\n if (!context) {\n throw new Error('useOrganizationList must be used within AuthdogProvider')\n }\n\n const fetchOrganizations = async () => {\n if (!context.token) {\n return []\n }\n\n isLoading.value = true\n error.value = null\n\n try {\n // This would be implemented based on your organizations API\n // For now, returning a placeholder\n const response = await fetch('/api/organizations', {\n headers: {\n 'Authorization': `Bearer ${context.token}`,\n },\n })\n\n if (!response.ok) {\n throw new Error('Failed to fetch organizations')\n }\n\n const data = await response.json()\n organizations.value = data.organizations || []\n return organizations.value\n } catch (err) {\n error.value = err as Error\n return []\n } finally {\n isLoading.value = false\n }\n }\n\n return {\n organizations: computed(() => organizations.value),\n isLoading: computed(() => isLoading.value),\n error: computed(() => error.value),\n fetchOrganizations,\n }\n}\n","import { ref, computed, inject } from 'vue'\nimport { AUTHDOG_CONTEXT_KEY, type AuthdogContext } from '../client/provider'\n\nexport const useAuthz = () => {\n const context = inject<AuthdogContext>(AUTHDOG_CONTEXT_KEY)\n const permissions = ref<string[]>([])\n const isLoading = ref(false)\n const error = ref<Error | null>(null)\n\n if (!context) {\n throw new Error('useAuthz must be used within AuthdogProvider')\n }\n\n const fetchPermissions = async () => {\n if (!context.token) {\n return []\n }\n\n isLoading.value = true\n error.value = null\n\n try {\n // This would be implemented based on your authorization API\n // For now, returning a placeholder\n const response = await fetch('/api/permissions', {\n headers: {\n 'Authorization': `Bearer ${context.token}`,\n },\n })\n\n if (!response.ok) {\n throw new Error('Failed to fetch permissions')\n }\n\n const data = await response.json()\n permissions.value = data.permissions || []\n return permissions.value\n } catch (err) {\n error.value = err as Error\n return []\n } finally {\n isLoading.value = false\n }\n }\n\n const hasPermission = (permission: string) => {\n return permissions.value.includes(permission)\n }\n\n const hasAnyPermission = (permissionList: string[]) => {\n return permissionList.some(permission => permissions.value.includes(permission))\n }\n\n const hasAllPermissions = (permissionList: string[]) => {\n return permissionList.every(permission => permissions.value.includes(permission))\n }\n\n return {\n permissions: computed(() => permissions.value),\n isLoading: computed(() => isLoading.value),\n error: computed(() => error.value),\n fetchPermissions,\n hasPermission,\n hasAnyPermission,\n hasAllPermissions,\n }\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,cAAAE,EAAA,oBAAAC,EAAA,wBAAAC,EAAA,eAAAC,EAAA,cAAAC,EAAA,eAAAC,EAAA,cAAAC,EAAA,YAAAC,IAAA,eAAAC,EAAAV,GCAA,IAAAW,EAAiC,eCAjC,IAAAC,EAAoF,eAQvEC,EAAoD,OAAO,SAAS,EAEpEC,KAAkB,mBAAgB,CAC7C,KAAM,kBACN,MAAMC,EAAG,CAAE,MAAAC,CAAM,EAAG,CAClB,IAAMC,KAAY,OAAI,EAAI,EAC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AiBC,GACdR,EAAY,MAAM,SAASQ,CAAU,EAGxCC,EAAoBC,GACjBA,EAAe,KAAKF,GAAcR,EAAY,MAAM,SAASQ,CAAU,CAAC,EAG3EG,EAAqBD,GAClBA,EAAe,MAAMF,GAAcR,EAAY,MAAM,SAASQ,CAAU,CAAC,EAGlF,MAAO,CACL,eAAa,YAAS,IAAMR,EAAY,KAAK,EAC7C,aAAW,YAAS,IAAMC,EAAU,KAAK,EACzC,SAAO,YAAS,IAAMC,EAAM,KAAK,EACjC,iBAAAC,EACA,cAAAI,EACA,iBAAAE,EACA,kBAAAE,CACF,CACF","names":["index_exports","__export","useAuthz","useOrganization","useOrganizationList","useSession","useSignIn","useSignOut","useSignUp","useUser","__toCommonJS","import_vue","import_vue","AUTHDOG_CONTEXT_KEY","AuthdogProvider","_","slots","isLoading","token","setToken","newToken","url","urlToken","existingToken","context","_a","useSession","context","AUTHDOG_CONTEXT_KEY","import_vue","getPublicKeyPayload","publicKey","validatePublicKey","publicKey","fetchUserData","token","publicKeyObj","getPublicKeyPayload","userData","browserCookiesOptions","useUser","context","AUTHDOG_CONTEXT_KEY","user","isLoading","error","fetchUser","publicKey","validatePublicKey","userData","fetchUserData","err","isAuthenticated","import_vue","useSignIn","context","AUTHDOG_CONTEXT_KEY","isLoading","error","publicKey","redirectUrl","publicKeyObj","authUrl","err","import_vue","useSignUp","context","AUTHDOG_CONTEXT_KEY","isLoading","error","publicKey","redirectUrl","publicKeyObj","authUrl","err","import_vue","useSignOut","context","AUTHDOG_CONTEXT_KEY","isLoading","error","err","import_vue","useOrganization","context","AUTHDOG_CONTEXT_KEY","organization","isLoading","error","fetchOrganization","organizationId","response","err","import_vue","useOrganizationList","context","AUTHDOG_CONTEXT_KEY","organizations","isLoading","error","fetchOrganizations","response","data","err","import_vue","useAuthz","context","AUTHDOG_CONTEXT_KEY","permissions","isLoading","error","fetchPermissions","response","data","err","hasPermission","permission","hasAnyPermission","permissionList","hasAllPermissions"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/composables/use-session.ts","../src/client/provider.ts","../src/composables/use-user.ts","../src/commons.ts","../src/client/session.ts","../src/composables/use-signin.ts","../src/composables/use-signup.ts","../src/composables/use-signout.ts","../src/composables/use-organization.ts","../src/composables/use-organization-list.ts","../src/composables/use-authz.ts"],"sourcesContent":["export * from \"./client\";\nexport * from \"./composables\";\n","import { computed, inject } from \"vue\";\nimport { AUTHDOG_CONTEXT_KEY, type AuthdogContext } from \"../client/provider\";\n\nexport const useSession = () => {\n const context = inject<AuthdogContext>(AUTHDOG_CONTEXT_KEY);\n\n if (!context) {\n throw new Error(\"useSession must be used within AuthdogProvider\");\n }\n\n const session = computed(() => ({\n token: context.token,\n isAuthenticated: !!context.token,\n }));\n\n return {\n session: session.value,\n isLoading: context.isLoading,\n };\n};\n","import {\n defineComponent,\n onMounted,\n ref,\n provide,\n inject,\n type InjectionKey,\n} from \"vue\";\n\nexport interface AuthdogContext {\n isLoading: boolean;\n token: string | null;\n setToken: (token: string | null) => void;\n}\n\nexport const AUTHDOG_CONTEXT_KEY: InjectionKey<AuthdogContext> =\n Symbol(\"authdog\");\n\nexport const AuthdogProvider = defineComponent({\n name: \"AuthdogProvider\",\n setup(_, { slots }) {\n const isLoading = ref(true);\n const token = ref<string | null>(null);\n\n const setToken = (newToken: string | null) => {\n token.value = newToken;\n };\n\n onMounted(() => {\n // Check if we're in the browser\n if (typeof window !== \"undefined\") {\n // Check if there's a token in the URL\n const url = new URL(window.location.href);\n const urlToken = url.searchParams.get(\"token\");\n\n if (urlToken) {\n // Remove token from URL without triggering a page reload\n url.searchParams.delete(\"token\");\n window.history.replaceState({}, document.title, url.toString());\n\n // Store token and reload to ensure server processes it\n localStorage.setItem(\"token\", urlToken);\n setToken(urlToken);\n\n // Force a reload to ensure the server processes the token\n window.location.reload();\n return;\n }\n\n // Check for existing token in localStorage\n const existingToken = localStorage.getItem(\"token\");\n if (existingToken) {\n setToken(existingToken);\n }\n\n // If no token, we're done loading\n isLoading.value = false;\n } else {\n // If we're on the server, don't show loading state\n isLoading.value = false;\n }\n });\n\n const context: AuthdogContext = {\n isLoading: isLoading.value,\n token: token.value,\n setToken,\n };\n\n provide(AUTHDOG_CONTEXT_KEY, context);\n\n return () => slots.default?.();\n },\n});\n","import { ref, computed, inject } from \"vue\";\nimport { AUTHDOG_CONTEXT_KEY, type AuthdogContext } from \"../client/provider\";\nimport { fetchUserData, validatePublicKey } from \"../client/session\";\n\nexport const useUser = () => {\n const context = inject<AuthdogContext>(AUTHDOG_CONTEXT_KEY);\n const user = ref<any>(null);\n const isLoading = ref(false);\n const error = ref<Error | null>(null);\n\n if (!context) {\n throw new Error(\"useUser must be used within AuthdogProvider\");\n }\n\n const fetchUser = async (publicKey: string) => {\n if (!context.token) {\n return null;\n }\n\n isLoading.value = true;\n error.value = null;\n\n try {\n validatePublicKey(publicKey);\n const userData = await fetchUserData(publicKey, context.token);\n user.value = userData?.user || null;\n return userData?.user || null;\n } catch (err) {\n error.value = err as Error;\n return null;\n } finally {\n isLoading.value = false;\n }\n };\n\n const isAuthenticated = computed(() => !!context.token && !!user.value);\n\n return {\n user: computed(() => user.value),\n isLoading: computed(() => isLoading.value),\n error: computed(() => error.value),\n isAuthenticated,\n fetchUser,\n };\n};\n","export interface PublicKeyPayload {\n environmentId: string;\n identityHost: string;\n}\n\nexport const getPublicKeyPayload = (publicKey: string): PublicKeyPayload => {\n if (!publicKey) {\n throw new Error(\"Public key is not defined\");\n }\n\n if (!publicKey.startsWith(\"pk_\")) {\n throw new Error(\"Invalid public key\");\n }\n\n try {\n return JSON.parse(\n Buffer.from(publicKey.replace(\"pk_\", \"\"), \"base64\").toString(\"utf-8\"),\n );\n } catch (e) {\n throw new Error(\"Failed to parse public key\");\n }\n};\n","import { getPublicKeyPayload } from \"../commons\";\n\nexport const getTokenFromUri = (url: string): string | null => {\n return new URL(url).searchParams.get(\"token\");\n};\n\ninterface IFetchUserData {\n user: {\n id: string;\n environmentId: string;\n externalId: string;\n userName: string;\n displayName: string;\n nickName: string;\n profileUrl: string;\n title: string;\n userType: string;\n preferredLanguage: string | null;\n locale: string | null;\n timezone: string | null;\n active: boolean;\n provider: string;\n lastLogin: string;\n createdAt: string;\n updatedAt: string;\n names: {\n id: string;\n userId: string;\n formatted: string | null;\n familyName: string;\n givenName: string;\n middleName: string | null;\n honorificPrefix: string | null;\n honorificSuffix: string | null;\n createdAt: string;\n updatedAt: string;\n };\n addresses: [];\n emails: {\n value: string;\n primary: boolean;\n type: string;\n }[];\n phoneNumbers: [];\n ims: [];\n photos: {\n value: string;\n type: string;\n }[];\n };\n meta: {\n code: number;\n message: string;\n };\n}\n\nexport const validatePublicKey = (publicKey: string) => {\n if (!publicKey) {\n throw new Error(\"Public key is not defined\");\n }\n\n if (!publicKey.startsWith(\"pk_\")) {\n throw new Error(\"Invalid public key\");\n }\n};\n\nexport const fetchUserData = async (\n publicKey: string,\n token: string,\n): Promise<IFetchUserData | null> => {\n validatePublicKey(publicKey);\n const publicKeyObj = getPublicKeyPayload(publicKey);\n const userData = await fetch(\n `${publicKeyObj?.identityHost}/oidc/${publicKeyObj?.environmentId}/userinfo`,\n {\n headers: {\n authorization: `Bearer ${token}`,\n },\n },\n );\n\n if (!userData.ok) {\n throw new Error(\"Failed to fetch user info\");\n }\n\n return await userData.json();\n};\n\nexport const browserCookiesOptions = {\n maxAge: 60 * 60 * 24 * 7, // 1 week\n path: \"/\",\n httpOnly: true,\n};\n","import { ref, computed, inject } from \"vue\";\nimport { AUTHDOG_CONTEXT_KEY, type AuthdogContext } from \"../client/provider\";\n\nexport const useSignIn = () => {\n const context = inject<AuthdogContext>(AUTHDOG_CONTEXT_KEY);\n const isLoading = ref(false);\n const error = ref<Error | null>(null);\n\n if (!context) {\n throw new Error(\"useSignIn must be used within AuthdogProvider\");\n }\n\n const signIn = async (publicKey: string, redirectUrl?: string) => {\n isLoading.value = true;\n error.value = null;\n\n try {\n const publicKeyObj = JSON.parse(\n Buffer.from(publicKey.replace(\"pk_\", \"\"), \"base64\").toString(\"utf-8\"),\n );\n\n const authUrl = new URL(\n `${publicKeyObj.identityHost}/oidc/${publicKeyObj.environmentId}/authorize`,\n );\n authUrl.searchParams.set(\"client_id\", publicKey);\n authUrl.searchParams.set(\"response_type\", \"code\");\n authUrl.searchParams.set(\"scope\", \"openid profile email\");\n authUrl.searchParams.set(\n \"redirect_uri\",\n redirectUrl || window.location.origin,\n );\n\n window.location.href = authUrl.toString();\n } catch (err) {\n error.value = err as Error;\n } finally {\n isLoading.value = false;\n }\n };\n\n return {\n signIn,\n isLoading: computed(() => isLoading.value),\n error: computed(() => error.value),\n };\n};\n","import { ref, computed, inject } from \"vue\";\nimport { AUTHDOG_CONTEXT_KEY, type AuthdogContext } from \"../client/provider\";\n\nexport const useSignUp = () => {\n const context = inject<AuthdogContext>(AUTHDOG_CONTEXT_KEY);\n const isLoading = ref(false);\n const error = ref<Error | null>(null);\n\n if (!context) {\n throw new Error(\"useSignUp must be used within AuthdogProvider\");\n }\n\n const signUp = async (publicKey: string, redirectUrl?: string) => {\n isLoading.value = true;\n error.value = null;\n\n try {\n const publicKeyObj = JSON.parse(\n Buffer.from(publicKey.replace(\"pk_\", \"\"), \"base64\").toString(\"utf-8\"),\n );\n\n const authUrl = new URL(\n `${publicKeyObj.identityHost}/oidc/${publicKeyObj.environmentId}/authorize`,\n );\n authUrl.searchParams.set(\"client_id\", publicKey);\n authUrl.searchParams.set(\"response_type\", \"code\");\n authUrl.searchParams.set(\"scope\", \"openid profile email\");\n authUrl.searchParams.set(\n \"redirect_uri\",\n redirectUrl || window.location.origin,\n );\n authUrl.searchParams.set(\"prompt\", \"signup\");\n\n window.location.href = authUrl.toString();\n } catch (err) {\n error.value = err as Error;\n } finally {\n isLoading.value = false;\n }\n };\n\n return {\n signUp,\n isLoading: computed(() => isLoading.value),\n error: computed(() => error.value),\n };\n};\n","import { ref, computed, inject } from \"vue\";\nimport { AUTHDOG_CONTEXT_KEY, type AuthdogContext } from \"../client/provider\";\n\nexport const useSignOut = () => {\n const context = inject<AuthdogContext>(AUTHDOG_CONTEXT_KEY);\n const isLoading = ref(false);\n const error = ref<Error | null>(null);\n\n if (!context) {\n throw new Error(\"useSignOut must be used within AuthdogProvider\");\n }\n\n const signOut = async () => {\n isLoading.value = true;\n error.value = null;\n\n try {\n // Clear token from context\n context.setToken(null);\n\n // Clear token from localStorage\n if (typeof window !== \"undefined\") {\n localStorage.removeItem(\"token\");\n }\n\n // Redirect to logout endpoint or home page\n if (typeof window !== \"undefined\") {\n window.location.href = \"/logout\";\n }\n } catch (err) {\n error.value = err as Error;\n } finally {\n isLoading.value = false;\n }\n };\n\n return {\n signOut,\n isLoading: computed(() => isLoading.value),\n error: computed(() => error.value),\n };\n};\n","import { ref, computed, inject } from \"vue\";\nimport { AUTHDOG_CONTEXT_KEY, type AuthdogContext } from \"../client/provider\";\n\nexport const useOrganization = () => {\n const context = inject<AuthdogContext>(AUTHDOG_CONTEXT_KEY);\n const organization = ref<any>(null);\n const isLoading = ref(false);\n const error = ref<Error | null>(null);\n\n if (!context) {\n throw new Error(\"useOrganization must be used within AuthdogProvider\");\n }\n\n const fetchOrganization = async (organizationId: string) => {\n if (!context.token) {\n return null;\n }\n\n isLoading.value = true;\n error.value = null;\n\n try {\n // This would be implemented based on your organization API\n // For now, returning a placeholder\n const response = await fetch(`/api/organizations/${organizationId}`, {\n headers: {\n Authorization: `Bearer ${context.token}`,\n },\n });\n\n if (!response.ok) {\n throw new Error(\"Failed to fetch organization\");\n }\n\n organization.value = await response.json();\n return organization.value;\n } catch (err) {\n error.value = err as Error;\n return null;\n } finally {\n isLoading.value = false;\n }\n };\n\n return {\n organization: computed(() => organization.value),\n isLoading: computed(() => isLoading.value),\n error: computed(() => error.value),\n fetchOrganization,\n };\n};\n","import { ref, computed, inject } from \"vue\";\nimport { AUTHDOG_CONTEXT_KEY, type AuthdogContext } from \"../client/provider\";\n\nexport const useOrganizationList = () => {\n const context = inject<AuthdogContext>(AUTHDOG_CONTEXT_KEY);\n const organizations = ref<any[]>([]);\n const isLoading = ref(false);\n const error = ref<Error | null>(null);\n\n if (!context) {\n throw new Error(\"useOrganizationList must be used within AuthdogProvider\");\n }\n\n const fetchOrganizations = async () => {\n if (!context.token) {\n return [];\n }\n\n isLoading.value = true;\n error.value = null;\n\n try {\n // This would be implemented based on your organizations API\n // For now, returning a placeholder\n const response = await fetch(\"/api/organizations\", {\n headers: {\n Authorization: `Bearer ${context.token}`,\n },\n });\n\n if (!response.ok) {\n throw new Error(\"Failed to fetch organizations\");\n }\n\n const data = await response.json();\n organizations.value = data.organizations || [];\n return organizations.value;\n } catch (err) {\n error.value = err as Error;\n return [];\n } finally {\n isLoading.value = false;\n }\n };\n\n return {\n organizations: computed(() => organizations.value),\n isLoading: computed(() => isLoading.value),\n error: computed(() => error.value),\n fetchOrganizations,\n };\n};\n","import { ref, computed, inject } from \"vue\";\nimport { AUTHDOG_CONTEXT_KEY, type AuthdogContext } from \"../client/provider\";\n\nexport const useAuthz = () => {\n const context = inject<AuthdogContext>(AUTHDOG_CONTEXT_KEY);\n const permissions = ref<string[]>([]);\n const isLoading = ref(false);\n const error = ref<Error | null>(null);\n\n if (!context) {\n throw new Error(\"useAuthz must be used within AuthdogProvider\");\n }\n\n const fetchPermissions = async () => {\n if (!context.token) {\n return [];\n }\n\n isLoading.value = true;\n error.value = null;\n\n try {\n // This would be implemented based on your authorization API\n // For now, returning a placeholder\n const response = await fetch(\"/api/permissions\", {\n headers: {\n Authorization: `Bearer ${context.token}`,\n },\n });\n\n if (!response.ok) {\n throw new Error(\"Failed to fetch permissions\");\n }\n\n const data = await response.json();\n permissions.value = data.permissions || [];\n return permissions.value;\n } catch (err) {\n error.value = err as Error;\n return [];\n } finally {\n isLoading.value = false;\n }\n };\n\n const hasPermission = (permission: string) => {\n return permissions.value.includes(permission);\n };\n\n const hasAnyPermission = (permissionList: string[]) => {\n return permissionList.some((permission) =>\n permissions.value.includes(permission),\n );\n };\n\n const hasAllPermissions = (permissionList: string[]) => {\n return permissionList.every((permission) =>\n permissions.value.includes(permission),\n );\n };\n\n return {\n permissions: computed(() => permissions.value),\n isLoading: computed(() => isLoading.value),\n error: computed(() => error.value),\n fetchPermissions,\n hasPermission,\n hasAnyPermission,\n hasAllPermissions,\n };\n};\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,cAAAE,EAAA,oBAAAC,EAAA,wBAAAC,EAAA,eAAAC,EAAA,cAAAC,EAAA,eAAAC,EAAA,cAAAC,EAAA,YAAAC,IAAA,eAAAC,EAAAV,GCAA,IAAAW,EAAiC,eCAjC,IAAAC,EAOO,eAQMC,EACX,OAAO,SAAS,EAELC,KAAkB,mBAAgB,CAC7C,KAAM,kBACN,MAAMC,EAAG,CAAE,MAAAC,CAAM,EAAG,CAClB,IAAMC,KAAY,OAAI,EAAI,EACpBC,KAAQ,OAAmB,IAAI,EAE/BC,EAAYC,GAA4B,CAC5CF,EAAM,MAAQE,CAChB,KAEA,aAAU,IAAM,CAEd,GAAI,OAAO,OAAW,IAAa,CAEjC,IAAMC,EAAM,IAAI,IAAI,OAAO,SAAS,IAAI,EAClCC,EAAWD,EAAI,aAAa,IAAI,OAAO,EAE7C,GAAIC,EAAU,CAEZD,EAAI,aAAa,OAAO,OAAO,EAC/B,OAAO,QAAQ,aAAa,CAAC,EAAG,SAAS,MAAOA,EAAI,SAAS,CAAC,EAG9D,aAAa,QAAQ,QAASC,CAAQ,EACtCH,EAASG,CAAQ,EAGjB,OAAO,SAAS,OAAO,EACvB,MACF,CAGA,IAAMC,EAAgB,aAAa,QAAQ,OAAO,EAC9CA,GACFJ,EAASI,CAAa,EAIxBN,EAAU,MAAQ,EACpB,MAEEA,EAAU,MAAQ,EAEtB,CAAC,EAED,IAAMO,EAA0B,CAC9B,UAAWP,EAAU,MACrB,MAAOC,EAAM,MACb,SAAAC,CACF,EAEA,oBAAQN,EAAqBW,CAAO,EAE7B,IAAG,CAvEd,IAAAC,EAuEiB,OAAAA,EAAAT,EAAM,UAA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AAM,8CAA8C,EAGhE,IAAMK,EAAmB,SAAY,CACnC,GAAI,CAACL,EAAQ,MACX,MAAO,CAAC,EAGVG,EAAU,MAAQ,GAClBC,EAAM,MAAQ,KAEd,GAAI,CAGF,IAAME,EAAW,MAAM,MAAM,mBAAoB,CAC/C,QAAS,CACP,cAAe,UAAUN,EAAQ,KAAK,EACxC,CACF,CAAC,EAED,GAAI,CAACM,EAAS,GACZ,MAAM,IAAI,MAAM,6BAA6B,EAG/C,IAAMC,EAAO,MAAMD,EAAS,KAAK,EACjC,OAAAJ,EAAY,MAAQK,EAAK,aAAe,CAAC,EAClCL,EAAY,KACrB,OAASM,EAAK,CACZ,OAAAJ,EAAM,MAAQI,EACP,CAAC,CACV,QAAE,CACAL,EAAU,MAAQ,EACpB,CACF,EAEMM,EAAiBC,GACdR,EAAY,MAAM,SAASQ,CAAU,EAGxCC,EAAoBC,GACjBA,EAAe,KAAMF,GAC1BR,EAAY,MAAM,SAASQ,CAAU,CACvC,EAGIG,EAAqBD,GAClBA,EAAe,MAAOF,GAC3BR,EAAY,MAAM,SAASQ,CAAU,CACvC,EAGF,MAAO,CACL,eAAa,YAAS,IAAMR,EAAY,KAAK,EAC7C,aAAW,YAAS,IAAMC,EAAU,KAAK,EACzC,SAAO,YAAS,IAAMC,EAAM,KAAK,EACjC,iBAAAC,EACA,cAAAI,EACA,iBAAAE,EACA,kBAAAE,CACF,CACF","names":["index_exports","__export","useAuthz","useOrganization","useOrganizationList","useSession","useSignIn","useSignOut","useSignUp","useUser","__toCommonJS","import_vue","import_vue","AUTHDOG_CONTEXT_KEY","AuthdogProvider","_","slots","isLoading","token","setToken","newToken","url","urlToken","existingToken","context","_a","useSession","context","AUTHDOG_CONTEXT_KEY","import_vue","getPublicKeyPayload","publicKey","validatePublicKey","publicKey","fetchUserData","token","publicKeyObj","getPublicKeyPayload","userData","browserCookiesOptions","useUser","context","AUTHDOG_CONTEXT_KEY","user","isLoading","error","fetchUser","publicKey","validatePublicKey","userData","fetchUserData","err","isAuthenticated","import_vue","useSignIn","context","AUTHDOG_CONTEXT_KEY","isLoading","error","publicKey","redirectUrl","publicKeyObj","authUrl","err","import_vue","useSignUp","context","AUTHDOG_CONTEXT_KEY","isLoading","error","publicKey","redirectUrl","publicKeyObj","authUrl","err","import_vue","useSignOut","context","AUTHDOG_CONTEXT_KEY","isLoading","error","err","import_vue","useOrganization","context","AUTHDOG_CONTEXT_KEY","organization","isLoading","error","fetchOrganization","organizationId","response","err","import_vue","useOrganizationList","context","AUTHDOG_CONTEXT_KEY","organizations","isLoading","error","fetchOrganizations","response","data","err","import_vue","useAuthz","context","AUTHDOG_CONTEXT_KEY","permissions","isLoading","error","fetchPermissions","response","data","err","hasPermission","permission","hasAnyPermission","permissionList","hasAllPermissions"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/composables/use-session.ts","../src/client/provider.ts","../src/composables/use-user.ts","../src/commons.ts","../src/client/session.ts","../src/composables/use-signin.ts","../src/composables/use-signup.ts","../src/composables/use-signout.ts","../src/composables/use-organization.ts","../src/composables/use-organization-list.ts","../src/composables/use-authz.ts"],"sourcesContent":["import { computed, inject } from 'vue'\nimport { AUTHDOG_CONTEXT_KEY, type AuthdogContext } from '../client/provider'\n\nexport const useSession = () => {\n const context = inject<AuthdogContext>(AUTHDOG_CONTEXT_KEY)\n\n if (!context) {\n throw new Error('useSession must be used within AuthdogProvider')\n }\n\n const session = computed(() => ({\n token: context.token,\n isAuthenticated: !!context.token,\n }))\n\n return {\n session: session.value,\n isLoading: context.isLoading,\n }\n}\n","import { defineComponent, onMounted, ref, provide, inject, type InjectionKey } from 'vue'\n\nexport interface AuthdogContext {\n isLoading: boolean\n token: string | null\n setToken: (token: string | null) => void\n}\n\nexport const AUTHDOG_CONTEXT_KEY: InjectionKey<AuthdogContext> = Symbol('authdog')\n\nexport const AuthdogProvider = defineComponent({\n name: 'AuthdogProvider',\n setup(_, { slots }) {\n const isLoading = ref(true)\n const token = ref<string | null>(null)\n\n const setToken = (newToken: string | null) => {\n token.value = newToken\n }\n\n onMounted(() => {\n // Check if we're in the browser\n if (typeof window !== 'undefined') {\n // Check if there's a token in the URL\n const url = new URL(window.location.href)\n const urlToken = url.searchParams.get('token')\n\n if (urlToken) {\n // Remove token from URL without triggering a page reload\n url.searchParams.delete('token')\n window.history.replaceState({}, document.title, url.toString())\n \n // Store token and reload to ensure server processes it\n localStorage.setItem('token', urlToken)\n setToken(urlToken)\n \n // Force a reload to ensure the server processes the token\n window.location.reload()\n return\n }\n\n // Check for existing token in localStorage\n const existingToken = localStorage.getItem('token')\n if (existingToken) {\n setToken(existingToken)\n }\n\n // If no token, we're done loading\n isLoading.value = false\n } else {\n // If we're on the server, don't show loading state\n isLoading.value = false\n }\n })\n\n const context: AuthdogContext = {\n isLoading: isLoading.value,\n token: token.value,\n setToken\n }\n\n provide(AUTHDOG_CONTEXT_KEY, context)\n\n return () => slots.default?.()\n }\n})\n","import { ref, computed, inject } from 'vue'\nimport { AUTHDOG_CONTEXT_KEY, type AuthdogContext } from '../client/provider'\nimport { fetchUserData, validatePublicKey } from '../client/session'\n\nexport const useUser = () => {\n const context = inject<AuthdogContext>(AUTHDOG_CONTEXT_KEY)\n const user = ref<any>(null)\n const isLoading = ref(false)\n const error = ref<Error | null>(null)\n\n if (!context) {\n throw new Error('useUser must be used within AuthdogProvider')\n }\n\n const fetchUser = async (publicKey: string) => {\n if (!context.token) {\n return null\n }\n\n isLoading.value = true\n error.value = null\n\n try {\n validatePublicKey(publicKey)\n const userData = await fetchUserData(publicKey, context.token)\n user.value = userData?.user || null\n return userData?.user || null\n } catch (err) {\n error.value = err as Error\n return null\n } finally {\n isLoading.value = false\n }\n }\n\n const isAuthenticated = computed(() => !!context.token && !!user.value)\n\n return {\n user: computed(() => user.value),\n isLoading: computed(() => isLoading.value),\n error: computed(() => error.value),\n isAuthenticated,\n fetchUser,\n }\n}\n","export interface PublicKeyPayload {\n environmentId: string\n identityHost: string\n}\n\nexport const getPublicKeyPayload = (publicKey: string): PublicKeyPayload => {\n if (!publicKey) {\n throw new Error('Public key is not defined')\n }\n\n if (!publicKey.startsWith('pk_')) {\n throw new Error('Invalid public key')\n }\n\n try {\n return JSON.parse(\n Buffer.from(publicKey.replace('pk_', ''), 'base64').toString('utf-8'),\n )\n } catch (e) {\n throw new Error('Failed to parse public key')\n }\n}\n","import { getPublicKeyPayload } from '../commons'\n\nexport const getTokenFromUri = (url: string): string | null => {\n return new URL(url).searchParams.get('token')\n}\n\ninterface IFetchUserData {\n user: {\n id: string\n environmentId: string\n externalId: string\n userName: string\n displayName: string\n nickName: string\n profileUrl: string\n title: string\n userType: string\n preferredLanguage: string | null\n locale: string | null\n timezone: string | null\n active: boolean\n provider: string\n lastLogin: string\n createdAt: string\n updatedAt: string\n names: {\n id: string\n userId: string\n formatted: string | null\n familyName: string\n givenName: string\n middleName: string | null\n honorificPrefix: string | null\n honorificSuffix: string | null\n createdAt: string\n updatedAt: string\n }\n addresses: []\n emails: {\n value: string\n primary: boolean\n type: string\n }[]\n phoneNumbers: []\n ims: []\n photos: {\n value: string\n type: string\n }[]\n }\n meta: {\n code: number\n message: string\n }\n}\n\nexport const validatePublicKey = (publicKey: string) => {\n if (!publicKey) {\n throw new Error('Public key is not defined')\n }\n\n if (!publicKey.startsWith('pk_')) {\n throw new Error('Invalid public key')\n }\n}\n\nexport const fetchUserData = async (\n publicKey: string,\n token: string,\n): Promise<IFetchUserData | null> => {\n validatePublicKey(publicKey)\n const publicKeyObj = getPublicKeyPayload(publicKey)\n const userData = await fetch(\n `${publicKeyObj?.identityHost}/oidc/${publicKeyObj?.environmentId}/userinfo`,\n {\n headers: {\n authorization: `Bearer ${token}`,\n },\n },\n )\n\n if (!userData.ok) {\n throw new Error('Failed to fetch user info')\n }\n\n return await userData.json()\n}\n\nexport const browserCookiesOptions = {\n maxAge: 60 * 60 * 24 * 7, // 1 week\n path: '/',\n httpOnly: true,\n}\n","import { ref, computed, inject } from 'vue'\nimport { AUTHDOG_CONTEXT_KEY, type AuthdogContext } from '../client/provider'\n\nexport const useSignIn = () => {\n const context = inject<AuthdogContext>(AUTHDOG_CONTEXT_KEY)\n const isLoading = ref(false)\n const error = ref<Error | null>(null)\n\n if (!context) {\n throw new Error('useSignIn must be used within AuthdogProvider')\n }\n\n const signIn = async (publicKey: string, redirectUrl?: string) => {\n isLoading.value = true\n error.value = null\n\n try {\n const publicKeyObj = JSON.parse(\n Buffer.from(publicKey.replace('pk_', ''), 'base64').toString('utf-8')\n )\n \n const authUrl = new URL(`${publicKeyObj.identityHost}/oidc/${publicKeyObj.environmentId}/authorize`)\n authUrl.searchParams.set('client_id', publicKey)\n authUrl.searchParams.set('response_type', 'code')\n authUrl.searchParams.set('scope', 'openid profile email')\n authUrl.searchParams.set('redirect_uri', redirectUrl || window.location.origin)\n \n window.location.href = authUrl.toString()\n } catch (err) {\n error.value = err as Error\n } finally {\n isLoading.value = false\n }\n }\n\n return {\n signIn,\n isLoading: computed(() => isLoading.value),\n error: computed(() => error.value),\n }\n}\n","import { ref, computed, inject } from 'vue'\nimport { AUTHDOG_CONTEXT_KEY, type AuthdogContext } from '../client/provider'\n\nexport const useSignUp = () => {\n const context = inject<AuthdogContext>(AUTHDOG_CONTEXT_KEY)\n const isLoading = ref(false)\n const error = ref<Error | null>(null)\n\n if (!context) {\n throw new Error('useSignUp must be used within AuthdogProvider')\n }\n\n const signUp = async (publicKey: string, redirectUrl?: string) => {\n isLoading.value = true\n error.value = null\n\n try {\n const publicKeyObj = JSON.parse(\n Buffer.from(publicKey.replace('pk_', ''), 'base64').toString('utf-8')\n )\n \n const authUrl = new URL(`${publicKeyObj.identityHost}/oidc/${publicKeyObj.environmentId}/authorize`)\n authUrl.searchParams.set('client_id', publicKey)\n authUrl.searchParams.set('response_type', 'code')\n authUrl.searchParams.set('scope', 'openid profile email')\n authUrl.searchParams.set('redirect_uri', redirectUrl || window.location.origin)\n authUrl.searchParams.set('prompt', 'signup')\n \n window.location.href = authUrl.toString()\n } catch (err) {\n error.value = err as Error\n } finally {\n isLoading.value = false\n }\n }\n\n return {\n signUp,\n isLoading: computed(() => isLoading.value),\n error: computed(() => error.value),\n }\n}\n","import { ref, computed, inject } from 'vue'\nimport { AUTHDOG_CONTEXT_KEY, type AuthdogContext } from '../client/provider'\n\nexport const useSignOut = () => {\n const context = inject<AuthdogContext>(AUTHDOG_CONTEXT_KEY)\n const isLoading = ref(false)\n const error = ref<Error | null>(null)\n\n if (!context) {\n throw new Error('useSignOut must be used within AuthdogProvider')\n }\n\n const signOut = async () => {\n isLoading.value = true\n error.value = null\n\n try {\n // Clear token from context\n context.setToken(null)\n \n // Clear token from localStorage\n if (typeof window !== 'undefined') {\n localStorage.removeItem('token')\n }\n \n // Redirect to logout endpoint or home page\n if (typeof window !== 'undefined') {\n window.location.href = '/logout'\n }\n } catch (err) {\n error.value = err as Error\n } finally {\n isLoading.value = false\n }\n }\n\n return {\n signOut,\n isLoading: computed(() => isLoading.value),\n error: computed(() => error.value),\n }\n}\n","import { ref, computed, inject } from 'vue'\nimport { AUTHDOG_CONTEXT_KEY, type AuthdogContext } from '../client/provider'\n\nexport const useOrganization = () => {\n const context = inject<AuthdogContext>(AUTHDOG_CONTEXT_KEY)\n const organization = ref<any>(null)\n const isLoading = ref(false)\n const error = ref<Error | null>(null)\n\n if (!context) {\n throw new Error('useOrganization must be used within AuthdogProvider')\n }\n\n const fetchOrganization = async (organizationId: string) => {\n if (!context.token) {\n return null\n }\n\n isLoading.value = true\n error.value = null\n\n try {\n // This would be implemented based on your organization API\n // For now, returning a placeholder\n const response = await fetch(`/api/organizations/${organizationId}`, {\n headers: {\n 'Authorization': `Bearer ${context.token}`,\n },\n })\n\n if (!response.ok) {\n throw new Error('Failed to fetch organization')\n }\n\n organization.value = await response.json()\n return organization.value\n } catch (err) {\n error.value = err as Error\n return null\n } finally {\n isLoading.value = false\n }\n }\n\n return {\n organization: computed(() => organization.value),\n isLoading: computed(() => isLoading.value),\n error: computed(() => error.value),\n fetchOrganization,\n }\n}\n","import { ref, computed, inject } from 'vue'\nimport { AUTHDOG_CONTEXT_KEY, type AuthdogContext } from '../client/provider'\n\nexport const useOrganizationList = () => {\n const context = inject<AuthdogContext>(AUTHDOG_CONTEXT_KEY)\n const organizations = ref<any[]>([])\n const isLoading = ref(false)\n const error = ref<Error | null>(null)\n\n if (!context) {\n throw new Error('useOrganizationList must be used within AuthdogProvider')\n }\n\n const fetchOrganizations = async () => {\n if (!context.token) {\n return []\n }\n\n isLoading.value = true\n error.value = null\n\n try {\n // This would be implemented based on your organizations API\n // For now, returning a placeholder\n const response = await fetch('/api/organizations', {\n headers: {\n 'Authorization': `Bearer ${context.token}`,\n },\n })\n\n if (!response.ok) {\n throw new Error('Failed to fetch organizations')\n }\n\n const data = await response.json()\n organizations.value = data.organizations || []\n return organizations.value\n } catch (err) {\n error.value = err as Error\n return []\n } finally {\n isLoading.value = false\n }\n }\n\n return {\n organizations: computed(() => organizations.value),\n isLoading: computed(() => isLoading.value),\n error: computed(() => error.value),\n fetchOrganizations,\n }\n}\n","import { ref, computed, inject } from 'vue'\nimport { AUTHDOG_CONTEXT_KEY, type AuthdogContext } from '../client/provider'\n\nexport const useAuthz = () => {\n const context = inject<AuthdogContext>(AUTHDOG_CONTEXT_KEY)\n const permissions = ref<string[]>([])\n const isLoading = ref(false)\n const error = ref<Error | null>(null)\n\n if (!context) {\n throw new Error('useAuthz must be used within AuthdogProvider')\n }\n\n const fetchPermissions = async () => {\n if (!context.token) {\n return []\n }\n\n isLoading.value = true\n error.value = null\n\n try {\n // This would be implemented based on your authorization API\n // For now, returning a placeholder\n const response = await fetch('/api/permissions', {\n headers: {\n 'Authorization': `Bearer ${context.token}`,\n },\n })\n\n if (!response.ok) {\n throw new Error('Failed to fetch permissions')\n }\n\n const data = await response.json()\n permissions.value = data.permissions || []\n return permissions.value\n } catch (err) {\n error.value = err as Error\n return []\n } finally {\n isLoading.value = false\n }\n }\n\n const hasPermission = (permission: string) => {\n return permissions.value.includes(permission)\n }\n\n const hasAnyPermission = (permissionList: string[]) => {\n return permissionList.some(permission => permissions.value.includes(permission))\n }\n\n const hasAllPermissions = (permissionList: string[]) => {\n return permissionList.every(permission => permissions.value.includes(permission))\n }\n\n return {\n permissions: computed(() => permissions.value),\n isLoading: computed(() => isLoading.value),\n error: computed(() => error.value),\n fetchPermissions,\n hasPermission,\n hasAnyPermission,\n hasAllPermissions,\n }\n}\n"],"mappings":"AAAA,OAAS,YAAAA,EAAU,UAAAC,MAAc,MCAjC,OAAS,mBAAAC,EAAiB,aAAAC,EAAW,OAAAC,EAAK,WAAAC,MAA0C,MAQ7E,IAAMC,EAAoD,OAAO,SAAS,EAEpEC,EAAkBL,EAAgB,CAC7C,KAAM,kBACN,MAAMM,EAAG,CAAE,MAAAC,CAAM,EAAG,CAClB,IAAMC,EAAYN,EAAI,EAAI,EACpBO,EAAQP,EAAmB,IAAI,EAE/BQ,EAAYC,GAA4B,CAC5CF,EAAM,MAAQE,CAChB,EAEAV,EAAU,IAAM,CAEd,GAAI,OAAO,OAAW,IAAa,CAEjC,IAAMW,EAAM,IAAI,IAAI,OAAO,SAAS,IAAI,EAClCC,EAAWD,EAAI,aAAa,IAAI,OAAO,EAE7C,GAAIC,EAAU,CAEZD,EAAI,aAAa,OAAO,OAAO,EAC/B,OAAO,QAAQ,aAAa,CAAC,EAAG,SAAS,MAAOA,EAAI,SAAS,CAAC,EAG9D,aAAa,QAAQ,QAASC,CAAQ,EACtCH,EAASG,CAAQ,EAGjB,OAAO,SAAS,OAAO,EACvB,MACF,CAGA,IAAMC,EAAgB,aAAa,QAAQ,OAAO,EAC9CA,GACFJ,EAASI,CAAa,EAIxBN,EAAU,MAAQ,EACpB,MAEEA,EAAU,MAAQ,EAEtB,CAAC,EAED,IAAMO,EAA0B,CAC9B,UAAWP,EAAU,MACrB,MAAOC,EAAM,MACb,SAAAC,CACF,EAEA,OAAAP,EAAQC,EAAqBW,CAAO,EAE7B,IAAG,CA/Dd,IAAAC,EA+DiB,OAAAA,EAAAT,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Provider","_","slots","isLoading","token","setToken","newToken","url","urlToken","existingToken","context","_a","useSession","context","inject","AUTHDOG_CONTEXT_KEY","computed","ref","computed","inject","getPublicKeyPayload","publicKey","validatePublicKey","publicKey","fetchUserData","token","publicKeyObj","getPublicKeyPayload","userData","browserCookiesOptions","useUser","context","inject","AUTHDOG_CONTEXT_KEY","user","ref","isLoading","error","fetchUser","publicKey","validatePublicKey","userData","fetchUserData","err","isAuthenticated","computed","ref","computed","inject","useSignIn","context","inject","AUTHDOG_CONTEXT_KEY","isLoading","ref","error","publicKey","redirectUrl","publicKeyObj","authUrl","err","computed","ref","computed","inject","useSignUp","context","inject","AUTHDOG_CONTEXT_KEY","isLoading","ref","error","publicKey","redirectUrl","publicKeyObj","authUrl","err","computed","ref","computed","inject","useSignOut","context","inject","AUTHDOG_CONTEXT_KEY","isLoading","ref","error","err","computed","ref","computed","inject","useOrganization","context","inject","AUTHDOG_CONTEXT_KEY","organization","ref","isLoading","error","fetchOrganization","organizationId","response","err","computed","ref","computed","inject","useOrganizationList","context","inject","AUTHDOG_CONTEXT_KEY","organizations","ref","isLoading","error","fetchOrganizations","response","data","err","computed","ref","computed","inject","useAuthz","context","inject","AUTHDOG_CONTEXT_KEY","permissions","ref","isLoading","error","fetchPermissions","response","data","err","hasPermission","permission","hasAnyPermission","permissionList","hasAllPermissions","computed"]}
1
+ {"version":3,"sources":["../src/composables/use-session.ts","../src/client/provider.ts","../src/composables/use-user.ts","../src/commons.ts","../src/client/session.ts","../src/composables/use-signin.ts","../src/composables/use-signup.ts","../src/composables/use-signout.ts","../src/composables/use-organization.ts","../src/composables/use-organization-list.ts","../src/composables/use-authz.ts"],"sourcesContent":["import { computed, inject } from \"vue\";\nimport { AUTHDOG_CONTEXT_KEY, type AuthdogContext } from \"../client/provider\";\n\nexport const useSession = () => {\n const context = inject<AuthdogContext>(AUTHDOG_CONTEXT_KEY);\n\n if (!context) {\n throw new Error(\"useSession must be used within AuthdogProvider\");\n }\n\n const session = computed(() => ({\n token: context.token,\n isAuthenticated: !!context.token,\n }));\n\n return {\n session: session.value,\n isLoading: context.isLoading,\n };\n};\n","import {\n defineComponent,\n onMounted,\n ref,\n provide,\n inject,\n type InjectionKey,\n} from \"vue\";\n\nexport interface AuthdogContext {\n isLoading: boolean;\n token: string | null;\n setToken: (token: string | null) => void;\n}\n\nexport const AUTHDOG_CONTEXT_KEY: InjectionKey<AuthdogContext> =\n Symbol(\"authdog\");\n\nexport const AuthdogProvider = defineComponent({\n name: \"AuthdogProvider\",\n setup(_, { slots }) {\n const isLoading = ref(true);\n const token = ref<string | null>(null);\n\n const setToken = (newToken: string | null) => {\n token.value = newToken;\n };\n\n onMounted(() => {\n // Check if we're in the browser\n if (typeof window !== \"undefined\") {\n // Check if there's a token in the URL\n const url = new URL(window.location.href);\n const urlToken = url.searchParams.get(\"token\");\n\n if (urlToken) {\n // Remove token from URL without triggering a page reload\n url.searchParams.delete(\"token\");\n window.history.replaceState({}, document.title, url.toString());\n\n // Store token and reload to ensure server processes it\n localStorage.setItem(\"token\", urlToken);\n setToken(urlToken);\n\n // Force a reload to ensure the server processes the token\n window.location.reload();\n return;\n }\n\n // Check for existing token in localStorage\n const existingToken = localStorage.getItem(\"token\");\n if (existingToken) {\n setToken(existingToken);\n }\n\n // If no token, we're done loading\n isLoading.value = false;\n } else {\n // If we're on the server, don't show loading state\n isLoading.value = false;\n }\n });\n\n const context: AuthdogContext = {\n isLoading: isLoading.value,\n token: token.value,\n setToken,\n };\n\n provide(AUTHDOG_CONTEXT_KEY, context);\n\n return () => slots.default?.();\n },\n});\n","import { ref, computed, inject } from \"vue\";\nimport { AUTHDOG_CONTEXT_KEY, type AuthdogContext } from \"../client/provider\";\nimport { fetchUserData, validatePublicKey } from \"../client/session\";\n\nexport const useUser = () => {\n const context = inject<AuthdogContext>(AUTHDOG_CONTEXT_KEY);\n const user = ref<any>(null);\n const isLoading = ref(false);\n const error = ref<Error | null>(null);\n\n if (!context) {\n throw new Error(\"useUser must be used within AuthdogProvider\");\n }\n\n const fetchUser = async (publicKey: string) => {\n if (!context.token) {\n return null;\n }\n\n isLoading.value = true;\n error.value = null;\n\n try {\n validatePublicKey(publicKey);\n const userData = await fetchUserData(publicKey, context.token);\n user.value = userData?.user || null;\n return userData?.user || null;\n } catch (err) {\n error.value = err as Error;\n return null;\n } finally {\n isLoading.value = false;\n }\n };\n\n const isAuthenticated = computed(() => !!context.token && !!user.value);\n\n return {\n user: computed(() => user.value),\n isLoading: computed(() => isLoading.value),\n error: computed(() => error.value),\n isAuthenticated,\n fetchUser,\n };\n};\n","export interface PublicKeyPayload {\n environmentId: string;\n identityHost: string;\n}\n\nexport const getPublicKeyPayload = (publicKey: string): PublicKeyPayload => {\n if (!publicKey) {\n throw new Error(\"Public key is not defined\");\n }\n\n if (!publicKey.startsWith(\"pk_\")) {\n throw new Error(\"Invalid public key\");\n }\n\n try {\n return JSON.parse(\n Buffer.from(publicKey.replace(\"pk_\", \"\"), \"base64\").toString(\"utf-8\"),\n );\n } catch (e) {\n throw new Error(\"Failed to parse public key\");\n }\n};\n","import { getPublicKeyPayload } from \"../commons\";\n\nexport const getTokenFromUri = (url: string): string | null => {\n return new URL(url).searchParams.get(\"token\");\n};\n\ninterface IFetchUserData {\n user: {\n id: string;\n environmentId: string;\n externalId: string;\n userName: string;\n displayName: string;\n nickName: string;\n profileUrl: string;\n title: string;\n userType: string;\n preferredLanguage: string | null;\n locale: string | null;\n timezone: string | null;\n active: boolean;\n provider: string;\n lastLogin: string;\n createdAt: string;\n updatedAt: string;\n names: {\n id: string;\n userId: string;\n formatted: string | null;\n familyName: string;\n givenName: string;\n middleName: string | null;\n honorificPrefix: string | null;\n honorificSuffix: string | null;\n createdAt: string;\n updatedAt: string;\n };\n addresses: [];\n emails: {\n value: string;\n primary: boolean;\n type: string;\n }[];\n phoneNumbers: [];\n ims: [];\n photos: {\n value: string;\n type: string;\n }[];\n };\n meta: {\n code: number;\n message: string;\n };\n}\n\nexport const validatePublicKey = (publicKey: string) => {\n if (!publicKey) {\n throw new Error(\"Public key is not defined\");\n }\n\n if (!publicKey.startsWith(\"pk_\")) {\n throw new Error(\"Invalid public key\");\n }\n};\n\nexport const fetchUserData = async (\n publicKey: string,\n token: string,\n): Promise<IFetchUserData | null> => {\n validatePublicKey(publicKey);\n const publicKeyObj = getPublicKeyPayload(publicKey);\n const userData = await fetch(\n `${publicKeyObj?.identityHost}/oidc/${publicKeyObj?.environmentId}/userinfo`,\n {\n headers: {\n authorization: `Bearer ${token}`,\n },\n },\n );\n\n if (!userData.ok) {\n throw new Error(\"Failed to fetch user info\");\n }\n\n return await userData.json();\n};\n\nexport const browserCookiesOptions = {\n maxAge: 60 * 60 * 24 * 7, // 1 week\n path: \"/\",\n httpOnly: true,\n};\n","import { ref, computed, inject } from \"vue\";\nimport { AUTHDOG_CONTEXT_KEY, type AuthdogContext } from \"../client/provider\";\n\nexport const useSignIn = () => {\n const context = inject<AuthdogContext>(AUTHDOG_CONTEXT_KEY);\n const isLoading = ref(false);\n const error = ref<Error | null>(null);\n\n if (!context) {\n throw new Error(\"useSignIn must be used within AuthdogProvider\");\n }\n\n const signIn = async (publicKey: string, redirectUrl?: string) => {\n isLoading.value = true;\n error.value = null;\n\n try {\n const publicKeyObj = JSON.parse(\n Buffer.from(publicKey.replace(\"pk_\", \"\"), \"base64\").toString(\"utf-8\"),\n );\n\n const authUrl = new URL(\n `${publicKeyObj.identityHost}/oidc/${publicKeyObj.environmentId}/authorize`,\n );\n authUrl.searchParams.set(\"client_id\", publicKey);\n authUrl.searchParams.set(\"response_type\", \"code\");\n authUrl.searchParams.set(\"scope\", \"openid profile email\");\n authUrl.searchParams.set(\n \"redirect_uri\",\n redirectUrl || window.location.origin,\n );\n\n window.location.href = authUrl.toString();\n } catch (err) {\n error.value = err as Error;\n } finally {\n isLoading.value = false;\n }\n };\n\n return {\n signIn,\n isLoading: computed(() => isLoading.value),\n error: computed(() => error.value),\n };\n};\n","import { ref, computed, inject } from \"vue\";\nimport { AUTHDOG_CONTEXT_KEY, type AuthdogContext } from \"../client/provider\";\n\nexport const useSignUp = () => {\n const context = inject<AuthdogContext>(AUTHDOG_CONTEXT_KEY);\n const isLoading = ref(false);\n const error = ref<Error | null>(null);\n\n if (!context) {\n throw new Error(\"useSignUp must be used within AuthdogProvider\");\n }\n\n const signUp = async (publicKey: string, redirectUrl?: string) => {\n isLoading.value = true;\n error.value = null;\n\n try {\n const publicKeyObj = JSON.parse(\n Buffer.from(publicKey.replace(\"pk_\", \"\"), \"base64\").toString(\"utf-8\"),\n );\n\n const authUrl = new URL(\n `${publicKeyObj.identityHost}/oidc/${publicKeyObj.environmentId}/authorize`,\n );\n authUrl.searchParams.set(\"client_id\", publicKey);\n authUrl.searchParams.set(\"response_type\", \"code\");\n authUrl.searchParams.set(\"scope\", \"openid profile email\");\n authUrl.searchParams.set(\n \"redirect_uri\",\n redirectUrl || window.location.origin,\n );\n authUrl.searchParams.set(\"prompt\", \"signup\");\n\n window.location.href = authUrl.toString();\n } catch (err) {\n error.value = err as Error;\n } finally {\n isLoading.value = false;\n }\n };\n\n return {\n signUp,\n isLoading: computed(() => isLoading.value),\n error: computed(() => error.value),\n };\n};\n","import { ref, computed, inject } from \"vue\";\nimport { AUTHDOG_CONTEXT_KEY, type AuthdogContext } from \"../client/provider\";\n\nexport const useSignOut = () => {\n const context = inject<AuthdogContext>(AUTHDOG_CONTEXT_KEY);\n const isLoading = ref(false);\n const error = ref<Error | null>(null);\n\n if (!context) {\n throw new Error(\"useSignOut must be used within AuthdogProvider\");\n }\n\n const signOut = async () => {\n isLoading.value = true;\n error.value = null;\n\n try {\n // Clear token from context\n context.setToken(null);\n\n // Clear token from localStorage\n if (typeof window !== \"undefined\") {\n localStorage.removeItem(\"token\");\n }\n\n // Redirect to logout endpoint or home page\n if (typeof window !== \"undefined\") {\n window.location.href = \"/logout\";\n }\n } catch (err) {\n error.value = err as Error;\n } finally {\n isLoading.value = false;\n }\n };\n\n return {\n signOut,\n isLoading: computed(() => isLoading.value),\n error: computed(() => error.value),\n };\n};\n","import { ref, computed, inject } from \"vue\";\nimport { AUTHDOG_CONTEXT_KEY, type AuthdogContext } from \"../client/provider\";\n\nexport const useOrganization = () => {\n const context = inject<AuthdogContext>(AUTHDOG_CONTEXT_KEY);\n const organization = ref<any>(null);\n const isLoading = ref(false);\n const error = ref<Error | null>(null);\n\n if (!context) {\n throw new Error(\"useOrganization must be used within AuthdogProvider\");\n }\n\n const fetchOrganization = async (organizationId: string) => {\n if (!context.token) {\n return null;\n }\n\n isLoading.value = true;\n error.value = null;\n\n try {\n // This would be implemented based on your organization API\n // For now, returning a placeholder\n const response = await fetch(`/api/organizations/${organizationId}`, {\n headers: {\n Authorization: `Bearer ${context.token}`,\n },\n });\n\n if (!response.ok) {\n throw new Error(\"Failed to fetch organization\");\n }\n\n organization.value = await response.json();\n return organization.value;\n } catch (err) {\n error.value = err as Error;\n return null;\n } finally {\n isLoading.value = false;\n }\n };\n\n return {\n organization: computed(() => organization.value),\n isLoading: computed(() => isLoading.value),\n error: computed(() => error.value),\n fetchOrganization,\n };\n};\n","import { ref, computed, inject } from \"vue\";\nimport { AUTHDOG_CONTEXT_KEY, type AuthdogContext } from \"../client/provider\";\n\nexport const useOrganizationList = () => {\n const context = inject<AuthdogContext>(AUTHDOG_CONTEXT_KEY);\n const organizations = ref<any[]>([]);\n const isLoading = ref(false);\n const error = ref<Error | null>(null);\n\n if (!context) {\n throw new Error(\"useOrganizationList must be used within AuthdogProvider\");\n }\n\n const fetchOrganizations = async () => {\n if (!context.token) {\n return [];\n }\n\n isLoading.value = true;\n error.value = null;\n\n try {\n // This would be implemented based on your organizations API\n // For now, returning a placeholder\n const response = await fetch(\"/api/organizations\", {\n headers: {\n Authorization: `Bearer ${context.token}`,\n },\n });\n\n if (!response.ok) {\n throw new Error(\"Failed to fetch organizations\");\n }\n\n const data = await response.json();\n organizations.value = data.organizations || [];\n return organizations.value;\n } catch (err) {\n error.value = err as Error;\n return [];\n } finally {\n isLoading.value = false;\n }\n };\n\n return {\n organizations: computed(() => organizations.value),\n isLoading: computed(() => isLoading.value),\n error: computed(() => error.value),\n fetchOrganizations,\n };\n};\n","import { ref, computed, inject } from \"vue\";\nimport { AUTHDOG_CONTEXT_KEY, type AuthdogContext } from \"../client/provider\";\n\nexport const useAuthz = () => {\n const context = inject<AuthdogContext>(AUTHDOG_CONTEXT_KEY);\n const permissions = ref<string[]>([]);\n const isLoading = ref(false);\n const error = ref<Error | null>(null);\n\n if (!context) {\n throw new Error(\"useAuthz must be used within AuthdogProvider\");\n }\n\n const fetchPermissions = async () => {\n if (!context.token) {\n return [];\n }\n\n isLoading.value = true;\n error.value = null;\n\n try {\n // This would be implemented based on your authorization API\n // For now, returning a placeholder\n const response = await fetch(\"/api/permissions\", {\n headers: {\n Authorization: `Bearer ${context.token}`,\n },\n });\n\n if (!response.ok) {\n throw new Error(\"Failed to fetch permissions\");\n }\n\n const data = await response.json();\n permissions.value = data.permissions || [];\n return permissions.value;\n } catch (err) {\n error.value = err as Error;\n return [];\n } finally {\n isLoading.value = false;\n }\n };\n\n const hasPermission = (permission: string) => {\n return permissions.value.includes(permission);\n };\n\n const hasAnyPermission = (permissionList: string[]) => {\n return permissionList.some((permission) =>\n permissions.value.includes(permission),\n );\n };\n\n const hasAllPermissions = (permissionList: string[]) => {\n return permissionList.every((permission) =>\n permissions.value.includes(permission),\n );\n };\n\n return {\n permissions: computed(() => permissions.value),\n isLoading: computed(() => isLoading.value),\n error: computed(() => error.value),\n fetchPermissions,\n hasPermission,\n hasAnyPermission,\n hasAllPermissions,\n };\n};\n"],"mappings":"AAAA,OAAS,YAAAA,EAAU,UAAAC,MAAc,MCAjC,OACE,mBAAAC,EACA,aAAAC,EACA,OAAAC,EACA,WAAAC,MAGK,MAQA,IAAMC,EACX,OAAO,SAAS,EAELC,EAAkBL,EAAgB,CAC7C,KAAM,kBACN,MAAMM,EAAG,CAAE,MAAAC,CAAM,EAAG,CAClB,IAAMC,EAAYN,EAAI,EAAI,EACp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C,EAED,GAAI,CAACQ,EAAS,GACZ,MAAM,IAAI,MAAM,6BAA6B,EAG/C,IAAMC,EAAO,MAAMD,EAAS,KAAK,EACjC,OAAAL,EAAY,MAAQM,EAAK,aAAe,CAAC,EAClCN,EAAY,KACrB,OAASO,EAAK,CACZ,OAAAJ,EAAM,MAAQI,EACP,CAAC,CACV,QAAE,CACAL,EAAU,MAAQ,EACpB,CACF,EAEMM,EAAiBC,GACdT,EAAY,MAAM,SAASS,CAAU,EAGxCC,EAAoBC,GACjBA,EAAe,KAAMF,GAC1BT,EAAY,MAAM,SAASS,CAAU,CACvC,EAGIG,EAAqBD,GAClBA,EAAe,MAAOF,GAC3BT,EAAY,MAAM,SAASS,CAAU,CACvC,EAGF,MAAO,CACL,YAAaI,EAAS,IAAMb,EAAY,KAAK,EAC7C,UAAWa,EAAS,IAAMX,EAAU,KAAK,EACzC,MAAOW,EAAS,IAAMV,EAAM,KAAK,EACjC,iBAAAC,EACA,cAAAI,EACA,iBAAAE,EACA,kBAAAE,CACF,CACF","names":["computed","inject","defineComponent","onMounted","ref","provide","AUTHDOG_CONTEXT_KEY","AuthdogProvider","_","slots","isLoading","token","setToken","newToken","url","urlToken","existingToken","context","_a","useSession","context","inject","AUTHDOG_CONTEXT_KEY","computed","ref","computed","inject","getPublicKeyPayload","publicKey","validatePublicKey","publicKey","fetchUserData","token","publicKeyObj","getPublicKeyPayload","userData","browserCookiesOptions","useUser","context","inject","AUTHDOG_CONTEXT_KEY","user","ref","isLoading","error","fetchUser","publicKey","validatePublicKey","userData","fetchUserData","err","isAuthenticated","computed","ref","computed","inject","useSignIn","context","inject","AUTHDOG_CONTEXT_KEY","isLoading","ref","error","publicKey","redirectUrl","publicKeyObj","authUrl","err","computed","ref","computed","inject","useSignUp","context","inject","AUTHDOG_CONTEXT_KEY","isLoading","ref","error","publicKey","redirectUrl","publicKeyObj","authUrl","err","computed","ref","computed","inject","useSignOut","context","inject","AUTHDOG_CONTEXT_KEY","isLoading","ref","error","err","computed","ref","computed","inject","useOrganization","context","inject","AUTHDOG_CONTEXT_KEY","organization","ref","isLoading","error","fetchOrganization","organizationId","response","err","computed","ref","computed","inject","useOrganizationList","context","inject","AUTHDOG_CONTEXT_KEY","organizations","ref","isLoading","error","fetchOrganizations","response","data","err","computed","ref","computed","inject","useAuthz","context","inject","AUTHDOG_CONTEXT_KEY","permissions","ref","isLoading","error","fetchPermissions","response","data","err","hasPermission","permission","hasAnyPermission","permissionList","hasAllPermissions","computed"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/server.ts"],"sourcesContent":["export * from './server'\n"],"mappings":"+WAAA,IAAAA,EAAA,kBAAAC,EAAAD","names":["server_exports","__toCommonJS"]}
1
+ {"version":3,"sources":["../src/server.ts"],"sourcesContent":["export * from \"./server\";\n"],"mappings":"+WAAA,IAAAA,EAAA,kBAAAC,EAAAD","names":["server_exports","__toCommonJS"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@authdog/vue",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "Authdog Vue SDK",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/index.js",