@drmhse/authos-vue 0.1.1 → 0.1.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/dist/index.d.mts CHANGED
@@ -19,6 +19,12 @@ interface AuthOSPluginOptions {
19
19
  baseUrl: string;
20
20
  storage?: TokenStorage;
21
21
  autoRefresh?: boolean;
22
+ /**
23
+ * Initial session token from server-side (for SSR hydration).
24
+ * When provided, skips the initial loading state on the client.
25
+ * Typically passed from cookies in Nuxt server components.
26
+ */
27
+ initialToken?: string;
22
28
  }
23
29
  declare const AUTH_OS_INJECTION_KEY: unique symbol;
24
30
 
package/dist/index.d.ts CHANGED
@@ -19,6 +19,12 @@ interface AuthOSPluginOptions {
19
19
  baseUrl: string;
20
20
  storage?: TokenStorage;
21
21
  autoRefresh?: boolean;
22
+ /**
23
+ * Initial session token from server-side (for SSR hydration).
24
+ * When provided, skips the initial loading state on the client.
25
+ * Typically passed from cookies in Nuxt server components.
26
+ */
27
+ initialToken?: string;
22
28
  }
23
29
  declare const AUTH_OS_INJECTION_KEY: unique symbol;
24
30
 
package/dist/index.js CHANGED
@@ -22,12 +22,22 @@ function createAuthOS(options) {
22
22
  };
23
23
  const client = new ssoSdk.SsoClient({
24
24
  baseURL: options.baseUrl,
25
- storage: getStorage()
25
+ storage: getStorage(),
26
+ token: options.initialToken
27
+ // Pass initial token if provided
26
28
  });
29
+ let hasSetInitialToken = false;
30
+ const setInitialToken = async () => {
31
+ if (options.initialToken && !hasSetInitialToken) {
32
+ await client.setSession({ access_token: options.initialToken });
33
+ hasSetInitialToken = true;
34
+ }
35
+ };
27
36
  const state = vue.reactive({
28
37
  user: null,
29
38
  isAuthenticated: false,
30
- isLoading: true,
39
+ isLoading: !options.initialToken,
40
+ // Skip loading if we have initial token
31
41
  currentOrganization: null,
32
42
  organizations: []
33
43
  });
@@ -37,6 +47,9 @@ function createAuthOS(options) {
37
47
  };
