@trust-proto/auth-node 0.1.0 → 0.2.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.
- package/dist/index.cjs +1346 -0
- package/dist/index.d.cts +423 -0
- package/dist/index.js +3 -1
- package/package.json +15 -15
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Blockchain configuration constants
|
|
3
|
+
* Supports production and development environments
|
|
4
|
+
*/
|
|
5
|
+
/** Environment type */
|
|
6
|
+
type Environment = 'production' | 'development';
|
|
7
|
+
/** Network configuration interface */
|
|
8
|
+
interface NetworkConfig {
|
|
9
|
+
RPC_ENDPOINT: string;
|
|
10
|
+
USER_CONTRACT_ADDRESS: string;
|
|
11
|
+
IPFS_GATEWAY: string;
|
|
12
|
+
TRUST_GATE_URL: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Get network configuration for specified environment
|
|
16
|
+
* @param env - Environment ('production' | 'development'), default: 'production'
|
|
17
|
+
* @returns Network configuration object
|
|
18
|
+
*/
|
|
19
|
+
declare function getNetworkConfig(env?: Environment): NetworkConfig;
|
|
20
|
+
/** User contract ABI (minimal for tokenURI) */
|
|
21
|
+
declare const USER_CONTRACT_ABI: readonly [{
|
|
22
|
+
readonly inputs: readonly [{
|
|
23
|
+
readonly internalType: "address";
|
|
24
|
+
readonly name: "tokenId";
|
|
25
|
+
readonly type: "address";
|
|
26
|
+
}];
|
|
27
|
+
readonly name: "tokenURI";
|
|
28
|
+
readonly outputs: readonly [{
|
|
29
|
+
readonly internalType: "string";
|
|
30
|
+
readonly name: "";
|
|
31
|
+
readonly type: "string";
|
|
32
|
+
}];
|
|
33
|
+
readonly stateMutability: "view";
|
|
34
|
+
readonly type: "function";
|
|
35
|
+
}];
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Liberion Auth Backend SDK Types
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Logger interface for dependency injection
|
|
43
|
+
*/
|
|
44
|
+
interface ILogger {
|
|
45
|
+
info(message: string, meta?: Record<string, unknown>): void;
|
|
46
|
+
warn(message: string, meta?: Record<string, unknown>): void;
|
|
47
|
+
error(message: string, meta?: Record<string, unknown>): void;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* User SNFT token structure from IPFS
|
|
51
|
+
*/
|
|
52
|
+
interface UserToken {
|
|
53
|
+
/** ML-DSA-87 public key (base64 encoded, 2592 bytes decoded) */
|
|
54
|
+
publicKeySign: string;
|
|
55
|
+
/** ML-KEM-1024 public key (base64 encoded, 1568 bytes decoded) */
|
|
56
|
+
publicKeyEncrypt: string;
|
|
57
|
+
/** Optional KYC assets */
|
|
58
|
+
assets?: Record<string, unknown>;
|
|
59
|
+
/** Additional token properties */
|
|
60
|
+
[key: string]: unknown;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* SSL credentials for HTTPS server
|
|
64
|
+
*/
|
|
65
|
+
interface SSLCredentials {
|
|
66
|
+
key: string;
|
|
67
|
+
cert: string;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Decline reason categories
|
|
71
|
+
*/
|
|
72
|
+
type DeclineReason = 'user_declined' | 'timeout' | 'error' | 'unknown';
|
|
73
|
+
/**
|
|
74
|
+
* Information about declined authorization
|
|
75
|
+
*/
|
|
76
|
+
interface DeclineInfo {
|
|
77
|
+
/** User wallet address (null if declined before activation) */
|
|
78
|
+
address: string | null;
|
|
79
|
+
/** Standardized decline reason */
|
|
80
|
+
reason: DeclineReason;
|
|
81
|
+
/** Detailed message */
|
|
82
|
+
message: string;
|
|
83
|
+
/** Who initiated the decline */
|
|
84
|
+
declinedBy: 'wallet' | 'browser';
|
|
85
|
+
/** Session identifier */
|
|
86
|
+
sessionId: string;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Payload received on successful authorization
|
|
90
|
+
*/
|
|
91
|
+
interface AuthPayload {
|
|
92
|
+
/** User wallet address */
|
|
93
|
+
address: string;
|
|
94
|
+
/** KYC fields provided by user */
|
|
95
|
+
fields: Record<string, unknown>;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Result returned from onSuccess callback
|
|
99
|
+
*/
|
|
100
|
+
interface AuthResult {
|
|
101
|
+
/** JWT token for authenticated user */
|
|
102
|
+
token?: string;
|
|
103
|
+
/** Error message if authentication failed */
|
|
104
|
+
error?: string;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Main configuration for LiberionAuth
|
|
108
|
+
*/
|
|
109
|
+
interface LiberionAuthConfig {
|
|
110
|
+
/** Project UUID from Liberion dashboard */
|
|
111
|
+
projectId: string;
|
|
112
|
+
/** Secret code for AES-256-CBC encryption */
|
|
113
|
+
secretCode: string;
|
|
114
|
+
/** WebSocket server port (default: 31313) */
|
|
115
|
+
port?: number;
|
|
116
|
+
/** Enable debug logging (default: false) */
|
|
117
|
+
debug?: boolean;
|
|
118
|
+
/** SSL credentials for HTTPS (default: undefined, use HTTP) */
|
|
119
|
+
ssl?: SSLCredentials;
|
|
120
|
+
/** Environment: 'production' or 'development' (default: 'production') */
|
|
121
|
+
environment?: Environment;
|
|
122
|
+
/** Logger instance (default: NoOpLogger) */
|
|
123
|
+
logger?: ILogger;
|
|
124
|
+
/**
|
|
125
|
+
* Called when wallet activates (scans QR)
|
|
126
|
+
* @param address - User wallet address
|
|
127
|
+
* @returns true if user is registered, false otherwise
|
|
128
|
+
*/
|
|
129
|
+
onHello?: (address: string) => Promise<boolean>;
|
|
130
|
+
/**
|
|
131
|
+
* Called on successful authorization
|
|
132
|
+
* @param payload - Contains address and KYC fields
|
|
133
|
+
* @returns Object with token or error
|
|
134
|
+
*/
|
|
135
|
+
onSuccess?: (payload: AuthPayload) => Promise<AuthResult>;
|
|
136
|
+
/**
|
|
137
|
+
* Called when authorization is declined
|
|
138
|
+
* @param info - Decline details including reason and who declined
|
|
139
|
+
*/
|
|
140
|
+
onDecline?: (info: DeclineInfo) => Promise<void>;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Session data stored for each connected client
|
|
144
|
+
*/
|
|
145
|
+
interface Session {
|
|
146
|
+
/** WebSocket client reference */
|
|
147
|
+
client: unknown;
|
|
148
|
+
/** Session UUID (for browser-wallet linking) */
|
|
149
|
+
sessionId: string | null;
|
|
150
|
+
/** User wallet address (set after activation) */
|
|
151
|
+
address: string | null;
|
|
152
|
+
/** Client session ID (for wallet auth) */
|
|
153
|
+
clientSessionId: string | null;
|
|
154
|
+
/** True if this is a browser session */
|
|
155
|
+
isBrowserSession: boolean;
|
|
156
|
+
/** Stored auth result for reconnect scenario */
|
|
157
|
+
authResult?: {
|
|
158
|
+
token: string;
|
|
159
|
+
};
|
|
160
|
+
/** Stored decline result for reconnect scenario */
|
|
161
|
+
declineResult?: {
|
|
162
|
+
message: string;
|
|
163
|
+
};
|
|
164
|
+
/** Authorization timeout handle */
|
|
165
|
+
timeout?: NodeJS.Timeout;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Crypto instance for signature verification
|
|
169
|
+
*/
|
|
170
|
+
interface CryptoInstance {
|
|
171
|
+
/** ML-DSA-87 public key */
|
|
172
|
+
dsaPublicKey: Uint8Array;
|
|
173
|
+
/** ML-KEM-1024 public key (optional) */
|
|
174
|
+
kemPublicKey: Uint8Array | null;
|
|
175
|
+
/** Algorithm identifier */
|
|
176
|
+
algorithm: string;
|
|
177
|
+
/** Original user token */
|
|
178
|
+
userToken: UserToken;
|
|
179
|
+
/**
|
|
180
|
+
* Verify ML-DSA-87 signature
|
|
181
|
+
* @param msg - Message that was signed
|
|
182
|
+
* @param signature - ML-DSA-87 signature
|
|
183
|
+
* @returns true if signature is valid
|
|
184
|
+
*/
|
|
185
|
+
verifySignature: (msg: Buffer | Uint8Array, sig: Buffer | Uint8Array) => boolean;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* LiberionAuth - Main SDK class for Liberion authentication
|
|
190
|
+
* Creates a WebSocket server that handles browser and wallet connections
|
|
191
|
+
*/
|
|
192
|
+
|
|
193
|
+
declare class LiberionAuth {
|
|
194
|
+
private logger;
|
|
195
|
+
private projectId;
|
|
196
|
+
private secretCode;
|
|
197
|
+
private networkConfig;
|
|
198
|
+
private sessions;
|
|
199
|
+
private interval;
|
|
200
|
+
private onHello?;
|
|
201
|
+
private onSuccess?;
|
|
202
|
+
private onDecline?;
|
|
203
|
+
static readonly COMMAND_AUTH = "auth";
|
|
204
|
+
static readonly COMMAND_READY = "ready";
|
|
205
|
+
constructor(config: LiberionAuthConfig);
|
|
206
|
+
private encode;
|
|
207
|
+
private decode;
|
|
208
|
+
private request;
|
|
209
|
+
private send;
|
|
210
|
+
private readMessage;
|
|
211
|
+
private newClient;
|
|
212
|
+
private handleClose;
|
|
213
|
+
private responseInit;
|
|
214
|
+
private responseActivate;
|
|
215
|
+
private responseAuth;
|
|
216
|
+
private responseDeclined;
|
|
217
|
+
private responseReconnect;
|
|
218
|
+
private responseFailed;
|
|
219
|
+
private errorResponse;
|
|
220
|
+
private finalResponse;
|
|
221
|
+
private finalizeSession;
|
|
222
|
+
private closeClient;
|
|
223
|
+
private findSession;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Logger adapters for dependency injection
|
|
228
|
+
*/
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* No-operation logger - default when no logger provided
|
|
232
|
+
* Silently ignores all log calls
|
|
233
|
+
*/
|
|
234
|
+
declare class NoOpLogger implements ILogger {
|
|
235
|
+
info(): void;
|
|
236
|
+
warn(): void;
|
|
237
|
+
error(): void;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Console logger for development/debugging
|
|
241
|
+
* Outputs to stdout/stderr with timestamps
|
|
242
|
+
*/
|
|
243
|
+
declare class ConsoleLogger implements ILogger {
|
|
244
|
+
private readonly prefix;
|
|
245
|
+
constructor(prefix?: string);
|
|
246
|
+
info(message: string, meta?: Record<string, unknown>): void;
|
|
247
|
+
warn(message: string, meta?: Record<string, unknown>): void;
|
|
248
|
+
error(message: string, meta?: Record<string, unknown>): void;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Create a logger adapter from Winston logger instance
|
|
252
|
+
* @param winston - Winston logger instance
|
|
253
|
+
* @returns ILogger compatible adapter
|
|
254
|
+
*
|
|
255
|
+
* @example
|
|
256
|
+
* ```typescript
|
|
257
|
+
* import { createWinstonAdapter } from '@trust-proto/auth-node';
|
|
258
|
+
* import { logger } from './my-winston-logger';
|
|
259
|
+
*
|
|
260
|
+
* const auth = new LiberionAuth({
|
|
261
|
+
* logger: createWinstonAdapter(logger),
|
|
262
|
+
* // ...
|
|
263
|
+
* });
|
|
264
|
+
* ```
|
|
265
|
+
*/
|
|
266
|
+
declare function createWinstonAdapter(winston: {
|
|
267
|
+
info: (message: string, meta?: Record<string, unknown>) => void;
|
|
268
|
+
warn: (message: string, meta?: Record<string, unknown>) => void;
|
|
269
|
+
error: (message: string, meta?: Record<string, unknown>) => void;
|
|
270
|
+
}): ILogger;
|
|
271
|
+
/**
|
|
272
|
+
* Shorten blockchain address for logging (privacy protection)
|
|
273
|
+
* @param address - Full blockchain address
|
|
274
|
+
* @returns Shortened address like "0x1234...abcd"
|
|
275
|
+
*/
|
|
276
|
+
declare function shortenAddress(address: string | null | undefined): string;
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* AES-256-CBC encryption utilities
|
|
280
|
+
*/
|
|
281
|
+
/**
|
|
282
|
+
* Encrypt buffer using AES-256-CBC
|
|
283
|
+
* @param buffer - Data to encrypt
|
|
284
|
+
* @param key - Encryption key (will be hashed to 32 bytes)
|
|
285
|
+
* @returns Encrypted buffer with IV prepended (16 bytes IV + encrypted data)
|
|
286
|
+
*/
|
|
287
|
+
declare function encryptBuffer(buffer: Buffer, key: string): Buffer;
|
|
288
|
+
/**
|
|
289
|
+
* Decrypt buffer using AES-256-CBC
|
|
290
|
+
* @param data - Encrypted data (16 bytes IV + encrypted data)
|
|
291
|
+
* @param key - Decryption key (will be hashed to 32 bytes)
|
|
292
|
+
* @returns Decrypted buffer
|
|
293
|
+
*/
|
|
294
|
+
declare function decryptBuffer(data: Buffer, key: string): Buffer;
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Post-Quantum Cryptography utility class
|
|
298
|
+
* Implements hybrid encryption: ML-KEM-1024 + XChaCha20-Poly1305 + ML-DSA-87
|
|
299
|
+
*/
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Post-Quantum Cryptography utility class
|
|
303
|
+
* Used by Trust Gate to:
|
|
304
|
+
* 1. Generate temporary session keys
|
|
305
|
+
* 2. Encrypt data for Wallet using user's public keys
|
|
306
|
+
* 3. Sign KEM ciphertext for authenticity
|
|
307
|
+
*
|
|
308
|
+
* Format matches client (cipher.js):
|
|
309
|
+
* version (1) + header (4) + sigLen (4) + signature + cipherText + nonce (24) + ct
|
|
310
|
+
*/
|
|
311
|
+
declare class PQCrypto {
|
|
312
|
+
private logger;
|
|
313
|
+
private _kemPrivateKey;
|
|
314
|
+
private kemPublicKey;
|
|
315
|
+
private dsaPrivateKey;
|
|
316
|
+
private dsaPublicKey;
|
|
317
|
+
private peerKEMPublicKey;
|
|
318
|
+
private peerDSAPublicKey;
|
|
319
|
+
constructor(logger?: ILogger);
|
|
320
|
+
/**
|
|
321
|
+
* Generate Trust Gate session keys from cryptographic seed
|
|
322
|
+
* @param seed - Random seed (at least 96 bytes: 64 for ML-KEM + 32 for ML-DSA)
|
|
323
|
+
*/
|
|
324
|
+
generateKeysFromSeed(seed: Uint8Array): Promise<void>;
|
|
325
|
+
/**
|
|
326
|
+
* Import peer's (user) public keys for encryption and verification
|
|
327
|
+
* @param kemPublicKey - ML-KEM-1024 public key (1568 bytes)
|
|
328
|
+
* @param dsaPublicKey - ML-DSA-87 public key (2592 bytes)
|
|
329
|
+
*/
|
|
330
|
+
importPeerPublicKeys(kemPublicKey: Uint8Array | Buffer, dsaPublicKey: Uint8Array | Buffer): void;
|
|
331
|
+
/**
|
|
332
|
+
* Hybrid encryption: ML-KEM + XChaCha20-Poly1305 + ML-DSA signature
|
|
333
|
+
* Matches client format: version + header + sigLen + signature + cipherText + nonce + ct
|
|
334
|
+
* @param message - Data to encrypt
|
|
335
|
+
* @returns Encrypted package in client-compatible format
|
|
336
|
+
*/
|
|
337
|
+
encrypt(message: ArrayBuffer | Uint8Array | Buffer): Promise<Buffer>;
|
|
338
|
+
/**
|
|
339
|
+
* Check if keys have been generated
|
|
340
|
+
*/
|
|
341
|
+
hasKeys(): boolean;
|
|
342
|
+
/**
|
|
343
|
+
* Export Trust Gate public keys (for sending to client)
|
|
344
|
+
* @returns Object with publicKeyEncrypt and publicKeySign as Buffers
|
|
345
|
+
*/
|
|
346
|
+
exportKeys(): {
|
|
347
|
+
publicKeyEncrypt: Buffer;
|
|
348
|
+
publicKeySign: Buffer;
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* ML-DSA-87 signature verification utilities
|
|
354
|
+
*/
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Initialize user crypto instance from SNFT token
|
|
358
|
+
* Parses ML-DSA-87 and ML-KEM-1024 public keys from base64-encoded token
|
|
359
|
+
*
|
|
360
|
+
* @param userToken - SNFT token with publicKeySign and publicKeyEncrypt (base64)
|
|
361
|
+
* @param logger - Optional logger instance
|
|
362
|
+
* @returns Crypto instance for signature verification
|
|
363
|
+
*/
|
|
364
|
+
declare function initUserCrypto(userToken: UserToken, logger?: ILogger): CryptoInstance;
|
|
365
|
+
/**
|
|
366
|
+
* Verify ML-DSA-87 signature of data
|
|
367
|
+
*
|
|
368
|
+
* @param crypto - Crypto instance from initUserCrypto
|
|
369
|
+
* @param data - Data that was signed
|
|
370
|
+
* @param signature - ML-DSA-87 signature (~4595 bytes)
|
|
371
|
+
* @param logger - Optional logger instance
|
|
372
|
+
* @returns true if signature is valid
|
|
373
|
+
* @throws Error if verification fails
|
|
374
|
+
*/
|
|
375
|
+
declare function checkSignature(crypto: CryptoInstance, data: Buffer | Uint8Array | ArrayBuffer | string, signature: Buffer | Uint8Array | ArrayBuffer | string, logger?: ILogger): boolean;
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* Token Provider - Fetches user SNFT tokens from blockchain and IPFS
|
|
379
|
+
*/
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* Extract IPFS hash from tokenURI
|
|
383
|
+
* Handles multiple formats:
|
|
384
|
+
* - ipfs://QmHash...
|
|
385
|
+
* - https://gateway.pinata.cloud/ipfs/QmHash...
|
|
386
|
+
* - https://secure.liberion.com/QmHash...
|
|
387
|
+
* - QmHash... (raw hash)
|
|
388
|
+
*/
|
|
389
|
+
declare function extractIpfsHash(tokenURI: string): string;
|
|
390
|
+
/**
|
|
391
|
+
* Get SNFT token from IPFS by user address
|
|
392
|
+
*
|
|
393
|
+
* @param address - User blockchain address
|
|
394
|
+
* @param logger - Optional logger instance
|
|
395
|
+
* @param networkConfig - Optional network configuration (defaults to production)
|
|
396
|
+
* @returns SNFT token object from IPFS
|
|
397
|
+
*/
|
|
398
|
+
declare function getTokenFromIPFS(address: string, logger?: ILogger, networkConfig?: NetworkConfig): Promise<UserToken>;
|
|
399
|
+
/**
|
|
400
|
+
* Clear the token cache (for testing or manual invalidation)
|
|
401
|
+
*/
|
|
402
|
+
declare function clearTokenCache(): void;
|
|
403
|
+
|
|
404
|
+
declare const COMMAND_READY = "ready";
|
|
405
|
+
declare const COMMAND_AUTH = "auth";
|
|
406
|
+
declare const COMMAND_AUTH_RESULT = "auth_result";
|
|
407
|
+
declare const COMMAND_ACTIVATED = "activated";
|
|
408
|
+
declare const COMMAND_AUTH_DECLINED = "declined";
|
|
409
|
+
declare const COMMAND_AUTH_TIMEOUT = "timeout";
|
|
410
|
+
declare const COMMAND_ERROR = "error";
|
|
411
|
+
declare const DEFAULT_PORT = 31313;
|
|
412
|
+
declare const STATUS: {
|
|
413
|
+
readonly OK: "ok";
|
|
414
|
+
readonly FAILED: "error";
|
|
415
|
+
};
|
|
416
|
+
declare const DECLINE_REASON: {
|
|
417
|
+
readonly USER: "user_declined";
|
|
418
|
+
readonly TIMEOUT: "timeout";
|
|
419
|
+
readonly ERROR: "error";
|
|
420
|
+
readonly UNKNOWN: "unknown";
|
|
421
|
+
};
|
|
422
|
+
|
|
423
|
+
export { type AuthPayload, type AuthResult, COMMAND_ACTIVATED, COMMAND_AUTH, COMMAND_AUTH_DECLINED, COMMAND_AUTH_RESULT, COMMAND_AUTH_TIMEOUT, COMMAND_ERROR, COMMAND_READY, ConsoleLogger, type CryptoInstance, DECLINE_REASON, DEFAULT_PORT, type DeclineInfo, type DeclineReason, type Environment, type ILogger, LiberionAuth, type LiberionAuthConfig, type NetworkConfig, NoOpLogger, PQCrypto, type SSLCredentials, STATUS, type Session, USER_CONTRACT_ABI, type UserToken, checkSignature, clearTokenCache, createWinstonAdapter, decryptBuffer, encryptBuffer, extractIpfsHash, getNetworkConfig, getTokenFromIPFS, initUserCrypto, shortenAddress };
|
package/dist/index.js
CHANGED
|
@@ -1152,6 +1152,7 @@ var PQCrypto = class {
|
|
|
1152
1152
|
sharedSecretSize: sharedSecret.length
|
|
1153
1153
|
// 32 bytes
|
|
1154
1154
|
});
|
|
1155
|
+
const sharedSecretBuffer = Uint8Array.from(sharedSecret);
|
|
1155
1156
|
const secretKeyRaw = await subtle.deriveBits(
|
|
1156
1157
|
{
|
|
1157
1158
|
name: "HKDF",
|
|
@@ -1159,12 +1160,13 @@ var PQCrypto = class {
|
|
|
1159
1160
|
salt: PROTOCOL_AAD,
|
|
1160
1161
|
info: PROTOCOL_AAD
|
|
1161
1162
|
},
|
|
1162
|
-
await subtle.importKey("raw",
|
|
1163
|
+
await subtle.importKey("raw", sharedSecretBuffer, { name: "HKDF" }, false, [
|
|
1163
1164
|
"deriveBits"
|
|
1164
1165
|
]),
|
|
1165
1166
|
256
|
|
1166
1167
|
);
|
|
1167
1168
|
sharedSecret.fill(0);
|
|
1169
|
+
sharedSecretBuffer.fill(0);
|
|
1168
1170
|
const versionBuf = new Uint8Array([1]);
|
|
1169
1171
|
const header = new Uint8Array(4);
|
|
1170
1172
|
new DataView(header.buffer).setUint32(0, kemCiphertext.length, false);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trust-proto/auth-node",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Liberion Auth Backend SDK with post-quantum cryptography",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
11
|
-
"import": "./dist/index.js"
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"require": "./dist/index.cjs"
|
|
12
13
|
}
|
|
13
14
|
},
|
|
14
15
|
"files": [
|
|
@@ -41,33 +42,32 @@
|
|
|
41
42
|
},
|
|
42
43
|
"dependencies": {
|
|
43
44
|
"@msgpack/msgpack": "^3.1.2",
|
|
44
|
-
"@noble/post-quantum": "^0.5.
|
|
45
|
-
"ethers": "^6.
|
|
45
|
+
"@noble/post-quantum": "^0.5.3",
|
|
46
|
+
"ethers": "^6.16.0",
|
|
46
47
|
"libsodium-wrappers": "^0.7.15",
|
|
47
48
|
"uuid": "^13.0.0",
|
|
48
49
|
"ws": "^8.18.2"
|
|
49
50
|
},
|
|
50
51
|
"devDependencies": {
|
|
51
52
|
"@types/libsodium-wrappers": "^0.7.14",
|
|
52
|
-
"@types/node": "^
|
|
53
|
+
"@types/node": "^25.0.3",
|
|
53
54
|
"@types/ws": "^8.5.0",
|
|
54
|
-
"@vitest/coverage-v8": "^4.0.
|
|
55
|
+
"@vitest/coverage-v8": "^4.0.16",
|
|
55
56
|
"tsup": "^8.0.0",
|
|
56
57
|
"typescript": "^5.7.0",
|
|
57
|
-
"vitest": "^4.0.
|
|
58
|
+
"vitest": "^4.0.16"
|
|
59
|
+
},
|
|
60
|
+
"publishConfig": {
|
|
61
|
+
"access": "public"
|
|
58
62
|
},
|
|
59
63
|
"scripts": {
|
|
60
|
-
"build": "tsup src/index.ts --format esm --dts --clean",
|
|
61
|
-
"dev": "tsup src/index.ts --format esm --dts --watch",
|
|
64
|
+
"build": "tsup src/index.ts --format esm,cjs --dts --clean",
|
|
65
|
+
"dev": "tsup src/index.ts --format esm,cjs --dts --watch",
|
|
62
66
|
"test": "vitest --run",
|
|
63
67
|
"test:watch": "vitest",
|
|
64
68
|
"test:coverage": "vitest --run --coverage",
|
|
65
69
|
"lint": "tsc --noEmit",
|
|
66
70
|
"typecheck": "tsc --noEmit",
|
|
67
|
-
"clean": "rm -rf dist coverage"
|
|
68
|
-
"prepublishOnly": "pnpm run build"
|
|
69
|
-
},
|
|
70
|
-
"publishConfig": {
|
|
71
|
-
"access": "public"
|
|
71
|
+
"clean": "rm -rf dist coverage"
|
|
72
72
|
}
|
|
73
|
-
}
|
|
73
|
+
}
|