@taruvi/sdk 1.4.8 → 1.5.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.
|
@@ -4,6 +4,9 @@ on:
|
|
|
4
4
|
push:
|
|
5
5
|
branches: [main, beta]
|
|
6
6
|
|
|
7
|
+
permissions:
|
|
8
|
+
contents: write
|
|
9
|
+
|
|
7
10
|
jobs:
|
|
8
11
|
publish:
|
|
9
12
|
runs-on: ubuntu-latest
|
|
@@ -48,8 +51,8 @@ jobs:
|
|
|
48
51
|
git tag "v${{ steps.version_check.outputs.current_version }}"
|
|
49
52
|
git push origin "v${{ steps.version_check.outputs.current_version }}"
|
|
50
53
|
|
|
51
|
-
- name: Publish
|
|
54
|
+
- name: Publish
|
|
52
55
|
if: steps.version_check.outputs.changed == 'true'
|
|
53
|
-
run: npm publish --access public
|
|
56
|
+
run: npm publish --access public
|
|
54
57
|
env:
|
|
55
58
|
NODE_AUTH_TOKEN: ${{ env.NPM_TOKEN }}
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Client } from "../../client.js";
|
|
2
2
|
import type { TaruviResponse } from "../../types.js";
|
|
3
3
|
import type { UserData } from "../users/types.js";
|
|
4
|
+
import { AuthRoutes } from "../../lib-internal/routes/AuthRoutes.js";
|
|
4
5
|
import { UserRoutes } from "../../lib-internal/routes/UserRoutes.js";
|
|
5
6
|
|
|
6
7
|
/**
|
|
@@ -94,12 +95,33 @@ export class Auth {
|
|
|
94
95
|
}
|
|
95
96
|
|
|
96
97
|
/**
|
|
97
|
-
* Check if
|
|
98
|
+
* Check if a session token exists locally (does not validate with server)
|
|
98
99
|
*/
|
|
99
|
-
|
|
100
|
+
hasToken(): boolean {
|
|
100
101
|
return this.client.tokenClient.isAuthenticated()
|
|
101
102
|
}
|
|
102
103
|
|
|
104
|
+
/**
|
|
105
|
+
* Check if user is authenticated by validating session with the server
|
|
106
|
+
*/
|
|
107
|
+
async isUserAuthenticated(): Promise<boolean> {
|
|
108
|
+
if (!this.hasToken()) return false
|
|
109
|
+
try {
|
|
110
|
+
await this.validateSession()
|
|
111
|
+
return true
|
|
112
|
+
} catch {
|
|
113
|
+
return false
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Validate current session token with auth session endpoint.
|
|
119
|
+
* HttpClient injects X-Session-Token automatically.
|
|
120
|
+
*/
|
|
121
|
+
async validateSession(): Promise<void> {
|
|
122
|
+
await this.client.httpClient.get(AuthRoutes.session())
|
|
123
|
+
}
|
|
124
|
+
|
|
103
125
|
/**
|
|
104
126
|
* Get the current session token
|
|
105
127
|
*/
|
|
@@ -112,7 +134,7 @@ export class Auth {
|
|
|
112
134
|
* @returns Promise with user data or null if not authenticated
|
|
113
135
|
*/
|
|
114
136
|
async getCurrentUser(): Promise<TaruviResponse<UserData> | null> {
|
|
115
|
-
if (!this.
|
|
137
|
+
if (!this.hasToken()) {
|
|
116
138
|
return null
|
|
117
139
|
}
|
|
118
140
|
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"permissions": {
|
|
3
|
-
"allow": [
|
|
4
|
-
"Bash(tree:*)",
|
|
5
|
-
"Bash(npm run build:*)",
|
|
6
|
-
"Bash(npm ls:*)",
|
|
7
|
-
"Bash(npm link:*)",
|
|
8
|
-
"Bash(npx --yes markdownlint-cli:*)",
|
|
9
|
-
"Bash(cat:*)",
|
|
10
|
-
"Bash(test:*)",
|
|
11
|
-
"Bash(ls:*)",
|
|
12
|
-
"WebFetch(domain:www.markdownpaste.com)",
|
|
13
|
-
"WebSearch",
|
|
14
|
-
"WebFetch(domain:supabase.com)"
|
|
15
|
-
],
|
|
16
|
-
"deny": [],
|
|
17
|
-
"ask": []
|
|
18
|
-
}
|
|
19
|
-
}
|