@getstrata/core 0.5.55 → 0.5.56

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 (77) hide show
  1. package/README.md +2 -0
  2. package/dist/core/media/imageTransform.d.ts +13 -0
  3. package/dist/core/scheduler/osCron.d.ts +14 -0
  4. package/dist/core/terminal/runShell.d.ts +6 -0
  5. package/dist/core/view/assertEtaHtmlSource.d.ts +5 -0
  6. package/dist/core/view/etaViewEngine.d.ts +4 -0
  7. package/dist/entries/audit/exportAuditLogs.js +2 -2
  8. package/dist/entries/audit/siemFormatter.js +2 -2
  9. package/dist/entries/auth/accessControl.js +4 -4
  10. package/dist/entries/auth/membershipScope.js +6 -6
  11. package/dist/entries/auth/oauth/providers.js +2 -2
  12. package/dist/entries/auth/password.js +2 -2
  13. package/dist/entries/auth/policy.js +2 -2
  14. package/dist/entries/auth/sessionCookie.js +4 -4
  15. package/dist/entries/auth/sessionGuard.js +0 -91
  16. package/dist/entries/auth/tokenHash.js +2 -2
  17. package/dist/entries/config/envSchema.js +2 -2
  18. package/dist/entries/contracts/container.js +2 -2
  19. package/dist/entries/contracts/di.js +2 -2
  20. package/dist/entries/contracts/serviceTokens.js +6 -6
  21. package/dist/entries/crypto/fieldEncryption.js +8 -8
  22. package/dist/entries/crypto/mfaSecret.js +2 -2
  23. package/dist/entries/database/errors.js +2 -2
  24. package/dist/entries/database/migrations.js +8 -8
  25. package/dist/entries/database/model.js +5 -5
  26. package/dist/entries/database/query.js +19 -19
  27. package/dist/entries/database/relationships.js +13 -13
  28. package/dist/entries/database/schema.js +13 -13
  29. package/dist/entries/database/seeders.js +2 -2
  30. package/dist/entries/facades.js +8 -8
  31. package/dist/entries/http/authMiddleware.js +2 -2
  32. package/dist/entries/http/bodySizeLimitMiddleware.js +2 -2
  33. package/dist/entries/http/cookies.js +2 -2
  34. package/dist/entries/http/csrfProtection.js +2 -2
  35. package/dist/entries/http/csrfToken.js +6 -6
  36. package/dist/entries/http/etag.js +8 -8
  37. package/dist/entries/http/flashSession.js +4 -4
  38. package/dist/entries/http/formRequest.js +2 -2
  39. package/dist/entries/http/loginThrottleMiddleware.js +2 -2
  40. package/dist/entries/http/metricsMiddleware.js +2 -2
  41. package/dist/entries/http/pagination.js +4 -4
  42. package/dist/entries/http/parseFormBody.js +2 -2
  43. package/dist/entries/http/parseMultipartUpload.js +2 -2
  44. package/dist/entries/http/resources.js +2 -2
  45. package/dist/entries/http/response.js +186 -98
  46. package/dist/entries/http/securedRouteModelBinding.js +2 -2
  47. package/dist/entries/http/throttleMiddleware.js +2 -2
  48. package/dist/entries/http/validation.js +13 -13
  49. package/dist/entries/http/webErrorResponse.js +184 -96
  50. package/dist/entries/lifecycle/gracefulShutdown.js +3 -3
  51. package/dist/entries/logging/logger.js +2 -2
  52. package/dist/entries/mail/mailer.js +6 -6
  53. package/dist/entries/mail/markdownMail.js +3 -3
  54. package/dist/entries/mail/markdownMailable.js +2 -2
  55. package/dist/entries/media/imageTransform.js +40 -0
  56. package/dist/entries/metrics/prometheus.js +2 -2
  57. package/dist/entries/openapi/generator.js +2 -2
  58. package/dist/entries/queue/createAppQueue.js +4 -4
  59. package/dist/entries/queue/publicQueue.js +10 -10
  60. package/dist/entries/queue/queueMetrics.js +2 -2
  61. package/dist/entries/queue/redisQueue.js +7 -7
  62. package/dist/entries/queue.js +3 -3
  63. package/dist/entries/scheduler/osCron.js +27 -0
  64. package/dist/entries/scheduler/schedule.js +2 -2
  65. package/dist/entries/security/oauthState.js +3 -3
  66. package/dist/entries/security/publicReads.js +2 -2
  67. package/dist/entries/security/safeFetch.js +2 -2
  68. package/dist/entries/security/safeUrl.js +5 -5
  69. package/dist/entries/security/scimTenantTokens.js +2 -2
  70. package/dist/entries/security/totp.js +2 -2
  71. package/dist/entries/storage/storage.js +7 -7
  72. package/dist/entries/tenant/tenantDatabaseScope.js +2 -2
  73. package/dist/entries/terminal/runShell.js +18 -0
  74. package/dist/entries/validation/rules.js +12 -12
  75. package/dist/entries/view.js +186 -98
  76. package/dist/index.js +431 -469
  77. package/package.json +17 -2
package/dist/index.js CHANGED
@@ -196,13 +196,6 @@ var ADMIN_ABILITIES = [
196
196
  "webhooks:write",
197
197
  "audit:read"
198
198
  ];
199
- var PLATFORM_ADMIN_ABILITIES = ["*"];
200
- function resolveAbilitiesForRole(role) {
201
- if (role === "admin") {
202
- return [...PLATFORM_ADMIN_ABILITIES];
203
- }
204
- return [...MEMBER_ABILITIES];
205
- }
206
199
 
