prividium 0.3.0 → 0.4.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.
package/README.md CHANGED
@@ -446,7 +446,7 @@ if (headers) {
446
446
 
447
447
  The SDK uses the following localStorage keys:
448
448
 
449
- - `prividium_jwt_<chainId>` - JWT token storage
449
+ - `prividium_token_<chainId>` - Token storage
450
450
  - `prividium_auth_state_<chainId>` - OAuth state parameter
451
451
 
452
452
  ## Security Considerations
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { UNAUTHORIZED_ERROR_CODE, FORBIDDEN_ERROR_CODE } from './rpc-error-codes.js';
2
+ import { UNAUTHORIZED_ERROR_CODE } from './rpc-error-codes.js';
3
3
  const jsonRpcErrorSchema = z.object({
4
4
  error: z.object({
5
5
  code: z.number(),
@@ -15,7 +15,7 @@ export async function hasPrividiumUnauthorizedError(response) {
15
15
  const parsed = jsonRpcErrorSchema.safeParse(await clonedResponse.json());
16
16
  // { success: false, error: {...} } | { success: true, data: {...} }
17
17
  if (parsed.success) {
18
- return [UNAUTHORIZED_ERROR_CODE, FORBIDDEN_ERROR_CODE].includes(parsed.data.error.code);
18
+ return parsed.data.error.code === UNAUTHORIZED_ERROR_CODE;
19
19
  }
20
20
  return false;
21
21
  }
@@ -67,6 +67,10 @@ export function createPrividiumChain(config) {
67
67
  headers: getAuthHeaders() || {}
68
68
  },
69
69
  onFetchRequest(_request, init) {
70
+ const isAuthenticated = tokenManager.isAuthorized();
71
+ if (!isAuthenticated) {
72
+ throw new PrividiumSessionError();
73
+ }
70
74
  init.headers = {
71
75
  ...init.headers,
72
76
  ...getAuthHeaders()
@@ -108,5 +108,5 @@ export declare const AUTH_ERRORS: {
108
108
  };
109
109
  export declare const STORAGE_KEYS: {
110
110
  readonly STATE_PREFIX: "prividium_auth_state_";
111
- readonly TOKEN_PREFIX: "prividium_jwt_";
111
+ readonly TOKEN_PREFIX: "prividium_token_";
112
112
  };
package/dist/sdk/types.js CHANGED
@@ -29,5 +29,5 @@ export const AUTH_ERRORS = {
29
29
  };
30
30
  export const STORAGE_KEYS = {
31
31
  STATE_PREFIX: 'prividium_auth_state_',
32
- TOKEN_PREFIX: 'prividium_jwt_'
32
+ TOKEN_PREFIX: 'prividium_token_'
33
33
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prividium",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "bin": {
5
5
  "prividium": "bin/cli.js"
6
6
  },
@@ -33,7 +33,7 @@
33
33
  "@fastify/static": "^8.3.0",
34
34
  "appdirsjs": "^1.2.7",
35
35
  "date-fns": "^4.1.0",
36
- "fastify": "^5.7.1",
36
+ "fastify": "^5.7.2",
37
37
  "fastify-type-provider-zod": "^6.1.0",
38
38
  "kleur": "^4.1.5",
39
39
  "open": "^10.1.0",