simple-crypto-utils 1.0.3 → 2.0.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/dist/index.cjs +35 -61
- package/dist/index.d.cts +2 -49
- package/dist/index.d.ts +2 -49
- package/dist/index.js +18 -61
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -20,11 +20,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
Key: () => Key,
|
|
23
24
|
LIBRARY_VERSION: () => LIBRARY_VERSION,
|
|
24
25
|
MAX_MESSAGE_AGE: () => MAX_MESSAGE_AGE,
|
|
25
26
|
MESSAGE_MAX_AGE_MS: () => MESSAGE_MAX_AGE_MS,
|
|
26
27
|
MINIMUM_PASSWORD_LENGTH: () => MINIMUM_PASSWORD_LENGTH,
|
|
27
28
|
MIN_PASSWORD_LENGTH: () => MIN_PASSWORD_LENGTH,
|
|
29
|
+
Signer: () => Signer,
|
|
28
30
|
VERSION: () => VERSION,
|
|
29
31
|
decrypt: () => decrypt,
|
|
30
32
|
decryptFile: () => decryptFile,
|
|
@@ -34,17 +36,26 @@ __export(index_exports, {
|
|
|
34
36
|
encrypt: () => encrypt,
|
|
35
37
|
encryptFileStreaming: () => encryptFileStreaming,
|
|
36
38
|
encryptMessage: () => encryptMessage,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
envelope: () => envelope,
|
|
40
|
+
generateECDHKeyPair: () => generateECDHKeyPair,
|
|
41
|
+
generateOTP: () => generateOTP,
|
|
42
|
+
generatePassword: () => generatePassword,
|
|
43
|
+
generateRSAKeyPair: () => generateRSAKeyPair,
|
|
44
|
+
generateTOTP: () => generateTOTP,
|
|
45
|
+
generateUUID: () => generateUUID,
|
|
46
|
+
hash: () => hash,
|
|
47
|
+
hashHmac: () => hashHmac,
|
|
48
|
+
hashPassword: () => hashPassword,
|
|
49
|
+
openEnvelope: () => openEnvelope,
|
|
50
|
+
sign: () => sign2,
|
|
43
51
|
validatePassword: () => validatePassword,
|
|
44
52
|
validatePrivateKey: () => validatePrivateKey,
|
|
45
53
|
validatePublicKey: () => validatePublicKey,
|
|
46
54
|
validateTimestamp: () => validateTimestamp,
|
|
47
|
-
validateVersion: () => validateVersion
|
|
55
|
+
validateVersion: () => validateVersion,
|
|
56
|
+
verify: () => verify,
|
|
57
|
+
verifyHmac: () => verifyHmac,
|
|
58
|
+
verifyPassword: () => verifyPassword
|
|
48
59
|
});
|
|
49
60
|
module.exports = __toCommonJS(index_exports);
|
|
50
61
|
|
|
@@ -463,14 +474,6 @@ function deriveAESKeyForEncryption(recipientPublicKeyStr) {
|
|
|
463
474
|
};
|
|
464
475
|
}
|
|
465
476
|
|
|
466
|
-
// src/password/index.ts
|
|
467
|
-
var password_exports = {};
|
|
468
|
-
__export(password_exports, {
|
|
469
|
-
generatePassword: () => generatePassword,
|
|
470
|
-
hashPassword: () => hashPassword,
|
|
471
|
-
verifyPassword: () => verifyPassword
|
|
472
|
-
});
|
|
473
|
-
|
|
474
477
|
// src/password/generate.ts
|
|
475
478
|
var import_crypto2 = require("crypto");
|
|
476
479
|
var charsetMap = {
|
|
@@ -546,29 +549,12 @@ async function verifyPassword(password, storedHash) {
|
|
|
546
549
|
return diff === 0;
|
|
547
550
|
}
|
|
548
551
|
|
|
549
|
-
// src/uuid/index.ts
|
|
550
|
-
var uuid_exports = {};
|
|
551
|
-
__export(uuid_exports, {
|
|
552
|
-
generateUUID: () => generateUUID
|
|
553
|
-
});
|
|
554
|
-
|
|
555
552
|
// src/uuid/generate.ts
|
|
556
553
|
var import_crypto5 = require("crypto");
|
|
557
554
|
function generateUUID() {
|
|
558
555
|
return (0, import_crypto5.randomUUID)();
|
|
559
556
|
}
|
|
560
557
|
|
|
561
|
-
// src/signature/index.ts
|
|
562
|
-
var signature_exports = {};
|
|
563
|
-
__export(signature_exports, {
|
|
564
|
-
Signer: () => Signer,
|
|
565
|
-
default: () => Signer,
|
|
566
|
-
envelope: () => envelope,
|
|
567
|
-
openEnvelope: () => openEnvelope,
|
|
568
|
-
sign: () => sign2,
|
|
569
|
-
verify: () => verify
|
|
570
|
-
});
|
|
571
|
-
|
|
572
558
|
// src/signature/sign.ts
|
|
573
559
|
var import_crypto6 = require("crypto");
|
|
574
560
|
|
|
@@ -875,14 +861,6 @@ var defaultSigner = new Signer();
|
|
|
875
861
|
var envelope = defaultSigner.envelope.bind(defaultSigner);
|
|
876
862
|
var openEnvelope = defaultSigner.openEnvelope.bind(defaultSigner);
|
|
877
863
|
|
|
878
|
-
// src/hash/index.ts
|
|
879
|
-
var hash_exports = {};
|
|
880
|
-
__export(hash_exports, {
|
|
881
|
-
hash: () => hash,
|
|
882
|
-
hashHmac: () => hashHmac,
|
|
883
|
-
verifyHmac: () => verifyHmac
|
|
884
|
-
});
|
|
885
|
-
|
|
886
864
|
// src/hash/hash.ts
|
|
887
865
|
var import_crypto8 = require("crypto");
|
|
888
866
|
function hash(data) {
|
|
@@ -908,14 +886,6 @@ function verifyHmac(secret, data, expectedHex) {
|
|
|
908
886
|
return (0, import_crypto10.timingSafeEqual)(actual, expected);
|
|
909
887
|
}
|
|
910
888
|
|
|
911
|
-
// src/keys/index.ts
|
|
912
|
-
var keys_exports = {};
|
|
913
|
-
__export(keys_exports, {
|
|
914
|
-
Key: () => Key,
|
|
915
|
-
generateECDHKeyPair: () => generateECDHKeyPair,
|
|
916
|
-
generateRSAKeyPair: () => generateRSAKeyPair
|
|
917
|
-
});
|
|
918
|
-
|
|
919
889
|
// src/keys/rsa.ts
|
|
920
890
|
var import_crypto11 = require("crypto");
|
|
921
891
|
function generateRSAKeyPair() {
|
|
@@ -1068,13 +1038,6 @@ var Key = class _Key {
|
|
|
1068
1038
|
}
|
|
1069
1039
|
};
|
|
1070
1040
|
|
|
1071
|
-
// src/otp/index.ts
|
|
1072
|
-
var otp_exports = {};
|
|
1073
|
-
__export(otp_exports, {
|
|
1074
|
-
generateOTP: () => generateOTP,
|
|
1075
|
-
generateTOTP: () => generateTOTP
|
|
1076
|
-
});
|
|
1077
|
-
|
|
1078
1041
|
// src/otp/totp.ts
|
|
1079
1042
|
var import_crypto15 = require("crypto");
|
|
1080
1043
|
function base32ToBuffer(base32) {
|
|
@@ -1541,11 +1504,13 @@ var MINIMUM_PASSWORD_LENGTH = MIN_PASSWORD_LENGTH;
|
|
|
1541
1504
|
var MAX_MESSAGE_AGE = MESSAGE_MAX_AGE_MS;
|
|
1542
1505
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1543
1506
|
0 && (module.exports = {
|
|
1507
|
+
Key,
|
|
1544
1508
|
LIBRARY_VERSION,
|
|
1545
1509
|
MAX_MESSAGE_AGE,
|
|
1546
1510
|
MESSAGE_MAX_AGE_MS,
|
|
1547
1511
|
MINIMUM_PASSWORD_LENGTH,
|
|
1548
1512
|
MIN_PASSWORD_LENGTH,
|
|
1513
|
+
Signer,
|
|
1549
1514
|
VERSION,
|
|
1550
1515
|
decrypt,
|
|
1551
1516
|
decryptFile,
|
|
@@ -1555,15 +1520,24 @@ var MAX_MESSAGE_AGE = MESSAGE_MAX_AGE_MS;
|
|
|
1555
1520
|
encrypt,
|
|
1556
1521
|
encryptFileStreaming,
|
|
1557
1522
|
encryptMessage,
|
|
1523
|
+
envelope,
|
|
1524
|
+
generateECDHKeyPair,
|
|
1525
|
+
generateOTP,
|
|
1526
|
+
generatePassword,
|
|
1527
|
+
generateRSAKeyPair,
|
|
1528
|
+
generateTOTP,
|
|
1529
|
+
generateUUID,
|
|
1558
1530
|
hash,
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
uuid,
|
|
1531
|
+
hashHmac,
|
|
1532
|
+
hashPassword,
|
|
1533
|
+
openEnvelope,
|
|
1534
|
+
sign,
|
|
1564
1535
|
validatePassword,
|
|
1565
1536
|
validatePrivateKey,
|
|
1566
1537
|
validatePublicKey,
|
|
1567
1538
|
validateTimestamp,
|
|
1568
|
-
validateVersion
|
|
1539
|
+
validateVersion,
|
|
1540
|
+
verify,
|
|
1541
|
+
verifyHmac,
|
|
1542
|
+
verifyPassword
|
|
1569
1543
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -78,13 +78,6 @@ declare function hashPassword(password: string): Promise<string>;
|
|
|
78
78
|
*/
|
|
79
79
|
declare function verifyPassword(password: string, storedHash: string): Promise<boolean>;
|
|
80
80
|
|
|
81
|
-
declare const index$5_generatePassword: typeof generatePassword;
|
|
82
|
-
declare const index$5_hashPassword: typeof hashPassword;
|
|
83
|
-
declare const index$5_verifyPassword: typeof verifyPassword;
|
|
84
|
-
declare namespace index$5 {
|
|
85
|
-
export { index$5_generatePassword as generatePassword, index$5_hashPassword as hashPassword, index$5_verifyPassword as verifyPassword };
|
|
86
|
-
}
|
|
87
|
-
|
|
88
81
|
/**
|
|
89
82
|
* Generates a cryptographically secure UUID (version 4).
|
|
90
83
|
*
|
|
@@ -100,11 +93,6 @@ declare namespace index$5 {
|
|
|
100
93
|
*/
|
|
101
94
|
declare function generateUUID(): string;
|
|
102
95
|
|
|
103
|
-
declare const index$4_generateUUID: typeof generateUUID;
|
|
104
|
-
declare namespace index$4 {
|
|
105
|
-
export { index$4_generateUUID as generateUUID };
|
|
106
|
-
}
|
|
107
|
-
|
|
108
96
|
type SerializationStrategy = "canonical" | "raw" | "selective";
|
|
109
97
|
interface SignOptions {
|
|
110
98
|
/** Serialization strategy for complex objects */
|
|
@@ -299,19 +287,6 @@ declare const openEnvelope: (envelope: {
|
|
|
299
287
|
data: any;
|
|
300
288
|
};
|
|
301
289
|
|
|
302
|
-
type index$3_SerializationStrategy = SerializationStrategy;
|
|
303
|
-
type index$3_SignOptions = SignOptions;
|
|
304
|
-
type index$3_Signer = Signer;
|
|
305
|
-
declare const index$3_Signer: typeof Signer;
|
|
306
|
-
type index$3_VerifyOptions = VerifyOptions;
|
|
307
|
-
declare const index$3_envelope: typeof envelope;
|
|
308
|
-
declare const index$3_openEnvelope: typeof openEnvelope;
|
|
309
|
-
declare const index$3_sign: typeof sign;
|
|
310
|
-
declare const index$3_verify: typeof verify;
|
|
311
|
-
declare namespace index$3 {
|
|
312
|
-
export { type index$3_SerializationStrategy as SerializationStrategy, type index$3_SignOptions as SignOptions, index$3_Signer as Signer, type index$3_VerifyOptions as VerifyOptions, Signer as default, index$3_envelope as envelope, index$3_openEnvelope as openEnvelope, index$3_sign as sign, index$3_verify as verify };
|
|
313
|
-
}
|
|
314
|
-
|
|
315
290
|
/**
|
|
316
291
|
* Computes the SHA-256 hash of a given string.
|
|
317
292
|
*
|
|
@@ -379,13 +354,6 @@ declare function hashHmac(secret: string, data: string): string;
|
|
|
379
354
|
*/
|
|
380
355
|
declare function verifyHmac(secret: string, data: string, expectedHex: string): boolean;
|
|
381
356
|
|
|
382
|
-
declare const index$2_hash: typeof hash;
|
|
383
|
-
declare const index$2_hashHmac: typeof hashHmac;
|
|
384
|
-
declare const index$2_verifyHmac: typeof verifyHmac;
|
|
385
|
-
declare namespace index$2 {
|
|
386
|
-
export { index$2_hash as hash, index$2_hashHmac as hashHmac, index$2_verifyHmac as verifyHmac };
|
|
387
|
-
}
|
|
388
|
-
|
|
389
357
|
/**
|
|
390
358
|
* Generates an X25519 key pair for Elliptic Curve Diffie-Hellman (ECDH).
|
|
391
359
|
*
|
|
@@ -493,15 +461,6 @@ declare class Key {
|
|
|
493
461
|
static generate(key: keyType): Promise<Key>;
|
|
494
462
|
}
|
|
495
463
|
|
|
496
|
-
type index$1_Key = Key;
|
|
497
|
-
declare const index$1_Key: typeof Key;
|
|
498
|
-
declare const index$1_generateECDHKeyPair: typeof generateECDHKeyPair;
|
|
499
|
-
declare const index$1_generateRSAKeyPair: typeof generateRSAKeyPair;
|
|
500
|
-
type index$1_keyType = keyType;
|
|
501
|
-
declare namespace index$1 {
|
|
502
|
-
export { index$1_Key as Key, index$1_generateECDHKeyPair as generateECDHKeyPair, index$1_generateRSAKeyPair as generateRSAKeyPair, type index$1_keyType as keyType };
|
|
503
|
-
}
|
|
504
|
-
|
|
505
464
|
/**
|
|
506
465
|
* Generates a Time-based One-Time Password (TOTP) according to RFC 6238.
|
|
507
466
|
*
|
|
@@ -547,12 +506,6 @@ declare function generateTOTP(secret: string, digits?: number, period?: number,
|
|
|
547
506
|
*/
|
|
548
507
|
declare function generateOTP(length?: number): string;
|
|
549
508
|
|
|
550
|
-
declare const index_generateOTP: typeof generateOTP;
|
|
551
|
-
declare const index_generateTOTP: typeof generateTOTP;
|
|
552
|
-
declare namespace index {
|
|
553
|
-
export { index_generateOTP as generateOTP, index_generateTOTP as generateTOTP };
|
|
554
|
-
}
|
|
555
|
-
|
|
556
509
|
declare const VERSION = 1;
|
|
557
510
|
declare const MIN_PASSWORD_LENGTH = 12;
|
|
558
511
|
declare const MESSAGE_MAX_AGE_MS: number;
|
|
@@ -1045,7 +998,7 @@ declare function deriveAESKeyForDecryption(recipientPrivateKeyStr: string, ephem
|
|
|
1045
998
|
* - Digital signatures (Ed25519)
|
|
1046
999
|
* - Forward secrecy
|
|
1047
1000
|
* - Replay attack prevention
|
|
1048
|
-
*
|
|
1001
|
+
*
|
|
1049
1002
|
* @module crypto-utils
|
|
1050
1003
|
* @version 1.0.0
|
|
1051
1004
|
*/
|
|
@@ -1128,4 +1081,4 @@ declare const LIBRARY_VERSION = 1;
|
|
|
1128
1081
|
declare const MINIMUM_PASSWORD_LENGTH = 12;
|
|
1129
1082
|
declare const MAX_MESSAGE_AGE: number;
|
|
1130
1083
|
|
|
1131
|
-
export { type AuthenticatedChannelOptions, type AuthenticatedKeySet, type DecryptAuthenticatedOptions, type DecryptEnvelopeOptions, type DecryptOptions, type DecryptResult, type DecryptSecureChannelOptions, type DecryptSymmetricOptions, type EncryptOptions, type EncryptResult, type KeyPair, LIBRARY_VERSION, MAX_MESSAGE_AGE, MESSAGE_MAX_AGE_MS, MINIMUM_PASSWORD_LENGTH, MIN_PASSWORD_LENGTH, type SealEnvelopeOptions, type SecureChannelOptions, type SymmetricPasswordOptions, VERSION, decrypt, decryptFile, decryptMessage, deriveAESKeyForDecryption, deriveAESKeyForEncryption, encrypt, encryptFileStreaming, encryptMessage,
|
|
1084
|
+
export { type AuthenticatedChannelOptions, type AuthenticatedKeySet, type DecryptAuthenticatedOptions, type DecryptEnvelopeOptions, type DecryptOptions, type DecryptResult, type DecryptSecureChannelOptions, type DecryptSymmetricOptions, type EncryptOptions, type EncryptResult, Key, type KeyPair, LIBRARY_VERSION, MAX_MESSAGE_AGE, MESSAGE_MAX_AGE_MS, MINIMUM_PASSWORD_LENGTH, MIN_PASSWORD_LENGTH, type SealEnvelopeOptions, type SecureChannelOptions, type SerializationStrategy, type SignOptions, Signer, type SymmetricPasswordOptions, VERSION, type VerifyOptions, decrypt, decryptFile, decryptMessage, deriveAESKeyForDecryption, deriveAESKeyForEncryption, encrypt, encryptFileStreaming, encryptMessage, envelope, generateECDHKeyPair, generateOTP, generatePassword, generateRSAKeyPair, generateTOTP, generateUUID, hash, hashHmac, hashPassword, type keyType, openEnvelope, sign, validatePassword, validatePrivateKey, validatePublicKey, validateTimestamp, validateVersion, verify, verifyHmac, verifyPassword };
|
package/dist/index.d.ts
CHANGED
|
@@ -78,13 +78,6 @@ declare function hashPassword(password: string): Promise<string>;
|
|
|
78
78
|
*/
|
|
79
79
|
declare function verifyPassword(password: string, storedHash: string): Promise<boolean>;
|
|
80
80
|
|
|
81
|
-
declare const index$5_generatePassword: typeof generatePassword;
|
|
82
|
-
declare const index$5_hashPassword: typeof hashPassword;
|
|
83
|
-
declare const index$5_verifyPassword: typeof verifyPassword;
|
|
84
|
-
declare namespace index$5 {
|
|
85
|
-
export { index$5_generatePassword as generatePassword, index$5_hashPassword as hashPassword, index$5_verifyPassword as verifyPassword };
|
|
86
|
-
}
|
|
87
|
-
|
|
88
81
|
/**
|
|
89
82
|
* Generates a cryptographically secure UUID (version 4).
|
|
90
83
|
*
|
|
@@ -100,11 +93,6 @@ declare namespace index$5 {
|
|
|
100
93
|
*/
|
|
101
94
|
declare function generateUUID(): string;
|
|
102
95
|
|
|
103
|
-
declare const index$4_generateUUID: typeof generateUUID;
|
|
104
|
-
declare namespace index$4 {
|
|
105
|
-
export { index$4_generateUUID as generateUUID };
|
|
106
|
-
}
|
|
107
|
-
|
|
108
96
|
type SerializationStrategy = "canonical" | "raw" | "selective";
|
|
109
97
|
interface SignOptions {
|
|
110
98
|
/** Serialization strategy for complex objects */
|
|
@@ -299,19 +287,6 @@ declare const openEnvelope: (envelope: {
|
|
|
299
287
|
data: any;
|
|
300
288
|
};
|
|
301
289
|
|
|
302
|
-
type index$3_SerializationStrategy = SerializationStrategy;
|
|
303
|
-
type index$3_SignOptions = SignOptions;
|
|
304
|
-
type index$3_Signer = Signer;
|
|
305
|
-
declare const index$3_Signer: typeof Signer;
|
|
306
|
-
type index$3_VerifyOptions = VerifyOptions;
|
|
307
|
-
declare const index$3_envelope: typeof envelope;
|
|
308
|
-
declare const index$3_openEnvelope: typeof openEnvelope;
|
|
309
|
-
declare const index$3_sign: typeof sign;
|
|
310
|
-
declare const index$3_verify: typeof verify;
|
|
311
|
-
declare namespace index$3 {
|
|
312
|
-
export { type index$3_SerializationStrategy as SerializationStrategy, type index$3_SignOptions as SignOptions, index$3_Signer as Signer, type index$3_VerifyOptions as VerifyOptions, Signer as default, index$3_envelope as envelope, index$3_openEnvelope as openEnvelope, index$3_sign as sign, index$3_verify as verify };
|
|
313
|
-
}
|
|
314
|
-
|
|
315
290
|
/**
|
|
316
291
|
* Computes the SHA-256 hash of a given string.
|
|
317
292
|
*
|
|
@@ -379,13 +354,6 @@ declare function hashHmac(secret: string, data: string): string;
|
|
|
379
354
|
*/
|
|
380
355
|
declare function verifyHmac(secret: string, data: string, expectedHex: string): boolean;
|
|
381
356
|
|
|
382
|
-
declare const index$2_hash: typeof hash;
|
|
383
|
-
declare const index$2_hashHmac: typeof hashHmac;
|
|
384
|
-
declare const index$2_verifyHmac: typeof verifyHmac;
|
|
385
|
-
declare namespace index$2 {
|
|
386
|
-
export { index$2_hash as hash, index$2_hashHmac as hashHmac, index$2_verifyHmac as verifyHmac };
|
|
387
|
-
}
|
|
388
|
-
|
|
389
357
|
/**
|
|
390
358
|
* Generates an X25519 key pair for Elliptic Curve Diffie-Hellman (ECDH).
|
|
391
359
|
*
|
|
@@ -493,15 +461,6 @@ declare class Key {
|
|
|
493
461
|
static generate(key: keyType): Promise<Key>;
|
|
494
462
|
}
|
|
495
463
|
|
|
496
|
-
type index$1_Key = Key;
|
|
497
|
-
declare const index$1_Key: typeof Key;
|
|
498
|
-
declare const index$1_generateECDHKeyPair: typeof generateECDHKeyPair;
|
|
499
|
-
declare const index$1_generateRSAKeyPair: typeof generateRSAKeyPair;
|
|
500
|
-
type index$1_keyType = keyType;
|
|
501
|
-
declare namespace index$1 {
|
|
502
|
-
export { index$1_Key as Key, index$1_generateECDHKeyPair as generateECDHKeyPair, index$1_generateRSAKeyPair as generateRSAKeyPair, type index$1_keyType as keyType };
|
|
503
|
-
}
|
|
504
|
-
|
|
505
464
|
/**
|
|
506
465
|
* Generates a Time-based One-Time Password (TOTP) according to RFC 6238.
|
|
507
466
|
*
|
|
@@ -547,12 +506,6 @@ declare function generateTOTP(secret: string, digits?: number, period?: number,
|
|
|
547
506
|
*/
|
|
548
507
|
declare function generateOTP(length?: number): string;
|
|
549
508
|
|
|
550
|
-
declare const index_generateOTP: typeof generateOTP;
|
|
551
|
-
declare const index_generateTOTP: typeof generateTOTP;
|
|
552
|
-
declare namespace index {
|
|
553
|
-
export { index_generateOTP as generateOTP, index_generateTOTP as generateTOTP };
|
|
554
|
-
}
|
|
555
|
-
|
|
556
509
|
declare const VERSION = 1;
|
|
557
510
|
declare const MIN_PASSWORD_LENGTH = 12;
|
|
558
511
|
declare const MESSAGE_MAX_AGE_MS: number;
|
|
@@ -1045,7 +998,7 @@ declare function deriveAESKeyForDecryption(recipientPrivateKeyStr: string, ephem
|
|
|
1045
998
|
* - Digital signatures (Ed25519)
|
|
1046
999
|
* - Forward secrecy
|
|
1047
1000
|
* - Replay attack prevention
|
|
1048
|
-
*
|
|
1001
|
+
*
|
|
1049
1002
|
* @module crypto-utils
|
|
1050
1003
|
* @version 1.0.0
|
|
1051
1004
|
*/
|
|
@@ -1128,4 +1081,4 @@ declare const LIBRARY_VERSION = 1;
|
|
|
1128
1081
|
declare const MINIMUM_PASSWORD_LENGTH = 12;
|
|
1129
1082
|
declare const MAX_MESSAGE_AGE: number;
|
|
1130
1083
|
|
|
1131
|
-
export { type AuthenticatedChannelOptions, type AuthenticatedKeySet, type DecryptAuthenticatedOptions, type DecryptEnvelopeOptions, type DecryptOptions, type DecryptResult, type DecryptSecureChannelOptions, type DecryptSymmetricOptions, type EncryptOptions, type EncryptResult, type KeyPair, LIBRARY_VERSION, MAX_MESSAGE_AGE, MESSAGE_MAX_AGE_MS, MINIMUM_PASSWORD_LENGTH, MIN_PASSWORD_LENGTH, type SealEnvelopeOptions, type SecureChannelOptions, type SymmetricPasswordOptions, VERSION, decrypt, decryptFile, decryptMessage, deriveAESKeyForDecryption, deriveAESKeyForEncryption, encrypt, encryptFileStreaming, encryptMessage,
|
|
1084
|
+
export { type AuthenticatedChannelOptions, type AuthenticatedKeySet, type DecryptAuthenticatedOptions, type DecryptEnvelopeOptions, type DecryptOptions, type DecryptResult, type DecryptSecureChannelOptions, type DecryptSymmetricOptions, type EncryptOptions, type EncryptResult, Key, type KeyPair, LIBRARY_VERSION, MAX_MESSAGE_AGE, MESSAGE_MAX_AGE_MS, MINIMUM_PASSWORD_LENGTH, MIN_PASSWORD_LENGTH, type SealEnvelopeOptions, type SecureChannelOptions, type SerializationStrategy, type SignOptions, Signer, type SymmetricPasswordOptions, VERSION, type VerifyOptions, decrypt, decryptFile, decryptMessage, deriveAESKeyForDecryption, deriveAESKeyForEncryption, encrypt, encryptFileStreaming, encryptMessage, envelope, generateECDHKeyPair, generateOTP, generatePassword, generateRSAKeyPair, generateTOTP, generateUUID, hash, hashHmac, hashPassword, type keyType, openEnvelope, sign, validatePassword, validatePrivateKey, validatePublicKey, validateTimestamp, validateVersion, verify, verifyHmac, verifyPassword };
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __export = (target, all) => {
|
|
3
|
-
for (var name in all)
|
|
4
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
|
-
};
|
|
6
|
-
|
|
7
1
|
// src/crypto/encrypt.ts
|
|
8
2
|
import { createReadStream, createWriteStream } from "fs";
|
|
9
3
|
import { unlink } from "fs/promises";
|
|
@@ -431,14 +425,6 @@ function deriveAESKeyForEncryption(recipientPublicKeyStr) {
|
|
|
431
425
|
};
|
|
432
426
|
}
|
|
433
427
|
|
|
434
|
-
// src/password/index.ts
|
|
435
|
-
var password_exports = {};
|
|
436
|
-
__export(password_exports, {
|
|
437
|
-
generatePassword: () => generatePassword,
|
|
438
|
-
hashPassword: () => hashPassword,
|
|
439
|
-
verifyPassword: () => verifyPassword
|
|
440
|
-
});
|
|
441
|
-
|
|
442
428
|
// src/password/generate.ts
|
|
443
429
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
444
430
|
var charsetMap = {
|
|
@@ -514,29 +500,12 @@ async function verifyPassword(password, storedHash) {
|
|
|
514
500
|
return diff === 0;
|
|
515
501
|
}
|
|
516
502
|
|
|
517
|
-
// src/uuid/index.ts
|
|
518
|
-
var uuid_exports = {};
|
|
519
|
-
__export(uuid_exports, {
|
|
520
|
-
generateUUID: () => generateUUID
|
|
521
|
-
});
|
|
522
|
-
|
|
523
503
|
// src/uuid/generate.ts
|
|
524
504
|
import { randomUUID } from "crypto";
|
|
525
505
|
function generateUUID() {
|
|
526
506
|
return randomUUID();
|
|
527
507
|
}
|
|
528
508
|
|
|
529
|
-
// src/signature/index.ts
|
|
530
|
-
var signature_exports = {};
|
|
531
|
-
__export(signature_exports, {
|
|
532
|
-
Signer: () => Signer,
|
|
533
|
-
default: () => Signer,
|
|
534
|
-
envelope: () => envelope,
|
|
535
|
-
openEnvelope: () => openEnvelope,
|
|
536
|
-
sign: () => sign2,
|
|
537
|
-
verify: () => verify
|
|
538
|
-
});
|
|
539
|
-
|
|
540
509
|
// src/signature/sign.ts
|
|
541
510
|
import { createPrivateKey as createPrivateKey2, sign as nodeSign } from "crypto";
|
|
542
511
|
|
|
@@ -843,14 +812,6 @@ var defaultSigner = new Signer();
|
|
|
843
812
|
var envelope = defaultSigner.envelope.bind(defaultSigner);
|
|
844
813
|
var openEnvelope = defaultSigner.openEnvelope.bind(defaultSigner);
|
|
845
814
|
|
|
846
|
-
// src/hash/index.ts
|
|
847
|
-
var hash_exports = {};
|
|
848
|
-
__export(hash_exports, {
|
|
849
|
-
hash: () => hash,
|
|
850
|
-
hashHmac: () => hashHmac,
|
|
851
|
-
verifyHmac: () => verifyHmac
|
|
852
|
-
});
|
|
853
|
-
|
|
854
815
|
// src/hash/hash.ts
|
|
855
816
|
import { createHash } from "crypto";
|
|
856
817
|
function hash(data) {
|
|
@@ -876,14 +837,6 @@ function verifyHmac(secret, data, expectedHex) {
|
|
|
876
837
|
return timingSafeEqual(actual, expected);
|
|
877
838
|
}
|
|
878
839
|
|
|
879
|
-
// src/keys/index.ts
|
|
880
|
-
var keys_exports = {};
|
|
881
|
-
__export(keys_exports, {
|
|
882
|
-
Key: () => Key,
|
|
883
|
-
generateECDHKeyPair: () => generateECDHKeyPair,
|
|
884
|
-
generateRSAKeyPair: () => generateRSAKeyPair
|
|
885
|
-
});
|
|
886
|
-
|
|
887
840
|
// src/keys/rsa.ts
|
|
888
841
|
import { generateKeyPair } from "crypto";
|
|
889
842
|
function generateRSAKeyPair() {
|
|
@@ -1036,13 +989,6 @@ var Key = class _Key {
|
|
|
1036
989
|
}
|
|
1037
990
|
};
|
|
1038
991
|
|
|
1039
|
-
// src/otp/index.ts
|
|
1040
|
-
var otp_exports = {};
|
|
1041
|
-
__export(otp_exports, {
|
|
1042
|
-
generateOTP: () => generateOTP,
|
|
1043
|
-
generateTOTP: () => generateTOTP
|
|
1044
|
-
});
|
|
1045
|
-
|
|
1046
992
|
// src/otp/totp.ts
|
|
1047
993
|
import { createHmac as createHmac3 } from "crypto";
|
|
1048
994
|
function base32ToBuffer(base32) {
|
|
@@ -1518,11 +1464,13 @@ var LIBRARY_VERSION = VERSION;
|
|
|
1518
1464
|
var MINIMUM_PASSWORD_LENGTH = MIN_PASSWORD_LENGTH;
|
|
1519
1465
|
var MAX_MESSAGE_AGE = MESSAGE_MAX_AGE_MS;
|
|
1520
1466
|
export {
|
|
1467
|
+
Key,
|
|
1521
1468
|
LIBRARY_VERSION,
|
|
1522
1469
|
MAX_MESSAGE_AGE,
|
|
1523
1470
|
MESSAGE_MAX_AGE_MS,
|
|
1524
1471
|
MINIMUM_PASSWORD_LENGTH,
|
|
1525
1472
|
MIN_PASSWORD_LENGTH,
|
|
1473
|
+
Signer,
|
|
1526
1474
|
VERSION,
|
|
1527
1475
|
decrypt,
|
|
1528
1476
|
decryptFile,
|
|
@@ -1532,15 +1480,24 @@ export {
|
|
|
1532
1480
|
encrypt,
|
|
1533
1481
|
encryptFileStreaming,
|
|
1534
1482
|
encryptMessage,
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1483
|
+
envelope,
|
|
1484
|
+
generateECDHKeyPair,
|
|
1485
|
+
generateOTP,
|
|
1486
|
+
generatePassword,
|
|
1487
|
+
generateRSAKeyPair,
|
|
1488
|
+
generateTOTP,
|
|
1489
|
+
generateUUID,
|
|
1490
|
+
hash,
|
|
1491
|
+
hashHmac,
|
|
1492
|
+
hashPassword,
|
|
1493
|
+
openEnvelope,
|
|
1494
|
+
sign2 as sign,
|
|
1541
1495
|
validatePassword,
|
|
1542
1496
|
validatePrivateKey,
|
|
1543
1497
|
validatePublicKey,
|
|
1544
1498
|
validateTimestamp,
|
|
1545
|
-
validateVersion
|
|
1499
|
+
validateVersion,
|
|
1500
|
+
verify,
|
|
1501
|
+
verifyHmac,
|
|
1502
|
+
verifyPassword
|
|
1546
1503
|
};
|
package/package.json
CHANGED