@degenerate/endpoints 0.0.3 → 0.0.4
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/endpoints/src/cors/authority/audience/get-set-audiences.d.ts +60 -0
- package/dist/endpoints/src/cors/authority/audience/get-set-audiences.d.ts.map +1 -0
- package/dist/endpoints/src/cors/authority/audience/get-set-audiences.js +90 -0
- package/dist/endpoints/src/cors/authority/jwt/validate-jwt-authorities.d.ts +16 -0
- package/dist/endpoints/src/cors/authority/jwt/validate-jwt-authorities.d.ts.map +1 -0
- package/dist/endpoints/src/cors/authority/jwt/validate-jwt-authorities.js +34 -0
- package/dist/endpoints/src/cors/endpoints/authorities/validate-authorities-transaction.d.ts +30 -0
- package/dist/endpoints/src/cors/endpoints/authorities/validate-authorities-transaction.d.ts.map +1 -0
- package/dist/endpoints/src/cors/endpoints/authorities/validate-authorities-transaction.js +155 -0
- package/dist/endpoints/src/cors/endpoints/helpers/validate-request-body.d.ts +11 -0
- package/dist/endpoints/src/cors/endpoints/helpers/validate-request-body.d.ts.map +1 -0
- package/dist/endpoints/src/cors/endpoints/helpers/validate-request-body.js +32 -0
- package/dist/{cors → endpoints/src/cors}/errors/all-error-handler.d.ts +2 -2
- package/dist/endpoints/src/cors/errors/all-error-handler.d.ts.map +1 -0
- package/dist/{cors → endpoints/src/cors}/errors/all-error-handler.js +1 -0
- package/dist/endpoints/src/cors/errors/bad-request-handler.d.ts +12 -0
- package/dist/endpoints/src/cors/errors/bad-request-handler.d.ts.map +1 -0
- package/dist/{cors → endpoints/src/cors}/errors/bad-request-handler.js +1 -0
- package/dist/endpoints/src/cors/errors/unauthorized-handler.d.ts +12 -0
- package/dist/endpoints/src/cors/errors/unauthorized-handler.d.ts.map +1 -0
- package/dist/{cors → endpoints/src/cors}/errors/unauthorized-handler.js +1 -0
- package/dist/endpoints/src/cors/index.d.ts +9 -0
- package/dist/endpoints/src/cors/index.d.ts.map +1 -0
- package/dist/{cors → endpoints/src/cors}/index.js +7 -0
- package/dist/endpoints/src/cors/routes/authorities.routes.d.ts +2 -0
- package/dist/endpoints/src/cors/routes/authorities.routes.d.ts.map +1 -0
- package/dist/endpoints/src/cors/routes/authorities.routes.js +69 -0
- package/dist/endpoints/src/cors/routes/events.routes.d.ts +2 -0
- package/dist/endpoints/src/cors/routes/events.routes.d.ts.map +1 -0
- package/dist/endpoints/src/cors/routes/events.routes.js +56 -0
- package/dist/endpoints/src/cors/routes/functions.routes.d.ts +2 -0
- package/dist/endpoints/src/cors/routes/functions.routes.d.ts.map +1 -0
- package/dist/endpoints/src/cors/routes/functions.routes.js +56 -0
- package/dist/endpoints/src/cors/routes/rules.routes.d.ts +2 -0
- package/dist/endpoints/src/cors/routes/rules.routes.d.ts.map +1 -0
- package/dist/endpoints/src/cors/routes/rules.routes.js +56 -0
- package/dist/endpoints/src/cors/routes/share-data.routes.d.ts +2 -0
- package/dist/endpoints/src/cors/routes/share-data.routes.d.ts.map +1 -0
- package/dist/endpoints/src/cors/routes/share-data.routes.js +56 -0
- package/dist/endpoints/src/examples/express-server/app.d.ts +3 -0
- package/dist/endpoints/src/examples/express-server/app.d.ts.map +1 -0
- package/dist/endpoints/src/examples/express-server/app.js +29 -0
- package/dist/endpoints/src/examples/express-server/server.d.ts +2 -0
- package/dist/endpoints/src/examples/express-server/server.d.ts.map +1 -0
- package/dist/endpoints/src/examples/express-server/server.js +9 -0
- package/dist/{index.d.ts.map → endpoints/src/index.d.ts.map} +1 -1
- package/dist/generic/src/_settings/authorization-settings.d.ts +17 -0
- package/dist/generic/src/_settings/authorization-settings.d.ts.map +1 -0
- package/dist/generic/src/_settings/authorization-settings.js +20 -0
- package/dist/generic/src/authorization/index.d.ts +24 -0
- package/dist/generic/src/authorization/index.d.ts.map +1 -0
- package/dist/generic/src/authorization/index.js +61 -0
- package/dist/generic/src/authorization/jwt/keys/create-public-key-pem.d.ts +9 -0
- package/dist/generic/src/authorization/jwt/keys/create-public-key-pem.d.ts.map +1 -0
- package/dist/generic/src/authorization/jwt/keys/create-public-key-pem.js +25 -0
- package/dist/generic/src/authorization/jwt/keys/create-secret-key-pem.d.ts +9 -0
- package/dist/generic/src/authorization/jwt/keys/create-secret-key-pem.d.ts.map +1 -0
- package/dist/generic/src/authorization/jwt/keys/create-secret-key-pem.js +24 -0
- package/dist/generic/src/authorization/jwt/sign/create-authorization-issuer.d.ts +10 -0
- package/dist/generic/src/authorization/jwt/sign/create-authorization-issuer.d.ts.map +1 -0
- package/dist/generic/src/authorization/jwt/sign/create-authorization-issuer.js +26 -0
- package/dist/generic/src/authorization/jwt/sign/create-authorization-subject.d.ts +12 -0
- package/dist/generic/src/authorization/jwt/sign/create-authorization-subject.d.ts.map +1 -0
- package/dist/generic/src/authorization/jwt/sign/create-authorization-subject.js +19 -0
- package/dist/generic/src/authorization/jwt/sign/create-jwt-options.d.ts +17 -0
- package/dist/generic/src/authorization/jwt/sign/create-jwt-options.d.ts.map +1 -0
- package/dist/generic/src/authorization/jwt/sign/create-jwt-options.js +43 -0
- package/dist/generic/src/authorization/jwt/sign/create-jwt-signed-token.d.ts +13 -0
- package/dist/generic/src/authorization/jwt/sign/create-jwt-signed-token.d.ts.map +1 -0
- package/dist/generic/src/authorization/jwt/sign/create-jwt-signed-token.js +22 -0
- package/dist/generic/src/authorization/jwt/transform/transform-token-payload-to-safe-payload.d.ts +10 -0
- package/dist/generic/src/authorization/jwt/transform/transform-token-payload-to-safe-payload.d.ts.map +1 -0
- package/dist/generic/src/authorization/jwt/transform/transform-token-payload-to-safe-payload.js +31 -0
- package/dist/generic/src/authorization/jwt/verify/get-decoded-jwt-header.d.ts +10 -0
- package/dist/generic/src/authorization/jwt/verify/get-decoded-jwt-header.d.ts.map +1 -0
- package/dist/generic/src/authorization/jwt/verify/get-decoded-jwt-header.js +20 -0
- package/dist/generic/src/authorization/jwt/verify/get-decoded-jwt-signed-token-payload.d.ts +9 -0
- package/dist/generic/src/authorization/jwt/verify/get-decoded-jwt-signed-token-payload.d.ts.map +1 -0
- package/dist/generic/src/authorization/jwt/verify/get-decoded-jwt-signed-token-payload.js +17 -0
- package/dist/generic/src/authorization/jwt/verify/verify-jwt-signed-token.d.ts +12 -0
- package/dist/generic/src/authorization/jwt/verify/verify-jwt-signed-token.d.ts.map +1 -0
- package/dist/generic/src/authorization/jwt/verify/verify-jwt-signed-token.js +34 -0
- package/dist/generic/src/authorization/safe/authorization/authorized-authorities.d.ts +42 -0
- package/dist/generic/src/authorization/safe/authorization/authorized-authorities.d.ts.map +1 -0
- package/dist/generic/src/authorization/safe/authorization/authorized-authorities.js +65 -0
- package/dist/generic/src/authorization/safe/request/decode-bearer-token.d.ts +11 -0
- package/dist/generic/src/authorization/safe/request/decode-bearer-token.d.ts.map +1 -0
- package/dist/generic/src/authorization/safe/request/decode-bearer-token.js +31 -0
- package/dist/generic/src/authorization/safe/request/decode-safe-request.d.ts +11 -0
- package/dist/generic/src/authorization/safe/request/decode-safe-request.d.ts.map +1 -0
- package/dist/generic/src/authorization/safe/request/decode-safe-request.js +30 -0
- package/dist/generic/src/authorization/safe/request/determine-issuer-from-request.d.ts +10 -0
- package/dist/generic/src/authorization/safe/request/determine-issuer-from-request.d.ts.map +1 -0
- package/dist/generic/src/authorization/safe/request/determine-issuer-from-request.js +29 -0
- package/dist/generic/src/authorization/safe/request/issuer/determine-issuer-from-bearer-token.d.ts +12 -0
- package/dist/generic/src/authorization/safe/request/issuer/determine-issuer-from-bearer-token.d.ts.map +1 -0
- package/dist/generic/src/authorization/safe/request/issuer/determine-issuer-from-bearer-token.js +30 -0
- package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-audience.d.ts +10 -0
- package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-audience.d.ts.map +1 -0
- package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-audience.js +24 -0
- package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-expiration-time.d.ts +8 -0
- package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-expiration-time.d.ts.map +1 -0
- package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-expiration-time.js +23 -0
- package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-issued-at-time.d.ts +9 -0
- package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-issued-at-time.d.ts.map +1 -0
- package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-issued-at-time.js +24 -0
- package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-issuer.d.ts +10 -0
- package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-issuer.d.ts.map +1 -0
- package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-issuer.js +25 -0
- package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-not-before-time.d.ts +8 -0
- package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-not-before-time.d.ts.map +1 -0
- package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-not-before-time.js +23 -0
- package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-subject.d.ts +10 -0
- package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-subject.d.ts.map +1 -0
- package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-subject.js +22 -0
- package/dist/generic/src/authorization/safe/validation/jwt/verify-token-header.d.ts +9 -0
- package/dist/generic/src/authorization/safe/validation/jwt/verify-token-header.d.ts.map +1 -0
- package/dist/generic/src/authorization/safe/validation/jwt/verify-token-header.js +25 -0
- package/dist/generic/src/authorization/safe/validation/jwt/verify-token-payload.d.ts +11 -0
- package/dist/generic/src/authorization/safe/validation/jwt/verify-token-payload.d.ts.map +1 -0
- package/dist/generic/src/authorization/safe/validation/jwt/verify-token-payload.js +30 -0
- package/dist/generic/src/errors/audit-log/audit-log-errors.d.ts +20 -0
- package/dist/generic/src/errors/audit-log/audit-log-errors.d.ts.map +1 -0
- package/dist/generic/src/errors/audit-log/audit-log-errors.js +31 -0
- package/dist/generic/src/errors/authorization/authorization-errors.d.ts +106 -0
- package/dist/generic/src/errors/authorization/authorization-errors.d.ts.map +1 -0
- package/dist/generic/src/errors/authorization/authorization-errors.js +160 -0
- package/dist/generic/src/errors/base-error.d.ts +23 -0
- package/dist/generic/src/errors/base-error.d.ts.map +1 -0
- package/dist/generic/src/errors/base-error.js +34 -0
- package/dist/generic/src/errors/database/database-errors.d.ts +24 -0
- package/dist/generic/src/errors/database/database-errors.d.ts.map +1 -0
- package/dist/generic/src/errors/database/database-errors.js +33 -0
- package/dist/generic/src/errors/generic/generic-errors.d.ts +35 -0
- package/dist/generic/src/errors/generic/generic-errors.d.ts.map +1 -0
- package/dist/generic/src/errors/generic/generic-errors.js +47 -0
- package/dist/generic/src/errors/index.d.ts +10 -0
- package/dist/generic/src/errors/index.d.ts.map +1 -0
- package/dist/generic/src/errors/index.js +26 -0
- package/dist/generic/src/errors/request/request-errors.d.ts +98 -0
- package/dist/generic/src/errors/request/request-errors.d.ts.map +1 -0
- package/dist/generic/src/errors/request/request-errors.js +134 -0
- package/dist/generic/src/errors/safe/safe-rules-errors.d.ts +102 -0
- package/dist/generic/src/errors/safe/safe-rules-errors.d.ts.map +1 -0
- package/dist/generic/src/errors/safe/safe-rules-errors.js +152 -0
- package/dist/generic/src/errors/scheduler/scheduler-errors.d.ts +8 -0
- package/dist/generic/src/errors/scheduler/scheduler-errors.d.ts.map +1 -0
- package/dist/generic/src/errors/scheduler/scheduler-errors.js +14 -0
- package/dist/generic/src/errors/share-data/share-data-errors.d.ts +67 -0
- package/dist/generic/src/errors/share-data/share-data-errors.d.ts.map +1 -0
- package/dist/generic/src/errors/share-data/share-data-errors.js +92 -0
- package/dist/generic/src/helpers/crypto/cryptography-helpers.d.ts +37 -0
- package/dist/generic/src/helpers/crypto/cryptography-helpers.d.ts.map +1 -0
- package/dist/generic/src/helpers/crypto/cryptography-helpers.js +65 -0
- package/dist/generic/src/helpers/object-validation-helpers.d.ts +66 -0
- package/dist/generic/src/helpers/object-validation-helpers.d.ts.map +1 -0
- package/dist/generic/src/helpers/object-validation-helpers.js +254 -0
- package/dist/generic/src/models/application/audit-log/application-audit-log-models.d.ts +87 -0
- package/dist/generic/src/models/application/audit-log/application-audit-log-models.d.ts.map +1 -0
- package/dist/generic/src/models/application/audit-log/application-audit-log-models.js +59 -0
- package/dist/generic/src/models/application/database/firestore-models.d.ts +84 -0
- package/dist/generic/src/models/application/database/firestore-models.d.ts.map +1 -0
- package/dist/generic/src/models/application/database/firestore-models.js +4 -0
- package/dist/generic/src/models/authorization/authorization-models.d.ts +81 -0
- package/dist/generic/src/models/authorization/authorization-models.d.ts.map +1 -0
- package/dist/generic/src/models/authorization/authorization-models.js +33 -0
- package/dist/generic/src/models/crypto/crypto-models.d.ts +5 -0
- package/dist/generic/src/models/crypto/crypto-models.d.ts.map +1 -0
- package/dist/generic/src/models/crypto/crypto-models.js +3 -0
- package/dist/generic/src/models/data/data-models.d.ts +24 -0
- package/dist/generic/src/models/data/data-models.d.ts.map +1 -0
- package/dist/generic/src/models/data/data-models.js +3 -0
- package/dist/generic/src/models/dynamic-execution/dynamic-execution-models.d.ts +9 -0
- package/dist/generic/src/models/dynamic-execution/dynamic-execution-models.d.ts.map +1 -0
- package/dist/generic/src/models/dynamic-execution/dynamic-execution-models.js +2 -0
- package/dist/generic/src/models/events/share-event-models.d.ts +65 -0
- package/dist/generic/src/models/events/share-event-models.d.ts.map +1 -0
- package/dist/generic/src/models/events/share-event-models.js +70 -0
- package/dist/generic/src/models/functions/share-data-function-models.d.ts +86 -0
- package/dist/generic/src/models/functions/share-data-function-models.d.ts.map +1 -0
- package/dist/generic/src/models/functions/share-data-function-models.js +17 -0
- package/dist/generic/src/models/generic/request-response-models.d.ts +8 -0
- package/dist/generic/src/models/generic/request-response-models.d.ts.map +1 -0
- package/dist/generic/src/models/generic/request-response-models.js +2 -0
- package/dist/generic/src/models/index.d.ts +13 -0
- package/dist/generic/src/models/index.d.ts.map +1 -0
- package/dist/generic/src/models/index.js +29 -0
- package/dist/generic/src/models/rules/share-rule-models.d.ts +303 -0
- package/dist/generic/src/models/rules/share-rule-models.d.ts.map +1 -0
- package/dist/generic/src/models/rules/share-rule-models.js +93 -0
- package/dist/generic/src/models/safe/safe-transaction-models.d.ts +81 -0
- package/dist/generic/src/models/safe/safe-transaction-models.d.ts.map +1 -0
- package/dist/generic/src/models/safe/safe-transaction-models.js +26 -0
- package/dist/generic/src/models/share-data/share-data.d.ts +56 -0
- package/dist/generic/src/models/share-data/share-data.d.ts.map +1 -0
- package/dist/generic/src/models/share-data/share-data.js +20 -0
- package/package.json +4 -3
- package/dist/cors/authority/audience/set-audience-authority.d.ts +0 -1
- package/dist/cors/authority/audience/set-audience-authority.d.ts.map +0 -1
- package/dist/cors/authority/audience/set-audience-authority.js +0 -1
- package/dist/cors/authority/jwt/validate-jwt-authority.d.ts +0 -1
- package/dist/cors/authority/jwt/validate-jwt-authority.d.ts.map +0 -1
- package/dist/cors/authority/jwt/validate-jwt-authority.js +0 -1
- package/dist/cors/errors/all-error-handler.d.ts.map +0 -1
- package/dist/cors/errors/bad-request-handler.d.ts +0 -12
- package/dist/cors/errors/bad-request-handler.d.ts.map +0 -1
- package/dist/cors/errors/unauthorized-handler.d.ts +0 -12
- package/dist/cors/errors/unauthorized-handler.d.ts.map +0 -1
- package/dist/cors/index.d.ts +0 -4
- package/dist/cors/index.d.ts.map +0 -1
- /package/dist/{index.d.ts → endpoints/src/index.d.ts} +0 -0
- /package/dist/{index.js → endpoints/src/index.js} +0 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { AuthorizationAudience } from '@degenerate/generic';
|
|
2
|
+
import { Request } from 'express';
|
|
3
|
+
/**
|
|
4
|
+
* This function gets the audience authority.
|
|
5
|
+
*
|
|
6
|
+
* @param req the incoming request
|
|
7
|
+
* @param res the response object
|
|
8
|
+
* @param next the next function
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
export declare function getAudienceAuthority(req: Request): AuthorizationAudience;
|
|
12
|
+
/**
|
|
13
|
+
* This function sets the audience to authorities.
|
|
14
|
+
*
|
|
15
|
+
* @param req the incoming request
|
|
16
|
+
* @param res the response object
|
|
17
|
+
* @param next the next function
|
|
18
|
+
*/
|
|
19
|
+
export declare function setAudienceAuthority(req: Request): void;
|
|
20
|
+
/**
|
|
21
|
+
* This function sets the audience to share data.
|
|
22
|
+
*
|
|
23
|
+
* @param req the incoming request
|
|
24
|
+
* @param res the response object
|
|
25
|
+
* @param next the next function
|
|
26
|
+
*/
|
|
27
|
+
export declare function setAudienceShareData(req: Request): void;
|
|
28
|
+
/**
|
|
29
|
+
* This function sets the audience to functions.
|
|
30
|
+
*
|
|
31
|
+
* @param req the incoming request
|
|
32
|
+
* @param res the response object
|
|
33
|
+
* @param next the next function
|
|
34
|
+
*/
|
|
35
|
+
export declare function setAudienceFunctions(req: Request): void;
|
|
36
|
+
/**
|
|
37
|
+
* This function sets the audience to rules.
|
|
38
|
+
*
|
|
39
|
+
* @param req the incoming request
|
|
40
|
+
* @param res the response object
|
|
41
|
+
* @param next the next function
|
|
42
|
+
*/
|
|
43
|
+
export declare function setAudienceRules(req: Request): void;
|
|
44
|
+
/**
|
|
45
|
+
* This function sets the audience to events.
|
|
46
|
+
*
|
|
47
|
+
* @param req the incoming request
|
|
48
|
+
* @param res the response object
|
|
49
|
+
* @param next the next function
|
|
50
|
+
*/
|
|
51
|
+
export declare function setAudienceEvents(req: Request): void;
|
|
52
|
+
/**
|
|
53
|
+
* This function sets the audience to endpoints.
|
|
54
|
+
*
|
|
55
|
+
* @param req the incoming request
|
|
56
|
+
* @param res the response object
|
|
57
|
+
* @param next the next function
|
|
58
|
+
*/
|
|
59
|
+
export declare function setAudienceEndpoints(req: Request): void;
|
|
60
|
+
//# sourceMappingURL=get-set-audiences.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-set-audiences.d.ts","sourceRoot":"","sources":["../../../../../../src/cors/authority/audience/get-set-audiences.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,qBAAqB,EAGxB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO,GAAG,qBAAqB,CAGxE;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO,QAGhD;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO,QAEhD;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO,QAEhD;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,QAE5C;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,QAE7C;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO,QAEhD"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAudienceAuthority = getAudienceAuthority;
|
|
4
|
+
exports.setAudienceAuthority = setAudienceAuthority;
|
|
5
|
+
exports.setAudienceShareData = setAudienceShareData;
|
|
6
|
+
exports.setAudienceFunctions = setAudienceFunctions;
|
|
7
|
+
exports.setAudienceRules = setAudienceRules;
|
|
8
|
+
exports.setAudienceEvents = setAudienceEvents;
|
|
9
|
+
exports.setAudienceEndpoints = setAudienceEndpoints;
|
|
10
|
+
const generic_1 = require("@degenerate/generic");
|
|
11
|
+
/**
|
|
12
|
+
* This function gets the audience authority.
|
|
13
|
+
*
|
|
14
|
+
* @param req the incoming request
|
|
15
|
+
* @param res the response object
|
|
16
|
+
* @param next the next function
|
|
17
|
+
* @returns
|
|
18
|
+
*/
|
|
19
|
+
function getAudienceAuthority(req) {
|
|
20
|
+
const audience = (0, generic_1.getAuthorizationAudience)(req);
|
|
21
|
+
return audience;
|
|
22
|
+
}
|
|
23
|
+
;
|
|
24
|
+
/**
|
|
25
|
+
* This function sets the audience to authorities.
|
|
26
|
+
*
|
|
27
|
+
* @param req the incoming request
|
|
28
|
+
* @param res the response object
|
|
29
|
+
* @param next the next function
|
|
30
|
+
*/
|
|
31
|
+
function setAudienceAuthority(req) {
|
|
32
|
+
console.log('setAudienceAuthority called');
|
|
33
|
+
(0, generic_1.setAuthorizationAudience)(req, generic_1.AuthorizationAudience.AUTHORITIES);
|
|
34
|
+
}
|
|
35
|
+
;
|
|
36
|
+
/**
|
|
37
|
+
* This function sets the audience to share data.
|
|
38
|
+
*
|
|
39
|
+
* @param req the incoming request
|
|
40
|
+
* @param res the response object
|
|
41
|
+
* @param next the next function
|
|
42
|
+
*/
|
|
43
|
+
function setAudienceShareData(req) {
|
|
44
|
+
(0, generic_1.setAuthorizationAudience)(req, generic_1.AuthorizationAudience.SHAREDATA);
|
|
45
|
+
}
|
|
46
|
+
;
|
|
47
|
+
/**
|
|
48
|
+
* This function sets the audience to functions.
|
|
49
|
+
*
|
|
50
|
+
* @param req the incoming request
|
|
51
|
+
* @param res the response object
|
|
52
|
+
* @param next the next function
|
|
53
|
+
*/
|
|
54
|
+
function setAudienceFunctions(req) {
|
|
55
|
+
(0, generic_1.setAuthorizationAudience)(req, generic_1.AuthorizationAudience.FUNCTIONS);
|
|
56
|
+
}
|
|
57
|
+
;
|
|
58
|
+
/**
|
|
59
|
+
* This function sets the audience to rules.
|
|
60
|
+
*
|
|
61
|
+
* @param req the incoming request
|
|
62
|
+
* @param res the response object
|
|
63
|
+
* @param next the next function
|
|
64
|
+
*/
|
|
65
|
+
function setAudienceRules(req) {
|
|
66
|
+
(0, generic_1.setAuthorizationAudience)(req, generic_1.AuthorizationAudience.RULES);
|
|
67
|
+
}
|
|
68
|
+
;
|
|
69
|
+
/**
|
|
70
|
+
* This function sets the audience to events.
|
|
71
|
+
*
|
|
72
|
+
* @param req the incoming request
|
|
73
|
+
* @param res the response object
|
|
74
|
+
* @param next the next function
|
|
75
|
+
*/
|
|
76
|
+
function setAudienceEvents(req) {
|
|
77
|
+
(0, generic_1.setAuthorizationAudience)(req, generic_1.AuthorizationAudience.EVENTS);
|
|
78
|
+
}
|
|
79
|
+
;
|
|
80
|
+
/**
|
|
81
|
+
* This function sets the audience to endpoints.
|
|
82
|
+
*
|
|
83
|
+
* @param req the incoming request
|
|
84
|
+
* @param res the response object
|
|
85
|
+
* @param next the next function
|
|
86
|
+
*/
|
|
87
|
+
function setAudienceEndpoints(req) {
|
|
88
|
+
(0, generic_1.setAuthorizationAudience)(req, generic_1.AuthorizationAudience.ENDPOINTS);
|
|
89
|
+
}
|
|
90
|
+
;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { NextFunction } from 'express';
|
|
2
|
+
/**
|
|
3
|
+
* This function validates that the incoming request has a valid JWT token and it is authorized
|
|
4
|
+
* for the expected function.
|
|
5
|
+
*
|
|
6
|
+
* Is is used as part of the CORS protection and adds a user object to the request 'req.user'
|
|
7
|
+
* if this is successful.
|
|
8
|
+
*
|
|
9
|
+
* @param req the incoming request
|
|
10
|
+
* @param res the response object
|
|
11
|
+
* @param next CORS next function
|
|
12
|
+
*
|
|
13
|
+
* @returns the next step if the validation succeeds or a unauthorized or disallowed response.
|
|
14
|
+
*/
|
|
15
|
+
export declare function validateJWTAuthorities(req: any, res: any, next: NextFunction): Promise<void>;
|
|
16
|
+
//# sourceMappingURL=validate-jwt-authorities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-jwt-authorities.d.ts","sourceRoot":"","sources":["../../../../../../src/cors/authority/jwt/validate-jwt-authorities.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAKvC;;;;;;;;;;;;GAYG;AACH,wBAAsB,sBAAsB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,YAAY,iBAelF"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.validateJWTAuthorities = validateJWTAuthorities;
|
|
5
|
+
const generic_1 = require("@degenerate/generic");
|
|
6
|
+
const get_set_audiences_1 = require("../audience/get-set-audiences");
|
|
7
|
+
const errors_1 = require("@degenerate/generic/src/errors");
|
|
8
|
+
/**
|
|
9
|
+
* This function validates that the incoming request has a valid JWT token and it is authorized
|
|
10
|
+
* for the expected function.
|
|
11
|
+
*
|
|
12
|
+
* Is is used as part of the CORS protection and adds a user object to the request 'req.user'
|
|
13
|
+
* if this is successful.
|
|
14
|
+
*
|
|
15
|
+
* @param req the incoming request
|
|
16
|
+
* @param res the response object
|
|
17
|
+
* @param next CORS next function
|
|
18
|
+
*
|
|
19
|
+
* @returns the next step if the validation succeeds or a unauthorized or disallowed response.
|
|
20
|
+
*/
|
|
21
|
+
async function validateJWTAuthorities(req, res, next) {
|
|
22
|
+
console.log('validateJWTAuthorities called');
|
|
23
|
+
// get audience from the request
|
|
24
|
+
const audience = (0, get_set_audiences_1.getAudienceAuthority)(req);
|
|
25
|
+
if (!audience) {
|
|
26
|
+
throw new errors_1.RequestNotAuthorizedError('No audience found in the request');
|
|
27
|
+
}
|
|
28
|
+
if (audience !== generic_1.AuthorizationAudience.AUTHORITIES) {
|
|
29
|
+
throw new errors_1.RequestNotAuthorizedError('the audience included is not for authorities');
|
|
30
|
+
}
|
|
31
|
+
// check if an Authority is present.
|
|
32
|
+
next();
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Request, Response, NextFunction } from 'express';
|
|
2
|
+
/**
|
|
3
|
+
* This takes the incoming object and validates that it is the correct shape
|
|
4
|
+
* @param req
|
|
5
|
+
* @param res
|
|
6
|
+
* @param next
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
export declare function validateAuthoritiesTransaction(req: Request, res: Response, next: NextFunction): Response<any, Record<string, any>> | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* This is the transaction targetting an authority in the SAFE Ecosystem.
|
|
12
|
+
*
|
|
13
|
+
const sampleTransactionAuthority: ISAFETransactionAuthority = {
|
|
14
|
+
createdAt: Date.now(),
|
|
15
|
+
authority: '0xAuthorityPublicKey',
|
|
16
|
+
authoritySignature: '0xAuthoritySignature',
|
|
17
|
+
transaction: {
|
|
18
|
+
type: SAFETransactionType.AUTHORITY,
|
|
19
|
+
action: SAFETransactionActionType.CREATE,
|
|
20
|
+
data: {
|
|
21
|
+
authorizationIssuer: 'exampleIssuer-12345678' as IAuthorizationIssuer,
|
|
22
|
+
authorizationPublicKey: '0xAuthorizationPublicKey',
|
|
23
|
+
authorityValidationType: AuthorityValidationType.JWT,
|
|
24
|
+
authorityOver: [SAFETransactionType.SHAREDATA, SAFETransactionType.FUNCTIONS],
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
version: 1,
|
|
28
|
+
};
|
|
29
|
+
*/
|
|
30
|
+
//# sourceMappingURL=validate-authorities-transaction.d.ts.map
|
package/dist/endpoints/src/cors/endpoints/authorities/validate-authorities-transaction.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-authorities-transaction.d.ts","sourceRoot":"","sources":["../../../../../../src/cors/endpoints/authorities/validate-authorities-transaction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE1D;;;;;;GAMG;AACH,wBAAgB,8BAA8B,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,kDAY7F;AAED;;;;;;;;;;;;;;;;;;;GAmBG"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateAuthoritiesTransaction = validateAuthoritiesTransaction;
|
|
4
|
+
/**
|
|
5
|
+
* This takes the incoming object and validates that it is the correct shape
|
|
6
|
+
* @param req
|
|
7
|
+
* @param res
|
|
8
|
+
* @param next
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
function validateAuthoritiesTransaction(req, res, next) {
|
|
12
|
+
const { transaction } = req.body;
|
|
13
|
+
if (!transaction) {
|
|
14
|
+
return res.status(400).send({ error: 'No transaction provided' });
|
|
15
|
+
}
|
|
16
|
+
if (!transaction.authorities) {
|
|
17
|
+
return res.status(400).send({ error: 'No authorities provided' });
|
|
18
|
+
}
|
|
19
|
+
if (!transaction.authorities.length) {
|
|
20
|
+
return res.status(400).send({ error: 'No authorities provided' });
|
|
21
|
+
}
|
|
22
|
+
next();
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* This is the transaction targetting an authority in the SAFE Ecosystem.
|
|
26
|
+
*
|
|
27
|
+
const sampleTransactionAuthority: ISAFETransactionAuthority = {
|
|
28
|
+
createdAt: Date.now(),
|
|
29
|
+
authority: '0xAuthorityPublicKey',
|
|
30
|
+
authoritySignature: '0xAuthoritySignature',
|
|
31
|
+
transaction: {
|
|
32
|
+
type: SAFETransactionType.AUTHORITY,
|
|
33
|
+
action: SAFETransactionActionType.CREATE,
|
|
34
|
+
data: {
|
|
35
|
+
authorizationIssuer: 'exampleIssuer-12345678' as IAuthorizationIssuer,
|
|
36
|
+
authorizationPublicKey: '0xAuthorizationPublicKey',
|
|
37
|
+
authorityValidationType: AuthorityValidationType.JWT,
|
|
38
|
+
authorityOver: [SAFETransactionType.SHAREDATA, SAFETransactionType.FUNCTIONS],
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
version: 1,
|
|
42
|
+
};
|
|
43
|
+
*/
|
|
44
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
45
|
+
// /**
|
|
46
|
+
// * This validates the incoming request for the shape of the add account holder record to a user
|
|
47
|
+
// *
|
|
48
|
+
// * @param req the incoming request
|
|
49
|
+
// * @param res the response
|
|
50
|
+
// * @param next the next function
|
|
51
|
+
// * @returns
|
|
52
|
+
// */
|
|
53
|
+
// export function validateAddAccountHolderRecord(req: Request, res: Response, next: NextFunction): void | Response<any> {
|
|
54
|
+
// let parsedBody;
|
|
55
|
+
// if (typeof req.body === 'object') {
|
|
56
|
+
// parsedBody = req.body;
|
|
57
|
+
// } else {
|
|
58
|
+
// parsedBody = JSON.parse(req.body);
|
|
59
|
+
// }
|
|
60
|
+
// // if we can't parse the body then it's not a valid object
|
|
61
|
+
// if (!parsedBody) throw new RequestObjectValidationFailedError(req.body, 'req.body', 'object');
|
|
62
|
+
// const bodyKeys = Object.keys(parsedBody);
|
|
63
|
+
// if (bodyKeys.length !== 2) {
|
|
64
|
+
// throw new RequestObjectShouldOnlyHaveXPropertiesError(parsedBody, 'req.body', bodyKeys.length, 2);
|
|
65
|
+
// }
|
|
66
|
+
// if (!validateString(parsedBody.userId, true, false, false)) {
|
|
67
|
+
// throw new RequestObjectValidationFailedError(parsedBody.userId, 'userId', 'string');
|
|
68
|
+
// }
|
|
69
|
+
// if (!validateArray(parsedBody.accountHolderRecords)) {
|
|
70
|
+
// throw new RequestObjectValidationFailedError(parsedBody.accountHolderRecords, 'accountHolderRecords', 'array');
|
|
71
|
+
// }
|
|
72
|
+
// for (const accountHolderRecord of parsedBody.accountHolderRecords) {
|
|
73
|
+
// validateAccountHolderRecord(accountHolderRecord);
|
|
74
|
+
// }
|
|
75
|
+
// req.body = parsedBody as IAccountHolderRecordDoc;
|
|
76
|
+
// next();
|
|
77
|
+
// return;
|
|
78
|
+
// }
|
|
79
|
+
// /**
|
|
80
|
+
// * Make sure the account holder record is valid
|
|
81
|
+
// *
|
|
82
|
+
// * @param accountHolderRecord the account holder record
|
|
83
|
+
// */
|
|
84
|
+
// function validateAccountHolderRecord(accountHolderRecord: any): void {
|
|
85
|
+
// if (!accountHolderRecord) throw new RequestObjectValidationFailedError(accountHolderRecord, 'accountHolderRecord', 'object');
|
|
86
|
+
// const bodyKeys = Object.keys(accountHolderRecord);
|
|
87
|
+
// if (bodyKeys.length !== 3) {
|
|
88
|
+
// throw new RequestObjectShouldOnlyHaveXPropertiesError(accountHolderRecord, 'accountHolderRecord', bodyKeys.length, 3);
|
|
89
|
+
// }
|
|
90
|
+
// if (!validateString(accountHolderRecord.financialEndpointProviderId, false, true, true)) {
|
|
91
|
+
// throw new RequestObjectValidationFailedError(accountHolderRecord.financialEndpointProviderId,
|
|
92
|
+
// 'financialEndpointProviderId', 'string');
|
|
93
|
+
// }
|
|
94
|
+
// if (!validateString(accountHolderRecord.institutionId, false, true, true)) {
|
|
95
|
+
// throw new RequestObjectValidationFailedError(accountHolderRecord.institutionId, 'institutionId', 'string');
|
|
96
|
+
// }
|
|
97
|
+
// if (!accountHolderRecord.accountHolder) throw new RequestObjectValidationFailedError(accountHolderRecord, 'accountHolder', 'object');
|
|
98
|
+
// validateAccountHolder(accountHolderRecord.accountHolder);
|
|
99
|
+
// return;
|
|
100
|
+
// }
|
|
101
|
+
// /**
|
|
102
|
+
// * This validates the account holder object
|
|
103
|
+
// *
|
|
104
|
+
// * @param accountHolder
|
|
105
|
+
// * @returns
|
|
106
|
+
// */
|
|
107
|
+
// function validateAccountHolder(accountHolder: any): void {
|
|
108
|
+
// if (!accountHolder) throw new RequestObjectValidationFailedError(accountHolder, 'accountHolder', 'object');
|
|
109
|
+
// const bodyKeys = Object.keys(accountHolder);
|
|
110
|
+
// if (bodyKeys.length !== 5) {
|
|
111
|
+
// throw new RequestObjectShouldOnlyHaveXPropertiesError(accountHolder, 'accountHolder', bodyKeys.length, 5);
|
|
112
|
+
// }
|
|
113
|
+
// if (!validateString(accountHolder.accountId, false, true, true)) {
|
|
114
|
+
// throw new RequestObjectValidationFailedError(accountHolder.accountId, 'accountId', 'string');
|
|
115
|
+
// }
|
|
116
|
+
// if (!accountHolder.address) throw new RequestObjectValidationFailedError(accountHolder, 'address', 'object');
|
|
117
|
+
// validateAccountHolderAddress(accountHolder.address);
|
|
118
|
+
// if (!validateString(accountHolder.name, false, true, true)) {
|
|
119
|
+
// throw new RequestObjectValidationFailedError(accountHolder.name, 'name', 'string');
|
|
120
|
+
// }
|
|
121
|
+
// if (!validateString(accountHolder.email, false, true, true)) {
|
|
122
|
+
// throw new RequestObjectValidationFailedError(accountHolder.email, 'email', 'string');
|
|
123
|
+
// }
|
|
124
|
+
// if (!validateString(accountHolder.phoneNumber, false, true, true)) {
|
|
125
|
+
// throw new RequestObjectValidationFailedError(accountHolder.phoneNumber, 'phoneNumber', 'string');
|
|
126
|
+
// }
|
|
127
|
+
// return;
|
|
128
|
+
// }
|
|
129
|
+
// /**
|
|
130
|
+
// * This validates the account holder address record
|
|
131
|
+
// *
|
|
132
|
+
// * @param address
|
|
133
|
+
// */
|
|
134
|
+
// function validateAccountHolderAddress(address: any): void {
|
|
135
|
+
// if (!address) throw new RequestObjectValidationFailedError(address, 'address', 'object');
|
|
136
|
+
// if (!validateString(address.civicAddress, false, true, true)) {
|
|
137
|
+
// throw new RequestObjectValidationFailedError(address.civicAddress, 'civicAddress', 'string');
|
|
138
|
+
// }
|
|
139
|
+
// if (!validateString(address.city, false, true, true)) {
|
|
140
|
+
// throw new RequestObjectValidationFailedError(address.city, 'city', 'string');
|
|
141
|
+
// }
|
|
142
|
+
// if (!validateString(address.province, false, true, true)) {
|
|
143
|
+
// throw new RequestObjectValidationFailedError(address.province, 'province', 'string');
|
|
144
|
+
// }
|
|
145
|
+
// if (!validateString(address.postalCode, false, true, true)) {
|
|
146
|
+
// throw new RequestObjectValidationFailedError(address.postalCode, 'postalCode', 'string');
|
|
147
|
+
// }
|
|
148
|
+
// if (!validateString(address.poBox, false, true, true)) {
|
|
149
|
+
// throw new RequestObjectValidationFailedError(address.poBox, 'poBox', 'string');
|
|
150
|
+
// }
|
|
151
|
+
// if (!validateString(address.country, false, true, true)) {
|
|
152
|
+
// throw new RequestObjectValidationFailedError(address.country, 'country', 'string');
|
|
153
|
+
// }
|
|
154
|
+
// return;
|
|
155
|
+
// }
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { NextFunction, Request, Response } from 'express';
|
|
2
|
+
/**
|
|
3
|
+
* This validates the incoming request body
|
|
4
|
+
*
|
|
5
|
+
* @param req the incoming request
|
|
6
|
+
* @param res the response
|
|
7
|
+
* @param next the next function
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
export declare function validateRequestBody(req: Request, res: Response, next: NextFunction): void;
|
|
11
|
+
//# sourceMappingURL=validate-request-body.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-request-body.d.ts","sourceRoot":"","sources":["../../../../../../src/cors/endpoints/helpers/validate-request-body.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAE1D;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAC/B,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,QAAQ,EACb,IAAI,EAAE,YAAY,GACnB,IAAI,CAgBN"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateRequestBody = validateRequestBody;
|
|
4
|
+
const generic_1 = require("@degenerate/generic");
|
|
5
|
+
/**
|
|
6
|
+
* This validates the incoming request body
|
|
7
|
+
*
|
|
8
|
+
* @param req the incoming request
|
|
9
|
+
* @param res the response
|
|
10
|
+
* @param next the next function
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
function validateRequestBody(req, res, next) {
|
|
14
|
+
let parsedBody;
|
|
15
|
+
if (typeof req.body === 'object') {
|
|
16
|
+
parsedBody = req.body;
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
try {
|
|
20
|
+
parsedBody = JSON.parse(req.body);
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
throw new generic_1.RequestObjectValidationFailedError(req.body, 'req.body', 'object');
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
// if we can't parse the body then it's not a valid object
|
|
27
|
+
if (!parsedBody)
|
|
28
|
+
throw new generic_1.RequestObjectValidationFailedError(req.body, 'req.body', 'object');
|
|
29
|
+
next();
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NextFunction, Request } from 'express';
|
|
1
|
+
import { NextFunction, Request, Response } from 'express';
|
|
2
2
|
import { BaseError } from '@degenerate/generic';
|
|
3
3
|
/**
|
|
4
4
|
* This is used to handle all errors. It is the last error handler in the chain.
|
|
@@ -8,5 +8,5 @@ import { BaseError } from '@degenerate/generic';
|
|
|
8
8
|
* @param res the response
|
|
9
9
|
* @param next the next function
|
|
10
10
|
*/
|
|
11
|
-
export declare function allErrorHandler(err: BaseError, req: Request, res:
|
|
11
|
+
export declare function allErrorHandler(err: BaseError, req: Request, res: Response, next: NextFunction): Response<any, Record<string, any>>;
|
|
12
12
|
//# sourceMappingURL=all-error-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"all-error-handler.d.ts","sourceRoot":"","sources":["../../../../../src/cors/errors/all-error-handler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAoB,MAAM,qBAAqB,CAAC;AAElE;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC3B,GAAG,EAAE,SAAS,EACd,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,QAAQ,EACb,IAAI,EAAE,YAAY,GACnB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAOpC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Request, Response, NextFunction } from 'express';
|
|
2
|
+
/**
|
|
3
|
+
* bad request moddleware handler
|
|
4
|
+
*
|
|
5
|
+
* @param err the error
|
|
6
|
+
* @param req the incoming request
|
|
7
|
+
* @param res the response
|
|
8
|
+
* @param next next function
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
export declare function badRequestHandler(err: any, req: Request, res: Response, next: NextFunction): Response<any, Record<string, any>> | undefined;
|
|
12
|
+
//# sourceMappingURL=bad-request-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bad-request-handler.d.ts","sourceRoot":"","sources":["../../../../../src/cors/errors/bad-request-handler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAG1D;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC7B,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,QAAQ,EACb,IAAI,EAAE,YAAY,kDAYrB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { NextFunction, Request, Response } from 'express';
|
|
2
|
+
/**
|
|
3
|
+
* This is used to handle unauthorized requests in the middleware
|
|
4
|
+
*
|
|
5
|
+
* @param err the error
|
|
6
|
+
* @param req the incoming request
|
|
7
|
+
* @param res the response
|
|
8
|
+
* @param next the next function
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
export declare function unauthorizedHandler(err: any, req: Request, res: Response, next: NextFunction): Response<any, Record<string, any>> | undefined;
|
|
12
|
+
//# sourceMappingURL=unauthorized-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unauthorized-handler.d.ts","sourceRoot":"","sources":["../../../../../src/cors/errors/unauthorized-handler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAE1D;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAC/B,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,QAAQ,EACb,IAAI,EAAE,YAAY,kDAYrB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './errors/all-error-handler';
|
|
2
|
+
export * from './errors/bad-request-handler';
|
|
3
|
+
export * from './errors/unauthorized-handler';
|
|
4
|
+
export * from './routes/authorities.routes';
|
|
5
|
+
export * from './routes/events.routes';
|
|
6
|
+
export * from './routes/functions.routes';
|
|
7
|
+
export * from './routes/rules.routes';
|
|
8
|
+
export * from './routes/share-data.routes';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/cors/index.ts"],"names":[],"mappings":"AACA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,+BAA+B,CAAC;AAM9C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC"}
|
|
@@ -19,3 +19,10 @@ __exportStar(require("./errors/all-error-handler"), exports);
|
|
|
19
19
|
__exportStar(require("./errors/bad-request-handler"), exports);
|
|
20
20
|
__exportStar(require("./errors/unauthorized-handler"), exports);
|
|
21
21
|
//#endregion cors functions
|
|
22
|
+
//#region routes
|
|
23
|
+
__exportStar(require("./routes/authorities.routes"), exports);
|
|
24
|
+
__exportStar(require("./routes/events.routes"), exports);
|
|
25
|
+
__exportStar(require("./routes/functions.routes"), exports);
|
|
26
|
+
__exportStar(require("./routes/rules.routes"), exports);
|
|
27
|
+
__exportStar(require("./routes/share-data.routes"), exports);
|
|
28
|
+
//#endregion routes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorities.routes.d.ts","sourceRoot":"","sources":["../../../../../src/cors/routes/authorities.routes.ts"],"names":[],"mappings":"AAuDA,eAAO,MAAM,WAAW,4CAAS,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.authorities = void 0;
|
|
27
|
+
const express = __importStar(require("express"));
|
|
28
|
+
const get_set_audiences_1 = require("../authority/audience/get-set-audiences");
|
|
29
|
+
const validate_jwt_authorities_1 = require("../authority/jwt/validate-jwt-authorities");
|
|
30
|
+
const params_object_helpers_1 = require("@degenerate/generic/src/helpers/request/params-object-helpers");
|
|
31
|
+
const validate_request_body_1 = require("../endpoints/helpers/validate-request-body");
|
|
32
|
+
// eslint-disable-next-line new-cap
|
|
33
|
+
const router = express.Router({ mergeParams: true });
|
|
34
|
+
router.use(get_set_audiences_1.setAudienceAuthority); // set the audience to share data (this will throw an error if the audience is not set)
|
|
35
|
+
router.use(validate_jwt_authorities_1.validateJWTAuthorities); // get the audience authority
|
|
36
|
+
/**
|
|
37
|
+
* This creates a new authority object.
|
|
38
|
+
*/
|
|
39
|
+
router.post('/', validate_request_body_1.validateRequestBody, // make sure this is a valid request body
|
|
40
|
+
async (req, res) => {
|
|
41
|
+
return res.status(200).send({ successful: true });
|
|
42
|
+
});
|
|
43
|
+
/**
|
|
44
|
+
* This gets the authorities objects and their data.
|
|
45
|
+
*/
|
|
46
|
+
router.get('/', async (req, res) => {
|
|
47
|
+
console.log('GET /authorities called');
|
|
48
|
+
res.status(200).send({ successful: true });
|
|
49
|
+
return;
|
|
50
|
+
});
|
|
51
|
+
router.get('/:authorityid', async (req, res) => {
|
|
52
|
+
console.log('GET /authorities params called');
|
|
53
|
+
const authorityId = (0, params_object_helpers_1.getAuthorityId)(req); // get the authority id.
|
|
54
|
+
console.log(`Authority ID: ${authorityId}`);
|
|
55
|
+
return res.status(200).send({ successful: true, authorityId });
|
|
56
|
+
});
|
|
57
|
+
/**
|
|
58
|
+
* This updates the authority object.
|
|
59
|
+
*/
|
|
60
|
+
router.patch('/', validate_request_body_1.validateRequestBody, async (req, res) => {
|
|
61
|
+
return res.status(200).send({ successful: true });
|
|
62
|
+
});
|
|
63
|
+
/**
|
|
64
|
+
* This deletes the authority object.
|
|
65
|
+
*/
|
|
66
|
+
router.delete('/', async (req, res) => {
|
|
67
|
+
return res.status(200).send({ successful: true });
|
|
68
|
+
});
|
|
69
|
+
exports.authorities = router;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.routes.d.ts","sourceRoot":"","sources":["../../../../../src/cors/routes/events.routes.ts"],"names":[],"mappings":"AAoCA,eAAO,MAAM,MAAM,4CAAS,CAAC"}
|