@armory-sh/middleware-hono 0.3.7 → 0.3.8
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/index.js +3 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -269,13 +269,12 @@ var acceptPaymentsViaArmory = (config) => {
|
|
|
269
269
|
}
|
|
270
270
|
const primaryConfig = getPrimaryConfig(resolved);
|
|
271
271
|
const defaultVersion = config.defaultVersion ?? 2;
|
|
272
|
-
const
|
|
273
|
-
const requirementsV2 = createPaymentRequirements(primaryConfig, 2);
|
|
272
|
+
const createRequirements = (version) => createPaymentRequirements(primaryConfig, version);
|
|
274
273
|
return async (c, next) => {
|
|
275
274
|
const paymentHeader = c.req.header("X-Payment") || c.req.header("x402-payment");
|
|
276
275
|
if (!paymentHeader) {
|
|
277
|
-
const requirements = defaultVersion === 1 ? requirementsV1 : requirementsV2;
|
|
278
276
|
const version = defaultVersion === 1 ? 1 : 2;
|
|
277
|
+
const requirements = createRequirements(version);
|
|
279
278
|
const headers = getHeadersForVersion(version);
|
|
280
279
|
c.status(402);
|
|
281
280
|
c.header(headers.required, encodeRequirements(requirements));
|
|
@@ -287,7 +286,7 @@ var acceptPaymentsViaArmory = (config) => {
|
|
|
287
286
|
if (primaryConfig.facilitator) {
|
|
288
287
|
const verifyResult = await verifyWithFacilitator(toHttpRequest(c), primaryConfig.facilitator);
|
|
289
288
|
if (!verifyResult.success) {
|
|
290
|
-
const requirements = version
|
|
289
|
+
const requirements = createRequirements(version);
|
|
291
290
|
const headers2 = getHeadersForVersion(version);
|
|
292
291
|
c.status(402);
|
|
293
292
|
c.header(headers2.required, encodeRequirements(requirements));
|