@axinom/mosaic-message-bus 0.32.0-rc.7 → 0.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/broker.js +5 -2
- package/dist/broker.js.map +1 -1
- package/dist/common/constants.d.ts +27 -0
- package/dist/common/constants.d.ts.map +1 -1
- package/dist/common/constants.js +28 -1
- package/dist/common/constants.js.map +1 -1
- package/dist/generated/key-service.d.ts +438 -0
- package/dist/generated/key-service.d.ts.map +1 -0
- package/dist/generated/key-service.js +162 -0
- package/dist/generated/key-service.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/middleware/index.d.ts +1 -0
- package/dist/middleware/index.d.ts.map +1 -1
- package/dist/middleware/index.js +1 -0
- package/dist/middleware/index.js.map +1 -1
- package/dist/middleware/validate-signed-event-middleware.d.ts +36 -0
- package/dist/middleware/validate-signed-event-middleware.d.ts.map +1 -0
- package/dist/middleware/validate-signed-event-middleware.js +57 -0
- package/dist/middleware/validate-signed-event-middleware.js.map +1 -0
- package/dist/publication.d.ts.map +1 -1
- package/dist/publication.js +3 -2
- package/dist/publication.js.map +1 -1
- package/dist/rascal-config-builder.d.ts +9 -1
- package/dist/rascal-config-builder.d.ts.map +1 -1
- package/dist/rascal-config-builder.js +1 -0
- package/dist/rascal-config-builder.js.map +1 -1
- package/dist/signing/cache-public-signing-keys.d.ts +37 -0
- package/dist/signing/cache-public-signing-keys.d.ts.map +1 -0
- package/dist/signing/cache-public-signing-keys.js +81 -0
- package/dist/signing/cache-public-signing-keys.js.map +1 -0
- package/dist/signing/event-signing-errors.d.ts +30 -0
- package/dist/signing/event-signing-errors.d.ts.map +1 -0
- package/dist/signing/event-signing-errors.js +33 -0
- package/dist/signing/event-signing-errors.js.map +1 -0
- package/dist/signing/index.d.ts +4 -0
- package/dist/signing/index.d.ts.map +1 -0
- package/dist/signing/index.js +20 -0
- package/dist/signing/index.js.map +1 -0
- package/dist/signing/register-public-signing-key.d.ts +16 -0
- package/dist/signing/register-public-signing-key.d.ts.map +1 -0
- package/dist/signing/register-public-signing-key.js +44 -0
- package/dist/signing/register-public-signing-key.js.map +1 -0
- package/dist/signing/signing-cache.d.ts +25 -0
- package/dist/signing/signing-cache.d.ts.map +1 -0
- package/dist/signing/signing-cache.js +46 -0
- package/dist/signing/signing-cache.js.map +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/signing.d.ts +30 -0
- package/dist/types/signing.d.ts.map +1 -0
- package/dist/types/{signing-details.js → signing.js} +1 -1
- package/dist/types/signing.js.map +1 -0
- package/package.json +16 -5
- package/src/common/constants.ts +32 -0
- package/src/generated/key-service.ts +459 -0
- package/src/index.ts +1 -0
- package/src/middleware/index.ts +1 -0
- package/src/middleware/validate-signed-event-middleware.spec.ts +679 -0
- package/src/middleware/validate-signed-event-middleware.ts +136 -0
- package/src/publication.ts +9 -5
- package/src/rascal-config-builder.spec.ts +1 -33
- package/src/rascal-config-builder.ts +11 -1
- package/src/signing/cache-public-signing-keys.graphql +10 -0
- package/src/signing/cache-public-signing-keys.ts +115 -0
- package/src/signing/event-signing-errors.ts +35 -0
- package/src/signing/index.ts +3 -0
- package/src/signing/register-public-signing-key.graphql +10 -0
- package/src/signing/register-public-signing-key.spec.ts +95 -0
- package/src/signing/register-public-signing-key.ts +59 -0
- package/src/signing/signing-cache.ts +49 -0
- package/src/tests/utils/create-builder.ts +34 -0
- package/src/tests/utils/index.ts +1 -0
- package/src/types/index.ts +1 -1
- package/src/types/signing.ts +50 -0
- package/dist/types/signing-details.d.ts +0 -3
- package/dist/types/signing-details.d.ts.map +0 -1
- package/dist/types/signing-details.js.map +0 -1
- package/src/types/signing-details.ts +0 -8
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-signing-errors.d.ts","sourceRoot":"","sources":["../../src/signing/event-signing-errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;CA+BrB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EventSigningErrors = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Possible errors that are explicitly handled during event signing and validation.
|
|
6
|
+
*/
|
|
7
|
+
exports.EventSigningErrors = {
|
|
8
|
+
SigningPublicKeyNotFound: {
|
|
9
|
+
message: "Unable to find the public signing key for service with ID '%s' and version %s. Please contact Axinom Support.",
|
|
10
|
+
code: 'SIGNING_PUBLIC_KEY_NOT_FOUND',
|
|
11
|
+
},
|
|
12
|
+
SignatureValidationFailed: {
|
|
13
|
+
message: 'Event signature validation has failed. The source of event message might be untrustworthy. Please contact Axinom Support.',
|
|
14
|
+
code: 'SIGNATURE_VALIDATION_FAILED',
|
|
15
|
+
},
|
|
16
|
+
KeyServiceNotAccessible: {
|
|
17
|
+
message: 'The Key service is not accessible. Please contact Axinom support.',
|
|
18
|
+
code: 'KEY_SERVICE_NOT_ACCESSIBLE',
|
|
19
|
+
},
|
|
20
|
+
UnexpectedMessageType: {
|
|
21
|
+
message: 'The received message has a type that the service does not expect. The source of message might be untrustworthy. Please contact Axinom Support.',
|
|
22
|
+
code: 'UNEXPECTED_MESSAGE_TYPE',
|
|
23
|
+
},
|
|
24
|
+
SigningHeadersMissing: {
|
|
25
|
+
message: 'The received event message is missing either signature or version headers. The source of message might be untrustworthy. Please contact Axinom Support.',
|
|
26
|
+
code: 'SIGNING_HEADERS_MISSING',
|
|
27
|
+
},
|
|
28
|
+
ServiceIdNotFound: {
|
|
29
|
+
message: 'The received message is missing a service ID at the start of the routing key or related message builder has no service ID. This is probably an implementation bug. Please contact the Service Support.',
|
|
30
|
+
code: 'SERVICE_ID_NOT_FOUND',
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=event-signing-errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-signing-errors.js","sourceRoot":"","sources":["../../src/signing/event-signing-errors.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,kBAAkB,GAAG;IAChC,wBAAwB,EAAE;QACxB,OAAO,EACL,+GAA+G;QACjH,IAAI,EAAE,8BAA8B;KACrC;IACD,yBAAyB,EAAE;QACzB,OAAO,EACL,2HAA2H;QAC7H,IAAI,EAAE,6BAA6B;KACpC;IACD,uBAAuB,EAAE;QACvB,OAAO,EACL,mEAAmE;QACrE,IAAI,EAAE,4BAA4B;KACnC;IACD,qBAAqB,EAAE;QACrB,OAAO,EACL,gJAAgJ;QAClJ,IAAI,EAAE,yBAAyB;KAChC;IACD,qBAAqB,EAAE;QACrB,OAAO,EACL,yJAAyJ;QAC3J,IAAI,EAAE,yBAAyB;KAChC;IACD,iBAAiB,EAAE;QACjB,OAAO,EACL,wMAAwM;QAC1M,IAAI,EAAE,sBAAsB;KAC7B;CACO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/signing/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,+BAA+B,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
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("./cache-public-signing-keys"), exports);
|
|
18
|
+
__exportStar(require("./event-signing-errors"), exports);
|
|
19
|
+
__exportStar(require("./register-public-signing-key"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/signing/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8DAA4C;AAC5C,yDAAuC;AACvC,gEAA8C"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Logger } from '@axinom/mosaic-service-common';
|
|
2
|
+
import { GetEventSigningTokenFunc, SigningRegistrationConfig } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Registers a service public key with the Key service. Caches the used token
|
|
5
|
+
* and the single registered public key. If some public keys were already cached - newly registered public key is added to the cached list.
|
|
6
|
+
*
|
|
7
|
+
* @param config - service configuration object containing all values relavant
|
|
8
|
+
* for event signing
|
|
9
|
+
* @param keyServiceBaseUrl - Base URL of Mosaic Key Service
|
|
10
|
+
* @param getTokenCallback - Function to retrieve authorization token result to make a
|
|
11
|
+
* registration request to the Key Service
|
|
12
|
+
* @param logger - Optional instance of the Mosaic Logger. If not provided - new
|
|
13
|
+
* instance will be created and used by the function itself.
|
|
14
|
+
*/
|
|
15
|
+
export declare const registerPublicSigningKey: (config: SigningRegistrationConfig, keyServiceBaseUrl: string, getTokenCallback: GetEventSigningTokenFunc, logger?: Logger) => Promise<void>;
|
|
16
|
+
//# sourceMappingURL=register-public-signing-key.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register-public-signing-key.d.ts","sourceRoot":"","sources":["../../src/signing/register-public-signing-key.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AAGvD,OAAO,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAO/E;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,wBAAwB,WAC3B,yBAAyB,qBACd,MAAM,oBACP,wBAAwB,WACjC,MAAM,KACd,QAAQ,IAAI,CA+Bd,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerPublicSigningKey = void 0;
|
|
4
|
+
const mosaic_service_common_1 = require("@axinom/mosaic-service-common");
|
|
5
|
+
const graphql_request_1 = require("graphql-request");
|
|
6
|
+
const key_service_1 = require("../generated/key-service");
|
|
7
|
+
const signing_cache_1 = require("./signing-cache");
|
|
8
|
+
/**
|
|
9
|
+
* Registers a service public key with the Key service. Caches the used token
|
|
10
|
+
* and the single registered public key. If some public keys were already cached - newly registered public key is added to the cached list.
|
|
11
|
+
*
|
|
12
|
+
* @param config - service configuration object containing all values relavant
|
|
13
|
+
* for event signing
|
|
14
|
+
* @param keyServiceBaseUrl - Base URL of Mosaic Key Service
|
|
15
|
+
* @param getTokenCallback - Function to retrieve authorization token result to make a
|
|
16
|
+
* registration request to the Key Service
|
|
17
|
+
* @param logger - Optional instance of the Mosaic Logger. If not provided - new
|
|
18
|
+
* instance will be created and used by the function itself.
|
|
19
|
+
*/
|
|
20
|
+
const registerPublicSigningKey = async (config, keyServiceBaseUrl, getTokenCallback, logger) => {
|
|
21
|
+
var _a;
|
|
22
|
+
logger = logger !== null && logger !== void 0 ? logger : new mosaic_service_common_1.Logger({ context: exports.registerPublicSigningKey.name });
|
|
23
|
+
const input = {
|
|
24
|
+
version: config.rmqEventSigningKeyVersion,
|
|
25
|
+
versionsToRevoke: config.rmqEventSigningKeyVersionsToRevoke,
|
|
26
|
+
serviceId: config.serviceId,
|
|
27
|
+
key: config.rmqEventSigningPublicKey,
|
|
28
|
+
};
|
|
29
|
+
const { accessToken, expiresInSeconds } = await getTokenCallback();
|
|
30
|
+
(0, signing_cache_1.setCachedSigningToken)(accessToken, expiresInSeconds - 60);
|
|
31
|
+
const client = new graphql_request_1.GraphQLClient(new URL('graphql', keyServiceBaseUrl).href);
|
|
32
|
+
const { RegisterPublicSigningKey } = (0, key_service_1.getSdk)(client);
|
|
33
|
+
const { data } = await RegisterPublicSigningKey({ input }, { Authorization: `Bearer ${accessToken}` });
|
|
34
|
+
if ((_a = data.registerPublicKey) === null || _a === void 0 ? void 0 : _a.publicKey) {
|
|
35
|
+
const currentKeys = (0, signing_cache_1.getCachedSigningPublicKeys)();
|
|
36
|
+
(0, signing_cache_1.setCachedSigningPublicKeys)([...(currentKeys !== null && currentKeys !== void 0 ? currentKeys : []), data.registerPublicKey.publicKey], 60 * 10);
|
|
37
|
+
}
|
|
38
|
+
logger.log({
|
|
39
|
+
message: 'Public signing key successfully registered.',
|
|
40
|
+
details: Object.assign({}, input),
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
exports.registerPublicSigningKey = registerPublicSigningKey;
|
|
44
|
+
//# sourceMappingURL=register-public-signing-key.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register-public-signing-key.js","sourceRoot":"","sources":["../../src/signing/register-public-signing-key.ts"],"names":[],"mappings":";;;AAAA,yEAAuD;AACvD,qDAAgD;AAChD,0DAA0E;AAE1E,mDAIyB;AAEzB;;;;;;;;;;;GAWG;AACI,MAAM,wBAAwB,GAAG,KAAK,EAC3C,MAAiC,EACjC,iBAAyB,EACzB,gBAA0C,EAC1C,MAAe,EACA,EAAE;;IACjB,MAAM,GAAG,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,IAAI,8BAAM,CAAC,EAAE,OAAO,EAAE,gCAAwB,CAAC,IAAI,EAAE,CAAC,CAAC;IAE1E,MAAM,KAAK,GAA2B;QACpC,OAAO,EAAE,MAAM,CAAC,yBAAyB;QACzC,gBAAgB,EAAE,MAAM,CAAC,kCAAkC;QAC3D,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,GAAG,EAAE,MAAM,CAAC,wBAAwB;KACrC,CAAC;IACF,MAAM,EAAE,WAAW,EAAE,gBAAgB,EAAE,GAAG,MAAM,gBAAgB,EAAE,CAAC;IACnE,IAAA,qCAAqB,EAAC,WAAW,EAAE,gBAAgB,GAAG,EAAE,CAAC,CAAC;IAE1D,MAAM,MAAM,GAAG,IAAI,+BAAa,CAAC,IAAI,GAAG,CAAC,SAAS,EAAE,iBAAiB,CAAC,CAAC,IAAI,CAAC,CAAC;IAC7E,MAAM,EAAE,wBAAwB,EAAE,GAAG,IAAA,oBAAM,EAAC,MAAM,CAAC,CAAC;IACpD,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,wBAAwB,CAC7C,EAAE,KAAK,EAAE,EACT,EAAE,aAAa,EAAE,UAAU,WAAW,EAAE,EAAE,CAC3C,CAAC;IAEF,IAAI,MAAA,IAAI,CAAC,iBAAiB,0CAAE,SAAS,EAAE;QACrC,MAAM,WAAW,GAAG,IAAA,0CAA0B,GAAE,CAAC;QACjD,IAAA,0CAA0B,EACxB,CAAC,GAAG,CAAC,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,EAAE,CAAC,EAAE,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,EAC1D,EAAE,GAAG,EAAE,CACR,CAAC;KACH;IAED,MAAM,CAAC,GAAG,CAAC;QACT,OAAO,EAAE,6CAA6C;QACtD,OAAO,oBAAO,KAAK,CAAE;KACtB,CAAC,CAAC;AACL,CAAC,CAAC;AApCW,QAAA,wBAAwB,4BAoCnC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { PublicSigningKey } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Retrieves the cached authorization token for requests related to event signing.
|
|
4
|
+
*/
|
|
5
|
+
export declare const getCachedSigningToken: () => string | undefined;
|
|
6
|
+
/**
|
|
7
|
+
* Caches the authorization token for requests related to event signing.
|
|
8
|
+
*/
|
|
9
|
+
export declare const setCachedSigningToken: (token: string, expiration: number) => void;
|
|
10
|
+
/**
|
|
11
|
+
* Retrieves the cached array of event signing public keys.
|
|
12
|
+
*/
|
|
13
|
+
export declare const getCachedSigningPublicKeys: () => PublicSigningKey[] | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Caches the array of event signing public keys.
|
|
16
|
+
*/
|
|
17
|
+
export declare const setCachedSigningPublicKeys: (keys: PublicSigningKey[] | undefined, expiration: number) => void;
|
|
18
|
+
/**
|
|
19
|
+
* Only used for unit tests. Helps clear cache so tests would not interfere with
|
|
20
|
+
* one another.
|
|
21
|
+
*/
|
|
22
|
+
export declare const exportedForTesting: {
|
|
23
|
+
clearSigningCache: () => void;
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=signing-cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signing-cache.d.ts","sourceRoot":"","sources":["../../src/signing/signing-cache.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAK5C;;GAEG;AACH,eAAO,MAAM,qBAAqB,QAAO,MAAM,GAAG,SAEjD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB,UACzB,MAAM,cACD,MAAM,KACjB,IAEF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,0BAA0B,QACnC,gBAAgB,EAAE,GAClB,SAEH,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,0BAA0B,SAC/B,gBAAgB,EAAE,GAAG,SAAS,cACxB,MAAM,KACjB,IAEF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,kBAAkB;6BACN,IAAI;CAC5B,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
exports.exportedForTesting = exports.setCachedSigningPublicKeys = exports.getCachedSigningPublicKeys = exports.setCachedSigningToken = exports.getCachedSigningToken = void 0;
|
|
7
|
+
const node_cache_1 = __importDefault(require("node-cache"));
|
|
8
|
+
const signingCache = new node_cache_1.default({ stdTTL: 60 * 10 }); // cache for 10 minutes
|
|
9
|
+
const signingCacheKeys = 'keys';
|
|
10
|
+
const signingCacheToken = 'token';
|
|
11
|
+
/**
|
|
12
|
+
* Retrieves the cached authorization token for requests related to event signing.
|
|
13
|
+
*/
|
|
14
|
+
const getCachedSigningToken = () => {
|
|
15
|
+
return signingCache.get(signingCacheToken);
|
|
16
|
+
};
|
|
17
|
+
exports.getCachedSigningToken = getCachedSigningToken;
|
|
18
|
+
/**
|
|
19
|
+
* Caches the authorization token for requests related to event signing.
|
|
20
|
+
*/
|
|
21
|
+
const setCachedSigningToken = (token, expiration) => {
|
|
22
|
+
signingCache.set(signingCacheToken, token, expiration);
|
|
23
|
+
};
|
|
24
|
+
exports.setCachedSigningToken = setCachedSigningToken;
|
|
25
|
+
/**
|
|
26
|
+
* Retrieves the cached array of event signing public keys.
|
|
27
|
+
*/
|
|
28
|
+
const getCachedSigningPublicKeys = () => {
|
|
29
|
+
return signingCache.get(signingCacheKeys);
|
|
30
|
+
};
|
|
31
|
+
exports.getCachedSigningPublicKeys = getCachedSigningPublicKeys;
|
|
32
|
+
/**
|
|
33
|
+
* Caches the array of event signing public keys.
|
|
34
|
+
*/
|
|
35
|
+
const setCachedSigningPublicKeys = (keys, expiration) => {
|
|
36
|
+
signingCache.set(signingCacheKeys, keys, expiration);
|
|
37
|
+
};
|
|
38
|
+
exports.setCachedSigningPublicKeys = setCachedSigningPublicKeys;
|
|
39
|
+
/**
|
|
40
|
+
* Only used for unit tests. Helps clear cache so tests would not interfere with
|
|
41
|
+
* one another.
|
|
42
|
+
*/
|
|
43
|
+
exports.exportedForTesting = {
|
|
44
|
+
clearSigningCache: () => signingCache.flushAll(),
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=signing-cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signing-cache.js","sourceRoot":"","sources":["../../src/signing/signing-cache.ts"],"names":[],"mappings":";;;;;;AAAA,4DAAmC;AAEnC,MAAM,YAAY,GAAG,IAAI,oBAAS,CAAC,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,uBAAuB;AAChF,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAChC,MAAM,iBAAiB,GAAG,OAAO,CAAC;AAElC;;GAEG;AACI,MAAM,qBAAqB,GAAG,GAAuB,EAAE;IAC5D,OAAO,YAAY,CAAC,GAAG,CAAS,iBAAiB,CAAC,CAAC;AACrD,CAAC,CAAC;AAFW,QAAA,qBAAqB,yBAEhC;AAEF;;GAEG;AACI,MAAM,qBAAqB,GAAG,CACnC,KAAa,EACb,UAAkB,EACZ,EAAE;IACR,YAAY,CAAC,GAAG,CAAC,iBAAiB,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC;AACzD,CAAC,CAAC;AALW,QAAA,qBAAqB,yBAKhC;AAEF;;GAEG;AACI,MAAM,0BAA0B,GAAG,GAE5B,EAAE;IACd,OAAO,YAAY,CAAC,GAAG,CAAqB,gBAAgB,CAAC,CAAC;AAChE,CAAC,CAAC;AAJW,QAAA,0BAA0B,8BAIrC;AAEF;;GAEG;AACI,MAAM,0BAA0B,GAAG,CACxC,IAAoC,EACpC,UAAkB,EACZ,EAAE;IACR,YAAY,CAAC,GAAG,CAAC,gBAAgB,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;AACvD,CAAC,CAAC;AALW,QAAA,0BAA0B,8BAKrC;AAEF;;;GAGG;AACU,QAAA,kBAAkB,GAAG;IAChC,iBAAiB,EAAE,GAAS,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE;CACvD,CAAC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,WAAW,CAAC"}
|
package/dist/types/index.js
CHANGED
|
@@ -19,5 +19,5 @@ __exportStar(require("./message-envelope"), exports);
|
|
|
19
19
|
__exportStar(require("./message-envelope-overrides"), exports);
|
|
20
20
|
__exportStar(require("./message-info"), exports);
|
|
21
21
|
__exportStar(require("./on-message-middleware"), exports);
|
|
22
|
-
__exportStar(require("./signing
|
|
22
|
+
__exportStar(require("./signing"), exports);
|
|
23
23
|
//# sourceMappingURL=index.js.map
|
package/dist/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,qDAAmC;AACnC,+DAA6C;AAC7C,iDAA+B;AAC/B,0DAAwC;AACxC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,qDAAmC;AACnC,+DAA6C;AAC7C,iDAA+B;AAC/B,0DAAwC;AACxC,4CAA0B"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { BasicConfig, BasicRMQConfig } from '@axinom/mosaic-service-common';
|
|
2
|
+
import { GetPublicSigningKeysQuery } from '../generated/key-service';
|
|
3
|
+
/**
|
|
4
|
+
* Signing public key object requested from the Key Service.
|
|
5
|
+
*/
|
|
6
|
+
export type PublicSigningKey = Omit<NonNullable<GetPublicSigningKeysQuery['publicKeys']>['nodes'][0], '__typename'>;
|
|
7
|
+
/**
|
|
8
|
+
* Configuration that is required for the service to have event signing enabled.
|
|
9
|
+
*/
|
|
10
|
+
export type SigningDetails = Required<Pick<BasicRMQConfig, 'rmqEventSigningPrivateKey' | 'rmqEventSigningKeyVersion'>>;
|
|
11
|
+
/**
|
|
12
|
+
* Configuration that is required for the service to be able to register its
|
|
13
|
+
* public key with the Key service.
|
|
14
|
+
*/
|
|
15
|
+
export type SigningRegistrationConfig = Required<Pick<BasicRMQConfig, 'rmqEventSigningPublicKey' | 'rmqEventSigningKeyVersion' | 'rmqEventSigningKeyVersionsToRevoke'> & Pick<BasicConfig, 'serviceId'>>;
|
|
16
|
+
/**
|
|
17
|
+
* Some event signing components need to make requests to the Key service and
|
|
18
|
+
* require a valid token to do so. This is usually done by a dedicated
|
|
19
|
+
* `callback` function that is expected to return this token result.
|
|
20
|
+
*/
|
|
21
|
+
export interface TokenResult {
|
|
22
|
+
accessToken: string;
|
|
23
|
+
expiresInSeconds: number;
|
|
24
|
+
tokenType: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Explicit type for the `callback` function that requests the authorization token.
|
|
28
|
+
*/
|
|
29
|
+
export type GetEventSigningTokenFunc = () => Promise<TokenResult>;
|
|
30
|
+
//# sourceMappingURL=signing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signing.d.ts","sourceRoot":"","sources":["../../src/types/signing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAErE;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,IAAI,CACjC,WAAW,CAAC,yBAAyB,CAAC,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAChE,YAAY,CACb,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,QAAQ,CACnC,IAAI,CACF,cAAc,EACd,2BAA2B,GAAG,2BAA2B,CAC1D,CACF,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,yBAAyB,GAAG,QAAQ,CAC9C,IAAI,CACF,cAAc,EACZ,0BAA0B,GAC1B,2BAA2B,GAC3B,oCAAoC,CACvC,GACC,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,CACjC,CAAC;AAEF;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,MAAM,OAAO,CAAC,WAAW,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signing.js","sourceRoot":"","sources":["../../src/types/signing.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axinom/mosaic-message-bus",
|
|
3
|
-
"version": "0.32.0
|
|
3
|
+
"version": "0.32.0",
|
|
4
4
|
"description": "Messaging library for Axinom Mosaic services",
|
|
5
5
|
"author": "Axinom",
|
|
6
6
|
"license": "PROPRIETARY",
|
|
@@ -26,23 +26,34 @@
|
|
|
26
26
|
"posttest:cov": "ts-node ../../scripts/open-test-coverage.ts -- libs/message-bus",
|
|
27
27
|
"test:debug": "node --inspect -r ts-node/register ../../node_modules/jest/bin/jest.js --runInBand --silent",
|
|
28
28
|
"test:ci": "jest --reporters=default --reporters=jest-junit --coverage --coverageReporters=cobertura --coverageReporters=html",
|
|
29
|
-
"lint": "eslint . --ext .ts,.tsx,.js --color --cache"
|
|
29
|
+
"lint": "eslint . --ext .ts,.tsx,.js --color --cache",
|
|
30
|
+
"codegen": "yarn util:load-vars graphql-codegen --config codegen.yml",
|
|
31
|
+
"util:load-vars": "env-cmd --silent -f ../../../.env env-cmd --silent -f ../../../.env.dev env-cmd --silent -f .env env-cmd --silent -f .env.dev"
|
|
30
32
|
},
|
|
31
33
|
"dependencies": {
|
|
32
|
-
"@axinom/mosaic-message-bus-abstractions": "^0.19.0
|
|
33
|
-
"@axinom/mosaic-service-common": "^0.54.0
|
|
34
|
+
"@axinom/mosaic-message-bus-abstractions": "^0.19.0",
|
|
35
|
+
"@axinom/mosaic-service-common": "^0.54.0",
|
|
34
36
|
"amqplib": "^0.10.3",
|
|
35
37
|
"dotenv": "^8.2.0",
|
|
38
|
+
"graphql": "^15.4.0",
|
|
39
|
+
"graphql-request": "^3.7.0",
|
|
40
|
+
"graphql-tag": "^2.11.0",
|
|
41
|
+
"node-cache": "^5.1.2",
|
|
36
42
|
"prom-client": "^15.1.0",
|
|
37
43
|
"ramda": "^0.27.0",
|
|
38
44
|
"rascal": "^14.0.1",
|
|
39
45
|
"uuid": "^8.3.2"
|
|
40
46
|
},
|
|
41
47
|
"devDependencies": {
|
|
48
|
+
"@graphql-codegen/cli": "^4.0.1",
|
|
49
|
+
"@graphql-codegen/typescript": "^2.7.3",
|
|
50
|
+
"@graphql-codegen/typescript-graphql-request": "^4.5.5",
|
|
51
|
+
"@graphql-codegen/typescript-operations": "^2.5.3",
|
|
42
52
|
"@types/node": "^18.11.18",
|
|
43
53
|
"@types/ramda": "^0.27.13",
|
|
44
54
|
"@types/rascal": "^10.0.5",
|
|
45
55
|
"@types/uuid": "^8.0.0",
|
|
56
|
+
"env-cmd": "^10.1.0",
|
|
46
57
|
"eslint": "^8.35.0",
|
|
47
58
|
"jest": "^29",
|
|
48
59
|
"rimraf": "^3.0.2",
|
|
@@ -53,5 +64,5 @@
|
|
|
53
64
|
"publishConfig": {
|
|
54
65
|
"access": "public"
|
|
55
66
|
},
|
|
56
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "12200181d99bdf8e61f30597d113489b172c8a17"
|
|
57
68
|
}
|
package/src/common/constants.ts
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Constant value to use for Aggregate ID of a sent message when it is not clear
|
|
3
|
+
* which entity it is associated with.
|
|
4
|
+
*/
|
|
1
5
|
export const UNKNOWN_AGGREGATE_ID = 'UNDEFINED_ID';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Constant value to use for Aggregate ID of a sent message when it is
|
|
9
|
+
* associated with multiple entities.
|
|
10
|
+
*/
|
|
2
11
|
export const MULTIPLE_AGGREGATE_IDS = 'MULTIPLE_IDS';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A header with this name and value of `true` is set for a failing message on a
|
|
15
|
+
* second-to-last retry attempt, indicating that for the next attempt, the
|
|
16
|
+
* message will no longer retry and will go to the dead_letter queue.
|
|
17
|
+
*/
|
|
3
18
|
export const MosaicFinalRedeliveryError = 'mosaic_final_error';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* A header with this name is set for a signed event originating from a service
|
|
22
|
+
* that has event signing set up. Contains a signature of a sent payload to be
|
|
23
|
+
* used by `validateSignedEventMiddleware` to make sure event comes from a
|
|
24
|
+
* trustworthy source.
|
|
25
|
+
*/
|
|
26
|
+
export const MOSAIC_SIGNING_SIGNATURE = 'x-mosaic-signature';
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* A header with this name is set for a signed event originating from a service
|
|
30
|
+
* that has event signing set up. Contains a version of a public key that can be
|
|
31
|
+
* used by `validateSignedEventMiddleware` to make sure event comes from a
|
|
32
|
+
* trustworthy source.
|
|
33
|
+
*/
|
|
34
|
+
export const MOSAIC_SIGNING_SIGNATURE_KEY_VERSION =
|
|
35
|
+
'x-mosaic-signature-key-version';
|