@getstrata/core 1.1.8 → 2.0.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/CHANGELOG.md +23 -0
- package/dist/core/database/transaction.d.ts +2 -1
- package/dist/core/database/transactionControl.d.ts +5 -0
- package/dist/core/events/deferredModelEvents.d.ts +3 -0
- package/dist/core/events/index.d.ts +1 -0
- package/dist/core/http/loginThrottleMiddleware.d.ts +3 -0
- package/dist/core/http/metricsMiddleware.d.ts +1 -2
- package/dist/core/http/requestMetaContext.d.ts +2 -0
- package/dist/core/http/throttleMiddleware.d.ts +11 -2
- package/dist/core/metrics/prometheus.d.ts +11 -1
- package/dist/core/queue/jobRunner.d.ts +3 -1
- package/dist/core/queue/redisQueue.d.ts +20 -3
- package/dist/core/tenant/databaseTenantContext.d.ts +5 -1
- package/dist/entries/audit/exportAuditLogs.js +751 -97
- package/dist/entries/auth/accessControl.js +16 -2
- package/dist/entries/auth/basicAuthGuard.js +271 -224
- package/dist/entries/auth/membershipMiddleware.js +17 -0
- package/dist/entries/auth/membershipScope.js +21 -6
- package/dist/entries/auth/membershipService.js +20 -5
- package/dist/entries/auth/oauth/samlProvider.js +187 -142
- package/dist/entries/auth/oneTimeToken.js +142 -123
- package/dist/entries/auth/passwordLogin.js +212 -191
- package/dist/entries/auth/policy.js +16 -2
- package/dist/entries/auth/saml/samlServiceProvider.js +187 -142
- package/dist/entries/auth/scimAuthMiddleware.js +732 -64
- package/dist/entries/database/migrations.js +144 -125
- package/dist/entries/database/schema.js +58 -39
- package/dist/entries/http/csrfMiddleware.js +28 -14
- package/dist/entries/http/csrfToken.js +28 -14
- package/dist/entries/http/flashMiddleware.js +28 -14
- package/dist/entries/http/metricsMiddleware.js +124 -27
- package/dist/entries/http/response.js +107 -0
- package/dist/entries/http/routeMiddleware.js +40 -0
- package/dist/entries/http/throttleMiddleware.js +124 -11
- package/dist/entries/jobs/exportAuditLogsJob.js +751 -97
- package/dist/entries/metrics/prometheus.js +71 -11
- package/dist/entries/queue/createAppQueue.js +215 -21
- package/dist/entries/queue/jobRunner.js +3 -2
- package/dist/entries/queue/publicQueue.js +215 -21
- package/dist/entries/queue/queueMetrics.js +215 -21
- package/dist/entries/queue/redisQueue.js +223 -22
- package/dist/entries/runtime/asyncContextStore.js +16 -0
- package/dist/entries/tenant/databaseTenantContext.js +666 -11
- package/dist/entries/tenant/tenancyConfig.js +19 -1
- package/dist/entries/tenant/tenantDatabaseScope.js +688 -18
- package/dist/entries/tracing/tracingMiddleware.js +28 -14
- package/dist/framework/public-api.d.ts +3 -3
- package/dist/index.js +1344 -651
- package/package.json +1 -1
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
var __esm = (fn, res, err) => () => {
|
|
3
|
+
if (fn)
|
|
4
|
+
try {
|
|
5
|
+
res = fn(fn = 0);
|
|
6
|
+
} catch (e) {
|
|
7
|
+
err = [e];
|
|
8
|
+
}
|
|
9
|
+
if (err)
|
|
10
|
+
throw err[0];
|
|
11
|
+
return res;
|
|
12
|
+
};
|
|
6
13
|
|
|
7
14
|
// ../../src/core/runtime/asyncContextStore.ts
|
|
8
15
|
import { AsyncLocalStorage } from "async_hooks";
|
|
@@ -17,6 +24,7 @@ function createAsyncContextStore(key) {
|
|
|
17
24
|
globalRecord[symbol] = store;
|
|
18
25
|
return store;
|
|
19
26
|
}
|
|
27
|
+
var init_asyncContextStore = () => {};
|
|
20
28
|
|
|
21
29
|
// ../../src/core/database/schema/driver.ts
|
|
22
30
|
function normalizeConnectionName(connection) {
|
|
@@ -57,6 +65,7 @@ function resolveDatabaseDriver(options = {}) {
|
|
|
57
65
|
}
|
|
58
66
|
return "pgsql";
|
|
59
67
|
}
|
|
68
|
+
var init_driver = () => {};
|
|
60
69
|
|
|
61
70
|
// ../../src/core/database/dialect.ts
|
|
62
71
|
function assertSafeIdentifier(identifier) {
|
|
@@ -68,133 +77,143 @@ function assertSafeIdentifier(identifier) {
|
|
|
68
77
|
function quoteIdentifierFor(dialect, column) {
|
|
69
78
|
return dialect.quoteIdentifier(column);
|
|
70
79
|
}
|
|
71
|
-
var postgresDialect = {
|
|
72
|
-
driver: "pgsql",
|
|
73
|
-
placeholder(index) {
|
|
74
|
-
return `$${index}`;
|
|
75
|
-
},
|
|
76
|
-
quoteIdentifier(identifier) {
|
|
77
|
-
return `"${assertSafeIdentifier(identifier)}"`;
|
|
78
|
-
},
|
|
79
|
-
nowExpression() {
|
|
80
|
-
return "NOW()";
|
|
81
|
-
},
|
|
82
|
-
timestampValue(value) {
|
|
83
|
-
return value.toISOString();
|
|
84
|
-
},
|
|
85
|
-
returningClause(columns) {
|
|
86
|
-
return ` RETURNING ${columns}`;
|
|
87
|
-
},
|
|
88
|
-
ilikeOperator() {
|
|
89
|
-
return "ILIKE";
|
|
90
|
-
},
|
|
91
|
-
nullsLastSuffix() {
|
|
92
|
-
return " NULLS LAST";
|
|
93
|
-
},
|
|
94
|
-
castToText(expression) {
|
|
95
|
-
return `${expression}::text`;
|
|
96
|
-
},
|
|
97
|
-
upsertSuffix(conflictColumns, updateColumns) {
|
|
98
|
-
const target = conflictColumns.map((column) => quoteIdentifierFor(this, column)).join(", ");
|
|
99
|
-
if (updateColumns.length === 0) {
|
|
100
|
-
return ` ON CONFLICT (${target}) DO NOTHING`;
|
|
101
|
-
}
|
|
102
|
-
const assignments = updateColumns.map((column) => {
|
|
103
|
-
const quoted = quoteIdentifierFor(this, column);
|
|
104
|
-
return `${quoted} = excluded.${quoted}`;
|
|
105
|
-
}).join(", ");
|
|
106
|
-
return ` ON CONFLICT (${target}) DO UPDATE SET ${assignments}`;
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
var mysqlDialect = {
|
|
110
|
-
driver: "mysql",
|
|
111
|
-
placeholder() {
|
|
112
|
-
return "?";
|
|
113
|
-
},
|
|
114
|
-
quoteIdentifier(identifier) {
|
|
115
|
-
return `\`${assertSafeIdentifier(identifier)}\``;
|
|
116
|
-
},
|
|
117
|
-
nowExpression() {
|
|
118
|
-
return "CURRENT_TIMESTAMP";
|
|
119
|
-
},
|
|
120
|
-
timestampValue(value) {
|
|
121
|
-
return value.toISOString().slice(0, 19).replace("T", " ");
|
|
122
|
-
},
|
|
123
|
-
returningClause() {
|
|
124
|
-
return "";
|
|
125
|
-
},
|
|
126
|
-
ilikeOperator() {
|
|
127
|
-
return "LIKE";
|
|
128
|
-
},
|
|
129
|
-
nullsLastSuffix() {
|
|
130
|
-
return "";
|
|
131
|
-
},
|
|
132
|
-
castToText(expression) {
|
|
133
|
-
return `CAST(${expression} AS CHAR)`;
|
|
134
|
-
},
|
|
135
|
-
upsertSuffix(conflictColumns, updateColumns) {
|
|
136
|
-
if (updateColumns.length === 0) {
|
|
137
|
-
const anchor = quoteIdentifierFor(this, conflictColumns[0] ?? "");
|
|
138
|
-
return ` ON DUPLICATE KEY UPDATE ${anchor} = ${anchor}`;
|
|
139
|
-
}
|
|
140
|
-
const assignments = updateColumns.map((column) => {
|
|
141
|
-
const quoted = quoteIdentifierFor(this, column);
|
|
142
|
-
return `${quoted} = VALUES(${quoted})`;
|
|
143
|
-
}).join(", ");
|
|
144
|
-
return ` ON DUPLICATE KEY UPDATE ${assignments}`;
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
var sqliteDialect = {
|
|
148
|
-
driver: "sqlite",
|
|
149
|
-
placeholder() {
|
|
150
|
-
return "?";
|
|
151
|
-
},
|
|
152
|
-
quoteIdentifier(identifier) {
|
|
153
|
-
return `"${assertSafeIdentifier(identifier)}"`;
|
|
154
|
-
},
|
|
155
|
-
nowExpression() {
|
|
156
|
-
return "strftime('%Y-%m-%dT%H:%M:%fZ', 'now')";
|
|
157
|
-
},
|
|
158
|
-
timestampValue(value) {
|
|
159
|
-
return value.toISOString();
|
|
160
|
-
},
|
|
161
|
-
returningClause(columns) {
|
|
162
|
-
return ` RETURNING ${columns}`;
|
|
163
|
-
},
|
|
164
|
-
ilikeOperator() {
|
|
165
|
-
return "LIKE";
|
|
166
|
-
},
|
|
167
|
-
nullsLastSuffix() {
|
|
168
|
-
return "";
|
|
169
|
-
},
|
|
170
|
-
castToText(expression) {
|
|
171
|
-
return `CAST(${expression} AS TEXT)`;
|
|
172
|
-
},
|
|
173
|
-
upsertSuffix(conflictColumns, updateColumns) {
|
|
174
|
-
const target = conflictColumns.map((column) => quoteIdentifierFor(this, column)).join(", ");
|
|
175
|
-
if (updateColumns.length === 0) {
|
|
176
|
-
return ` ON CONFLICT (${target}) DO NOTHING`;
|
|
177
|
-
}
|
|
178
|
-
const assignments = updateColumns.map((column) => {
|
|
179
|
-
const quoted = quoteIdentifierFor(this, column);
|
|
180
|
-
return `${quoted} = excluded.${quoted}`;
|
|
181
|
-
}).join(", ");
|
|
182
|
-
return ` ON CONFLICT (${target}) DO UPDATE SET ${assignments}`;
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
var dialects = {
|
|
186
|
-
pgsql: postgresDialect,
|
|
187
|
-
mysql: mysqlDialect,
|
|
188
|
-
sqlite: sqliteDialect
|
|
189
|
-
};
|
|
190
|
-
var dialectContext = createAsyncContextStore("@getstrata/sqlDialect");
|
|
191
|
-
var dialectOverride = null;
|
|
192
80
|
function dialectFor(driver) {
|
|
193
81
|
return dialects[driver];
|
|
194
82
|
}
|
|
195
83
|
function currentSqlDialect() {
|
|
196
84
|
return dialectContext.getStore() ?? dialectOverride ?? dialectFor(resolveDatabaseDriver());
|
|
197
85
|
}
|
|
86
|
+
var postgresDialect, mysqlDialect, sqliteDialect, dialects, dialectContext, dialectOverride = null;
|
|
87
|
+
var init_dialect = __esm(() => {
|
|
88
|
+
init_asyncContextStore();
|
|
89
|
+
init_driver();
|
|
90
|
+
postgresDialect = {
|
|
91
|
+
driver: "pgsql",
|
|
92
|
+
placeholder(index) {
|
|
93
|
+
return `$${index}`;
|
|
94
|
+
},
|
|
95
|
+
quoteIdentifier(identifier) {
|
|
96
|
+
return `"${assertSafeIdentifier(identifier)}"`;
|
|
97
|
+
},
|
|
98
|
+
nowExpression() {
|
|
99
|
+
return "NOW()";
|
|
100
|
+
},
|
|
101
|
+
timestampValue(value) {
|
|
102
|
+
return value.toISOString();
|
|
103
|
+
},
|
|
104
|
+
returningClause(columns) {
|
|
105
|
+
return ` RETURNING ${columns}`;
|
|
106
|
+
},
|
|
107
|
+
ilikeOperator() {
|
|
108
|
+
return "ILIKE";
|
|
109
|
+
},
|
|
110
|
+
nullsLastSuffix() {
|
|
111
|
+
return " NULLS LAST";
|
|
112
|
+
},
|
|
113
|
+
castToText(expression) {
|
|
114
|
+
return `${expression}::text`;
|
|
115
|
+
},
|
|
116
|
+
upsertSuffix(conflictColumns, updateColumns) {
|
|
117
|
+
const target = conflictColumns.map((column) => quoteIdentifierFor(this, column)).join(", ");
|
|
118
|
+
if (updateColumns.length === 0) {
|
|
119
|
+
return ` ON CONFLICT (${target}) DO NOTHING`;
|
|
120
|
+
}
|
|
121
|
+
const assignments = updateColumns.map((column) => {
|
|
122
|
+
const quoted = quoteIdentifierFor(this, column);
|
|
123
|
+
return `${quoted} = excluded.${quoted}`;
|
|
124
|
+
}).join(", ");
|
|
125
|
+
return ` ON CONFLICT (${target}) DO UPDATE SET ${assignments}`;
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
mysqlDialect = {
|
|
129
|
+
driver: "mysql",
|
|
130
|
+
placeholder() {
|
|
131
|
+
return "?";
|
|
132
|
+
},
|
|
133
|
+
quoteIdentifier(identifier) {
|
|
134
|
+
return `\`${assertSafeIdentifier(identifier)}\``;
|
|
135
|
+
},
|
|
136
|
+
nowExpression() {
|
|
137
|
+
return "CURRENT_TIMESTAMP";
|
|
138
|
+
},
|
|
139
|
+
timestampValue(value) {
|
|
140
|
+
return value.toISOString().slice(0, 19).replace("T", " ");
|
|
141
|
+
},
|
|
142
|
+
returningClause() {
|
|
143
|
+
return "";
|
|
144
|
+
},
|
|
145
|
+
ilikeOperator() {
|
|
146
|
+
return "LIKE";
|
|
147
|
+
},
|
|
148
|
+
nullsLastSuffix() {
|
|
149
|
+
return "";
|
|
150
|
+
},
|
|
151
|
+
castToText(expression) {
|
|
152
|
+
return `CAST(${expression} AS CHAR)`;
|
|
153
|
+
},
|
|
154
|
+
upsertSuffix(conflictColumns, updateColumns) {
|
|
155
|
+
if (updateColumns.length === 0) {
|
|
156
|
+
const anchor = quoteIdentifierFor(this, conflictColumns[0] ?? "");
|
|
157
|
+
return ` ON DUPLICATE KEY UPDATE ${anchor} = ${anchor}`;
|
|
158
|
+
}
|
|
159
|
+
const assignments = updateColumns.map((column) => {
|
|
160
|
+
const quoted = quoteIdentifierFor(this, column);
|
|
161
|
+
return `${quoted} = VALUES(${quoted})`;
|
|
162
|
+
}).join(", ");
|
|
163
|
+
return ` ON DUPLICATE KEY UPDATE ${assignments}`;
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
sqliteDialect = {
|
|
167
|
+
driver: "sqlite",
|
|
168
|
+
placeholder() {
|
|
169
|
+
return "?";
|
|
170
|
+
},
|
|
171
|
+
quoteIdentifier(identifier) {
|
|
172
|
+
return `"${assertSafeIdentifier(identifier)}"`;
|
|
173
|
+
},
|
|
174
|
+
nowExpression() {
|
|
175
|
+
return "strftime('%Y-%m-%dT%H:%M:%fZ', 'now')";
|
|
176
|
+
},
|
|
177
|
+
timestampValue(value) {
|
|
178
|
+
return value.toISOString();
|
|
179
|
+
},
|
|
180
|
+
returningClause(columns) {
|
|
181
|
+
return ` RETURNING ${columns}`;
|
|
182
|
+
},
|
|
183
|
+
ilikeOperator() {
|
|
184
|
+
return "LIKE";
|
|
185
|
+
},
|
|
186
|
+
nullsLastSuffix() {
|
|
187
|
+
return "";
|
|
188
|
+
},
|
|
189
|
+
castToText(expression) {
|
|
190
|
+
return `CAST(${expression} AS TEXT)`;
|
|
191
|
+
},
|
|
192
|
+
upsertSuffix(conflictColumns, updateColumns) {
|
|
193
|
+
const target = conflictColumns.map((column) => quoteIdentifierFor(this, column)).join(", ");
|
|
194
|
+
if (updateColumns.length === 0) {
|
|
195
|
+
return ` ON CONFLICT (${target}) DO NOTHING`;
|
|
196
|
+
}
|
|
197
|
+
const assignments = updateColumns.map((column) => {
|
|
198
|
+
const quoted = quoteIdentifierFor(this, column);
|
|
199
|
+
return `${quoted} = excluded.${quoted}`;
|
|
200
|
+
}).join(", ");
|
|
201
|
+
return ` ON CONFLICT (${target}) DO UPDATE SET ${assignments}`;
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
dialects = {
|
|
205
|
+
pgsql: postgresDialect,
|
|
206
|
+
mysql: mysqlDialect,
|
|
207
|
+
sqlite: sqliteDialect
|
|
208
|
+
};
|
|
209
|
+
dialectContext = createAsyncContextStore("@getstrata/sqlDialect");
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
// ../../src/core/database/migrations/runner.ts
|
|
213
|
+
init_dialect();
|
|
214
|
+
import { readdir } from "fs/promises";
|
|
215
|
+
import { join } from "path";
|
|
216
|
+
import { pathToFileURL } from "url";
|
|
198
217
|
|
|
199
218
|
// ../../src/core/database/migrations/advisoryLock.ts
|
|
200
219
|
var MIGRATION_LOCK_KEY = 42424242;
|
|
@@ -1,4 +1,57 @@
|
|
|
1
1
|
// @bun
|
|
2
|
+
var __esm = (fn, res, err) => () => {
|
|
3
|
+
if (fn)
|
|
4
|
+
try {
|
|
5
|
+
res = fn(fn = 0);
|
|
6
|
+
} catch (e) {
|
|
7
|
+
err = [e];
|
|
8
|
+
}
|
|
9
|
+
if (err)
|
|
10
|
+
throw err[0];
|
|
11
|
+
return res;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// ../../src/core/database/schema/driver.ts
|
|
15
|
+
function normalizeConnectionName(connection) {
|
|
16
|
+
const normalized = connection.trim().toLowerCase();
|
|
17
|
+
if (normalized === "pgsql" || normalized === "postgres" || normalized === "postgresql") {
|
|
18
|
+
return "pgsql";
|
|
19
|
+
}
|
|
20
|
+
if (normalized === "mysql" || normalized === "mariadb") {
|
|
21
|
+
return "mysql";
|
|
22
|
+
}
|
|
23
|
+
if (normalized === "sqlite") {
|
|
24
|
+
return "sqlite";
|
|
25
|
+
}
|
|
26
|
+
throw new Error(`Unsupported DB_CONNECTION: ${connection}`);
|
|
27
|
+
}
|
|
28
|
+
function resolveDriverFromUrl(url) {
|
|
29
|
+
const normalized = url.trim().toLowerCase();
|
|
30
|
+
if (normalized.startsWith("postgres://") || normalized.startsWith("postgresql://") || normalized.startsWith("postgres:")) {
|
|
31
|
+
return "pgsql";
|
|
32
|
+
}
|
|
33
|
+
if (normalized.startsWith("mysql://") || normalized.startsWith("mysql:")) {
|
|
34
|
+
return "mysql";
|
|
35
|
+
}
|
|
36
|
+
if (normalized.startsWith("sqlite:")) {
|
|
37
|
+
return "sqlite";
|
|
38
|
+
}
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
function resolveDatabaseDriver(options = {}) {
|
|
42
|
+
const connection = options.connection ?? process.env.DB_CONNECTION;
|
|
43
|
+
if (connection) {
|
|
44
|
+
return normalizeConnectionName(connection);
|
|
45
|
+
}
|
|
46
|
+
const url = options.url ?? process.env.DATABASE_URL ?? "";
|
|
47
|
+
const fromUrl = resolveDriverFromUrl(url);
|
|
48
|
+
if (fromUrl) {
|
|
49
|
+
return fromUrl;
|
|
50
|
+
}
|
|
51
|
+
return "pgsql";
|
|
52
|
+
}
|
|
53
|
+
var init_driver = () => {};
|
|
54
|
+
|
|
2
55
|
// ../../src/core/database/schema/columnDefinition.ts
|
|
3
56
|
class ColumnDefinition {
|
|
4
57
|
name;
|
|
@@ -220,45 +273,10 @@ class Blueprint {
|
|
|
220
273
|
});
|
|
221
274
|
}
|
|
222
275
|
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
return "pgsql";
|
|
228
|
-
}
|
|
229
|
-
if (normalized === "mysql" || normalized === "mariadb") {
|
|
230
|
-
return "mysql";
|
|
231
|
-
}
|
|
232
|
-
if (normalized === "sqlite") {
|
|
233
|
-
return "sqlite";
|
|
234
|
-
}
|
|
235
|
-
throw new Error(`Unsupported DB_CONNECTION: ${connection}`);
|
|
236
|
-
}
|
|
237
|
-
function resolveDriverFromUrl(url) {
|
|
238
|
-
const normalized = url.trim().toLowerCase();
|
|
239
|
-
if (normalized.startsWith("postgres://") || normalized.startsWith("postgresql://") || normalized.startsWith("postgres:")) {
|
|
240
|
-
return "pgsql";
|
|
241
|
-
}
|
|
242
|
-
if (normalized.startsWith("mysql://") || normalized.startsWith("mysql:")) {
|
|
243
|
-
return "mysql";
|
|
244
|
-
}
|
|
245
|
-
if (normalized.startsWith("sqlite:")) {
|
|
246
|
-
return "sqlite";
|
|
247
|
-
}
|
|
248
|
-
return null;
|
|
249
|
-
}
|
|
250
|
-
function resolveDatabaseDriver(options = {}) {
|
|
251
|
-
const connection = options.connection ?? process.env.DB_CONNECTION;
|
|
252
|
-
if (connection) {
|
|
253
|
-
return normalizeConnectionName(connection);
|
|
254
|
-
}
|
|
255
|
-
const url = options.url ?? process.env.DATABASE_URL ?? "";
|
|
256
|
-
const fromUrl = resolveDriverFromUrl(url);
|
|
257
|
-
if (fromUrl) {
|
|
258
|
-
return fromUrl;
|
|
259
|
-
}
|
|
260
|
-
return "pgsql";
|
|
261
|
-
}
|
|
276
|
+
|
|
277
|
+
// ../../src/core/database/schema/index.ts
|
|
278
|
+
init_driver();
|
|
279
|
+
|
|
262
280
|
// ../../src/core/database/schema/errors.ts
|
|
263
281
|
class UnsupportedSchemaFeatureError extends Error {
|
|
264
282
|
constructor(feature, driver) {
|
|
@@ -1084,6 +1102,7 @@ function grammarForDriver(driver) {
|
|
|
1084
1102
|
}
|
|
1085
1103
|
}
|
|
1086
1104
|
// ../../src/core/database/schema/schema.ts
|
|
1105
|
+
init_driver();
|
|
1087
1106
|
class SchemaBuilder {
|
|
1088
1107
|
#driver;
|
|
1089
1108
|
#statements = [];
|
|
@@ -1,4 +1,31 @@
|
|
|
1
1
|
// @bun
|
|
2
|
+
var __esm = (fn, res, err) => () => {
|
|
3
|
+
if (fn)
|
|
4
|
+
try {
|
|
5
|
+
res = fn(fn = 0);
|
|
6
|
+
} catch (e) {
|
|
7
|
+
err = [e];
|
|
8
|
+
}
|
|
9
|
+
if (err)
|
|
10
|
+
throw err[0];
|
|
11
|
+
return res;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// ../../src/core/runtime/asyncContextStore.ts
|
|
15
|
+
import { AsyncLocalStorage } from "async_hooks";
|
|
16
|
+
function createAsyncContextStore(key) {
|
|
17
|
+
const symbol = Symbol.for(key);
|
|
18
|
+
const globalRecord = globalThis;
|
|
19
|
+
const existing = globalRecord[symbol];
|
|
20
|
+
if (existing) {
|
|
21
|
+
return existing;
|
|
22
|
+
}
|
|
23
|
+
const store = new AsyncLocalStorage;
|
|
24
|
+
globalRecord[symbol] = store;
|
|
25
|
+
return store;
|
|
26
|
+
}
|
|
27
|
+
var init_asyncContextStore = () => {};
|
|
28
|
+
|
|
2
29
|
// ../../src/core/http/csrfMiddleware.ts
|
|
3
30
|
import { currentCredentialSource } from "@getstrata/core/auth/authContext";
|
|
4
31
|
import { ForbiddenError } from "@getstrata/core/errors/http";
|
|
@@ -120,21 +147,8 @@ function readBunRequestCookie(request, name) {
|
|
|
120
147
|
return request.cookies.get(name) ?? readRequestCookie(request, name);
|
|
121
148
|
}
|
|
122
149
|
|
|
123
|
-
// ../../src/core/runtime/asyncContextStore.ts
|
|
124
|
-
import { AsyncLocalStorage } from "async_hooks";
|
|
125
|
-
function createAsyncContextStore(key) {
|
|
126
|
-
const symbol = Symbol.for(key);
|
|
127
|
-
const globalRecord = globalThis;
|
|
128
|
-
const existing = globalRecord[symbol];
|
|
129
|
-
if (existing) {
|
|
130
|
-
return existing;
|
|
131
|
-
}
|
|
132
|
-
const store = new AsyncLocalStorage;
|
|
133
|
-
globalRecord[symbol] = store;
|
|
134
|
-
return store;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
150
|
// ../../src/core/http/requestMetaContext.ts
|
|
151
|
+
init_asyncContextStore();
|
|
138
152
|
var requestMetaContext = createAsyncContextStore("@getstrata/requestMetaContext");
|
|
139
153
|
function runWithRequestMeta(meta, callback) {
|
|
140
154
|
return requestMetaContext.run(meta, callback);
|
|
@@ -1,4 +1,31 @@
|
|
|
1
1
|
// @bun
|
|
2
|
+
var __esm = (fn, res, err) => () => {
|
|
3
|
+
if (fn)
|
|
4
|
+
try {
|
|
5
|
+
res = fn(fn = 0);
|
|
6
|
+
} catch (e) {
|
|
7
|
+
err = [e];
|
|
8
|
+
}
|
|
9
|
+
if (err)
|
|
10
|
+
throw err[0];
|
|
11
|
+
return res;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// ../../src/core/runtime/asyncContextStore.ts
|
|
15
|
+
import { AsyncLocalStorage } from "async_hooks";
|
|
16
|
+
function createAsyncContextStore(key) {
|
|
17
|
+
const symbol = Symbol.for(key);
|
|
18
|
+
const globalRecord = globalThis;
|
|
19
|
+
const existing = globalRecord[symbol];
|
|
20
|
+
if (existing) {
|
|
21
|
+
return existing;
|
|
22
|
+
}
|
|
23
|
+
const store = new AsyncLocalStorage;
|
|
24
|
+
globalRecord[symbol] = store;
|
|
25
|
+
return store;
|
|
26
|
+
}
|
|
27
|
+
var init_asyncContextStore = () => {};
|
|
28
|
+
|
|
2
29
|
// ../../src/core/http/csrfToken.ts
|
|
3
30
|
import { timingSafeEqual } from "crypto";
|
|
4
31
|
|
|
@@ -116,21 +143,8 @@ function readBunRequestCookie(request, name) {
|
|
|
116
143
|
return request.cookies.get(name) ?? readRequestCookie(request, name);
|
|
117
144
|
}
|
|
118
145
|
|
|
119
|
-
// ../../src/core/runtime/asyncContextStore.ts
|
|
120
|
-
import { AsyncLocalStorage } from "async_hooks";
|
|
121
|
-
function createAsyncContextStore(key) {
|
|
122
|
-
const symbol = Symbol.for(key);
|
|
123
|
-
const globalRecord = globalThis;
|
|
124
|
-
const existing = globalRecord[symbol];
|
|
125
|
-
if (existing) {
|
|
126
|
-
return existing;
|
|
127
|
-
}
|
|
128
|
-
const store = new AsyncLocalStorage;
|
|
129
|
-
globalRecord[symbol] = store;
|
|
130
|
-
return store;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
146
|
// ../../src/core/http/requestMetaContext.ts
|
|
147
|
+
init_asyncContextStore();
|
|
134
148
|
var requestMetaContext = createAsyncContextStore("@getstrata/requestMetaContext");
|
|
135
149
|
function runWithRequestMeta(meta, callback) {
|
|
136
150
|
return requestMetaContext.run(meta, callback);
|
|
@@ -1,4 +1,31 @@
|
|
|
1
1
|
// @bun
|
|
2
|
+
var __esm = (fn, res, err) => () => {
|
|
3
|
+
if (fn)
|
|
4
|
+
try {
|
|
5
|
+
res = fn(fn = 0);
|
|
6
|
+
} catch (e) {
|
|
7
|
+
err = [e];
|
|
8
|
+
}
|
|
9
|
+
if (err)
|
|
10
|
+
throw err[0];
|
|
11
|
+
return res;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// ../../src/core/runtime/asyncContextStore.ts
|
|
15
|
+
import { AsyncLocalStorage } from "async_hooks";
|
|
16
|
+
function createAsyncContextStore(key) {
|
|
17
|
+
const symbol = Symbol.for(key);
|
|
18
|
+
const globalRecord = globalThis;
|
|
19
|
+
const existing = globalRecord[symbol];
|
|
20
|
+
if (existing) {
|
|
21
|
+
return existing;
|
|
22
|
+
}
|
|
23
|
+
const store = new AsyncLocalStorage;
|
|
24
|
+
globalRecord[symbol] = store;
|
|
25
|
+
return store;
|
|
26
|
+
}
|
|
27
|
+
var init_asyncContextStore = () => {};
|
|
28
|
+
|
|
2
29
|
// ../../src/core/http/flashSession.ts
|
|
3
30
|
import { createHmac, timingSafeEqual } from "crypto";
|
|
4
31
|
|
|
@@ -191,21 +218,8 @@ function withFlashClear(response) {
|
|
|
191
218
|
});
|
|
192
219
|
}
|
|
193
220
|
|
|
194
|
-
// ../../src/core/runtime/asyncContextStore.ts
|
|
195
|
-
import { AsyncLocalStorage } from "async_hooks";
|
|
196
|
-
function createAsyncContextStore(key) {
|
|
197
|
-
const symbol = Symbol.for(key);
|
|
198
|
-
const globalRecord = globalThis;
|
|
199
|
-
const existing = globalRecord[symbol];
|
|
200
|
-
if (existing) {
|
|
201
|
-
return existing;
|
|
202
|
-
}
|
|
203
|
-
const store = new AsyncLocalStorage;
|
|
204
|
-
globalRecord[symbol] = store;
|
|
205
|
-
return store;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
221
|
// ../../src/core/http/requestMetaContext.ts
|
|
222
|
+
init_asyncContextStore();
|
|
209
223
|
var requestMetaContext = createAsyncContextStore("@getstrata/requestMetaContext");
|
|
210
224
|
function runWithRequestMeta(meta, callback) {
|
|
211
225
|
return requestMetaContext.run(meta, callback);
|