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.
Files changed (80) hide show
  1. package/README.md +2 -0
  2. package/build/background-jobs/web/authorization.js +2 -33
  3. package/build/background-jobs/web/path-matcher.js +5 -30
  4. package/build/database/drivers/base.js +17 -0
  5. package/build/database/drivers/mssql/index.js +30 -0
  6. package/build/database/record/index.js +22 -10
  7. package/build/deployment-api/controller.js +437 -0
  8. package/build/deployment-api/index.js +210 -0
  9. package/build/deployment-api/path-matcher.js +45 -0
  10. package/build/deployment-api/registry.js +84 -0
  11. package/build/deployment-api/run-store.js +798 -0
  12. package/build/deployment-api/sanitize.js +114 -0
  13. package/build/http-client/request.js +3 -1
  14. package/build/src/background-jobs/web/authorization.d.ts.map +1 -1
  15. package/build/src/background-jobs/web/authorization.js +3 -29
  16. package/build/src/background-jobs/web/path-matcher.d.ts +2 -12
  17. package/build/src/background-jobs/web/path-matcher.d.ts.map +1 -1
  18. package/build/src/background-jobs/web/path-matcher.js +5 -30
  19. package/build/src/database/drivers/base.d.ts +16 -0
  20. package/build/src/database/drivers/base.d.ts.map +1 -1
  21. package/build/src/database/drivers/base.js +16 -1
  22. package/build/src/database/drivers/mssql/index.d.ts.map +1 -1
  23. package/build/src/database/drivers/mssql/index.js +29 -1
  24. package/build/src/database/record/index.d.ts +3 -2
  25. package/build/src/database/record/index.d.ts.map +1 -1
  26. package/build/src/database/record/index.js +21 -10
  27. package/build/src/deployment-api/controller.d.ts +117 -0
  28. package/build/src/deployment-api/controller.d.ts.map +1 -0
  29. package/build/src/deployment-api/controller.js +384 -0
  30. package/build/src/deployment-api/index.d.ts +46 -0
  31. package/build/src/deployment-api/index.d.ts.map +1 -0
  32. package/build/src/deployment-api/index.js +178 -0
  33. package/build/src/deployment-api/path-matcher.d.ts +31 -0
  34. package/build/src/deployment-api/path-matcher.d.ts.map +1 -0
  35. package/build/src/deployment-api/path-matcher.js +39 -0
  36. package/build/src/deployment-api/registry.d.ts +106 -0
  37. package/build/src/deployment-api/registry.d.ts.map +1 -0
  38. package/build/src/deployment-api/registry.js +74 -0
  39. package/build/src/deployment-api/run-store.d.ts +402 -0
  40. package/build/src/deployment-api/run-store.d.ts.map +1 -0
  41. package/build/src/deployment-api/run-store.js +711 -0
  42. package/build/src/deployment-api/sanitize.d.ts +27 -0
  43. package/build/src/deployment-api/sanitize.d.ts.map +1 -0
  44. package/build/src/deployment-api/sanitize.js +100 -0
  45. package/build/src/http-client/request.d.ts.map +1 -1
  46. package/build/src/http-client/request.js +4 -2
  47. package/build/src/sync/signed-sync-envelope-replay-service.d.ts +154 -0
  48. package/build/src/sync/signed-sync-envelope-replay-service.d.ts.map +1 -0
  49. package/build/src/sync/signed-sync-envelope-replay-service.js +294 -0
  50. package/build/src/sync/sync-envelope-replay-service.d.ts +84 -15
  51. package/build/src/sync/sync-envelope-replay-service.d.ts.map +1 -1
  52. package/build/src/sync/sync-envelope-replay-service.js +98 -16
  53. package/build/src/utils/bearer-token.d.ts +15 -0
  54. package/build/src/utils/bearer-token.d.ts.map +1 -0
  55. package/build/src/utils/bearer-token.js +29 -0
  56. package/build/src/utils/mount-prefix.d.ts +21 -0
  57. package/build/src/utils/mount-prefix.d.ts.map +1 -0
  58. package/build/src/utils/mount-prefix.js +35 -0
  59. package/build/sync/signed-sync-envelope-replay-service.js +342 -0
  60. package/build/sync/sync-envelope-replay-service.js +110 -15
  61. package/build/tsconfig.tsbuildinfo +1 -1
  62. package/build/utils/bearer-token.js +34 -0
  63. package/build/utils/mount-prefix.js +36 -0
  64. package/package.json +2 -1
  65. package/src/background-jobs/web/authorization.js +2 -33
  66. package/src/background-jobs/web/path-matcher.js +5 -30
  67. package/src/database/drivers/base.js +17 -0
  68. package/src/database/drivers/mssql/index.js +30 -0
  69. package/src/database/record/index.js +22 -10
  70. package/src/deployment-api/controller.js +437 -0
  71. package/src/deployment-api/index.js +210 -0
  72. package/src/deployment-api/path-matcher.js +45 -0
  73. package/src/deployment-api/registry.js +84 -0
  74. package/src/deployment-api/run-store.js +798 -0
  75. package/src/deployment-api/sanitize.js +114 -0
  76. package/src/http-client/request.js +3 -1
  77. package/src/sync/signed-sync-envelope-replay-service.js +342 -0
  78. package/src/sync/sync-envelope-replay-service.js +110 -15
  79. package/src/utils/bearer-token.js +34 -0
  80. 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
+ }