207
200
  // ../../src/core/contracts/serviceTokens.ts
208
201
  var CORE_QUEUE_TOKEN = "core.queue";
@@ -1608,65 +1601,6 @@ var apiTokenTable = defineTable({
1608
1601
  defaultOrderBy: { column: "id", direction: "ASC" }
1609
1602
  });
1610
1603
 
1611
- // ../../src/core/auth/password.ts
1612
- async function verifyPassword(password, passwordHash) {
1613
- return await Bun.password.verify(password, passwordHash);
1614
- }
1615
-
1616
- // ../../src/core/crypto/fieldEncryption.ts
1617
- import { createCipheriv, createDecipheriv, createHmac, randomBytes } from "crypto";
1618
- var ENCRYPTION_PREFIX = "enc:v1:";
1619
- var IV_LENGTH = 12;
1620
- var TAG_LENGTH = 16;
1621
- function resolveEncryptionKey() {
1622
- const raw = process.env.KMS_ENCRYPTION_KEY?.trim();
1623
- if (!raw) {
1624
- return null;
1625
- }
1626
- if (/^[0-9a-f]{64}$/i.test(raw)) {
1627
- return Buffer.from(raw, "hex");
1628
- }
1629
- const decoded = Buffer.from(raw, "base64");
1630
- if (decoded.length === 32) {
1631
- return decoded;
1632
- }
1633
- throw new Error("KMS_ENCRYPTION_KEY must be 32 bytes (hex or base64).");
1634
- }
1635
- function isFieldEncryptionEnabled() {
1636
- const featureFlag = process.env.FEATURE_FIELD_ENCRYPTION;
1637
- if (featureFlag === "false") {
1638
- return false;
1639
- }
1640
- if (featureFlag === "true") {
1641
- return true;
1642
- }
1643
- return (process.env.APP_ENV ?? "local") === "production";
1644
- }
1645
- function decryptField(value, key) {
1646
- if (!value.startsWith(ENCRYPTION_PREFIX)) {
1647
- return value;
1648
- }
1649
- const payload = Buffer.from(value.slice(ENCRYPTION_PREFIX.length), "base64");
1650
- const iv = payload.subarray(0, IV_LENGTH);
1651
- const tag = payload.subarray(payload.length - TAG_LENGTH);
1652
- const ciphertext = payload.subarray(IV_LENGTH, payload.length - TAG_LENGTH);
1653
- const decipher = createDecipheriv("aes-256-gcm", key, iv);
1654
- decipher.setAuthTag(tag);
1655
- return Buffer.concat([decipher.update(ciphertext), decipher.final()]).toString("utf8");
1656
- }
1657
-
1658
- // ../../src/core/crypto/mfaSecret.ts
1659
- function revealMfaSecret(stored) {
1660
- if (!stored) {
1661
- return null;
1662
- }
1663
- const key = resolveEncryptionKey();
1664
- if (!isFieldEncryptionEnabled() || !key || !stored.startsWith("enc:v1:")) {
1665
- return stored;
1666
- }
1667
- return decryptField(stored, key);
1668
- }
1669
-
1670
1604
  // ../../src/core/http/requestMetaContext.ts
1671
1605
  var requestMetaContext = createAsyncContextStore("@getstrata/requestMetaContext");
1672
1606
  function runWithRequestMeta(meta, callback) {
@@ -1694,66 +1628,6 @@ function logSecurityEvent(event, details = {}) {
1694
1628
  }));
1695
1629
  }
1696
1630
 
1697
- // ../../src/core/security/tokenExpiry.ts
1698
- function resolveDefaultTokenExpiryDays() {
1699
- const raw = process.env.API_TOKEN_DEFAULT_EXPIRY_DAYS?.trim();
1700
- if (!raw) {
1701
- return null;
1702
- }
1703
- const parsed = Number.parseInt(raw, 10);
1704
- if (!Number.isInteger(parsed) || parsed <= 0) {
1705
- return null;
1706
- }
1707
- return parsed;
1708
- }
1709
-
1710
- // ../../src/core/security/totp.ts
1711
- import { createHmac as createHmac2 } from "crypto";
1712
- function decodeBase32(input) {
1713
- const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
1714
- const normalized = input.replace(/=+$/u, "").toUpperCase();
1715
- let bits = "";
1716
- for (const char of normalized) {
1717
- const value = alphabet.indexOf(char);
1718
- if (value === -1) {
1719
- throw new Error("Invalid base32 character in MFA secret.");
1720
- }
1721
- bits += value.toString(2).padStart(5, "0");
1722
- }
1723
- const bytes = [];
1724
- for (let index = 0;index + 8 <= bits.length; index += 8) {
1725
- bytes.push(Number.parseInt(bits.slice(index, index + 8), 2));
1726
- }
1727
- return Buffer.from(bytes);
1728
- }
1729
- function generateTotp(secret, counter, digits = 6) {
1730
- const key = decodeBase32(secret);
1731
- const buffer = Buffer.alloc(8);
1732
- buffer.writeBigUInt64BE(BigInt(counter));
1733
- const digest = createHmac2("sha1", key).update(buffer).digest();
1734
- const lastByte = digest[digest.length - 1] ?? 0;
1735
- const offset = lastByte & 15;
1736
- const b0 = digest[offset] ?? 0;
1737
- const b1 = digest[offset + 1] ?? 0;
1738
- const b2 = digest[offset + 2] ?? 0;
1739
- const b3 = digest[offset + 3] ?? 0;
1740
- const code = (b0 & 127) << 24 | (b1 & 255) << 16 | (b2 & 255) << 8 | b3 & 255;
1741
- return String(code % 10 ** digits).padStart(digits, "0");
1742
- }
1743
- function verifyTotp(secret, token, window = 1) {
1744
- const normalized = token.trim();
1745
- if (!/^\d{6}$/u.test(normalized)) {
1746
- return false;
1747
- }
1748
- const timestep = Math.floor(Date.now() / 30000);
1749
- for (let offset = -window;offset <= window; offset += 1) {
1750
- if (generateTotp(secret, timestep + offset) === normalized) {
1751
- return true;
1752
- }
1753
- }
1754
- return false;
1755
- }
1756
-
1757
1631
  // ../../src/core/tenant/tenantContext.ts
