@bandeira-tech/b3nd-web 0.2.0 → 0.2.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,15 +1,14 @@
1
1
  // clients/websocket/mod.ts
2
2
  var WebSocketClient = class {
3
- config;
4
- ws = null;
5
- connected = false;
6
- reconnectAttempts = 0;
7
- reconnectTimer = null;
8
- pendingRequests = /* @__PURE__ */ new Map();
9
- messageHandler = this.handleMessage.bind(this);
10
- closeHandler = this.handleClose.bind(this);
11
- errorHandler = this.handleError.bind(this);
12
3
  constructor(config) {
4
+ this.ws = null;
5
+ this.connected = false;
6
+ this.reconnectAttempts = 0;
7
+ this.reconnectTimer = null;
8
+ this.pendingRequests = /* @__PURE__ */ new Map();
9
+ this.messageHandler = this.handleMessage.bind(this);
10
+ this.closeHandler = this.handleClose.bind(this);
11
+ this.errorHandler = this.handleError.bind(this);
13
12
  this.config = {
14
13
  timeout: 3e4,
15
14
  ...config,
@@ -26,19 +25,17 @@ var WebSocketClient = class {
26
25
  * Ensure WebSocket connection is established
27
26
  */
28
27
  async ensureConnected() {
29
- var _a, _b;
30
- if (this.connected && ((_a = this.ws) == null ? void 0 : _a.readyState) === WebSocket.OPEN) {
28
+ if (this.connected && this.ws?.readyState === WebSocket.OPEN) {
31
29
  return;
32
30
  }
33
- if (((_b = this.ws) == null ? void 0 : _b.readyState) === WebSocket.CONNECTING) {
31
+ if (this.ws?.readyState === WebSocket.CONNECTING) {
34
32
  return new Promise((resolve, reject) => {
35
33
  const timeout = setTimeout(() => reject(new Error("Connection timeout")), this.config.timeout);
36
34
  const checkConnection = () => {
37
- var _a2, _b2;
38
35
  if (this.connected) {
39
36
  clearTimeout(timeout);
40
37
  resolve();
41
- } else if (((_a2 = this.ws) == null ? void 0 : _a2.readyState) === WebSocket.CLOSED || ((_b2 = this.ws) == null ? void 0 : _b2.readyState) === WebSocket.CLOSING) {
38
+ } else if (this.ws?.readyState === WebSocket.CLOSED || this.ws?.readyState === WebSocket.CLOSING) {
42
39
  clearTimeout(timeout);
43
40
  reject(new Error("Connection failed"));
44
41
  } else {
@@ -78,8 +75,7 @@ var WebSocketClient = class {
78
75
  this.ws.addEventListener("close", this.closeHandler);
79
76
  this.ws.addEventListener("error", this.errorHandler);
80
77
  const timeout = setTimeout(() => {
81
- var _a;
82
- (_a = this.ws) == null ? void 0 : _a.close();
78
+ this.ws?.close();
83
79
  reject(new Error("Connection timeout"));
84
80
  }, this.config.timeout);
85
81
  this.ws.addEventListener("open", () => clearTimeout(timeout), { once: true });
@@ -108,10 +104,9 @@ var WebSocketClient = class {
108
104
  * Handle WebSocket close
109
105
  */
110
106
  handleClose() {
111
- var _a;
112
107
  this.connected = false;
113
108
  this.cleanupPendingRequests(new Error("WebSocket connection closed"));
114
- if (((_a = this.config.reconnect) == null ? void 0 : _a.enabled) && this.reconnectAttempts < (this.config.reconnect.maxAttempts || 5)) {
109
+ if (this.config.reconnect?.enabled && this.reconnectAttempts < (this.config.reconnect.maxAttempts || 5)) {
115
110
  this.scheduleReconnect();
116
111
  }
117
112
  }
@@ -126,11 +121,10 @@ var WebSocketClient = class {
126
121
  * Schedule reconnection attempt
127
122
  */
128
123
  scheduleReconnect() {
129
- var _a, _b;
130
124
  if (this.reconnectTimer) {
131
125
  clearTimeout(this.reconnectTimer);
132
126
  }
133
- const delay = ((_a = this.config.reconnect) == null ? void 0 : _a.backoff) === "exponential" ? (this.config.reconnect.interval || 1e3) * Math.pow(2, this.reconnectAttempts) : ((_b = this.config.reconnect) == null ? void 0 : _b.interval) || 1e3;
127
+ const delay = this.config.reconnect?.backoff === "exponential" ? (this.config.reconnect.interval || 1e3) * Math.pow(2, this.reconnectAttempts) : this.config.reconnect?.interval || 1e3;
134
128
  this.reconnectTimer = setTimeout(() => {
135
129
  this.reconnectAttempts++;
136
130
  this.connect().catch(() => {
@@ -153,7 +147,6 @@ var WebSocketClient = class {
153
147
  async sendRequest(type, payload) {
154
148
  await this.ensureConnected();
155
149
  return new Promise((resolve, reject) => {
156
- var _a;
157
150
  const id = crypto.randomUUID();
158
151
  const request = { id, type, payload };
159
152
  const timeout = setTimeout(() => {
@@ -172,7 +165,7 @@ var WebSocketClient = class {
172
165
  timeout
173
166
  });
174
167
  try {
175
- (_a = this.ws) == null ? void 0 : _a.send(JSON.stringify(request));
168
+ this.ws?.send(JSON.stringify(request));
176
169
  } catch (error) {
177
170
  this.pendingRequests.delete(id);
178
171
  clearTimeout(timeout);
@@ -211,8 +204,8 @@ var WebSocketClient = class {
211
204
  success: true,
212
205
  data: [],
213
206
  pagination: {
214
- page: (options == null ? void 0 : options.page) || 1,
215
- limit: (options == null ? void 0 : options.limit) || 50
207
+ page: options?.page || 1,
208
+ limit: options?.limit || 50
216
209
  }
217
210
  };
218
211
  }
@@ -1,15 +1,10 @@
1
1
  // apps/mod.ts
2
2
  var AppsClient = class {
3
- base;
4
- api;
5
- f;
6
- authToken;
7
3
  constructor(cfg) {
8
4
  if (!cfg.appServerUrl) throw new Error("appServerUrl is required");
9
5
  if (!cfg.apiBasePath) throw new Error("apiBasePath is required");
10
6
  this.base = cfg.appServerUrl.replace(/\/$/, "");
11
7
  this.api = (cfg.apiBasePath.startsWith("/") ? cfg.apiBasePath : `/${cfg.apiBasePath}`).replace(/\/$/, "");
12
- if (cfg.authToken) this.authToken = cfg.authToken;
13
8
  if (cfg.fetch) {
14
9
  this.f = cfg.fetch;
15
10
  } else if (typeof window !== "undefined" && typeof window.fetch === "function") {
@@ -18,55 +13,62 @@ var AppsClient = class {
18
13
  this.f = fetch;
19
14
  }
20
15
  }
21
- setAuthToken(token) {
22
- this.authToken = token;
23
- }
24
16
  async health() {
25
17
  const r = await this.f(`${this.base}${this.api}/health`);
26
18
  if (!r.ok) throw new Error(`health failed: ${r.statusText}`);
27
19
  return r.json();
28
20
  }
29
- async registerApp(reg) {
30
- const r = await this.f(`${this.base}${this.api}/apps/register`, {
21
+ async updateOrigins(appKey, message) {
22
+ const r = await this.f(`${this.base}${this.api}/apps/origins/${encodeURIComponent(appKey)}`, {
23
+ method: "POST",
24
+ headers: { "Content-Type": "application/json" },
25
+ body: JSON.stringify(message)
26
+ });
27
+ const j = await r.json();
28
+ if (!r.ok || !j.success) throw new Error(j.error || r.statusText);
29
+ return j;
30
+ }
31
+ async updateGoogleClientId(appKey, message) {
32
+ const r = await this.f(`${this.base}${this.api}/apps/google-client-id/${encodeURIComponent(appKey)}`, {
31
33
  method: "POST",
32
- headers: { "Content-Type": "application/json", ...this.authToken ? { Authorization: `Bearer ${this.authToken}` } : {} },
33
- body: JSON.stringify(reg)
34
+ headers: { "Content-Type": "application/json" },
35
+ body: JSON.stringify(message)
34
36
  });
35
37
  const j = await r.json();
36
38
  if (!r.ok || !j.success) throw new Error(j.error || r.statusText);
37
39
  return j;
38
40
  }
39
- async updateSchema(appKey, actions) {
40
- const r = await this.f(`${this.base}${this.api}/apps/${encodeURIComponent(appKey)}/schema`, {
41
+ async updateSchema(appKey, message) {
42
+ const r = await this.f(`${this.base}${this.api}/apps/schema/${encodeURIComponent(appKey)}`, {
41
43
  method: "POST",
42
- headers: { "Content-Type": "application/json", ...this.authToken ? { Authorization: `Bearer ${this.authToken}` } : {} },
43
- body: JSON.stringify(actions)
44
+ headers: { "Content-Type": "application/json" },
45
+ body: JSON.stringify(message)
44
46
  });
45
47
  const j = await r.json();
46
48
  if (!r.ok || !j.success) throw new Error(j.error || r.statusText);
47
49
  return j;
48
50
  }
49
51
  async getSchema(appKey) {
50
- const r = await this.f(`${this.base}${this.api}/apps/${encodeURIComponent(appKey)}/schema`, { headers: { ...this.authToken ? { Authorization: `Bearer ${this.authToken}` } : {} } });
52
+ const r = await this.f(`${this.base}${this.api}/apps/schema/${encodeURIComponent(appKey)}`);
51
53
  const j = await r.json();
52
54
  if (!r.ok || !j.success) throw new Error(j.error || r.statusText);
53
55
  return j;
54
56
  }
55
- async createSession(appKey, token) {
57
+ async createSession(appKey, message) {
56
58
  const r = await this.f(`${this.base}${this.api}/app/${encodeURIComponent(appKey)}/session`, {
57
59
  method: "POST",
58
60
  headers: { "Content-Type": "application/json" },
59
- body: JSON.stringify({ token })
61
+ body: JSON.stringify(message)
60
62
  });
61
63
  const j = await r.json();
62
64
  if (!r.ok || !j.success) throw new Error(j.error || r.statusText);
63
65
  return j;
64
66
  }
65
- async invokeAction(appKey, action, payload, origin) {
67
+ async invokeAction(appKey, action, signedMessage, origin) {
66
68
  const r = await this.f(`${this.base}${this.api}/app/${encodeURIComponent(appKey)}/${encodeURIComponent(action)}`, {
67
69
  method: "POST",
68
- headers: { "Content-Type": "text/plain", ...origin ? { Origin: origin } : {} },
69
- body: payload
70
+ headers: { "Content-Type": "application/json", ...origin ? { Origin: origin } : {} },
71
+ body: JSON.stringify(signedMessage)
70
72
  });
71
73
  const j = await r.json();
72
74
  if (!r.ok || !j.success) throw new Error(j.error || r.statusText);
@@ -1,4 +1,4 @@
1
- import { N as NodeProtocolInterface, a as HttpClientConfig, g as WriteResult, R as ReadResult, b as ListOptions, c as ListResult, D as DeleteResult, H as HealthStatus } from '../../types-Bw0Boe0n.js';
1
+ import { N as NodeProtocolInterface, a as HttpClientConfig, g as WriteResult, R as ReadResult, b as ListOptions, c as ListResult, D as DeleteResult, H as HealthStatus } from '../../types-oQCx3U-_.js';
2
2
 
3
3
  /**
4
4
  * HttpClient - HTTP implementation of NodeProtocolInterface
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  HttpClient
3
- } from "../../chunk-PMBS2GFA.js";
3
+ } from "../../chunk-LFUC4ETD.js";
4
4
  import "../../chunk-MLKGABMK.js";
5
5
  export {
6
6
  HttpClient
@@ -1,4 +1,4 @@
1
- import { N as NodeProtocolInterface, d as LocalStorageClientConfig, g as WriteResult, R as ReadResult, b as ListOptions, c as ListResult, D as DeleteResult, H as HealthStatus } from '../../types-Bw0Boe0n.js';
1
+ import { N as NodeProtocolInterface, d as LocalStorageClientConfig, g as WriteResult, R as ReadResult, b as ListOptions, c as ListResult, D as DeleteResult, H as HealthStatus } from '../../types-oQCx3U-_.js';
2
2
 
3
3
  /**
4
4
  * LocalStorageClient - Browser localStorage implementation of NodeProtocolInterface
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  LocalStorageClient
3
- } from "../../chunk-XH4OLKBV.js";
3
+ } from "../../chunk-7U5JDFQW.js";
4
4
  import "../../chunk-MLKGABMK.js";
5
5
  export {
6
6
  LocalStorageClient
@@ -1,4 +1,4 @@
1
- import { N as NodeProtocolInterface, W as WebSocketClientConfig, g as WriteResult, R as ReadResult, b as ListOptions, c as ListResult, D as DeleteResult, H as HealthStatus } from '../../types-Bw0Boe0n.js';
1
+ import { N as NodeProtocolInterface, W as WebSocketClientConfig, g as WriteResult, R as ReadResult, b as ListOptions, c as ListResult, D as DeleteResult, H as HealthStatus } from '../../types-oQCx3U-_.js';
2
2
 
3
3
  /**
4
4
  * WebSocketClient - WebSocket implementation of NodeProtocolInterface
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  WebSocketClient
3
- } from "../../chunk-C2ZIFM22.js";
3
+ } from "../../chunk-T43IWAQK.js";
4
4
  import "../../chunk-MLKGABMK.js";
5
5
  export {
6
6
  WebSocketClient
@@ -1 +1 @@
1
- export { A as AuthenticatedMessage, a as EncryptedPayload, E as EncryptionKeyPair, K as KeyPair, S as SignedEncryptedMessage, h as createAuthenticatedMessage, i as createSignedEncryptedMessage, d as decrypt, f as decryptWithHex, e as encrypt, b as generateEncryptionKeyPair, k as generateNonce, l as generateRandomData, g as generateSigningKeyPair, s as sign, c as signWithHex, v as verify, j as verifyAndDecrypt } from '../mod-DHjjiF1o.js';
1
+ export { A as AuthenticatedMessage, a as EncryptedPayload, E as EncryptionKeyPair, I as IdentityKey, K as KeyPair, d as PrivateEncryptionKey, P as PublicEncryptionKey, c as SecretEncryptionKey, S as SignedEncryptedMessage, b as SignedSymmetricMessage, k as createAuthenticatedMessage, l as createAuthenticatedMessageWithHex, w as createSignedEncryptedMessage, B as createSignedSymmetricMessage, i as decrypt, z as decryptSymmetric, j as decryptWithHex, n as deriveKeyFromSeed, h as encrypt, y as encryptSymmetric, r as exportPrivateKeyPem, e as generateEncryptionKeyPair, o as generateNonce, q as generateRandomData, g as generateSigningKeyPair, p as pemToCryptoKey, s as sign, t as signPayload, f as signWithHex, v as verify, x as verifyAndDecryptMessage, u as verifyPayload } from '../mod-D02790g_.js';
@@ -1,31 +1,57 @@
1
1
  import {
2
+ IdentityKey,
3
+ PrivateEncryptionKey,
4
+ PublicEncryptionKey,
5
+ SecretEncryptionKey,
2
6
  createAuthenticatedMessage,
7
+ createAuthenticatedMessageWithHex,
3
8
  createSignedEncryptedMessage,
9
+ createSignedSymmetricMessage,
4
10
  decrypt,
11
+ decryptSymmetric,
5
12
  decryptWithHex,
13
+ deriveKeyFromSeed,
6
14
  encrypt,
15
+ encryptSymmetric,
16
+ exportPrivateKeyPem,
7
17
  generateEncryptionKeyPair,
8
18
  generateNonce,
9
19
  generateRandomData,
10
20
  generateSigningKeyPair,
21
+ pemToCryptoKey,
11
22
  sign,
23
+ signPayload,
12
24
  signWithHex,
13
25
  verify,
14
- verifyAndDecrypt
15
- } from "../chunk-G6JDROB4.js";
26
+ verifyAndDecryptMessage,
27
+ verifyPayload
28
+ } from "../chunk-K3ZSSVHR.js";
16
29
  import "../chunk-MLKGABMK.js";
17
30
  export {
31
+ IdentityKey,
32
+ PrivateEncryptionKey,
33
+ PublicEncryptionKey,
34
+ SecretEncryptionKey,
18
35
  createAuthenticatedMessage,
36
+ createAuthenticatedMessageWithHex,
19
37
  createSignedEncryptedMessage,
38
+ createSignedSymmetricMessage,
20
39
  decrypt,
40
+ decryptSymmetric,
21
41
  decryptWithHex,
42
+ deriveKeyFromSeed,
22
43
  encrypt,
44
+ encryptSymmetric,
45
+ exportPrivateKeyPem,
23
46
  generateEncryptionKeyPair,
24
47
  generateNonce,
25
48
  generateRandomData,
26
49
  generateSigningKeyPair,
50
+ pemToCryptoKey,
27
51
  sign,
52
+ signPayload,
28
53
  signWithHex,
29
54
  verify,
30
- verifyAndDecrypt
55
+ verifyAndDecryptMessage,
56
+ verifyPayload
31
57
  };
@@ -0,0 +1,241 @@
1
+ interface KeyPair {
2
+ publicKey: CryptoKey;
3
+ privateKey: CryptoKey;
4
+ publicKeyHex: string;
5
+ privateKeyHex: string;
6
+ }
7
+ interface EncryptionKeyPair {
8
+ publicKey: CryptoKey;
9
+ privateKey: CryptoKey;
10
+ publicKeyHex: string;
11
+ }
12
+ interface EncryptedPayload {
13
+ data: string;
14
+ nonce: string;
15
+ ephemeralPublicKey?: string;
16
+ }
17
+ interface AuthenticatedMessage<T = unknown> {
18
+ auth: Array<{
19
+ pubkey: string;
20
+ signature: string;
21
+ }>;
22
+ payload: T;
23
+ }
24
+ interface SignedEncryptedMessage {
25
+ auth: Array<{
26
+ pubkey: string;
27
+ signature: string;
28
+ }>;
29
+ payload: EncryptedPayload;
30
+ }
31
+ interface SignedSymmetricMessage {
32
+ auth: Array<{
33
+ pubkey: string;
34
+ signature: string;
35
+ }>;
36
+ payload: EncryptedPayload;
37
+ }
38
+ declare class IdentityKey {
39
+ private readonly privateKey;
40
+ readonly publicKeyHex: string;
41
+ private constructor();
42
+ static generate(): Promise<{
43
+ key: IdentityKey;
44
+ privateKeyPem: string;
45
+ publicKeyHex: string;
46
+ }>;
47
+ static fromPem(pem: string, publicKeyHex: string): Promise<IdentityKey>;
48
+ static fromHex(params: {
49
+ privateKeyHex: string;
50
+ publicKeyHex: string;
51
+ }): Promise<IdentityKey>;
52
+ sign(payload: unknown): Promise<string>;
53
+ }
54
+ declare class PublicEncryptionKey {
55
+ readonly publicKeyHex: string;
56
+ readonly publicKey: CryptoKey | null;
57
+ constructor(publicKeyHex: string, publicKey: CryptoKey | null);
58
+ static fromHex(publicKeyHex: string): Promise<PublicEncryptionKey>;
59
+ static generatePair(): Promise<{
60
+ publicKey: PublicEncryptionKey;
61
+ privateKeyHex: string;
62
+ }>;
63
+ encrypt(data: unknown): Promise<EncryptedPayload>;
64
+ toHex(): string;
65
+ }
66
+ declare class SecretEncryptionKey {
67
+ readonly keyHex: string;
68
+ private constructor();
69
+ static fromSecret(params: {
70
+ secret: string;
71
+ salt: string;
72
+ iterations?: number;
73
+ }): Promise<SecretEncryptionKey>;
74
+ static fromHex(keyHex: string): SecretEncryptionKey;
75
+ encrypt(data: unknown): Promise<EncryptedPayload>;
76
+ decrypt(payload: EncryptedPayload): Promise<unknown>;
77
+ }
78
+ declare class PrivateEncryptionKey {
79
+ readonly privateKey: CryptoKey;
80
+ readonly privateKeyHex: string;
81
+ readonly publicKeyHex: string;
82
+ constructor(privateKey: CryptoKey, privateKeyHex: string, publicKeyHex: string);
83
+ static fromHex(params: {
84
+ privateKeyHex: string;
85
+ publicKeyHex: string;
86
+ }): Promise<PrivateEncryptionKey>;
87
+ static generatePair(): Promise<{
88
+ privateKey: PrivateEncryptionKey;
89
+ publicKey: PublicEncryptionKey;
90
+ }>;
91
+ toPublic(): PublicEncryptionKey;
92
+ decrypt(payload: EncryptedPayload): Promise<unknown>;
93
+ toHex(): string;
94
+ }
95
+ /**
96
+ * Convert a PEM-encoded private key to a CryptoKey
97
+ */
98
+ declare function pemToCryptoKey(pem: string, algorithm: "Ed25519" | "X25519"): Promise<CryptoKey>;
99
+ /**
100
+ * Generate an Ed25519 keypair for signing
101
+ */
102
+ declare function generateSigningKeyPair(): Promise<KeyPair>;
103
+ /**
104
+ * Generate an X25519 keypair for encryption (ECDH)
105
+ */
106
+ declare function generateEncryptionKeyPair(): Promise<EncryptionKeyPair>;
107
+ /**
108
+ * Sign a payload with an Ed25519 private key
109
+ */
110
+ declare function sign<T>(privateKey: CryptoKey, payload: T): Promise<string>;
111
+ /**
112
+ * Sign a payload with an Ed25519 private key from hex
113
+ */
114
+ declare function signWithHex<T>(privateKeyHex: string, payload: T): Promise<string>;
115
+ /**
116
+ * Verify a signature using Ed25519 public key
117
+ */
118
+ declare function verify<T>(publicKeyHex: string, signatureHex: string, payload: T): Promise<boolean>;
119
+ /**
120
+ * Encrypt data using X25519 ECDH + AES-GCM
121
+ * Uses ephemeral keypair for forward secrecy
122
+ */
123
+ declare function encrypt(data: unknown, recipientPublicKeyHex: string): Promise<EncryptedPayload>;
124
+ /**
125
+ * Decrypt data using X25519 ECDH + AES-GCM
126
+ */
127
+ declare function decrypt(encryptedPayload: EncryptedPayload, recipientPrivateKey: CryptoKey): Promise<unknown>;
128
+ /**
129
+ * Decrypt data using private key from hex
130
+ */
131
+ declare function decryptWithHex(encryptedPayload: EncryptedPayload, recipientPrivateKeyHex: string): Promise<unknown>;
132
+ /**
133
+ * Create an authenticated message (signed but not encrypted)
134
+ */
135
+ declare function createAuthenticatedMessage<T>(payload: T, signers: Array<{
136
+ privateKey: CryptoKey;
137
+ publicKeyHex: string;
138
+ }>): Promise<AuthenticatedMessage<T>>;
139
+ /**
140
+ * Create an authenticated message with hex-encoded keys (convenience wrapper)
141
+ */
142
+ declare function createAuthenticatedMessageWithHex<T>(payload: T, pubkeyHex: string, privateKeyHex: string): Promise<AuthenticatedMessage<T>>;
143
+ /**
144
+ * Derive an encryption key from seed and salt using PBKDF2
145
+ * Returns hex-encoded key suitable for encrypt/decrypt functions
146
+ */
147
+ declare function deriveKeyFromSeed(seed: string, salt: string, iterations?: number): Promise<string>;
148
+ declare function generateNonce(length?: number): Uint8Array;
149
+ declare function generateRandomData(size: number): Uint8Array;
150
+ declare function exportPrivateKeyPem(privateKey: CryptoKey, label: string): Promise<string>;
151
+ declare function signPayload(params: {
152
+ payload: unknown;
153
+ identity: IdentityKey;
154
+ }): Promise<Array<{
155
+ pubkey: string;
156
+ signature: string;
157
+ }>>;
158
+ declare function verifyPayload(params: {
159
+ payload: unknown;
160
+ auth: Array<{
161
+ pubkey: string;
162
+ signature: string;
163
+ }>;
164
+ }): Promise<{
165
+ verified: boolean;
166
+ signers: string[];
167
+ }>;
168
+ declare function createSignedEncryptedMessage(params: {
169
+ data: unknown;
170
+ identity: IdentityKey;
171
+ encryptionKey: SecretEncryptionKey | PublicEncryptionKey;
172
+ }): Promise<SignedEncryptedMessage>;
173
+ declare function createSignedEncryptedMessage(data: unknown, signers: Array<{
174
+ privateKey: CryptoKey;
175
+ publicKeyHex: string;
176
+ }>, recipientPublicKeyHex: string): Promise<SignedEncryptedMessage>;
177
+ declare function verifyAndDecryptMessage(params: {
178
+ message: SignedEncryptedMessage;
179
+ encryptionKey: SecretEncryptionKey | PrivateEncryptionKey;
180
+ }): Promise<{
181
+ data: unknown;
182
+ verified: boolean;
183
+ signers: string[];
184
+ }>;
185
+ /**
186
+ * Encrypt data using a symmetric key (AES-GCM) provided as hex
187
+ */
188
+ declare function encryptSymmetric(data: unknown, keyHex: string): Promise<EncryptedPayload>;
189
+ /**
190
+ * Decrypt data using a symmetric key (AES-GCM) provided as hex
191
+ */
192
+ declare function decryptSymmetric(payload: EncryptedPayload, keyHex: string): Promise<unknown>;
193
+ /**
194
+ * Create a signed symmetric message (signs encrypted payload)
195
+ */
196
+ declare function createSignedSymmetricMessage(data: unknown, signers: Array<{
197
+ privateKey: CryptoKey;
198
+ publicKeyHex: string;
199
+ }>, keyHex: string): Promise<SignedSymmetricMessage>;
200
+
201
+ type mod_AuthenticatedMessage<T = unknown> = AuthenticatedMessage<T>;
202
+ type mod_EncryptedPayload = EncryptedPayload;
203
+ type mod_EncryptionKeyPair = EncryptionKeyPair;
204
+ type mod_IdentityKey = IdentityKey;
205
+ declare const mod_IdentityKey: typeof IdentityKey;
206
+ type mod_KeyPair = KeyPair;
207
+ type mod_PrivateEncryptionKey = PrivateEncryptionKey;
208
+ declare const mod_PrivateEncryptionKey: typeof PrivateEncryptionKey;
209
+ type mod_PublicEncryptionKey = PublicEncryptionKey;
210
+ declare const mod_PublicEncryptionKey: typeof PublicEncryptionKey;
211
+ type mod_SecretEncryptionKey = SecretEncryptionKey;
212
+ declare const mod_SecretEncryptionKey: typeof SecretEncryptionKey;
213
+ type mod_SignedEncryptedMessage = SignedEncryptedMessage;
214
+ type mod_SignedSymmetricMessage = SignedSymmetricMessage;
215
+ declare const mod_createAuthenticatedMessage: typeof createAuthenticatedMessage;
216
+ declare const mod_createAuthenticatedMessageWithHex: typeof createAuthenticatedMessageWithHex;
217
+ declare const mod_createSignedEncryptedMessage: typeof createSignedEncryptedMessage;
218
+ declare const mod_createSignedSymmetricMessage: typeof createSignedSymmetricMessage;
219
+ declare const mod_decrypt: typeof decrypt;
220
+ declare const mod_decryptSymmetric: typeof decryptSymmetric;
221
+ declare const mod_decryptWithHex: typeof decryptWithHex;
222
+ declare const mod_deriveKeyFromSeed: typeof deriveKeyFromSeed;
223
+ declare const mod_encrypt: typeof encrypt;
224
+ declare const mod_encryptSymmetric: typeof encryptSymmetric;
225
+ declare const mod_exportPrivateKeyPem: typeof exportPrivateKeyPem;
226
+ declare const mod_generateEncryptionKeyPair: typeof generateEncryptionKeyPair;
227
+ declare const mod_generateNonce: typeof generateNonce;
228
+ declare const mod_generateRandomData: typeof generateRandomData;
229
+ declare const mod_generateSigningKeyPair: typeof generateSigningKeyPair;
230
+ declare const mod_pemToCryptoKey: typeof pemToCryptoKey;
231
+ declare const mod_sign: typeof sign;
232
+ declare const mod_signPayload: typeof signPayload;
233
+ declare const mod_signWithHex: typeof signWithHex;
234
+ declare const mod_verify: typeof verify;
235
+ declare const mod_verifyAndDecryptMessage: typeof verifyAndDecryptMessage;
236
+ declare const mod_verifyPayload: typeof verifyPayload;
237
+ declare namespace mod {
238
+ export { type mod_AuthenticatedMessage as AuthenticatedMessage, type mod_EncryptedPayload as EncryptedPayload, type mod_EncryptionKeyPair as EncryptionKeyPair, mod_IdentityKey as IdentityKey, type mod_KeyPair as KeyPair, mod_PrivateEncryptionKey as PrivateEncryptionKey, mod_PublicEncryptionKey as PublicEncryptionKey, mod_SecretEncryptionKey as SecretEncryptionKey, type mod_SignedEncryptedMessage as SignedEncryptedMessage, type mod_SignedSymmetricMessage as SignedSymmetricMessage, mod_createAuthenticatedMessage as createAuthenticatedMessage, mod_createAuthenticatedMessageWithHex as createAuthenticatedMessageWithHex, mod_createSignedEncryptedMessage as createSignedEncryptedMessage, mod_createSignedSymmetricMessage as createSignedSymmetricMessage, mod_decrypt as decrypt, mod_decryptSymmetric as decryptSymmetric, mod_decryptWithHex as decryptWithHex, mod_deriveKeyFromSeed as deriveKeyFromSeed, mod_encrypt as encrypt, mod_encryptSymmetric as encryptSymmetric, mod_exportPrivateKeyPem as exportPrivateKeyPem, mod_generateEncryptionKeyPair as generateEncryptionKeyPair, mod_generateNonce as generateNonce, mod_generateRandomData as generateRandomData, mod_generateSigningKeyPair as generateSigningKeyPair, mod_pemToCryptoKey as pemToCryptoKey, mod_sign as sign, mod_signPayload as signPayload, mod_signWithHex as signWithHex, mod_verify as verify, mod_verifyAndDecryptMessage as verifyAndDecryptMessage, mod_verifyPayload as verifyPayload };
239
+ }
240
+
241
+ export { type AuthenticatedMessage as A, createSignedSymmetricMessage as B, type EncryptionKeyPair as E, IdentityKey as I, type KeyPair as K, PublicEncryptionKey as P, type SignedEncryptedMessage as S, type EncryptedPayload as a, type SignedSymmetricMessage as b, SecretEncryptionKey as c, PrivateEncryptionKey as d, generateEncryptionKeyPair as e, signWithHex as f, generateSigningKeyPair as g, encrypt as h, decrypt as i, decryptWithHex as j, createAuthenticatedMessage as k, createAuthenticatedMessageWithHex as l, mod as m, deriveKeyFromSeed as n, generateNonce as o, pemToCryptoKey as p, generateRandomData as q, exportPrivateKeyPem as r, sign as s, signPayload as t, verifyPayload as u, verify as v, createSignedEncryptedMessage as w, verifyAndDecryptMessage as x, encryptSymmetric as y, decryptSymmetric as z };
@@ -1,7 +1,7 @@
1
- export { C as ClientError, D as DeleteResult, H as HealthStatus, a as HttpClientConfig, L as ListItem, b as ListOptions, c as ListResult, d as LocalStorageClientConfig, N as NodeProtocolInterface, P as PersistenceRecord, R as ReadResult, S as Schema, V as ValidationFn, W as WebSocketClientConfig, e as WebSocketRequest, f as WebSocketResponse, g as WriteResult } from '../types-Bw0Boe0n.js';
1
+ export { C as ClientError, D as DeleteResult, H as HealthStatus, a as HttpClientConfig, L as ListItem, b as ListOptions, c as ListResult, d as LocalStorageClientConfig, N as NodeProtocolInterface, P as PersistenceRecord, R as ReadResult, S as Schema, V as ValidationFn, W as WebSocketClientConfig, e as WebSocketRequest, f as WebSocketResponse, g as WriteResult } from '../types-oQCx3U-_.js';
2
2
  export { HttpClient } from '../clients/http/mod.js';
3
3
  export { WebSocketClient } from '../clients/websocket/mod.js';
4
4
  export { LocalStorageClient } from '../clients/local-storage/mod.js';
5
5
  export { WalletClient } from '../wallet/mod.js';
6
6
  export { AppsClient } from '../apps/mod.js';
7
- export { m as encrypt } from '../mod-DHjjiF1o.js';
7
+ export { m as encrypt } from '../mod-D02790g_.js';
@@ -1,21 +1,21 @@
1
1
  import {
2
2
  AppsClient
3
- } from "../chunk-QHDBFVLU.js";
3
+ } from "../chunk-VAZUCGED.js";
4
4
  import {
5
5
  mod_exports
6
- } from "../chunk-G6JDROB4.js";
6
+ } from "../chunk-K3ZSSVHR.js";
7
7
  import {
8
8
  WalletClient
9
- } from "../chunk-2D2RT2DW.js";
9
+ } from "../chunk-2VOR4VLG.js";
10
10
  import {
11
11
  HttpClient
12
- } from "../chunk-PMBS2GFA.js";
12
+ } from "../chunk-LFUC4ETD.js";
13
13
  import {
14
14
  LocalStorageClient
15
- } from "../chunk-XH4OLKBV.js";
15
+ } from "../chunk-7U5JDFQW.js";
16
16
  import {
17
17
  WebSocketClient
18
- } from "../chunk-C2ZIFM22.js";
18
+ } from "../chunk-T43IWAQK.js";
19
19
  import "../chunk-MLKGABMK.js";
20
20
  export {
21
21
  AppsClient,
@@ -198,8 +198,8 @@ interface LocalStorageClientConfig {
198
198
  */
199
199
  declare class ClientError extends Error {
200
200
  readonly code: string;
201
- readonly details?: unknown;
202
- constructor(message: string, code: string, details?: unknown);
201
+ readonly details?: unknown | undefined;
202
+ constructor(message: string, code: string, details?: unknown | undefined);
203
203
  }
204
204
  /**
205
205
  * WebSocket protocol types for request/response communication