edhoc 1.0.0 → 1.0.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/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "edhoc",
3
3
  "description": "A Node.js implementation of EDHOC (Ephemeral Diffie-Hellman Over COSE) protocol for lightweight authenticated key exchange in IoT and other constrained environments.",
4
- "version": "1.0.0",
4
+ "version": "1.0.1",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
7
7
  "debug": "npx node-gyp build --debug",
8
- "install": "node-gyp-build && npx tsc",
8
+ "install": "node-gyp-build",
9
9
  "postinstall": "patch-package",
10
10
  "lint": "eslint .",
11
11
  "prebuildify": "prebuildify --napi --target 17.0.0 --force --strip --verbose",
@@ -22,7 +22,9 @@
22
22
  "@noble/curves": "^1.4.0",
23
23
  "bindings": "^1.5.0",
24
24
  "cbor": "^9.0.2",
25
- "coap": "^1.3.0"
25
+ "coap": "^1.3.0",
26
+ "node-addon-api": "^8.0.0",
27
+ "node-gyp-build": "^4.8.1"
26
28
  },
27
29
  "devDependencies": {
28
30
  "@commitlint/cli": "^19.3.0",
@@ -36,8 +38,6 @@
36
38
  "@types/eslint__js": "^8.42.3",
37
39
  "eslint": "^8.57.0",
38
40
  "mocha": "^10.7.0",
39
- "node-addon-api": "^8.0.0",
40
- "node-gyp-build": "^4.8.1",
41
41
  "nyc": "^17.0.0",
42
42
  "patch-package": "^8.0.0",
43
43
  "prebuildify": "^6.0.1",
Binary file
Binary file
@@ -1,5 +0,0 @@
1
- import { EDHOC } from './edhoc';
2
- export interface NodeGypBinding {
3
- EDHOC: EDHOC;
4
- }
5
- //# sourceMappingURL=bindings.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bindings.d.ts","sourceRoot":"","sources":["../lib/bindings.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAG/B,MAAM,WAAW,cAAc;IAC3B,KAAK,EAAE,KAAK,CAAA;CACf"}
package/dist/bindings.js DELETED
@@ -1,10 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const node_gyp_build_1 = __importDefault(require("node-gyp-build"));
7
- const path_1 = require("path");
8
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
- const binding = (0, node_gyp_build_1.default)((0, path_1.join)(__dirname, '../'));
10
- exports.EDHOC = binding.EDHOC;
@@ -1,16 +0,0 @@
1
- import { DefaultEdhocCryptoManager } from './crypto';
2
- import { EDHOC, EdhocCredentialManager, EdhocCredentials } from './edhoc';
3
- export declare class X509Credentials {
4
- certificate: Buffer;
5
- privateKey: Buffer;
6
- constructor(certificate: Buffer, privateKey: Buffer);
7
- }
8
- export declare class DefaultEdhocCredentialManager implements EdhocCredentialManager {
9
- private credentials;
10
- private trustRoots;
11
- setCredentials(cryptoManager: DefaultEdhocCryptoManager, credentials: X509Credentials, keyID?: Buffer): void;
12
- addTrustRoot(certificate: Buffer): void;
13
- fetch(edhoc: EDHOC): Promise<EdhocCredentials>;
14
- verify(edhoc: EDHOC, credentials: EdhocCredentials): Promise<EdhocCredentials>;
15
- }
16
- //# sourceMappingURL=credentials.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../lib/credentials.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,sBAAsB,EAAE,gBAAgB,EAA4D,MAAM,SAAS,CAAC;AAGpI,qBAAa,eAAe;IAEjB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;gBAEd,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;CAItD;AAED,qBAAa,6BAA8B,YAAW,sBAAsB;IAExE,OAAO,CAAC,WAAW,CAAsE;IACzF,OAAO,CAAC,UAAU,CAAyB;IAE3C,cAAc,CAAC,aAAa,EAAE,yBAAyB,EAAE,WAAW,EAAE,eAAe,EAAE,KAAK,GAAE,MAAuC;IAYrI,YAAY,CAAC,WAAW,EAAE,MAAM;IAI1B,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAK9C,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,gBAAgB;CAuD3D"}
@@ -1,84 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DefaultEdhocCredentialManager = exports.X509Credentials = void 0;
4
- const edhoc_1 = require("./edhoc");
5
- const crypto_1 = require("crypto");
6
- class X509Credentials {
7
- certificate;
8
- privateKey;
9
- constructor(certificate, privateKey) {
10
- this.certificate = certificate;
11
- this.privateKey = privateKey;
12
- }
13
- }
14
- exports.X509Credentials = X509Credentials;
15
- class DefaultEdhocCredentialManager {
16
- credentials = new Map();
17
- trustRoots = [];
18
- setCredentials(cryptoManager, credentials, keyID = Buffer.from('00000001', 'hex')) {
19
- cryptoManager.addKey(keyID, credentials.privateKey);
20
- let chain = {
21
- format: edhoc_1.EdhocCredentialsFormat.x5chain,
22
- privateKeyID: keyID,
23
- x5chain: {
24
- certificates: [credentials.certificate]
25
- }
26
- };
27
- this.credentials.set(keyID.toString('hex'), chain);
28
- }
29
- addTrustRoot(certificate) {
30
- this.trustRoots.push(new crypto_1.X509Certificate(certificate));
31
- }
32
- async fetch(edhoc) {
33
- const credential = this.credentials.values().next().value;
34
- return credential;
35
- }
36
- async verify(edhoc, credentials) {
37
- if (credentials.format === edhoc_1.EdhocCredentialsFormat.x5chain) {
38
- const x5chain = credentials.x5chain;
39
- const certificates = x5chain.certificates;
40
- const numCerts = certificates.length;
41
- if (numCerts < 1) {
42
- throw new Error('Certificate chain must contain at least one certificate.');
43
- }
44
- let verified = false;
45
- // Step 1: Verify each certificate against the next one in the chain, if there are multiple certificates
46
- for (let i = 0; i < numCerts - 1; i++) {
47
- const currentCert = new crypto_1.X509Certificate(certificates[i]);
48
- const nextCert = new crypto_1.X509Certificate(certificates[i + 1]);
49
- if (!currentCert.verify(nextCert.publicKey)) {
50
- throw new Error(`Verification failed: Certificate at index ${i} is not signed by the next certificate in the chain.`);
51
- }
52
- }
53
- // Step 2: Verify the last certificate in the chain against the trust roots
54
- const lastCert = new crypto_1.X509Certificate(certificates[numCerts - 1]);
55
- for (let trustRoot of this.trustRoots) {
56
- if (lastCert.verify(trustRoot.publicKey)) {
57
- verified = true;
58
- break; // Exit the loop once verified
59
- }
60
- }
61
- if (!verified) {
62
- throw new Error('Certificate chain not verified');
63
- }
64
- let token = new crypto_1.X509Certificate(certificates[0]).publicKey.export({ format: 'jwk' });
65
- if (token.crv === 'P-256') {
66
- credentials.publicKey = Buffer.concat([
67
- Buffer.from(token.x, 'base64'),
68
- Buffer.from(token.y, 'base64')
69
- ]);
70
- return credentials;
71
- }
72
- else if (token.crv === 'Ed25519') {
73
- let publicKey = Buffer.from(token.x, 'base64');
74
- credentials.publicKey = publicKey;
75
- return credentials;
76
- }
77
- else {
78
- throw new Error('Unsupported curve');
79
- }
80
- }
81
- throw new Error('Credentials format not supported');
82
- }
83
- }
84
- exports.DefaultEdhocCredentialManager = DefaultEdhocCredentialManager;
package/dist/crypto.d.ts DELETED
@@ -1,22 +0,0 @@
1
- import { EDHOC, EdhocCryptoManager, EdhocKeyType } from './edhoc';
2
- export declare class DefaultEdhocCryptoManager implements EdhocCryptoManager {
3
- private keys;
4
- private keyIdentifier;
5
- constructor();
6
- addKey(keyID: Buffer, key: Buffer): void;
7
- generateKey(edhoc: EDHOC, keyType: EdhocKeyType, key: Buffer): Promise<Buffer>;
8
- destroyKey(edhoc: EDHOC, keyID: Buffer): boolean;
9
- makeKeyPair(edhoc: EDHOC, keyID: Buffer, privateKeySize: number, publicKeySize: number): {
10
- privateKey: Buffer;
11
- publicKey: Buffer;
12
- };
13
- keyAgreement(edhoc: EDHOC, keyID: Buffer, publicKey: Buffer, privateKeySize: number): Buffer;
14
- sign(edhoc: EDHOC, keyID: Buffer, input: Buffer, signatureSize: number): Buffer;
15
- verify(edhoc: EDHOC, keyID: Buffer, input: Buffer, signature: Buffer): boolean;
16
- extract(edhoc: EDHOC, keyID: Buffer, salt: Buffer, keySize: number): Buffer;
17
- expand(edhoc: EDHOC, keyID: Buffer, info: Buffer, keySize: number): Buffer;
18
- encrypt(edhoc: EDHOC, keyID: Buffer, nonce: Buffer, aad: Buffer, plaintext: Buffer, size: number): Buffer;
19
- decrypt(edhoc: EDHOC, keyID: Buffer, nonce: Buffer, aad: Buffer, ciphertext: Buffer, size: number): Buffer;
20
- hash(edhoc: EDHOC, data: Buffer, hashSize: number): Promise<Buffer>;
21
- }
22
- //# sourceMappingURL=crypto.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../lib/crypto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,kBAAkB,EAAE,YAAY,EAAc,MAAM,SAAS,CAAC;AAqB9E,qBAAa,yBAA0B,YAAW,kBAAkB;IAEhE,OAAO,CAAC,IAAI,CAAiB;IAC7B,OAAO,CAAC,aAAa,CAAgB;;IAM9B,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;IAKlC,WAAW,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM;IAqClE,UAAU,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM;IAStC,WAAW,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM;;;;IAoBtF,YAAY,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;IAiBnF,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM;IA4BtE,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;IAwBpE,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;IAQlE,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;IASjE,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAqBhG,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAqB3F,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;CAG1D"}
package/dist/crypto.js DELETED
@@ -1,177 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DefaultEdhocCryptoManager = void 0;
4
- const edhoc_1 = require("./edhoc");
5
- const ed25519_1 = require("@noble/curves/ed25519");
6
- const p256_1 = require("@noble/curves/p256");
7
- const sha256_1 = require("@noble/hashes/sha256");
8
- const hkdf_1 = require("@noble/hashes/hkdf");
9
- const crypto_1 = require("crypto");
10
- class DefaultEdhocCryptoManager {
11
- keys = {};
12
- keyIdentifier = 1000;
13
- constructor() {
14
- this.keys = {};
15
- }
16
- addKey(keyID, key) {
17
- const kid = keyID.toString('hex');
18
- this.keys[kid] = key;
19
- }
20
- async generateKey(edhoc, keyType, key) {
21
- // Key Identifier
22
- const keyBuffer = Buffer.alloc(4);
23
- keyBuffer.writeInt32LE(this.keyIdentifier++);
24
- const keyID = keyBuffer.toString('hex');
25
- // Key Exchange Curve
26
- const curveKE = [edhoc_1.EdhocSuite.Suite2, edhoc_1.EdhocSuite.Suite3, edhoc_1.EdhocSuite.Suite5].includes(edhoc.selectedSuite) ? p256_1.p256 :
27
- [edhoc_1.EdhocSuite.Suite0, edhoc_1.EdhocSuite.Suite1, edhoc_1.EdhocSuite.Suite4, edhoc_1.EdhocSuite.Suite6].includes(edhoc.selectedSuite) ? ed25519_1.x25519 : null;
28
- // Signature Curve
29
- const curveSIG = [edhoc_1.EdhocSuite.Suite2, edhoc_1.EdhocSuite.Suite3, edhoc_1.EdhocSuite.Suite5, edhoc_1.EdhocSuite.Suite6].includes(edhoc.selectedSuite) ? p256_1.p256 :
30
- [edhoc_1.EdhocSuite.Suite0, edhoc_1.EdhocSuite.Suite1, edhoc_1.EdhocSuite.Suite4].includes(edhoc.selectedSuite) ? ed25519_1.ed25519 : null;
31
- if (null == curveKE || null == curveSIG) {
32
- throw new Error('Unsupported suite');
33
- }
34
- switch (keyType) {
35
- case edhoc_1.EdhocKeyType.MakeKeyPair:
36
- this.keys[keyID] = curveKE.utils.randomPrivateKey();
37
- break;
38
- case edhoc_1.EdhocKeyType.KeyAgreement:
39
- this.keys[keyID] = key.byteLength > 0 ? Buffer.from(key) : curveKE.utils.randomPrivateKey();
40
- break;
41
- case edhoc_1.EdhocKeyType.Signature:
42
- this.keys[keyID] = key.byteLength > 0 ? Buffer.from(key) : curveSIG.utils.randomPrivateKey();
43
- break;
44
- default:
45
- this.keys[keyID] = Buffer.from(key);
46
- }
47
- return keyBuffer;
48
- }
49
- destroyKey(edhoc, keyID) {
50
- const kid = keyID.toString('hex');
51
- if (kid in this.keys === false) {
52
- throw new Error(`Key '${kid}' not found`);
53
- }
54
- delete this.keys[kid];
55
- return true;
56
- }
57
- makeKeyPair(edhoc, keyID, privateKeySize, publicKeySize) {
58
- const kid = keyID.toString('hex');
59
- if (kid in this.keys === false) {
60
- throw new Error(`Key '${kid}' not found`);
61
- }
62
- try {
63
- const curveKE = [edhoc_1.EdhocSuite.Suite2, edhoc_1.EdhocSuite.Suite3, edhoc_1.EdhocSuite.Suite5].includes(edhoc.selectedSuite) ? p256_1.p256 :
64
- [edhoc_1.EdhocSuite.Suite0, edhoc_1.EdhocSuite.Suite1, edhoc_1.EdhocSuite.Suite4, edhoc_1.EdhocSuite.Suite6].includes(edhoc.selectedSuite) ? ed25519_1.x25519 : null;
65
- return {
66
- privateKey: Buffer.from(this.keys[kid]),
67
- publicKey: Buffer.from(curveKE.getPublicKey(this.keys[kid])).subarray(curveKE === p256_1.p256 ? 1 : 0)
68
- };
69
- }
70
- catch (error) {
71
- throw new Error(`Wrong key type`);
72
- }
73
- }
74
- keyAgreement(edhoc, keyID, publicKey, privateKeySize) {
75
- const kid = keyID.toString('hex');
76
- if (kid in this.keys === false) {
77
- throw new Error(`Key '${kid}' not found`);
78
- }
79
- // Key Exchange Curve
80
- const curveKE = [edhoc_1.EdhocSuite.Suite2, edhoc_1.EdhocSuite.Suite3, edhoc_1.EdhocSuite.Suite5].includes(edhoc.selectedSuite) ? p256_1.p256 :
81
- [edhoc_1.EdhocSuite.Suite0, edhoc_1.EdhocSuite.Suite1, edhoc_1.EdhocSuite.Suite4, edhoc_1.EdhocSuite.Suite6].includes(edhoc.selectedSuite) ? ed25519_1.x25519 : null;
82
- const publicKeyBuffer = (curveKE === p256_1.p256) ? Buffer.concat([Buffer.from([publicKey.byteLength == 64 ? 0x04 : 0x02]), publicKey]) : publicKey;
83
- const sharedSecrect = Buffer.from(curveKE.getSharedSecret(this.keys[kid], new Uint8Array(publicKeyBuffer)));
84
- return sharedSecrect.subarray(curveKE === p256_1.p256 ? 1 : 0);
85
- }
86
- sign(edhoc, keyID, input, signatureSize) {
87
- const kid = keyID.toString('hex');
88
- if (kid in this.keys === false) {
89
- throw new Error(`Key '${kid}' not found`);
90
- }
91
- // Signature Curve
92
- const curveSIG = [edhoc_1.EdhocSuite.Suite2, edhoc_1.EdhocSuite.Suite3, edhoc_1.EdhocSuite.Suite5, edhoc_1.EdhocSuite.Suite6].includes(edhoc.selectedSuite) ? p256_1.p256 :
93
- [edhoc_1.EdhocSuite.Suite0, edhoc_1.EdhocSuite.Suite1, edhoc_1.EdhocSuite.Suite4].includes(edhoc.selectedSuite) ? ed25519_1.ed25519 : null;
94
- if (null === curveSIG) {
95
- throw new Error('Unsupported suite');
96
- }
97
- const signature = curveSIG.sign((0, sha256_1.sha256)(input), new Uint8Array(this.keys[kid]));
98
- if (signature instanceof Uint8Array) {
99
- return Buffer.from(signature);
100
- }
101
- else if ('toCompactRawBytes' in signature) {
102
- return Buffer.from(signature.toCompactRawBytes());
103
- }
104
- else {
105
- throw new Error('Unsupported signature type');
106
- }
107
- }
108
- verify(edhoc, keyID, input, signature) {
109
- const kid = keyID.toString('hex');
110
- if (kid in this.keys === false) {
111
- throw new Error(`Key '${kid}' not found`);
112
- }
113
- // Signature Curve
114
- const curveSIG = [edhoc_1.EdhocSuite.Suite2, edhoc_1.EdhocSuite.Suite3, edhoc_1.EdhocSuite.Suite5, edhoc_1.EdhocSuite.Suite6].includes(edhoc.selectedSuite) ? p256_1.p256 :
115
- [edhoc_1.EdhocSuite.Suite0, edhoc_1.EdhocSuite.Suite1, edhoc_1.EdhocSuite.Suite4].includes(edhoc.selectedSuite) ? ed25519_1.ed25519 : null;
116
- if (null === curveSIG) {
117
- throw new Error('Unsupported suite');
118
- }
119
- const publicKey = this.keys[kid];
120
- const publicKeyBuffer = (curveSIG === p256_1.p256) ? Buffer.concat([Buffer.from([publicKey.byteLength == 64 ? 0x04 : 0x02]), publicKey]) : publicKey;
121
- if (!curveSIG.verify(new Uint8Array(signature), (0, sha256_1.sha256)(input), new Uint8Array(publicKeyBuffer))) {
122
- throw new Error('Signature not verified');
123
- }
124
- return true;
125
- }
126
- extract(edhoc, keyID, salt, keySize) {
127
- const kid = keyID.toString('hex');
128
- if (kid in this.keys === false) {
129
- throw new Error(`Key '${kid}' not found`);
130
- }
131
- return Buffer.from((0, hkdf_1.extract)(sha256_1.sha256, new Uint8Array(this.keys[kid]), new Uint8Array(salt)));
132
- }
133
- expand(edhoc, keyID, info, keySize) {
134
- const kid = keyID.toString('hex');
135
- if (kid in this.keys === false) {
136
- throw new Error(`Key '${kid}' not found`);
137
- }
138
- const expanded = Buffer.from((0, hkdf_1.expand)(sha256_1.sha256, new Uint8Array(this.keys[kid]), new Uint8Array(info), keySize));
139
- return expanded;
140
- }
141
- encrypt(edhoc, keyID, nonce, aad, plaintext, size) {
142
- const kid = keyID.toString('hex');
143
- if (kid in this.keys === false) {
144
- throw new Error(`Key '${kid}' not found`);
145
- }
146
- const tagLength = [edhoc_1.EdhocSuite.Suite0, edhoc_1.EdhocSuite.Suite2].includes(edhoc.selectedSuite) ? 8 : 16;
147
- const algorithm = [edhoc_1.EdhocSuite.Suite4, edhoc_1.EdhocSuite.Suite5].includes(edhoc.selectedSuite) ? 'chacha20-poly1305' :
148
- [edhoc_1.EdhocSuite.Suite6].includes(edhoc.selectedSuite) ? 'aes-128-gcm' : 'aes-128-ccm';
149
- const cipher = (0, crypto_1.createCipheriv)(algorithm, this.keys[kid], nonce, { authTagLength: tagLength });
150
- cipher.setAAD(aad, { plaintextLength: Buffer.byteLength(plaintext) });
151
- const encrypted = Buffer.concat([
152
- cipher.update(plaintext),
153
- cipher.final(),
154
- cipher.getAuthTag()
155
- ]);
156
- return encrypted;
157
- }
158
- decrypt(edhoc, keyID, nonce, aad, ciphertext, size) {
159
- const kid = keyID.toString('hex');
160
- if (kid in this.keys === false) {
161
- throw new Error(`Key '${kid}' not found`);
162
- }
163
- const tagLength = [edhoc_1.EdhocSuite.Suite0, edhoc_1.EdhocSuite.Suite2].includes(edhoc.selectedSuite) ? 8 : 16;
164
- const algorithm = [edhoc_1.EdhocSuite.Suite4, edhoc_1.EdhocSuite.Suite5].includes(edhoc.selectedSuite) ? 'chacha20-poly1305' :
165
- [edhoc_1.EdhocSuite.Suite6].includes(edhoc.selectedSuite) ? 'aes-128-gcm' : 'aes-128-ccm';
166
- const decipher = (0, crypto_1.createDecipheriv)(algorithm, this.keys[kid], nonce, { authTagLength: tagLength });
167
- decipher.setAuthTag(ciphertext.subarray(ciphertext.length - tagLength));
168
- decipher.setAAD(aad, { plaintextLength: ciphertext.length - tagLength });
169
- let decrypted = decipher.update(ciphertext.subarray(0, ciphertext.length - tagLength));
170
- decipher.final();
171
- return decrypted;
172
- }
173
- async hash(edhoc, data, hashSize) {
174
- return Buffer.from((0, sha256_1.sha256)(data));
175
- }
176
- }
177
- exports.DefaultEdhocCryptoManager = DefaultEdhocCryptoManager;
package/dist/edhoc.d.ts DELETED
@@ -1,346 +0,0 @@
1
- /**
2
- * Enumerates the types of credential formats that can be used with EDHOC.
3
- */
4
- export declare enum EdhocCredentialsFormat {
5
- kid = 4,// Represents a key identifier.
6
- x5chain = 33,// Represents an X.509 certificate chain.
7
- x5t = 34
8
- }
9
- /**
10
- * Base interface for EDHOC credentials.
11
- */
12
- export interface EdhocCredentials {
13
- format: EdhocCredentialsFormat;
14
- privateKeyID?: Buffer;
15
- publicKey?: Buffer;
16
- }
17
- /**
18
- * Extends EdhocCredentials for credentials using a key identifier (KID).
19
- */
20
- export interface EdhocCredentialsKID extends EdhocCredentials {
21
- format: EdhocCredentialsFormat.kid;
22
- kid: {
23
- kid: number;
24
- credentials?: Buffer;
25
- isCBOR?: boolean;
26
- };
27
- }
28
- /**
29
- * Extends EdhocCredentials for credentials using an X.509 certificate chain.
30
- */
31
- export interface EdhocCredentialsCertificateChain extends EdhocCredentials {
32
- format: EdhocCredentialsFormat.x5chain;
33
- x5chain: {
34
- certificates: Buffer[];
35
- };
36
- }
37
- /**
38
- * Extends EdhocCredentials for credentials using a hashed X.509 certificate.
39
- */
40
- export interface EdhocCredentialsCertificateHash extends EdhocCredentials {
41
- format: EdhocCredentialsFormat.x5t;
42
- x5t: {
43
- certificate?: Buffer;
44
- hash: Buffer;
45
- hashAlgorithm: EdhocCredentialsCertificateHashAlgorithm;
46
- };
47
- }
48
- /**
49
- * Enumerates the types of hash algorithms that can be used with hashed X.509 certificates.
50
- */
51
- export declare enum EdhocCredentialsCertificateHashAlgorithm {
52
- Sha256 = -16,// SHA-256 hash algorithm.
53
- Sha256_64 = -15
54
- }
55
- /**
56
- * Provides methods for managing EDHOC credentials.
57
- */
58
- export interface EdhocCredentialManager {
59
- /**
60
- * Fetches EDHOC credentials based on the provided EDHOC context.
61
- * @param edhoc The EDHOC context for which to fetch credentials.
62
- * @return A promise that resolves to the fetched EdhocCredentials or throws an error if not successful.
63
- */
64
- fetch(edhoc: EDHOC): Promise<EdhocCredentials> | EdhocCredentials | never;
65
- /**
66
- * Verifies EDHOC credentials based on the provided EDHOC context and credentials.
67
- * @param edhoc The EDHOC context against which to verify credentials.
68
- * @param credentials The credentials to verify.
69
- * @return A promise that resolves to the verified EdhocCredentials or throws an error if not successful.
70
- */
71
- verify(edhoc: EDHOC, credentials: EdhocCredentials): Promise<EdhocCredentials> | EdhocCredentials | never;
72
- }
73
- /**
74
- * Enumerates the types of cryptographic operations that can be performed with EDHOC.
75
- */
76
- export declare enum EdhocKeyType {
77
- MakeKeyPair = 0,// Used to generate a key pair.
78
- KeyAgreement = 1,// Used for key agreement operations.
79
- Signature = 2,// Used for creating digital signatures.
80
- Verify = 3,// Used for verifying digital signatures.
81
- Extract = 4,// Used for extracting key material.
82
- Expand = 5,// Used for expanding key material.
83
- Encrypt = 6,// Used for encrypting data.
84
- Decrypt = 7
85
- }
86
- /**
87
- * Type representing a public key in buffer format.
88
- */
89
- export type EdhocPublicKey = Buffer;
90
- /**
91
- * Type representing a private key in buffer format.
92
- */
93
- export type EdhocPrivateKey = Buffer;
94
- /**
95
- * Represents a tuple of public and private keys.
96
- */
97
- export interface PublicPrivateTuple {
98
- publicKey: EdhocPublicKey;
99
- privateKey: EdhocPrivateKey;
100
- }
101
- /**
102
- * Manages cryptographic functions necessary for the operation of EDHOC protocols.
103
- */
104
- export interface EdhocCryptoManager {
105
- /**
106
- * Generates a cryptographic key of the specified type.
107
- * @param edhoc The EDHOC session context.
108
- * @param keyType The type of key to generate, as defined in EdhocKeyType.
109
- * @param key Optional buffer containing seed or related data if necessary.
110
- * @return A promise resolving to a Buffer containing the generated key.
111
- */
112
- generateKey(edhoc: EDHOC, keyType: EdhocKeyType, key: Buffer): Promise<Buffer> | Buffer | never;
113
- /**
114
- * Destroys a cryptographic key identified by the keyID.
115
- * @param edhoc The EDHOC session context.
116
- * @param keyID Buffer identifying the key to destroy.
117
- * @return A promise resolving to true if the key was successfully destroyed.
118
- */
119
- destroyKey(edhoc: EDHOC, keyID: Buffer): Promise<boolean> | boolean | never;
120
- /**
121
- * Generates a public-private key pair.
122
- * @param edhoc The EDHOC session context.
123
- * @param keyID Buffer to identify the key pair for future operations.
124
- * @param privateKeySize Size in bytes for the private key.
125
- * @param publicKeySize Size in bytes for the public key.
126
- * @return A promise resolving to a PublicPrivateTuple containing both keys.
127
- // */
128
- makeKeyPair(edhoc: EDHOC, keyID: Buffer, privateKeySize: number, publicKeySize: number): Promise<PublicPrivateTuple> | PublicPrivateTuple | never;
129
- /**
130
- * Performs a key agreement operation using a public and a private key.
131
- * @param edhoc The EDHOC session context.
132
- * @param keyID Buffer identifying the key agreement process.
133
- * @param publicKey The public key of the other party.
134
- * @param privateKeySize Size of the private key used in the key agreement.
135
- * @return A promise resolving to the resultant private key.
136
- */
137
- keyAgreement(edhoc: EDHOC, keyID: Buffer, publicKey: EdhocPublicKey, privateKeySize: number): Promise<Buffer> | Buffer | never;
138
- /**
139
- * Signs data using a specified key.
140
- * @param edhoc The EDHOC session context.
141
- * @param keyID Buffer identifying the key to use for signing.
142
- * @param input Buffer containing the data to sign.
143
- * @param signatureSize The desired size of the signature.
144
- * @return A promise resolving to the signature.
145
- */
146
- sign(edhoc: EDHOC, keyID: Buffer, input: Buffer, signatureSize: number): Promise<Buffer> | Buffer | never;
147
- /**
148
- * Verifies a signature against the provided data.
149
- * @param edhoc The EDHOC session context.
150
- * @param keyID Buffer identifying the key to use for verification.
151
- * @param input Buffer containing the original data that was signed.
152
- * @param signature Buffer containing the signature to verify.
153
- * @return A promise resolving to true if the signature is valid.
154
- */
155
- verify(edhoc: EDHOC, keyID: Buffer, input: Buffer, signature: Buffer): Promise<boolean> | boolean | never;
156
- /**
157
- * Extracts a key using a salt.
158
- * @param edhoc The EDHOC session context.
159
- * @param keyID Buffer identifying the extraction process.
160
- * @param salt Buffer containing the salt used in the extraction.
161
- * @param keySize The desired size of the key to extract.
162
- * @return A promise resolving to the extracted key.
163
- */
164
- extract(edhoc: EDHOC, keyID: Buffer, salt: Buffer, keySize: number): Promise<Buffer> | Buffer | never;
165
- /**
166
- * Expands a key using provided information.
167
- * @param edhoc The EDHOC session context.
168
- * @param keyID Buffer identifying the expansion process.
169
- * @param info Buffer containing information used for key expansion.
170
- * @param keySize The desired size of the key after expansion.
171
- * @return A promise resolving to the expanded key.
172
- */
173
- expand(edhoc: EDHOC, keyID: Buffer, info: Buffer, keySize: number): Promise<Buffer> | Buffer | never;
174
- /**
175
- * Encrypts plaintext using a specified key and nonce.
176
- * @param edhoc The EDHOC session context.
177
- * @param keyID Buffer identifying the key to use for encryption.
178
- * @param nonce Buffer containing the nonce to use in the encryption process.
179
- * @param aad Buffer containing additional authenticated data.
180
- * @param plaintext Buffer containing the data to encrypt.
181
- * @param size The size of the output buffer.
182
- * @return A promise resolving to the ciphertext.
183
- */
184
- encrypt(edhoc: EDHOC, keyID: Buffer, nonce: Buffer, aad: Buffer, plaintext: Buffer, size: number): Promise<Buffer> | Buffer | never;
185
- /**
186
- * Decrypts ciphertext using a specified key and nonce.
187
- * @param edhoc The EDHOC session context.
188
- * @param keyID Buffer identifying the key to use for decryption.
189
- * @param nonce Buffer containing the nonce to use in the decryption process.
190
- * @param aad Buffer containing additional authenticated data.
191
- * @param ciphertext Buffer containing the data to decrypt.
192
- * @param size The size of the output buffer.
193
- * @return A promise resolving to the plaintext.
194
- */
195
- decrypt(edhoc: EDHOC, keyID: Buffer, nonce: Buffer, aad: Buffer, ciphertext: Buffer, size: number): Promise<Buffer> | Buffer | never;
196
- /**
197
- * Computes a hash of the given data.
198
- * @param edhoc The EDHOC session context.
199
- * @param data Buffer containing the data to hash.
200
- * @param hashSize The size of the hash to compute.
201
- * @return A promise resolving to the hash.
202
- */
203
- hash(edhoc: EDHOC, data: Buffer, hashSize: number): Promise<Buffer> | Buffer | never;
204
- }
205
- /**
206
- * Represents an EDHOC connection identifier which can be either a number or a Buffer.
207
- */
208
- export type EdhocConnectionID = number | Buffer;
209
- /**
210
- * Enumerates the methods available for EDHOC protocol exchanges.
211
- * Each method corresponds to different authentication mechanisms.
212
- */
213
- export declare enum EdhocMethod {
214
- Method0 = 0,
215
- Method1 = 1,
216
- Method2 = 2,
217
- Method3 = 3
218
- }
219
- /**
220
- * Enumerates the cipher suites available for EDHOC protocol operations.
221
- * Each suite represents a set of cryptographic algorithms.
222
- */
223
- export declare enum EdhocSuite {
224
- Suite0 = 0,
225
- Suite1 = 1,
226
- Suite2 = 2,
227
- Suite3 = 3,
228
- Suite4 = 4,
229
- Suite5 = 5,
230
- Suite6 = 6,
231
- Suite24 = 24,
232
- Suite25 = 25
233
- }
234
- /**
235
- * Represents an External Authorization Data (EAD) object used in EDHOC protocol exchanges.
236
- * EAD objects carry additional authorization information relevant to the session.
237
- */
238
- export interface EdhocEAD {
239
- label: number;
240
- value: Buffer;
241
- }
242
- /**
243
- * Describes the context for OSCORE (Object Security for Constrained RESTful Environments) derived from EDHOC.
244
- * OSCORE contexts are used to securely communicate over constrained networks.
245
- */
246
- export interface EdhocOscoreContext {
247
- masterSecret: Buffer;
248
- masterSalt: Buffer;
249
- senderId: Buffer;
250
- recipientId: Buffer;
251
- }
252
- /**
253
- * The EDHOC class encapsulates the EDHOC protocol logic, managing the lifecycle of an EDHOC session.
254
- */
255
- export declare class EDHOC {
256
- /**
257
- * The connection ID used by the local entity for this EDHOC session.
258
- */
259
- connectionID: EdhocConnectionID;
260
- /**
261
- * The connection ID used by the peer entity, which is read-only and set during the EDHOC message exchange.
262
- */
263
- readonly peerConnectionID: EdhocConnectionID;
264
- /**
265
- * The method of authentication to be used in this EDHOC session, as defined in EdhocMethod.
266
- */
267
- method: EdhocMethod;
268
- /**
269
- * A list of cipher suites supported by this session, providing flexibility in cryptographic negotiations.
270
- */
271
- cipherSuites: EdhocSuite[];
272
- /**
273
- * Represents the selected EDHOC cipher suite.
274
- */
275
- selectedSuite: EdhocSuite;
276
- /**
277
- * A logging function to log operational data during the EDHOC protocol execution.
278
- * @param name The name or description of the log entry.
279
- * @param data The data to be logged, typically related to protocol messages or internal state.
280
- */
281
- logger: (name: string, data: Buffer) => void;
282
- /**
283
- * Constructs an EDHOC protocol handler.
284
- * @param connectionID The identifier for this connection.
285
- * @param method The EDHOC method to be used for the session.
286
- * @param suite An array of supported cipher suites.
287
- * @param credentials A manager for handling credentials related to EDHOC.
288
- * @param crypto A crypto manager to handle cryptographic functions.
289
- */
290
- constructor(connectionID: EdhocConnectionID, method: EdhocMethod, suite: EdhocSuite[], credentials: EdhocCredentialManager, crypto: EdhocCryptoManager);
291
- /**
292
- * Composes the first EDHOC message.
293
- * @param ead Optional array of EAD objects to include in the message.
294
- * @return A promise that resolves to the composed message buffer.
295
- */
296
- composeMessage1(ead?: EdhocEAD[]): Promise<Buffer> | never;
297
- /**
298
- * Processes the received first EDHOC message.
299
- * @param message The received message buffer.
300
- * @return A promise that resolves to an array of EAD objects extracted from the message.
301
- */
302
- processMessage1(message: Buffer): Promise<EdhocEAD[]> | never;
303
- /**
304
- * Composes the second EDHOC message.
305
- * @param ead Optional array of EAD objects to include in the message.
306
- * @return A promise that resolves to the composed message buffer.
307
- */
308
- composeMessage2(ead?: EdhocEAD[]): Promise<Buffer> | never;
309
- /**
310
- * Processes the received second EDHOC message.
311
- * @param message The received message buffer.
312
- * @return A promise that resolves to an array of EAD objects extracted from the message.
313
- */
314
- processMessage2(message: Buffer): Promise<EdhocEAD[]> | never;
315
- /**
316
- * Composes the third EDHOC message.
317
- * @param ead Optional array of EAD objects to include in the message.
318
- * @return A promise that resolves to the composed message buffer.
319
- */
320
- composeMessage3(ead?: EdhocEAD[]): Promise<Buffer> | never;
321
- /**
322
- * Processes the received third EDHOC message.
323
- * @param message The received message buffer.
324
- * @return A promise that resolves to an array of EAD objects extracted from the message.
325
- */
326
- processMessage3(message: Buffer): Promise<EdhocEAD[]> | never;
327
- /**
328
- * Composes the fourth and final EDHOC message.
329
- * @param ead Optional array of EAD objects to include in the message.
330
- * @return A promise that resolves to the composed message buffer.
331
- */
332
- composeMessage4(ead?: EdhocEAD[]): Promise<Buffer> | never;
333
- /**
334
- * Processes the received fourth EDHOC message.
335
- * @param message The received message buffer.
336
- * @return A promise that resolves to an array of EAD objects extracted from the message.
337
- */
338
- processMessage4(message: Buffer): Promise<EdhocEAD[]> | never;
339
- /**
340
- * Exports the OSCORE context derived from the EDHOC session.
341
- * @return A promise that resolves to the OSCORE context used for secured communication in constrained environments.
342
- */
343
- exportOSCORE(): Promise<EdhocOscoreContext> | never;
344
- }
345
- export * from './bindings';
346
- //# sourceMappingURL=edhoc.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"edhoc.d.ts","sourceRoot":"","sources":["../lib/edhoc.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,sBAAsB;IAC9B,GAAG,IAAI,CAAU,+BAA+B;IAChD,OAAO,KAAK,CAAK,yCAAyC;IAC1D,GAAG,KAAK;CACX;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC7B,MAAM,EAAE,sBAAsB,CAAC;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,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AAK;IAEjE;;;;OAIG;IACI,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,GAAG,KAAK;IAEpE;;;;OAIG;IACI,eAAe,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,KAAK;IAEjE;;;;OAIG;IACI,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,GAAG,KAAK;IAEpE;;;;OAIG;IACI,eAAe,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,KAAK;IAEjE;;;;OAIG;IACI,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,GAAG,KAAK;IAEpE;;;;OAIG;IACI,eAAe,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,KAAK;IAEjE;;;;OAIG;IACI,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,GAAG,KAAK;IAEpE;;;OAGG;IACI,YAAY,IAAI,OAAO,CAAC,kBAAkB,CAAC,GAAG,KAAK;CAC7D;AAED,cAAc,YAAY,CAAC"}
package/dist/edhoc.js DELETED
@@ -1,76 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.EdhocSuite = exports.EdhocMethod = exports.EdhocKeyType = exports.EdhocCredentialsCertificateHashAlgorithm = exports.EdhocCredentialsFormat = void 0;
18
- /**
19
- * Enumerates the types of credential formats that can be used with EDHOC.
20
- */
21
- var EdhocCredentialsFormat;
22
- (function (EdhocCredentialsFormat) {
23
- EdhocCredentialsFormat[EdhocCredentialsFormat["kid"] = 4] = "kid";
24
- EdhocCredentialsFormat[EdhocCredentialsFormat["x5chain"] = 33] = "x5chain";
25
- EdhocCredentialsFormat[EdhocCredentialsFormat["x5t"] = 34] = "x5t"; // Represents a hashed X.509 certificate.
26
- })(EdhocCredentialsFormat || (exports.EdhocCredentialsFormat = EdhocCredentialsFormat = {}));
27
- /**
28
- * Enumerates the types of hash algorithms that can be used with hashed X.509 certificates.
29
- */
30
- var EdhocCredentialsCertificateHashAlgorithm;
31
- (function (EdhocCredentialsCertificateHashAlgorithm) {
32
- EdhocCredentialsCertificateHashAlgorithm[EdhocCredentialsCertificateHashAlgorithm["Sha256"] = -16] = "Sha256";
33
- EdhocCredentialsCertificateHashAlgorithm[EdhocCredentialsCertificateHashAlgorithm["Sha256_64"] = -15] = "Sha256_64"; // SHA-256 truncated to 64 bits.
34
- })(EdhocCredentialsCertificateHashAlgorithm || (exports.EdhocCredentialsCertificateHashAlgorithm = EdhocCredentialsCertificateHashAlgorithm = {}));
35
- /**
36
- * Enumerates the types of cryptographic operations that can be performed with EDHOC.
37
- */
38
- var EdhocKeyType;
39
- (function (EdhocKeyType) {
40
- EdhocKeyType[EdhocKeyType["MakeKeyPair"] = 0] = "MakeKeyPair";
41
- EdhocKeyType[EdhocKeyType["KeyAgreement"] = 1] = "KeyAgreement";
42
- EdhocKeyType[EdhocKeyType["Signature"] = 2] = "Signature";
43
- EdhocKeyType[EdhocKeyType["Verify"] = 3] = "Verify";
44
- EdhocKeyType[EdhocKeyType["Extract"] = 4] = "Extract";
45
- EdhocKeyType[EdhocKeyType["Expand"] = 5] = "Expand";
46
- EdhocKeyType[EdhocKeyType["Encrypt"] = 6] = "Encrypt";
47
- EdhocKeyType[EdhocKeyType["Decrypt"] = 7] = "Decrypt";
48
- })(EdhocKeyType || (exports.EdhocKeyType = EdhocKeyType = {}));
49
- /**
50
- * Enumerates the methods available for EDHOC protocol exchanges.
51
- * Each method corresponds to different authentication mechanisms.
52
- */
53
- var EdhocMethod;
54
- (function (EdhocMethod) {
55
- EdhocMethod[EdhocMethod["Method0"] = 0] = "Method0";
56
- EdhocMethod[EdhocMethod["Method1"] = 1] = "Method1";
57
- EdhocMethod[EdhocMethod["Method2"] = 2] = "Method2";
58
- EdhocMethod[EdhocMethod["Method3"] = 3] = "Method3";
59
- })(EdhocMethod || (exports.EdhocMethod = EdhocMethod = {}));
60
- /**
61
- * Enumerates the cipher suites available for EDHOC protocol operations.
62
- * Each suite represents a set of cryptographic algorithms.
63
- */
64
- var EdhocSuite;
65
- (function (EdhocSuite) {
66
- EdhocSuite[EdhocSuite["Suite0"] = 0] = "Suite0";
67
- EdhocSuite[EdhocSuite["Suite1"] = 1] = "Suite1";
68
- EdhocSuite[EdhocSuite["Suite2"] = 2] = "Suite2";
69
- EdhocSuite[EdhocSuite["Suite3"] = 3] = "Suite3";
70
- EdhocSuite[EdhocSuite["Suite4"] = 4] = "Suite4";
71
- EdhocSuite[EdhocSuite["Suite5"] = 5] = "Suite5";
72
- EdhocSuite[EdhocSuite["Suite6"] = 6] = "Suite6";
73
- EdhocSuite[EdhocSuite["Suite24"] = 24] = "Suite24";
74
- EdhocSuite[EdhocSuite["Suite25"] = 25] = "Suite25";
75
- })(EdhocSuite || (exports.EdhocSuite = EdhocSuite = {}));
76
- __exportStar(require("./bindings"), exports);
package/dist/index.d.ts DELETED
@@ -1,4 +0,0 @@
1
- export * from "./edhoc";
2
- export * from "./crypto";
3
- export * from "./credentials";
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC"}
package/dist/index.js DELETED
@@ -1,19 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./edhoc"), exports);
18
- __exportStar(require("./crypto"), exports);
19
- __exportStar(require("./credentials"), exports);