prividium 0.20.0 → 0.21.1

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.
Files changed (104) hide show
  1. package/bin/cli.js +8 -1
  2. package/dist/cli/base-cli.d.ts +5 -0
  3. package/dist/cli/base-cli.js +11 -0
  4. package/dist/cli/commands/config.d.ts +2 -0
  5. package/dist/cli/commands/doctor/clients/browser-auth.d.ts +1 -0
  6. package/dist/cli/commands/doctor/clients/http.d.ts +3 -0
  7. package/dist/cli/commands/doctor/clients/rpc.d.ts +19 -0
  8. package/dist/cli/commands/doctor/clients/wallet-api.d.ts +7 -0
  9. package/dist/cli/commands/doctor/constants.d.ts +1 -0
  10. package/dist/cli/commands/doctor/probes/authentication/authentication.d.ts +4 -0
  11. package/dist/cli/commands/doctor/probes/authentication/wallet-preconditions.d.ts +2 -0
  12. package/dist/cli/commands/doctor/probes/authentication.d.ts +2 -0
  13. package/dist/cli/commands/doctor/probes/bridging/bridging.d.ts +5 -0
  14. package/dist/cli/commands/doctor/probes/bridging.d.ts +2 -0
  15. package/dist/cli/commands/doctor/probes/global/input-validation.d.ts +3 -0
  16. package/dist/cli/commands/doctor/probes/global/reachability.d.ts +5 -0
  17. package/dist/cli/commands/doctor/probes/global.d.ts +2 -0
  18. package/dist/cli/commands/doctor/probes/wallet/authenticated-rpc.d.ts +3 -0
  19. package/dist/cli/commands/doctor/probes/wallet/authorization-and-wallet-rpc.d.ts +5 -0
  20. package/dist/cli/commands/doctor/probes/wallet-api.d.ts +2 -0
  21. package/dist/cli/commands/doctor/probes/wallet.d.ts +2 -0
  22. package/dist/cli/commands/doctor/profile.d.ts +12 -0
  23. package/dist/cli/commands/doctor/report/build.d.ts +2 -0
  24. package/dist/cli/commands/doctor/report/render.d.ts +2 -0
  25. package/dist/cli/commands/doctor/stages.d.ts +2 -0
  26. package/dist/cli/commands/doctor/types.d.ts +90 -0
  27. package/dist/cli/commands/doctor/utils.d.ts +18 -0
  28. package/dist/cli/commands/doctor.d.ts +2 -0
  29. package/dist/cli/commands/proxy.d.ts +2 -0
  30. package/dist/cli/{cli/commands → commands}/proxy.js +1 -3
  31. package/dist/cli/commands/utils/schemas.d.ts +3 -0
  32. package/dist/cli/commands/utils/schemas.js +3 -0
  33. package/dist/cli/commands/utils/show-prividium-header.d.ts +2 -0
  34. package/dist/cli/commands/utils/url-config.d.ts +18 -0
  35. package/dist/cli/commands/verify/account-data-cmd.d.ts +14 -0
  36. package/dist/cli/commands/verify/account-data-cmd.js +102 -0
  37. package/dist/cli/commands/verify/erc20-balance-cmd.d.ts +17 -0
  38. package/dist/cli/commands/verify/erc20-balance-cmd.js +111 -0
  39. package/dist/cli/commands/verify/erc20-supply-cmd.d.ts +16 -0
  40. package/dist/cli/commands/verify/erc20-supply-cmd.js +102 -0
  41. package/dist/cli/commands/verify/utils.d.ts +5 -0
  42. package/dist/cli/commands/verify/utils.js +38 -0
  43. package/dist/cli/commands/verify/verify-workflow.d.ts +8 -0
  44. package/dist/cli/commands/verify/verify-workflow.js +41 -0
  45. package/dist/cli/commands/verify.d.ts +18 -0
  46. package/dist/cli/commands/verify.js +43 -0
  47. package/dist/cli/index.d.ts +3 -0
  48. package/dist/cli/index.js +11 -0
  49. package/dist/cli/server/config-file.d.ts +62 -0
  50. package/dist/cli/server/config-file.js +167 -0
  51. package/dist/cli/server/connection-workflow.d.ts +12 -0
  52. package/dist/cli/server/server.d.ts +28 -0
  53. package/dist/sdk/create-prividium-client.d.ts +1 -1
  54. package/dist/sdk/create-prividium-client.js +1 -1
  55. package/dist/sdk/selective-disclosure/account-properties.d.ts +7 -1
  56. package/dist/sdk/selective-disclosure/account-properties.js +22 -10
  57. package/dist/sdk/selective-disclosure/utils.d.ts +2 -0
  58. package/dist/sdk/selective-disclosure/utils.js +3 -0
  59. package/dist/sdk/selective-disclosure/verify-disclosure.d.ts +35 -12
  60. package/dist/sdk/selective-disclosure/verify-disclosure.js +60 -25
  61. package/dist/tsconfig.cli.tsbuildinfo +1 -0
  62. package/dist/tsconfig.sdk.tsbuildinfo +1 -1
  63. package/package.json +12 -2
  64. package/dist/cli/cli/base-cli.js +0 -9
  65. package/dist/cli/cli/index.js +0 -13
  66. package/dist/cli/cli/server/config-file.js +0 -78
  67. package/dist/cli/src/error-utils.js +0 -73
  68. package/dist/cli/src/memory-storage.js +0 -12
  69. package/dist/cli/src/rpc-error-codes.js +0 -28
  70. package/dist/cli/src/siwe-auth.js +0 -70
  71. package/dist/cli/src/storage.js +0 -142
  72. package/dist/cli/src/types.js +0 -46
  73. package/dist/cli/tsconfig.cli.tsbuildinfo +0 -1
  74. /package/dist/cli/cli/{static/callback.html → callback.html} +0 -0
  75. /package/dist/cli/cli/{static/start.html → start.html} +0 -0
  76. /package/dist/cli/{cli/commands → commands}/config.js +0 -0
  77. /package/dist/cli/{cli/commands → commands}/doctor/clients/browser-auth.js +0 -0
  78. /package/dist/cli/{cli/commands → commands}/doctor/clients/http.js +0 -0
  79. /package/dist/cli/{cli/commands → commands}/doctor/clients/rpc.js +0 -0
  80. /package/dist/cli/{cli/commands → commands}/doctor/clients/wallet-api.js +0 -0
  81. /package/dist/cli/{cli/commands → commands}/doctor/constants.js +0 -0
  82. /package/dist/cli/{cli/commands → commands}/doctor/probes/authentication/authentication.js +0 -0
  83. /package/dist/cli/{cli/commands → commands}/doctor/probes/authentication/wallet-preconditions.js +0 -0
  84. /package/dist/cli/{cli/commands → commands}/doctor/probes/authentication.js +0 -0
  85. /package/dist/cli/{cli/commands → commands}/doctor/probes/bridging/bridging.js +0 -0
  86. /package/dist/cli/{cli/commands → commands}/doctor/probes/bridging.js +0 -0
  87. /package/dist/cli/{cli/commands → commands}/doctor/probes/global/input-validation.js +0 -0
  88. /package/dist/cli/{cli/commands → commands}/doctor/probes/global/reachability.js +0 -0
  89. /package/dist/cli/{cli/commands → commands}/doctor/probes/global.js +0 -0
  90. /package/dist/cli/{cli/commands → commands}/doctor/probes/wallet/authenticated-rpc.js +0 -0
  91. /package/dist/cli/{cli/commands → commands}/doctor/probes/wallet/authorization-and-wallet-rpc.js +0 -0
  92. /package/dist/cli/{cli/commands → commands}/doctor/probes/wallet-api.js +0 -0
  93. /package/dist/cli/{cli/commands → commands}/doctor/probes/wallet.js +0 -0
  94. /package/dist/cli/{cli/commands → commands}/doctor/profile.js +0 -0
  95. /package/dist/cli/{cli/commands → commands}/doctor/report/build.js +0 -0
  96. /package/dist/cli/{cli/commands → commands}/doctor/report/render.js +0 -0
  97. /package/dist/cli/{cli/commands → commands}/doctor/stages.js +0 -0
  98. /package/dist/cli/{cli/commands → commands}/doctor/types.js +0 -0
  99. /package/dist/cli/{cli/commands → commands}/doctor/utils.js +0 -0
  100. /package/dist/cli/{cli/commands → commands}/doctor.js +0 -0
  101. /package/dist/cli/{cli/commands → commands}/utils/show-prividium-header.js +0 -0
  102. /package/dist/cli/{cli/commands → commands}/utils/url-config.js +0 -0
  103. /package/dist/cli/{cli/server → server}/connection-workflow.js +0 -0
  104. /package/dist/cli/{cli/server → server}/server.js +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prividium",
