@nuria-tech/auth-sdk 1.0.2 → 1.0.4

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/vue.d.cts ADDED
@@ -0,0 +1,13 @@
1
+ import { Ref } from 'vue';
2
+ import { e as Session, a as AuthClient } from './types-2k4ZYpF4.cjs';
3
+
4
+ interface UseVueAuthSessionResult {
5
+ session: Ref<Session | null>;
6
+ isAuthenticated: Readonly<Ref<boolean>>;
7
+ isLoading: Ref<boolean>;
8
+ error: Ref<unknown>;
9
+ refresh: () => Promise<Session | null>;
10
+ }
11
+ declare function useAuthSession(auth: AuthClient): UseVueAuthSessionResult;
12
+
13
+ export { type UseVueAuthSessionResult, useAuthSession };
package/dist/vue.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ import { Ref } from 'vue';
2
+ import { e as Session, a as AuthClient } from './types-2k4ZYpF4.js';
3
+
4
+ interface UseVueAuthSessionResult {
5
+ session: Ref<Session | null>;
6
+ isAuthenticated: Readonly<Ref<boolean>>;
7
+ isLoading: Ref<boolean>;
8
+ error: Ref<unknown>;
9
+ refresh: () => Promise<Session | null>;
10
+ }
11
+ declare function useAuthSession(auth: AuthClient): UseVueAuthSessionResult;
12
+
13
+ export { type UseVueAuthSessionResult, useAuthSession };
package/dist/vue.js ADDED
@@ -0,0 +1,55 @@
1
+ import { ref, onMounted, onUnmounted, computed } from 'vue';
2
+
3
+ // src/vue/use-auth-session.ts
4
+ function useAuthSession(auth) {
5
+ const session = ref(auth.getSession());
6
+ const isLoading = ref(session.value === null);
7
+ const error = ref(null);
8
+ let unsubscribe = null;
9
+ const hydrate = async () => {
10
+ try {
11
+ await auth.getAccessToken();
12
+ session.value = auth.getSession();
13
+ } catch (err) {
14
+ error.value = err;
15
+ } finally {
16
+ isLoading.value = false;
17
+ }
18
+ };
19
+ onMounted(() => {
20
+ unsubscribe = auth.onAuthStateChanged((nextSession) => {
21
+ session.value = nextSession;
22
+ isLoading.value = false;
23
+ });
24
+ void hydrate();
25
+ });
26
+ onUnmounted(() => {
27
+ unsubscribe == null ? void 0 : unsubscribe();
28
+ unsubscribe = null;
29
+ });
30
+ const refresh = async () => {
31
+ try {
32
+ await auth.getAccessToken();
33
+ const nextSession = auth.getSession();
34
+ session.value = nextSession;
35
+ error.value = null;
36
+ return nextSession;
37
+ } catch (err) {
38
+ error.value = err;
39
+ return null;
40
+ } finally {
41
+ isLoading.value = false;
42
+ }
43
+ };
44
+ return {
45
+ session,
46
+ isAuthenticated: computed(() => session.value !== null),
47
+ isLoading,
48
+ error,
49
+ refresh
50
+ };
51
+ }
52
+
53
+ export { useAuthSession };
54
+ //# sourceMappingURL=vue.js.map
55
+ //# sourceMappingURL=vue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/vue/use-auth-session.ts"],"names":[],"mappings":";;;AAWO,SAAS,eAAe,IAAA,EAA2C;AACxE,EAAA,MAAM,OAAA,GAAU,GAAA,CAAoB,IAAA,CAAK,UAAA,EAAY,CAAA;AACrD,EAAA,MAAM,SAAA,GAAY,GAAA,CAAa,OAAA,CAAQ,KAAA,KAAU,IAAI,CAAA;AACrD,EAAA,MAAM,KAAA,GAAQ,IAAa,IAAI,CAAA;AAC/B,EAAA,IAAI,WAAA,GAAmC,IAAA;AAEvC,EAAA,MAAM,UAAU,YAAY;AAC1B,IAAA,IAAI;AACF,MAAA,MAAM,KAAK,cAAA,EAAe;AAC1B,MAAA,OAAA,CAAQ,KAAA,GAAQ,KAAK,UAAA,EAAW;AAAA,IAClC,SAAS,GAAA,EAAK;AACZ,MAAA,KAAA,CAAM,KAAA,GAAQ,GAAA;AAAA,IAChB,CAAA,SAAE;AACA,MAAA,SAAA,CAAU,KAAA,GAAQ,KAAA;AAAA,IACpB;AAAA,EACF,CAAA;AAEA,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,WAAA,GAAc,IAAA,CAAK,kBAAA,CAAmB,CAAC,WAAA,KAAgB;AACrD,MAAA,OAAA,CAAQ,KAAA,GAAQ,WAAA;AAChB,MAAA,SAAA,CAAU,KAAA,GAAQ,KAAA;AAAA,IACpB,CAAC,CAAA;AACD,IAAA,KAAK,OAAA,EAAQ;AAAA,EACf,CAAC,CAAA;AAED,EAAA,WAAA,CAAY,MAAM;AAChB,IAAA,WAAA,IAAA,IAAA,GAAA,MAAA,GAAA,WAAA,EAAA;AACA,IAAA,WAAA,GAAc,IAAA;AAAA,EAChB,CAAC,CAAA;AAED,EAAA,MAAM,UAAU,YAAY;AAC1B,IAAA,IAAI;AACF,MAAA,MAAM,KAAK,cAAA,EAAe;AAC1B,MAAA,MAAM,WAAA,GAAc,KAAK,UAAA,EAAW;AACpC,MAAA,OAAA,CAAQ,KAAA,GAAQ,WAAA;AAChB,MAAA,KAAA,CAAM,KAAA,GAAQ,IAAA;AACd,MAAA,OAAO,WAAA;AAAA,IACT,SAAS,GAAA,EAAK;AACZ,MAAA,KAAA,CAAM,KAAA,GAAQ,GAAA;AACd,MAAA,OAAO,IAAA;AAAA,IACT,CAAA,SAAE;AACA,MAAA,SAAA,CAAU,KAAA,GAAQ,KAAA;AAAA,IACpB;AAAA,EACF,CAAA;AAEA,EAAA,OAAO;AAAA,IACL,OAAA;AAAA,IACA,eAAA,EAAiB,QAAA,CAAS,MAAM,OAAA,CAAQ,UAAU,IAAI,CAAA;AAAA,IACtD,SAAA;AAAA,IACA,KAAA;AAAA,IACA;AAAA,GACF;AACF","file":"vue.js","sourcesContent":["import { computed, onMounted, onUnmounted, ref, type Ref } from 'vue';\nimport type { AuthClient, Session } from '../core/types';\n\nexport interface UseVueAuthSessionResult {\n session: Ref<Session | null>;\n isAuthenticated: Readonly<Ref<boolean>>;\n isLoading: Ref<boolean>;\n error: Ref<unknown>;\n refresh: () => Promise<Session | null>;\n}\n\nexport function useAuthSession(auth: AuthClient): UseVueAuthSessionResult {\n const session = ref<Session | null>(auth.getSession());\n const isLoading = ref<boolean>(session.value === null);\n const error = ref<unknown>(null);\n let unsubscribe: (() => void) | null = null;\n\n const hydrate = async () => {\n try {\n await auth.getAccessToken();\n session.value = auth.getSession();\n } catch (err) {\n error.value = err;\n } finally {\n isLoading.value = false;\n }\n };\n\n onMounted(() => {\n unsubscribe = auth.onAuthStateChanged((nextSession) => {\n session.value = nextSession;\n isLoading.value = false;\n });\n void hydrate();\n });\n\n onUnmounted(() => {\n unsubscribe?.();\n unsubscribe = null;\n });\n\n const refresh = async () => {\n try {\n await auth.getAccessToken();\n const nextSession = auth.getSession();\n session.value = nextSession;\n error.value = null;\n return nextSession;\n } catch (err) {\n error.value = err;\n return null;\n } finally {\n isLoading.value = false;\n }\n };\n\n return {\n session,\n isAuthenticated: computed(() => session.value !== null),\n isLoading,\n error,\n refresh,\n };\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuria-tech/auth-sdk",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Browser OAuth 2.0 Authorization Code + PKCE client SDK — redirect-only, no password flows",
5
5
  "license": "MIT",
