@teleporthq/teleport-plugin-next-workflows 0.45.2 → 0.45.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 (54) hide show
  1. package/__tests__/analytics-track-outcome.test.ts +71 -3
  2. package/__tests__/auth-password-security.test.ts +101 -0
  3. package/__tests__/automations-bus.test.ts +85 -2
  4. package/__tests__/security-lists-parity.test.ts +2 -2
  5. package/__tests__/security-runtime.test.ts +37 -20
  6. package/dist/cjs/auth-generator.d.ts.map +1 -1
  7. package/dist/cjs/auth-generator.js +48 -19
  8. package/dist/cjs/auth-generator.js.map +1 -1
  9. package/dist/cjs/automations/event-bus-source.d.ts.map +1 -1
  10. package/dist/cjs/automations/event-bus-source.js +37 -23
  11. package/dist/cjs/automations/event-bus-source.js.map +1 -1
  12. package/dist/cjs/nodes/account/account-request-password-reset.d.ts.map +1 -1
  13. package/dist/cjs/nodes/account/account-request-password-reset.js +3 -2
  14. package/dist/cjs/nodes/account/account-request-password-reset.js.map +1 -1
  15. package/dist/cjs/nodes/analytics/analytics-track-outcome.d.ts.map +1 -1
  16. package/dist/cjs/nodes/analytics/analytics-track-outcome.js +17 -4
  17. package/dist/cjs/nodes/analytics/analytics-track-outcome.js.map +1 -1
  18. package/dist/cjs/password-reset-route-generator.d.ts +2 -0
  19. package/dist/cjs/password-reset-route-generator.d.ts.map +1 -1
  20. package/dist/cjs/password-reset-route-generator.js +17 -10
  21. package/dist/cjs/password-reset-route-generator.js.map +1 -1
  22. package/dist/cjs/security-runtime/security-runtime-code.d.ts +3 -2
  23. package/dist/cjs/security-runtime/security-runtime-code.d.ts.map +1 -1
  24. package/dist/cjs/security-runtime/security-runtime-code.js +17 -13
  25. package/dist/cjs/security-runtime/security-runtime-code.js.map +1 -1
  26. package/dist/cjs/tsconfig.tsbuildinfo +1 -1
  27. package/dist/esm/auth-generator.d.ts.map +1 -1
  28. package/dist/esm/auth-generator.js +48 -19
  29. package/dist/esm/auth-generator.js.map +1 -1
  30. package/dist/esm/automations/event-bus-source.d.ts.map +1 -1
  31. package/dist/esm/automations/event-bus-source.js +37 -23
  32. package/dist/esm/automations/event-bus-source.js.map +1 -1
  33. package/dist/esm/nodes/account/account-request-password-reset.d.ts.map +1 -1
  34. package/dist/esm/nodes/account/account-request-password-reset.js +3 -2
  35. package/dist/esm/nodes/account/account-request-password-reset.js.map +1 -1
  36. package/dist/esm/nodes/analytics/analytics-track-outcome.d.ts.map +1 -1
  37. package/dist/esm/nodes/analytics/analytics-track-outcome.js +17 -4
  38. package/dist/esm/nodes/analytics/analytics-track-outcome.js.map +1 -1
  39. package/dist/esm/password-reset-route-generator.d.ts +2 -0
  40. package/dist/esm/password-reset-route-generator.d.ts.map +1 -1
  41. package/dist/esm/password-reset-route-generator.js +16 -9
  42. package/dist/esm/password-reset-route-generator.js.map +1 -1
  43. package/dist/esm/security-runtime/security-runtime-code.d.ts +3 -2
  44. package/dist/esm/security-runtime/security-runtime-code.d.ts.map +1 -1
  45. package/dist/esm/security-runtime/security-runtime-code.js +17 -13
  46. package/dist/esm/security-runtime/security-runtime-code.js.map +1 -1
  47. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  48. package/package.json +2 -2
  49. package/src/auth-generator.ts +48 -19
  50. package/src/automations/event-bus-source.ts +37 -23
  51. package/src/nodes/account/account-request-password-reset.ts +3 -2
  52. package/src/nodes/analytics/analytics-track-outcome.ts +17 -4
  53. package/src/password-reset-route-generator.ts +18 -9
  54. package/src/security-runtime/security-runtime-code.ts +17 -13