3
- "version": "0.20.0",
3
+ "version": "0.21.1",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "prividium": "bin/cli.js"
@@ -15,6 +15,16 @@
15
15
  "types": "./dist/sdk/siwe.d.ts"
16
16
  }
17
17
  },
18
+ "imports": {
19
+ "#sdk": {
20
+ "import": "./dist/sdk/index.js",
21
+ "types": "./dist/sdk/index.d.ts"
22
+ },
23
+ "#sdk/siwe": {
24
+ "import": "./dist/sdk/siwe.js",
25
+ "types": "./dist/sdk/siwe.d.ts"
26
+ }
27
+ },
18
28
  "license": "MIT OR Apache-2.0",
19
29
  "files": [
20
30
  "dist",
@@ -29,7 +39,7 @@
29
39
  "test": "vitest run",
30
40
  "test:watch": "vitest",
31
41
  "typecheck": "tsc -b --noEmit",
32
- "cli": "tsx cli/index.ts",
42
+ "cli": "tsc -b tsconfig.sdk.json && tsx bin/cli.js",
33
43
  "typecheck:test": "tsc --project tsconfig.test.json --noEmit"
34
44
  },
35
45
  "dependencies": {
@@ -1,9 +0,0 @@
1
- import yargs from 'yargs';
2
- export const BASE_CLI = yargs(process.argv.slice(2))
3
- .scriptName('prividium-cli')
4
- .option('configPath', {
5
- alias: ['c', 'config-path', 'config'],
6
- description: 'Path for config file. By default config file is stored under user personal folder',
7
- type: 'string',
8
- demandOption: false
9
- });
@@ -1,13 +0,0 @@
1
- import { BASE_CLI } from './base-cli.js';
2
- import { addConfig } from './commands/config.js';
3
- import { addDoctor } from './commands/doctor.js';
4
- import { addProxy } from './commands/proxy.js';
5
- const actions = [addProxy, addDoctor, addConfig];
6
- const baseCli = actions.reduce((argv, applyAction) => {
7
- return applyAction(argv);
8
- }, BASE_CLI);
9
- const cli = baseCli.help().strict().demandCommand();
10
- cli.parseAsync().catch((e) => {
11
- console.error(e);
12
- process.exit(1);
13
- });
@@ -1,78 +0,0 @@
1
- import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
2
- import path from 'node:path';
3
- import { log } from '@clack/prompts';
4
- import appDirs from 'appdirsjs';
5
- import color from 'kleur';
6
- import { z } from 'zod';
7
- // biome-ignore lint/suspicious/noExplicitAny: CJS/ESM interop
8
- const appDirsFn = appDirs.default;
9
- const dirs = appDirsFn({ appName: 'prividium-proxy' });
10
- // Source of truth for the on-disk config-file shapes the SDK accepts.
11
- // `latest` is what `write()` produces today.
12
- // Any other entry is keyed by the last SDK version that wrote that shape;
13
- // it exists only so older config files keep working after a user upgrades.
14
- // To add a new legacy entry: copy the previous `latest` into a new `vX_Y`
15
- // key, then change `latest` to the new shape and add a branch in `migrate()`.
16
- const schemas = {
17
- latest: z.object({
18
- apiUrl: z.string()
19
- }),
20
- v0_17: z.object({
21
- prividiumRpcUrl: z.string(),
22
- userPanelUrl: z.string()
23
- })
24
- };
25
- function migrate(json) {
26
- const latest = schemas.latest.safeParse(json);
27
- if (latest.success)
28
- return latest.data;
29
- const v0_17 = schemas.v0_17.safeParse(json);
30
- if (v0_17.success)
31
- return { apiUrl: v0_17.data.prividiumRpcUrl };
32
- return null;
33
- }
34
- export class ConfigFile {
35
- filePath;
36
- constructor(filePath) {
37
- if (filePath) {
38
- this.filePath = filePath;
39
- }
40
- else {
41
- this.filePath = path.join(dirs.config, 'config.json');
42
- }
43
- }
44
- read() {
45
- if (!existsSync(this.filePath)) {
46
- return {};
47
- }
48
- else {
49
- const data = readFileSync(this.filePath).toString();
50
- try {
51
- const json = JSON.parse(data);
52
- return migrate(json) ?? {};
53
- }
54
- catch {
55
- rmSync(this.filePath);
56
- log.warn('Corrupted configuration file');
57
- return {};
58
- }
59
- }
60
- }
61
- write(param) {
62
- const dir = path.parse(this.filePath).dir;
63
- mkdirSync(dir, { recursive: true });
64
- writeFileSync(this.filePath, JSON.stringify(param));
65
- }
66
- remove() {
67
- if (existsSync(this.filePath)) {
68
- rmSync(this.filePath);
69
- }
70
- }
71
- print() {
72
- const { apiUrl } = this.read();
73
- console.log(`${color.bold('Prividium™ API url')}: ${apiUrl}`);
74
- }
75
- printPath() {
76
- console.log(this.filePath);
77
- }
78
- }
@@ -1,73 +0,0 @@
1
- import { z } from 'zod';
2
- import { UNAUTHORIZED_ERROR_CODE } from './rpc-error-codes.js';
3
- const jsonRpcErrorSchema = z.object({
4
- error: z.object({
5
- code: z.number(),
6
- message: z.string().optional(),
7
- data: z.unknown().optional()
8
- })
9
- });
10
- const apiErrorSchema = z.object({
11
- error: z.object({
12
- code: z.string(),
13
- message: z.string()
14
- })
15
- });
16
- /**
17
- * Checks if a Response contains a Prividium unauthorized/forbidden error.
18
- */
19
- export async function hasPrividiumUnauthorizedError(response) {
20
- try {
21
- const clonedResponse = response.clone();
22
- const parsed = jsonRpcErrorSchema.safeParse(await clonedResponse.json());
23
- if (parsed.success) {
24
- return parsed.data.error.code === UNAUTHORIZED_ERROR_CODE;
25
- }
26
- return false;
27
- }
28
- catch {
29
- return false;
30
- }
31
- }
32
- export function isPrividiumUnauthorizedRpcError(error) {
33
- if (!error || typeof error !== 'object') {
34
- return false;
35
- }
36
- const value = error;
37
- if (value.code === UNAUTHORIZED_ERROR_CODE) {
38
- return true;
39
- }
40
- return isPrividiumUnauthorizedRpcError(value.cause);
41
- }
42
- /**
43
- * Extracts a human-readable error string from a failed HTTP response.
44
- * Attempts to parse the server's `{ error: { code, message } }` JSON structure,
45
- * falls back to plain text, and ultimately to status + statusText.
46
- * Never throws — always returns a usable string.
47
- */
48
- export async function extractResponseError(response) {
49
- const base = `${response.status} ${response.statusText}`;
50
- try {
51
- const cloned = response.clone();
52
- const text = await cloned.text();
53
- if (!text) {
54
- return base;
55
- }
56
- try {
57
- const json = JSON.parse(text);
58
- const parsed = apiErrorSchema.safeParse(json);
59
- if (parsed.success) {
60
- const { code, message } = parsed.data.error;
61
- return `${base}: ${message} (${code})`;
62
- }
63
- }
64
- catch {
65
- // Not JSON
66
- }
67
- return `${base}: ${text}`;
68
- }
69
- catch {
70
- // Body unreadable
71
- }
72
- return base;
73
- }
@@ -1,12 +0,0 @@
1
- export class MemoryStorage {
2
- store = new Map();
3
- getItem(key) {
4
- return this.store.get(key) ?? null;
5
- }
6
- setItem(key, value) {
7
- this.store.set(key, value);
8
- }
9
- removeItem(key) {
10
- this.store.delete(key);
11
- }
12
- }
@@ -1,28 +0,0 @@
1
- /**
2
- * RPC error codes used in Prividium SDK.
3
- * Standard codes follow JSON-RPC 2.0 spec, custom codes handle auth/authz.
4
- */
5
- /**
6
- * Internal error (-32603). Standard JSON-RPC 2.0 code for server errors.
7
- */
8
- export const INTERNAL_RPC_ERROR = -32603;
9
- /**
10
- * Invalid Request (-32600). Standard JSON-RPC 2.0 code for malformed requests.
11
- */
12
- export const INVALID_REQUEST_ERROR_CODE = -32600;
13
- /**
14
- * Method not found (-32601). Standard JSON-RPC 2.0 code for unknown/unavailable methods.
15
- */
16
- export const METHOD_NOT_FOUND_ERROR_CODE = -32601;
17
- /**
18
- * Invalid params (-32602). Standard JSON-RPC 2.0 code for bad parameters.
19
- */
20
- export const BAD_RPC_PARAMS_ERROR_CODE = -32602;
21
- /**
22
- * Unauthorized (-32090). Custom code for authentication failures (no/invalid token).
23
- */
24
- export const UNAUTHORIZED_ERROR_CODE = -32090;
25
- /**
26
- * Forbidden (-32001). Custom code for authorization failures (valid token, insufficient permissions).
27
- */
28
- export const FORBIDDEN_ERROR_CODE = -32001;
@@ -1,70 +0,0 @@
1
- import { z } from 'zod';
2
- import { extractResponseError } from './error-utils.js';
3
- const siweMessageResponseSchema = z.object({
4
- msg: z.string(),
5
- nonceToken: z.string()
6
- });
7
- const siweLoginResponseSchema = z.object({
8
- token: z.string(),
9
- expiresAt: z.string()
10
- });
11
- const mfaResponseSchema = z.object({
12
- requiresMfa: z.literal(true)
13
- });
14
- export class SiweAuth {
15
- config;
16
- constructor(config) {
17
- this.config = config;
18
- }
19
- get address() {
20
- return this.config.account.address;
21
- }
22
- async authorize() {
23
- // Step 1: Request SIWE message
24
- const siweResponse = await fetch(new URL('/api/siwe-messages', this.config.prividiumApiBaseUrl), {
25
- method: 'POST',
26
- headers: { 'Content-Type': 'application/json' },
27
- body: JSON.stringify({
28
- address: this.config.account.address,
29
- ...(this.config.domain && { domain: this.config.domain })
30
- })
31
- });
32
- if (!siweResponse.ok) {
33
- const detail = await extractResponseError(siweResponse);
34
- throw new Error(`Failed to get SIWE message: ${detail}`);
35
- }
36
- const siweData = siweMessageResponseSchema.parse(await siweResponse.json());
37
- // Step 2: Sign the message
38
- const signature = await this.config.account.signMessage({ message: siweData.msg });
39
- // Step 3: Login
40
- const loginResponse = await fetch(new URL('/api/auth/login/crypto-native', this.config.prividiumApiBaseUrl), {
41
- method: 'POST',
42
- headers: { 'Content-Type': 'application/json' },
43
- body: JSON.stringify({ message: siweData.msg, signature, nonceToken: siweData.nonceToken })
44
- });
45
- if (!loginResponse.ok) {
46
- const detail = await extractResponseError(loginResponse);
47
- throw new Error(`SIWE login failed: ${detail}`);
48
- }
49
- const loginJson = await loginResponse.json();
50
- // Check for MFA requirement (admin users with passkeys)
51
- const mfaParsed = mfaResponseSchema.safeParse(loginJson);
52
- if (mfaParsed.success) {
53
- throw new Error('SIWE login requires MFA which is not supported in programmatic auth');
54
- }
55
- const loginData = siweLoginResponseSchema.parse(loginJson);
56
- // Step 4: Store token directly (login response includes expiresAt)
57
- const tokenData = {
58
- rawToken: loginData.token,
59
- expiresAt: new Date(loginData.expiresAt)
60
- };
61
- this.config.tokenManager.setTokenDirect(tokenData);
62
- return tokenData;
63
- }
64
- unauthorize() {
65
- this.config.tokenManager.clearToken();
66
- }
67
- isAuthorized() {
68
- return this.config.tokenManager.isAuthorized();
69
- }
70
- }
@@ -1,142 +0,0 @@
1
- import { addYears } from 'date-fns/addYears';
2
- import { z } from 'zod';
3
- import { STORAGE_KEYS, tokenDataSchema } from './types.js';
4
- export class LocalStorage {
5
- getItem(key) {
6
- if (typeof localStorage === 'undefined') {
7
- return null;
8
- }
9
- return localStorage.getItem(key);
10
- }
11
- setItem(key, value) {
12
- if (typeof localStorage !== 'undefined') {
13
- localStorage.setItem(key, value);
14
- }
15
- }
16
- removeItem(key) {
17
- if (typeof localStorage !== 'undefined') {
18
- localStorage.removeItem(key);
19
- }
20
- }
21
- }
22
- export class TokenManager {
23
- storage;
24
- chainId;
25
- prividiumApiUrl;
26
- tokenCache = null;
27
- onAuthExpiry;
28
- constructor(storage, chainId, prividiumApiUrl, onAuthExpiry) {
29
- this.storage = storage;
30
- this.chainId = chainId;
31
- this.prividiumApiUrl = prividiumApiUrl;
32
- this.onAuthExpiry = onAuthExpiry ?? (() => { });
33
- }
34
- get tokenKey() {
35
- return `${STORAGE_KEYS.TOKEN_PREFIX}${this.chainId}`;
36
- }
37
- get stateKey() {
38
- return `${STORAGE_KEYS.STATE_PREFIX}${this.chainId}`;
39
- }
40
- getToken() {
41
- if (this.tokenCache) {
42
- return this.tokenCache;
43
- }
44
- const tokenDataStr = this.storage.getItem(this.tokenKey);
45
- if (!tokenDataStr) {
46
- return null;
47
- }
48
- try {
49
- const tokenData = tokenDataSchema.safeParse(JSON.parse(tokenDataStr));
50
- if (!tokenData.success) {
51
- return null;
52
- }
53
- if (new Date() > tokenData.data.expiresAt) {
54
- this.clearToken();
55
- this.onAuthExpiry();
56
- return null;
57
- }
58
- this.tokenCache = tokenData.data;
59
- return tokenData.data;
60
- }
61
- catch (e) {
62
- if (e instanceof SyntaxError) {
63
- return null;
64
- }
65
- throw e;
66
- }
67
- }
68
- async getTokenExpiration(token) {
69
- const currentSessionRes = await fetch(new URL('/api/auth/current-session', this.prividiumApiUrl), {
70
- headers: {
71
- authorization: `Bearer ${token}`
72
- }
73
- });
74
- if (!currentSessionRes.ok) {
75
- throw new Error('Error accessing prividium api');
76
- }
77
- if (currentSessionRes.status === 404) {
78
- // NOTE: 404 indicates /api/auth/current-session is unavailable (older API),
79
- // so the token expiration cannot be retrieved. The SDK must defer expiry
80
- // handling until a 403 response is received; a far-future date prevents
81
- // premature onExpiry callbacks before validation fails.
82
- return addYears(new Date(), 100);
83
- }
84
- if (!currentSessionRes.ok || currentSessionRes.status !== 200) {
85
- throw new Error('Error accessing prividium api');
86
- }
87
- const schema = z.object({
88
- expiresAt: z.iso.datetime()
89
- });
90
- const parsed = schema.safeParse(await currentSessionRes.json());
91
- if (!parsed.success) {
92
- throw new Error('Invalid response from prividium api');
93
- }
94
- return new Date(parsed.data.expiresAt);
95
- }
96
- async setToken(rawToken) {
97
- try {
98
- const expiresAt = await this.getTokenExpiration(rawToken);
99
- const tokenData = { rawToken, expiresAt };
100
- this.storage.setItem(this.tokenKey, JSON.stringify(tokenData));
101
- this.tokenCache = tokenData;
102
- return tokenData;
103
- }
104
- catch (error) {
105
- this.clearToken();
106
- throw error;
107
- }
108
- }
109
- /**
110
- * Stores token data directly without fetching expiration from the API.
111
- * Used by SIWE auth where the login response already includes expiresAt.
112
- */
113
- setTokenDirect(tokenData) {
114
- this.storage.setItem(this.tokenKey, JSON.stringify(tokenData));
115
- this.tokenCache = tokenData;
116
- }
117
- clearToken() {
118
- this.tokenCache = null;
119
- this.storage.removeItem(this.tokenKey);
120
- }
121
- isAuthorized() {
122
- const tokenData = this.getToken();
123
- if (tokenData === null) {
124
- return false;
125
- }
126
- const isExpired = new Date() > tokenData.expiresAt;
127
- if (isExpired) {
128
- this.onAuthExpiry();
129
- this.clearToken();
130
- }
131
- return !isExpired;
132
- }
133
- setState(state) {
134
- this.storage.setItem(this.stateKey, state);
135
- }
136
- getState() {
137
- return this.storage.getItem(this.stateKey);
138
- }
139
- clearState() {
140
- this.storage.removeItem(this.stateKey);
141
- }
142
- }
@@ -1,46 +0,0 @@
1
- import { z } from 'zod';
2
- export const roleSchema = z.object({
3
- roleName: z.string()
4
- });
5
- export const profileSchema = z.object({
6
- id: z.string(),
7
- createdAt: z.coerce.date(),
8
- displayName: z.string(),
9
- updatedAt: z.coerce.date(),
10
- roles: roleSchema.array(),
11
- wallets: z.unknown().array()
12
- });
13
- export const authorizeTransactionResponseSchema = z.object({
14
- message: z.string(),
15
- activeUntil: z.string()
16
- });
17
- const methodSelectorSchema = z.string().regex(/^0x[0-9a-fA-F]{8}$/, 'Invalid method selector format');
18
- const addressSchema = z.string().regex(/^0x[0-9a-fA-F]{40}$/i, 'Invalid address format');
19
- export const contractAbiResponseSchema = z.object({
20
- contractAddress: addressSchema,
21
- name: z.string().nullable(),
22
- abi: z.array(z.record(z.string(), z.unknown())),
23
- functions: z.array(z.object({
24
- selector: methodSelectorSchema,
25
- signature: z.string(),
26
- name: z.string(),
27
- accessType: z.enum(['read', 'write'])
28
- }))
29
- });
30
- export const tokenDataSchema = z.object({
31
- rawToken: z.string(),
32
- expiresAt: z.coerce.date()
33
- });
34
- export const AUTH_ERRORS = {
35
- INVALID_STATE: 'Invalid state parameter',
36
- NO_RECEIVED_STATE: 'No state parameter',
37
- NO_SAVED_STATE: 'No saved state',
38
- NO_TOKEN: 'No token received',
39
- EXPIRED_TOKEN: 'Expired token',
40
- INVALID_JWT: 'Invalid JWT format',
41
- AUTH_REQUIRED: 'Authentication required'
42
- };
43
- export const STORAGE_KEYS = {
44
- STATE_PREFIX: 'prividium_auth_state_',
45
- TOKEN_PREFIX: 'prividium_token_'
46
- };
@@ -1 +0,0 @@
1
- {"root":["../../cli/base-cli.ts","../../cli/index.ts","../../cli/commands/config.ts","../../cli/commands/doctor.ts","../../cli/commands/proxy.ts","../../cli/commands/doctor/constants.ts","../../cli/commands/doctor/profile.ts","../../cli/commands/doctor/stages.ts","../../cli/commands/doctor/types.ts","../../cli/commands/doctor/utils.ts","../../cli/commands/doctor/clients/browser-auth.ts","../../cli/commands/doctor/clients/http.ts","../../cli/commands/doctor/clients/rpc.ts","../../cli/commands/doctor/clients/wallet-api.ts","../../cli/commands/doctor/probes/authentication.ts","../../cli/commands/doctor/probes/bridging.ts","../../cli/commands/doctor/probes/global.ts","../../cli/commands/doctor/probes/wallet-api.ts","../../cli/commands/doctor/probes/wallet.ts","../../cli/commands/doctor/probes/authentication/authentication.ts","../../cli/commands/doctor/probes/authentication/wallet-preconditions.ts","../../cli/commands/doctor/probes/bridging/bridging.ts","../../cli/commands/doctor/probes/global/input-validation.ts","../../cli/commands/doctor/probes/global/reachability.ts","../../cli/commands/doctor/probes/wallet/authenticated-rpc.ts","../../cli/commands/doctor/probes/wallet/authorization-and-wallet-rpc.ts","../../cli/commands/doctor/report/build.ts","../../cli/commands/doctor/report/render.ts","../../cli/commands/utils/show-prividium-header.ts","../../cli/commands/utils/url-config.ts","../../cli/server/config-file.ts","../../cli/server/connection-workflow.ts","../../cli/server/server.ts"],"version":"5.8.3"}
File without changes
File without changes
File without changes
File without changes