@faremeter/middleware 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/common.d.ts +52 -0
- package/dist/src/common.d.ts.map +1 -0
- package/dist/src/common.js +96 -0
- package/dist/src/express.d.ts +3 -6
- package/dist/src/express.d.ts.map +1 -1
- package/dist/src/express.js +8 -64
- package/dist/src/hono.d.ts +2 -5
- package/dist/src/hono.d.ts.map +1 -1
- package/dist/src/hono.js +10 -61
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +17 -2
- package/dist/src/utils.d.ts +0 -17
- package/dist/src/utils.d.ts.map +0 -1
- package/dist/src/utils.js +0 -28
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faremeter/middleware",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"license": "LGPL-3.0-only",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
@@ -10,6 +10,21 @@
|
|
|
10
10
|
"require": "./dist/src/index.js",
|
|
11
11
|
"import": "./dist/src/index.js",
|
|
12
12
|
"types": "./dist/src/index.d.ts"
|
|
13
|
+
},
|
|
14
|
+
"./hono": {
|
|
15
|
+
"require": "./dist/src/hono.js",
|
|
16
|
+
"import": "./dist/src/hono.js",
|
|
17
|
+
"types": "./dist/src/hono.d.ts"
|
|
18
|
+
},
|
|
19
|
+
"./express": {
|
|
20
|
+
"require": "./dist/src/express.js",
|
|
21
|
+
"import": "./dist/src/express.js",
|
|
22
|
+
"types": "./dist/src/express.d.ts"
|
|
23
|
+
},
|
|
24
|
+
"./common": {
|
|
25
|
+
"require": "./dist/src/common.js",
|
|
26
|
+
"import": "./dist/src/common.js",
|
|
27
|
+
"types": "./dist/src/common.d.ts"
|
|
13
28
|
}
|
|
14
29
|
},
|
|
15
30
|
"files": [
|
|
@@ -33,7 +48,7 @@
|
|
|
33
48
|
"dependencies": {
|
|
34
49
|
"@logtape/logtape": "1.0.4",
|
|
35
50
|
"arktype": "2.1.21",
|
|
36
|
-
"@faremeter/types": "^0.
|
|
51
|
+
"@faremeter/types": "^0.6.0"
|
|
37
52
|
},
|
|
38
53
|
"tap": {
|
|
39
54
|
"plugin": [
|
package/dist/src/utils.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { x402PaymentRequirements, x402PaymentPayload } from "@faremeter/types";
|
|
2
|
-
export declare function findMatchingPaymentRequirements(accepts: x402PaymentRequirements[], payload: x402PaymentPayload): {
|
|
3
|
-
scheme: string;
|
|
4
|
-
network: string;
|
|
5
|
-
maxAmountRequired: string;
|
|
6
|
-
resource: string;
|
|
7
|
-
description: string;
|
|
8
|
-
mimeType: string;
|
|
9
|
-
payTo: string;
|
|
10
|
-
maxTimeoutSeconds: number;
|
|
11
|
-
asset: string;
|
|
12
|
-
outputSchema?: object;
|
|
13
|
-
extra?: object;
|
|
14
|
-
} | undefined;
|
|
15
|
-
export declare function gateGetPaymentRequiredResponse(res: Response): void;
|
|
16
|
-
export type RelaxedRequirements = Partial<x402PaymentRequirements>;
|
|
17
|
-
//# sourceMappingURL=utils.d.ts.map
|
package/dist/src/utils.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uBAAuB,EACvB,kBAAkB,EACnB,MAAM,kBAAkB,CAAC;AAI1B,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,uBAAuB,EAAE,EAClC,OAAO,EAAE,kBAAkB;;;;;;;;;;;;cA6B5B;AAED,wBAAgB,8BAA8B,CAAC,GAAG,EAAE,QAAQ,QAS3D;AAED,MAAM,MAAM,mBAAmB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC"}
|
package/dist/src/utils.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { logger } from "./logger.js";
|
|
2
|
-
export function findMatchingPaymentRequirements(accepts, payload) {
|
|
3
|
-
let possible;
|
|
4
|
-
if (payload.asset !== undefined) {
|
|
5
|
-
// Narrow based on the asset if available.
|
|
6
|
-
possible = accepts.filter((x) => x.network === payload.network &&
|
|
7
|
-
x.scheme === payload.scheme &&
|
|
8
|
-
x.asset === payload.asset);
|
|
9
|
-
}
|
|
10
|
-
else {
|
|
11
|
-
// Otherwise fall back to the behavior in coinbase/x402.
|
|
12
|
-
possible = accepts.filter((x) => x.network === payload.network && x.scheme === payload.scheme);
|
|
13
|
-
}
|
|
14
|
-
if (possible.length > 1) {
|
|
15
|
-
logger.warning(`found ${possible.length} ambiguous matching requirements for client payment: {*}`, payload);
|
|
16
|
-
}
|
|
17
|
-
// XXX - If there are more than one, this really should be an error.
|
|
18
|
-
// For now, err on the side of potential compatibility.
|
|
19
|
-
return possible[0];
|
|
20
|
-
}
|
|
21
|
-
export function gateGetPaymentRequiredResponse(res) {
|
|
22
|
-
if (res.status === 200) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
const msg = `received a non success response to requirements request from facilitator: ${res.statusText} (${res.status})`;
|
|
26
|
-
logger.error(msg);
|
|
27
|
-
throw new Error(msg);
|
|
28
|
-
}
|