1758
1632
  var tenantContext = createAsyncContextStore("@getstrata/tenantContext");
1759
1633
  function runWithTenant(tenant, callback) {
@@ -1776,99 +1650,6 @@ function rateLimitMultiplierForPlan(plan) {
1776
1650
  }
1777
1651
  }
1778
1652
 
1779
- // ../../src/modules/user/authService.ts
1780
- class AuthService {
1781
- users;
1782
- tokens;
1783
- oauthIdentities;
1784
- oauthProviders = new Map;
1785
- constructor(users, tokens, oauthIdentities) {
1786
- this.users = users;
1787
- this.tokens = tokens;
1788
- this.oauthIdentities = oauthIdentities;
1789
- }
1790
- registerOAuthProvider(provider) {
1791
- this.oauthProviders.set(provider.name, provider);
1792
- }
1793
- getOAuthProvider(name) {
1794
- return this.oauthProviders.get(name);
1795
- }
1796
- async loginWithPassword(email, password, options = {}) {
1797
- const user = await this.users.findByEmail(email);
1798
- if (!user?.password_hash) {
1799
- logSecurityEvent("auth_login_failed", { reason: "unknown_user", email });
1800
- throw new UnauthorizedError("Invalid credentials.");
1801
- }
1802
- const valid = await verifyPassword(password, user.password_hash);
1803
- if (!valid) {
1804
- logSecurityEvent("auth_login_failed", { reason: "invalid_password", user_id: user.id });
1805
- throw new UnauthorizedError("Invalid credentials.");
1806
- }
1807
- if (isFeatureEnabled("emailVerification") && !user.email_verified_at) {
1808
- logSecurityEvent("auth_login_blocked", { reason: "email_unverified", user_id: user.id });
1809
- throw new UnauthorizedError("Email address is not verified.");
1810
- }
1811
- if (isFeatureEnabled("mfa") && user.mfa_enabled) {
1812
- const mfaSecret = revealMfaSecret(user.mfa_secret);
1813
- if (!mfaSecret || !options.mfaCode || !verifyTotp(mfaSecret, options.mfaCode)) {
1814
- logSecurityEvent("auth_login_failed", { reason: "invalid_mfa", user_id: user.id });
1815
- throw new UnauthorizedError("Invalid MFA code.");
1816
- }
1817
- }
1818
- logSecurityEvent("auth_login_success", { user_id: user.id, method: "password" });
1819
- return await this.tokens.createToken(user.id, {
1820
- name: "password-login",
1821
- abilities: resolveAbilitiesForRole(user.role),
1822
- expiresInDays: resolveDefaultTokenExpiryDays() ?? undefined
1823
- });
1824
- }
1825
- async loginWithOAuth(providerName, code) {
1826
- const provider = this.oauthProviders.get(providerName);
1827
- if (!provider) {
1828
- throw new UnauthorizedError("Unsupported OAuth provider.");
1829
- }
1830
- const profile = await provider.exchangeCode(code);
1831
- const user = await this.findOrCreateOAuthUser(providerName, profile);
1832
- logSecurityEvent("auth_login_success", { user_id: user.id, method: `oauth:${providerName}` });
1833
- return await this.tokens.createToken(user.id, {
1834
- name: `${providerName}-oauth`,
1835
- abilities: resolveAbilitiesForRole(user.role),
1836
- expiresInDays: resolveDefaultTokenExpiryDays() ?? undefined
1837
- });
1838
- }
1839
- buildOAuthAuthorizationUrl(providerName, state) {
1840
- const provider = this.oauthProviders.get(providerName);
1841
- if (!provider) {
1842
- throw new UnauthorizedError("Unsupported OAuth provider.");
1843
- }
1844
- return provider.getAuthorizationUrl(state);
1845
- }
1846
- async findOrCreateOAuthUser(providerName, profile) {
1847
- const existingIdentity = await this.oauthIdentities.findByProviderUser(providerName, profile.providerUserId);
1848
- if (existingIdentity) {
1849
- return await this.users.findByIdOrThrow(existingIdentity.user_id);
1850
- }
1851
- const existingUser = await this.users.findByEmail(profile.email);
1852
- const user = existingUser ?? await this.users.create({
1853
- name: profile.name,
1854
- email: profile.email,
1855
- role: "member",
1856
- tenant_id: currentTenantId(),
1857
- email_verified_at: new Date,
1858
- created_at: new Date,
1859
- updated_at: new Date
1860
- });
1861
- await this.oauthIdentities.create({
1862
- user_id: user.id,
1863
- provider: providerName,
1864
- provider_user_id: profile.providerUserId,
1865
- email: profile.email,
1866
- created_at: new Date
1867
- });
1868
- return user;
1869
- }
1870
- }
1871
-
1872
1653
  // ../../src/modules/user/notificationTable.ts