6
6
  "author": "Nuria Tech",
@@ -29,6 +29,31 @@
29
29
  "import": "./dist/index.js",
30
30
  "require": "./dist/index.cjs"
31
31
  },
32
+ "./react": {
33
+ "types": "./dist/react.d.ts",
34
+ "import": "./dist/react.js",
35
+ "require": "./dist/react.cjs"
36
+ },
37
+ "./vue": {
38
+ "types": "./dist/vue.d.ts",
39
+ "import": "./dist/vue.js",
40
+ "require": "./dist/vue.cjs"
41
+ },
42
+ "./nuxt": {
43
+ "types": "./dist/nuxt.d.ts",
44
+ "import": "./dist/nuxt.js",
45
+ "require": "./dist/nuxt.cjs"
46
+ },
47
+ "./next": {
48
+ "types": "./dist/next.d.ts",
49
+ "import": "./dist/next.js",
50
+ "require": "./dist/next.cjs"
51
+ },
52
+ "./angular": {
53
+ "types": "./dist/angular.d.ts",
54
+ "import": "./dist/angular.js",
55
+ "require": "./dist/angular.cjs"
56
+ },
32
57
  "./package.json": "./package.json"
33
58
  },
34
59
  "files": [
@@ -45,17 +70,41 @@
45
70
  "format": "prettier --write src/**/*.ts",
46
71
  "typecheck": "tsc --noEmit"
47
72
  },
73
+ "peerDependencies": {
74
+ "react": ">=18",
75
+ "rxjs": ">=7.8",
76
+ "vue": ">=3.3"
77
+ },
78
+ "peerDependenciesMeta": {
79
+ "react": {
80
+ "optional": true
81
+ },
82
+ "rxjs": {
83
+ "optional": true
84
+ },
85
+ "vue": {
86
+ "optional": true
87
+ }
88
+ },
48
89
  "devDependencies": {
90
+ "@testing-library/react": "16.3.0",
49
91
  "@typescript-eslint/eslint-plugin": "8.56.1",
50
92
  "@typescript-eslint/parser": "8.56.1",
93
+ "@types/react": "19.2.2",
94
+ "@types/react-dom": "19.2.2",
95
+ "@types/node": "24.3.2",
51
96
  "@vitest/coverage-v8": "4.0.18",
52
97
  "eslint": "10.0.2",
53
98
  "eslint-config-prettier": "10.1.8",
54
99
  "eslint-plugin-prettier": "5.5.5",
55
100
  "happy-dom": "20.7.0",
56
101
  "prettier": "3.8.1",
102
+ "react": "19.2.0",
103
+ "react-dom": "19.2.0",
104
+ "rxjs": "7.8.2",
57
105
  "tsup": "8.5.1",
58
106
  "typescript": "5.9.3",
59
- "vitest": "4.0.18"
107
+ "vitest": "4.0.18",
108
+ "vue": "3.5.22"
60
109
  }
61
110
  }