@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.
- package/__tests__/analytics-track-outcome.test.ts +71 -3
- package/__tests__/auth-password-security.test.ts +101 -0
- package/__tests__/automations-bus.test.ts +85 -2
- package/__tests__/security-lists-parity.test.ts +2 -2
- package/__tests__/security-runtime.test.ts +37 -20
- package/dist/cjs/auth-generator.d.ts.map +1 -1
- package/dist/cjs/auth-generator.js +48 -19
- package/dist/cjs/auth-generator.js.map +1 -1
- package/dist/cjs/automations/event-bus-source.d.ts.map +1 -1
- package/dist/cjs/automations/event-bus-source.js +37 -23
- package/dist/cjs/automations/event-bus-source.js.map +1 -1
- package/dist/cjs/nodes/account/account-request-password-reset.d.ts.map +1 -1
- package/dist/cjs/nodes/account/account-request-password-reset.js +3 -2
- package/dist/cjs/nodes/account/account-request-password-reset.js.map +1 -1
- package/dist/cjs/nodes/analytics/analytics-track-outcome.d.ts.map +1 -1
- package/dist/cjs/nodes/analytics/analytics-track-outcome.js +17 -4
- package/dist/cjs/nodes/analytics/analytics-track-outcome.js.map +1 -1
- package/dist/cjs/password-reset-route-generator.d.ts +2 -0
- package/dist/cjs/password-reset-route-generator.d.ts.map +1 -1
- package/dist/cjs/password-reset-route-generator.js +17 -10
- package/dist/cjs/password-reset-route-generator.js.map +1 -1
- package/dist/cjs/security-runtime/security-runtime-code.d.ts +3 -2
- package/dist/cjs/security-runtime/security-runtime-code.d.ts.map +1 -1
- package/dist/cjs/security-runtime/security-runtime-code.js +17 -13
- package/dist/cjs/security-runtime/security-runtime-code.js.map +1 -1
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/auth-generator.d.ts.map +1 -1
- package/dist/esm/auth-generator.js +48 -19
- package/dist/esm/auth-generator.js.map +1 -1
- package/dist/esm/automations/event-bus-source.d.ts.map +1 -1
- package/dist/esm/automations/event-bus-source.js +37 -23
- package/dist/esm/automations/event-bus-source.js.map +1 -1
- package/dist/esm/nodes/account/account-request-password-reset.d.ts.map +1 -1
- package/dist/esm/nodes/account/account-request-password-reset.js +3 -2
- package/dist/esm/nodes/account/account-request-password-reset.js.map +1 -1
- package/dist/esm/nodes/analytics/analytics-track-outcome.d.ts.map +1 -1
- package/dist/esm/nodes/analytics/analytics-track-outcome.js +17 -4
- package/dist/esm/nodes/analytics/analytics-track-outcome.js.map +1 -1
- package/dist/esm/password-reset-route-generator.d.ts +2 -0
- package/dist/esm/password-reset-route-generator.d.ts.map +1 -1
- package/dist/esm/password-reset-route-generator.js +16 -9
- package/dist/esm/password-reset-route-generator.js.map +1 -1
- package/dist/esm/security-runtime/security-runtime-code.d.ts +3 -2
- package/dist/esm/security-runtime/security-runtime-code.d.ts.map +1 -1
- package/dist/esm/security-runtime/security-runtime-code.js +17 -13
- package/dist/esm/security-runtime/security-runtime-code.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/auth-generator.ts +48 -19
- package/src/automations/event-bus-source.ts +37 -23
- package/src/nodes/account/account-request-password-reset.ts +3 -2
- package/src/nodes/analytics/analytics-track-outcome.ts +17 -4
- package/src/password-reset-route-generator.ts +18 -9
- 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`,
|
|
37
|
-
*
|
|
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
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
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
|
|
394
|
-
// older backup): create 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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