@byok-sdk/cloud-dataplane 0.4.2 → 0.5.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/README.md +7 -0
- package/dist/index.js +50 -1
- package/dist/index.js.map +1 -1
- package/dist/runtime.d.ts +1 -1
- package/dist/runtime.js +50 -1
- package/dist/runtime.js.map +1 -1
- package/dist/sql/0008_device_assertion_replay.sql +17 -0
- package/dist/stores/device-assertion-replay.d.ts +10 -0
- package/dist/stores/index.d.ts +1 -0
- package/package.json +4 -4
package/dist/runtime.d.ts
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
*/
|
|
27
27
|
export { createByokPool } from './pool';
|
|
28
28
|
export type { ByokPoolOptions } from './pool';
|
|
29
|
-
export { PostgresDeviceDirectory, PostgresInboundDedupStore, PostgresNonceStore, PostgresPairingCodeStore, PostgresProofRequestReceiptStore, PostgresRequestReceiptStore, PostgresTaskAttemptStore, PostgresActivityStore, PostgresApprovalTimelineStore, createPostgresCloudStores, } from './stores/index';
|
|
29
|
+
export { PostgresDeviceDirectory, PostgresInboundDedupStore, PostgresNonceStore, PostgresPairingCodeStore, PostgresProofRequestReceiptStore, PostgresRequestReceiptStore, PostgresTaskAttemptStore, PostgresActivityStore, PostgresApprovalTimelineStore, PostgresDeviceAssertionReplayAuthority, createPostgresCloudStores, } from './stores/index';
|
|
30
30
|
export type { PostgresCloudStoreOptions, PostgresCloudStores, PostgresObjectStorageOptions, } from './stores/index';
|
|
31
31
|
export { DEFAULT_MAX_ATTEMPTS, DEFAULT_PRESIGN_TTL_SECONDS, DEFAULT_RETRY_DELAY_MS, MAX_PRESIGN_TTL_SECONDS, MIN_PRESIGN_TTL_SECONDS, ObjectStoreRequestError, R2_BLOB_ERROR_CODES, R2BlobStoreError, R2CloudBlobStore, R2ObjectMaintenanceStore, } from './stores/index';
|
|
32
32
|
export type { ObjectStoreFetch, R2BlobErrorCode, R2BlobStoreOptions } from './stores/index';
|
package/dist/runtime.js
CHANGED
|
@@ -1382,6 +1382,55 @@ var PostgresApprovalTimelineStore = class {
|
|
|
1382
1382
|
}
|
|
1383
1383
|
};
|
|
1384
1384
|
|
|
1385
|
+
// src/stores/device-assertion-replay.ts
|
|
1386
|
+
var PostgresDeviceAssertionReplayAuthority = class {
|
|
1387
|
+
#pool;
|
|
1388
|
+
constructor(pool) {
|
|
1389
|
+
this.#pool = pool;
|
|
1390
|
+
}
|
|
1391
|
+
async consume(input) {
|
|
1392
|
+
if (!Number.isFinite(Date.parse(input.expiresAt))) {
|
|
1393
|
+
throw new Error("device assertion replay expiry is invalid");
|
|
1394
|
+
}
|
|
1395
|
+
const result = await this.#pool.query(
|
|
1396
|
+
`INSERT INTO device_assertion_replay (
|
|
1397
|
+
tenant_id, issuer, product_id, device_id, audience, jti, expires_at
|
|
1398
|
+
)
|
|
1399
|
+
VALUES ($1, $2, $3, $4, $5, $6, $7)
|
|
1400
|
+
ON CONFLICT (tenant_id, issuer, product_id, device_id, audience, jti) DO NOTHING
|
|
1401
|
+
RETURNING jti`,
|
|
1402
|
+
[
|
|
1403
|
+
input.tenantId,
|
|
1404
|
+
input.issuer,
|
|
1405
|
+
input.productId,
|
|
1406
|
+
input.deviceId,
|
|
1407
|
+
input.audience,
|
|
1408
|
+
input.jti,
|
|
1409
|
+
input.expiresAt
|
|
1410
|
+
]
|
|
1411
|
+
);
|
|
1412
|
+
return result.rowCount === 1;
|
|
1413
|
+
}
|
|
1414
|
+
/** Bounded retention cleanup; callers choose cadence and batch size. */
|
|
1415
|
+
async deleteExpired(before, limit) {
|
|
1416
|
+
if (!Number.isFinite(before.getTime()) || !Number.isSafeInteger(limit) || limit <= 0) {
|
|
1417
|
+
throw new Error("device assertion replay cleanup bounds are invalid");
|
|
1418
|
+
}
|
|
1419
|
+
const result = await this.#pool.query(
|
|
1420
|
+
`DELETE FROM device_assertion_replay
|
|
1421
|
+
WHERE ctid IN (
|
|
1422
|
+
SELECT ctid
|
|
1423
|
+
FROM device_assertion_replay
|
|
1424
|
+
WHERE expires_at <= $1
|
|
1425
|
+
ORDER BY expires_at
|
|
1426
|
+
LIMIT $2
|
|
1427
|
+
)`,
|
|
1428
|
+
[before.toISOString(), limit]
|
|
1429
|
+
);
|
|
1430
|
+
return result.rowCount ?? 0;
|
|
1431
|
+
}
|
|
1432
|
+
};
|
|
1433
|
+
|
|
1385
1434
|
// src/stores/index.ts
|
|
1386
1435
|
function createPostgresCloudStores(options) {
|
|
1387
1436
|
const { pool, clock, crypto } = options;
|
|
@@ -3304,6 +3353,6 @@ var PostgresTruthCommitter = class {
|
|
|
3304
3353
|
}
|
|
3305
3354
|
};
|
|
3306
3355
|
|
|
3307
|
-
export { DEFAULT_MAX_ATTEMPTS, DEFAULT_PRESIGN_TTL_SECONDS, DEFAULT_RETRY_DELAY_MS, MAX_PRESIGN_TTL_SECONDS, MIN_PRESIGN_TTL_SECONDS, ObjectStoreRequestError, PostgresActivityStore, PostgresApprovalTimelineStore, PostgresBoardStore, PostgresDeviceDirectory, PostgresInboundDedupStore, PostgresMailboxStore, PostgresNonceStore, PostgresObjectStore, PostgresPairingCodeStore, PostgresPresenceStore, PostgresProofRequestReceiptStore, PostgresQuotaStore, PostgresRequestReceiptStore, PostgresSkillPackStore, PostgresTaskAttemptStore, PostgresTruthCommitter, PostgresTruthStore, R2BlobStoreError, R2CloudBlobStore, R2ObjectMaintenanceStore, R2_BLOB_ERROR_CODES, createByokPool, createPostgresCloudStores, createPostgresCoreStores };
|
|
3356
|
+
export { DEFAULT_MAX_ATTEMPTS, DEFAULT_PRESIGN_TTL_SECONDS, DEFAULT_RETRY_DELAY_MS, MAX_PRESIGN_TTL_SECONDS, MIN_PRESIGN_TTL_SECONDS, ObjectStoreRequestError, PostgresActivityStore, PostgresApprovalTimelineStore, PostgresBoardStore, PostgresDeviceAssertionReplayAuthority, PostgresDeviceDirectory, PostgresInboundDedupStore, PostgresMailboxStore, PostgresNonceStore, PostgresObjectStore, PostgresPairingCodeStore, PostgresPresenceStore, PostgresProofRequestReceiptStore, PostgresQuotaStore, PostgresRequestReceiptStore, PostgresSkillPackStore, PostgresTaskAttemptStore, PostgresTruthCommitter, PostgresTruthStore, R2BlobStoreError, R2CloudBlobStore, R2ObjectMaintenanceStore, R2_BLOB_ERROR_CODES, createByokPool, createPostgresCloudStores, createPostgresCoreStores };
|
|
3308
3357
|
//# sourceMappingURL=runtime.js.map
|
|
3309
3358
|
//# sourceMappingURL=runtime.js.map
|