38
48
  return {
39
49
  install(app) {
50
+ vue.nextTick(() => {
51
+ setInitialToken();
52
+ });
40
53
  client.onAuthStateChange(async (isAuthenticated) => {
41
54
  state.isAuthenticated = isAuthenticated;
42
55
  state.isLoading = false;
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { AUTH_OS_INJECTION_KEY, useAuthOS } from './chunk-OGRUDANK.mjs';
2
2
  export { AUTH_OS_INJECTION_KEY, useAuthOS } from './chunk-OGRUDANK.mjs';
3
3
  import './chunk-6DZX6EAA.mjs';
4
- import { defineComponent, reactive, provide, onMounted, onUnmounted, h, ref, computed, inject } from 'vue';
4
+ import { defineComponent, reactive, provide, onMounted, onUnmounted, h, ref, computed, inject, nextTick } from 'vue';
5
5
  import { SsoClient, BrowserStorage, MemoryStorage, SsoApiError } from '@drmhse/sso-sdk';
6
6
  export { AuthErrorCodes, BrowserStorage, MemoryStorage, SsoApiError } from '@drmhse/sso-sdk';
7
7
 
@@ -18,12 +18,22 @@ function createAuthOS(options) {
18
18
  };
19
19
  const client = new SsoClient({
20
20
  baseURL: options.baseUrl,
21
- storage: getStorage()
21
+ storage: getStorage(),
22
+ token: options.initialToken
23
+ // Pass initial token if provided
22
24
  });
25
+ let hasSetInitialToken = false;
26
+ const setInitialToken = async () => {
27
+ if (options.initialToken && !hasSetInitialToken) {
28
+ await client.setSession({ access_token: options.initialToken });
29
+ hasSetInitialToken = true;
30
+ }
31
+ };
23
32
  const state = reactive({
24
33
  user: null,
25
34
  isAuthenticated: false,
26
- isLoading: true,
35
+ isLoading: !options.initialToken,
36
+ // Skip loading if we have initial token
27
37
  currentOrganization: null,
28
38
  organizations: []
29
39
  });
@@ -33,6 +43,9 @@ function createAuthOS(options) {
33
43
  };
34
44
  return {
35
45
  install(app) {
46
+ nextTick(() => {
47
+ setInitialToken();
48
+ });
36
49
  client.onAuthStateChange(async (isAuthenticated) => {
37
50
  state.isAuthenticated = isAuthenticated;
38
51
  state.isLoading = false;
package/dist/nuxt.d.mts CHANGED
@@ -3,6 +3,26 @@ import * as nuxt_app from 'nuxt/app';
3
3
 
4
4
  interface AuthOSModuleOptions {
5
5
  baseUrl: string;
6
+ /**
7
+ * Cookie name for storing the access token
8
+ * @default 'authos_token'
9
+ */
10
+ tokenCookie?: string;
11
+ /**
12
+ * Cookie domain (optional)
13
+ * Use this for subdomain-wide auth
14
+ */
15
+ domain?: string;
16
+ /**
17
+ * Cookie path
18
+ * @default '/'
19
+ */
20
+ path?: string;
21
+ /**
22
+ * SameSite cookie attribute
23
+ * @default 'lax'
24
+ */
25
+ sameSite?: 'strict' | 'lax' | 'none';
6
26
  }
7
27
  declare const _default: _nuxt_schema.NuxtModule<AuthOSModuleOptions, AuthOSModuleOptions, false>;
8
28
 
package/dist/nuxt.d.ts CHANGED
@@ -3,6 +3,26 @@ import * as nuxt_app from 'nuxt/app';
3
3
 
4
4
  interface AuthOSModuleOptions {
5
5
  baseUrl: string;
6
+ /**
7
+ * Cookie name for storing the access token
8
+ * @default 'authos_token'
9
+ */
10
+ tokenCookie?: string;
11
+ /**
12
+ * Cookie domain (optional)
13
+ * Use this for subdomain-wide auth
14
+ */
15
+ domain?: string;
16
+ /**
17
+ * Cookie path
18
+ * @default '/'
19
+ */
20
+ path?: string;
21
+ /**
22
+ * SameSite cookie attribute
23
+ * @default 'lax'
24
+ */
25
+ sameSite?: 'strict' | 'lax' | 'none';
6
26
  }
7
27
  declare const _default: _nuxt_schema.NuxtModule<AuthOSModuleOptions, AuthOSModuleOptions, false>;
8
28
 
package/dist/nuxt.js CHANGED
@@ -10464,12 +10464,19 @@ var module_default = defineNuxtModule({
10464
10464
  }
10465
10465
  },
10466
10466
  defaults: {
10467
- baseUrl: ""
10467
+ baseUrl: "",
10468
+ tokenCookie: "authos_token",
10469
+ path: "/",
10470
+ sameSite: "lax"
10468
10471
  },
10469
10472
  setup(options, nuxt) {
10470
10473
  const resolver = createResolver((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('nuxt.js', document.baseURI).href)));
10471
10474
  nuxt.options.runtimeConfig.public.authOS = {
10472
- baseUrl: options.baseUrl
10475
+ baseUrl: options.baseUrl,
10476
+ tokenCookie: options.tokenCookie,
10477
+ domain: options.domain,
10478
+ path: options.path,
10479
+ sameSite: options.sameSite
10473
10480
  };
10474
10481
  addPlugin(resolver.resolve("./runtime/plugin"));
10475
10482
  addImports([
package/dist/nuxt.mjs CHANGED
@@ -7953,12 +7953,19 @@ var module_default = defineNuxtModule({
7953
7953
  }
7954
7954
  },
7955
7955
  defaults: {
7956
- baseUrl: ""
7956
+ baseUrl: "",
7957
+ tokenCookie: "authos_token",
7958
+ path: "/",
7959
+ sameSite: "lax"
7957
7960
  },
7958
7961
  setup(options, nuxt) {
7959
7962
  const resolver = createResolver(import.meta.url);
7960
7963
  nuxt.options.runtimeConfig.public.authOS = {
7961
- baseUrl: options.baseUrl
7964
+ baseUrl: options.baseUrl,
7965
+ tokenCookie: options.tokenCookie,
7966
+ domain: options.domain,
7967
+ path: options.path,
7968
+ sameSite: options.sameSite
7962
7969
  };
7963
7970
  addPlugin(resolver.resolve("./runtime/plugin"));
7964
7971
  addImports([
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drmhse/authos-vue",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Vue and Nuxt adapter for AuthOS authentication",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",