@degenerate/endpoints 0.0.11 → 0.0.13
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/cors/endpoints/helpers/validate-incoming-request-data.d.ts.map +1 -1
- package/dist/cors/endpoints/helpers/validate-incoming-request-data.js +1 -0
- package/dist/cors/index.d.ts +1 -2
- package/dist/cors/index.d.ts.map +1 -1
- package/dist/cors/index.js +2 -3
- package/dist/cors/logging/add-unique-tracking.js +2 -2
- package/dist/cors/routes/authorities/v1.routes.d.ts.map +1 -1
- package/dist/cors/routes/authorities/v1.routes.js +8 -8
- package/dist/cors/routes/rules/v1/rule-set.routes.d.ts.map +1 -1
- package/dist/cors/routes/rules/v1/rule-set.routes.js +4 -6
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -0
- package/package.json +3 -3
- package/dist/cors/endpoints/authorities/validate-authorities-transaction.d.ts +0 -30
- package/dist/cors/endpoints/authorities/validate-authorities-transaction.d.ts.map +0 -1
- package/dist/cors/endpoints/authorities/validate-authorities-transaction.js +0 -155
- package/dist/schema/authorities-transactions.schema.d.ts +0 -306
- package/dist/schema/authorities-transactions.schema.d.ts.map +0 -1
- package/dist/schema/authorities-transactions.schema.js +0 -71
- package/dist/schema/rules/rules-conditions.schema.d.ts +0 -402
- package/dist/schema/rules/rules-conditions.schema.d.ts.map +0 -1
- package/dist/schema/rules/rules-conditions.schema.js +0 -99
- package/dist/schema/rules/rules-enums.schema.d.ts +0 -39
- package/dist/schema/rules/rules-enums.schema.d.ts.map +0 -1
- package/dist/schema/rules/rules-enums.schema.js +0 -90
- package/dist/schema/rules/rules.schema.d.ts +0 -2839
- package/dist/schema/rules/rules.schema.d.ts.map +0 -1
- package/dist/schema/rules/rules.schema.js +0 -76
- package/dist/schema/rules-transactions.schema.d.ts +0 -450
- package/dist/schema/rules-transactions.schema.d.ts.map +0 -1
- package/dist/schema/rules-transactions.schema.js +0 -63
- package/dist/schema/transactions.schema.d.ts +0 -45
- package/dist/schema/transactions.schema.d.ts.map +0 -1
- package/dist/schema/transactions.schema.js +0 -43
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-incoming-request-data.d.ts","sourceRoot":"","sources":["../../../../src/cors/endpoints/helpers/validate-incoming-request-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,SAAS,EAAE,MAAM,KAAK,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAG1D;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,CAAC,SAAS,SAAS,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC,SAC9D,OAAO,OAAO,QAAQ,QAAQ,YAAY,
|
|
1
|
+
{"version":3,"file":"validate-incoming-request-data.d.ts","sourceRoot":"","sources":["../../../../src/cors/endpoints/helpers/validate-incoming-request-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,SAAS,EAAE,MAAM,KAAK,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAG1D;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,CAAC,SAAS,SAAS,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC,SAC9D,OAAO,OAAO,QAAQ,QAAQ,YAAY,UAc1D"}
|
package/dist/cors/index.d.ts
CHANGED
|
@@ -5,9 +5,8 @@ export * from './authority/jwt/validate-jwt-events';
|
|
|
5
5
|
export * from './authority/jwt/validate-jwt-functions';
|
|
6
6
|
export * from './authority/jwt/validate-jwt-rules';
|
|
7
7
|
export * from './authority/jwt/validate-jwt-share-data';
|
|
8
|
-
export * from './endpoints/authorities/validate-authorities-transaction';
|
|
9
|
-
export * from './endpoints/helpers/validate-request-body';
|
|
10
8
|
export * from './endpoints/helpers/validate-incoming-request-data';
|
|
9
|
+
export * from './endpoints/helpers/validate-request-body';
|
|
11
10
|
export * from './errors/all-error-handler';
|
|
12
11
|
export * from './errors/bad-request-handler';
|
|
13
12
|
export * from './errors/unauthorized-handler';
|
package/dist/cors/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cors/index.ts"],"names":[],"mappings":"AAAA,cAAc,wCAAwC,CAAC;AACvD,cAAc,0CAA0C,CAAC;AACzD,cAAc,wCAAwC,CAAC;AACvD,cAAc,qCAAqC,CAAC;AACpD,cAAc,wCAAwC,CAAC;AACvD,cAAc,oCAAoC,CAAC;AACnD,cAAc,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cors/index.ts"],"names":[],"mappings":"AAAA,cAAc,wCAAwC,CAAC;AACvD,cAAc,0CAA0C,CAAC;AACzD,cAAc,wCAAwC,CAAC;AACvD,cAAc,qCAAqC,CAAC;AACpD,cAAc,wCAAwC,CAAC;AACvD,cAAc,oCAAoC,CAAC;AACnD,cAAc,yCAAyC,CAAC;AAGxD,cAAc,oDAAoD,CAAC;AAEnE,cAAc,2CAA2C,CAAC;AAI1D,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,+BAA+B,CAAC;AAI9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,2BAA2B,CAAC;AAI1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC"}
|
package/dist/cors/index.js
CHANGED
|
@@ -22,11 +22,10 @@ __exportStar(require("./authority/jwt/validate-jwt-functions"), exports);
|
|
|
22
22
|
__exportStar(require("./authority/jwt/validate-jwt-rules"), exports);
|
|
23
23
|
__exportStar(require("./authority/jwt/validate-jwt-share-data"), exports);
|
|
24
24
|
//#region Endpoints
|
|
25
|
-
__exportStar(require("./endpoints/authorities/validate-authorities-transaction"), exports);
|
|
26
|
-
// zod checks
|
|
27
|
-
__exportStar(require("./endpoints/helpers/validate-request-body"), exports);
|
|
28
25
|
// object javascript checks
|
|
29
26
|
__exportStar(require("./endpoints/helpers/validate-incoming-request-data"), exports);
|
|
27
|
+
// zod checks
|
|
28
|
+
__exportStar(require("./endpoints/helpers/validate-request-body"), exports);
|
|
30
29
|
//#endregion Endpoints
|
|
31
30
|
//#region errors functions
|
|
32
31
|
__exportStar(require("./errors/all-error-handler"), exports);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addUniqueTracking = addUniqueTracking;
|
|
4
4
|
const generic_1 = require("@degenerate/generic");
|
|
5
|
-
const
|
|
5
|
+
const generic_2 = require("@degenerate/generic");
|
|
6
6
|
/**
|
|
7
7
|
* This function adds a unique tracking id to the request object.
|
|
8
8
|
*
|
|
@@ -12,7 +12,7 @@ const request_object_helpers_1 = require("@degenerate/generic/src/helpers/reques
|
|
|
12
12
|
* @returns
|
|
13
13
|
*/
|
|
14
14
|
function addUniqueTracking(req, res, next) {
|
|
15
|
-
(0,
|
|
15
|
+
(0, generic_2.setUniqueTrackingId)(req, `${(0, generic_1.createId)(30)}-${Date.now()}`);
|
|
16
16
|
next();
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"v1.routes.d.ts","sourceRoot":"","sources":["../../../../src/cors/routes/authorities/v1.routes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"v1.routes.d.ts","sourceRoot":"","sources":["../../../../src/cors/routes/authorities/v1.routes.ts"],"names":[],"mappings":"AAkGA,eAAO,MAAM,EAAE,4CAAS,CAAC"}
|
|
@@ -32,14 +32,13 @@ const validate_request_body_1 = require("../../endpoints/helpers/validate-reques
|
|
|
32
32
|
const validate_incoming_request_data_1 = require("../../endpoints/helpers/validate-incoming-request-data");
|
|
33
33
|
// #endregion Middleware Protections
|
|
34
34
|
//#region Incoming Shape Validations
|
|
35
|
-
const
|
|
35
|
+
const generic_1 = require("@degenerate/generic");
|
|
36
36
|
//#endregion Incoming Shape Validations
|
|
37
37
|
//#region Functions and Models
|
|
38
38
|
const add_unique_tracking_1 = require("../../logging/add-unique-tracking");
|
|
39
39
|
//#endregion Functions and Models
|
|
40
40
|
//#region Route Imports
|
|
41
41
|
//#endregion Route Imports
|
|
42
|
-
const generic_1 = require("@degenerate/generic");
|
|
43
42
|
// eslint-disable-next-line new-cap
|
|
44
43
|
const router = express.Router({ mergeParams: true });
|
|
45
44
|
router.use(add_unique_tracking_1.addUniqueTracking); // add the unique tracking id to the request
|
|
@@ -49,7 +48,7 @@ router.use(add_unique_tracking_1.addUniqueTracking); // add the unique tracking
|
|
|
49
48
|
router.post(// https://{hostname}/authorities/v1
|
|
50
49
|
'/', add_unique_tracking_1.addUniqueTracking, // add a unique tracking id to the request
|
|
51
50
|
validate_request_body_1.validateRequestBody, // make sure this is a valid request body
|
|
52
|
-
(0, validate_incoming_request_data_1.validateIncomingRequestData)(
|
|
51
|
+
(0, validate_incoming_request_data_1.validateIncomingRequestData)(generic_1.ISAFETransactionAuthorityAddSchema), async (req, res) => {
|
|
53
52
|
return res.status(200).send({ successful: true });
|
|
54
53
|
});
|
|
55
54
|
/**
|
|
@@ -70,17 +69,18 @@ async (req, res) => {
|
|
|
70
69
|
/**
|
|
71
70
|
* This updates the authority object.
|
|
72
71
|
*/
|
|
73
|
-
router.patch(// https://{hostname}/authorities/v1
|
|
74
|
-
'
|
|
75
|
-
validate_request_body_1.validateRequestBody, (0, validate_incoming_request_data_1.validateIncomingRequestData)(
|
|
76
|
-
|
|
72
|
+
router.patch(// https://{hostname}/authorities/v1/{authorityid}
|
|
73
|
+
'/:authorityid', add_unique_tracking_1.addUniqueTracking, // add a unique tracking id to the request
|
|
74
|
+
validate_request_body_1.validateRequestBody, (0, validate_incoming_request_data_1.validateIncomingRequestData)(generic_1.ISAFETransactionAuthorityUpdateSchema), async (req, res) => {
|
|
75
|
+
const authorityId = (0, generic_1.getAuthorityId)(req); // get the authority id.
|
|
76
|
+
return res.status(200).send({ successful: true, authorityId });
|
|
77
77
|
});
|
|
78
78
|
/**
|
|
79
79
|
* This deletes the authority object.
|
|
80
80
|
*/
|
|
81
81
|
router.delete(// https://{hostname}/authorities/v1
|
|
82
82
|
'/:authorityid', add_unique_tracking_1.addUniqueTracking, // add a unique tracking id to the request
|
|
83
|
-
validate_request_body_1.validateRequestBody, (0, validate_incoming_request_data_1.validateIncomingRequestData)(
|
|
83
|
+
validate_request_body_1.validateRequestBody, (0, validate_incoming_request_data_1.validateIncomingRequestData)(generic_1.ISAFETransactionAuthorityDeleteSchema), async (req, res) => {
|
|
84
84
|
const authorityId = (0, generic_1.getAuthorityId)(req); // get the authority id.
|
|
85
85
|
return res.status(200).send({ successful: true, authorityId });
|
|
86
86
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rule-set.routes.d.ts","sourceRoot":"","sources":["../../../../../src/cors/routes/rules/v1/rule-set.routes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rule-set.routes.d.ts","sourceRoot":"","sources":["../../../../../src/cors/routes/rules/v1/rule-set.routes.ts"],"names":[],"mappings":"AAkGA,eAAO,MAAM,QAAQ,4CAAS,CAAC"}
|
|
@@ -33,9 +33,7 @@ const express = __importStar(require("express"));
|
|
|
33
33
|
const validate_incoming_request_data_1 = require("../../../endpoints/helpers/validate-incoming-request-data");
|
|
34
34
|
//#endregion Incoming Shape Validations
|
|
35
35
|
//#region Functions and Models
|
|
36
|
-
const rules_transactions_schema_1 = require("../../../../schema/rules-transactions.schema");
|
|
37
36
|
const generic_1 = require("@degenerate/generic");
|
|
38
|
-
const params_object_helpers_1 = require("@degenerate/generic/src/helpers/request/params-object-helpers");
|
|
39
37
|
//#endregion Functions and Models
|
|
40
38
|
//#region Route Imports
|
|
41
39
|
//#endregion Route Imports
|
|
@@ -45,7 +43,7 @@ const router = express.Router({ mergeParams: true });
|
|
|
45
43
|
* This creates a new rules set object.
|
|
46
44
|
*/
|
|
47
45
|
router.post(// https://{hostname}/rules/v1/rule-sets
|
|
48
|
-
'/', (0, validate_incoming_request_data_1.validateIncomingRequestData)(
|
|
46
|
+
'/', (0, validate_incoming_request_data_1.validateIncomingRequestData)(generic_1.ISAFETransactionRuleSetAddSchema), async (req, res, next) => {
|
|
49
47
|
try {
|
|
50
48
|
return res.status(200).send({ successful: true });
|
|
51
49
|
}
|
|
@@ -70,7 +68,7 @@ router.get('/', async (req, res, next) => {
|
|
|
70
68
|
*/
|
|
71
69
|
router.get('/:rulesetsid', async (req, res, next) => {
|
|
72
70
|
try {
|
|
73
|
-
const rulesId = (0,
|
|
71
|
+
const rulesId = (0, generic_1.getParamRuleSetsId)(req); // get the rules id.
|
|
74
72
|
return res.status(200).send({ successful: true });
|
|
75
73
|
}
|
|
76
74
|
catch (err) {
|
|
@@ -82,7 +80,7 @@ router.get('/:rulesetsid', async (req, res, next) => {
|
|
|
82
80
|
*/
|
|
83
81
|
router.patch('/:rulesetsid', async (req, res, next) => {
|
|
84
82
|
try {
|
|
85
|
-
const rulesId = (0,
|
|
83
|
+
const rulesId = (0, generic_1.getParamRuleSetsId)(req); // get the rules id.
|
|
86
84
|
return res.status(200).send({ successful: true });
|
|
87
85
|
}
|
|
88
86
|
catch (err) {
|
|
@@ -94,7 +92,7 @@ router.patch('/:rulesetsid', async (req, res, next) => {
|
|
|
94
92
|
*/
|
|
95
93
|
router.delete('/:rulesetsid', async (req, res, next) => {
|
|
96
94
|
try {
|
|
97
|
-
const rulesId = (0,
|
|
95
|
+
const rulesId = (0, generic_1.getParamRuleSetsId)(req); // get the rules id.
|
|
98
96
|
return res.status(200).send({ successful: true });
|
|
99
97
|
}
|
|
100
98
|
catch (err) {
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,QAAQ,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,18 @@
|
|
|
1
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 });
|
|
2
17
|
// This is the main file for the package
|
|
18
|
+
__exportStar(require("./cors"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@degenerate/endpoints",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"devDependencies": {
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"author": "Degenerate Inc.",
|
|
40
40
|
"license": "ISC",
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@degenerate/generic": "^0.1.
|
|
42
|
+
"@degenerate/generic": "^0.1.12",
|
|
43
43
|
"express": "^4.21.1",
|
|
44
44
|
"zod": "^3.23.8"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "4e03fc84a8e12c1afb93df57e8da0bb02f932792"
|
|
47
47
|
}
|
|
@@ -1,30 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,155 +0,0 @@
|
|
|
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
|
-
// }
|