velocious 1.0.571 → 1.0.573
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/README.md +2 -0
- package/build/background-jobs/web/authorization.js +2 -33
- package/build/background-jobs/web/path-matcher.js +5 -30
- package/build/database/drivers/base.js +17 -0
- package/build/database/drivers/mssql/index.js +30 -0
- package/build/database/record/index.js +22 -10
- package/build/deployment-api/controller.js +437 -0
- package/build/deployment-api/index.js +210 -0
- package/build/deployment-api/path-matcher.js +45 -0
- package/build/deployment-api/registry.js +84 -0
- package/build/deployment-api/run-store.js +798 -0
- package/build/deployment-api/sanitize.js +114 -0
- package/build/http-client/request.js +3 -1
- package/build/src/background-jobs/web/authorization.d.ts.map +1 -1
- package/build/src/background-jobs/web/authorization.js +3 -29
- package/build/src/background-jobs/web/path-matcher.d.ts +2 -12
- package/build/src/background-jobs/web/path-matcher.d.ts.map +1 -1
- package/build/src/background-jobs/web/path-matcher.js +5 -30
- package/build/src/database/drivers/base.d.ts +16 -0
- package/build/src/database/drivers/base.d.ts.map +1 -1
- package/build/src/database/drivers/base.js +16 -1
- package/build/src/database/drivers/mssql/index.d.ts.map +1 -1
- package/build/src/database/drivers/mssql/index.js +29 -1
- package/build/src/database/record/index.d.ts +3 -2
- package/build/src/database/record/index.d.ts.map +1 -1
- package/build/src/database/record/index.js +21 -10
- package/build/src/deployment-api/controller.d.ts +117 -0
- package/build/src/deployment-api/controller.d.ts.map +1 -0
- package/build/src/deployment-api/controller.js +384 -0
- package/build/src/deployment-api/index.d.ts +46 -0
- package/build/src/deployment-api/index.d.ts.map +1 -0
- package/build/src/deployment-api/index.js +178 -0
- package/build/src/deployment-api/path-matcher.d.ts +31 -0
- package/build/src/deployment-api/path-matcher.d.ts.map +1 -0
- package/build/src/deployment-api/path-matcher.js +39 -0
- package/build/src/deployment-api/registry.d.ts +106 -0
- package/build/src/deployment-api/registry.d.ts.map +1 -0
- package/build/src/deployment-api/registry.js +74 -0
- package/build/src/deployment-api/run-store.d.ts +402 -0
- package/build/src/deployment-api/run-store.d.ts.map +1 -0
- package/build/src/deployment-api/run-store.js +711 -0
- package/build/src/deployment-api/sanitize.d.ts +27 -0
- package/build/src/deployment-api/sanitize.d.ts.map +1 -0
- package/build/src/deployment-api/sanitize.js +100 -0
- package/build/src/http-client/request.d.ts.map +1 -1
- package/build/src/http-client/request.js +4 -2
- package/build/src/sync/signed-sync-envelope-replay-service.d.ts +154 -0
- package/build/src/sync/signed-sync-envelope-replay-service.d.ts.map +1 -0
- package/build/src/sync/signed-sync-envelope-replay-service.js +294 -0
- package/build/src/sync/sync-envelope-replay-service.d.ts +84 -15
- package/build/src/sync/sync-envelope-replay-service.d.ts.map +1 -1
- package/build/src/sync/sync-envelope-replay-service.js +98 -16
- package/build/src/utils/bearer-token.d.ts +15 -0
- package/build/src/utils/bearer-token.d.ts.map +1 -0
- package/build/src/utils/bearer-token.js +29 -0
- package/build/src/utils/mount-prefix.d.ts +21 -0
- package/build/src/utils/mount-prefix.d.ts.map +1 -0
- package/build/src/utils/mount-prefix.js +35 -0
- package/build/sync/signed-sync-envelope-replay-service.js +342 -0
- package/build/sync/sync-envelope-replay-service.js +110 -15
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/utils/bearer-token.js +34 -0
- package/build/utils/mount-prefix.js +36 -0
- package/package.json +2 -1
- package/src/background-jobs/web/authorization.js +2 -33
- package/src/background-jobs/web/path-matcher.js +5 -30
- package/src/database/drivers/base.js +17 -0
- package/src/database/drivers/mssql/index.js +30 -0
- package/src/database/record/index.js +22 -10
- package/src/deployment-api/controller.js +437 -0
- package/src/deployment-api/index.js +210 -0
- package/src/deployment-api/path-matcher.js +45 -0
- package/src/deployment-api/registry.js +84 -0
- package/src/deployment-api/run-store.js +798 -0
- package/src/deployment-api/sanitize.js +114 -0
- package/src/http-client/request.js +3 -1
- package/src/sync/signed-sync-envelope-replay-service.js +342 -0
- package/src/sync/sync-envelope-replay-service.js +110 -15
- package/src/utils/bearer-token.js +34 -0
- package/src/utils/mount-prefix.js +36 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
import crypto from "node:crypto"
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Constant-time comparison so token checks don't leak length/contents through
|
|
7
|
+
* timing. Returns false for differing lengths before the timing-safe compare.
|
|
8
|
+
* @param {string} a - First value.
|
|
9
|
+
* @param {string} b - Second value.
|
|
10
|
+
* @returns {boolean} - Whether the values are equal.
|
|
11
|
+
*/
|
|
12
|
+
export function constantTimeEqual(a, b) {
|
|
13
|
+
const bufferA = Buffer.from(String(a))
|
|
14
|
+
const bufferB = Buffer.from(String(b))
|
|
15
|
+
|
|
16
|
+
if (bufferA.length !== bufferB.length) return false
|
|
17
|
+
|
|
18
|
+
return crypto.timingSafeEqual(bufferA, bufferB)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Extracts the bearer token from the Authorization header of a request.
|
|
23
|
+
* @param {import("../http-server/client/request.js").default | import("../http-server/client/websocket-request.js").default} request - Request object.
|
|
24
|
+
* @returns {string | null} - Bearer token from the Authorization header, if any.
|
|
25
|
+
*/
|
|
26
|
+
export function bearerToken(request) {
|
|
27
|
+
const header = request.header("authorization")
|
|
28
|
+
|
|
29
|
+
if (typeof header !== "string") return null
|
|
30
|
+
|
|
31
|
+
const match = header.match(/^Bearer\s+(.+)$/i)
|
|
32
|
+
|
|
33
|
+
return match ? match[1].trim() : null
|
|
34
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Normalizes a mount prefix: ensures a leading slash and strips any trailing
|
|
5
|
+
* slash so `/velocious/jobs/` and `/velocious/jobs` behave identically.
|
|
6
|
+
* @param {string} at - Raw mount prefix.
|
|
7
|
+
* @returns {string} - Normalized prefix.
|
|
8
|
+
*/
|
|
9
|
+
export function normalizeMountPrefix(at) {
|
|
10
|
+
if (typeof at !== "string" || !at.startsWith("/")) {
|
|
11
|
+
throw new Error(`mount requires an 'at' path starting with '/', got: ${String(at)}`)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (at.length > 1 && at.endsWith("/")) {
|
|
15
|
+
return at.slice(0, -1)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return at
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Extracts the request sub-path under a normalized mount prefix, or null when
|
|
23
|
+
* the path is outside the mount. A root mount (`/`) treats the whole path as
|
|
24
|
+
* the sub-path.
|
|
25
|
+
* @param {object} args - Options.
|
|
26
|
+
* @param {string} args.prefix - Normalized mount prefix.
|
|
27
|
+
* @param {string} args.path - Request path without query string.
|
|
28
|
+
* @returns {string | null} - Sub-path ("/" for the bare prefix) or null.
|
|
29
|
+
*/
|
|
30
|
+
export function mountSubPath({prefix, path}) {
|
|
31
|
+
if (prefix === "/") return path
|
|
32
|
+
if (path === prefix) return "/"
|
|
33
|
+
if (path.startsWith(`${prefix}/`)) return path.slice(prefix.length)
|
|
34
|
+
|
|
35
|
+
return null
|
|
36
|
+
}
|