@lango-project/lango-server 0.2.2 → 0.2.4

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 (158) hide show
  1. package/README.md +252 -29
  2. package/dist/.lango/runtime.mjs +16 -0
  3. package/dist/body_reader.mjs +15 -14
  4. package/dist/body_reader.mjs.map +1 -1
  5. package/dist/builder.mjs +26 -2
  6. package/dist/builder.mjs.map +1 -1
  7. package/dist/cli/.lango/runtime.mjs +16 -0
  8. package/dist/cli/body_reader.mjs +15 -14
  9. package/dist/cli/body_reader.mjs.map +1 -1
  10. package/dist/cli/client_identity.mjs +250 -0
  11. package/dist/cli/client_identity.mjs.map +1 -0
  12. package/dist/cli/database.mjs +23 -8
  13. package/dist/cli/database.mjs.map +1 -1
  14. package/dist/cli/database_scope.mjs +11 -0
  15. package/dist/cli/database_scope.mjs.map +1 -1
  16. package/dist/cli/endpoint.mjs +11 -7
  17. package/dist/cli/endpoint.mjs.map +1 -1
  18. package/dist/cli/longpoll_broker.mjs +9 -8
  19. package/dist/cli/longpoll_broker.mjs.map +1 -1
  20. package/dist/cli/longpoll_options.mjs +8 -7
  21. package/dist/cli/longpoll_options.mjs.map +1 -1
  22. package/dist/cli/longpoll_session.mjs +11 -10
  23. package/dist/cli/longpoll_session.mjs.map +1 -1
  24. package/dist/cli/middleware.mjs +1 -1
  25. package/dist/cli/middleware.mjs.map +1 -1
  26. package/dist/cli/options.mjs +41 -4
  27. package/dist/cli/options.mjs.map +1 -1
  28. package/dist/cli/origin.mjs +87 -0
  29. package/dist/cli/origin.mjs.map +1 -0
  30. package/dist/cli/policy.mjs +121 -0
  31. package/dist/cli/policy.mjs.map +1 -0
  32. package/dist/cli/postgres_adapter.mjs +15 -3
  33. package/dist/cli/postgres_adapter.mjs.map +1 -1
  34. package/dist/cli/routes.mjs +69 -18
  35. package/dist/cli/routes.mjs.map +1 -1
  36. package/dist/cli/server.mjs +88 -81
  37. package/dist/cli/server.mjs.map +1 -1
  38. package/dist/cli/static_files.mjs +5 -4
  39. package/dist/cli/static_files.mjs.map +1 -1
  40. package/dist/client_identity.mjs +250 -0
  41. package/dist/client_identity.mjs.map +1 -0
  42. package/dist/database.mjs +23 -8
  43. package/dist/database.mjs.map +1 -1
  44. package/dist/database_action.mjs +71 -0
  45. package/dist/database_action.mjs.map +1 -0
  46. package/dist/database_scope.mjs +11 -0
  47. package/dist/database_scope.mjs.map +1 -1
  48. package/dist/endpoint.mjs +11 -7
  49. package/dist/endpoint.mjs.map +1 -1
  50. package/dist/execution_failure.mjs +30 -0
  51. package/dist/execution_failure.mjs.map +1 -0
  52. package/dist/execution_identity.mjs +103 -0
  53. package/dist/execution_identity.mjs.map +1 -0
  54. package/dist/execution_log.mjs +47 -0
  55. package/dist/execution_log.mjs.map +1 -0
  56. package/dist/execution_runtime.mjs +201 -0
  57. package/dist/execution_runtime.mjs.map +1 -0
  58. package/dist/execution_worker.mjs +41 -0
  59. package/dist/execution_worker.mjs.map +1 -0
  60. package/dist/executor.mjs +384 -0
  61. package/dist/executor.mjs.map +1 -0
  62. package/dist/group.mjs +49 -16
  63. package/dist/group.mjs.map +1 -1
  64. package/dist/http_failure.mjs +9 -2
  65. package/dist/http_failure.mjs.map +1 -1
  66. package/dist/job_configuration.mjs +37 -0
  67. package/dist/job_configuration.mjs.map +1 -0
  68. package/dist/job_context.mjs +61 -0
  69. package/dist/job_context.mjs.map +1 -0
  70. package/dist/library.mjs +31 -0
  71. package/dist/library.mjs.map +1 -1
  72. package/dist/longpoll_broker.mjs +9 -8
  73. package/dist/longpoll_broker.mjs.map +1 -1
  74. package/dist/longpoll_options.mjs +8 -7
  75. package/dist/longpoll_options.mjs.map +1 -1
  76. package/dist/longpoll_session.mjs +11 -10
  77. package/dist/longpoll_session.mjs.map +1 -1
  78. package/dist/middleware.mjs +1 -1
  79. package/dist/middleware.mjs.map +1 -1
  80. package/dist/module_loader.mjs +44 -0
  81. package/dist/module_loader.mjs.map +1 -0
  82. package/dist/options.mjs +41 -4
  83. package/dist/options.mjs.map +1 -1
  84. package/dist/origin.mjs +87 -0
  85. package/dist/origin.mjs.map +1 -0
  86. package/dist/policy.mjs +121 -0
  87. package/dist/policy.mjs.map +1 -0
  88. package/dist/postgres_adapter.mjs +15 -3
  89. package/dist/postgres_adapter.mjs.map +1 -1
  90. package/dist/postgres_worker.mjs +82 -19
  91. package/dist/postgres_worker.mjs.map +1 -1
  92. package/dist/queue_provider.mjs +52 -0
  93. package/dist/queue_provider.mjs.map +1 -0
  94. package/dist/response.mjs +1 -1
  95. package/dist/response.mjs.map +1 -1
  96. package/dist/route_info.mjs +1 -1
  97. package/dist/route_info.mjs.map +1 -1
  98. package/dist/routes.mjs +69 -18
  99. package/dist/routes.mjs.map +1 -1
  100. package/dist/runtime.mjs +287 -132
  101. package/dist/runtime.mjs.map +1 -1
  102. package/dist/server.mjs +88 -81
  103. package/dist/server.mjs.map +1 -1
  104. package/dist/server_context.mjs +21 -9
  105. package/dist/server_context.mjs.map +1 -1
  106. package/dist/static_files.mjs +5 -4
  107. package/dist/static_files.mjs.map +1 -1
  108. package/dist/token.mjs +34 -7
  109. package/dist/token.mjs.map +1 -1
  110. package/dist/tokens.mjs +11 -2
  111. package/dist/tokens.mjs.map +1 -1
  112. package/dist/worker.mjs +7 -6
  113. package/dist/worker.mjs.map +1 -1
  114. package/docs/jobs.md +123 -0
  115. package/docs/security.md +420 -0
  116. package/examples/security/README.md +160 -0
  117. package/examples/security/deploy.xml +12 -0
  118. package/examples/security/handlers.lango +610 -0
  119. package/examples/security/package.json +19 -0
  120. package/examples/security/passwords.lango +61 -0
  121. package/examples/security/routes.xml +14 -0
  122. package/examples/security/schema.lango +91 -0
  123. package/examples/security/setup.lango +30 -0
  124. package/package.json +14 -6
  125. package/src/builder.lango +22 -0
  126. package/src/client_identity.lango +184 -0
  127. package/src/database.lango +15 -4
  128. package/src/database_action.lango +30 -0
  129. package/src/database_scope.lango +7 -0
  130. package/src/endpoint.lango +12 -5
  131. package/src/execution_failure.lango +14 -0
  132. package/src/execution_identity.lango +71 -0
  133. package/src/execution_log.lango +28 -0
  134. package/src/execution_runtime.lango +135 -0
  135. package/src/execution_worker.lango +32 -0
  136. package/src/executor.lango +284 -0
  137. package/src/group.lango +36 -21
  138. package/src/http_failure.lango +9 -5
  139. package/src/job_configuration.lango +29 -0
  140. package/src/job_context.lango +44 -0
  141. package/src/library.lango +21 -0
  142. package/src/longpoll_options.lango +11 -5
  143. package/src/middleware.lango +1 -1
  144. package/src/module_loader.lango +25 -0
  145. package/src/options.lango +41 -2
  146. package/src/origin.lango +56 -0
  147. package/src/policy.lango +84 -0
  148. package/src/postgres_adapter.lango +12 -0
  149. package/src/postgres_worker.lango +54 -3
  150. package/src/queue_provider.lango +30 -0
  151. package/src/response.lango +1 -1
  152. package/src/route_info.lango +2 -0
  153. package/src/routes.lango +74 -15
  154. package/src/runtime.lango +173 -94
  155. package/src/server.lango +9 -2
  156. package/src/server_context.lango +10 -2
  157. package/src/token.lango +26 -5
  158. package/src/tokens.lango +10 -3
