@degenerate/endpoints 0.0.8 → 0.0.10

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.
@@ -1 +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"}
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,iBAclF"}
@@ -18,7 +18,6 @@ const get_set_audiences_1 = require("../audience/get-set-audiences");
18
18
  * @returns the next step if the validation succeeds or a unauthorized or disallowed response.
19
19
  */
20
20
  async function validateJWTAuthorities(req, res, next) {
21
- console.log('validateJWTAuthorities called');
22
21
  // get audience from the request
23
22
  const audience = (0, get_set_audiences_1.getAudienceAuthority)(req);
24
23
  if (!audience) {
@@ -0,0 +1,10 @@
1
+ import { ZodSchema } from 'zod';
2
+ import { Request, Response, NextFunction } from 'express';
3
+ /**
4
+ * This function validates the incoming request data against a schema.
5
+ *
6
+ * @param schema the schema to validate against
7
+ * @returns a middleware function that will validate the incoming request data
8
+ */
9
+ export declare function validateIncomingRequestData<T extends ZodSchema<any>>(schema: T): (req: Request, res: Response, next: NextFunction) => void;
10
+ //# sourceMappingURL=validate-incoming-request-data.d.ts.map
@@ -0,0 +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,UAa1D"}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateIncomingRequestData = validateIncomingRequestData;
4
+ const zod_1 = require("zod");
5
+ const generic_1 = require("@degenerate/generic");
6
+ /**
7
+ * This function validates the incoming request data against a schema.
8
+ *
9
+ * @param schema the schema to validate against
10
+ * @returns a middleware function that will validate the incoming request data
11
+ */
12
+ function validateIncomingRequestData(schema) {
13
+ return (req, res, next) => {
14
+ try {
15
+ schema.parse(req.body);
16
+ next();
17
+ }
18
+ catch (error) {
19
+ if (error instanceof zod_1.ZodError) {
20
+ const messages = formatZodErrors(error);
21
+ throw new generic_1.RequestValidationFailedError(req, messages);
22
+ }
23
+ else {
24
+ next(error); // Pass other errors to the next middleware
25
+ }
26
+ }
27
+ };
28
+ }
29
+ /**
30
+ * This function formats Zod error messages.
31
+ *
32
+ * @param error the ZodError object
33
+ * @returns an array of formatted error messages
34
+ */
35
+ function formatZodErrors(error) {
36
+ return error.errors.map(issue => `${issue.path.join('.')} is ${issue.message}`);
37
+ }
@@ -1 +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"}
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,kDAWrB"}
@@ -13,10 +13,9 @@ const generic_1 = require("@degenerate/generic");
13
13
  */
14
14
  function badRequestHandler(err, req, res, next) {
15
15
  if (err instanceof generic_1.BaseError && err.errorCode === 400) {
16
- console.error(err.toJSON());
17
16
  const response = {
18
17
  successful: false,
19
- error: 'Bad Request',
18
+ error: err.message,
20
19
  };
21
20
  return res.status(400).send(response);
22
21
  }
@@ -1 +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"}
1
+ {"version":3,"file":"authorities.routes.d.ts","sourceRoot":"","sources":["../../../src/cors/routes/authorities.routes.ts"],"names":[],"mappings":"AA0DA,eAAO,MAAM,WAAW,4CAAS,CAAC"}
@@ -29,6 +29,8 @@ const get_set_audiences_1 = require("../authority/audience/get-set-audiences");
29
29
  const validate_jwt_authorities_1 = require("../authority/jwt/validate-jwt-authorities");
30
30
  const validate_request_body_1 = require("../endpoints/helpers/validate-request-body");
31
31
  const generic_1 = require("@degenerate/generic");
32
+ const validate_incoming_request_data_1 = require("../endpoints/helpers/validate-incoming-request-data");
33
+ const authorities_schema_1 = require("../../schema/authorities.schema");
32
34
  // eslint-disable-next-line new-cap
33
35
  const router = express.Router({ mergeParams: true });
34
36
  router.use(get_set_audiences_1.setAudienceAuthority); // set the audience to share data (this will throw an error if the audience is not set)
@@ -37,7 +39,7 @@ router.use(validate_jwt_authorities_1.validateJWTAuthorities); // get the audien
37
39
  * This creates a new authority object.
38
40
  */
39
41
  router.post('/', validate_request_body_1.validateRequestBody, // make sure this is a valid request body
40
- async (req, res) => {
42
+ (0, validate_incoming_request_data_1.validateIncomingRequestData)(authorities_schema_1.ISAFETransactionAuthorityAddSchema), async (req, res) => {
41
43
  return res.status(200).send({ successful: true });
42
44
  });
43
45
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../../src/examples/express-server/app.ts"],"names":[],"mappings":"AAYA,QAAA,MAAM,GAAG,6CAAY,CAAC;AAiBtB,eAAe,GAAG,CAAC"}
1
+ {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../../src/examples/express-server/app.ts"],"names":[],"mappings":"AAaA,QAAA,MAAM,GAAG,6CAAY,CAAC;AAqBtB,eAAe,GAAG,CAAC"}
@@ -11,6 +11,7 @@ const functions_routes_1 = require("../../cors/routes/functions.routes");
11
11
  const rules_routes_1 = require("../../cors/routes/rules.routes");
12
12
  const share_data_routes_1 = require("../../cors/routes/share-data.routes");
13
13
  const generic_1 = require("@degenerate/generic");
14
+ const cors_1 = require("../../cors");
14
15
  //#endregion Route Imports
15
16
  // create the express application
16
17
  const app = (0, express_1.default)();
@@ -26,4 +27,7 @@ app.use('/events', events_routes_1.events); // add the events routes
26
27
  app.use('/functions', functions_routes_1.functions); // add the functions routes
27
28
  app.use('/rules', rules_routes_1.rules); // add the rules routes
28
29
  app.use('/share-data', share_data_routes_1.shareData); // add the share data routes
30
+ app.use(cors_1.unauthorizedHandler); // the unauthorized handler should be the first error handler
31
+ app.use(cors_1.badRequestHandler); // the bad request handler should be the second error handler
32
+ app.use(cors_1.allErrorHandler); // the all error handler catches all remaining errors
29
33
  exports.default = app;
@@ -38,22 +38,22 @@ export declare const ISAFETransactionBaseSchema: z.ZodObject<{
38
38
  }>;
39
39
  version: z.ZodNumber;
40
40
  }, "strip", z.ZodTypeAny, {
41
+ createdAt: number;
42
+ authority: string;
43
+ authoritySignature: string;
41
44
  transaction: {
42
45
  type: SAFETransactionType;
43
46
  action: SAFETransactionActionType;
44
47
  };
48
+ version: number;
49
+ }, {
45
50
  createdAt: number;
46
51
  authority: string;
47
52
  authoritySignature: string;
48
- version: number;
49
- }, {
50
53
  transaction: {
51
54
  type: SAFETransactionType;
52
55
  action: SAFETransactionActionType;
53
56
  };
54
- createdAt: number;
55
- authority: string;
56
- authoritySignature: string;
57
57
  version: number;
58
58
  }>;
59
59
  /**
@@ -77,9 +77,9 @@ const sampleTransactionAuthority: ISAFETransactionAuthority = {
77
77
  };
78
78
  */
79
79
  /**
80
- * This is the schema for the authority transaction.
80
+ * This is the schema for the authority transaction add.
81
81
  */
82
- export declare const ISAFETransactionAuthoritySchema: z.ZodObject<z.objectUtil.extendShape<{
82
+ export declare const ISAFETransactionAuthorityAddSchema: z.ZodObject<z.objectUtil.extendShape<{
83
83
  createdAt: z.ZodNumber;
84
84
  authority: z.ZodString;
85
85
  authoritySignature: z.ZodString;
@@ -97,7 +97,7 @@ export declare const ISAFETransactionAuthoritySchema: z.ZodObject<z.objectUtil.e
97
97
  }, {
98
98
  transaction: z.ZodObject<{
99
99
  type: z.ZodLiteral<SAFETransactionType.AUTHORITY>;
100
- action: z.ZodEnum<[SAFETransactionActionType.ADD, SAFETransactionActionType.REMOVE, SAFETransactionActionType.UPDATE]>;
100
+ action: z.ZodLiteral<SAFETransactionActionType.ADD>;
101
101
  data: z.ZodObject<{
102
102
  authorizationIssuer: z.ZodString;
103
103
  authorizationPublicKey: z.ZodString;
@@ -115,59 +115,59 @@ export declare const ISAFETransactionAuthoritySchema: z.ZodObject<z.objectUtil.e
115
115
  authorityOver: SAFETransactionType[];
116
116
  }>;
117
117
  }, "strip", z.ZodTypeAny, {
118
+ type: SAFETransactionType.AUTHORITY;
119
+ action: SAFETransactionActionType.ADD;
118
120
  data: {
119
121
  authorizationIssuer: string;
120
122
  authorizationPublicKey: string;
121
123
  authorityValidationType: AuthorityValidationType;
122
124
  authorityOver: SAFETransactionType[];
123
125
  };
124
- type: SAFETransactionType.AUTHORITY;
125
- action: SAFETransactionActionType;
126
126
  }, {
127
+ type: SAFETransactionType.AUTHORITY;
128
+ action: SAFETransactionActionType.ADD;
127
129
  data: {
128
130
  authorizationIssuer: string;
129
131
  authorizationPublicKey: string;
130
132
  authorityValidationType: AuthorityValidationType;
131
133
  authorityOver: SAFETransactionType[];
132
134
  };
133
- type: SAFETransactionType.AUTHORITY;
134
- action: SAFETransactionActionType;
135
135
  }>;
136
136
  }>, "strip", z.ZodTypeAny, {
137
+ createdAt: number;
138
+ authority: string;
139
+ authoritySignature: string;
137
140
  transaction: {
141
+ type: SAFETransactionType.AUTHORITY;
142
+ action: SAFETransactionActionType.ADD;
138
143
  data: {
139
144
  authorizationIssuer: string;
140
145
  authorizationPublicKey: string;
141
146
  authorityValidationType: AuthorityValidationType;
142
147
  authorityOver: SAFETransactionType[];
143
148
  };
144
- type: SAFETransactionType.AUTHORITY;
145
- action: SAFETransactionActionType;
146
149
  };
150
+ version: number;
151
+ }, {
147
152
  createdAt: number;
148
153
  authority: string;
149
154
  authoritySignature: string;
150
- version: number;
151
- }, {
152
155
  transaction: {
156
+ type: SAFETransactionType.AUTHORITY;
157
+ action: SAFETransactionActionType.ADD;
153
158
  data: {
154
159
  authorizationIssuer: string;
155
160
  authorizationPublicKey: string;
156
161
  authorityValidationType: AuthorityValidationType;
157
162
  authorityOver: SAFETransactionType[];
158
163
  };
159
- type: SAFETransactionType.AUTHORITY;
160
- action: SAFETransactionActionType;
161
164
  };
162
- createdAt: number;
163
- authority: string;
164
- authoritySignature: string;
165
165
  version: number;
166
166
  }>;
167
167
  /**
168
- * This is the schema for the authority transaction add.
168
+ * This is the schema for the authority transaction update.
169
169
  */
170
- export declare const ISAFETransactionAuthorityAddSchema: z.ZodObject<z.objectUtil.extendShape<z.objectUtil.extendShape<{
170
+ export declare const ISAFETransactionAuthorityUpdateSchema: z.ZodObject<z.objectUtil.extendShape<{
171
171
  createdAt: z.ZodNumber;
172
172
  authority: z.ZodString;
173
173
  authoritySignature: z.ZodString;
@@ -185,7 +185,7 @@ export declare const ISAFETransactionAuthorityAddSchema: z.ZodObject<z.objectUti
185
185
  }, {
186
186
  transaction: z.ZodObject<{
187
187
  type: z.ZodLiteral<SAFETransactionType.AUTHORITY>;
188
- action: z.ZodEnum<[SAFETransactionActionType.ADD, SAFETransactionActionType.REMOVE, SAFETransactionActionType.UPDATE]>;
188
+ action: z.ZodLiteral<SAFETransactionActionType.UPDATE>;
189
189
  data: z.ZodObject<{
190
190
  authorizationIssuer: z.ZodString;
191
191
  authorizationPublicKey: z.ZodString;
@@ -203,135 +203,59 @@ export declare const ISAFETransactionAuthorityAddSchema: z.ZodObject<z.objectUti
203
203
  authorityOver: SAFETransactionType[];
204
204
  }>;
205
205
  }, "strip", z.ZodTypeAny, {
206
+ type: SAFETransactionType.AUTHORITY;
207
+ action: SAFETransactionActionType.UPDATE;
206
208
  data: {
207
209
  authorizationIssuer: string;
208
210
  authorizationPublicKey: string;
209
211
  authorityValidationType: AuthorityValidationType;
210
212
  authorityOver: SAFETransactionType[];
211
213
  };
212
- type: SAFETransactionType.AUTHORITY;
213
- action: SAFETransactionActionType;
214
214
  }, {
215
+ type: SAFETransactionType.AUTHORITY;
216
+ action: SAFETransactionActionType.UPDATE;
215
217
  data: {
216
218
  authorizationIssuer: string;
217
219
  authorizationPublicKey: string;
218
220
  authorityValidationType: AuthorityValidationType;
219
221
  authorityOver: SAFETransactionType[];
220
222
  };
221
- type: SAFETransactionType.AUTHORITY;
222
- action: SAFETransactionActionType;
223
- }>;
224
- }>, {
225
- transaction: z.ZodObject<{
226
- action: z.ZodLiteral<SAFETransactionActionType.ADD>;
227
- }, "strip", z.ZodTypeAny, {
228
- action: SAFETransactionActionType.ADD;
229
- }, {
230
- action: SAFETransactionActionType.ADD;
231
223
  }>;
232
224
  }>, "strip", z.ZodTypeAny, {
233
- transaction: {
234
- action: SAFETransactionActionType.ADD;
235
- };
236
225
  createdAt: number;
237
226
  authority: string;
238
227
  authoritySignature: string;
239
- version: number;
240
- }, {
241
228
  transaction: {
242
- action: SAFETransactionActionType.ADD;
243
- };
244
- createdAt: number;
245
- authority: string;
246
- authoritySignature: string;
247
- version: number;
248
- }>;
249
- /**
250
- * This is the schema for the authority transaction update.
251
- */
252
- export declare const ISAFETransactionAuthorityUpdateSchema: z.ZodObject<z.objectUtil.extendShape<z.objectUtil.extendShape<{
253
- createdAt: z.ZodNumber;
254
- authority: z.ZodString;
255
- authoritySignature: z.ZodString;
256
- transaction: z.ZodObject<{
257
- type: z.ZodEnum<[SAFETransactionType.AUTHORITY, SAFETransactionType.SHAREDATA, SAFETransactionType.FUNCTIONS, SAFETransactionType.RULES, SAFETransactionType.EVENTS, SAFETransactionType.ENDPOINTS]>;
258
- action: z.ZodEnum<[SAFETransactionActionType.ADD, SAFETransactionActionType.REMOVE, SAFETransactionActionType.UPDATE]>;
259
- }, "strip", z.ZodTypeAny, {
260
- type: SAFETransactionType;
261
- action: SAFETransactionActionType;
262
- }, {
263
- type: SAFETransactionType;
264
- action: SAFETransactionActionType;
265
- }>;
266
- version: z.ZodNumber;
267
- }, {
268
- transaction: z.ZodObject<{
269
- type: z.ZodLiteral<SAFETransactionType.AUTHORITY>;
270
- action: z.ZodEnum<[SAFETransactionActionType.ADD, SAFETransactionActionType.REMOVE, SAFETransactionActionType.UPDATE]>;
271
- data: z.ZodObject<{
272
- authorizationIssuer: z.ZodString;
273
- authorizationPublicKey: z.ZodString;
274
- authorityValidationType: z.ZodEnum<[AuthorityValidationType]>;
275
- authorityOver: z.ZodArray<z.ZodEnum<[SAFETransactionType.AUTHORITY, SAFETransactionType.SHAREDATA, SAFETransactionType.FUNCTIONS, SAFETransactionType.RULES, SAFETransactionType.EVENTS, SAFETransactionType.ENDPOINTS]>, "many">;
276
- }, "strip", z.ZodTypeAny, {
277
- authorizationIssuer: string;
278
- authorizationPublicKey: string;
279
- authorityValidationType: AuthorityValidationType;
280
- authorityOver: SAFETransactionType[];
281
- }, {
282
- authorizationIssuer: string;
283
- authorizationPublicKey: string;
284
- authorityValidationType: AuthorityValidationType;
285
- authorityOver: SAFETransactionType[];
286
- }>;
287
- }, "strip", z.ZodTypeAny, {
288
- data: {
289
- authorizationIssuer: string;
290
- authorizationPublicKey: string;
291
- authorityValidationType: AuthorityValidationType;
292
- authorityOver: SAFETransactionType[];
293
- };
294
229
  type: SAFETransactionType.AUTHORITY;
295
- action: SAFETransactionActionType;
296
- }, {
230
+ action: SAFETransactionActionType.UPDATE;
297
231
  data: {
298
232
  authorizationIssuer: string;
299
233
  authorizationPublicKey: string;
300
234
  authorityValidationType: AuthorityValidationType;
301
235
  authorityOver: SAFETransactionType[];
302
236
  };
303
- type: SAFETransactionType.AUTHORITY;
304
- action: SAFETransactionActionType;
305
- }>;
306
- }>, {
307
- transaction: z.ZodObject<{
308
- action: z.ZodLiteral<SAFETransactionActionType.UPDATE>;
309
- }, "strip", z.ZodTypeAny, {
310
- action: SAFETransactionActionType.UPDATE;
311
- }, {
312
- action: SAFETransactionActionType.UPDATE;
313
- }>;
314
- }>, "strip", z.ZodTypeAny, {
315
- transaction: {
316
- action: SAFETransactionActionType.UPDATE;
317
237
  };
238
+ version: number;
239
+ }, {
318
240
  createdAt: number;
319
241
  authority: string;
320
242
  authoritySignature: string;
321
- version: number;
322
- }, {
323
243
  transaction: {
244
+ type: SAFETransactionType.AUTHORITY;
324
245
  action: SAFETransactionActionType.UPDATE;
246
+ data: {
247
+ authorizationIssuer: string;
248
+ authorizationPublicKey: string;
249
+ authorityValidationType: AuthorityValidationType;
250
+ authorityOver: SAFETransactionType[];
251
+ };
325
252
  };
326
- createdAt: number;
327
- authority: string;
328
- authoritySignature: string;
329
253
  version: number;
330
254
  }>;
331
255
  /**
332
256
  * This is the schema for the authority transaction remove.
333
257
  */
334
- export declare const ISAFETransactionAuthorityRemoveSchema: z.ZodObject<z.objectUtil.extendShape<z.objectUtil.extendShape<{
258
+ export declare const ISAFETransactionAuthorityRemoveSchema: z.ZodObject<z.objectUtil.extendShape<{
335
259
  createdAt: z.ZodNumber;
336
260
  authority: z.ZodString;
337
261
  authoritySignature: z.ZodString;
@@ -349,7 +273,7 @@ export declare const ISAFETransactionAuthorityRemoveSchema: z.ZodObject<z.object
349
273
  }, {
350
274
  transaction: z.ZodObject<{
351
275
  type: z.ZodLiteral<SAFETransactionType.AUTHORITY>;
352
- action: z.ZodEnum<[SAFETransactionActionType.ADD, SAFETransactionActionType.REMOVE, SAFETransactionActionType.UPDATE]>;
276
+ action: z.ZodLiteral<SAFETransactionActionType.REMOVE>;
353
277
  data: z.ZodObject<{
354
278
  authorizationIssuer: z.ZodString;
355
279
  authorizationPublicKey: z.ZodString;
@@ -367,47 +291,53 @@ export declare const ISAFETransactionAuthorityRemoveSchema: z.ZodObject<z.object
367
291
  authorityOver: SAFETransactionType[];
368
292
  }>;
369
293
  }, "strip", z.ZodTypeAny, {
294
+ type: SAFETransactionType.AUTHORITY;
295
+ action: SAFETransactionActionType.REMOVE;
370
296
  data: {
371
297
  authorizationIssuer: string;
372
298
  authorizationPublicKey: string;
373
299
  authorityValidationType: AuthorityValidationType;
374
300
  authorityOver: SAFETransactionType[];
375
301
  };
376
- type: SAFETransactionType.AUTHORITY;
377
- action: SAFETransactionActionType;
378
302
  }, {
303
+ type: SAFETransactionType.AUTHORITY;
304
+ action: SAFETransactionActionType.REMOVE;
379
305
  data: {
380
306
  authorizationIssuer: string;
381
307
  authorizationPublicKey: string;
382
308
  authorityValidationType: AuthorityValidationType;
383
309
  authorityOver: SAFETransactionType[];
384
310
  };
385
- type: SAFETransactionType.AUTHORITY;
386
- action: SAFETransactionActionType;
387
- }>;
388
- }>, {
389
- transaction: z.ZodObject<{
390
- action: z.ZodLiteral<SAFETransactionActionType.REMOVE>;
391
- }, "strip", z.ZodTypeAny, {
392
- action: SAFETransactionActionType.REMOVE;
393
- }, {
394
- action: SAFETransactionActionType.REMOVE;
395
311
  }>;
396
312
  }>, "strip", z.ZodTypeAny, {
397
- transaction: {
398
- action: SAFETransactionActionType.REMOVE;
399
- };
400
313
  createdAt: number;
401
314
  authority: string;
402
315
  authoritySignature: string;
403
- version: number;
404
- }, {
405
316
  transaction: {
317
+ type: SAFETransactionType.AUTHORITY;
406
318
  action: SAFETransactionActionType.REMOVE;
319
+ data: {
320
+ authorizationIssuer: string;
321
+ authorizationPublicKey: string;
322
+ authorityValidationType: AuthorityValidationType;
323
+ authorityOver: SAFETransactionType[];
324
+ };
407
325
  };
326
+ version: number;
327
+ }, {
408
328
  createdAt: number;
409
329
  authority: string;
410
330
  authoritySignature: string;
331
+ transaction: {
332
+ type: SAFETransactionType.AUTHORITY;
333
+ action: SAFETransactionActionType.REMOVE;
334
+ data: {
335
+ authorizationIssuer: string;
336
+ authorizationPublicKey: string;
337
+ authorityValidationType: AuthorityValidationType;
338
+ authorityOver: SAFETransactionType[];
339
+ };
340
+ };
411
341
  version: number;
412
342
  }>;
413
343
  //# sourceMappingURL=authorities.schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"authorities.schema.d.ts","sourceRoot":"","sources":["../../src/schema/authorities.schema.ts"],"names":[],"mappings":"AACA,OAAO,CAAC,MAAM,KAAK,CAAC;AAKpB,OAAO,EACH,uBAAuB,EACvB,yBAAyB,EACzB,mBAAmB,EACtB,MAAM,qBAAqB,CAAC;AAK7B;;GAEG;AACH,eAAO,MAAM,mCAAmC;;;;;;;;;;;;;;;EAK9C,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EASrC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;GAmBG;AAEH;;GAEG;AACH,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAM1C,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,kCAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAI7C,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,qCAAqC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAIhD,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,qCAAqC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAIhD,CAAC"}
1
+ {"version":3,"file":"authorities.schema.d.ts","sourceRoot":"","sources":["../../src/schema/authorities.schema.ts"],"names":[],"mappings":"AACA,OAAO,CAAC,MAAM,KAAK,CAAC;AAKpB,OAAO,EACH,uBAAuB,EACvB,yBAAyB,EACzB,mBAAmB,EACtB,MAAM,qBAAqB,CAAC;AAK7B;;GAEG;AACH,eAAO,MAAM,mCAAmC;;;;;;;;;;;;;;;EAK9C,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EASrC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;GAmBG;AAEH;;GAEG;AACH,eAAO,MAAM,kCAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAM7C,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,qCAAqC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAMhD,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,qCAAqC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAMhD,CAAC"}
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ISAFETransactionAuthorityRemoveSchema = exports.ISAFETransactionAuthorityUpdateSchema = exports.ISAFETransactionAuthorityAddSchema = exports.ISAFETransactionAuthoritySchema = exports.ISAFETransactionBaseSchema = exports.ISAFETransactionAuthorityDataSchema = void 0;
6
+ exports.ISAFETransactionAuthorityRemoveSchema = exports.ISAFETransactionAuthorityUpdateSchema = exports.ISAFETransactionAuthorityAddSchema = exports.ISAFETransactionBaseSchema = exports.ISAFETransactionAuthorityDataSchema = void 0;
7
7
  // This contains the schemas for the authorities objects in the zod format..
8
8
  const zod_1 = __importDefault(require("zod"));
9
9
  const transaction_schema_1 = require("./transaction.schema");
@@ -52,37 +52,33 @@ const sampleTransactionAuthority: ISAFETransactionAuthority = {
52
52
  version: 1,
53
53
  };
54
54
  */
55
- /**
56
- * This is the schema for the authority transaction.
57
- */
58
- exports.ISAFETransactionAuthoritySchema = exports.ISAFETransactionBaseSchema.extend({
59
- transaction: zod_1.default.object({
60
- type: zod_1.default.literal(generic_1.SAFETransactionType.AUTHORITY),
61
- action: transaction_schema_1.SAFETransactionActionTypeSchema,
62
- data: exports.ISAFETransactionAuthorityDataSchema,
63
- }),
64
- });
65
55
  /**
66
56
  * This is the schema for the authority transaction add.
67
57
  */
68
- exports.ISAFETransactionAuthorityAddSchema = exports.ISAFETransactionAuthoritySchema.extend({
58
+ exports.ISAFETransactionAuthorityAddSchema = exports.ISAFETransactionBaseSchema.extend({
69
59
  transaction: zod_1.default.object({
60
+ type: zod_1.default.literal(generic_1.SAFETransactionType.AUTHORITY),
70
61
  action: zod_1.default.literal(generic_1.SAFETransactionActionType.ADD),
62
+ data: exports.ISAFETransactionAuthorityDataSchema,
71
63
  }),
72
64
  });
73
65
  /**
74
66
  * This is the schema for the authority transaction update.
75
67
  */
76
- exports.ISAFETransactionAuthorityUpdateSchema = exports.ISAFETransactionAuthoritySchema.extend({
68
+ exports.ISAFETransactionAuthorityUpdateSchema = exports.ISAFETransactionBaseSchema.extend({
77
69
  transaction: zod_1.default.object({
70
+ type: zod_1.default.literal(generic_1.SAFETransactionType.AUTHORITY),
78
71
  action: zod_1.default.literal(generic_1.SAFETransactionActionType.UPDATE),
72
+ data: exports.ISAFETransactionAuthorityDataSchema,
79
73
  }),
80
74
  });
81
75
  /**
82
76
  * This is the schema for the authority transaction remove.
83
77
  */
84
- exports.ISAFETransactionAuthorityRemoveSchema = exports.ISAFETransactionAuthoritySchema.extend({
78
+ exports.ISAFETransactionAuthorityRemoveSchema = exports.ISAFETransactionBaseSchema.extend({
85
79
  transaction: zod_1.default.object({
80
+ type: zod_1.default.literal(generic_1.SAFETransactionType.AUTHORITY),
86
81
  action: zod_1.default.literal(generic_1.SAFETransactionActionType.REMOVE),
82
+ data: exports.ISAFETransactionAuthorityDataSchema,
87
83
  }),
88
84
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@degenerate/endpoints",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
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.8",
42
+ "@degenerate/generic": "^0.1.9",
43
43
  "express": "^4.21.1",
44
44
  "zod": "^3.23.8"
45
45
  },
46
- "gitHead": "2037872036e4ccce0805f049b125983d3cb7415b"
46
+ "gitHead": "5e38293cf889de1089ca2cda356191136a493507"
47
47
  }