@debros/network-ts-sdk 0.6.2 → 0.7.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.
@@ -0,0 +1,19 @@
1
+ export { GuardianClient, GuardianError } from './guardian';
2
+ export { fanOut, fanOutIndexed, withTimeout, withRetry } from './fanout';
3
+ export type {
4
+ GuardianEndpoint,
5
+ GuardianErrorCode,
6
+ GuardianInfo,
7
+ HealthResponse,
8
+ StatusResponse,
9
+ PushResponse,
10
+ PullResponse,
11
+ StoreSecretResponse,
12
+ GetSecretResponse,
13
+ DeleteSecretResponse,
14
+ ListSecretsResponse,
15
+ SecretEntry,
16
+ ChallengeResponse,
17
+ SessionResponse,
18
+ FanOutResult,
19
+ } from './types';
@@ -0,0 +1,101 @@
1
+ /** A guardian node endpoint. */
2
+ export interface GuardianEndpoint {
3
+ address: string;
4
+ port: number;
5
+ }
6
+
7
+ /** V1 push response. */
8
+ export interface PushResponse {
9
+ status: string;
10
+ }
11
+
12
+ /** V1 pull response. */
13
+ export interface PullResponse {
14
+ share: string; // base64
15
+ }
16
+
17
+ /** V2 store response. */
18
+ export interface StoreSecretResponse {
19
+ status: string;
20
+ name: string;
21
+ version: number;
22
+ }
23
+
24
+ /** V2 get response. */
25
+ export interface GetSecretResponse {
26
+ share: string; // base64
27
+ name: string;
28
+ version: number;
29
+ created_ns: number;
30
+ updated_ns: number;
31
+ }
32
+
33
+ /** V2 delete response. */
34
+ export interface DeleteSecretResponse {
35
+ status: string;
36
+ name: string;
37
+ }
38
+
39
+ /** V2 list response. */
40
+ export interface ListSecretsResponse {
41
+ secrets: SecretEntry[];
42
+ }
43
+
44
+ /** An entry in the list secrets response. */
45
+ export interface SecretEntry {
46
+ name: string;
47
+ version: number;
48
+ size: number;
49
+ }
50
+
51
+ /** Health check response. */
52
+ export interface HealthResponse {
53
+ status: string;
54
+ version: string;
55
+ }
56
+
57
+ /** Status response. */
58
+ export interface StatusResponse {
59
+ status: string;
60
+ version: string;
61
+ data_dir: string;
62
+ client_port: number;
63
+ peer_port: number;
64
+ }
65
+
66
+ /** Guardian info response. */
67
+ export interface GuardianInfo {
68
+ guardians: Array<{ address: string; port: number }>;
69
+ threshold: number;
70
+ total: number;
71
+ }
72
+
73
+ /** Challenge response from auth endpoint. */
74
+ export interface ChallengeResponse {
75
+ nonce: string;
76
+ created_ns: number;
77
+ tag: string;
78
+ }
79
+
80
+ /** Session token response from auth endpoint. */
81
+ export interface SessionResponse {
82
+ identity: string;
83
+ expiry_ns: number;
84
+ tag: string;
85
+ }
86
+
87
+ /** Error body from guardian. */
88
+ export interface GuardianErrorBody {
89
+ error: string;
90
+ }
91
+
92
+ /** Error classification codes. */
93
+ export type GuardianErrorCode = 'TIMEOUT' | 'NOT_FOUND' | 'AUTH' | 'SERVER_ERROR' | 'NETWORK' | 'CONFLICT';
94
+
95
+ /** Fan-out result for a single guardian. */
96
+ export interface FanOutResult<T> {
97
+ endpoint: GuardianEndpoint;
98
+ result: T | null;
99
+ error: string | null;
100
+ errorCode?: GuardianErrorCode;
101
+ }
@@ -0,0 +1,62 @@
1
+ import type { GuardianEndpoint } from './transport/types';
2
+
3
+ /** Configuration for VaultClient. */
4
+ export interface VaultConfig {
5
+ /** Guardian endpoints to connect to. */
6
+ guardians: GuardianEndpoint[];
7
+ /** HMAC key for authentication (derived from user's secret). */
8
+ hmacKey: Uint8Array;
9
+ /** Identity hash (hex string, 64 chars). */
10
+ identityHex: string;
11
+ /** Request timeout in ms (default: 10000). */
12
+ timeoutMs?: number;
13
+ }
14
+
15
+ /** Metadata for a stored secret. */
16
+ export interface SecretMeta {
17
+ name: string;
18
+ version: number;
19
+ size: number;
20
+ }
21
+
22
+ /** Result of a store operation. */
23
+ export interface StoreResult {
24
+ /** Number of guardians that acknowledged. */
25
+ ackCount: number;
26
+ /** Total guardians contacted. */
27
+ totalContacted: number;
28
+ /** Number of failures. */
29
+ failCount: number;
30
+ /** Whether write quorum was met. */
31
+ quorumMet: boolean;
32
+ /** Per-guardian results. */
33
+ guardianResults: GuardianResult[];
34
+ }
35
+
36
+ /** Result of a retrieve operation. */
37
+ export interface RetrieveResult {
38
+ /** The reconstructed secret data. */
39
+ data: Uint8Array;
40
+ /** Number of shares collected. */
41
+ sharesCollected: number;
42
+ }
43
+
44
+ /** Result of a list operation. */
45
+ export interface ListResult {
46
+ secrets: SecretMeta[];
47
+ }
48
+
49
+ /** Result of a delete operation. */
50
+ export interface DeleteResult {
51
+ /** Number of guardians that acknowledged. */
52
+ ackCount: number;
53
+ totalContacted: number;
54
+ quorumMet: boolean;
55
+ }
56
+
57
+ /** Per-guardian operation result. */
58
+ export interface GuardianResult {
59
+ endpoint: string;
60
+ success: boolean;
61
+ error?: string;
62
+ }