@nmshd/transport 6.60.3 → 6.61.0-secureelements.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/buildInformation.js +5 -5
- package/dist/core/CoreCrypto.d.ts +45 -1
- package/dist/core/CoreCrypto.d.ts.map +1 -1
- package/dist/core/CoreCrypto.js +64 -0
- package/dist/core/CoreCrypto.js.map +1 -1
- package/dist/core/CryptoProviderMapping.d.ts +50 -0
- package/dist/core/CryptoProviderMapping.d.ts.map +1 -0
- package/dist/core/CryptoProviderMapping.js +142 -0
- package/dist/core/CryptoProviderMapping.js.map +1 -0
- package/dist/core/Transport.d.ts +6 -1
- package/dist/core/Transport.d.ts.map +1 -1
- package/dist/core/Transport.js +16 -2
- package/dist/core/Transport.js.map +1 -1
- package/dist/core/backbone/RESTClient.d.ts.map +1 -1
- package/dist/core/backbone/RESTClient.js +8 -10
- package/dist/core/backbone/RESTClient.js.map +1 -1
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -0
- package/dist/core/index.js.map +1 -1
- package/dist/modules/accounts/AccountController.d.ts.map +1 -1
- package/dist/modules/accounts/AccountController.js +64 -17
- package/dist/modules/accounts/AccountController.js.map +1 -1
- package/dist/modules/devices/DeviceController.d.ts +2 -2
- package/dist/modules/devices/DeviceController.d.ts.map +1 -1
- package/dist/modules/devices/DeviceController.js +1 -1
- package/dist/modules/devices/DeviceController.js.map +1 -1
- package/dist/modules/devices/DeviceSecretController.d.ts +2 -2
- package/dist/modules/devices/DeviceSecretController.d.ts.map +1 -1
- package/dist/modules/devices/DeviceSecretController.js +23 -6
- package/dist/modules/devices/DeviceSecretController.js.map +1 -1
- package/dist/modules/files/FileController.d.ts.map +1 -1
- package/dist/modules/files/FileController.js +1 -3
- package/dist/modules/files/FileController.js.map +1 -1
- package/dist/modules/messages/MessageController.d.ts.map +1 -1
- package/dist/modules/messages/MessageController.js +2 -5
- package/dist/modules/messages/MessageController.js.map +1 -1
- package/dist/modules/messages/transmission/MessageContentWrapper.js +1 -2
- package/dist/modules/messages/transmission/MessageContentWrapper.js.map +1 -1
- package/dist/modules/relationships/RelationshipsController.d.ts.map +1 -1
- package/dist/modules/relationships/RelationshipsController.js +1 -3
- package/dist/modules/relationships/RelationshipsController.js.map +1 -1
- package/dist/modules/sync/SyncController.d.ts.map +1 -1
- package/dist/modules/sync/SyncController.js +3 -5
- package/dist/modules/sync/SyncController.js.map +1 -1
- package/package.json +9 -7
package/dist/buildInformation.js
CHANGED
|
@@ -4,11 +4,11 @@ exports.buildInformation = void 0;
|
|
|
4
4
|
const ts_serval_1 = require("@js-soft/ts-serval");
|
|
5
5
|
const crypto_1 = require("@nmshd/crypto");
|
|
6
6
|
exports.buildInformation = {
|
|
7
|
-
version: "6.
|
|
8
|
-
build: "
|
|
9
|
-
date: "2025-07-
|
|
10
|
-
commit: "
|
|
11
|
-
dependencies: {"@js-soft/docdb-access-abstractions":"1.
|
|
7
|
+
version: "6.61.0-secureelements.1",
|
|
8
|
+
build: "310",
|
|
9
|
+
date: "2025-07-07T08:28:24+00:00",
|
|
10
|
+
commit: "141ad0759da3ab6d793b7113ca707815d45fffc2",
|
|
11
|
+
dependencies: {"@js-soft/docdb-access-abstractions":"1.2.0","@js-soft/logging-abstractions":"^1.0.1","@js-soft/simple-logger":"1.0.5","@js-soft/ts-utils":"^2.3.3","@nmshd/core-types":"*","@nmshd/crypto":"2.2.0-alpha.3","@nmshd/rs-crypto-node":"0.14.0","axios":"^1.10.0","fast-json-patch":"^3.1.1","form-data":"^4.0.3","https-proxy-agent":"^7.0.6","json-stringify-safe":"^5.0.1","lodash":"^4.17.21","luxon":"^3.6.1","qs":"^6.14.0","reflect-metadata":"^0.2.2","ts-simple-nameof":"^1.3.1","uuid":"^11.1.0"},
|
|
12
12
|
libraries: {
|
|
13
13
|
crypto: crypto_1.buildInformation,
|
|
14
14
|
serval: ts_serval_1.buildInformation
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CoreBuffer, CryptoCipher, CryptoEncryptionAlgorithm, CryptoExchangeKeypair, CryptoExchangePublicKey, CryptoExchangeSecrets, CryptoSecretKey, CryptoSignature, CryptoSignatureKeypair, CryptoSignaturePrivateKey, CryptoSignaturePublicKey } from "@nmshd/crypto";
|
|
1
|
+
import { CoreBuffer, CryptoCipher, CryptoEncryptionAlgorithm, CryptoExchangeKeypair, CryptoExchangePublicKey, CryptoExchangeSecrets, CryptoSecretKey, CryptoSignature, CryptoSignatureKeypair, CryptoSignaturePrivateKey, CryptoSignaturePublicKey, DeviceBoundDerivedKeyHandle, DeviceBoundKeyHandle, PortableDerivedKeyHandle, PortableKeyHandle, ProviderIdentifier } from "@nmshd/crypto";
|
|
2
2
|
import { TransportVersion } from "./types/TransportVersion";
|
|
3
3
|
export declare abstract class CoreCrypto {
|
|
4
4
|
/**
|
|
@@ -29,6 +29,50 @@ export declare abstract class CoreCrypto {
|
|
|
29
29
|
* @returns A Promise object resolving into a new CryptoSecretKey
|
|
30
30
|
*/
|
|
31
31
|
static generateSecretKey(version?: TransportVersion): Promise<CryptoSecretKey>;
|
|
32
|
+
/**
|
|
33
|
+
* Generates a handle-based secret key for symmetric encryption.
|
|
34
|
+
* Depending on the given version, different algorithms are used:
|
|
35
|
+
*
|
|
36
|
+
* v1: AES256_GCM
|
|
37
|
+
*
|
|
38
|
+
* @param providerIdent The provider identifier
|
|
39
|
+
* @param version The version which should be used, "latest" is the default.
|
|
40
|
+
* @returns A Promise object resolving into a new CryptoSecretKeyHandle.
|
|
41
|
+
*/
|
|
42
|
+
static generateDeviceBoundKeyHandle(providerIdent: ProviderIdentifier, version?: TransportVersion): Promise<DeviceBoundKeyHandle>;
|
|
43
|
+
/**
|
|
44
|
+
* Generates a handle-based secret key for symmetric encryption.
|
|
45
|
+
* Depending on the given version, different algorithms are used:
|
|
46
|
+
*
|
|
47
|
+
* v1: AES256_GCM
|
|
48
|
+
*
|
|
49
|
+
* @param providerIdent The provider identifier
|
|
50
|
+
* @param version The version which should be used, "latest" is the default.
|
|
51
|
+
* @returns A Promise object resolving into a new CryptoSecretKeyHandle.
|
|
52
|
+
*/
|
|
53
|
+
static generatePortableKeyHandle(providerIdent: ProviderIdentifier, version?: TransportVersion): Promise<PortableKeyHandle>;
|
|
54
|
+
/**
|
|
55
|
+
* Generates a handle-based secret key for symmetric encryption.
|
|
56
|
+
* Depending on the given version, different algorithms are used:
|
|
57
|
+
*
|
|
58
|
+
* v1: AES256_GCM
|
|
59
|
+
*
|
|
60
|
+
* @param providerIdent The provider identifier
|
|
61
|
+
* @param version The version which should be used, "latest" is the default.
|
|
62
|
+
* @returns A Promise object resolving into a new CryptoSecretKeyHandle.
|
|
63
|
+
*/
|
|
64
|
+
static generateDeviceBoundDerivationHandle(baseKey: DeviceBoundKeyHandle, keyId: number, context: string): Promise<DeviceBoundDerivedKeyHandle>;
|
|
65
|
+
/**
|
|
66
|
+
* Generates a handle-based secret key for symmetric encryption.
|
|
67
|
+
* Depending on the given version, different algorithms are used:
|
|
68
|
+
*
|
|
69
|
+
* v1: AES256_GCM
|
|
70
|
+
*
|
|
71
|
+
* @param providerIdent The provider identifier
|
|
72
|
+
* @param version The version which should be used, "latest" is the default.
|
|
73
|
+
* @returns A Promise object resolving into a new CryptoSecretKeyHandle.
|
|
74
|
+
*/
|
|
75
|
+
static generatePortableDerivationHandle(baseKey: PortableKeyHandle, keyId: number, context: string): Promise<PortableDerivedKeyHandle>;
|
|
32
76
|
/**
|
|
33
77
|
* Generates a high entropy key / hash derived from a low entropy human readable/memorable master password, a unique salt,
|
|
34
78
|
* the given symmetric algorithm and the version. Depending on the given version, different key derivation algorithms are used.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoreCrypto.d.ts","sourceRoot":"","sources":["../../src/core/CoreCrypto.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,UAAU,EACV,YAAY,
|
|
1
|
+
{"version":3,"file":"CoreCrypto.d.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,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,GAAE,gBAA0C,GAAG,OAAO,CAAC,UAAU,CAAC;IAUvJ;;;;;OAKG;WACiB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;WAIzC,qBAAqB,IAAI,OAAO,CAAC,MAAM,CAAC;IAI5D,OAAO,CAAC,MAAM,CAAC,cAAc;CAGhC"}
|
package/dist/core/CoreCrypto.js
CHANGED
|
@@ -58,6 +58,70 @@ class CoreCrypto {
|
|
|
58
58
|
throw this.invalidVersion(version);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Generates a handle-based secret key for symmetric encryption.
|
|
63
|
+
* Depending on the given version, different algorithms are used:
|
|
64
|
+
*
|
|
65
|
+
* v1: AES256_GCM
|
|
66
|
+
*
|
|
67
|
+
* @param providerIdent The provider identifier
|
|
68
|
+
* @param version The version which should be used, "latest" is the default.
|
|
69
|
+
* @returns A Promise object resolving into a new CryptoSecretKeyHandle.
|
|
70
|
+
*/
|
|
71
|
+
static async generateDeviceBoundKeyHandle(providerIdent, version = TransportVersion_1.TransportVersion.Latest) {
|
|
72
|
+
switch (version) {
|
|
73
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
74
|
+
case TransportVersion_1.TransportVersion.V1:
|
|
75
|
+
return await crypto_1.CryptoEncryptionHandle.generateDeviceBoundKeyHandle(providerIdent, 3 /* CryptoEncryptionAlgorithm.XCHACHA20_POLY1305 */, 2 /* CryptoHashAlgorithm.SHA512 */);
|
|
76
|
+
default:
|
|
77
|
+
throw this.invalidVersion(version);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Generates a handle-based secret key for symmetric encryption.
|
|
82
|
+
* Depending on the given version, different algorithms are used:
|
|
83
|
+
*
|
|
84
|
+
* v1: AES256_GCM
|
|
85
|
+
*
|
|
86
|
+
* @param providerIdent The provider identifier
|
|
87
|
+
* @param version The version which should be used, "latest" is the default.
|
|
88
|
+
* @returns A Promise object resolving into a new CryptoSecretKeyHandle.
|
|
89
|
+
*/
|
|
90
|
+
static async generatePortableKeyHandle(providerIdent, version = TransportVersion_1.TransportVersion.Latest) {
|
|
91
|
+
switch (version) {
|
|
92
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
93
|
+
case TransportVersion_1.TransportVersion.V1:
|
|
94
|
+
return await crypto_1.CryptoEncryptionHandle.generatePortableKeyHandle(providerIdent, 3 /* CryptoEncryptionAlgorithm.XCHACHA20_POLY1305 */, 2 /* CryptoHashAlgorithm.SHA512 */);
|
|
95
|
+
default:
|
|
96
|
+
throw this.invalidVersion(version);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Generates a handle-based secret key for symmetric encryption.
|
|
101
|
+
* Depending on the given version, different algorithms are used:
|
|
102
|
+
*
|
|
103
|
+
* v1: AES256_GCM
|
|
104
|
+
*
|
|
105
|
+
* @param providerIdent The provider identifier
|
|
106
|
+
* @param version The version which should be used, "latest" is the default.
|
|
107
|
+
* @returns A Promise object resolving into a new CryptoSecretKeyHandle.
|
|
108
|
+
*/
|
|
109
|
+
static async generateDeviceBoundDerivationHandle(baseKey, keyId, context) {
|
|
110
|
+
return await crypto_1.CryptoDerivationHandle.deriveDeviceBoundKeyHandle(baseKey, keyId, context);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Generates a handle-based secret key for symmetric encryption.
|
|
114
|
+
* Depending on the given version, different algorithms are used:
|
|
115
|
+
*
|
|
116
|
+
* v1: AES256_GCM
|
|
117
|
+
*
|
|
118
|
+
* @param providerIdent The provider identifier
|
|
119
|
+
* @param version The version which should be used, "latest" is the default.
|
|
120
|
+
* @returns A Promise object resolving into a new CryptoSecretKeyHandle.
|
|
121
|
+
*/
|
|
122
|
+
static async generatePortableDerivationHandle(baseKey, keyId, context) {
|
|
123
|
+
return await crypto_1.CryptoDerivationHandle.derivePortableKeyHandle(baseKey, keyId, context);
|
|
124
|
+
}
|
|
61
125
|
/**
|
|
62
126
|
* Generates a high entropy key / hash derived from a low entropy human readable/memorable master password, a unique salt,
|
|
63
127
|
* the given symmetric algorithm and the version. Depending on the given version, different key derivation algorithms are used.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoreCrypto.js","sourceRoot":"","sources":["../../src/core/CoreCrypto.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"CoreCrypto.js","sourceRoot":"","sources":["../../src/core/CoreCrypto.ts"],"names":[],"mappings":";;;AAAA,0CA6BuB;AACvB,kCAA4C;AAC5C,qDAAkD;AAClD,+DAA4D;AAE5D,MAAsB,UAAU;IAC5B;;;;;;;OAOG;IACI,MAAM,CAAC,KAAK,CAAC,wBAAwB,CAAC,UAA4B,mCAAgB,CAAC,MAAM;QAC5F,QAAQ,OAAO,EAAE,CAAC;YACd,uEAAuE;YACvE,KAAK,mCAAgB,CAAC,EAAE;gBACpB,OAAO,MAAM,yBAAgB,CAAC,eAAe,gDAAwC,CAAC;YAC1F;gBACI,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QAC3C,CAAC;IACL,CAAC;IAED;;;;;;;;OAQG;IACI,MAAM,CAAC,KAAK,CAAC,uBAAuB,CAAC,UAA4B,mCAAgB,CAAC,MAAM;QAC3F,QAAQ,OAAO,EAAE,CAAC;YACd,uEAAuE;YACvE,KAAK,mCAAgB,CAAC,EAAE;gBACpB,OAAO,MAAM,uBAAc,CAAC,eAAe,6CAAqC,CAAC;YACrF;gBACI,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QAC3C,CAAC;IACL,CAAC;IAED;;;;;;;OAOG;IACI,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC,UAA4B,mCAAgB,CAAC,MAAM;QACrF,QAAQ,OAAO,EAAE,CAAC;YACd,uEAAuE;YACvE,KAAK,mCAAgB,CAA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AS,CAAC,CAAC;YAC7D;gBACI,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QAC3C,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAY;QACnC,OAAO,MAAM,qBAAY,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,qBAAqB;QACrC,OAAO,MAAM,wBAAiB,CAAC,oBAAoB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAClE,CAAC;IAEO,MAAM,CAAC,cAAc,CAAC,OAAyB;QACnD,OAAO,IAAI,+BAAc,CAAC,eAAe,OAAO,oBAAoB,CAAC,CAAC;IAC1E,CAAC;CACJ;AAvUD,gCAuUC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { DeviceBoundKeyHandle, PortableKeyHandle } from "@nmshd/crypto";
|
|
2
|
+
import { SecurityLevel } from "@nmshd/rs-crypto-types";
|
|
3
|
+
export declare const CryptoProviderTypes: {
|
|
4
|
+
readonly Software: "Software";
|
|
5
|
+
readonly Hardware: "Hardware";
|
|
6
|
+
readonly Network: "Network";
|
|
7
|
+
readonly Legacy: "Legacy";
|
|
8
|
+
};
|
|
9
|
+
export declare const CryptoPurpose: {
|
|
10
|
+
readonly DeviceKeyPair: "deviceKeyPair";
|
|
11
|
+
readonly BaseKey: "baseKey";
|
|
12
|
+
};
|
|
13
|
+
type CryptoPurpose = (typeof CryptoPurpose)[keyof typeof CryptoPurpose];
|
|
14
|
+
export declare const CryptoKeyType: {
|
|
15
|
+
readonly Signature: "signature";
|
|
16
|
+
readonly Encryption: "encryption";
|
|
17
|
+
readonly Derivation: "derivation";
|
|
18
|
+
readonly Exchange: "exchange";
|
|
19
|
+
};
|
|
20
|
+
type CryptoKeyType = (typeof CryptoKeyType)[keyof typeof CryptoKeyType];
|
|
21
|
+
export declare const CryptoObject: {
|
|
22
|
+
readonly AccountController: "AccountController";
|
|
23
|
+
readonly AnonymousTokenController: "AnonymousTokenController";
|
|
24
|
+
readonly Certificate: "Certificate";
|
|
25
|
+
readonly DeviceController: "DeviceController";
|
|
26
|
+
readonly DeviceSecretController: "DeviceSecretController";
|
|
27
|
+
readonly IdentityController: "IdentityController";
|
|
28
|
+
readonly FileController: "FileController";
|
|
29
|
+
readonly MessageController: "MessageController";
|
|
30
|
+
readonly RelationshipTemplateController: "RelationshipTemplateController";
|
|
31
|
+
readonly RelationshipsController: "RelationshipsController";
|
|
32
|
+
readonly RelationshipSecretController: "RelationshipSecretController";
|
|
33
|
+
readonly SecretController: "SecretController";
|
|
34
|
+
readonly TokenController: "TokenController";
|
|
35
|
+
};
|
|
36
|
+
type CryptoObject = (typeof CryptoObject)[keyof typeof CryptoObject];
|
|
37
|
+
export type CryptoOperationPreferences = Partial<Record<CryptoObject, Partial<Record<CryptoKeyType, SecurityLevel | Partial<Record<Exclude<CryptoPurpose, undefined>, SecurityLevel>>>>>>;
|
|
38
|
+
export declare const DEFAULT_CRYPTO_OPERATION_PREFERENCES: CryptoOperationPreferences;
|
|
39
|
+
export declare const ALL_CRYPTO_PROVIDERS: string[];
|
|
40
|
+
export declare class CryptoProviderMapping {
|
|
41
|
+
private static readonly ALLOWED_CRYPTO_OPERATIONS;
|
|
42
|
+
private static readonly DEFAULT_OPERATION_PREFERENCES;
|
|
43
|
+
private static readonly FALLBACK_PREFERENCE;
|
|
44
|
+
private readonly _objectOperationPreferences;
|
|
45
|
+
constructor(preferences?: CryptoOperationPreferences);
|
|
46
|
+
private getPreferredProviderLevel;
|
|
47
|
+
getPreferredProviderKeyHandle(cryptoObject: CryptoObject, cryptoOperation: CryptoKeyType, isPortable: boolean, purpose?: CryptoPurpose): Promise<DeviceBoundKeyHandle | PortableKeyHandle>;
|
|
48
|
+
}
|
|
49
|
+
export {};
|
|
50
|
+
//# sourceMappingURL=CryptoProviderMapping.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
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;IAIjG,OAAO,CAAC,yBAAyB;IAsCpB,6BAA6B,CACtC,YAAY,EAAE,YAAY,EAC1B,eAAe,EAAE,aAAa,EAC9B,UAAU,EAAE,OAAO,EACnB,OAAO,CAAC,EAAE,aAAa,GACxB,OAAO,CAAC,oBAAoB,GAAG,iBAAiB,CAAC;CAoBvD"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CryptoProviderMapping = exports.ALL_CRYPTO_PROVIDERS = exports.DEFAULT_CRYPTO_OPERATION_PREFERENCES = exports.CryptoObject = exports.CryptoKeyType = exports.CryptoPurpose = exports.CryptoProviderTypes = void 0;
|
|
4
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
5
|
+
const crypto_1 = require("@nmshd/crypto");
|
|
6
|
+
const CoreCrypto_1 = require("./CoreCrypto");
|
|
7
|
+
exports.CryptoProviderTypes = {
|
|
8
|
+
Software: "Software",
|
|
9
|
+
Hardware: "Hardware",
|
|
10
|
+
Network: "Network",
|
|
11
|
+
Legacy: "Legacy"
|
|
12
|
+
};
|
|
13
|
+
exports.CryptoPurpose = {
|
|
14
|
+
DeviceKeyPair: "deviceKeyPair",
|
|
15
|
+
BaseKey: "baseKey"
|
|
16
|
+
};
|
|
17
|
+
exports.CryptoKeyType = {
|
|
18
|
+
Signature: "signature",
|
|
19
|
+
Encryption: "encryption",
|
|
20
|
+
Derivation: "derivation",
|
|
21
|
+
Exchange: "exchange"
|
|
22
|
+
};
|
|
23
|
+
exports.CryptoObject = {
|
|
24
|
+
AccountController: "AccountController",
|
|
25
|
+
AnonymousTokenController: "AnonymousTokenController",
|
|
26
|
+
Certificate: "Certificate",
|
|
27
|
+
DeviceController: "DeviceController",
|
|
28
|
+
DeviceSecretController: "DeviceSecretController",
|
|
29
|
+
IdentityController: "IdentityController",
|
|
30
|
+
FileController: "FileController",
|
|
31
|
+
MessageController: "MessageController",
|
|
32
|
+
RelationshipTemplateController: "RelationshipTemplateController",
|
|
33
|
+
RelationshipsController: "RelationshipsController",
|
|
34
|
+
RelationshipSecretController: "RelationshipSecretController",
|
|
35
|
+
SecretController: "SecretController",
|
|
36
|
+
TokenController: "TokenController"
|
|
37
|
+
};
|
|
38
|
+
exports.DEFAULT_CRYPTO_OPERATION_PREFERENCES = {
|
|
39
|
+
[exports.CryptoObject.AccountController]: {},
|
|
40
|
+
[exports.CryptoObject.AnonymousTokenController]: {},
|
|
41
|
+
[exports.CryptoObject.Certificate]: {},
|
|
42
|
+
[exports.CryptoObject.DeviceController]: {},
|
|
43
|
+
[exports.CryptoObject.DeviceSecretController]: {},
|
|
44
|
+
[exports.CryptoObject.FileController]: {
|
|
45
|
+
[exports.CryptoKeyType.Encryption]: exports.CryptoProviderTypes.Software
|
|
46
|
+
},
|
|
47
|
+
[exports.CryptoObject.IdentityController]: {},
|
|
48
|
+
[exports.CryptoObject.MessageController]: {
|
|
49
|
+
[exports.CryptoKeyType.Encryption]: exports.CryptoProviderTypes.Software
|
|
50
|
+
},
|
|
51
|
+
[exports.CryptoObject.RelationshipTemplateController]: {
|
|
52
|
+
[exports.CryptoKeyType.Encryption]: exports.CryptoProviderTypes.Software
|
|
53
|
+
},
|
|
54
|
+
[exports.CryptoObject.RelationshipsController]: {},
|
|
55
|
+
[exports.CryptoObject.RelationshipSecretController]: {},
|
|
56
|
+
[exports.CryptoObject.SecretController]: {
|
|
57
|
+
[exports.CryptoKeyType.Exchange]: exports.CryptoProviderTypes.Software
|
|
58
|
+
},
|
|
59
|
+
[exports.CryptoObject.TokenController]: {
|
|
60
|
+
[exports.CryptoKeyType.Encryption]: exports.CryptoProviderTypes.Software
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
// To be removed after initialization of ts-crypto is adjusted
|
|
64
|
+
exports.ALL_CRYPTO_PROVIDERS = ["SoftwareProvider"];
|
|
65
|
+
class CryptoProviderMapping {
|
|
66
|
+
static { this.ALLOWED_CRYPTO_OPERATIONS = {
|
|
67
|
+
[exports.CryptoObject.AccountController]: [exports.CryptoKeyType.Encryption, exports.CryptoKeyType.Signature],
|
|
68
|
+
[exports.CryptoObject.AnonymousTokenController]: [exports.CryptoKeyType.Derivation],
|
|
69
|
+
[exports.CryptoObject.Certificate]: [exports.CryptoKeyType.Encryption],
|
|
70
|
+
[exports.CryptoObject.DeviceController]: [exports.CryptoKeyType.Signature, exports.CryptoKeyType.Encryption],
|
|
71
|
+
[exports.CryptoObject.DeviceSecretController]: [exports.CryptoKeyType.Derivation],
|
|
72
|
+
[exports.CryptoObject.FileController]: [exports.CryptoKeyType.Encryption],
|
|
73
|
+
[exports.CryptoObject.IdentityController]: [exports.CryptoKeyType.Encryption],
|
|
74
|
+
[exports.CryptoObject.MessageController]: [exports.CryptoKeyType.Encryption],
|
|
75
|
+
[exports.CryptoObject.RelationshipTemplateController]: [exports.CryptoKeyType.Derivation, exports.CryptoKeyType.Encryption],
|
|
76
|
+
[exports.CryptoObject.RelationshipsController]: [exports.CryptoKeyType.Encryption],
|
|
77
|
+
[exports.CryptoObject.RelationshipSecretController]: [exports.CryptoKeyType.Encryption],
|
|
78
|
+
[exports.CryptoObject.SecretController]: [exports.CryptoKeyType.Encryption],
|
|
79
|
+
[exports.CryptoObject.TokenController]: [exports.CryptoKeyType.Encryption]
|
|
80
|
+
}; }
|
|
81
|
+
static { this.DEFAULT_OPERATION_PREFERENCES = {
|
|
82
|
+
[exports.CryptoKeyType.Derivation]: exports.CryptoProviderTypes.Software,
|
|
83
|
+
[exports.CryptoKeyType.Signature]: exports.CryptoProviderTypes.Hardware,
|
|
84
|
+
[exports.CryptoKeyType.Encryption]: exports.CryptoProviderTypes.Hardware,
|
|
85
|
+
[exports.CryptoKeyType.Exchange]: exports.CryptoProviderTypes.Software
|
|
86
|
+
}; }
|
|
87
|
+
static { this.FALLBACK_PREFERENCE = exports.CryptoProviderTypes.Software; }
|
|
88
|
+
constructor(preferences = exports.DEFAULT_CRYPTO_OPERATION_PREFERENCES) {
|
|
89
|
+
this._objectOperationPreferences = preferences;
|
|
90
|
+
}
|
|
91
|
+
getPreferredProviderLevel(cryptoObject, cryptoOperation, purpose) {
|
|
92
|
+
const allowedOps = CryptoProviderMapping.ALLOWED_CRYPTO_OPERATIONS[cryptoObject];
|
|
93
|
+
if (allowedOps && !allowedOps.includes(cryptoOperation)) {
|
|
94
|
+
throw new Error(`Operation '${cryptoOperation}' is not supported for object '${cryptoObject}'.`);
|
|
95
|
+
}
|
|
96
|
+
let chosenSecurityLevel;
|
|
97
|
+
const objectPrefs = this._objectOperationPreferences[cryptoObject];
|
|
98
|
+
if (objectPrefs) {
|
|
99
|
+
const operationPrefOrMap = objectPrefs[cryptoOperation];
|
|
100
|
+
if (operationPrefOrMap) {
|
|
101
|
+
if (typeof operationPrefOrMap === "object") {
|
|
102
|
+
if (purpose && operationPrefOrMap[purpose]) {
|
|
103
|
+
chosenSecurityLevel = operationPrefOrMap[purpose];
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
chosenSecurityLevel = operationPrefOrMap;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (!chosenSecurityLevel) {
|
|
112
|
+
const operationPref = CryptoProviderMapping.DEFAULT_OPERATION_PREFERENCES[cryptoOperation];
|
|
113
|
+
chosenSecurityLevel = operationPref ?? CryptoProviderMapping.FALLBACK_PREFERENCE;
|
|
114
|
+
}
|
|
115
|
+
if (!(0, crypto_1.hasProviderForSecurityLevel)(chosenSecurityLevel)) {
|
|
116
|
+
if (chosenSecurityLevel !== CryptoProviderMapping.FALLBACK_PREFERENCE && !(0, crypto_1.hasProviderForSecurityLevel)(CryptoProviderMapping.FALLBACK_PREFERENCE)) {
|
|
117
|
+
throw new Error(`No provider available for either ${chosenSecurityLevel} or fallback ${CryptoProviderMapping.FALLBACK_PREFERENCE} for operation ${cryptoOperation}.`);
|
|
118
|
+
}
|
|
119
|
+
return CryptoProviderMapping.FALLBACK_PREFERENCE;
|
|
120
|
+
}
|
|
121
|
+
return chosenSecurityLevel;
|
|
122
|
+
}
|
|
123
|
+
async getPreferredProviderKeyHandle(cryptoObject, cryptoOperation, isPortable, purpose) {
|
|
124
|
+
const securityLevel = this.getPreferredProviderLevel(cryptoObject, cryptoOperation, purpose);
|
|
125
|
+
switch (securityLevel) {
|
|
126
|
+
case exports.CryptoProviderTypes.Hardware:
|
|
127
|
+
if (isPortable) {
|
|
128
|
+
return await CoreCrypto_1.CoreCrypto.generatePortableKeyHandle({ securityLevel });
|
|
129
|
+
}
|
|
130
|
+
return await CoreCrypto_1.CoreCrypto.generateDeviceBoundKeyHandle({ securityLevel });
|
|
131
|
+
case exports.CryptoProviderTypes.Software:
|
|
132
|
+
if (isPortable) {
|
|
133
|
+
return await CoreCrypto_1.CoreCrypto.generatePortableKeyHandle({ securityLevel });
|
|
134
|
+
}
|
|
135
|
+
return await CoreCrypto_1.CoreCrypto.generateDeviceBoundKeyHandle({ securityLevel });
|
|
136
|
+
default:
|
|
137
|
+
throw new Error(`Unsupported SecurityLevel '${securityLevel}' encountered for key handle generation.`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
exports.CryptoProviderMapping = CryptoProviderMapping;
|
|
142
|
+
//# sourceMappingURL=CryptoProviderMapping.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CryptoProviderMapping.js","sourceRoot":"","sources":["../../src/core/CryptoProviderMapping.ts"],"names":[],"mappings":";;;AAAA,yDAAyD;AACzD,0CAAqG;AAErG,6CAA0C;AAE7B,QAAA,mBAAmB,GAAG;IAC/B,QAAQ,EAAE,UAAU;IACpB,QAAQ,EAAE,UAAU;IACpB,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;CACV,CAAC;AAEE,QAAA,aAAa,GAAG;IACzB,aAAa,EAAE,eAAe;IAC9B,OAAO,EAAE,SAAS;CACZ,CAAC;AAGE,QAAA,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C;gBACD,OAAO,MAAM,uBAAU,CAAC,4BAA4B,CAAC,EAAE,aAAa,EAAE,CAAC,CAAC;YAE5E,KAAK,2BAAmB,CAAC,QAAQ;gBAC7B,IAAI,UAAU,EAAE,CAAC;oBACb,OAAO,MAAM,uBAAU,CAAC,yBAAyB,CAAC,EAAE,aAAa,EAAE,CAAC,CAAC;gBACzE,CAAC;gBACD,OAAO,MAAM,uBAAU,CAAC,4BAA4B,CAAC,EAAE,aAAa,EAAE,CAAC,CAAC;YAE5E;gBACI,MAAM,IAAI,KAAK,CAAC,8BAA8B,aAAa,0CAA0C,CAAC,CAAC;QAC/G,CAAC;IACL,CAAC;;AA9FL,sDA+FC"}
|
package/dist/core/Transport.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { ILoggerFactory } from "@js-soft/logging-abstractions";
|
|
2
2
|
import { EventBus } from "@js-soft/ts-utils";
|
|
3
|
+
import { CryptoLayerConfig } from "@nmshd/crypto";
|
|
3
4
|
import { AgentOptions } from "http";
|
|
4
5
|
import { AgentOptions as HTTPSAgentOptions } from "https";
|
|
6
|
+
import { CryptoOperationPreferences } from "./CryptoProviderMapping";
|
|
5
7
|
import { ICorrelator } from "./ICorrelator";
|
|
6
8
|
export interface IConfig {
|
|
7
9
|
allowIdentityCreation: boolean;
|
|
@@ -22,6 +24,7 @@ export interface IConfig {
|
|
|
22
24
|
httpAgentOptions: AgentOptions;
|
|
23
25
|
httpsAgentOptions: HTTPSAgentOptions;
|
|
24
26
|
tagCacheLifetimeInMinutes: number;
|
|
27
|
+
cryptoOperationPreferences: CryptoOperationPreferences;
|
|
25
28
|
}
|
|
26
29
|
export interface IConfigOverwrite {
|
|
27
30
|
allowIdentityCreation?: boolean;
|
|
@@ -39,14 +42,16 @@ export interface IConfigOverwrite {
|
|
|
39
42
|
httpAgentOptions?: AgentOptions;
|
|
40
43
|
httpsAgentOptions?: HTTPSAgentOptions;
|
|
41
44
|
tagCacheLifetimeInMinutes?: number;
|
|
45
|
+
cryptoOperationPreferences?: CryptoOperationPreferences;
|
|
42
46
|
}
|
|
43
47
|
export declare class Transport {
|
|
44
48
|
readonly eventBus: EventBus;
|
|
45
49
|
readonly correlator?: ICorrelator | undefined;
|
|
50
|
+
readonly cryptoLayerConfig?: CryptoLayerConfig | undefined;
|
|
46
51
|
private readonly _config;
|
|
47
52
|
get config(): IConfig;
|
|
48
53
|
private static readonly defaultConfig;
|
|
49
|
-
constructor(customConfig: IConfigOverwrite, eventBus: EventBus, loggerFactory?: ILoggerFactory, correlator?: ICorrelator | undefined);
|
|
54
|
+
constructor(customConfig: IConfigOverwrite, eventBus: EventBus, loggerFactory?: ILoggerFactory, correlator?: ICorrelator | undefined, cryptoLayerConfig?: CryptoLayerConfig | undefined);
|
|
50
55
|
init(): Promise<Transport>;
|
|
51
56
|
}
|
|
52
57
|
//# sourceMappingURL=Transport.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transport.d.ts","sourceRoot":"","sources":["../../src/core/Transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAExE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"Transport.d.ts","sourceRoot":"","sources":["../../src/core/Transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAExE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAA2C,MAAM,eAAe,CAAC;AAC3F,OAAO,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,EAAE,YAAY,IAAI,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE1D,OAAO,EAAE,0BAA0B,EAAwC,MAAM,yBAAyB,CAAC;AAC3G,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAO5C,MAAM,WAAW,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,iBAAiB,CAAC;IACtC,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,0BAA0B,CAAC,EAAE,0BAA0B,CAAC;CAC3D;AAED,qBAAa,SAAS;aAkCE,QAAQ,EAAE,QAAQ;aAElB,UAAU,CAAC,EAAE,WAAW;aACxB,iBAAiB,CAAC,EAAE,iBAAiB;IApCzD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;IAClC,IAAW,MAAM,IAAI,OAAO,CAE3B;IAED,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAwBnC;gBAGE,YAAY,EAAE,gBAAgB,EACd,QAAQ,EAAE,QAAQ,EAClC,aAAa,GAAE,cAA0C,EACzC,UAAU,CAAC,EAAE,WAAW,YAAA,EACxB,iBAAiB,CAAC,EAAE,iBAAiB,YAAA;IAgC5C,IAAI,IAAI,OAAO,CAAC,SAAS,CAAC;CAqB1C"}
|
package/dist/core/Transport.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.Transport = void 0;
|
|
|
7
7
|
const simple_logger_1 = require("@js-soft/simple-logger");
|
|
8
8
|
const crypto_1 = require("@nmshd/crypto");
|
|
9
9
|
const lodash_1 = __importDefault(require("lodash"));
|
|
10
|
+
const CryptoProviderMapping_1 = require("./CryptoProviderMapping");
|
|
10
11
|
const TransportCoreErrors_1 = require("./TransportCoreErrors");
|
|
11
12
|
const TransportError_1 = require("./TransportError");
|
|
12
13
|
const TransportLoggerFactory_1 = require("./TransportLoggerFactory");
|
|
@@ -37,11 +38,13 @@ class Transport {
|
|
|
37
38
|
keepAlive: true,
|
|
38
39
|
maxFreeSockets: 2
|
|
39
40
|
},
|
|
40
|
-
tagCacheLifetimeInMinutes: 5
|
|
41
|
+
tagCacheLifetimeInMinutes: 5,
|
|
42
|
+
cryptoOperationPreferences: CryptoProviderMapping_1.DEFAULT_CRYPTO_OPERATION_PREFERENCES
|
|
41
43
|
}; }
|
|
42
|
-
constructor(customConfig, eventBus, loggerFactory = new simple_logger_1.SimpleLoggerFactory(), correlator) {
|
|
44
|
+
constructor(customConfig, eventBus, loggerFactory = new simple_logger_1.SimpleLoggerFactory(), correlator, cryptoLayerConfig) {
|
|
43
45
|
this.eventBus = eventBus;
|
|
44
46
|
this.correlator = correlator;
|
|
47
|
+
this.cryptoLayerConfig = cryptoLayerConfig;
|
|
45
48
|
this._config = lodash_1.default.defaultsDeep({}, customConfig, Transport.defaultConfig);
|
|
46
49
|
TransportLoggerFactory_1.TransportLoggerFactory.init(loggerFactory);
|
|
47
50
|
log = TransportLoggerFactory_1.TransportLoggerFactory.getLogger(Transport);
|
|
@@ -67,6 +70,17 @@ class Transport {
|
|
|
67
70
|
async init() {
|
|
68
71
|
log.trace("Initializing Libsodium...");
|
|
69
72
|
await crypto_1.SodiumWrapper.ready();
|
|
73
|
+
if (this.cryptoLayerConfig) {
|
|
74
|
+
log.trace("Initializing Crypto Layer...");
|
|
75
|
+
try {
|
|
76
|
+
await (0, crypto_1.initCryptoLayerProviders)(this.cryptoLayerConfig);
|
|
77
|
+
log.trace("Crypto Layer initialized successfully");
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
log.warn("Failed to initialize Crypto Layer, continuing without it.", error);
|
|
81
|
+
}
|
|
82
|
+
log.trace("Crypto Layer initialized");
|
|
83
|
+
}
|
|
70
84
|
log.trace("Libsodium initialized");
|
|
71
85
|
log.info("Transport initialized");
|
|
72
86
|
return this;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transport.js","sourceRoot":"","sources":["../../src/core/Transport.ts"],"names":[],"mappings":";;;;;;AACA,0DAA6D;AAE7D,
|
|
1
|
+
{"version":3,"file":"Transport.js","sourceRoot":"","sources":["../../src/core/Transport.ts"],"names":[],"mappings":";;;;;;AACA,0DAA6D;AAE7D,0CAA2F;AAG3F,oDAAuB;AACvB,mEAA2G;AAE3G,+DAA4D;AAC5D,qDAAkD;AAClD,qEAAkE;AAElE,IAAI,GAAY,CAAC;AA2CjB,MAAa,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,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAsB9E,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,YAAY,CAAC,MAAM,GAAG,WAAW,CAAC,CAAC;IA2B7G,OAAO,CAAC,yBAAyB;IAYjC,OAAO,CAAC,YAAY;CAUvB"}
|
|
@@ -107,7 +107,7 @@ class RESTClient {
|
|
|
107
107
|
addAxiosLoggingInterceptors(axiosInstance) {
|
|
108
108
|
axiosInstance.interceptors.request.use((config) => {
|
|
109
109
|
const requestAsAny = config;
|
|
110
|
-
requestAsAny.meta = config.meta
|
|
110
|
+
requestAsAny.meta = config.meta ?? {};
|
|
111
111
|
requestAsAny.meta.startTime = new Date().getTime();
|
|
112
112
|
return config;
|
|
113
113
|
});
|
|
@@ -207,14 +207,12 @@ class RESTClient {
|
|
|
207
207
|
this._logger.debug(error);
|
|
208
208
|
return ClientResult_1.ClientResult.fail(error, platformParameters);
|
|
209
209
|
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
};
|
|
217
|
-
}
|
|
210
|
+
response.data.pagination ??= {
|
|
211
|
+
pageNumber: 1,
|
|
212
|
+
pageSize: response.data.result.length,
|
|
213
|
+
totalPages: 1,
|
|
214
|
+
totalRecords: response.data.result.length
|
|
215
|
+
};
|
|
218
216
|
const paginationDataSource = new RestPaginationDataSource(this, path, args);
|
|
219
217
|
const paginator = new Paginator_1.Paginator(response.data.result, response.data.pagination, paginationDataSource, progessCallback);
|
|
220
218
|
return ClientResult_1.ClientResult.ok(paginator, platformParameters);
|
|
@@ -301,7 +299,7 @@ class RESTClient {
|
|
|
301
299
|
let sendData = formData;
|
|
302
300
|
if (typeof formData.getHeaders !== "undefined") {
|
|
303
301
|
const h = formData.getHeaders();
|
|
304
|
-
conf["headers"] = conf["headers"]
|
|
302
|
+
conf["headers"] = conf["headers"] ?? {};
|
|
305
303
|
for (const key in h) {
|
|
306
304
|
conf["headers"][key] = h[key];
|
|
307
305
|
}
|