@xyo-network/chain-bridge 1.16.8 → 1.16.9

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.
@@ -0,0 +1,2 @@
1
+ export declare const TODO = true;
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/indexers/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,IAAI,OAAO,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/chain-bridge",
3
- "version": "1.16.8",
3
+ "version": "1.16.9",
4
4
  "description": "XYO Layer One Bridge",
5
5
  "homepage": "https://xylabs.com",
6
6
  "bugs": {
@@ -55,7 +55,7 @@
55
55
  "@xylabs/typeof": "~5.0.24",
56
56
  "@xyo-network/archivist-model": "~5.1.21",
57
57
  "@xyo-network/boundwitness-model": "~5.1.21",
58
- "@xyo-network/chain-protocol": "~1.16.8",
58
+ "@xyo-network/chain-protocol": "~1.16.9",
59
59
  "@xyo-network/manifest-model": "~5.1.21",
60
60
  "@xyo-network/module-factory-locator": "~5.1.21",
61
61
  "@xyo-network/module-model": "~5.1.21",
@@ -65,7 +65,7 @@
65
65
  "@xyo-network/typechain": "~4.0.10",
66
66
  "@xyo-network/wallet-model": "~5.1.21",
67
67
  "@xyo-network/xl1-protocol": "~1.13.6",
68
- "@xyo-network/xl1-protocol-sdk": "~1.16.8",
68
+ "@xyo-network/xl1-protocol-sdk": "~1.16.9",
69
69
  "compression": "~1.8.1",
70
70
  "cors": "~2.8.5",
71
71
  "express": "~5.1.0",
@@ -96,10 +96,10 @@
96
96
  "@xyo-network/bios": "~7.1.1",
97
97
  "@xyo-network/bios-model": "~7.1.1",
98
98
  "@xyo-network/boundwitness-builder": "~5.1.21",
99
- "@xyo-network/chain-modules": "~1.16.8",
100
- "@xyo-network/chain-protocol": "~1.16.8",
101
- "@xyo-network/chain-services": "~1.16.8",
102
- "@xyo-network/chain-telemetry": "~1.16.8",
99
+ "@xyo-network/chain-modules": "~1.16.9",
100
+ "@xyo-network/chain-protocol": "~1.16.9",
101
+ "@xyo-network/chain-services": "~1.16.9",
102
+ "@xyo-network/chain-telemetry": "~1.16.9",
103
103
  "@xyo-network/manifest-wrapper": "~5.1.21",
104
104
  "@xyo-network/module-abstract": "~5.1.21",
105
105
  "@xyo-network/module-abstract-mongodb": "~5.1.21",
@@ -0,0 +1 @@
1
+ export const TODO = true
@@ -1,2 +0,0 @@
1
- export * from './requestHandlerValidator.ts';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/server/routes/bridge/middleware/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAA"}
@@ -1,32 +0,0 @@
1
- import type { NextFunction, Request, RequestHandler, Response } from 'express';
2
- import type { ZodType } from 'zod';
3
- import { z } from 'zod';
4
- /**
5
- * Empty Zod schema for requests with no parameters.
6
- */
7
- export declare const EmptyParamsZod: z.ZodObject<{}, z.core.$catchall<z.ZodString>>;
8
- /**
9
- * Empty Zod schema for requests with no query parameters.
10
- */
11
- export declare const EmptyQueryParamsZod: z.ZodObject<{}, z.core.$catchall<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>>;
12
- /**
13
- * Default validation schemas for request handler validator.
14
- */
15
- export declare const ValidateRequestDefaults: {
16
- params: z.ZodObject<{}, z.core.$catchall<z.ZodString>>;
17
- query: z.ZodObject<{}, z.core.$catchall<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>>;
18
- body: z.ZodJSONSchema;
19
- response: z.ZodJSONSchema;
20
- };
21
- /**
22
- * Factory for Express middleware that validates request and response objects using Zod schemas.
23
- * @param schemas The Zod schemas to use for validation.
24
- * @returns A middleware function for validating requests and responses.
25
- */
26
- export declare function requestHandlerValidator<TParams extends typeof EmptyQueryParamsZod | ZodType<Record<string, string>> = typeof EmptyQueryParamsZod, TQuery extends typeof EmptyQueryParamsZod | ZodType<Record<string, string | string[]>> = typeof EmptyQueryParamsZod, TBody extends ZodType<unknown> = ZodType<unknown>, TResponse extends ZodType<unknown> = ZodType<unknown>>(schemas?: Partial<{
27
- body: TBody;
28
- params: TParams;
29
- query: TQuery;
30
- response: TResponse;
31
- }>): (handler: (req: Request<z.core.output<TParams>, z.core.output<TResponse>, z.core.output<TBody>, z.core.output<TQuery>>, res: Response<z.core.output<TResponse>>, next: NextFunction) => unknown) => RequestHandler;
32
- //# sourceMappingURL=requestHandlerValidator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"requestHandlerValidator.d.ts","sourceRoot":"","sources":["../../../../../../src/server/routes/bridge/middleware/requestHandlerValidator.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,YAAY,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,EAChD,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AAClC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;GAEG;AACH,eAAO,MAAM,cAAc,gDAAoC,CAAA;AAE/D;;GAEG;AACH,eAAO,MAAM,mBAAmB,gGAAoE,CAAA;AAEpG;;GAEG;AACH,eAAO,MAAM,uBAAuB;;;;;CAKnC,CAAA;AAID;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,SAAS,OAAO,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,OAAO,mBAAmB,EACzG,MAAM,SAAS,OAAO,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC,GAAG,OAAO,mBAAmB,EACnH,KAAK,SAAS,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,EACjD,SAAS,SAAS,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,EACrD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,KAAK,CAAA;IACX,MAAM,EAAE,OAAO,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,SAAS,CAAA;CACpB,CAAC,IAOQ,SAAS,CAAC,GAAG,EAAE,OAAO,+FAA0B,EAAE,GAAG,EAAE,QAAQ,0BAAK,EAAE,IAAI,EAAE,YAAY,KAAK,OAAO,KAAG,cAAc,CAiE9H"}
@@ -1 +0,0 @@
1
- export * from './requestHandlerValidator.ts'
@@ -1,120 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
- import type { ExpressError } from '@xylabs/express'
3
- import { isPromise } from '@xylabs/typeof'
4
- import type {
5
- NextFunction, Request, RequestHandler, Response,
6
- } from 'express'
7
- import { ReasonPhrases, StatusCodes } from 'http-status-codes'
8
- import type { ZodType } from 'zod'
9
- import { z } from 'zod'
10
-
11
- /**
12
- * Empty Zod schema for requests with no parameters.
13
- */
14
- export const EmptyParamsZod = z.object({}).catchall(z.string())
15
-
16
- /**
17
- * Empty Zod schema for requests with no query parameters.
18
- */
19
- export const EmptyQueryParamsZod = z.object({}).catchall(z.union([z.string(), z.array(z.string())]))
20
-
21
- /**
22
- * Default validation schemas for request handler validator.
23
- */
24
- export const ValidateRequestDefaults = {
25
- params: EmptyParamsZod,
26
- query: EmptyQueryParamsZod,
27
- body: z.json(),
28
- response: z.json(),
29
- }
30
-
31
- type ValidatableRequestKey = 'params' | 'query' | 'body'
32
-
33
- /**
34
- * Factory for Express middleware that validates request and response objects using Zod schemas.
35
- * @param schemas The Zod schemas to use for validation.
36
- * @returns A middleware function for validating requests and responses.
37
- */
38
- export function requestHandlerValidator<
39
- TParams extends typeof EmptyQueryParamsZod | ZodType<Record<string, string>> = typeof EmptyQueryParamsZod,
40
- TQuery extends typeof EmptyQueryParamsZod | ZodType<Record<string, string | string[]>> = typeof EmptyQueryParamsZod,
41
- TBody extends ZodType<unknown> = ZodType<unknown>,
42
- TResponse extends ZodType<unknown> = ZodType<unknown>,
43
- >(schemas?: Partial<{
44
- body: TBody
45
- params: TParams
46
- query: TQuery
47
- response: TResponse
48
- }>) {
49
- type Params = z.infer<TParams>
50
- type Query = z.infer<TQuery>
51
- type Body = z.infer<TBody>
52
- type Res = z.infer<TResponse>
53
- const validators = { ...ValidateRequestDefaults, ...schemas }
54
-
55
- return (handler: (req: Request<Params, Res, Body, Query>, res: Response<Res>, next: NextFunction) => unknown): RequestHandler => {
56
- return async (req: Request, res: Response, next: NextFunction) => {
57
- const originalJson = res.json.bind(res)
58
- try {
59
- // Validate incoming request
60
- const errors: string[] = []
61
- const keys: ValidatableRequestKey[] = ['params', 'query', 'body']
62
- for (const key of keys) {
63
- const validator = validators[key]
64
- const result = validator.safeParse(req[key])
65
- if (result.success) {
66
- Object.assign(req[key], result.data)
67
- } else {
68
- errors.push(
69
- ...result.error.issues.map(
70
- issue => (issue.path.length === 0)
71
- ? `${key}: ${issue.message}`
72
- : `${key}.${issue.path.join('.')}: ${issue.message}`,
73
- ),
74
- )
75
- }
76
- }
77
-
78
- // If there were validation errors, short-circuit and return Bad Request
79
- if (errors.length > 0) {
80
- const message = errors.join('; ')
81
- const err: ExpressError = new Error(message)
82
- err.name = ReasonPhrases.BAD_REQUEST
83
- err.statusCode = StatusCodes.BAD_REQUEST
84
- next(err)
85
- return false
86
- }
87
-
88
- // Wrap res.json to validate outgoing response
89
- res.json = (data: any) => {
90
- const result = validators.response.safeParse(data)
91
- if (result.success) {
92
- return originalJson(result.data)
93
- } else {
94
- const message = result.error.issues.map(
95
- issue => (issue.path.length === 0)
96
- ? `response: ${issue.message}`
97
- : `response.${issue.path.join('.')}: ${issue.message}`,
98
- ).join('; ')
99
- const err: ExpressError = new Error(message)
100
- err.name = ReasonPhrases.INTERNAL_SERVER_ERROR
101
- err.statusCode = StatusCodes.INTERNAL_SERVER_ERROR
102
-
103
- // Restore original json function in case the error handler wants to use it
104
- res.json = originalJson
105
- throw err
106
- }
107
- }
108
-
109
- // Automatically handle async errors
110
- const result = handler(req as any, res as any, next)
111
- if (result && isPromise(result)) {
112
- await result
113
- }
114
- } catch (err) {
115
- res.json = originalJson
116
- next(err)
117
- }
118
- }
119
- }
120
- }