s3db.js 13.6.0 → 14.0.2
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/README.md +139 -43
- package/dist/s3db.cjs +72425 -38970
- package/dist/s3db.cjs.map +1 -1
- package/dist/s3db.es.js +72177 -38764
- package/dist/s3db.es.js.map +1 -1
- package/mcp/lib/base-handler.js +157 -0
- package/mcp/lib/handlers/connection-handler.js +280 -0
- package/mcp/lib/handlers/query-handler.js +533 -0
- package/mcp/lib/handlers/resource-handler.js +428 -0
- package/mcp/lib/tool-registry.js +336 -0
- package/mcp/lib/tools/connection-tools.js +161 -0
- package/mcp/lib/tools/query-tools.js +267 -0
- package/mcp/lib/tools/resource-tools.js +404 -0
- package/package.json +94 -49
- package/src/clients/memory-client.class.js +346 -191
- package/src/clients/memory-storage.class.js +300 -84
- package/src/clients/s3-client.class.js +7 -6
- package/src/concerns/geo-encoding.js +19 -2
- package/src/concerns/ip.js +59 -9
- package/src/concerns/money.js +8 -1
- package/src/concerns/password-hashing.js +49 -8
- package/src/concerns/plugin-storage.js +186 -18
- package/src/concerns/storage-drivers/filesystem-driver.js +284 -0
- package/src/database.class.js +139 -29
- package/src/errors.js +332 -42
- package/src/plugins/api/auth/oidc-auth.js +66 -17
- package/src/plugins/api/auth/strategies/base-strategy.class.js +74 -0
- package/src/plugins/api/auth/strategies/factory.class.js +63 -0
- package/src/plugins/api/auth/strategies/global-strategy.class.js +44 -0
- package/src/plugins/api/auth/strategies/path-based-strategy.class.js +83 -0
- package/src/plugins/api/auth/strategies/path-rules-strategy.class.js +118 -0
- package/src/plugins/api/concerns/failban-manager.js +106 -57
- package/src/plugins/api/concerns/opengraph-helper.js +116 -0
- package/src/plugins/api/concerns/route-context.js +601 -0
- package/src/plugins/api/concerns/state-machine.js +288 -0
- package/src/plugins/api/index.js +180 -41
- package/src/plugins/api/routes/auth-routes.js +198 -30
- package/src/plugins/api/routes/resource-routes.js +19 -4
- package/src/plugins/api/server/health-manager.class.js +163 -0
- package/src/plugins/api/server/middleware-chain.class.js +310 -0
- package/src/plugins/api/server/router.class.js +472 -0
- package/src/plugins/api/server.js +280 -1303
- package/src/plugins/api/utils/custom-routes.js +17 -5
- package/src/plugins/api/utils/guards.js +76 -17
- package/src/plugins/api/utils/openapi-generator-cached.class.js +133 -0
- package/src/plugins/api/utils/openapi-generator.js +7 -6
- package/src/plugins/api/utils/template-engine.js +77 -3
- package/src/plugins/audit.plugin.js +30 -8
- package/src/plugins/backup.plugin.js +110 -14
- package/src/plugins/cache/cache.class.js +22 -5
- package/src/plugins/cache/filesystem-cache.class.js +116 -19
- package/src/plugins/cache/memory-cache.class.js +211 -57
- package/src/plugins/cache/multi-tier-cache.class.js +371 -0
- package/src/plugins/cache/partition-aware-filesystem-cache.class.js +168 -47
- package/src/plugins/cache/redis-cache.class.js +552 -0
- package/src/plugins/cache/s3-cache.class.js +17 -8
- package/src/plugins/cache.plugin.js +176 -61
- package/src/plugins/cloud-inventory/drivers/alibaba-driver.js +8 -1
- package/src/plugins/cloud-inventory/drivers/aws-driver.js +60 -29
- package/src/plugins/cloud-inventory/drivers/azure-driver.js +8 -1
- package/src/plugins/cloud-inventory/drivers/base-driver.js +16 -2
- package/src/plugins/cloud-inventory/drivers/cloudflare-driver.js +8 -1
- package/src/plugins/cloud-inventory/drivers/digitalocean-driver.js +8 -1
- package/src/plugins/cloud-inventory/drivers/hetzner-driver.js +8 -1
- package/src/plugins/cloud-inventory/drivers/linode-driver.js +8 -1
- package/src/plugins/cloud-inventory/drivers/mongodb-atlas-driver.js +8 -1
- package/src/plugins/cloud-inventory/drivers/vultr-driver.js +8 -1
- package/src/plugins/cloud-inventory/index.js +29 -8
- package/src/plugins/cloud-inventory/registry.js +64 -42
- package/src/plugins/cloud-inventory.plugin.js +240 -138
- package/src/plugins/concerns/plugin-dependencies.js +54 -0
- package/src/plugins/concerns/resource-names.js +100 -0
- package/src/plugins/consumers/index.js +10 -2
- package/src/plugins/consumers/sqs-consumer.js +12 -2
- package/src/plugins/cookie-farm-suite.plugin.js +278 -0
- package/src/plugins/cookie-farm.errors.js +73 -0
- package/src/plugins/cookie-farm.plugin.js +869 -0
- package/src/plugins/costs.plugin.js +7 -1
- package/src/plugins/eventual-consistency/analytics.js +94 -19
- package/src/plugins/eventual-consistency/config.js +15 -7
- package/src/plugins/eventual-consistency/consolidation.js +29 -11
- package/src/plugins/eventual-consistency/garbage-collection.js +3 -1
- package/src/plugins/eventual-consistency/helpers.js +39 -14
- package/src/plugins/eventual-consistency/install.js +21 -2
- package/src/plugins/eventual-consistency/utils.js +32 -10
- package/src/plugins/fulltext.plugin.js +38 -11
- package/src/plugins/geo.plugin.js +61 -9
- package/src/plugins/identity/concerns/config.js +61 -0
- package/src/plugins/identity/concerns/mfa-manager.js +15 -2
- package/src/plugins/identity/concerns/rate-limit.js +124 -0
- package/src/plugins/identity/concerns/resource-schemas.js +9 -1
- package/src/plugins/identity/concerns/token-generator.js +29 -4
- package/src/plugins/identity/drivers/auth-driver.interface.js +76 -0
- package/src/plugins/identity/drivers/client-credentials-driver.js +127 -0
- package/src/plugins/identity/drivers/index.js +18 -0
- package/src/plugins/identity/drivers/password-driver.js +122 -0
- package/src/plugins/identity/email-service.js +17 -2
- package/src/plugins/identity/index.js +413 -69
- package/src/plugins/identity/oauth2-server.js +413 -30
- package/src/plugins/identity/oidc-discovery.js +16 -8
- package/src/plugins/identity/rsa-keys.js +115 -35
- package/src/plugins/identity/server.js +166 -45
- package/src/plugins/identity/session-manager.js +53 -7
- package/src/plugins/identity/ui/pages/mfa-verification.js +17 -15
- package/src/plugins/identity/ui/routes.js +363 -255
- package/src/plugins/importer/index.js +153 -20
- package/src/plugins/index.js +9 -2
- package/src/plugins/kubernetes-inventory/index.js +6 -0
- package/src/plugins/kubernetes-inventory/k8s-driver.js +867 -0
- package/src/plugins/kubernetes-inventory/resource-types.js +274 -0
- package/src/plugins/kubernetes-inventory.plugin.js +980 -0
- package/src/plugins/metrics.plugin.js +64 -16
- package/src/plugins/ml/base-model.class.js +25 -15
- package/src/plugins/ml/regression-model.class.js +1 -1
- package/src/plugins/ml.errors.js +57 -25
- package/src/plugins/ml.plugin.js +28 -4
- package/src/plugins/namespace.js +210 -0
- package/src/plugins/plugin.class.js +180 -8
- package/src/plugins/puppeteer/console-monitor.js +729 -0
- package/src/plugins/puppeteer/cookie-manager.js +492 -0
- package/src/plugins/puppeteer/network-monitor.js +816 -0
- package/src/plugins/puppeteer/performance-manager.js +746 -0
- package/src/plugins/puppeteer/proxy-manager.js +478 -0
- package/src/plugins/puppeteer/stealth-manager.js +556 -0
- package/src/plugins/puppeteer.errors.js +81 -0
- package/src/plugins/puppeteer.plugin.js +1327 -0
- package/src/plugins/queue-consumer.plugin.js +69 -14
- package/src/plugins/recon/behaviors/uptime-behavior.js +691 -0
- package/src/plugins/recon/concerns/command-runner.js +148 -0
- package/src/plugins/recon/concerns/diff-detector.js +372 -0
- package/src/plugins/recon/concerns/fingerprint-builder.js +307 -0
- package/src/plugins/recon/concerns/process-manager.js +338 -0
- package/src/plugins/recon/concerns/report-generator.js +478 -0
- package/src/plugins/recon/concerns/security-analyzer.js +571 -0
- package/src/plugins/recon/concerns/target-normalizer.js +68 -0
- package/src/plugins/recon/config/defaults.js +321 -0
- package/src/plugins/recon/config/resources.js +370 -0
- package/src/plugins/recon/index.js +778 -0
- package/src/plugins/recon/managers/dependency-manager.js +174 -0
- package/src/plugins/recon/managers/scheduler-manager.js +179 -0
- package/src/plugins/recon/managers/storage-manager.js +745 -0
- package/src/plugins/recon/managers/target-manager.js +274 -0
- package/src/plugins/recon/stages/asn-stage.js +314 -0
- package/src/plugins/recon/stages/certificate-stage.js +84 -0
- package/src/plugins/recon/stages/dns-stage.js +107 -0
- package/src/plugins/recon/stages/dnsdumpster-stage.js +362 -0
- package/src/plugins/recon/stages/fingerprint-stage.js +71 -0
- package/src/plugins/recon/stages/google-dorks-stage.js +440 -0
- package/src/plugins/recon/stages/http-stage.js +89 -0
- package/src/plugins/recon/stages/latency-stage.js +148 -0
- package/src/plugins/recon/stages/massdns-stage.js +302 -0
- package/src/plugins/recon/stages/osint-stage.js +1373 -0
- package/src/plugins/recon/stages/ports-stage.js +169 -0
- package/src/plugins/recon/stages/screenshot-stage.js +94 -0
- package/src/plugins/recon/stages/secrets-stage.js +514 -0
- package/src/plugins/recon/stages/subdomains-stage.js +295 -0
- package/src/plugins/recon/stages/tls-audit-stage.js +78 -0
- package/src/plugins/recon/stages/vulnerability-stage.js +78 -0
- package/src/plugins/recon/stages/web-discovery-stage.js +113 -0
- package/src/plugins/recon/stages/whois-stage.js +349 -0
- package/src/plugins/recon.plugin.js +75 -0
- package/src/plugins/recon.plugin.js.backup +2635 -0
- package/src/plugins/relation.errors.js +87 -14
- package/src/plugins/replicator.plugin.js +514 -137
- package/src/plugins/replicators/base-replicator.class.js +89 -1
- package/src/plugins/replicators/bigquery-replicator.class.js +66 -22
- package/src/plugins/replicators/dynamodb-replicator.class.js +22 -15
- package/src/plugins/replicators/mongodb-replicator.class.js +22 -15
- package/src/plugins/replicators/mysql-replicator.class.js +52 -17
- package/src/plugins/replicators/planetscale-replicator.class.js +30 -4
- package/src/plugins/replicators/postgres-replicator.class.js +62 -27
- package/src/plugins/replicators/s3db-replicator.class.js +25 -18
- package/src/plugins/replicators/schema-sync.helper.js +3 -3
- package/src/plugins/replicators/sqs-replicator.class.js +8 -2
- package/src/plugins/replicators/turso-replicator.class.js +23 -3
- package/src/plugins/replicators/webhook-replicator.class.js +42 -4
- package/src/plugins/s3-queue.plugin.js +464 -65
- package/src/plugins/scheduler.plugin.js +20 -6
- package/src/plugins/state-machine.plugin.js +40 -9
- package/src/plugins/tfstate/README.md +126 -126
- package/src/plugins/tfstate/base-driver.js +28 -4
- package/src/plugins/tfstate/errors.js +65 -10
- package/src/plugins/tfstate/filesystem-driver.js +52 -8
- package/src/plugins/tfstate/index.js +163 -90
- package/src/plugins/tfstate/s3-driver.js +64 -6
- package/src/plugins/ttl.plugin.js +72 -17
- package/src/plugins/vector/distances.js +18 -12
- package/src/plugins/vector/kmeans.js +26 -4
- package/src/resource.class.js +115 -19
- package/src/testing/factory.class.js +20 -3
- package/src/testing/seeder.class.js +7 -1
- package/src/clients/memory-client.md +0 -917
- package/src/plugins/cloud-inventory/drivers/mock-drivers.js +0 -449
|
@@ -359,26 +359,33 @@ class S3dbReplicator extends BaseReplicator {
|
|
|
359
359
|
return { skipped: true, reason: 'resource_not_included' };
|
|
360
360
|
}
|
|
361
361
|
|
|
362
|
-
const results =
|
|
363
|
-
|
|
362
|
+
const { results, errors } = await this.processBatch(
|
|
363
|
+
records,
|
|
364
|
+
async (record) => {
|
|
365
|
+
const [ok, err, result] = await tryFn(() => this.replicate({
|
|
366
|
+
resource: resourceName,
|
|
367
|
+
operation: record.operation,
|
|
368
|
+
id: record.id,
|
|
369
|
+
data: record.data,
|
|
370
|
+
beforeData: record.beforeData
|
|
371
|
+
}));
|
|
364
372
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
373
|
+
if (!ok) {
|
|
374
|
+
throw err;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
return result;
|
|
378
|
+
},
|
|
379
|
+
{
|
|
380
|
+
concurrency: this.config.batchConcurrency,
|
|
381
|
+
mapError: (error, record) => {
|
|
382
|
+
if (this.config.verbose) {
|
|
383
|
+
console.warn(`[S3dbReplicator] Batch replication failed for record ${record.id}: ${error.message}`);
|
|
384
|
+
}
|
|
385
|
+
return { id: record.id, error: error.message };
|
|
378
386
|
}
|
|
379
|
-
errors.push({ id: record.id, error: err.message });
|
|
380
387
|
}
|
|
381
|
-
|
|
388
|
+
);
|
|
382
389
|
|
|
383
390
|
// Log errors if any occurred during batch processing
|
|
384
391
|
if (errors.length > 0) {
|
|
@@ -487,4 +494,4 @@ class S3dbReplicator extends BaseReplicator {
|
|
|
487
494
|
}
|
|
488
495
|
}
|
|
489
496
|
|
|
490
|
-
export default S3dbReplicator;
|
|
497
|
+
export default S3dbReplicator;
|
|
@@ -11,15 +11,15 @@ import tryFn from "#src/concerns/try-fn.js";
|
|
|
11
11
|
* Filter out plugin attributes from attributes object
|
|
12
12
|
* Plugin attributes are internal implementation details and should not be replicated
|
|
13
13
|
* @param {Object} attributes - All attributes including plugin attributes
|
|
14
|
-
* @param {Object} resource - Resource instance with schema._pluginAttributes
|
|
14
|
+
* @param {Object} resource - Resource instance with $schema._pluginAttributes
|
|
15
15
|
* @returns {Object} Filtered attributes (user attributes only)
|
|
16
16
|
*/
|
|
17
17
|
function filterPluginAttributes(attributes, resource) {
|
|
18
|
-
if (!resource
|
|
18
|
+
if (!resource?.$schema?._pluginAttributes) {
|
|
19
19
|
return attributes;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
const pluginAttrNames = Object.values(resource
|
|
22
|
+
const pluginAttrNames = Object.values(resource.$schema._pluginAttributes).flat();
|
|
23
23
|
|
|
24
24
|
return Object.fromEntries(
|
|
25
25
|
Object.entries(attributes).filter(([name]) => !pluginAttrNames.includes(name))
|
|
@@ -88,7 +88,13 @@ class SqsReplicator extends BaseReplicator {
|
|
|
88
88
|
if (this.defaultQueue) {
|
|
89
89
|
return [this.defaultQueue];
|
|
90
90
|
}
|
|
91
|
-
throw
|
|
91
|
+
throw this.createError(`No queue URL found for resource '${resource}'`, {
|
|
92
|
+
operation: 'resolveQueue',
|
|
93
|
+
resourceName: resource,
|
|
94
|
+
statusCode: 404,
|
|
95
|
+
retriable: false,
|
|
96
|
+
suggestion: 'Provide queueUrl, defaultQueue, queues mapping, or resourceQueueMap for this resource.'
|
|
97
|
+
});
|
|
92
98
|
}
|
|
93
99
|
|
|
94
100
|
_applyTransformer(resource, data) {
|
|
@@ -382,4 +388,4 @@ class SqsReplicator extends BaseReplicator {
|
|
|
382
388
|
}
|
|
383
389
|
}
|
|
384
390
|
|
|
385
|
-
export default SqsReplicator;
|
|
391
|
+
export default SqsReplicator;
|
|
@@ -198,7 +198,15 @@ class TursoReplicator extends BaseReplicator {
|
|
|
198
198
|
const message = `Schema sync failed for table ${tableName}: ${errSync.message}`;
|
|
199
199
|
|
|
200
200
|
if (this.schemaSync.onMismatch === 'error') {
|
|
201
|
-
throw
|
|
201
|
+
throw this.createError(message, {
|
|
202
|
+
operation: 'schemaSync',
|
|
203
|
+
resourceName,
|
|
204
|
+
tableName,
|
|
205
|
+
statusCode: 409,
|
|
206
|
+
retriable: errSync?.retriable ?? false,
|
|
207
|
+
suggestion: 'Ensure the Turso table schema matches the resource definition or set schemaSync.onMismatch to warn/ignore.',
|
|
208
|
+
docs: 'docs/plugins/replicator.md'
|
|
209
|
+
});
|
|
202
210
|
} else if (this.schemaSync.onMismatch === 'warn') {
|
|
203
211
|
console.warn(`[TursoReplicator] ${message}`);
|
|
204
212
|
}
|
|
@@ -228,11 +236,23 @@ class TursoReplicator extends BaseReplicator {
|
|
|
228
236
|
|
|
229
237
|
if (!tableExists) {
|
|
230
238
|
if (!this.schemaSync.autoCreateTable) {
|
|
231
|
-
throw
|
|
239
|
+
throw this.createError(`Table ${tableName} does not exist and autoCreateTable is disabled`, {
|
|
240
|
+
operation: 'schemaSync',
|
|
241
|
+
tableName,
|
|
242
|
+
statusCode: 404,
|
|
243
|
+
retriable: false,
|
|
244
|
+
suggestion: 'Create the table manually or enable schemaSync.autoCreateTable.'
|
|
245
|
+
});
|
|
232
246
|
}
|
|
233
247
|
|
|
234
248
|
if (this.schemaSync.strategy === 'validate-only') {
|
|
235
|
-
throw
|
|
249
|
+
throw this.createError(`Table ${tableName} does not exist (validate-only mode)`, {
|
|
250
|
+
operation: 'schemaSync',
|
|
251
|
+
tableName,
|
|
252
|
+
statusCode: 404,
|
|
253
|
+
retriable: false,
|
|
254
|
+
suggestion: 'Provision the destination table before running validate-only checks or choose a different strategy.'
|
|
255
|
+
});
|
|
236
256
|
}
|
|
237
257
|
|
|
238
258
|
// Create table
|
|
@@ -84,7 +84,12 @@ class WebhookReplicator extends BaseReplicator {
|
|
|
84
84
|
// Required
|
|
85
85
|
this.url = config.url;
|
|
86
86
|
if (!this.url) {
|
|
87
|
-
throw
|
|
87
|
+
throw this.createError('WebhookReplicator requires a "url" configuration', {
|
|
88
|
+
operation: 'constructor',
|
|
89
|
+
statusCode: 400,
|
|
90
|
+
retriable: false,
|
|
91
|
+
suggestion: 'Provide the webhook endpoint URL: new WebhookReplicator({ url: "https://example.com/webhook" })'
|
|
92
|
+
});
|
|
88
93
|
}
|
|
89
94
|
|
|
90
95
|
// HTTP settings
|
|
@@ -441,7 +446,18 @@ class WebhookReplicator extends BaseReplicator {
|
|
|
441
446
|
return { success: true, status: response.status };
|
|
442
447
|
}
|
|
443
448
|
|
|
444
|
-
throw
|
|
449
|
+
throw this.createError(response.error || `HTTP ${response.status}: ${response.statusText}`, {
|
|
450
|
+
operation: 'replicate',
|
|
451
|
+
resourceName: resource,
|
|
452
|
+
statusCode: response.status ?? 502,
|
|
453
|
+
retriable: this.retryOnStatus?.includes?.(response.status ?? 0) ?? false,
|
|
454
|
+
suggestion: 'Inspect the webhook endpoint response and credentials, then retry after the remote service succeeds.',
|
|
455
|
+
metadata: {
|
|
456
|
+
status: response.status,
|
|
457
|
+
statusText: response.statusText,
|
|
458
|
+
url: this.url
|
|
459
|
+
}
|
|
460
|
+
});
|
|
445
461
|
});
|
|
446
462
|
|
|
447
463
|
if (ok) return result;
|
|
@@ -505,7 +521,19 @@ class WebhookReplicator extends BaseReplicator {
|
|
|
505
521
|
};
|
|
506
522
|
}
|
|
507
523
|
|
|
508
|
-
throw
|
|
524
|
+
throw this.createError(response.error || `HTTP ${response.status}: ${response.statusText}`, {
|
|
525
|
+
operation: 'replicateBatch',
|
|
526
|
+
resourceName: resource,
|
|
527
|
+
statusCode: response.status ?? 502,
|
|
528
|
+
retriable: this.retryOnStatus?.includes?.(response.status ?? 0) ?? false,
|
|
529
|
+
suggestion: 'Check the webhook batch payload, remote rate limits, and retry policy before retrying.',
|
|
530
|
+
metadata: {
|
|
531
|
+
status: response.status,
|
|
532
|
+
statusText: response.statusText,
|
|
533
|
+
url: this.url,
|
|
534
|
+
batchSize: records.length
|
|
535
|
+
}
|
|
536
|
+
});
|
|
509
537
|
}
|
|
510
538
|
|
|
511
539
|
// Otherwise, send individual requests (parallel)
|
|
@@ -562,7 +590,17 @@ class WebhookReplicator extends BaseReplicator {
|
|
|
562
590
|
const response = await this._makeRequest(testPayload);
|
|
563
591
|
|
|
564
592
|
if (!response.success) {
|
|
565
|
-
throw
|
|
593
|
+
throw this.createError(response.error || `HTTP ${response.status}: ${response.statusText}`, {
|
|
594
|
+
operation: 'testConnection',
|
|
595
|
+
statusCode: response.status ?? 502,
|
|
596
|
+
retriable: this.retryOnStatus?.includes?.(response.status ?? 0) ?? false,
|
|
597
|
+
suggestion: 'Confirm the webhook endpoint, authentication headers, and retryOnStatus settings before retrying.',
|
|
598
|
+
metadata: {
|
|
599
|
+
status: response.status,
|
|
600
|
+
statusText: response.statusText,
|
|
601
|
+
url: this.url
|
|
602
|
+
}
|
|
603
|
+
});
|
|
566
604
|
}
|
|
567
605
|
|
|
568
606
|
return true;
|