1873
1654
  var notificationTable = defineTable({
1874
1655
  name: "notification",
@@ -4840,14 +4621,14 @@ function createCsrfProtection(secret, options = {}) {
4840
4621
  };
4841
4622
  }
4842
4623
  // ../../src/core/http/flashSession.ts
4843
- import { createHmac as createHmac3, timingSafeEqual as timingSafeEqual3 } from "crypto";
4624
+ import { createHmac, timingSafeEqual as timingSafeEqual3 } from "crypto";
4844
4625
  var FLASH_COOKIE = "workhub_flash";
4845
4626
  var FLASH_TTL_MS = 60 * 1000;
4846
4627
  function resolveFlashSecret() {
4847
4628
  return process.env.SESSION_SECRET?.trim() || process.env.OAUTH_STATE_SECRET?.trim() || "workhub-dev-flash-secret";
4848
4629
  }
4849
4630
  function signFlashPayload(payload, issuedAt) {
4850
- const signature = createHmac3("sha256", resolveFlashSecret()).update(`${payload}.${issuedAt}`).digest("hex");
4631
+ const signature = createHmac("sha256", resolveFlashSecret()).update(`${payload}.${issuedAt}`).digest("hex");
4851
4632
  return `${payload}.${issuedAt}.${signature}`;
4852
4633
  }
4853
4634
  function readFlashCookie(request) {
@@ -5217,8 +4998,183 @@ function isViewsEnabled() {
5217
4998
  }
5218
4999
 
5219
5000
  // ../../src/core/view/etaViewEngine.ts
5220
- import { join as join4 } from "path";
5001
+ import { join as join4, relative } from "path";
5221
5002
  import { Eta } from "eta";
5003
+
5004
+ // ../../src/core/view/assertEtaHtmlSource.ts
5005
+ var HTML_TAGS = new Set([
5006
+ "a",
5007
+ "abbr",
5008
+ "address",
5009
+ "article",
5010
+ "aside",
5011
+ "audio",
5012
+ "b",
5013
+ "blockquote",
5014
+ "body",
5015
+ "button",
5016
+ "canvas",
5017
+ "caption",
5018
+ "cite",
5019
+ "code",
5020
+ "col",
5021
+ "colgroup",
5022
+ "data",
5023
+ "datalist",
5024
+ "dd",
5025
+ "del",
5026
+ "details",
5027
+ "dfn",
5028
+ "dialog",
5029
+ "div",
5030
+ "dl",
5031
+ "dt",
5032
+ "em",
5033
+ "fieldset",
5034
+ "figcaption",
5035
+ "figure",
5036
+ "footer",
5037
+ "form",
5038
+ "h1",
5039
+ "h2",
5040
+ "h3",
5041
+ "h4",
5042
+ "h5",
5043
+ "h6",
5044
+ "header",
5045
+ "hgroup",
5046
+ "hr",
5047
+ "html",
5048
+ "i",
5049
+ "iframe",
5050
+ "img",
5051
+ "input",
5052
+ "ins",
5053
+ "kbd",
5054
+ "label",
5055
+ "legend",
5056
+ "li",
5057
+ "main",
5058
+ "map",
5059
+ "mark",
5060
+ "menu",
5061
+ "meter",
5062
+ "nav",
5063
+ "object",
5064
+ "ol",
5065
+ "optgroup",
5066
+ "option",
5067
+ "output",
5068
+ "p",
5069
+ "picture",
5070
+ "pre",
5071
+ "progress",
5072
+ "q",
5073
+ "rp",
5074
+ "rt",
5075
+ "ruby",
5076
+ "s",
5077
+ "samp",
5078
+ "script",
5079
+ "search",
5080
+ "section",
5081
+ "select",
5082
+ "slot",
5083
+ "small",
5084
+ "source",
5085
+ "span",
5086
+ "strong",
5087
+ "style",
5088
+ "sub",
5089
+ "summary",
5090
+ "sup",
5091
+ "table",
5092
+ "tbody",
5093
+ "td",
5094
+ "template",
5095
+ "textarea",
5096
+ "tfoot",
5097
+ "th",
5098
+ "thead",
5099
+ "time",
5100
+ "title",
5101
+ "tr",
5102
+ "track",
5103
+ "u",
5104
+ "ul",
5105
+ "var",
5106
+ "video",
5107
+ "wbr"
5108
+ ]);
5109
+ var TAG_PATTERN = "([a-z][a-z0-9]*)";
5110
+ var CLASS_OR_ID_PATTERN = "[.#][\\w-]+";
5111
+ var CLASS_ID_SHORTHAND = new RegExp(`^${TAG_PATTERN}(?:${CLASS_OR_ID_PATTERN})+`);
5112
+ var ATTRIBUTE_SHORTHAND = new RegExp(`^${TAG_PATTERN}(?:${CLASS_OR_ID_PATTERN})*\\s+[\\w:-]+=`);
5113
+ var TAG_SHORTHAND = new RegExp(`^${TAG_PATTERN}(?:>|\\s+\\S|$)`);
5114
+ function htmlTagName(match) {
5115
+ const tag = match?.[1];
5116
+ return tag && HTML_TAGS.has(tag) ? tag : undefined;
5117
+ }
5118
+ function describePugLikeLine(line) {
5119
+ if (/^\|(?:\s|$)/.test(line)) {
5120
+ return "piped text";
5121
+ }
5122
+ if (htmlTagName(line.match(CLASS_ID_SHORTHAND))) {
5123
+ return "class/id shorthand";
5124
+ }
5125
+ if (htmlTagName(line.match(ATTRIBUTE_SHORTHAND))) {
5126
+ return "attribute shorthand";
5127
+ }
5128
+ if (htmlTagName(line.match(TAG_SHORTHAND))) {
5129
+ return "tag shorthand";
5130
+ }
5131
+ return;
5132
+ }
5133
+ function updateSkipBlock(lower, skipBlock) {
5134
+ if (skipBlock) {
5135
+ if (skipBlock === "comment" && lower.includes("-->")) {
5136
+ return null;
5137
+ }
5138
+ if (skipBlock !== "comment" && lower.includes(`</${skipBlock}`)) {
5139
+ return null;
5140
+ }
5141
+ return skipBlock;
5142
+ }
5143
+ if (lower.startsWith("<!--") && !lower.includes("-->")) {
5144
+ return "comment";
5145
+ }
5146
+ if (lower.startsWith("<script") && !lower.includes("</script")) {
5147
+ return "script";
5148
+ }
5149
+ if (lower.startsWith("<style") && !lower.includes("</style")) {
5150
+ return "style";
5151
+ }
5152
+ return null;
5153
+ }
5154
+ function assertEtaHtmlSource(templateName, source) {
5155
+ let skipBlock = null;
5156
+ for (const rawLine of source.split(/\r?\n/)) {
5157
+ const trimmed = rawLine.trim();
5158
+ if (!trimmed) {
5159
+ continue;
5160
+ }
5161
+ const lower = trimmed.toLowerCase();
5162
+ const nextSkipBlock = updateSkipBlock(lower, skipBlock);
5163
+ if (skipBlock || nextSkipBlock) {
5164
+ skipBlock = nextSkipBlock;
5165
+ continue;
5166
+ }
5167
+ if (trimmed.startsWith("<") || trimmed.startsWith("<%")) {
5168
+ continue;
5169
+ }
5170
+ const kind = describePugLikeLine(trimmed);
5171
+ if (kind) {
5172
+ throw new Error(`Eta view "${templateName}" contains Pug-like markup (${kind}: ${trimmed}). Eta views must be HTML + <% %> tags, not Pug.`);
5173
+ }
5174
+ }
5175
+ }
5176
+
5177
+ // ../../src/core/view/etaViewEngine.ts
5222
5178
  var DEFAULT_VIEWS_DIRECTORY = join4(process.cwd(), "resources/views");
5223
5179
  var DEFAULT_LAYOUT = "layouts/app.eta";
5224
5180
 
@@ -5231,6 +5187,12 @@ class EtaViewEngine {
5231
5187
  autoTrim: false
5232
5188
  });
5233
5189
  this.resolveLayoutData = resolveLayoutData;
5190
+ const readFile2 = this.eta.readFile?.bind(this.eta);
5191
+ this.eta.readFile = (path) => {
5192
+ const source = readFile2 ? readFile2(path) : "";
5193
+ assertEtaHtmlSource(relative(viewsDirectory, path) || path, source);
5194
+ return source;
5195
+ };
5234
5196
  }
