@suveren/gateway 0.40.0 → 0.41.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/control-plane/index.mjs +182 -37
- package/dist/mcp-server/http.mjs +355 -71
- package/dist/ui/assets/{index-C-lA_7Lt.js → index-CO-dj98E.js} +27 -27
- package/dist/ui/index.html +1 -1
- package/node_modules/@hap/core/README.md +3 -3
- package/node_modules/@hap/core/dist/index.d.mts +567 -123
- package/node_modules/@hap/core/dist/index.d.ts +567 -123
- package/node_modules/@hap/core/dist/index.js +869 -23
- package/node_modules/@hap/core/dist/index.mjs +829 -22
- package/node_modules/@hap/core/node_modules/@hpke/core/LICENSE +21 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/README.md +263 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/mod.d.ts +11 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/mod.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/mod.js +6 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/package.json +3 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/aeads/aesGcm.d.ts +80 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/aeads/aesGcm.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/aeads/aesGcm.js +167 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/aeads/exportOnly.d.ts +34 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/aeads/exportOnly.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/aeads/exportOnly.js +56 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/cipherSuiteNative.d.ts +145 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/cipherSuiteNative.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/cipherSuiteNative.js +326 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/encryptionContext.d.ts +15 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/encryptionContext.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/encryptionContext.js +68 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/exporterContext.d.ts +19 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/exporterContext.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/exporterContext.js +62 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/aeadParams.d.ts +17 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/aeadParams.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/aeadParams.js +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/cipherSuiteParams.d.ts +13 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/cipherSuiteParams.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/cipherSuiteParams.js +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/encapsulator.d.ts +8 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/encapsulator.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/encapsulator.js +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/encryptionContext.d.ts +40 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/encryptionContext.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/encryptionContext.js +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/exporter.d.ts +17 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/exporter.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/exporter.js +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/keyInfo.d.ts +7 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/keyInfo.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/keyInfo.js +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/responses.d.ts +10 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/responses.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/responses.js +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemNative.d.ts +26 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemNative.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemNative.js +112 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x25519.d.ts +24 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x25519.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x25519.js +214 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x448.d.ts +24 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x448.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x448.js +214 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemX25519.d.ts +38 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemX25519.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemX25519.js +66 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemX448.d.ts +38 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemX448.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemX448.js +66 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/mutex.d.ts +5 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/mutex.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/mutex.js +28 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/native.d.ts +236 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/native.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/native.js +235 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/recipientContext.d.ts +6 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/recipientContext.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/recipientContext.js +38 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/senderContext.d.ts +11 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/senderContext.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/senderContext.js +45 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/utils/emitNotSupported.d.ts +2 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/utils/emitNotSupported.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/utils/emitNotSupported.js +6 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/package.json +46 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/mod.d.ts +11 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/mod.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/mod.js +47 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/package.json +3 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/aeads/aesGcm.d.ts +80 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/aeads/aesGcm.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/aeads/aesGcm.js +183 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/aeads/exportOnly.d.ts +34 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/aeads/exportOnly.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/aeads/exportOnly.js +70 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/cipherSuiteNative.d.ts +145 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/cipherSuiteNative.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/cipherSuiteNative.js +340 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/encryptionContext.d.ts +15 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/encryptionContext.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/encryptionContext.js +82 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/exporterContext.d.ts +19 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/exporterContext.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/exporterContext.js +78 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/aeadParams.d.ts +17 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/aeadParams.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/aeadParams.js +12 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/cipherSuiteParams.d.ts +13 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/cipherSuiteParams.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/cipherSuiteParams.js +12 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/encapsulator.d.ts +8 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/encapsulator.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/encapsulator.js +12 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/encryptionContext.d.ts +40 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/encryptionContext.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/encryptionContext.js +12 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/exporter.d.ts +17 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/exporter.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/exporter.js +12 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/keyInfo.d.ts +7 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/keyInfo.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/keyInfo.js +12 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/responses.d.ts +10 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/responses.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/responses.js +12 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemNative.d.ts +26 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemNative.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemNative.js +128 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x25519.d.ts +24 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x25519.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x25519.js +228 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x448.d.ts +24 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x448.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x448.js +228 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemX25519.d.ts +38 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemX25519.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemX25519.js +80 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemX448.d.ts +38 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemX448.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemX448.js +80 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/mutex.d.ts +5 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/mutex.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/mutex.js +42 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/native.d.ts +236 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/native.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/native.js +255 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/recipientContext.d.ts +6 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/recipientContext.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/recipientContext.js +52 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/senderContext.d.ts +11 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/senderContext.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/senderContext.js +59 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/utils/emitNotSupported.d.ts +2 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/utils/emitNotSupported.d.ts.map +1 -0
- package/node_modules/@hap/core/node_modules/@hpke/core/script/src/utils/emitNotSupported.js +19 -0
- package/node_modules/@hap/core/package.json +2 -1
- package/node_modules/@hap/core/src/canonicalize.ts +9 -0
- package/node_modules/@hap/core/src/commitment-modes.ts +21 -9
- package/node_modules/@hap/core/src/errors.ts +24 -8
- package/node_modules/@hap/core/src/gatekeeper.ts +52 -8
- package/node_modules/@hap/core/src/index.ts +5 -1
- package/node_modules/@hap/core/src/issuance.ts +250 -0
- package/node_modules/@hap/core/src/mandate.ts +52 -14
- package/node_modules/@hap/core/src/owner-signature.ts +86 -39
- package/node_modules/@hap/core/src/profile.ts +45 -0
- package/node_modules/@hap/core/src/proposal-content.ts +219 -0
- package/node_modules/@hap/core/src/ticket-projection.ts +167 -0
- package/node_modules/@hap/core/src/ticket.ts +254 -20
- package/node_modules/@hap/core/src/types.ts +33 -5
- package/node_modules/@hap/core/src/verifier-policy.ts +178 -0
- package/node_modules/@hap/core/src/versions.ts +50 -19
- package/node_modules/@hono/node-server/dist/index.cjs +31 -6
- package/node_modules/@hono/node-server/dist/index.mjs +31 -6
- package/node_modules/@hono/node-server/package.json +1 -1
- package/node_modules/@hpke/common/esm/package.json +5 -1
- package/node_modules/@hpke/common/esm/src/curve/montgomery.d.ts +2 -2
- package/node_modules/@hpke/common/esm/src/curve/montgomery.d.ts.map +1 -1
- package/node_modules/@hpke/common/esm/src/curve/montgomery.js +41 -26
- package/node_modules/@hpke/common/esm/src/hash/sha3.d.ts.map +1 -1
- package/node_modules/@hpke/common/esm/src/hash/sha3.js +0 -15
- package/node_modules/@hpke/common/esm/src/kdfs/hkdf.d.ts +2 -1
- package/node_modules/@hpke/common/esm/src/kdfs/hkdf.d.ts.map +1 -1
- package/node_modules/@hpke/common/esm/src/kdfs/hkdf.js +12 -2
- package/node_modules/@hpke/common/esm/src/kems/dhkemPrimitives/xCurve.d.ts.map +1 -1
- package/node_modules/@hpke/common/esm/src/kems/dhkemPrimitives/xCurve.js +14 -3
- package/node_modules/@hpke/common/esm/src/utils/misc.d.ts +6 -0
- package/node_modules/@hpke/common/esm/src/utils/misc.d.ts.map +1 -1
- package/node_modules/@hpke/common/esm/src/utils/misc.js +43 -10
- package/node_modules/@hpke/common/esm/src/utils/noble.d.ts +1 -1
- package/node_modules/@hpke/common/esm/src/utils/noble.d.ts.map +1 -1
- package/node_modules/@hpke/common/esm/src/utils/noble.js +21 -10
- package/node_modules/@hpke/common/package.json +5 -1
- package/node_modules/@hpke/common/script/src/curve/montgomery.d.ts +2 -2
- package/node_modules/@hpke/common/script/src/curve/montgomery.d.ts.map +1 -1
- package/node_modules/@hpke/common/script/src/curve/montgomery.js +40 -25
- package/node_modules/@hpke/common/script/src/hash/sha3.d.ts.map +1 -1
- package/node_modules/@hpke/common/script/src/hash/sha3.js +0 -15
- package/node_modules/@hpke/common/script/src/kdfs/hkdf.d.ts +2 -1
- package/node_modules/@hpke/common/script/src/kdfs/hkdf.d.ts.map +1 -1
- package/node_modules/@hpke/common/script/src/kdfs/hkdf.js +12 -2
- package/node_modules/@hpke/common/script/src/kems/dhkemPrimitives/xCurve.d.ts.map +1 -1
- package/node_modules/@hpke/common/script/src/kems/dhkemPrimitives/xCurve.js +13 -2
- package/node_modules/@hpke/common/script/src/utils/misc.d.ts +6 -0
- package/node_modules/@hpke/common/script/src/utils/misc.d.ts.map +1 -1
- package/node_modules/@hpke/common/script/src/utils/misc.js +43 -9
- package/node_modules/@hpke/common/script/src/utils/noble.d.ts +1 -1
- package/node_modules/@hpke/common/script/src/utils/noble.d.ts.map +1 -1
- package/node_modules/@hpke/common/script/src/utils/noble.js +22 -11
- package/node_modules/@hpke/core/README.md +56 -56
- package/node_modules/@hpke/core/esm/package.json +2 -1
- package/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x25519.d.ts +3 -21
- package/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x25519.d.ts.map +1 -1
- package/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x25519.js +3 -201
- package/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x448.d.ts +3 -21
- package/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x448.d.ts.map +1 -1
- package/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x448.js +3 -201
- package/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/xCurveNative.d.ts +26 -0
- package/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/xCurveNative.d.ts.map +1 -0
- package/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/xCurveNative.js +216 -0
- package/node_modules/@hpke/core/package.json +6 -2
- package/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x25519.d.ts +3 -21
- package/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x25519.d.ts.map +1 -1
- package/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x25519.js +4 -202
- package/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x448.d.ts +3 -21
- package/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x448.d.ts.map +1 -1
- package/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x448.js +4 -202
- package/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/xCurveNative.d.ts +26 -0
- package/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/xCurveNative.d.ts.map +1 -0
- package/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/xCurveNative.js +230 -0
- package/node_modules/@types/node/README.md +1 -1
- package/node_modules/@types/node/package.json +2 -2
- package/node_modules/@types/node/zlib.d.ts +752 -0
- package/node_modules/encodeurl/README.md +14 -0
- package/node_modules/encodeurl/index.js +5 -10
- package/node_modules/encodeurl/package.json +10 -6
- package/node_modules/express-rate-limit/dist/index.cjs +7 -3
- package/node_modules/express-rate-limit/dist/index.mjs +7 -3
- package/node_modules/express-rate-limit/package.json +10 -10
- package/node_modules/hono/dist/cjs/adapter/bun/serve-static.js +1 -1
- package/node_modules/hono/dist/cjs/adapter/bun/websocket.js +1 -1
- package/node_modules/hono/dist/cjs/context.js +1 -1
- package/node_modules/hono/dist/cjs/helper/css/common.js +3 -5
- package/node_modules/hono/dist/cjs/hono-base.js +4 -10
- package/node_modules/hono/dist/cjs/hono.js +0 -1
- package/node_modules/hono/dist/cjs/middleware/basic-auth/index.js +1 -1
- package/node_modules/hono/dist/cjs/middleware/bearer-auth/index.js +1 -1
- package/node_modules/hono/dist/cjs/middleware/csrf/index.js +2 -2
- package/node_modules/hono/dist/cjs/middleware/jwk/jwk.js +2 -2
- package/node_modules/hono/dist/cjs/middleware/jwt/jwt.js +2 -2
- package/node_modules/hono/dist/cjs/middleware/mount/index.js +4 -4
- package/node_modules/hono/dist/cjs/router/reg-exp-router/node.js +13 -11
- package/node_modules/hono/dist/cjs/router/reg-exp-router/prepared-router.js +4 -4
- package/node_modules/hono/dist/cjs/router/reg-exp-router/router.js +39 -51
- package/node_modules/hono/dist/cjs/router/reg-exp-router/trie.js +15 -5
- package/node_modules/hono/dist/cjs/utils/jwt/jwt.js +2 -1
- package/node_modules/hono/dist/cjs/utils/mount.js +35 -0
- package/node_modules/hono/dist/cjs/utils/url.js +10 -0
- package/node_modules/hono/dist/cjs/validator/validator.js +1 -1
- package/node_modules/hono/dist/context.js +1 -1
- package/node_modules/hono/dist/helper/css/common.js +3 -5
- package/node_modules/hono/dist/hono-base.js +4 -10
- package/node_modules/hono/dist/hono.js +0 -1
- package/node_modules/hono/dist/middleware/basic-auth/index.js +1 -1
- package/node_modules/hono/dist/middleware/bearer-auth/index.js +1 -1
- package/node_modules/hono/dist/middleware/csrf/index.js +2 -2
- package/node_modules/hono/dist/middleware/jwk/jwk.js +2 -2
- package/node_modules/hono/dist/middleware/jwt/jwt.js +2 -2
- package/node_modules/hono/dist/middleware/language/language.js +1 -1
- package/node_modules/hono/dist/middleware/mount/index.js +4 -4
- package/node_modules/hono/dist/router/reg-exp-router/node.js +13 -11
- package/node_modules/hono/dist/router/reg-exp-router/prepared-router.js +5 -5
- package/node_modules/hono/dist/router/reg-exp-router/router.js +40 -52
- package/node_modules/hono/dist/router/reg-exp-router/trie.js +15 -5
- package/node_modules/hono/dist/types/middleware/mount/index.d.ts +1 -0
- package/node_modules/hono/dist/types/router/reg-exp-router/node.d.ts +3 -3
- package/node_modules/hono/dist/types/router/reg-exp-router/trie.d.ts +1 -1
- package/node_modules/hono/dist/types/utils/mount.d.ts +4 -0
- package/node_modules/hono/dist/types/utils/url.d.ts +1 -0
- package/node_modules/hono/dist/utils/jwt/jwt.js +2 -1
- package/node_modules/hono/dist/utils/mount.js +34 -0
- package/node_modules/hono/dist/utils/url.js +10 -1
- package/node_modules/hono/dist/validator/validator.js +1 -1
- package/node_modules/hono/package.json +1 -1
- package/node_modules/ip-address/README.md +39 -39
- package/node_modules/ip-address/dist/ipv6.js +1 -1
- package/node_modules/ip-address/dist/ipv6.js.map +1 -1
- package/node_modules/ip-address/package.json +1 -1
- package/node_modules/jose/dist/types/jwt/decrypt.d.ts +3 -0
- package/node_modules/jose/dist/types/jwt/unsecured.d.ts +2 -0
- package/node_modules/jose/dist/types/jwt/verify.d.ts +3 -0
- package/node_modules/jose/dist/types/types.d.ts +8 -0
- package/node_modules/jose/dist/types/util/decode_jwt.d.ts +1 -0
- package/node_modules/jose/dist/webapi/jwks/remote.js +3 -1
- package/node_modules/jose/dist/webapi/lib/deflate.js +2 -1
- package/node_modules/jose/dist/webapi/lib/jwt_claims_set.js +2 -1
- package/node_modules/jose/package.json +1 -1
- package/node_modules/qs/CHANGELOG.md +29 -22
- package/node_modules/qs/dist/qs.js +14 -14
- package/node_modules/qs/eslint.config.mjs +6 -0
- package/node_modules/qs/lib/stringify.js +1 -1
- package/node_modules/qs/package.json +5 -5
- package/node_modules/qs/test/stringify.js +74 -0
- package/package.json +2 -2
|
@@ -8,8 +8,14 @@ var Trie = class {
|
|
|
8
8
|
#index = 0;
|
|
9
9
|
paths = require_router_utils.createNullObject();
|
|
10
10
|
insert(path, isStatic) {
|
|
11
|
+
const keys = [];
|
|
11
12
|
if (isStatic) {
|
|
12
|
-
this.#root.insert(path.split(""),
|
|
13
|
+
this.#root.insert(path.split(""), -1, [], this.#context, keys);
|
|
14
|
+
this.paths[path] = [
|
|
15
|
+
-1,
|
|
16
|
+
[],
|
|
17
|
+
keys
|
|
18
|
+
];
|
|
13
19
|
return;
|
|
14
20
|
}
|
|
15
21
|
const paramAssoc = [];
|
|
@@ -17,7 +23,7 @@ var Trie = class {
|
|
|
17
23
|
let markedPath = path;
|
|
18
24
|
for (let i = 0;;) {
|
|
19
25
|
let replaced = false;
|
|
20
|
-
markedPath = markedPath.replace(/\{[^}]+\}/g, (m) => {
|
|
26
|
+
markedPath = markedPath.replace(/\{(?:\{[\d,]+\}|[^}])+\}/g, (m) => {
|
|
21
27
|
const mark = `@\\${i}`;
|
|
22
28
|
groups[i] = [mark, m];
|
|
23
29
|
i++;
|
|
@@ -31,7 +37,7 @@ var Trie = class {
|
|
|
31
37
|
* - /* wildcard
|
|
32
38
|
* - character
|
|
33
39
|
*/
|
|
34
|
-
const tokens = markedPath.match(/(?::[^\/]+)|(?:\/\*$)|./
|
|
40
|
+
const tokens = markedPath.match(/(?::[^\/]+)|(?:\/\*$)|./gs) || [];
|
|
35
41
|
for (let i = groups.length - 1; i >= 0; i--) {
|
|
36
42
|
const [mark] = groups[i];
|
|
37
43
|
for (let j = tokens.length - 1; j >= 0; j--) if (tokens[j].indexOf(mark) !== -1) {
|
|
@@ -39,8 +45,12 @@ var Trie = class {
|
|
|
39
45
|
break;
|
|
40
46
|
}
|
|
41
47
|
}
|
|
42
|
-
this.#root.insert(tokens, this.#index, paramAssoc, this.#context,
|
|
43
|
-
this.paths[path] = [
|
|
48
|
+
this.#root.insert(tokens, this.#index, paramAssoc, this.#context, keys);
|
|
49
|
+
this.paths[path] = [
|
|
50
|
+
this.#index++,
|
|
51
|
+
paramAssoc,
|
|
52
|
+
keys
|
|
53
|
+
];
|
|
44
54
|
}
|
|
45
55
|
buildRegExp() {
|
|
46
56
|
let regexp = this.#root.buildRegExpStr();
|
|
@@ -16,7 +16,7 @@ const decodeJwtPart = (part) => JSON.parse(require_utils_jwt_utf8.utf8Decoder.de
|
|
|
16
16
|
function isTokenHeader(obj) {
|
|
17
17
|
if (typeof obj === "object" && obj !== null) {
|
|
18
18
|
const objWithAlg = obj;
|
|
19
|
-
return "alg" in objWithAlg && Object.values(require_utils_jwt_jwa.AlgorithmTypes).includes(objWithAlg.alg) && (!("typ" in objWithAlg) || objWithAlg.typ === "JWT");
|
|
19
|
+
return "alg" in objWithAlg && Object.values(require_utils_jwt_jwa.AlgorithmTypes).includes(objWithAlg.alg) && (!("typ" in objWithAlg) || objWithAlg.typ === "JWT") && !("crit" in objWithAlg);
|
|
20
20
|
}
|
|
21
21
|
return false;
|
|
22
22
|
}
|
|
@@ -67,6 +67,7 @@ const verify = async (token, publicKey, algOrOptions) => {
|
|
|
67
67
|
if (!(Array.isArray(payload.aud) ? payload.aud : [payload.aud]).some((payloadAud) => aud instanceof RegExp ? aud.test(payloadAud) : typeof aud === "string" ? payloadAud === aud : Array.isArray(aud) && aud.includes(payloadAud))) throw new require_utils_jwt_types.JwtTokenAudience(aud, payload.aud);
|
|
68
68
|
}
|
|
69
69
|
const headerPayload = token.substring(0, token.lastIndexOf("."));
|
|
70
|
+
if (!/^[A-Za-z0-9_-]*={0,2}$/.test(tokenParts[2])) throw new require_utils_jwt_types.JwtTokenInvalid(token);
|
|
70
71
|
let signature;
|
|
71
72
|
try {
|
|
72
73
|
signature = require_utils_encode.decodeBase64Url(tokenParts[2]);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_request_constants = require("../request/constants.js");
|
|
3
|
+
const require_utils_url = require("./url.js");
|
|
4
|
+
//#region src/utils/mount.ts
|
|
5
|
+
const getPathPrefixLength = (c, pathPrefix, routePath) => {
|
|
6
|
+
if (!/[:*]/.test(pathPrefix)) return pathPrefix.length;
|
|
7
|
+
const path = c.req.path;
|
|
8
|
+
const matchResult = c.req[require_request_constants.GET_MATCH_RESULT];
|
|
9
|
+
const paramNames = /* @__PURE__ */ new Set();
|
|
10
|
+
let length = 0;
|
|
11
|
+
for (const part of require_utils_url.splitRoutingPath(pathPrefix)) {
|
|
12
|
+
const pattern = require_utils_url.getPattern(part);
|
|
13
|
+
if (pattern && pattern !== "*") {
|
|
14
|
+
const name = pattern[1];
|
|
15
|
+
if (paramNames.has(name)) throw new Error(`mount(): Duplicate path parameter "${name}" in "${routePath}".`);
|
|
16
|
+
paramNames.add(name);
|
|
17
|
+
}
|
|
18
|
+
if (pattern && pattern !== "*" && pattern[2] !== true) {
|
|
19
|
+
const value = matchResult.length === 2 ? matchResult[1][matchResult[0][c.req.routeIndex][1][pattern[1]]] : matchResult[0][c.req.routeIndex][1][pattern[1]];
|
|
20
|
+
length += value.length + 1;
|
|
21
|
+
} else if (pattern || part.endsWith("*")) {
|
|
22
|
+
const end = path.indexOf("/", length + 1);
|
|
23
|
+
length = end === -1 ? path.length : end;
|
|
24
|
+
} else length += part.length + 1;
|
|
25
|
+
}
|
|
26
|
+
return length;
|
|
27
|
+
};
|
|
28
|
+
const createMountedRequest = (c, pathPrefix, routePath) => {
|
|
29
|
+
if (/[^/]\*$/.test(routePath)) throw new Error(`mount(): Wildcard must follow "/" in "${routePath}".`);
|
|
30
|
+
const url = new URL(c.req.raw.url);
|
|
31
|
+
url.pathname = require_utils_url.stripPathPrefix(url.pathname, c.req.path, getPathPrefixLength(c, pathPrefix, routePath));
|
|
32
|
+
return new Request(url, c.req.raw);
|
|
33
|
+
};
|
|
34
|
+
//#endregion
|
|
35
|
+
exports.createMountedRequest = createMountedRequest;
|
|
@@ -111,6 +111,15 @@ const getPathNoStrict = (request) => {
|
|
|
111
111
|
const result = getPath(request);
|
|
112
112
|
return result.length > 1 && result.at(-1) === "/" ? result.slice(0, -1) : result;
|
|
113
113
|
};
|
|
114
|
+
const stripPathPrefix = (rawPath, decodedPath, prefixLength) => {
|
|
115
|
+
if (rawPath.at(-1) === "/" && decodedPath.at(-1) !== "/") rawPath = rawPath.slice(0, -1);
|
|
116
|
+
let index = 0;
|
|
117
|
+
for (let i = decodedPath.indexOf("/"); i !== -1 && i < prefixLength; i = decodedPath.indexOf("/", i + 1)) {
|
|
118
|
+
index = rawPath.indexOf("/", index + 1);
|
|
119
|
+
if (index === -1) return "/";
|
|
120
|
+
}
|
|
121
|
+
return rawPath.slice(index) || "/";
|
|
122
|
+
};
|
|
114
123
|
/**
|
|
115
124
|
* Merge paths.
|
|
116
125
|
* @param {string[]} ...paths - The paths to merge.
|
|
@@ -215,6 +224,7 @@ exports.getQueryStrings = getQueryStrings;
|
|
|
215
224
|
exports.mergePath = mergePath;
|
|
216
225
|
exports.splitPath = splitPath;
|
|
217
226
|
exports.splitRoutingPath = splitRoutingPath;
|
|
227
|
+
exports.stripPathPrefix = stripPathPrefix;
|
|
218
228
|
exports.tryDecode = tryDecode;
|
|
219
229
|
exports.tryDecodeURI = tryDecodeURI;
|
|
220
230
|
exports.tryDecodeURIComponent = tryDecodeURIComponent;
|
|
@@ -4,7 +4,7 @@ const require_utils_buffer = require("../utils/buffer.js");
|
|
|
4
4
|
const require_helper_cookie_index = require("../helper/cookie/index.js");
|
|
5
5
|
//#region src/validator/validator.ts
|
|
6
6
|
const jsonRegex = /^application\/([a-z-\.]+\+)?json(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/i;
|
|
7
|
-
const multipartRegex = /^multipart\/form-data(;\s
|
|
7
|
+
const multipartRegex = /^multipart\/form-data(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/i;
|
|
8
8
|
const urlencodedRegex = /^application\/x-www-form-urlencoded(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/i;
|
|
9
9
|
const validator = (target, validationFunc) => {
|
|
10
10
|
return async (c, next) => {
|
|
@@ -197,7 +197,7 @@ var Context = class {
|
|
|
197
197
|
* ```
|
|
198
198
|
*/
|
|
199
199
|
header = (name, value, options) => {
|
|
200
|
-
if (this.finalized) this.#res = createResponseInstance(this.#res.body, this.#res);
|
|
200
|
+
if (this.finalized && !this.#res.bodyUsed) this.#res = createResponseInstance(this.#res.body, this.#res);
|
|
201
201
|
const headers = this.#res ? this.#res.headers : this.#preparedHeaders ??= new Headers();
|
|
202
202
|
if (value === void 0) headers.delete(name);
|
|
203
203
|
else if (options?.append) headers.append(name, value);
|
|
@@ -79,10 +79,8 @@ const buildStyleString = (strings, values) => {
|
|
|
79
79
|
for (let j = 0, len = vArray.length; j < len; j++) {
|
|
80
80
|
let value = vArray[j];
|
|
81
81
|
if (typeof value === "boolean" || value === null || value === void 0) continue;
|
|
82
|
-
if (typeof value === "string")
|
|
83
|
-
|
|
84
|
-
else styleString += value;
|
|
85
|
-
} else if (typeof value === "number") styleString += value;
|
|
82
|
+
if (typeof value === "string") styleString += value.replace(/[\\"']/g, "\\$&");
|
|
83
|
+
else if (typeof value === "number") styleString += value;
|
|
86
84
|
else if (value[CSS_ESCAPED]) styleString += value[CSS_ESCAPED];
|
|
87
85
|
else if (value[CLASS_NAME].startsWith("@keyframes ")) {
|
|
88
86
|
selectors.push(value);
|
|
@@ -107,7 +105,7 @@ const buildStyleString = (strings, values) => {
|
|
|
107
105
|
}
|
|
108
106
|
return [
|
|
109
107
|
label,
|
|
110
|
-
minify(styleString),
|
|
108
|
+
minify(styleString).replace(/<\//g, "<\\/"),
|
|
111
109
|
selectors,
|
|
112
110
|
externalClassNames
|
|
113
111
|
];
|
|
@@ -3,6 +3,7 @@ import { getPath, getPathNoStrict, mergePath } from "./utils/url.js";
|
|
|
3
3
|
import { Context } from "./context.js";
|
|
4
4
|
import { METHODS } from "./router.js";
|
|
5
5
|
import { COMPOSED_HANDLER } from "./utils/constants.js";
|
|
6
|
+
import { createMountedRequest } from "./utils/mount.js";
|
|
6
7
|
//#region src/hono-base.ts
|
|
7
8
|
/**
|
|
8
9
|
* @module
|
|
@@ -227,17 +228,10 @@ var Hono = class Hono {
|
|
|
227
228
|
} catch {}
|
|
228
229
|
return [c.env, executionContext];
|
|
229
230
|
};
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
const pathPrefixLength = mergedPath === "/" ? 0 : mergedPath.length;
|
|
233
|
-
return (request) => {
|
|
234
|
-
const url = new URL(request.url);
|
|
235
|
-
url.pathname = this.getPath(request).slice(pathPrefixLength) || "/";
|
|
236
|
-
return new Request(url, request);
|
|
237
|
-
};
|
|
238
|
-
})();
|
|
231
|
+
const mergedPath = mergePath(this._basePath, path);
|
|
232
|
+
const defaultReplaceRequest = (c) => createMountedRequest(c, mergedPath.replace(/\/$/, ""), mergePath(mergedPath, "*"));
|
|
239
233
|
const handler = async (c, next) => {
|
|
240
|
-
const res = await applicationHandler(replaceRequest(c.req.raw), ...getOptions(c));
|
|
234
|
+
const res = await applicationHandler(replaceRequest ? replaceRequest(c.req.raw) : defaultReplaceRequest(c), ...getOptions(c));
|
|
241
235
|
if (res) return res;
|
|
242
236
|
await next();
|
|
243
237
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { HonoBase as Hono$1 } from "./hono-base.js";
|
|
2
2
|
import { RegExpRouter } from "./router/reg-exp-router/router.js";
|
|
3
|
-
import "./router/reg-exp-router/index.js";
|
|
4
3
|
import { SmartRouter } from "./router/smart-router/router.js";
|
|
5
4
|
import { TrieRouter } from "./router/trie-router/router.js";
|
|
6
5
|
import "./router/trie-router/index.js";
|
|
@@ -80,7 +80,7 @@ const basicAuth = (options, ...users) => {
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
const status = 401;
|
|
83
|
-
const headers = { "WWW-Authenticate": "Basic realm=\"" + options.realm?.replace(/"/g, "
|
|
83
|
+
const headers = { "WWW-Authenticate": "Basic realm=\"" + options.realm?.replace(/[\\"]/g, "\\$&") + "\"" };
|
|
84
84
|
const responseMessage = typeof options.invalidUserMessage === "function" ? await options.invalidUserMessage(ctx) : options.invalidUserMessage;
|
|
85
85
|
const res = typeof responseMessage === "string" ? new Response(responseMessage, {
|
|
86
86
|
status,
|
|
@@ -44,7 +44,7 @@ const bearerAuth = (options) => {
|
|
|
44
44
|
if (!("token" in options || "verifyToken" in options)) throw new Error("bearer auth middleware requires options for \"token\" or \"verifyToken\"");
|
|
45
45
|
if (!options.realm) options.realm = "";
|
|
46
46
|
if (options.prefix === void 0) options.prefix = PREFIX;
|
|
47
|
-
const realm = options.realm?.replace(/"/g, "
|
|
47
|
+
const realm = options.realm?.replace(/[\\"]/g, "\\$&");
|
|
48
48
|
const prefix = options.prefix;
|
|
49
49
|
const tokenRegexp = new RegExp(`^${TOKEN_STRINGS}$`);
|
|
50
50
|
const wwwAuthenticatePrefix = prefix === "" ? "" : `${prefix} `;
|
|
@@ -8,7 +8,7 @@ const secFetchSiteValues = [
|
|
|
8
8
|
];
|
|
9
9
|
const isSecFetchSite = (value) => secFetchSiteValues.includes(value);
|
|
10
10
|
const isSafeMethodRe = /^(GET|HEAD|OPTIONS)$/;
|
|
11
|
-
const
|
|
11
|
+
const isCsrfContentTypeRe = /^\b(application\/x-www-form-urlencoded|multipart\/form-data|text\/(?:plain|ping))\b/i;
|
|
12
12
|
/**
|
|
13
13
|
* CSRF Protection Middleware for Hono.
|
|
14
14
|
*
|
|
@@ -94,7 +94,7 @@ const csrf = (options) => {
|
|
|
94
94
|
return await secFetchSiteHandler(secFetchSite, c);
|
|
95
95
|
};
|
|
96
96
|
return async function csrf(c, next) {
|
|
97
|
-
if (!isSafeMethodRe.test(c.req.method) &&
|
|
97
|
+
if (!isSafeMethodRe.test(c.req.method) && isCsrfContentTypeRe.test(c.req.header("content-type") || "text/plain") && !await isAllowedSecFetchSite(c.req.header("sec-fetch-site"), c) && !await isAllowedOrigin(c.req.header("origin"), c)) {
|
|
98
98
|
const res = new Response("Forbidden", { status: 403 });
|
|
99
99
|
throw new HTTPException(403, { res });
|
|
100
100
|
}
|
|
@@ -109,8 +109,8 @@ const jwk = (options, init) => {
|
|
|
109
109
|
};
|
|
110
110
|
};
|
|
111
111
|
function unauthorizedResponse(opts) {
|
|
112
|
-
const realm = (opts.realm ?? opts.ctx.req.url).replace(/"/g, "
|
|
113
|
-
const errDescription = opts.errDescription.replace(/"/g, "
|
|
112
|
+
const realm = (opts.realm ?? opts.ctx.req.url).replace(/[\\"]/g, "\\$&");
|
|
113
|
+
const errDescription = opts.errDescription.replace(/[\\"]/g, "\\$&");
|
|
114
114
|
return new Response("Unauthorized", {
|
|
115
115
|
status: 401,
|
|
116
116
|
statusText: opts.statusText,
|
|
@@ -103,8 +103,8 @@ const jwt = (options) => {
|
|
|
103
103
|
};
|
|
104
104
|
};
|
|
105
105
|
function unauthorizedResponse(opts) {
|
|
106
|
-
const realm = (opts.realm ?? opts.ctx.req.url).replace(/"/g, "
|
|
107
|
-
const errDescription = opts.errDescription.replace(/"/g, "
|
|
106
|
+
const realm = (opts.realm ?? opts.ctx.req.url).replace(/[\\"]/g, "\\$&");
|
|
107
|
+
const errDescription = opts.errDescription.replace(/[\\"]/g, "\\$&");
|
|
108
108
|
return new Response("Unauthorized", {
|
|
109
109
|
status: 401,
|
|
110
110
|
statusText: opts.statusText,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getCookie, setCookie } from "../../helper/cookie/index.js";
|
|
2
1
|
import { parseAccept } from "../../utils/accept.js";
|
|
2
|
+
import { getCookie, setCookie } from "../../helper/cookie/index.js";
|
|
3
3
|
//#region src/middleware/language/language.ts
|
|
4
4
|
const DEFAULT_OPTIONS = {
|
|
5
5
|
order: [
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
+
import { createMountedRequest } from "../../utils/mount.js";
|
|
1
2
|
import { routePath } from "../../helper/route/index.js";
|
|
2
3
|
//#region src/middleware/mount/index.ts
|
|
3
4
|
const defaultReplaceRequest = (c) => {
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
url.pathname = c.req.path.slice(pathPrefix.length) || "/";
|
|
7
|
-
return new Request(url, c.req.raw);
|
|
5
|
+
const path = routePath(c);
|
|
6
|
+
return createMountedRequest(c, path.replace(/\/?\*$/, ""), path);
|
|
8
7
|
};
|
|
9
8
|
const defaultGetOptions = (c) => {
|
|
10
9
|
let executionContext = void 0;
|
|
@@ -21,6 +20,7 @@ const defaultGetOptions = (c) => {
|
|
|
21
20
|
* @param {Function} applicationHandler - other Request Handler
|
|
22
21
|
* @param {MountOptions} [options] - options of `mount()`
|
|
23
22
|
* @returns {MiddlewareHandler} handler to register with `app.all()`
|
|
23
|
+
* @throws {Error} If the route ends with a wildcard inside a segment (e.g. `/assets*`), or automatic request rewriting encounters duplicate path parameter names.
|
|
24
24
|
*
|
|
25
25
|
* @example
|
|
26
26
|
* ```ts
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createNullObject } from "../utils.js";
|
|
2
2
|
//#region src/router/reg-exp-router/node.ts
|
|
3
3
|
const LABEL_REG_EXP_STR = "[^/]+";
|
|
4
|
-
const ONLY_WILDCARD_REG_EXP_STR = "
|
|
5
|
-
const TAIL_WILDCARD_REG_EXP_STR = "(
|
|
4
|
+
const ONLY_WILDCARD_REG_EXP_STR = "[^]*";
|
|
5
|
+
const TAIL_WILDCARD_REG_EXP_STR = "(?:|/[^]*)";
|
|
6
6
|
const PATH_ERROR = Symbol();
|
|
7
7
|
const regExpMetaChars = /* @__PURE__ */ new Set(".\\+*[^]$()");
|
|
8
8
|
/**
|
|
@@ -15,8 +15,8 @@ const regExpMetaChars = /* @__PURE__ */ new Set(".\\+*[^]$()");
|
|
|
15
15
|
function compareKey(a, b) {
|
|
16
16
|
if (a.length === 1) return b.length === 1 ? a < b ? -1 : 1 : -1;
|
|
17
17
|
if (b.length === 1) return 1;
|
|
18
|
-
if (a === "
|
|
19
|
-
else if (b === "
|
|
18
|
+
if (a === "[^]*" || a === "(?:|/[^]*)") return b === "[^]*" ? -1 : 1;
|
|
19
|
+
else if (b === "[^]*" || b === "(?:|/[^]*)") return -1;
|
|
20
20
|
if (a === "[^/]+") return 1;
|
|
21
21
|
else if (b === "[^/]+") return -1;
|
|
22
22
|
return a.length === b.length ? a < b ? -1 : 1 : b.length - a.length;
|
|
@@ -25,14 +25,14 @@ var Node = class Node {
|
|
|
25
25
|
#index;
|
|
26
26
|
#varIndex;
|
|
27
27
|
#children = createNullObject();
|
|
28
|
-
insert(tokens, index, paramMap, context,
|
|
28
|
+
insert(tokens, index, paramMap, context, keys) {
|
|
29
29
|
let node = this;
|
|
30
30
|
for (let i = 0, len = tokens.length; i < len; i++) {
|
|
31
31
|
const token = tokens[i];
|
|
32
32
|
const pattern = token.length === 1 ? token === "*" ? i === len - 1 ? [
|
|
33
33
|
"",
|
|
34
34
|
"",
|
|
35
|
-
|
|
35
|
+
ONLY_WILDCARD_REG_EXP_STR
|
|
36
36
|
] : [
|
|
37
37
|
"",
|
|
38
38
|
"",
|
|
@@ -47,15 +47,16 @@ var Node = class Node {
|
|
|
47
47
|
const name = pattern[1];
|
|
48
48
|
let regexpStr = pattern[2] || "[^/]+";
|
|
49
49
|
if (name && pattern[2]) {
|
|
50
|
-
if (regexpStr
|
|
50
|
+
if (new RegExp(regexpStr).test("")) throw PATH_ERROR;
|
|
51
51
|
regexpStr = regexpStr.replace(/^\((?!\?:)(?=[^)]+\)$)/, "(?:");
|
|
52
52
|
if (/\((?!\?:)/.test(regexpStr)) throw PATH_ERROR;
|
|
53
53
|
if (regexpStr.length === 1 && regExpMetaChars.has(regexpStr)) throw PATH_ERROR;
|
|
54
54
|
}
|
|
55
|
+
keys.push(regexpStr);
|
|
55
56
|
nextNode = node.#children[regexpStr];
|
|
56
57
|
if (!nextNode) {
|
|
57
|
-
if (regexpStr !== "
|
|
58
|
-
for (const k in node.#children) if ((regexpStr.length > 1 || k.length > 1) && k !== "
|
|
58
|
+
if (regexpStr !== "[^]*" && regexpStr !== "(?:|/[^]*)") {
|
|
59
|
+
for (const k in node.#children) if ((regexpStr.length > 1 || k.length > 1) && k !== "[^]*" && k !== "(?:|/[^]*)") throw PATH_ERROR;
|
|
59
60
|
}
|
|
60
61
|
nextNode = node.#children[regexpStr] = new Node();
|
|
61
62
|
}
|
|
@@ -64,16 +65,17 @@ var Node = class Node {
|
|
|
64
65
|
paramMap.push([name, nextNode.#varIndex]);
|
|
65
66
|
}
|
|
66
67
|
} else {
|
|
68
|
+
keys.push(token);
|
|
67
69
|
nextNode = node.#children[token];
|
|
68
70
|
if (!nextNode) {
|
|
69
|
-
for (const k in node.#children) if (k.length > 1 && k !== "
|
|
71
|
+
for (const k in node.#children) if (k.length > 1 && k !== "[^]*" && k !== "(?:|/[^]*)") throw PATH_ERROR;
|
|
70
72
|
nextNode = node.#children[token] = new Node();
|
|
71
73
|
}
|
|
72
74
|
}
|
|
73
75
|
node = nextNode;
|
|
74
76
|
}
|
|
75
77
|
if (node.#index !== void 0) throw PATH_ERROR;
|
|
76
|
-
node.#index =
|
|
78
|
+
node.#index = index;
|
|
77
79
|
}
|
|
78
80
|
buildRegExpStr() {
|
|
79
81
|
const strList = Object.keys(this.#children).sort(compareKey).map((k) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "../../router.js";
|
|
2
|
-
import {
|
|
2
|
+
import { match } from "./matcher.js";
|
|
3
3
|
import { RegExpRouter } from "./router.js";
|
|
4
4
|
//#region src/router/reg-exp-router/prepared-router.ts
|
|
5
5
|
var PreparedRegExpRouter = class {
|
|
@@ -27,7 +27,7 @@ var PreparedRegExpRouter = class {
|
|
|
27
27
|
if (!this.#matchers[method]) {
|
|
28
28
|
const all = this.#matchers["ALL"];
|
|
29
29
|
const staticMap = {};
|
|
30
|
-
for (const key in all[2]) staticMap[key] = [all[2][key][0].slice(),
|
|
30
|
+
for (const key in all[2]) staticMap[key] = [all[2][key][0].slice(), all[2][key][1]];
|
|
31
31
|
this.#matchers[method] = [
|
|
32
32
|
all[0],
|
|
33
33
|
all[1].map((list) => Array.isArray(list) ? list.slice() : 0),
|
|
@@ -71,7 +71,7 @@ const buildInitParams = ({ paths }) => {
|
|
|
71
71
|
...map
|
|
72
72
|
};
|
|
73
73
|
else relocateMap[path] = [[[], map]];
|
|
74
|
-
if (relocateMap[path][0][0].
|
|
74
|
+
if (!relocateMap[path][0][0].includes(i)) relocateMap[path][0][0].push(i);
|
|
75
75
|
}
|
|
76
76
|
});
|
|
77
77
|
});
|
|
@@ -79,7 +79,7 @@ const buildInitParams = ({ paths }) => {
|
|
|
79
79
|
if (p === path) {
|
|
80
80
|
relocateMap[path] ||= [[[]]];
|
|
81
81
|
const value = path2 === path ? "" : path2;
|
|
82
|
-
if (relocateMap[path][0][0].
|
|
82
|
+
if (!relocateMap[path][0][0].includes(value)) relocateMap[path][0][0].push(value);
|
|
83
83
|
}
|
|
84
84
|
});
|
|
85
85
|
}
|
|
@@ -88,7 +88,7 @@ const buildInitParams = ({ paths }) => {
|
|
|
88
88
|
return [matchers, relocateMap];
|
|
89
89
|
};
|
|
90
90
|
const serializeInitParams = ([matchers, relocateMap]) => {
|
|
91
|
-
return `[${JSON.stringify(matchers, (_, value) => value instanceof RegExp ? `##${value
|
|
91
|
+
return `[${JSON.stringify(matchers, (_, value) => value instanceof RegExp || value === void 0 ? `##${value}##` : value).replace(/"##(.+?)##"/g, (_, str) => str.replace(/\\\\/g, "\\"))},${JSON.stringify(relocateMap)}]`;
|
|
92
92
|
};
|
|
93
93
|
//#endregion
|
|
94
94
|
export { PreparedRegExpRouter, buildInitParams, serializeInitParams };
|
|
@@ -2,24 +2,24 @@ import { checkOptionalParameter } from "../../utils/url.js";
|
|
|
2
2
|
import { MESSAGE_MATCHER_IS_ALREADY_BUILT, UnsupportedPathError } from "../../router.js";
|
|
3
3
|
import { createNullObject } from "../utils.js";
|
|
4
4
|
import { emptyParam, match } from "./matcher.js";
|
|
5
|
-
import {
|
|
5
|
+
import { PATH_ERROR } from "./node.js";
|
|
6
6
|
import { Trie } from "./trie.js";
|
|
7
7
|
//#region src/router/reg-exp-router/router.ts
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return
|
|
8
|
+
function endsWithWildcard(keys) {
|
|
9
|
+
const tail = keys[keys.length - 1];
|
|
10
|
+
return tail === "[^]*" || tail === "(?:|/[^]*)";
|
|
11
11
|
}
|
|
12
|
-
function
|
|
13
|
-
|
|
12
|
+
function covers(wildcard, target) {
|
|
13
|
+
const last = wildcard.length - 1;
|
|
14
|
+
for (let i = 0; i < last; i++) if (wildcard[i] !== target[i]) return false;
|
|
15
|
+
return wildcard[last] === "[^]*" || target.length === last || target[last] === "/";
|
|
14
16
|
}
|
|
15
17
|
var RegExpRouter = class {
|
|
16
18
|
name = "RegExpRouter";
|
|
17
|
-
#
|
|
18
|
-
#routes;
|
|
19
|
+
#handlers;
|
|
19
20
|
#tries;
|
|
20
21
|
constructor() {
|
|
21
|
-
this.#
|
|
22
|
-
this.#routes = { ["ALL"]: createNullObject() };
|
|
22
|
+
this.#handlers = { ["ALL"]: [] };
|
|
23
23
|
this.#tries = { ["ALL"]: new Trie() };
|
|
24
24
|
}
|
|
25
25
|
#insertPath(method, path) {
|
|
@@ -30,65 +30,53 @@ var RegExpRouter = class {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
add(method, path, handler) {
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if (!
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
for (const p in handlerMap["ALL"]) {
|
|
41
|
-
handlerMap[method][p] = [...handlerMap["ALL"][p]];
|
|
42
|
-
this.#insertPath(method, p);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
33
|
+
const handlers = this.#handlers;
|
|
34
|
+
if (!handlers) throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
|
|
35
|
+
const tries = this.#tries;
|
|
36
|
+
if (!handlers[method]) {
|
|
37
|
+
tries[method] = new Trie();
|
|
38
|
+
handlers[method] = [...handlers["ALL"]];
|
|
39
|
+
for (const p in tries["ALL"].paths) this.#insertPath(method, p);
|
|
45
40
|
}
|
|
46
41
|
if (path === "/*") path = "*";
|
|
47
|
-
const methods = method === "ALL" ? Object.keys(
|
|
48
|
-
if (/\*$/.test(path)) {
|
|
49
|
-
const re = buildWildcardRegExp(path);
|
|
50
|
-
for (const m of methods) if (!middleware[m][path]) {
|
|
51
|
-
this.#insertPath(m, path);
|
|
52
|
-
middleware[m][path] = findMiddleware(middleware[m], path) || findMiddleware(middleware["ALL"], path) || [];
|
|
53
|
-
}
|
|
54
|
-
for (const handlerMap of [middleware, routes]) for (const m of methods) for (const p in handlerMap[m]) re.test(p) && handlerMap[m][p].push([handler, path]);
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
42
|
+
const methods = method === "ALL" ? Object.keys(handlers) : [method];
|
|
57
43
|
const paths = checkOptionalParameter(path) || [path];
|
|
58
44
|
for (const path of paths) for (const m of methods) {
|
|
59
|
-
if (!
|
|
60
|
-
|
|
61
|
-
routes[m][path] = findMiddleware(middleware[m], path) || findMiddleware(middleware["ALL"], path) || [];
|
|
62
|
-
}
|
|
63
|
-
routes[m][path].push([handler, path]);
|
|
45
|
+
if (!tries[m].paths[path]) this.#insertPath(m, path);
|
|
46
|
+
handlers[m].push([handler, path]);
|
|
64
47
|
}
|
|
65
48
|
}
|
|
66
49
|
match = match;
|
|
67
50
|
buildAllMatchers() {
|
|
68
51
|
const matchers = createNullObject();
|
|
69
|
-
for (const method of Object.keys(this.#
|
|
70
|
-
this.#
|
|
71
|
-
wildcardRegExpCache = createNullObject();
|
|
52
|
+
for (const method of Object.keys(this.#handlers)) matchers[method] = this.#buildMatcher(method);
|
|
53
|
+
this.#handlers = this.#tries = void 0;
|
|
72
54
|
return matchers;
|
|
73
55
|
}
|
|
74
56
|
#buildMatcher(method) {
|
|
75
|
-
const
|
|
76
|
-
const routes = this.#routes[method];
|
|
57
|
+
const handlers = this.#handlers[method];
|
|
77
58
|
const trie = this.#tries[method];
|
|
78
59
|
const staticMap = createNullObject();
|
|
79
60
|
const handlerData = [];
|
|
80
61
|
const [regexp, indexReplacementMap, paramReplacementMap] = trie.buildRegExp();
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
continue;
|
|
87
|
-
}
|
|
88
|
-
handlerData[pathData[0]] = handlers.map(([h, handlerPath]) => [h, trie.paths[handlerPath][1].reduceRight((map, [key], i) => {
|
|
89
|
-
map[key] = paramReplacementMap[pathData[1][i][1]];
|
|
62
|
+
const own = createNullObject();
|
|
63
|
+
const entries = handlers.map(([h, p], i) => {
|
|
64
|
+
(own[p] ??= []).push(i);
|
|
65
|
+
return [h, trie.paths[p][1].reduceRight((map, [key, varIndex]) => {
|
|
66
|
+
map[key] = paramReplacementMap[varIndex];
|
|
90
67
|
return map;
|
|
91
|
-
}, createNullObject())]
|
|
68
|
+
}, createNullObject())];
|
|
69
|
+
});
|
|
70
|
+
const wildcards = Object.keys(own).filter((p) => endsWithWildcard(trie.paths[p][2]));
|
|
71
|
+
for (const path in trie.paths) {
|
|
72
|
+
const [index, , keys] = trie.paths[path];
|
|
73
|
+
const indexes = [...own[path]];
|
|
74
|
+
for (const p of wildcards) if (p !== path && covers(trie.paths[p][2], keys)) indexes.push(...own[p]);
|
|
75
|
+
const data = indexes.sort((a, b) => a - b).map((i) => entries[i]);
|
|
76
|
+
if (index === -1) {
|
|
77
|
+
const last = Math.max(-1, ...data.flatMap(([, map]) => Object.values(map)));
|
|
78
|
+
staticMap[path] = [data, last === -1 ? emptyParam : path.match(regexp).slice(0, last + 1)];
|
|
79
|
+
} else handlerData[index] = data;
|
|
92
80
|
}
|
|
93
81
|
return [
|
|
94
82
|
regexp,
|
|
@@ -7,8 +7,14 @@ var Trie = class {
|
|
|
7
7
|
#index = 0;
|
|
8
8
|
paths = createNullObject();
|
|
9
9
|
insert(path, isStatic) {
|
|
10
|
+
const keys = [];
|
|
10
11
|
if (isStatic) {
|
|
11
|
-
this.#root.insert(path.split(""),
|
|
12
|
+
this.#root.insert(path.split(""), -1, [], this.#context, keys);
|
|
13
|
+
this.paths[path] = [
|
|
14
|
+
-1,
|
|
15
|
+
[],
|
|
16
|
+
keys
|
|
17
|
+
];
|
|
12
18
|
return;
|
|
13
19
|
}
|
|
14
20
|
const paramAssoc = [];
|
|
@@ -16,7 +22,7 @@ var Trie = class {
|
|
|
16
22
|
let markedPath = path;
|
|
17
23
|
for (let i = 0;;) {
|
|
18
24
|
let replaced = false;
|
|
19
|
-
markedPath = markedPath.replace(/\{[^}]+\}/g, (m) => {
|
|
25
|
+
markedPath = markedPath.replace(/\{(?:\{[\d,]+\}|[^}])+\}/g, (m) => {
|
|
20
26
|
const mark = `@\\${i}`;
|
|
21
27
|
groups[i] = [mark, m];
|
|
22
28
|
i++;
|
|
@@ -30,7 +36,7 @@ var Trie = class {
|
|
|
30
36
|
* - /* wildcard
|
|
31
37
|
* - character
|
|
32
38
|
*/
|
|
33
|
-
const tokens = markedPath.match(/(?::[^\/]+)|(?:\/\*$)|./
|
|
39
|
+
const tokens = markedPath.match(/(?::[^\/]+)|(?:\/\*$)|./gs) || [];
|
|
34
40
|
for (let i = groups.length - 1; i >= 0; i--) {
|
|
35
41
|
const [mark] = groups[i];
|
|
36
42
|
for (let j = tokens.length - 1; j >= 0; j--) if (tokens[j].indexOf(mark) !== -1) {
|
|
@@ -38,8 +44,12 @@ var Trie = class {
|
|
|
38
44
|
break;
|
|
39
45
|
}
|
|
40
46
|
}
|
|
41
|
-
this.#root.insert(tokens, this.#index, paramAssoc, this.#context,
|
|
42
|
-
this.paths[path] = [
|
|
47
|
+
this.#root.insert(tokens, this.#index, paramAssoc, this.#context, keys);
|
|
48
|
+
this.paths[path] = [
|
|
49
|
+
this.#index++,
|
|
50
|
+
paramAssoc,
|
|
51
|
+
keys
|
|
52
|
+
];
|
|
43
53
|
}
|
|
44
54
|
buildRegExp() {
|
|
45
55
|
let regexp = this.#root.buildRegExpStr();
|
|
@@ -16,6 +16,7 @@ type MountOptions = MountOptionHandler | {
|
|
|
16
16
|
* @param {Function} applicationHandler - other Request Handler
|
|
17
17
|
* @param {MountOptions} [options] - options of `mount()`
|
|
18
18
|
* @returns {MiddlewareHandler} handler to register with `app.all()`
|
|
19
|
+
* @throws {Error} If the route ends with a wildcard inside a segment (e.g. `/assets*`), or automatic request rewriting encounters duplicate path parameter names.
|
|
19
20
|
*
|
|
20
21
|
* @example
|
|
21
22
|
* ```ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//#region src/router/reg-exp-router/node.d.ts
|
|
2
2
|
export declare const LABEL_REG_EXP_STR = "[^/]+";
|
|
3
|
-
export declare const ONLY_WILDCARD_REG_EXP_STR = "
|
|
4
|
-
export declare const TAIL_WILDCARD_REG_EXP_STR = "(
|
|
3
|
+
export declare const ONLY_WILDCARD_REG_EXP_STR = "[^]*";
|
|
4
|
+
export declare const TAIL_WILDCARD_REG_EXP_STR = "(?:|/[^]*)";
|
|
5
5
|
export declare const PATH_ERROR: unique symbol;
|
|
6
6
|
export type ParamAssocArray = [string, number][];
|
|
7
7
|
export interface Context {
|
|
@@ -9,7 +9,7 @@ export interface Context {
|
|
|
9
9
|
}
|
|
10
10
|
export declare class Node {
|
|
11
11
|
|
|
12
|
-
insert(tokens: readonly string[], index: number, paramMap: ParamAssocArray, context: Context,
|
|
12
|
+
insert(tokens: readonly string[], index: number, paramMap: ParamAssocArray, context: Context, keys: string[]): void;
|
|
13
13
|
buildRegExpStr(): string;
|
|
14
14
|
}
|
|
15
15
|
//#endregion
|
|
@@ -3,7 +3,7 @@ import { ParamAssocArray } from "./node.js";
|
|
|
3
3
|
export type ReplacementMap = number[];
|
|
4
4
|
export declare class Trie {
|
|
5
5
|
|
|
6
|
-
paths: Record<string, [number, ParamAssocArray]>;
|
|
6
|
+
paths: Record<string, [number, ParamAssocArray, string[]]>;
|
|
7
7
|
insert(path: string, isStatic: boolean): void;
|
|
8
8
|
buildRegExp(): [RegExp, ReplacementMap, ReplacementMap];
|
|
9
9
|
}
|