package/dist/runtime.mjs CHANGED
@@ -1,3 +1,7 @@
1
+ import { ModuleLoader } from "./module_loader.mjs";
2
+ import { routeInfo } from "./route_info.mjs";
3
+ import { ClientIdentity } from "./client_identity.mjs";
4
+ import { originAllowed } from "./origin.mjs";
1
5
  import { trace } from "./trace.mjs";
2
6
  import { routePattern, matchPath, moreSpecific } from "./route_pattern.mjs";
3
7
  import { ServerContext } from "./server_context.mjs";
@@ -8,6 +12,7 @@ import { Response } from "./response.mjs";
8
12
  import { HttpFailure } from "./http_failure.mjs";
9
13
  import { requestIdentity } from "./request_identity.mjs";
10
14
  import { errorDetails, errorMessage } from "./error_details.mjs";
15
+ import * as crypto from "node:crypto";
11
16
  import * as threads from "node:worker_threads";
12
17
  import {
13
18
  hostGlobal as __hostGlobal,
@@ -15,6 +20,9 @@ import {
15
20
  contextGet as __contextGet,
16
21
  contextSet as __contextSet,
17
22
  contextRestore as __contextRestore,
23
+ bindContexts as __bindContexts,
24
+ fromJson as __fromJson,
25
+ toJson as __toJson,
18
26
  getClass as __getClass,
19
27
  isKindof as __isKindof,
20
28
  isNumber as __isNumber,
@@ -40,30 +48,44 @@ export class Runtime {
40
48
  #routes;
41
49
  #events;
42
50
  #tokens;
43
- #modules;
51
+ #loader;
52
+ #queueFactory;
44
53
  #middlewares;
45
54
  #database;
55
+ #clients;
46
56
  constructor(definition) {
47
57
  __requireArity(arguments.length, [0], "constructor");
48
58
  definition = __boundary(definition);
49
- let refresh = __withArity((tokens) => {
59
+ let refresh = __withArity(__bindContexts((tokens) => {
50
60
  tokens = __boundary(tokens);
51
61
  return this.refreshTokens(tokens);
52
62
  return null;
53
- }, [0], "closure");
54
- this.#serverContext = new ServerContext(__normalize(definition.routes), refresh);
63
+ }), [0], "closure");
64
+ let rotate = __bindContexts(() => {
65
+ return this.#rotateClient();
66
+ return null;
67
+ });
68
+ this.#serverContext = new ServerContext(__normalize(definition.routes), refresh, rotate);
55
69
  this.#definition = definition;
56
70
  this.#routes = [];
57
71
  this.#events = { };
58
72
  this.#tokens = new Tokens(__normalize(definition.settings));
59
- this.#modules = { };
73
+ this.#loader = new ModuleLoader();
74
+ this.#queueFactory = null;
60
75
  this.#middlewares = __normalize(__hostGlobal(["Object"]).create(null));
61
76
  this.#database = new Database(definition.settings.database, definition.settings.root);
77
+ this.#clients = null;
78
+ if (__requireBoolean(definition.settings.client !== null)) {
79
+ this.#clients = new ClientIdentity(definition.settings.client, __normalize(this.#database));
80
+ }
62
81
  }
63
82
  preload() {
64
83
  trace(`Worker ${__normalize(threads.threadId)}: preparing database, middleware, routes and events`);
65
84
  let definitions = __normalize(this.#definition.routes);
66
85
  let pending = __normalize(this.#database.open());
86
+ if (__requireBoolean(__normalize(this.#definition.queueProvider) !== null)) {
87
+ pending = this.#prepareQueue(pending);
88
+ }
67
89
  if (__requireBoolean(__normalize(this.#definition.middlewares) !== null)) {
68
90
  for (const [name, spec] of __entries(__normalize(this.#definition.middlewares))) {
69
91
  pending = this.#prepareMiddleware(pending, name, spec);
@@ -76,12 +98,12 @@ export class Runtime {
76
98
  for (const [name, target] of __entries(events)) {
77
99
  pending = this.#prepareEvent(pending, name, target);
78
100
  }
79
- return pending.catch(__withArity((error) => {
101
+ return pending.catch(__withArity(__bindContexts((error) => {
80
102
  error = __boundary(error);
81
103
  this.close();
82
104
  throw error;
83
105
  return null;
84
- }, [0], "closure"));
106
+ }), [0], "closure"));
85
107
  return null;
86
108
  }
87
109
  close() {
@@ -89,16 +111,39 @@ export class Runtime {
89
111
  return null;
90
112
  return null;
91
113
  }
114
+ #prepareQueue(pending) {
115
+ __requireArity(arguments.length, [0], "prepareQueue");
116
+ pending = __boundary(pending);
117
+ return pending.then(__withArity(__bindContexts((ignored) => {
118
+ ignored = __boundary(ignored);
119
+ return __normalize(this.#loader.target(__normalize(this.#definition.queueProvider)));
120
+ return null;
121
+ }), [0], "closure")).then(__withArity(__bindContexts((factory) => {
122
+ factory = __boundary(factory);
123
+ this.#queueFactory = factory;
124
+ return null;
125
+ return null;
126
+ }), [0], "closure"));
127
+ return null;
128
+ }
129
+ #queueSender() {
130
+ if (__requireBoolean(__normalize(this.#queueFactory) === null)) {
131
+ return null;
132
+ }
133
+ let factory = __normalize(this.#queueFactory);
134
+ return __call(factory, __normalize(this.#definition.queueProvider.options));
135
+ return null;
136
+ }
92
137
  #prepareMiddleware(pending, name, spec) {
93
138
  __requireArity(arguments.length, [0, 1, 2], "prepareMiddleware");
94
139
  pending = __boundary(pending);
95
140
  name = __boundary(name);
96
141
  spec = __boundary(spec);
97
- return pending.then(__withArity((ignored) => {
142
+ return pending.then(__withArity(__bindContexts((ignored) => {
98
143
  ignored = __boundary(ignored);
99
144
  return this.#target(spec);
100
145
  return null;
101
- }, [0], "closure")).then(__withArity((handler) => {
146
+ }), [0], "closure")).then(__withArity(__bindContexts((handler) => {
102
147
  handler = __boundary(handler);
103
148
  this.#middlewares[name] = handler;
104
149
  if (__requireBoolean(__normalize(spec.validate) !== null)) {
@@ -106,14 +151,14 @@ export class Runtime {
106
151
  }
107
152
  return null;
108
153
  return null;
109
- }, [0], "closure")).then(__withArity((validator) => {
154
+ }), [0], "closure")).then(__withArity(__bindContexts((validator) => {
110
155
  validator = __boundary(validator);
111
156
  if (__requireBoolean(validator !== null)) {
112
157
  return __call(validator, __normalize(this.#serverContext.routes()));
113
158
  }
114
159
  return null;
115
160
  return null;
116
- }, [0], "closure"));
161
+ }), [0], "closure"));
117
162
  return null;
118
163
  }
119
164
  #prepareRoute(pending, route) {
@@ -126,11 +171,11 @@ export class Runtime {
126
171
  __add(this.#routes, prepared);
127
172
  return pending;
128
173
  }
129
- return pending.then(__withArity((ignored) => {
174
+ return pending.then(__withArity(__bindContexts((ignored) => {
130
175
  ignored = __boundary(ignored);
131
176
  return this.#target(route);
132
177
  return null;
133
- }, [0], "closure")).then(__withArity((handler) => {
178
+ }), [0], "closure")).then(__withArity(__bindContexts((handler) => {
134
179
  handler = __boundary(handler);
135
180
  let middleware = null;
136
181
  let name = __normalize(route.middleware);
@@ -140,10 +185,10 @@ export class Runtime {
140
185
  }
141
186
  middleware = __normalize(this.#middlewares[name]);
142
187
  }
143
- __add(this.#routes, { path: __normalize(route.path), pattern: routePattern(__normalize(route.path)), auth: __normalize(route.auth), handler: handler, middleware: middleware });
188
+ __add(this.#routes, { path: __normalize(route.path), pattern: routePattern(__normalize(route.path)), auth: __normalize(route.auth), policy: __normalize(route.policy), reauthSeconds: __normalize(route.reauthSeconds), legacyAuth: __normalize(route.legacyAuth), handler: handler, middleware: middleware });
144
189
  return null;
145
190
  return null;
146
- }, [0], "closure"));
191
+ }), [0], "closure"));
147
192
  return null;
148
193
  }
149
194
  #prepareEvent(pending, name, spec) {
@@ -151,16 +196,16 @@ export class Runtime {
151
196
  pending = __boundary(pending);
152
197
  name = __boundary(name);
153
198
  spec = __boundary(spec);
154
- return pending.then(__withArity((ignored) => {
199
+ return pending.then(__withArity(__bindContexts((ignored) => {
155
200
  ignored = __boundary(ignored);
156
201
  return this.#target(spec);
157
202
  return null;
158
- }, [0], "closure")).then(__withArity((handler) => {
203
+ }), [0], "closure")).then(__withArity(__bindContexts((handler) => {
159
204
  handler = __boundary(handler);
160
205
  this.#events[name] = handler;
161
206
  return null;
162
207
  return null;
163
- }, [0], "closure"));
208
+ }), [0], "closure"));
164
209
  return null;
165
210
  }
166
211
  #target(spec) {
@@ -168,15 +213,7 @@ export class Runtime {
168
213
  spec = __boundary(spec);
169
214
  let file = __normalize(spec.module);
170
215
  trace(`Worker ${__normalize(threads.threadId)}: resolving ${file} export ${__normalize(spec.handler)}`);
171
- if (__requireBoolean(__includes(file, __normalize(this.#modules)))) {
172
- return __normalize(__hostGlobal(["Promise"]).resolve(exported(__normalize(this.#modules[file]), __normalize(spec.handler))));
173
- }
174
- return import(file).then(__withArity((mod) => {
175
- mod = __boundary(mod);
176
- this.#modules[file] = mod;
177
- return exported(mod, __normalize(spec.handler));
178
- return null;
179
- }, [0], "closure"));
216
+ return __normalize(this.#loader.target(spec));
180
217
  return null;
181
218
  }
182
219
  #match(path) {
@@ -208,12 +245,13 @@ export class Runtime {
208
245
  __contextScope.push(__contextSet("server", __normalize(this.#serverContext)));
209
246
  __contextScope.push(__contextSet("request", __normalize(__hostGlobal(["Object"]).freeze(__normalize(task.request)))));
210
247
  __contextScope.push(__contextSet("response", new Response()));
248
+ if (__requireBoolean(!__requireBoolean(originAllowed(__normalize(this.#definition.settings.origin), __contextGet("request"))))) {
249
+ return failure(403, "OriginRejected");
250
+ }
211
251
  let fresh = __normalize(__contextGet("request").headers.authorization) === null;
212
252
  let claims = null;
213
253
  try {
214
- if (__requireBoolean(fresh)) {
215
- claims = __normalize(this.#tokens.create());
216
- } else {
254
+ if (__requireBoolean(!__requireBoolean(fresh))) {
217
255
  claims = __normalize(this.#tokens.read(__normalize(__contextGet("request").headers.authorization)));
218
256
  }
219
257
  } catch (error) {
@@ -226,6 +264,9 @@ export class Runtime {
226
264
  return failure(404, "RouteNotFound");
227
265
  }
228
266
  let route = __normalize(matched.route);
267
+ let metadata = routeInfo([route]);
268
+ let selected = __normalize(__hostGlobal(["Object"]).freeze(__normalize(metadata[0])));
269
+ __contextScope.push(__contextSet("request", __normalize(__hostGlobal(["Object"]).freeze(__normalize(__hostGlobal(["Object"]).assign({ }, __contextGet("request"), { route: selected }))))));
229
270
  let input = null;
230
271
  try {
231
272
  input = __normalize(__hostGlobal(["JSON"]).parse(__normalize(task.body)));
@@ -242,43 +283,128 @@ export class Runtime {
242
283
  } catch (error) {
243
284
  return failure(400, "InvalidPath");
244
285
  }
245
- __contextScope.push(__contextSet("token", new Token(claims)));
246
- trace(`${requestIdentity(__normalize(__contextGet("request").id), __contextGet("token"))} Matched route ${matched.route.path}; fresh=${fresh}`);
247
286
  __contextScope.push(__contextSet("db", __normalize(this.#database.scope())));
248
- return __normalize(__hostGlobal(["Promise"]).resolve(null)).then(__withArity(((__capturedContext0, __capturedContext1, __capturedContext2, __capturedContext3, __capturedContext4, __capturedContext5) => (ignored) => {
287
+ __contextScope.push(__contextSet("clientIdentity", null));
288
+ let restored = false;
289
+ try {
290
+ if (__requireBoolean(__normalize(this.#clients) !== null)) {
291
+ __contextScope.push(__contextSet("clientIdentity", __normalize(this.#clients.begin(claims, __normalize(this.#tokens)))));
292
+ claims = __normalize(__contextGet("clientIdentity").claims);
293
+ fresh = __normalize(__contextGet("clientIdentity").fresh);
294
+ restored = __normalize(__contextGet("clientIdentity").restored);
295
+ }
296
+ if (__requireBoolean(claims === null)) {
297
+ claims = __normalize(this.#tokens.create());
298
+ }
299
+ } catch (error) {
300
+ closeScope(__contextGet("db"), false);
301
+ if (__requireBoolean(__isKindof(error, HttpFailure))) {
302
+ return __normalize(error.result());
303
+ }
304
+ __normalize(__contextGet("log").err(`[${__normalize(__contextGet("request").id)}] Client identity failed: ${errorDetails(error)}`));
305
+ return failure(500, "InternalServerError");
306
+ }
307
+ return this.#process(task, route, input, claims, fresh, restored);
308
+ return null;
309
+ } finally {
310
+ __contextRestore(__contextScope);
311
+ }
312
+ }
313
+ #rotateClient() {
314
+ const __contextScope = [];
315
+ try {
316
+ if (__requireBoolean(__requireBoolean(__normalize(this.#clients) === null) || __requireBoolean(__contextGet("clientIdentity") === null))) {
317
+ throw "Managed client identity is unavailable";
318
+ }
319
+ if (__requireBoolean(__normalize(__contextGet("clientIdentity").closed))) {
320
+ throw "Client identity scope is closed";
321
+ }
322
+ __contextGet("clientIdentity").rotate = true;
323
+ return null;
324
+ return null;
325
+ } finally {
326
+ __contextRestore(__contextScope);
327
+ }
328
+ }
329
+ #signResponse(claims) {
330
+ const __contextScope = [];
331
+ try {
332
+ __requireArity(arguments.length, [0], "signResponse");
333
+ claims = __boundary(claims);
334
+ if (__requireBoolean(__normalize(this.#clients) === null)) {
335
+ return __normalize(this.#tokens.sign(claims));
336
+ }
337
+ return __normalize(this.#clients.publish(__contextGet("clientIdentity"), claims, __contextGet("response"), __normalize(this.#tokens)));
338
+ return null;
339
+ } finally {
340
+ __contextRestore(__contextScope);
341
+ }
342
+ }
343
+ #process(task, route, input, claims, fresh, restored) {
344
+ const __contextScope = [];
345
+ try {
346
+ __requireArity(arguments.length, [0, 1, 2, 3, 4, 5], "process");
347
+ task = __boundary(task);
348
+ route = __boundary(route);
349
+ input = __boundary(input);
350
+ claims = __boundary(claims);
351
+ fresh = __boundary(fresh);
352
+ restored = __boundary(restored);
353
+ __contextScope.push(__contextSet("token", new Token(claims)));
354
+ let sender = null;
355
+ try {
356
+ sender = this.#queueSender();
357
+ } catch (error) {
358
+ closeScope(__contextGet("db"), false);
359
+ closeClientScope();
360
+ __normalize(__contextGet("log").err(`${requestIdentity(__normalize(__contextGet("request").id), __contextGet("token"))} Queue preparation failed: ${errorDetails(error)}`));
361
+ return failure(500, "InternalServerError");
362
+ }
363
+ __contextScope.push(__contextSet("queue", sender));
364
+ trace(`${requestIdentity(__normalize(__contextGet("request").id), __contextGet("token"))} Matched route ${__normalize(route.path)}; fresh=${fresh}`);
365
+ return __normalize(__hostGlobal(["Promise"]).resolve(null)).then(__withArity(__bindContexts((ignored) => {
249
366
  const __contextScope = [];
250
367
  try {
251
- __contextScope.push(__contextSet("server", __capturedContext0));
252
- __contextScope.push(__contextSet("request", __capturedContext1));
253
- __contextScope.push(__contextSet("response", __capturedContext2));
254
- __contextScope.push(__contextSet("token", __capturedContext3));
255
- __contextScope.push(__contextSet("log", __capturedContext4));
256
- __contextScope.push(__contextSet("db", __capturedContext5));
257
368
  ignored = __boundary(ignored);
258
369
  if (__requireBoolean(fresh)) {
259
- return this.#event("register", input);
370
+ let registration = __normalize(__hostGlobal(["Object"]).assign({ }, input, { ip: __normalize(__contextGet("request").remoteAddress), userAgent: __normalize(__contextGet("request").headers["user-agent"]) }));
371
+ return this.#event("register", registration);
260
372
  }
261
- return this.#validate();
373
+ return this.#validate(restored);
262
374
  return null;
263
375
  } finally {
264
376
  __contextRestore(__contextScope);
265
377
  }
266
- })(__contextGet("server"), __contextGet("request"), __contextGet("response"), __contextGet("token"), __contextGet("log"), __contextGet("db")), [0], "closure")).then(__withArity(((__capturedContext0, __capturedContext1, __capturedContext2, __capturedContext3, __capturedContext4, __capturedContext5) => (validatedAt) => {
378
+ }), [0], "closure")).then(__withArity(__bindContexts((validatedAt) => {
267
379
  const __contextScope = [];
268
380
  try {
269
- __contextScope.push(__contextSet("server", __capturedContext0));
270
- __contextScope.push(__contextSet("request", __capturedContext1));
271
- __contextScope.push(__contextSet("response", __capturedContext2));
272
- __contextScope.push(__contextSet("token", __capturedContext3));
273
- __contextScope.push(__contextSet("log", __capturedContext4));
274
- __contextScope.push(__contextSet("db", __capturedContext5));
275
381
  validatedAt = __boundary(validatedAt);
276
382
  if (__requireBoolean(__requireBoolean(!__requireBoolean(fresh)) && __requireBoolean(__isNumber(validatedAt)))) {
277
383
  stampValidation(claims, validatedAt);
278
384
  __normalize(__contextGet("token").renew());
279
385
  }
280
- if (__requireBoolean(__requireBoolean(__normalize(route.auth) !== "anonymous") && __requireBoolean(!__requireBoolean(__normalize(__contextGet("token").hasAuth(__normalize(route.auth))))))) {
281
- throw { status: 401, error: "Unauthorized" };
386
+ if (__requireBoolean(__requireBoolean(__normalize(route.policy) !== "anonymous") && __requireBoolean(!__requireBoolean(__normalize(__contextGet("token").hasPolicy(__normalize(route.policy))))))) {
387
+ if (__requireBoolean(__normalize(route.legacyAuth))) {
388
+ __normalize(__contextGet("response").reject(401, "Unauthorized"));
389
+ }
390
+ if (__requireBoolean(__requireBoolean(__normalize(route.policy) === "login") || __requireBoolean(!__requireBoolean(__normalize(__contextGet("token").hasPolicy("login")))))) {
391
+ needLogin(route, 401, "LoginRequired");
392
+ }
393
+ __normalize(__contextGet("response").reject(403, "Forbidden"));
394
+ }
395
+ if (__requireBoolean(__normalize(route.reauthSeconds) > 0)) {
396
+ let authenticatedAt = __normalize(__contextGet("token").get("authenticatedAt"));
397
+ let now = __normalize(__hostGlobal(["Date"]).now());
398
+ if (__requireBoolean(__requireBoolean(__requireBoolean(!__requireBoolean(__normalize(__hostGlobal(["Number"]).isSafeInteger(authenticatedAt)))) || __requireBoolean(authenticatedAt < 0)) || __requireBoolean(authenticatedAt > now))) {
399
+ needLogin(route, 403, "ReauthenticationRequired");
400
+ }
401
+ if (__requireBoolean(__finite(now - authenticatedAt) >= __finite(__normalize(route.reauthSeconds) * 1000))) {
402
+ needLogin(route, 403, "ReauthenticationRequired");
403
+ }
404
+ }
405
+ let expected = __normalize(__contextGet("request").headers["x-lango-expected-user"]);
406
+ if (__requireBoolean(__requireBoolean(expected !== null) && __requireBoolean(expected !== __toJson(__normalize(__contextGet("token").get("userId")))))) {
407
+ __normalize(__contextGet("response").reject(409, "IdentityChanged"));
282
408
  }
283
409
  if (__requireBoolean(__normalize(route.kind) === "longpoll")) {
284
410
  return null;
@@ -294,20 +420,15 @@ export class Runtime {
294
420
  } finally {
295
421
  __contextRestore(__contextScope);
296
422
  }
297
- })(__contextGet("server"), __contextGet("request"), __contextGet("response"), __contextGet("token"), __contextGet("log"), __contextGet("db")), [0], "closure")).then(__withArity(((__capturedContext0, __capturedContext1, __capturedContext2, __capturedContext3, __capturedContext4, __capturedContext5) => (output) => {
423
+ }), [0], "closure")).then(__withArity(__bindContexts((output) => {
298
424
  const __contextScope = [];
299
425
  try {
300
- __contextScope.push(__contextSet("server", __capturedContext0));
301
- __contextScope.push(__contextSet("request", __capturedContext1));
302
- __contextScope.push(__contextSet("response", __capturedContext2));
303
- __contextScope.push(__contextSet("token", __capturedContext3));
304
- __contextScope.push(__contextSet("log", __capturedContext4));
305
- __contextScope.push(__contextSet("db", __capturedContext5));
306
426
  output = __boundary(output);
427
+ let encoded = null;
307
428
  if (__requireBoolean(__normalize(task.authorize) === true)) {
308
429
  closeScope(__contextGet("db"), true);
309
430
  let authorizedClaims = this.#tokenClaims(__contextGet("token"), claims, true);
310
- let encoded = __normalize(this.#tokens.sign(authorizedClaims));
431
+ encoded = this.#signResponse(authorizedClaims);
311
432
  if (__requireBoolean(__normalize(task.pollResult) === null)) {
312
433
  return { status: 200, authorization: encoded };
313
434
  }
@@ -330,7 +451,12 @@ export class Runtime {
330
451
  closeScope(__contextGet("db"), true);
331
452
  let result = __normalize(__contextGet("response").result(body));
332
453
  let updated = this.#tokenClaims(__contextGet("token"), claims, __normalize(result.status) < 400);
333
- result.headers["x-lango-token"] = __normalize(this.#tokens.sign(updated));
454
+ encoded = this.#signResponse(updated);
455
+ result = __normalize(__contextGet("response").result(body));
456
+ result.headers["x-lango-token"] = encoded;
457
+ if (__requireBoolean(__requireBoolean(__normalize(result.status) < 400) && __requireBoolean(authenticationChanged(claims, updated)))) {
458
+ result.headers["x-lango-auth-change"] = `v1:${__normalize(crypto.randomUUID())}`;
459
+ }
334
460
  if (__requireBoolean(__requireBoolean(__requireBoolean(__normalize(task.internal) !== true) && __requireBoolean(__normalize(this.#definition.settings.requestEvent))) && __requireBoolean(__includes("request", __normalize(this.#events))))) {
335
461
  return this.#audit(__normalize(__contextGet("request").id), result, __normalize(task.body), body, updated);
336
462
  }
@@ -340,14 +466,9 @@ export class Runtime {
340
466
  } finally {
341
467
  __contextRestore(__contextScope);
342
468
  }
343
- })(__contextGet("server"), __contextGet("request"), __contextGet("response"), __contextGet("token"), __contextGet("log"), __contextGet("db")), [0], "closure")).catch(__withArity(((__capturedContext0, __capturedContext1, __capturedContext2, __capturedContext3, __capturedContext4) => (error) => {
469
+ }), [0], "closure")).catch(__withArity(__bindContexts((error) => {
344
470
  const __contextScope = [];
345
471
  try {
346
- __contextScope.push(__contextSet("server", __capturedContext0));
347
- __contextScope.push(__contextSet("request", __capturedContext1));
348
- __contextScope.push(__contextSet("log", __capturedContext2));
349
- __contextScope.push(__contextSet("db", __capturedContext3));
350
- __contextScope.push(__contextSet("token", __capturedContext4));
351
472
  error = __boundary(error);
352
473
  closeScope(__contextGet("db"), false);
353
474
  if (__requireBoolean(__isKindof(error, HttpFailure))) {
@@ -363,16 +484,16 @@ export class Runtime {
363
484
  } finally {
364
485
  __contextRestore(__contextScope);
365
486
  }
366
- })(__contextGet("server"), __contextGet("request"), __contextGet("log"), __contextGet("db"), __contextGet("token")), [0], "closure")).finally(((__capturedContext0) => () => {
487
+ }), [0], "closure")).finally(__bindContexts(() => {
367
488
  const __contextScope = [];
368
489
  try {
369
- __contextScope.push(__contextSet("db", __capturedContext0));
490
+ closeClientScope();
370
491
  closeScope(__contextGet("db"), false);
371
492
  return null;
372
493
  } finally {
373
494
  __contextRestore(__contextScope);
374
495
  }
375
- })(__contextGet("db")));
496
+ }));
376
497
  return null;
377
498
  } finally {
378
499
  __contextRestore(__contextScope);
@@ -413,11 +534,16 @@ export class Runtime {
413
534
  let child = __normalize(__hostGlobal(["Object"]).assign({ }, __contextGet("request"), { headers: __normalize(__hostGlobal(["Object"]).assign({ }, __normalize(__contextGet("request").headers), { authorization: `Bearer ${encoded}` })) }));
414
535
  pending = this.#refreshOne(pending, results, encoded, owner, child);
415
536
  }
416
- return pending.then(__withArity((ignored) => {
417
- ignored = __boundary(ignored);
418
- return results;
419
- return null;
420
- }, [0], "closure"));
537
+ return pending.then(__withArity(__bindContexts((ignored) => {
538
+ const __contextScope = [];
539
+ try {
540
+ ignored = __boundary(ignored);
541
+ return results;
542
+ return null;
543
+ } finally {
544
+ __contextRestore(__contextScope);
545
+ }
546
+ }), [0], "closure"));
421
547
  return null;
422
548
  } finally {
423
549
  __contextRestore(__contextScope);
@@ -430,7 +556,7 @@ export class Runtime {
430
556
  encoded = __boundary(encoded);
431
557
  owner = __boundary(owner);
432
558
  child = __boundary(child);
433
- return pending.then(__withArity((ignored) => {
559
+ return pending.then(__withArity(__bindContexts((ignored) => {
434
560
  ignored = __boundary(ignored);
435
561
  let checked = null;
436
562
  try {
@@ -443,7 +569,7 @@ export class Runtime {
443
569
  }
444
570
  return this.handle({ request: child, body: "{}", internal: true });
445
571
  return null;
446
- }, [0], "closure")).then(__withArity((result) => {
572
+ }), [0], "closure")).then(__withArity(__bindContexts((result) => {
447
573
  result = __boundary(result);
448
574
  let updated = null;
449
575
  if (__requireBoolean(__normalize(result.status) < 400)) {
@@ -452,7 +578,7 @@ export class Runtime {
452
578
  __add(results, { previous: encoded, token: updated, status: __normalize(result.status) });
453
579
  return null;
454
580
  return null;
455
- }, [0], "closure"));
581
+ }), [0], "closure"));
456
582
  return null;
457
583
  }
458
584
  #event(name, input) {
@@ -464,45 +590,42 @@ export class Runtime {
464
590
  if (__requireBoolean(!__requireBoolean(__includes(name, __normalize(this.#events))))) {
465
591
  return null;
466
592
  }
467
- trace(`${requestIdentity(__normalize(__contextGet("request").id), __contextGet("token"))} Running event ${name}`);
593
+ let identity = `[${__normalize(__contextGet("request").id)}]`;
594
+ if (__requireBoolean(__contextGet("token") !== null)) {
595
+ identity = requestIdentity(__normalize(__contextGet("request").id), __contextGet("token"));
596
+ }
597
+ trace(`${identity} Running event ${name}`);
468
598
  let handler = __normalize(this.#events[name]);
469
599
  __normalize(threads.parentPort.postMessage({ kind: "event", id: __normalize(__contextGet("request").id) }));
470
- return __normalize(__hostGlobal(["Promise"]).resolve(null)).then(__withArity(((__capturedContext0, __capturedContext1, __capturedContext2, __capturedContext3, __capturedContext4, __capturedContext5) => (ignored) => {
600
+ return __normalize(__hostGlobal(["Promise"]).resolve(null)).then(__withArity(__bindContexts((ignored) => {
471
601
  const __contextScope = [];
472
602
  try {
473
- __contextScope.push(__contextSet("server", __capturedContext0));
474
- __contextScope.push(__contextSet("request", __capturedContext1));
475
- __contextScope.push(__contextSet("response", __capturedContext2));
476
- __contextScope.push(__contextSet("token", __capturedContext3));
477
- __contextScope.push(__contextSet("log", __capturedContext4));
478
- __contextScope.push(__contextSet("db", __capturedContext5));
479
603
  ignored = __boundary(ignored);
480
604
  return __call(handler, input);
481
605
  return null;
482
606
  } finally {
483
607
  __contextRestore(__contextScope);
484
608
  }
485
- })(__contextGet("server"), __contextGet("request"), __contextGet("response"), __contextGet("token"), __contextGet("log"), __contextGet("db")), [0], "closure")).finally(((__capturedContext0, __capturedContext1) => () => {
609
+ }), [0], "closure")).finally(__bindContexts(() => {
486
610
  const __contextScope = [];
487
611
  try {
488
- __contextScope.push(__contextSet("server", __capturedContext0));
489
- __contextScope.push(__contextSet("request", __capturedContext1));
490
612
  __normalize(threads.parentPort.postMessage({ kind: "handler", id: __normalize(__contextGet("request").id) }));
491
613
  return null;
492
614
  } finally {
493
615
  __contextRestore(__contextScope);
494
616
  }
495
- })(__contextGet("server"), __contextGet("request")));
617
+ }));
496
618
  return null;
497
619
  } finally {
498
620
  __contextRestore(__contextScope);
499
621
  }
500
622
  }
501
- #validate() {
623
+ #validate(force = false) {
502
624
  const __contextScope = [];
503
625
  try {
626
+ force = __boundary(force);
504
627
  let claims = __normalize(__contextGet("token").snapshot());
505
- if (__requireBoolean(__finite(__normalize(__hostGlobal(["Date"]).now()) - __normalize(claims.validatedAt)) < 1000)) {
628
+ if (__requireBoolean(__requireBoolean(!__requireBoolean(force)) && __requireBoolean(__finite(__normalize(__hostGlobal(["Date"]).now()) - __normalize(claims.validatedAt)) < 1000))) {
506
629
  return null;
507
630
  }
508
631
  if (__requireBoolean(!__requireBoolean(__includes("validate", __normalize(this.#events))))) {
@@ -510,25 +633,18 @@ export class Runtime {
510
633
  }
511
634
  let original = __normalize(__hostGlobal(["JSON"]).stringify(claims));
512
635
  __contextScope.push(__contextSet("token", new Token(claims, true)));
513
- return __normalize(__hostGlobal(["Promise"]).resolve(null)).then(__withArity(((__capturedContext0, __capturedContext1, __capturedContext2, __capturedContext3, __capturedContext4, __capturedContext5) => (ignored) => {
636
+ return __normalize(__hostGlobal(["Promise"]).resolve(null)).then(__withArity(__bindContexts((ignored) => {
514
637
  const __contextScope = [];
515
638
  try {
516
- __contextScope.push(__contextSet("token", __capturedContext0));
517
- __contextScope.push(__contextSet("response", __capturedContext1));
518
- __contextScope.push(__contextSet("server", __capturedContext2));
519
- __contextScope.push(__contextSet("request", __capturedContext3));
520
- __contextScope.push(__contextSet("log", __capturedContext4));
521
- __contextScope.push(__contextSet("db", __capturedContext5));
522
639
  ignored = __boundary(ignored);
523
640
  return this.#event("validate", null);
524
641
  return null;
525
642
  } finally {
526
643
  __contextRestore(__contextScope);
527
644
  }
528
- })(__contextGet("token"), __contextGet("response"), __contextGet("server"), __contextGet("request"), __contextGet("log"), __contextGet("db")), [0], "closure")).then(__withArity(((__capturedContext0) => (valid) => {
645
+ }), [0], "closure")).then(__withArity(__bindContexts((valid) => {
529
646
  const __contextScope = [];
530
647
  try {
531
- __contextScope.push(__contextSet("token", __capturedContext0));
532
648
  valid = __boundary(valid);
533
649
  if (__requireBoolean(!__requireBoolean(__isBool(valid)))) {
534
650
  throw "Validate must return boolean";
@@ -545,7 +661,7 @@ export class Runtime {
545
661
  } finally {
546
662
  __contextRestore(__contextScope);
547
663
  }
548
- })(__contextGet("token")), [0], "closure"));
664
+ }), [0], "closure"));
549
665
  return null;
550
666
  } finally {
551
667
  __contextRestore(__contextScope);
@@ -563,27 +679,29 @@ export class Runtime {
563
679
  __contextScope.push(__contextSet("db", __normalize(this.#database.scope())));
564
680
  __contextScope.push(__contextSet("token", new Token(claims, true)));
565
681
  __contextScope.push(__contextSet("response", __normalize(__hostGlobal(["Object"]).freeze({ }))));
682
+ let sender = null;
683
+ try {
684
+ sender = this.#queueSender();
685
+ } catch (error) {
686
+ closeScope(__contextGet("db"), false);
687
+ __normalize(__contextGet("log").err(`${requestIdentity(id, __contextGet("token"))} Request event queue preparation failed: ${errorDetails(error)}`));
688
+ return result;
689
+ }
690
+ __contextScope.push(__contextSet("queue", sender));
566
691
  let metadata = { input: input, output: output, status: __normalize(result.status) };
567
692
  __normalize(threads.parentPort.postMessage({ kind: "prepared", logIdentity: requestIdentity(id, __contextGet("token")), id: id, result: result }));
568
- return __normalize(__hostGlobal(["Promise"]).resolve(null)).then(__withArity(((__capturedContext0, __capturedContext1, __capturedContext2, __capturedContext3, __capturedContext4, __capturedContext5) => (ignored) => {
693
+ return __normalize(__hostGlobal(["Promise"]).resolve(null)).then(__withArity(__bindContexts((ignored) => {
569
694
  const __contextScope = [];
570
695
  try {
571
- __contextScope.push(__contextSet("token", __capturedContext0));
572
- __contextScope.push(__contextSet("server", __capturedContext1));
573
- __contextScope.push(__contextSet("request", __capturedContext2));
574
- __contextScope.push(__contextSet("response", __capturedContext3));
575
- __contextScope.push(__contextSet("log", __capturedContext4));
576
- __contextScope.push(__contextSet("db", __capturedContext5));
577
696
  ignored = __boundary(ignored);
578
697
  return this.#event("request", __normalize(__hostGlobal(["Object"]).freeze(metadata)));
579
698
  return null;
580
699
  } finally {
581
700
  __contextRestore(__contextScope);
582
701
  }
583
- })(__contextGet("token"), __contextGet("server"), __contextGet("request"), __contextGet("response"), __contextGet("log"), __contextGet("db")), [0], "closure")).then(__withArity(((__capturedContext0) => (ignored) => {
702
+ }), [0], "closure")).then(__withArity(__bindContexts((ignored) => {
584
703
  const __contextScope = [];
585
704
  try {
586
- __contextScope.push(__contextSet("db", __capturedContext0));
587
705
  ignored = __boundary(ignored);
588
706
  closeScope(__contextGet("db"), true);
589
707
  return null;
@@ -591,13 +709,9 @@ export class Runtime {
591
709
  } finally {
592
710
  __contextRestore(__contextScope);
593
711
  }
594
- })(__contextGet("db")), [0], "closure")).catch(__withArity(((__capturedContext0, __capturedContext1, __capturedContext2, __capturedContext3) => (error) => {
712
+ }), [0], "closure")).catch(__withArity(__bindContexts((error) => {
595
713
  const __contextScope = [];
596
714
  try {
597
- __contextScope.push(__contextSet("log", __capturedContext0));
598
- __contextScope.push(__contextSet("db", __capturedContext1));
599
- __contextScope.push(__contextSet("request", __capturedContext2));
600
- __contextScope.push(__contextSet("token", __capturedContext3));
601
715
  error = __boundary(error);
602
716
  closeScope(__contextGet("db"), false);
603
717
  __normalize(__contextGet("log").err(`${requestIdentity(__normalize(__contextGet("request").id), __contextGet("token"))} Request event failed: ${errorDetails(error)}`));
@@ -606,37 +720,30 @@ export class Runtime {
606
720
  } finally {
607
721
  __contextRestore(__contextScope);
608
722
  }
609
- })(__contextGet("log"), __contextGet("db"), __contextGet("request"), __contextGet("token")), [0], "closure")).then(__withArity((ignored) => {
610
- ignored = __boundary(ignored);
611
- return result;
612
- return null;
613
- }, [0], "closure")).finally(((__capturedContext0) => () => {
723
+ }), [0], "closure")).then(__withArity(__bindContexts((ignored) => {
724
+ const __contextScope = [];
725
+ try {
726
+ ignored = __boundary(ignored);
727
+ return result;
728
+ return null;
729
+ } finally {
730
+ __contextRestore(__contextScope);
731
+ }
732
+ }), [0], "closure")).finally(__bindContexts(() => {
614
733
  const __contextScope = [];
615
734
  try {
616
- __contextScope.push(__contextSet("db", __capturedContext0));
617
735
  closeScope(__contextGet("db"), false);
618
736
  return null;
619
737
  } finally {
620
738
  __contextRestore(__contextScope);
621
739
  }
622
- })(__contextGet("db")));
740
+ }));
623
741
  return null;
624
742
  } finally {
625
743
  __contextRestore(__contextScope);
626
744
  }
627
745
  }
628
746
  }
629
- function exported(mod, name) {
630
- __requireArity(arguments.length, [0, 1], "exported");
631
- mod = __boundary(mod);
632
- name = __boundary(name);
633
- if (__requireBoolean(__requireBoolean(!__requireBoolean(__normalize(__hostGlobal(["Object"]).hasOwn(mod, name)))) || __requireBoolean(!__requireBoolean(__isKindof(__normalize(mod[name]), Function))))) {
634
- throw `Handler is not exported: ${name}`;
635
- }
636
- return __normalize(mod[name]);
637
- return null;
638
- }
639
-
640
747
  function failure(status, code) {
641
748
  __requireArity(arguments.length, [0, 1], "failure");
642
749
  status = __boundary(status);
@@ -672,4 +779,52 @@ function closeScope(db, strict) {
672
779
  return null;
673
780
  return null;
674
781
  }
782
+
783
+ function closeClientScope() {
784
+ const __contextScope = [];
785
+ try {
786
+ if (__requireBoolean(__contextGet("clientIdentity") !== null)) {
787
+ __contextGet("clientIdentity").closed = true;
788
+ }
789
+ return null;
790
+ return null;
791
+ } finally {
792
+ __contextRestore(__contextScope);
793
+ }
794
+ }
795
+
796
+ function needLogin(route, status, reason) {
797
+ const __contextScope = [];
798
+ try {
799
+ __requireArity(arguments.length, [0, 1, 2], "needLogin");
800
+ route = __boundary(route);
801
+ status = __boundary(status);
802
+ reason = __boundary(reason);
803
+ throw new HttpFailure(status, reason, { "content-type": "application/json; charset=utf-8", "cache-control": "no-store", "x-lango-need-login": "1" }, { reason: reason, path: __normalize(__contextGet("request").path), policy: __normalize(route.policy), reauthSeconds: __normalize(route.reauthSeconds), userId: __normalize(__contextGet("token").get("userId")) });
804
+ return null;
805
+ } finally {
806
+ __contextRestore(__contextScope);
807
+ }
808
+ }
809
+
810
+ function authenticationChanged(previous, current) {
811
+ const __contextScope = [];
812
+ try {
813
+ __requireArity(arguments.length, [0, 1], "authenticationChanged");
814
+ previous = __boundary(previous);
815
+ current = __boundary(current);
816
+ if (__requireBoolean(__requireBoolean(__contextGet("clientIdentity") !== null) && __requireBoolean(__normalize(__contextGet("clientIdentity").rotate)))) {
817
+ return true;
818
+ }
819
+ for (const name of ["auth", "userId", "grantId", "authenticatedAt"]) {
820
+ if (__requireBoolean(__toJson(__normalize(previous[name])) !== __toJson(__normalize(current[name])))) {
821
+ return true;
822
+ }
823
+ }
824
+ return false;
825
+ return null;
826
+ } finally {
827
+ __contextRestore(__contextScope);
828
+ }
829
+ }
675
830
  //# sourceMappingURL=runtime.mjs.map