voidai-sdk 0.1.0 → 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.
@@ -1 +1,5 @@
1
1
  /*! Axios v1.13.2 Copyright (c) 2025 Matt Zabriskie and contributors */
2
+
3
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
4
+
5
+ /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "voidai-sdk",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "TypeScript SDK for VoidAI Bridge - Blockchain wallet authentication and API integration",
5
5
  "main": "dist/index.js",
6
6
  "browser": "dist-browser/voidai-sdk.js",
@@ -50,6 +50,7 @@
50
50
  "dependencies": {
51
51
  "axios": "^1.6.7",
52
52
  "cors": "^2.8.5",
53
+ "viem": "^2.45.0",
53
54
  "zod": "^3.22.4"
54
55
  }
55
- }
56
+ }
@@ -1,50 +0,0 @@
1
- import { VoidAIBridgeClient } from '../api/client';
2
- import { SignInResponse, RefreshTokenResponse } from '../types';
3
- export declare class AuthSession {
4
- private apiClient;
5
- private accessToken;
6
- private refreshToken;
7
- private accessTokenWs;
8
- private adminStatus;
9
- constructor(apiClient: VoidAIBridgeClient);
10
- /**
11
- * Get nonce (signature) for wallet authentication
12
- * @param wallet - Public key wallet address
13
- */
14
- getNonce(wallet: string): Promise<string>;
15
- /**
16
- * Sign in with wallet
17
- * @param publicKey - Wallet public key
18
- * @param signature - Signed nonce
19
- * @param chainId - Blockchain chain ID
20
- */
21
- signIn(publicKey: string, signature: string, chainId: string): Promise<SignInResponse>;
22
- /**
23
- * Refresh access token using refresh token
24
- */
25
- refreshAccessToken(): Promise<RefreshTokenResponse>;
26
- /**
27
- * Get current access token
28
- */
29
- getAccessToken(): string | null;
30
- /**
31
- * Get current refresh token
32
- */
33
- getRefreshToken(): string | null;
34
- /**
35
- * Get WebSocket access token
36
- */
37
- getAccessTokenWs(): string | null;
38
- /**
39
- * Check if user is admin
40
- */
41
- isAdmin(): boolean;
42
- /**
43
- * Check if user is authenticated
44
- */
45
- isAuthenticated(): boolean;
46
- /**
47
- * Logout and clear session
48
- */
49
- logout(): Promise<void>;
50
- }
@@ -1,110 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AuthSession = void 0;
4
- class AuthSession {
5
- constructor(apiClient) {
6
- this.accessToken = null;
7
- this.refreshToken = null;
8
- this.accessTokenWs = null;
9
- this.adminStatus = false;
10
- this.apiClient = apiClient;
11
- }
12
- /**
13
- * Get nonce (signature) for wallet authentication
14
- * @param wallet - Public key wallet address
15
- */
16
- async getNonce(wallet) {
17
- const response = await this.apiClient.post('/api/wallet/get-nonce', {
18
- wallet,
19
- });
20
- return response.nonce;
21
- }
22
- /**
23
- * Sign in with wallet
24
- * @param publicKey - Wallet public key
25
- * @param signature - Signed nonce
26
- * @param chainId - Blockchain chain ID
27
- */
28
- async signIn(publicKey, signature, chainId) {
29
- const requestBody = {
30
- publicKey,
31
- signature,
32
- chainId,
33
- };
34
- const response = await this.apiClient.post('/api/wallet/signin/wallet', requestBody);
35
- // Store session data
36
- this.accessToken = response.accessToken;
37
- this.refreshToken = response.refreshToken;
38
- this.accessTokenWs = response.accessTokenWs;
39
- this.adminStatus = response.isAdmin;
40
- // Update client with access token for future requests
41
- this.apiClient.setAccessToken(response.accessToken);
42
- return response;
43
- }
44
- /**
45
- * Refresh access token using refresh token
46
- */
47
- async refreshAccessToken() {
48
- if (!this.refreshToken) {
49
- throw new Error('VoidAI SDK: No refresh token available');
50
- }
51
- // Temporarily set refresh token as authorization
52
- const previousToken = this.apiClient.getAccessToken();
53
- this.apiClient.setAccessToken(this.refreshToken);
54
- try {
55
- const response = await this.apiClient.post('/api/wallet/refresh-token');
56
- // Update stored tokens
57
- this.accessToken = response.accessToken;
58
- this.refreshToken = response.refreshToken;
59
- // Update client with new access token
60
- this.apiClient.setAccessToken(response.accessToken);
61
- return response;
62
- }
63
- catch (error) {
64
- // Restore previous token on error
65
- this.apiClient.setAccessToken(previousToken);
66
- throw error;
67
- }
68
- }
69
- /**
70
- * Get current access token
71
- */
72
- getAccessToken() {
73
- return this.accessToken;
74
- }
75
- /**
76
- * Get current refresh token
77
- */
78
- getRefreshToken() {
79
- return this.refreshToken;
80
- }
81
- /**
82
- * Get WebSocket access token
83
- */
84
- getAccessTokenWs() {
85
- return this.accessTokenWs;
86
- }
87
- /**
88
- * Check if user is admin
89
- */
90
- isAdmin() {
91
- return this.adminStatus;
92
- }
93
- /**
94
- * Check if user is authenticated
95
- */
96
- isAuthenticated() {
97
- return !!this.accessToken;
98
- }
99
- /**
100
- * Logout and clear session
101
- */
102
- async logout() {
103
- this.accessToken = null;
104
- this.refreshToken = null;
105
- this.accessTokenWs = null;
106
- this.adminStatus = false;
107
- this.apiClient.setAccessToken(null);
108
- }
109
- }
110
- exports.AuthSession = AuthSession;