@@ -33,8 +33,9 @@ export const securityRuntimeSpecifier = (relativePrefix) => `${relativePrefix}/$
33
33
  * itself, an IPv6 one its /64 (an IPv4 tail counted as the two groups it
34
34
  * fills). Every rate limit keyed by visitor uses it.
35
35
  * - `rateLimit` counts fixed windows in the app's Postgres database (table
36
- * `teleport_rate_limits`, created on first use under an advisory lock), so
37
- * every instance of a serverless app counts together. Only an app with no
36
+ * `teleport_rate_limits`, which the editor makes, created here under an
37
+ * advisory lock only when it is really missing), so every instance of a
38
+ * serverless app counts together. Only an app with no
38
39
  * database (or no `pg` driver) counts in a bounded per-instance map; a
39
40
  * database error counts in that map for a short while and is logged once.
40
41
  * A request waits on the database at most 1.5 s; after a failure one
@@ -97,6 +98,9 @@ var CLEANUP_MAX_BATCHES = 3;
97
98
  var CLEANUP_QUERY_TIMEOUT_MS = 5000;
98
99
  var MEMORY_MAX_WINDOWS = 10000;
99
100
 
101
+ // A site's database role may read and write its tables without being allowed
102
+ // to create one, and CREATE ... IF NOT EXISTS asks for that permission even when
103
+ // the table is there: these run only for a table that really is missing.
100
104
  var CREATE_SQL = 'CREATE TABLE IF NOT EXISTS "' + RATE_LIMITS_TABLE + '" (' +
101
105
  '"key" TEXT NOT NULL, "window_start" BIGINT NOT NULL, "count" INTEGER NOT NULL DEFAULT 0, ' +
102
106
  '"expires_at" BIGINT NOT NULL, PRIMARY KEY ("key", "window_start"))';
@@ -293,7 +297,6 @@ function __memoryHit(storageKey, windowStart, windowSeconds, nowSec) {
293
297
  return entry.count;
294
298
  }
295
299
 
296
- var __tableReady = false;
297
300
  // Healthy, every request asks the database. After a failure, requests count in
298
301
  // memory until __databaseRetryAt; then ONE request probes (it pushes the retry
299
302
  // time back before it asks), so the requests beside it never wait on a
@@ -372,12 +375,15 @@ async function __databaseHit(storageKey, windowStart, expiresAt, nowSec) {
372
375
  return within(client.query(sql, values || []), QUERY_TIMEOUT_MS);
373
376
  };
374
377
  var createTable = async function () {
375
- await run('BEGIN');
376
- await run(LOCK_SQL, [RATE_LIMITS_TABLE]);
377
- await run(CREATE_SQL);
378
- await run(INDEX_SQL);
379
- await run('COMMIT');
380
- __tableReady = true;
378
+ try {
379
+ await run('BEGIN');
380
+ await run(LOCK_SQL, [RATE_LIMITS_TABLE]);
381
+ await run(CREATE_SQL);
382
+ await run(INDEX_SQL);
383
+ await run('COMMIT');
384
+ } catch (err) {
385
+ throw new Error('the table ' + RATE_LIMITS_TABLE + ' is missing and could not be created: ' + __errorText(err));
386
+ }
381
387
  };
382
388
  var hit = function () {
383
389
  return run(HIT_SQL, [storageKey, windowStart, expiresAt]);
@@ -385,15 +391,13 @@ async function __databaseHit(storageKey, windowStart, expiresAt, nowSec) {
385
391
  var handedToCleanup = false;
386
392
  try {
387
393
  await within(client.connect(), CONNECT_TIMEOUT_MS);
388
- if (!__tableReady) await createTable();
389
394
  var result;
390
395
  try {
391
396
  result = await hit();
392
397
  } catch (err) {
393
- // The table went away (dropped, or the database restored from an
394
- // older backup): create it again and count this request in it.
398
+ // The table is not there (dropped, or the database restored from an
399
+ // older backup): create it and count this request in it.
395
400
  if (!err || err.code !== '42P01') throw err;
396
- __tableReady = false;
397
401
  await createTable();
398
402
  result = await hit();
399
403
  }
@@ -1 +1 @@
1
- {"version":3,"file":"security-runtime-code.js","sourceRoot":"","sources":["../../../src/security-runtime/security-runtime-code.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAA;AAE5D;;;GAGG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,kBAAkB,CAAA;AAC3D,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,OAAO,CAAC,CAAA;AAC9C,MAAM,CAAC,MAAM,0BAA0B,GAAG,kBAAkB,CAAA;AAC5D,MAAM,CAAC,MAAM,iBAAiB,GAAG,sBAAsB,CAAA;AAEvD,qEAAqE;AACrE,MAAM,CAAC,MAAM,yBAAyB,GAAG,qCAAqC,CAAA;AAE9E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,cAAsB,EAAU,EAAE,CACzE,GAAG,cAAc,IAAI,qBAAqB,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,0BAA0B,EAAE,CAAA;AAEtF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,GAAW,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;E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