5235
5197
  async render(name, data = {}, options = {}) {
5236
5198
  const template = name.endsWith(".eta") ? name : `${name}.eta`;
@@ -6544,9 +6506,9 @@ function currentTraceId() {
6544
6506
  return traceContextStorage.getStore()?.traceId ?? null;
6545
6507
  }
6546
6508
  // ../../src/core/tracing/otel.ts
6547
- import { randomBytes as randomBytes2 } from "crypto";
6509
+ import { randomBytes } from "crypto";
6548
6510
  function randomHex(bytes) {
6549
- return randomBytes2(bytes).toString("hex");
6511
+ return randomBytes(bytes).toString("hex");
6550
6512
  }
6551
6513
  function createSpan(input) {
6552
6514
  const spanId = randomHex(8);
@@ -6700,250 +6662,250 @@ function validateObject(payload, schema) {
6700
6662
  return output;
6701
6663
  }
6702
6664
  export {
6703
- wrapRouteHandler,
6704
- wrapMarkdownMailLayout,
6705
- withMigrationLock,
6706
- withMiddleware,
6707
- withErrorHandling,
6708
- verifyCsrfToken,
6709
- validateObject,
6710
- toResourceCollection,
6711
- toPaginatedResourceCollection,
6712
- stripMarkdown,
6713
- stringRule,
6714
- storageFacade as storage,
6715
- setActiveApplicationContext,
6716
- serializeDate,
6717
- sendMarkdownMail,
6718
- securedBindRouteModelByKey,
6719
- securedBindRouteModel,
6720
- scopedOrganizationIds,
6721
- runWithTraceContext,
6722
- runWithTenantDatabase,
6723
- runWithTenant,
6724
- runWithRequestMeta,
6725
- runWithDatabaseConnection,
6726
- runWithAuthUser,
6727
- runSeedersFromDirectory,
6728
- runQueueJob,
6729
- runInTransaction,
6730
- runGracefulShutdown,
6731
- runDueScheduledTasks,
6732
- rollbackDatabase,
6733
- resolveWebLayoutData,
6734
- resolveUserTenantId,
6735
- resolveUserId,
6736
- resolveService,
6737
- resolveRepositoryConnection,
6738
- resolveOrganizationScope,
6739
- resolveMembershipService,
6740
- resolveDatabaseDriver,
6741
- resolveCsrfTokenForRequest,
6742
- resolveCsrfToken,
6743
- resolveApplicationQueue,
6744
- resolveApplicationPolicyGate,
6745
- resolveApplicationLogger,
6746
- resolveApplicationEventBus,
6747
- resolveApplicationDependencies,
6748
- resolveApplicationConfig,
6749
- resolveApplicationCache,
6750
- resolveApplicationAuth,
6751
- resetDefaultStorage,
6752
- required,
6753
- requestIdMiddleware,
6754
- repositoryConnection,
6755
- renderMarkdownMail,
6756
- registerShutdownHandler,
6757
- registerModelRepository,
6758
- registerDefaultDatabasePool,
6759
- readSubmittedCsrfTokenFromBody,
6760
- readSubmittedCsrfToken,
6761
- readRequestCookie,
6762
- readBunRequestCookie,
6763
- rateLimitMultiplierForPlan,
6764
- queue,
6765
- prometheusRegistry,
6766
- policyGate,
6767
- parsePositiveIntParam,
6768
- parsePaginationQuery,
6769
- parseMultipartUpload,
6770
- paginatedResponse,
6771
- normalizeMetricPath,
6772
- noContentResponse,
6773
- morphTo,
6774
- morphOne,
6775
- morphMany,
6776
- modelEventName,
6777
- minLength,
6778
- migrateDatabase,
6779
- maxLength,
6780
- markdownToHtml,
6781
- mailer,
6782
- mail,
6783
- logSecurityEvent,
6784
- log,
6785
- loadSeedersFromDirectory,
6786
- loadMigrationsFromDirectory,
6787
- jsonResponse2 as jsonResponse,
6788
- jobRegistry,
6789
- isPublicReadsEnabled,
6790
- isInsideTenantDatabaseScope,
6791
- isHtmxRequest,
6792
- isGlobalAdmin,
6793
- isEtagEnabled,
6794
- installGracefulShutdownSignals,
6795
- inferReferencedTable,
6796
- indexMorphToRelation,
6797
- indexMorphOneRelation,
6798
- indexMorphManyRelation,
6799
- indexHasOneRelation,
6800
- indexHasManyRelation,
6801
- indexBelongsToRelation,
6802
- indexBelongsToManyRelation,
6803
- hydrateValue,
6804
- htmlResponse,
6805
- hasOrgMembership,
6806
- hasOne,
6807
- hasMinimumOrgRole2 as hasMinimumOrgRole,
6808
- hasMany,
6809
- guestCanViewResource,
6810
- grammarForDriver,
6811
- getMigrationStatus,
6812
- getDefaultDatabaseQuery,
6813
- getDefaultDatabasePool,
6814
- getActiveDatabaseConnection,
6815
- freshDatabase,
6816
- formatAdminValue,
6817
- filterMassAssignable,
6818
- events,
6819
- eventBus,
6820
- etagFromResource,
6821
- emptyPaginateResult,
6822
- emailRule,
6823
- dehydrateValue,
6824
- defineTable,
6825
- currentTraceId,
6826
- currentTenantId,
6827
- currentTenant,
6828
- currentRequestMeta,
6829
- currentOrganizationIds,
6830
- currentOrgRole,
6831
- currentAuthUser,
6832
- createdResponse,
6833
- createTrackedJob,
6834
- createTracingMiddleware,
6835
- createThrottleMiddleware,
6836
- createTenantMiddleware,
6837
- createStorageDriver,
6838
- createSecurityHeadersMiddleware,
6839
- createScimThrottleMiddleware,
6840
- createScimAuthMiddleware,
6841
- createSchemaBuilder,
6842
- createRequireWebAuthMiddleware,
6843
- createRequireGlobalAdminMiddleware,
6844
- createRequireAuthMiddleware,
6845
- createRequireAbilityMiddleware,
6846
- createRequestLoggingMiddleware,
6847
- createQueueWorker,
6848
- createQueue,
6849
- createProductionQueue,
6850
- createNotificationDispatcher,
6851
- createMetricsMiddleware,
6852
- createMemoryThrottleMiddleware,
6853
- createMembershipMiddleware,
6854
- createLoginThrottleMiddleware,
6855
- createFlashMiddleware,
6856
- createFailedJobService,
6857
- createDatabaseQueryProxy,
6858
- createDatabaseConnection2 as createDatabaseConnection,
6859
- createCsrfTokenCookie,
6860
- createCsrfProtection,
6861
- createCsrfMiddleware,
6862
- createCorsMiddleware,
6863
- createCacheStore,
6864
- createBodySizeLimitMiddleware,
6865
- createAuthorizeMiddleware,
6866
- createAuthMiddleware,
6867
- config,
6868
- conditionalJsonResponse,
6869
- composeMiddleware,
6870
- compileBlueprint,
6871
- collectQueueMetrics,
6872
- cache,
6873
- buildSmtpPayload,
6874
- buildRequestCacheKey,
6875
- buildMarkdownMailMessage,
6876
- bindRouteModel,
6877
- bindDatabaseConnection2 as bindDatabaseConnection,
6878
- belongsToMany,
6879
- belongsTo,
6880
- authContext,
6881
- auth,
6882
- auditChecksum,
6883
- assertResourceInCurrentTenant,
6884
- assertOrganizationReadable,
6885
- assertIfMatch,
6886
- applyMiddlewareToRoutes,
6887
- applyConditionalGet,
6888
- applyCasts,
6889
- appendProjectScope,
6890
- appendOrganizationScope,
6891
- appSchedule,
6892
- WhereBuilder,
6893
- WebFormRequest,
6894
- ValidationError,
6895
- UnsupportedSchemaFeatureError,
6896
- UnprocessableEntityError,
6897
- UnauthorizedError,
6898
- SyncQueue,
6899
- StorageManager,
6900
- SqliteGrammar,
6901
- ServiceContainer,
6902
- Schema,
6903
- Schedule,
6904
- ResilientQueue,
6905
- RepositoryQuery,
6906
- RedisQueue,
6907
- QueueWorker,
6908
- PrometheusRegistry,
6909
- PreconditionFailedError,
6910
- PostgresGrammar,
6911
- PolicyGate,
6912
- Policy,
6913
- PayloadTooLargeError,
6914
- NotificationDispatcher,
6915
- Notification,
6916
- NotFoundError,
6917
- MySqlGrammar,
6918
- Model,
6919
- membershipService_default as MembershipService,
6920
- Mailer,
6921
- LogMailDriver,
6922
- LocalStorageDriver,
6923
- Job,
6924
- HttpError,
6925
- GuestGuard,
6926
- FormRequest,
6927
- ForeignIdColumnDefinition,
6928
- ForbiddenError,
6929
- failedJobService_default as FailedJobService,
6930
- failedJobRepository_default as FailedJobRepository,
6931
- EventBus,
6932
- EtaViewEngine,
6933
- DatabaseTokenGuard,
6934
- DEFAULT_VIEWS_DIRECTORY,
6935
- DEFAULT_TENANT,
6936
- ConflictError,
6937
- ConfigStore,
6938
- CompositeGuard,
6939
- ColumnDefinition,
6940
- repository_default2 as CacheRepository,
6941
- CACHE_TAGS,
6942
- Blueprint,
6943
- baseRepository_default as BaseRepository,
6944
- BadRequestError,
6945
- AuthManager,
6946
- AsyncQueue,
6665
+ AdminResourceRegistry,
6947
6666
  ApiTokenGuard,
6948
- AdminResourceRegistry
6667
+ AsyncQueue,
6668
+ AuthManager,
6669
+ BadRequestError,
6670
+ baseRepository_default as BaseRepository,
6671
+ Blueprint,
6672
+ CACHE_TAGS,
6673
+ repository_default2 as CacheRepository,
6674
+ ColumnDefinition,
6675
+ CompositeGuard,
6676
+ ConfigStore,
6677
+ ConflictError,
6678
+ DEFAULT_TENANT,
6679
+ DEFAULT_VIEWS_DIRECTORY,
6680
+ DatabaseTokenGuard,
6681
+ EtaViewEngine,
6682
+ EventBus,
6683
+ failedJobRepository_default as FailedJobRepository,
6684
+ failedJobService_default as FailedJobService,
6685
+ ForbiddenError,
6686
+ ForeignIdColumnDefinition,
6687
+ FormRequest,
6688
+ GuestGuard,
6689
+ HttpError,
6690
+ Job,
6691
+ LocalStorageDriver,
6692
+ LogMailDriver,
6693
+ Mailer,
6694
+ membershipService_default as MembershipService,
6695
+ Model,
6696
+ MySqlGrammar,
6697
+ NotFoundError,
6698
+ Notification,
6699
+ NotificationDispatcher,
6700
+ PayloadTooLargeError,
6701
+ Policy,
6702
+ PolicyGate,
6703
+ PostgresGrammar,
6704
+ PreconditionFailedError,
6705
+ PrometheusRegistry,
6706
+ QueueWorker,
6707
+ RedisQueue,
6708
+ RepositoryQuery,
6709
+ ResilientQueue,
6710
+ Schedule,
6711
+ Schema,
6712
+ ServiceContainer,
6713
+ SqliteGrammar,
6714
+ StorageManager,
6715
+ SyncQueue,
6716
+ UnauthorizedError,
6717
+ UnprocessableEntityError,
6718
+ UnsupportedSchemaFeatureError,
6719
+ ValidationError,
6720
+ WebFormRequest,
6721
+ WhereBuilder,
6722
+ appSchedule,
6723
+ appendOrganizationScope,
6724
+ appendProjectScope,
6725
+ applyCasts,
6726
+ applyConditionalGet,
6727
+ applyMiddlewareToRoutes,
6728
+ assertIfMatch,
6729
+ assertOrganizationReadable,
6730
+ assertResourceInCurrentTenant,
6731
+ auditChecksum,
6732
+ auth,
6733
+ authContext,
6734
+ belongsTo,
6735
+ belongsToMany,
6736
+ bindDatabaseConnection2 as bindDatabaseConnection,
6737
+ bindRouteModel,
6738
+ buildMarkdownMailMessage,
6739
+ buildRequestCacheKey,
6740
+ buildSmtpPayload,
6741
+ cache,
6742
+ collectQueueMetrics,
6743
+ compileBlueprint,
6744
+ composeMiddleware,
6745
+ conditionalJsonResponse,
6746
+ config,
6747
+ createAuthMiddleware,
6748
+ createAuthorizeMiddleware,
6749
+ createBodySizeLimitMiddleware,
6750
+ createCacheStore,
6751
+ createCorsMiddleware,
6752
+ createCsrfMiddleware,
6753
+ createCsrfProtection,
6754
+ createCsrfTokenCookie,
6755
+ createDatabaseConnection2 as createDatabaseConnection,
6756
+ createDatabaseQueryProxy,
6757
+ createFailedJobService,
6758
+ createFlashMiddleware,
6759
+ createLoginThrottleMiddleware,
6760
+ createMembershipMiddleware,
6761
+ createMemoryThrottleMiddleware,
6762
+ createMetricsMiddleware,
6763
+ createNotificationDispatcher,
6764
+ createProductionQueue,
6765
+ createQueue,
6766
+ createQueueWorker,
6767
+ createRequestLoggingMiddleware,
6768
+ createRequireAbilityMiddleware,
6769
+ createRequireAuthMiddleware,
6770
+ createRequireGlobalAdminMiddleware,
6771
+ createRequireWebAuthMiddleware,
6772
+ createSchemaBuilder,
6773
+ createScimAuthMiddleware,
6774
+ createScimThrottleMiddleware,
6775
+ createSecurityHeadersMiddleware,
6776
+ createStorageDriver,
6777
+ createTenantMiddleware,
6778
+ createThrottleMiddleware,
6779
+ createTracingMiddleware,
6780
+ createTrackedJob,
6781
+ createdResponse,
6782
+ currentAuthUser,
6783
+ currentOrgRole,
6784
+ currentOrganizationIds,
6785
+ currentRequestMeta,
6786
+ currentTenant,
6787
+ currentTenantId,
6788
+ currentTraceId,
6789
+ defineTable,
6790
+ dehydrateValue,
6791
+ emailRule,
6792
+ emptyPaginateResult,
6793
+ etagFromResource,
6794
+ eventBus,
6795
+ events,
6796
+ filterMassAssignable,
6797
+ formatAdminValue,
6798
+ freshDatabase,
6799
+ getActiveDatabaseConnection,
6800
+ getDefaultDatabasePool,
6801
+ getDefaultDatabaseQuery,
6802
+ getMigrationStatus,
6803
+ grammarForDriver,
6804
+ guestCanViewResource,
6805
+ hasMany,
6806
+ hasMinimumOrgRole2 as hasMinimumOrgRole,
6807
+ hasOne,
6808
+ hasOrgMembership,
6809
+ htmlResponse,
6810
+ hydrateValue,
6811
+ indexBelongsToManyRelation,
6812
+ indexBelongsToRelation,
6813
+ indexHasManyRelation,
6814
+ indexHasOneRelation,
6815
+ indexMorphManyRelation,
6816
+ indexMorphOneRelation,
6817
+ indexMorphToRelation,
6818
+ inferReferencedTable,
6819
+ installGracefulShutdownSignals,
6820
+ isEtagEnabled,
6821
+ isGlobalAdmin,
6822
+ isHtmxRequest,
6823
+ isInsideTenantDatabaseScope,
6824
+ isPublicReadsEnabled,
6825
+ jobRegistry,
6826
+ jsonResponse2 as jsonResponse,
6827
+ loadMigrationsFromDirectory,
6828
+ loadSeedersFromDirectory,
6829
+ log,
6830
+ logSecurityEvent,
6831
+ mail,
6832
+ mailer,
6833
+ markdownToHtml,
6834
+ maxLength,
6835
+ migrateDatabase,
6836
+ minLength,
6837
+ modelEventName,
6838
+ morphMany,
6839
+ morphOne,
6840
+ morphTo,
6841
+ noContentResponse,
6842
+ normalizeMetricPath,
6843
+ paginatedResponse,
6844
+ parseMultipartUpload,
6845
+ parsePaginationQuery,
6846
+ parsePositiveIntParam,
6847
+ policyGate,
6848
+ prometheusRegistry,
6849
+ queue,
6850
+ rateLimitMultiplierForPlan,
6851
+ readBunRequestCookie,
6852
+ readRequestCookie,
6853
+ readSubmittedCsrfToken,
6854
+ readSubmittedCsrfTokenFromBody,
6855
+ registerDefaultDatabasePool,
6856
+ registerModelRepository,
6857
+ registerShutdownHandler,
6858
+ renderMarkdownMail,
6859
+ repositoryConnection,
6860
+ requestIdMiddleware,
6861
+ required,
6862
+ resetDefaultStorage,
6863
+ resolveApplicationAuth,
6864
+ resolveApplicationCache,
6865
+ resolveApplicationConfig,
6866
+ resolveApplicationDependencies,
6867
+ resolveApplicationEventBus,
6868
+ resolveApplicationLogger,
6869
+ resolveApplicationPolicyGate,
6870
+ resolveApplicationQueue,
6871
+ resolveCsrfToken,
6872
+ resolveCsrfTokenForRequest,
6873
+ resolveDatabaseDriver,
6874
+ resolveMembershipService,
6875
+ resolveOrganizationScope,
6876
+ resolveRepositoryConnection,
6877
+ resolveService,
6878
+ resolveUserId,
6879
+ resolveUserTenantId,
6880
+ resolveWebLayoutData,
6881
+ rollbackDatabase,
6882
+ runDueScheduledTasks,
6883
+ runGracefulShutdown,
6884
+ runInTransaction,
6885
+ runQueueJob,
6886
+ runSeedersFromDirectory,
6887
+ runWithAuthUser,
6888
+ runWithDatabaseConnection,
6889
+ runWithRequestMeta,
6890
+ runWithTenant,
6891
+ runWithTenantDatabase,
6892
+ runWithTraceContext,
6893
+ scopedOrganizationIds,
6894
+ securedBindRouteModel,
6895
+ securedBindRouteModelByKey,
6896
+ sendMarkdownMail,
6897
+ serializeDate,
6898
+ setActiveApplicationContext,
6899
+ storageFacade as storage,
6900
+ stringRule,
6901
+ stripMarkdown,
6902
+ toPaginatedResourceCollection,
6903
+ toResourceCollection,
6904
+ validateObject,
6905
+ verifyCsrfToken,
6906
+ withErrorHandling,
6907
+ withMiddleware,
6908
+ withMigrationLock,
6909
+ wrapMarkdownMailLayout,
6910
+ wrapRouteHandler
6949
6911
  };