cas-typescript-sdk 1.0.47 → 1.0.48
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/index.d.ts +141 -0
- package/index.darwin-x64.node +0 -0
- package/index.linux-x64-gnu.node +0 -0
- package/index.linux-x64-musl.node +0 -0
- package/index.win32-x64-msvc.node +0 -0
- package/lib/asymmetric/index.d.ts +3 -0
- package/lib/asymmetric/index.js +5 -0
- package/lib/digital-signature/index.d.ts +6 -0
- package/lib/digital-signature/index.js +11 -0
- package/lib/hashers/index.d.ts +5 -0
- package/lib/hashers/index.js +11 -0
- package/lib/hybrid/index.d.ts +2 -0
- package/lib/hybrid/index.js +5 -0
- package/lib/index.d.ts +10 -0
- package/lib/key_exchange/index.d.ts +3 -0
- package/lib/key_exchange/index.js +5 -0
- package/lib/message/index.d.ts +2 -0
- package/lib/message/index.js +5 -0
- package/lib/password-hashers/index.d.ts +6 -0
- package/lib/password-hashers/index.js +13 -0
- package/lib/signature/index.d.ts +2 -0
- package/lib/signature/index.js +5 -0
- package/lib/sponges/index.d.ts +2 -0
- package/lib/sponges/index.js +5 -0
- package/lib/symmetric/index.d.ts +2 -0
- package/lib/symmetric/index.js +5 -0
- package/package.json +8 -1
- package/.github/workflows/main-pr-linux.yml +0 -28
- package/.github/workflows/main-pr-windows.yml +0 -28
- package/.github/workflows/main-publish.yml +0 -109
- package/Cargo.toml +0 -19
- package/build.rs +0 -5
- package/docs/EXAMPLES.md +0 -138
- package/src/asymmetric/cas_ed25519.rs +0 -35
- package/src/asymmetric/cas_rsa.rs +0 -32
- package/src/digital_signature/sha_256_rsa.rs +0 -40
- package/src/digital_signature/sha_512_rsa.rs +0 -40
- package/src/digital_signature/types.rs +0 -34
- package/src/hashers/blake2.rs +0 -60
- package/src/hashers/sha.rs +0 -68
- package/src/hybrid/hpke.rs +0 -63
- package/src/hybrid/types.rs +0 -15
- package/src/key_exchange/types.rs +0 -17
- package/src/key_exchange/x25519.rs +0 -25
- package/src/lib.rs +0 -47
- package/src/message/hmac.rs +0 -21
- package/src/password_hashers/argon2.rs +0 -37
- package/src/password_hashers/bcrypt.rs +0 -37
- package/src/password_hashers/scrypt.rs +0 -36
- package/src/sponges/ascon_aead.rs +0 -66
- package/src/symmetric/aes.rs +0 -71
- package/src-ts/asymmetric/RSAWrapper.ts +0 -59
- package/src-ts/digital-signature/digital-siganture-sha-512.ts +0 -40
- package/src-ts/digital-signature/digital-signature-base.ts +0 -6
- package/src-ts/digital-signature/digital-signature-factory.ts +0 -25
- package/src-ts/digital-signature/digital-signaturte-sha-256.ts +0 -41
- package/src-ts/hashers/blake2-wrapper.ts +0 -43
- package/src-ts/hashers/hasher-base.ts +0 -6
- package/src-ts/hashers/hasher-factory.ts +0 -19
- package/src-ts/hashers/hasher-type.ts +0 -4
- package/src-ts/hashers/sha-wrapper.ts +0 -60
- package/src-ts/hybrid/hpke.ts +0 -44
- package/src-ts/key_exchange/x25519.ts +0 -23
- package/src-ts/message/hmac.ts +0 -26
- package/src-ts/password-hashers/argon2-wrapper.ts +0 -31
- package/src-ts/password-hashers/bcrypt-wrapper.ts +0 -35
- package/src-ts/password-hashers/password-hasher-base.ts +0 -4
- package/src-ts/password-hashers/password-hasher-factory.ts +0 -25
- package/src-ts/password-hashers/password-hasher-type.ts +0 -5
- package/src-ts/password-hashers/scrypt-wrapper.ts +0 -32
- package/src-ts/signature/ed25519-wrapper.ts +0 -36
- package/src-ts/sponges/ascon-wrapper.ts +0 -72
- package/src-ts/symmetric/aes-wrapper.ts +0 -101
- package/test-ts/asymmetric.test.spec.ts +0 -15
- package/test-ts/digital-signature.test.spec.ts +0 -70
- package/test-ts/hasher.test.spec.ts +0 -139
- package/test-ts/helpers/array.ts +0 -10
- package/test-ts/hmac.test.spec.ts +0 -16
- package/test-ts/hybrid.test.spec.ts +0 -23
- package/test-ts/insecure-channel.test.spec.ts +0 -55
- package/test-ts/key-exchange.test.spec.ts +0 -23
- package/test-ts/password-hasher.test.spec.ts +0 -104
- package/test-ts/sponges.test.spec.ts +0 -28
- package/test-ts/symmetric.test.spec.ts +0 -82
- package/tsconfig.json +0 -22
package/index.d.ts
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/* auto-generated by NAPI-RS */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export declare class Cased25519KeyPairResult {
|
|
4
|
+
privateKey: Array<number>
|
|
5
|
+
publicKey: Array<number>
|
|
6
|
+
constructor(privateKey: Array<number>, publicKey: Array<number>)
|
|
7
|
+
}
|
|
8
|
+
export type CASED25519KeyPairResult = Cased25519KeyPairResult
|
|
9
|
+
|
|
10
|
+
export declare class CasrsaDigitalSignatureResult {
|
|
11
|
+
publicKey: string
|
|
12
|
+
privateKey: string
|
|
13
|
+
signature: Array<number>
|
|
14
|
+
constructor(publicKey: string, privateKey: string, signature: Array<number>)
|
|
15
|
+
}
|
|
16
|
+
export type CASRSADigitalSignatureResult = CasrsaDigitalSignatureResult
|
|
17
|
+
|
|
18
|
+
export declare class CasrsaKeyPairResult {
|
|
19
|
+
privateKey: string
|
|
20
|
+
publicKey: string
|
|
21
|
+
constructor(privateKey: string, publicKey: string)
|
|
22
|
+
}
|
|
23
|
+
export type CASRSAKeyPairResult = CasrsaKeyPairResult
|
|
24
|
+
|
|
25
|
+
export declare class Casshaed25519DalekDigitalSignatureResult {
|
|
26
|
+
publicKey: Array<number>
|
|
27
|
+
signature: Array<number>
|
|
28
|
+
constructor(publicKey: Array<number>, signature: Array<number>)
|
|
29
|
+
}
|
|
30
|
+
export type CASSHAED25519DalekDigitalSignatureResult = Casshaed25519DalekDigitalSignatureResult
|
|
31
|
+
|
|
32
|
+
export declare class CaSx25519SecretPublicKeyResult {
|
|
33
|
+
publicKey: Array<number>
|
|
34
|
+
secretKey: Array<number>
|
|
35
|
+
constructor(publicKey: Array<number>, secretKey: Array<number>)
|
|
36
|
+
}
|
|
37
|
+
export type CASx25519SecretPublicKeyResult = CaSx25519SecretPublicKeyResult
|
|
38
|
+
|
|
39
|
+
export declare class HpkeEncryptResult {
|
|
40
|
+
tag: Array<number>
|
|
41
|
+
ciphertext: Array<number>
|
|
42
|
+
encapsulatedKey: Array<number>
|
|
43
|
+
constructor(tag: Array<number>, ciphertext: Array<number>, encapsulatedKey: Array<number>)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export declare class HpkeKeyResult {
|
|
47
|
+
publicKey: Array<number>
|
|
48
|
+
secretKey: Array<number>
|
|
49
|
+
infoStr: Array<number>
|
|
50
|
+
constructor(publicKey: Array<number>, secretKey: Array<number>, infoStr: Array<number>)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export declare function aes128Decrypt(aesKey: Array<number>, nonce: Array<number>, ciphertext: Array<number>): Array<number>
|
|
54
|
+
|
|
55
|
+
export declare function aes128Encrypt(aesKey: Array<number>, nonce: Array<number>, plaintext: Array<number>): Array<number>
|
|
56
|
+
|
|
57
|
+
export declare function aes128Key(): Array<number>
|
|
58
|
+
|
|
59
|
+
export declare function aes128KeyFromX25519SharedSecret(sharedSecret: Array<number>): Array<number>
|
|
60
|
+
|
|
61
|
+
export declare function aes256Decrypt(aesKey: Array<number>, nonce: Array<number>, ciphertext: Array<number>): Array<number>
|
|
62
|
+
|
|
63
|
+
export declare function aes256Encrypt(aesKey: Array<number>, nonce: Array<number>, plaintext: Array<number>): Array<number>
|
|
64
|
+
|
|
65
|
+
export declare function aes256Key(): Array<number>
|
|
66
|
+
|
|
67
|
+
export declare function aes256KeyFromX25519SharedSecret(sharedSecret: Array<number>): Array<number>
|
|
68
|
+
|
|
69
|
+
export declare function aesNonce(): Array<number>
|
|
70
|
+
|
|
71
|
+
export declare function argon2Hash(password: string): string
|
|
72
|
+
|
|
73
|
+
export declare function argon2Verify(hashedPassword: string, passwordToVerify: string): boolean
|
|
74
|
+
|
|
75
|
+
export declare function ascon128Decrypt(key: Array<number>, nonce: Array<number>, ciphertext: Array<number>): Array<number>
|
|
76
|
+
|
|
77
|
+
export declare function ascon128Encrypt(key: Array<number>, nonce: Array<number>, plaintext: Array<number>): Array<number>
|
|
78
|
+
|
|
79
|
+
export declare function ascon128KeyGenerate(): Array<number>
|
|
80
|
+
|
|
81
|
+
export declare function ascon128NonceGenerate(): Array<number>
|
|
82
|
+
|
|
83
|
+
export declare function bcryptHash(passwordToHash: string): string
|
|
84
|
+
|
|
85
|
+
export declare function bcryptVerify(hashedPassword: string, passwordToVerify: string): boolean
|
|
86
|
+
|
|
87
|
+
export declare function blake2Sha256(dataToHash: Array<number>): Array<number>
|
|
88
|
+
|
|
89
|
+
export declare function blake2Sha256Verify(dataToHash: Array<number>, dataToVerify: Array<number>): boolean
|
|
90
|
+
|
|
91
|
+
export declare function blake2Sha512(dataToHash: Array<number>): Array<number>
|
|
92
|
+
|
|
93
|
+
export declare function blake2Sha512Verify(dataToHash: Array<number>, dataToVerify: Array<number>): boolean
|
|
94
|
+
|
|
95
|
+
export declare function generateEd25519Keys(): Cased25519KeyPairResult
|
|
96
|
+
|
|
97
|
+
export declare function generateInfoStr(): Array<number>
|
|
98
|
+
|
|
99
|
+
export declare function generateRsaKeys(keySize: number): CasrsaKeyPairResult
|
|
100
|
+
|
|
101
|
+
export declare function hmacSign(key: Array<number>, message: Array<number>): Array<number>
|
|
102
|
+
|
|
103
|
+
export declare function hmacVerify(key: Array<number>, message: Array<number>, signature: Array<number>): boolean
|
|
104
|
+
|
|
105
|
+
export declare function hpkeDecrypt(ciphertext: Array<number>, privateKey: Array<number>, encappedKey: Array<number>, tag: Array<number>, infoStr: Array<number>): Array<number>
|
|
106
|
+
|
|
107
|
+
export declare function hpkeEncrypt(plaintext: Array<number>, publicKey: Array<number>, infoStr: Array<number>): HpkeEncryptResult
|
|
108
|
+
|
|
109
|
+
export declare function hpkeGenerateKeypair(): HpkeKeyResult
|
|
110
|
+
|
|
111
|
+
export declare function scryptHash(passwordToHash: string): string
|
|
112
|
+
|
|
113
|
+
export declare function scryptVerify(hashedPassword: string, passwordToVerify: string): boolean
|
|
114
|
+
|
|
115
|
+
export declare function sha256(dataToHash: Array<number>): Array<number>
|
|
116
|
+
|
|
117
|
+
export declare function sha256RsaDigitalSignature(rsaKeySize: number, dataToSign: Array<number>): CASRSADigitalSignatureResult
|
|
118
|
+
|
|
119
|
+
export declare function sha256RsaVerifyDigitalSignature(publicKey: string, dataToVerify: Array<number>, signature: Array<number>): boolean
|
|
120
|
+
|
|
121
|
+
export declare function sha256Verify(dataToHash: Array<number>, dataToVerify: Array<number>): boolean
|
|
122
|
+
|
|
123
|
+
export declare function sha512(dataToHash: Array<number>): Array<number>
|
|
124
|
+
|
|
125
|
+
export declare function sha512RsaDigitalSignature(rsaKeySize: number, dataToSign: Array<number>): CASRSADigitalSignatureResult
|
|
126
|
+
|
|
127
|
+
export declare function sha512RsaVerifyDigitalSignature(publicKey: string, dataToVerify: Array<number>, signature: Array<number>): boolean
|
|
128
|
+
|
|
129
|
+
export declare function sha512Verify(dataToHash: Array<number>, dataToVerify: Array<number>): boolean
|
|
130
|
+
|
|
131
|
+
export declare function signEd25519(privateKey: Array<number>, message: Array<number>): Array<number>
|
|
132
|
+
|
|
133
|
+
export declare function signRsa(privateKey: string, hash: Array<number>): Array<number>
|
|
134
|
+
|
|
135
|
+
export declare function verifyEd25519(publicKey: Array<number>, message: Array<number>, signature: Array<number>): boolean
|
|
136
|
+
|
|
137
|
+
export declare function verifyRsa(publicKey: string, hash: Array<number>, signature: Array<number>): boolean
|
|
138
|
+
|
|
139
|
+
export declare function x25519DiffieHellman(mySecretKey: Array<number>, usersPublicKey: Array<number>): Array<number>
|
|
140
|
+
|
|
141
|
+
export declare function x25519GenerateSecretAndPublicKey(): CASx25519SecretPublicKeyResult
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RSAWrapper = void 0;
|
|
4
|
+
const RSAWrapper_1 = require("./RSAWrapper");
|
|
5
|
+
Object.defineProperty(exports, "RSAWrapper", { enumerable: true, get: function () { return RSAWrapper_1.RSAWrapper; } });
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DigitalSignatureType } from "./digital-signature-factory";
|
|
2
|
+
import { DigitalSignatureFactory } from "./digital-signature-factory";
|
|
3
|
+
import { DigitalSignatureSHA256Wrapper } from "./digital-signaturte-sha-256";
|
|
4
|
+
import { DigitalSignatureSHA512Wrapper } from "./digital-siganture-sha-512";
|
|
5
|
+
import { CASRSADigitalSignatureResult, CASSHAED25519DalekDigitalSignatureResult } from "../../index";
|
|
6
|
+
export { DigitalSignatureFactory, DigitalSignatureSHA256Wrapper, DigitalSignatureSHA512Wrapper, DigitalSignatureType, CASSHAED25519DalekDigitalSignatureResult, CASRSADigitalSignatureResult };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DigitalSignatureType = exports.DigitalSignatureSHA512Wrapper = exports.DigitalSignatureSHA256Wrapper = exports.DigitalSignatureFactory = void 0;
|
|
4
|
+
const digital_signature_factory_1 = require("./digital-signature-factory");
|
|
5
|
+
Object.defineProperty(exports, "DigitalSignatureType", { enumerable: true, get: function () { return digital_signature_factory_1.DigitalSignatureType; } });
|
|
6
|
+
const digital_signature_factory_2 = require("./digital-signature-factory");
|
|
7
|
+
Object.defineProperty(exports, "DigitalSignatureFactory", { enumerable: true, get: function () { return digital_signature_factory_2.DigitalSignatureFactory; } });
|
|
8
|
+
const digital_signaturte_sha_256_1 = require("./digital-signaturte-sha-256");
|
|
9
|
+
Object.defineProperty(exports, "DigitalSignatureSHA256Wrapper", { enumerable: true, get: function () { return digital_signaturte_sha_256_1.DigitalSignatureSHA256Wrapper; } });
|
|
10
|
+
const digital_siganture_sha_512_1 = require("./digital-siganture-sha-512");
|
|
11
|
+
Object.defineProperty(exports, "DigitalSignatureSHA512Wrapper", { enumerable: true, get: function () { return digital_siganture_sha_512_1.DigitalSignatureSHA512Wrapper; } });
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Blake2Wrapper = exports.HasherType = exports.HasherFactory = exports.SHAWrapper = void 0;
|
|
4
|
+
const hasher_factory_1 = require("./hasher-factory");
|
|
5
|
+
Object.defineProperty(exports, "HasherFactory", { enumerable: true, get: function () { return hasher_factory_1.HasherFactory; } });
|
|
6
|
+
const hasher_type_1 = require("./hasher-type");
|
|
7
|
+
Object.defineProperty(exports, "HasherType", { enumerable: true, get: function () { return hasher_type_1.HasherType; } });
|
|
8
|
+
const sha_wrapper_1 = require("./sha-wrapper");
|
|
9
|
+
Object.defineProperty(exports, "SHAWrapper", { enumerable: true, get: function () { return sha_wrapper_1.SHAWrapper; } });
|
|
10
|
+
const blake2_wrapper_1 = require("./blake2-wrapper");
|
|
11
|
+
Object.defineProperty(exports, "Blake2Wrapper", { enumerable: true, get: function () { return blake2_wrapper_1.Blake2Wrapper; } });
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from "./password-hashers/index";
|
|
2
|
+
export * from "./hashers/index";
|
|
3
|
+
export * from "./key_exchange/index";
|
|
4
|
+
export * from "./symmetric/index";
|
|
5
|
+
export * from "./asymmetric/index";
|
|
6
|
+
export * from "./digital-signature";
|
|
7
|
+
export * from "./sponges/index";
|
|
8
|
+
export * from "./message/index";
|
|
9
|
+
export * from "./signature/index";
|
|
10
|
+
export * from "./hybrid/index";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.X25519Wrapper = void 0;
|
|
4
|
+
const x25519_1 = require("./x25519");
|
|
5
|
+
Object.defineProperty(exports, "X25519Wrapper", { enumerable: true, get: function () { return x25519_1.X25519Wrapper; } });
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Argon2Wrapper } from "./argon2-wrapper";
|
|
2
|
+
import { BCryptWrapper } from "./bcrypt-wrapper";
|
|
3
|
+
import { ScryptWrapper } from "./scrypt-wrapper";
|
|
4
|
+
import { PasswordHasherType } from "./password-hasher-type";
|
|
5
|
+
import { PasswordHasherFactory } from "./password-hasher-factory";
|
|
6
|
+
export { Argon2Wrapper, BCryptWrapper, PasswordHasherFactory, PasswordHasherType, ScryptWrapper, };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ScryptWrapper = exports.PasswordHasherType = exports.PasswordHasherFactory = exports.BCryptWrapper = exports.Argon2Wrapper = void 0;
|
|
4
|
+
const argon2_wrapper_1 = require("./argon2-wrapper");
|
|
5
|
+
Object.defineProperty(exports, "Argon2Wrapper", { enumerable: true, get: function () { return argon2_wrapper_1.Argon2Wrapper; } });
|
|
6
|
+
const bcrypt_wrapper_1 = require("./bcrypt-wrapper");
|
|
7
|
+
Object.defineProperty(exports, "BCryptWrapper", { enumerable: true, get: function () { return bcrypt_wrapper_1.BCryptWrapper; } });
|
|
8
|
+
const scrypt_wrapper_1 = require("./scrypt-wrapper");
|
|
9
|
+
Object.defineProperty(exports, "ScryptWrapper", { enumerable: true, get: function () { return scrypt_wrapper_1.ScryptWrapper; } });
|
|
10
|
+
const password_hasher_type_1 = require("./password-hasher-type");
|
|
11
|
+
Object.defineProperty(exports, "PasswordHasherType", { enumerable: true, get: function () { return password_hasher_type_1.PasswordHasherType; } });
|
|
12
|
+
const password_hasher_factory_1 = require("./password-hasher-factory");
|
|
13
|
+
Object.defineProperty(exports, "PasswordHasherFactory", { enumerable: true, get: function () { return password_hasher_factory_1.PasswordHasherFactory; } });
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Ed25519Wrapper = void 0;
|
|
4
|
+
const ed25519_wrapper_1 = require("./ed25519-wrapper");
|
|
5
|
+
Object.defineProperty(exports, "Ed25519Wrapper", { enumerable: true, get: function () { return ed25519_wrapper_1.Ed25519Wrapper; } });
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AsconWrapper = void 0;
|
|
4
|
+
const ascon_wrapper_1 = require("./ascon-wrapper");
|
|
5
|
+
Object.defineProperty(exports, "AsconWrapper", { enumerable: true, get: function () { return ascon_wrapper_1.AsconWrapper; } });
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AESWrapper = void 0;
|
|
4
|
+
const aes_wrapper_1 = require("./aes-wrapper");
|
|
5
|
+
Object.defineProperty(exports, "AESWrapper", { enumerable: true, get: function () { return aes_wrapper_1.AESWrapper; } });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cas-typescript-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.48",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -23,6 +23,13 @@
|
|
|
23
23
|
"url": "https://github.com/Cryptographic-API-Services/cas-typescript-sdk/issues"
|
|
24
24
|
},
|
|
25
25
|
"homepage": "https://github.com/Cryptographic-API-Services/cas-typescript-sdk#readme",
|
|
26
|
+
"files": [
|
|
27
|
+
"lib",
|
|
28
|
+
"index.js",
|
|
29
|
+
"index.d.ts",
|
|
30
|
+
"*.node",
|
|
31
|
+
"README.md"
|
|
32
|
+
],
|
|
26
33
|
"publishConfig": {
|
|
27
34
|
"access": "public",
|
|
28
35
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
|
|
2
|
-
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
|
|
3
|
-
|
|
4
|
-
name: Linux Build / Test
|
|
5
|
-
|
|
6
|
-
on:
|
|
7
|
-
pull_request:
|
|
8
|
-
branches: [ "main" ]
|
|
9
|
-
|
|
10
|
-
jobs:
|
|
11
|
-
build:
|
|
12
|
-
|
|
13
|
-
runs-on: ubuntu-latest
|
|
14
|
-
|
|
15
|
-
strategy:
|
|
16
|
-
matrix:
|
|
17
|
-
node-version: [24.x]
|
|
18
|
-
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
|
|
19
|
-
|
|
20
|
-
steps:
|
|
21
|
-
- uses: actions/checkout@v3
|
|
22
|
-
- name: Use Node.js ${{ matrix.node-version }}
|
|
23
|
-
uses: actions/setup-node@v3
|
|
24
|
-
with:
|
|
25
|
-
node-version: ${{ matrix.node-version }}
|
|
26
|
-
cache: 'npm'
|
|
27
|
-
- run: npm ci
|
|
28
|
-
- run: npm test
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
|
|
2
|
-
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
|
|
3
|
-
|
|
4
|
-
name: Windows Build / Test
|
|
5
|
-
|
|
6
|
-
on:
|
|
7
|
-
pull_request:
|
|
8
|
-
branches: [ "main" ]
|
|
9
|
-
|
|
10
|
-
jobs:
|
|
11
|
-
build:
|
|
12
|
-
|
|
13
|
-
runs-on: windows-latest
|
|
14
|
-
|
|
15
|
-
strategy:
|
|
16
|
-
matrix:
|
|
17
|
-
node-version: [24.x]
|
|
18
|
-
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
|
|
19
|
-
|
|
20
|
-
steps:
|
|
21
|
-
- uses: actions/checkout@v3
|
|
22
|
-
- name: Use Node.js ${{ matrix.node-version }}
|
|
23
|
-
uses: actions/setup-node@v3
|
|
24
|
-
with:
|
|
25
|
-
node-version: ${{ matrix.node-version }}
|
|
26
|
-
cache: 'npm'
|
|
27
|
-
- run: npm ci
|
|
28
|
-
- run: npm test
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
# Cross-platform build and publish workflow
|
|
2
|
-
|
|
3
|
-
name: Build and Publish
|
|
4
|
-
|
|
5
|
-
on:
|
|
6
|
-
push:
|
|
7
|
-
branches: [ "main" ]
|
|
8
|
-
|
|
9
|
-
jobs:
|
|
10
|
-
build-matrix:
|
|
11
|
-
runs-on: ${{ matrix.settings.host }}
|
|
12
|
-
strategy:
|
|
13
|
-
fail-fast: false
|
|
14
|
-
matrix:
|
|
15
|
-
settings:
|
|
16
|
-
# Linux builds (on Ubuntu)
|
|
17
|
-
- host: ubuntu-latest
|
|
18
|
-
target: x86_64-unknown-linux-gnu
|
|
19
|
-
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-zig
|
|
20
|
-
- host: ubuntu-latest
|
|
21
|
-
target: x86_64-unknown-linux-musl
|
|
22
|
-
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine-zig
|
|
23
|
-
# Windows builds (on Windows)
|
|
24
|
-
- host: windows-latest
|
|
25
|
-
target: x86_64-pc-windows-msvc
|
|
26
|
-
# macOS builds (on macOS)
|
|
27
|
-
- host: macos-latest
|
|
28
|
-
target: x86_64-apple-darwin
|
|
29
|
-
|
|
30
|
-
name: Build ${{ matrix.settings.target }}
|
|
31
|
-
steps:
|
|
32
|
-
- uses: actions/checkout@v4
|
|
33
|
-
|
|
34
|
-
- name: Setup node
|
|
35
|
-
uses: actions/setup-node@v4
|
|
36
|
-
with:
|
|
37
|
-
node-version: 24
|
|
38
|
-
cache: npm
|
|
39
|
-
|
|
40
|
-
- name: Install dependencies
|
|
41
|
-
run: npm ci
|
|
42
|
-
|
|
43
|
-
- name: Setup Rust
|
|
44
|
-
if: ${{ !matrix.settings.docker }}
|
|
45
|
-
uses: dtolnay/rust-toolchain@stable
|
|
46
|
-
with:
|
|
47
|
-
toolchain: stable
|
|
48
|
-
targets: ${{ matrix.settings.target }}
|
|
49
|
-
components: rustfmt, clippy
|
|
50
|
-
|
|
51
|
-
- name: Build in Docker
|
|
52
|
-
if: ${{ matrix.settings.docker }}
|
|
53
|
-
run: |
|
|
54
|
-
docker run --rm -v "$(pwd)":/build -w /build ${{ matrix.settings.docker }} sh -c "
|
|
55
|
-
rustup toolchain install nightly &&
|
|
56
|
-
rustup default nightly &&
|
|
57
|
-
npm ci &&
|
|
58
|
-
cargo update &&
|
|
59
|
-
npm run build:ts &&
|
|
60
|
-
npx napi build --platform --release --target ${{ matrix.settings.target }}
|
|
61
|
-
"
|
|
62
|
-
|
|
63
|
-
- name: Build native
|
|
64
|
-
if: ${{ !matrix.settings.docker }}
|
|
65
|
-
run: |
|
|
66
|
-
cargo update
|
|
67
|
-
npm run build:ts
|
|
68
|
-
npx napi build --platform --release --target ${{ matrix.settings.target }}
|
|
69
|
-
|
|
70
|
-
- name: Upload artifact
|
|
71
|
-
uses: actions/upload-artifact@v4
|
|
72
|
-
with:
|
|
73
|
-
name: bindings-${{ matrix.settings.target }}
|
|
74
|
-
path: "*.node"
|
|
75
|
-
if-no-files-found: error
|
|
76
|
-
|
|
77
|
-
publish:
|
|
78
|
-
name: Publish
|
|
79
|
-
runs-on: ubuntu-latest
|
|
80
|
-
needs: [build-matrix]
|
|
81
|
-
|
|
82
|
-
steps:
|
|
83
|
-
- uses: actions/checkout@v4
|
|
84
|
-
|
|
85
|
-
- name: Setup node
|
|
86
|
-
uses: actions/setup-node@v4
|
|
87
|
-
with:
|
|
88
|
-
node-version: 24
|
|
89
|
-
registry-url: 'https://registry.npmjs.org'
|
|
90
|
-
cache: npm
|
|
91
|
-
|
|
92
|
-
- name: Install dependencies
|
|
93
|
-
run: npm ci
|
|
94
|
-
|
|
95
|
-
- name: Build TypeScript
|
|
96
|
-
run: npm run build:ts
|
|
97
|
-
|
|
98
|
-
- name: Download all artifacts
|
|
99
|
-
uses: actions/download-artifact@v4
|
|
100
|
-
with:
|
|
101
|
-
merge-multiple: true
|
|
102
|
-
|
|
103
|
-
- name: List binaries
|
|
104
|
-
run: ls -la *.node
|
|
105
|
-
|
|
106
|
-
- name: Publish to npm
|
|
107
|
-
run: npm publish --access public
|
|
108
|
-
env:
|
|
109
|
-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/Cargo.toml
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
[package]
|
|
2
|
-
name = "cas-typescript-sdk-napi"
|
|
3
|
-
version = "0.1.0"
|
|
4
|
-
edition = "2021"
|
|
5
|
-
|
|
6
|
-
[lib]
|
|
7
|
-
path = "src/lib.rs"
|
|
8
|
-
crate-type = ["cdylib"]
|
|
9
|
-
|
|
10
|
-
[dependencies]
|
|
11
|
-
napi = "3"
|
|
12
|
-
napi-derive = "3"
|
|
13
|
-
csbindgen = "1.9.3"
|
|
14
|
-
cas-lib = { version = "=0.2.65" }
|
|
15
|
-
zeroize = "1.8.1"
|
|
16
|
-
zeroizing-alloc = "0.1.0"
|
|
17
|
-
|
|
18
|
-
[build-dependencies]
|
|
19
|
-
napi-build = "1"
|
package/build.rs
DELETED
package/docs/EXAMPLES.md
DELETED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
### Symmetric
|
|
2
|
-
- AES 256
|
|
3
|
-
```typescript
|
|
4
|
-
const aesWrapper: AESWrapper = new AESWrapper();
|
|
5
|
-
const aesKey = aesWrapper.aes128Key();
|
|
6
|
-
const aesNonce = aesWrapper.aesNonce();
|
|
7
|
-
const toEncrypt: string = "This is my array to encrypt";
|
|
8
|
-
const encoder = new TextEncoder();
|
|
9
|
-
const tohashBytes: Array<number> = Array.from(encoder.encode(toEncrypt));
|
|
10
|
-
const ciphertext = aesWrapper.aes128Encrypt(aesKey, aesNonce, tohashBytes);
|
|
11
|
-
const plaintxt = aesWrapper.aes128Decrypt(aesKey, aesNonce, ciphertext);
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
### Asymmetric
|
|
15
|
-
-RSA
|
|
16
|
-
```typescript
|
|
17
|
-
const rsaWrapper: RSAWrapper = new RSAWrapper();
|
|
18
|
-
const keys: RsaKeyPairResult = rsaWrapper.generateKeys(4096);
|
|
19
|
-
const tohashed: string = "This is my array to encrypt";
|
|
20
|
-
const encoder = new TextEncoder();
|
|
21
|
-
const tohashBytes: Array<number> = Array.from(encoder.encode(tohashed));
|
|
22
|
-
const ciphertext = rsaWrapper.encrypt(keys.publicKey, tohashBytes);
|
|
23
|
-
const plaintext = rsaWrapper.decrypt(keys.privateKey, ciphertext);
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
### Digital Signature
|
|
28
|
-
-ED25519 SHA
|
|
29
|
-
```typescript
|
|
30
|
-
const shaDsWrapper = DigitalSignatureFactory.get(DigitalSignatureType.SHA256)
|
|
31
|
-
const toHash: string = "This is my array to encrypt";
|
|
32
|
-
const encoder = new TextEncoder();
|
|
33
|
-
const toHashBytes: Array<number> = Array.from(encoder.encode(toHash));
|
|
34
|
-
const dsResult = shaDsWrapper.createED25519(toHashBytes);
|
|
35
|
-
const verify = shaDsWrapper.verifyED25519(dsResult.publicKey, toHashBytes, dsResult.signature);
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
-RSA SHA
|
|
39
|
-
```typescript
|
|
40
|
-
const shaDsWrapper = DigitalSignatureFactory.get(DigitalSignatureType.SHA512)
|
|
41
|
-
const tohashed: string = "This is my array to encrypt";
|
|
42
|
-
const notOriginal: string = "This is not a fun time";
|
|
43
|
-
const encoder = new TextEncoder();
|
|
44
|
-
const tohashBytes: Array<number> = Array.from(encoder.encode(tohashed));
|
|
45
|
-
const badBytes: Array<number> = Array.from(encoder.encode(notOriginal));
|
|
46
|
-
const dsResult: RSADigitalSignatureResult = shaDsWrapper.createRsa(4096, tohashBytes);
|
|
47
|
-
const verify = shaDsWrapper.verifyRSa(dsResult.publicKey, badBytes, dsResult.signature);
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
### Hashers
|
|
52
|
-
-SHA3 512
|
|
53
|
-
```typescript
|
|
54
|
-
const wrapper = new SHAWrapper();
|
|
55
|
-
const tohashed: string = "This is my array to hash";
|
|
56
|
-
const encoder = new TextEncoder();
|
|
57
|
-
const tohashBytes: Array<number> = Array.from(encoder.encode(tohashed));
|
|
58
|
-
const hashed = wrapper.hash512(tohashBytes);
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
-SHA3 256
|
|
62
|
-
```typescript
|
|
63
|
-
const wrapper = new SHAWrapper();
|
|
64
|
-
const tohashed: string = "This is my array to hash";
|
|
65
|
-
const encoder = new TextEncoder();
|
|
66
|
-
const tohashBytes: Array<number> = Array.from(encoder.encode(tohashed));
|
|
67
|
-
const hashed = wrapper.hash256(tohashBytes);
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
### Hybrid Encryption
|
|
71
|
-
-AES/RSA Encryption
|
|
72
|
-
```typescript
|
|
73
|
-
const hybridWrapper = new HybridEncryptionWrapper();
|
|
74
|
-
let initalizer = new AESRSAHybridInitializer(128, 4096);
|
|
75
|
-
const tohashed: string = "This is my encrypt text for rsa hybrid";
|
|
76
|
-
const encoder = new TextEncoder();
|
|
77
|
-
const toEncrypt: Array<number> = Array.from(encoder.encode(tohashed));
|
|
78
|
-
let result: AesRsaHybridEncryptResult = hybridWrapper.encrypt(toEncrypt, initalizer);
|
|
79
|
-
let plaintext: Array<number> = hybridWrapper.decrypt(initalizer.rsaKeyPair.privateKey, result);
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
### Key Exchange
|
|
83
|
-
-X25519
|
|
84
|
-
```typescript
|
|
85
|
-
const wrapper = new X25519Wrapper();
|
|
86
|
-
const alice = wrapper.generateSecretAndPublicKey();
|
|
87
|
-
const bob = wrapper.generateSecretAndPublicKey();
|
|
88
|
-
|
|
89
|
-
const alice_shared_secret = wrapper.generateSharedSecret(
|
|
90
|
-
alice.secretKey,
|
|
91
|
-
bob.publicKey,
|
|
92
|
-
);
|
|
93
|
-
const bob_shared_secret = wrapper.generateSharedSecret(
|
|
94
|
-
bob.secretKey,
|
|
95
|
-
alice.publicKey,
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
var result = areEqual(alice_shared_secret, bob_shared_secret);
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
### Sponges
|
|
102
|
-
-Ascon 128
|
|
103
|
-
```typescript
|
|
104
|
-
const wrapper: AsconWrapper = new AsconWrapper();
|
|
105
|
-
const key: Array<number> = wrapper.ascon128Key();
|
|
106
|
-
const nonce: Array<number> = wrapper.ascon128Nonce();
|
|
107
|
-
const tohashed: string = "This is my array to encrypt";
|
|
108
|
-
const encoder = new TextEncoder();
|
|
109
|
-
const tohashBytes: Array<number> = Array.from(encoder.encode(tohashed));
|
|
110
|
-
const ciphertext = wrapper.ascon128Encrypt(key, nonce, tohashBytes);
|
|
111
|
-
const plaintext = wrapper.ascon128Decrypt(key, nonce, ciphertext);
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
### Passwords
|
|
115
|
-
- BCrypt
|
|
116
|
-
```typescript
|
|
117
|
-
const hasher: BCryptWrapper = new BCryptWrapper();
|
|
118
|
-
const password: string = "ThisOneBadPassword!@";
|
|
119
|
-
const hashedPassword: string = hasher.hashPassword(password);
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
- SCrypt
|
|
123
|
-
```typescript
|
|
124
|
-
const hasher: ScryptWrapper = PasswordHasherFactory.getHasher(
|
|
125
|
-
PasswordHasherType.Scrypt,
|
|
126
|
-
);
|
|
127
|
-
const password: string = "ScryptRocks";
|
|
128
|
-
const hashed: string = hasher.hashPassword(password);
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
- Argon2
|
|
132
|
-
```typescript
|
|
133
|
-
const hasher: ScryptWrapper = PasswordHasherFactory.getHasher(
|
|
134
|
-
PasswordHasherType.Argon2,
|
|
135
|
-
);
|
|
136
|
-
const password: string = "ScryptRocks";
|
|
137
|
-
const hashed: string = hasher.hashPassword(password);
|
|
138
|
-
```
|