@spine-event-engine/server 2.0.0-snapshot.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/LICENSE +201 -0
- package/README.md +569 -0
- package/REFERENCE.md +488 -0
- package/dist/bus/command-bus.d.ts +61 -0
- package/dist/bus/command-bus.d.ts.map +1 -0
- package/dist/bus/command-bus.js +201 -0
- package/dist/bus/command-bus.js.map +1 -0
- package/dist/bus/command-dispatcher-registry.d.ts +33 -0
- package/dist/bus/command-dispatcher-registry.d.ts.map +1 -0
- package/dist/bus/command-dispatcher-registry.js +75 -0
- package/dist/bus/command-dispatcher-registry.js.map +1 -0
- package/dist/bus/command-dispatcher.d.ts +25 -0
- package/dist/bus/command-dispatcher.d.ts.map +1 -0
- package/dist/bus/command-dispatcher.js +15 -0
- package/dist/bus/command-dispatcher.js.map +1 -0
- package/dist/bus/command-errors.d.ts +23 -0
- package/dist/bus/command-errors.d.ts.map +1 -0
- package/dist/bus/command-errors.js +52 -0
- package/dist/bus/command-errors.js.map +1 -0
- package/dist/bus/event-bus.d.ts +113 -0
- package/dist/bus/event-bus.d.ts.map +1 -0
- package/dist/bus/event-bus.js +518 -0
- package/dist/bus/event-bus.js.map +1 -0
- package/dist/bus/event-dispatcher-origin-schemas.d.ts +17 -0
- package/dist/bus/event-dispatcher-origin-schemas.d.ts.map +1 -0
- package/dist/bus/event-dispatcher-origin-schemas.js +32 -0
- package/dist/bus/event-dispatcher-origin-schemas.js.map +1 -0
- package/dist/bus/event-dispatcher-registry.d.ts +48 -0
- package/dist/bus/event-dispatcher-registry.d.ts.map +1 -0
- package/dist/bus/event-dispatcher-registry.js +176 -0
- package/dist/bus/event-dispatcher-registry.js.map +1 -0
- package/dist/bus/event-dispatcher.d.ts +48 -0
- package/dist/bus/event-dispatcher.d.ts.map +1 -0
- package/dist/bus/event-dispatcher.js +15 -0
- package/dist/bus/event-dispatcher.js.map +1 -0
- package/dist/context/bounded-context.d.ts +606 -0
- package/dist/context/bounded-context.d.ts.map +1 -0
- package/dist/context/bounded-context.js +1780 -0
- package/dist/context/bounded-context.js.map +1 -0
- package/dist/context/entity-inbox.d.ts +63 -0
- package/dist/context/entity-inbox.d.ts.map +1 -0
- package/dist/context/entity-inbox.js +380 -0
- package/dist/context/entity-inbox.js.map +1 -0
- package/dist/context/local-inbox-handoff.d.ts +244 -0
- package/dist/context/local-inbox-handoff.d.ts.map +1 -0
- package/dist/context/local-inbox-handoff.js +334 -0
- package/dist/context/local-inbox-handoff.js.map +1 -0
- package/dist/context/projection-handoff.d.ts +46 -0
- package/dist/context/projection-handoff.d.ts.map +1 -0
- package/dist/context/projection-handoff.js +172 -0
- package/dist/context/projection-handoff.js.map +1 -0
- package/dist/context/tenant-index.d.ts +41 -0
- package/dist/context/tenant-index.d.ts.map +1 -0
- package/dist/context/tenant-index.js +92 -0
- package/dist/context/tenant-index.js.map +1 -0
- package/dist/delivery/conditional-pickup.d.ts +25 -0
- package/dist/delivery/conditional-pickup.d.ts.map +1 -0
- package/dist/delivery/conditional-pickup.js +26 -0
- package/dist/delivery/conditional-pickup.js.map +1 -0
- package/dist/delivery/delivery-builder.d.ts +216 -0
- package/dist/delivery/delivery-builder.d.ts.map +1 -0
- package/dist/delivery/delivery-builder.js +323 -0
- package/dist/delivery/delivery-builder.js.map +1 -0
- package/dist/delivery/delivery-lease.d.ts +15 -0
- package/dist/delivery/delivery-lease.d.ts.map +1 -0
- package/dist/delivery/delivery-lease.js +44 -0
- package/dist/delivery/delivery-lease.js.map +1 -0
- package/dist/delivery/delivery-loop.d.ts +113 -0
- package/dist/delivery/delivery-loop.d.ts.map +1 -0
- package/dist/delivery/delivery-loop.js +119 -0
- package/dist/delivery/delivery-loop.js.map +1 -0
- package/dist/delivery/delivery-monitor.d.ts +165 -0
- package/dist/delivery/delivery-monitor.d.ts.map +1 -0
- package/dist/delivery/delivery-monitor.js +168 -0
- package/dist/delivery/delivery-monitor.js.map +1 -0
- package/dist/delivery/delivery-ports.d.ts +141 -0
- package/dist/delivery/delivery-ports.d.ts.map +1 -0
- package/dist/delivery/delivery-ports.js +15 -0
- package/dist/delivery/delivery-ports.js.map +1 -0
- package/dist/delivery/delivery-run-control.d.ts +50 -0
- package/dist/delivery/delivery-run-control.d.ts.map +1 -0
- package/dist/delivery/delivery-run-control.js +66 -0
- package/dist/delivery/delivery-run-control.js.map +1 -0
- package/dist/delivery/delivery-run-coordinator.d.ts +218 -0
- package/dist/delivery/delivery-run-coordinator.d.ts.map +1 -0
- package/dist/delivery/delivery-run-coordinator.js +609 -0
- package/dist/delivery/delivery-run-coordinator.js.map +1 -0
- package/dist/delivery/delivery-storage-error.d.ts +13 -0
- package/dist/delivery/delivery-storage-error.d.ts.map +1 -0
- package/dist/delivery/delivery-storage-error.js +30 -0
- package/dist/delivery/delivery-storage-error.js.map +1 -0
- package/dist/delivery/delivery-supervisor.d.ts +175 -0
- package/dist/delivery/delivery-supervisor.d.ts.map +1 -0
- package/dist/delivery/delivery-supervisor.js +469 -0
- package/dist/delivery/delivery-supervisor.js.map +1 -0
- package/dist/delivery/delivery-worker.d.ts +180 -0
- package/dist/delivery/delivery-worker.d.ts.map +1 -0
- package/dist/delivery/delivery-worker.js +232 -0
- package/dist/delivery/delivery-worker.js.map +1 -0
- package/dist/delivery/delivery.d.ts +238 -0
- package/dist/delivery/delivery.d.ts.map +1 -0
- package/dist/delivery/delivery.js +400 -0
- package/dist/delivery/delivery.js.map +1 -0
- package/dist/delivery/inbox-records.d.ts +19 -0
- package/dist/delivery/inbox-records.d.ts.map +1 -0
- package/dist/delivery/inbox-records.js +291 -0
- package/dist/delivery/inbox-records.js.map +1 -0
- package/dist/delivery/inbox-storage.d.ts +81 -0
- package/dist/delivery/inbox-storage.d.ts.map +1 -0
- package/dist/delivery/inbox-storage.js +353 -0
- package/dist/delivery/inbox-storage.js.map +1 -0
- package/dist/delivery/inbox.d.ts +263 -0
- package/dist/delivery/inbox.d.ts.map +1 -0
- package/dist/delivery/inbox.js +172 -0
- package/dist/delivery/inbox.js.map +1 -0
- package/dist/delivery/parked-delivery-obligations.d.ts +182 -0
- package/dist/delivery/parked-delivery-obligations.d.ts.map +1 -0
- package/dist/delivery/parked-delivery-obligations.js +390 -0
- package/dist/delivery/parked-delivery-obligations.js.map +1 -0
- package/dist/delivery/shard-index.d.ts +41 -0
- package/dist/delivery/shard-index.d.ts.map +1 -0
- package/dist/delivery/shard-index.js +67 -0
- package/dist/delivery/shard-index.js.map +1 -0
- package/dist/delivery/sharded-work-registry.d.ts +114 -0
- package/dist/delivery/sharded-work-registry.d.ts.map +1 -0
- package/dist/delivery/sharded-work-registry.js +360 -0
- package/dist/delivery/sharded-work-registry.js.map +1 -0
- package/dist/entity/entity-metadata.d.ts +173 -0
- package/dist/entity/entity-metadata.d.ts.map +1 -0
- package/dist/entity/entity-metadata.js +187 -0
- package/dist/entity/entity-metadata.js.map +1 -0
- package/dist/entity/entity-storage-descriptor.d.ts +64 -0
- package/dist/entity/entity-storage-descriptor.d.ts.map +1 -0
- package/dist/entity/entity-storage-descriptor.js +227 -0
- package/dist/entity/entity-storage-descriptor.js.map +1 -0
- package/dist/entity/entity-transaction.d.ts +372 -0
- package/dist/entity/entity-transaction.d.ts.map +1 -0
- package/dist/entity/entity-transaction.js +413 -0
- package/dist/entity/entity-transaction.js.map +1 -0
- package/dist/entity/entity-transition-validation.d.ts +47 -0
- package/dist/entity/entity-transition-validation.d.ts.map +1 -0
- package/dist/entity/entity-transition-validation.js +327 -0
- package/dist/entity/entity-transition-validation.js.map +1 -0
- package/dist/entity/entity.d.ts +499 -0
- package/dist/entity/entity.d.ts.map +1 -0
- package/dist/entity/entity.js +829 -0
- package/dist/entity/entity.js.map +1 -0
- package/dist/entity/implicit-required-id.d.ts +15 -0
- package/dist/entity/implicit-required-id.d.ts.map +1 -0
- package/dist/entity/implicit-required-id.js +123 -0
- package/dist/entity/implicit-required-id.js.map +1 -0
- package/dist/entity/spec-scanner.d.ts +14 -0
- package/dist/entity/spec-scanner.d.ts.map +1 -0
- package/dist/entity/spec-scanner.js +37 -0
- package/dist/entity/spec-scanner.js.map +1 -0
- package/dist/handler/build-time-handler-analyzer.d.ts +150 -0
- package/dist/handler/build-time-handler-analyzer.d.ts.map +1 -0
- package/dist/handler/build-time-handler-analyzer.js +1101 -0
- package/dist/handler/build-time-handler-analyzer.js.map +1 -0
- package/dist/handler/command-registration-readiness.d.ts +99 -0
- package/dist/handler/command-registration-readiness.d.ts.map +1 -0
- package/dist/handler/command-registration-readiness.js +118 -0
- package/dist/handler/command-registration-readiness.js.map +1 -0
- package/dist/handler/event-handler-filter.d.ts +43 -0
- package/dist/handler/event-handler-filter.d.ts.map +1 -0
- package/dist/handler/event-handler-filter.js +128 -0
- package/dist/handler/event-handler-filter.js.map +1 -0
- package/dist/handler/event-registration-readiness.d.ts +196 -0
- package/dist/handler/event-registration-readiness.d.ts.map +1 -0
- package/dist/handler/event-registration-readiness.js +187 -0
- package/dist/handler/event-registration-readiness.js.map +1 -0
- package/dist/handler/external.d.ts +10 -0
- package/dist/handler/external.d.ts.map +1 -0
- package/dist/handler/external.js +15 -0
- package/dist/handler/external.js.map +1 -0
- package/dist/handler/generated-handler-registry.d.ts +154 -0
- package/dist/handler/generated-handler-registry.d.ts.map +1 -0
- package/dist/handler/generated-handler-registry.js +223 -0
- package/dist/handler/generated-handler-registry.js.map +1 -0
- package/dist/handler/generated-registry-discovery.d.ts +94 -0
- package/dist/handler/generated-registry-discovery.d.ts.map +1 -0
- package/dist/handler/generated-registry-discovery.js +228 -0
- package/dist/handler/generated-registry-discovery.js.map +1 -0
- package/dist/handler/generated-registry-writer.d.ts +58 -0
- package/dist/handler/generated-registry-writer.d.ts.map +1 -0
- package/dist/handler/generated-registry-writer.js +458 -0
- package/dist/handler/generated-registry-writer.js.map +1 -0
- package/dist/handler/handler-codegen.d.ts +48 -0
- package/dist/handler/handler-codegen.d.ts.map +1 -0
- package/dist/handler/handler-codegen.js +214 -0
- package/dist/handler/handler-codegen.js.map +1 -0
- package/dist/handler/handler-decorators.d.ts +134 -0
- package/dist/handler/handler-decorators.d.ts.map +1 -0
- package/dist/handler/handler-decorators.js +239 -0
- package/dist/handler/handler-decorators.js.map +1 -0
- package/dist/handler/handler-metadata.d.ts +510 -0
- package/dist/handler/handler-metadata.d.ts.map +1 -0
- package/dist/handler/handler-metadata.js +391 -0
- package/dist/handler/handler-metadata.js.map +1 -0
- package/dist/handler/registration-readiness-metadata.d.ts +68 -0
- package/dist/handler/registration-readiness-metadata.d.ts.map +1 -0
- package/dist/handler/registration-readiness-metadata.js +170 -0
- package/dist/handler/registration-readiness-metadata.js.map +1 -0
- package/dist/handler/rejection-source.d.ts +11 -0
- package/dist/handler/rejection-source.d.ts.map +1 -0
- package/dist/handler/rejection-source.js +25 -0
- package/dist/handler/rejection-source.js.map +1 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +54 -0
- package/dist/index.js.map +1 -0
- package/dist/integration/external-messages.d.ts +49 -0
- package/dist/integration/external-messages.d.ts.map +1 -0
- package/dist/integration/external-messages.js +112 -0
- package/dist/integration/external-messages.js.map +1 -0
- package/dist/integration/integration-broker.d.ts +74 -0
- package/dist/integration/integration-broker.d.ts.map +1 -0
- package/dist/integration/integration-broker.js +444 -0
- package/dist/integration/integration-broker.js.map +1 -0
- package/dist/integration/third-party-context.d.ts +56 -0
- package/dist/integration/third-party-context.d.ts.map +1 -0
- package/dist/integration/third-party-context.js +130 -0
- package/dist/integration/third-party-context.js.map +1 -0
- package/dist/repository/command-errors.d.ts +25 -0
- package/dist/repository/command-errors.d.ts.map +1 -0
- package/dist/repository/command-errors.js +43 -0
- package/dist/repository/command-errors.js.map +1 -0
- package/dist/repository/command-routing.d.ts +72 -0
- package/dist/repository/command-routing.d.ts.map +1 -0
- package/dist/repository/command-routing.js +98 -0
- package/dist/repository/command-routing.js.map +1 -0
- package/dist/repository/commit-fence.d.ts +22 -0
- package/dist/repository/commit-fence.d.ts.map +1 -0
- package/dist/repository/commit-fence.js +37 -0
- package/dist/repository/commit-fence.js.map +1 -0
- package/dist/repository/event-routing.d.ts +71 -0
- package/dist/repository/event-routing.d.ts.map +1 -0
- package/dist/repository/event-routing.js +96 -0
- package/dist/repository/event-routing.js.map +1 -0
- package/dist/repository/primitive-id.d.ts +86 -0
- package/dist/repository/primitive-id.d.ts.map +1 -0
- package/dist/repository/primitive-id.js +110 -0
- package/dist/repository/primitive-id.js.map +1 -0
- package/dist/repository/repository.d.ts +670 -0
- package/dist/repository/repository.d.ts.map +1 -0
- package/dist/repository/repository.js +3298 -0
- package/dist/repository/repository.js.map +1 -0
- package/dist/repository/routing-declarations.d.ts +75 -0
- package/dist/repository/routing-declarations.d.ts.map +1 -0
- package/dist/repository/routing-declarations.js +101 -0
- package/dist/repository/routing-declarations.js.map +1 -0
- package/dist/repository/state-update-routing.d.ts +66 -0
- package/dist/repository/state-update-routing.d.ts.map +1 -0
- package/dist/repository/state-update-routing.js +91 -0
- package/dist/repository/state-update-routing.js.map +1 -0
- package/dist/runtime/runtime.d.ts +156 -0
- package/dist/runtime/runtime.d.ts.map +1 -0
- package/dist/runtime/runtime.js +215 -0
- package/dist/runtime/runtime.js.map +1 -0
- package/dist/runtime/signal-intake.d.ts +84 -0
- package/dist/runtime/signal-intake.d.ts.map +1 -0
- package/dist/runtime/signal-intake.js +94 -0
- package/dist/runtime/signal-intake.js.map +1 -0
- package/dist/runtime/signal-metadata.d.ts +242 -0
- package/dist/runtime/signal-metadata.d.ts.map +1 -0
- package/dist/runtime/signal-metadata.js +368 -0
- package/dist/runtime/signal-metadata.js.map +1 -0
- package/dist/server/browser-server.d.ts +49 -0
- package/dist/server/browser-server.d.ts.map +1 -0
- package/dist/server/browser-server.js +633 -0
- package/dist/server/browser-server.js.map +1 -0
- package/dist/server/durable-subscription-bindings.d.ts +122 -0
- package/dist/server/durable-subscription-bindings.d.ts.map +1 -0
- package/dist/server/durable-subscription-bindings.js +524 -0
- package/dist/server/durable-subscription-bindings.js.map +1 -0
- package/dist/server/environment-attachment.d.ts +356 -0
- package/dist/server/environment-attachment.d.ts.map +1 -0
- package/dist/server/environment-attachment.js +2061 -0
- package/dist/server/environment-attachment.js.map +1 -0
- package/dist/server/environment-delivery-records.d.ts +77 -0
- package/dist/server/environment-delivery-records.d.ts.map +1 -0
- package/dist/server/environment-delivery-records.js +282 -0
- package/dist/server/environment-delivery-records.js.map +1 -0
- package/dist/server/environment-delivery-worker.d.ts +161 -0
- package/dist/server/environment-delivery-worker.d.ts.map +1 -0
- package/dist/server/environment-delivery-worker.js +664 -0
- package/dist/server/environment-delivery-worker.js.map +1 -0
- package/dist/server/environment.d.ts +43 -0
- package/dist/server/environment.d.ts.map +1 -0
- package/dist/server/environment.js +90 -0
- package/dist/server/environment.js.map +1 -0
- package/dist/server/managed-child-subscription.d.ts +11 -0
- package/dist/server/managed-child-subscription.d.ts.map +1 -0
- package/dist/server/managed-child-subscription.js +44 -0
- package/dist/server/managed-child-subscription.js.map +1 -0
- package/dist/server/managed-server-application.d.ts +324 -0
- package/dist/server/managed-server-application.d.ts.map +1 -0
- package/dist/server/managed-server-application.js +937 -0
- package/dist/server/managed-server-application.js.map +1 -0
- package/dist/server/node-coordinator.d.ts +191 -0
- package/dist/server/node-coordinator.d.ts.map +1 -0
- package/dist/server/node-coordinator.js +552 -0
- package/dist/server/node-coordinator.js.map +1 -0
- package/dist/server/process-server-coordinator.d.ts +15 -0
- package/dist/server/process-server-coordinator.d.ts.map +1 -0
- package/dist/server/process-server-coordinator.js +112 -0
- package/dist/server/process-server-coordinator.js.map +1 -0
- package/dist/server/reserved-spine-rpc-paths.json +8 -0
- package/dist/server/retryable-close.d.ts +28 -0
- package/dist/server/retryable-close.d.ts.map +1 -0
- package/dist/server/retryable-close.js +129 -0
- package/dist/server/retryable-close.js.map +1 -0
- package/dist/server/server-environment.d.ts +180 -0
- package/dist/server/server-environment.d.ts.map +1 -0
- package/dist/server/server-environment.js +418 -0
- package/dist/server/server-environment.js.map +1 -0
- package/dist/server/server-log.d.ts +18 -0
- package/dist/server/server-log.d.ts.map +1 -0
- package/dist/server/server-log.js +96 -0
- package/dist/server/server-log.js.map +1 -0
- package/dist/server/server.d.ts +389 -0
- package/dist/server/server.d.ts.map +1 -0
- package/dist/server/server.js +752 -0
- package/dist/server/server.js.map +1 -0
- package/dist/services/spine-services.d.ts +88 -0
- package/dist/services/spine-services.d.ts.map +1 -0
- package/dist/services/spine-services.js +1586 -0
- package/dist/services/spine-services.js.map +1 -0
- package/dist/stand/stand.d.ts +294 -0
- package/dist/stand/stand.d.ts.map +1 -0
- package/dist/stand/stand.js +680 -0
- package/dist/stand/stand.js.map +1 -0
- package/dist/stand/subscription-observer.d.ts +53 -0
- package/dist/stand/subscription-observer.d.ts.map +1 -0
- package/dist/stand/subscription-observer.js +444 -0
- package/dist/stand/subscription-observer.js.map +1 -0
- package/dist/stand/subscription-records.d.ts +12 -0
- package/dist/stand/subscription-records.d.ts.map +1 -0
- package/dist/stand/subscription-records.js +99 -0
- package/dist/stand/subscription-records.js.map +1 -0
- package/dist/stand/subscription-registry.d.ts +285 -0
- package/dist/stand/subscription-registry.d.ts.map +1 -0
- package/dist/stand/subscription-registry.js +403 -0
- package/dist/stand/subscription-registry.js.map +1 -0
- package/dist/stand/subscription-runtime.d.ts +102 -0
- package/dist/stand/subscription-runtime.d.ts.map +1 -0
- package/dist/stand/subscription-runtime.js +380 -0
- package/dist/stand/subscription-runtime.js.map +1 -0
- package/dist/testing/index.d.ts +14 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +34 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +65 -0
|
@@ -0,0 +1,524 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026, CodeMatters. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
|
5
|
+
* in compliance with the License. You may obtain a copy of the License at
|
|
6
|
+
*
|
|
7
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
|
10
|
+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
|
11
|
+
* or implied. See the License for the specific language governing permissions and limitations under
|
|
12
|
+
* the License.
|
|
13
|
+
*/
|
|
14
|
+
import { clone, create, fromBinary, ScalarType, toBinary } from "@bufbuild/protobuf";
|
|
15
|
+
import { timestampFromMs } from "@bufbuild/protobuf/wkt";
|
|
16
|
+
import { GatewayAuthenticatedSubscriptionSchema, } from "@spine-event-engine/proto/auth";
|
|
17
|
+
import { SubscriptionIdSchema, SubscriptionSchema, TopicSchema, } from "@spine-event-engine/proto/client";
|
|
18
|
+
import { TenantIdSchema } from "@spine-event-engine/proto";
|
|
19
|
+
import { ColumnTypes, RecordColumn, RecordSpec, } from "@spine-event-engine/storage";
|
|
20
|
+
const expiryBatchSize = 25;
|
|
21
|
+
const durableCleanupStates = new WeakMap();
|
|
22
|
+
/**
|
|
23
|
+
* Persists the approved authenticated subscription message directly.
|
|
24
|
+
*
|
|
25
|
+
* This handle serializes only operations for a single ID in this Gateway
|
|
26
|
+
* process. It intentionally does not coordinate multiple Gateway processes.
|
|
27
|
+
*/
|
|
28
|
+
export class DurableSubscriptionBindings {
|
|
29
|
+
// prettier-ignore
|
|
30
|
+
/**
|
|
31
|
+
* Names the Gateway storage context.
|
|
32
|
+
*/
|
|
33
|
+
namespace;
|
|
34
|
+
#storage;
|
|
35
|
+
#nextId;
|
|
36
|
+
#pending = new Map();
|
|
37
|
+
#active = new Map();
|
|
38
|
+
#limits;
|
|
39
|
+
#queued = new Map();
|
|
40
|
+
#running = new Set();
|
|
41
|
+
#purgeHorizon;
|
|
42
|
+
#activePurgeHorizon;
|
|
43
|
+
#purging;
|
|
44
|
+
#closed = false;
|
|
45
|
+
#closing;
|
|
46
|
+
/**
|
|
47
|
+
* Opens a durable store without taking ownership of the supplied factory.
|
|
48
|
+
*
|
|
49
|
+
* @param options Supplies storage, identity allocation, and backend cleanup.
|
|
50
|
+
*/
|
|
51
|
+
constructor(options) {
|
|
52
|
+
if (options.namespace.trim().length === 0)
|
|
53
|
+
throw new Error("Gateway namespace must be non-blank.");
|
|
54
|
+
this.namespace = options.namespace;
|
|
55
|
+
durableCleanupStates.set(this, { caller: options.cleanup, backend: undefined });
|
|
56
|
+
this.#limits = {
|
|
57
|
+
pendingOperationLimit: 1,
|
|
58
|
+
operationTimeoutMs: 30_000,
|
|
59
|
+
shutdownTimeoutMs: 1_000,
|
|
60
|
+
...options.limits,
|
|
61
|
+
};
|
|
62
|
+
for (const limit of Object.values(this.#limits))
|
|
63
|
+
if (!Number.isSafeInteger(limit) || limit <= 0)
|
|
64
|
+
throw new Error("subscription limits must be positive safe integers");
|
|
65
|
+
this.#nextId = options.nextId;
|
|
66
|
+
this.#storage = options.storageFactory.createRecordStorage({ name: `spine.auth.${options.namespace}`, multitenant: false }, new RecordSpec({
|
|
67
|
+
recordType: GatewayAuthenticatedSubscriptionSchema,
|
|
68
|
+
idSchema: SubscriptionIdSchema,
|
|
69
|
+
extractId: (record) => {
|
|
70
|
+
if (record.id === undefined)
|
|
71
|
+
throw new Error("Authenticated subscription has no ID.");
|
|
72
|
+
return record.id;
|
|
73
|
+
},
|
|
74
|
+
columns: [
|
|
75
|
+
new RecordColumn("when_expires", ColumnTypes.scalar(ScalarType.INT64), (record) => DurableSubscriptionValues.expiryMs(record.whenExpires)),
|
|
76
|
+
],
|
|
77
|
+
}));
|
|
78
|
+
if (!this.#storage.atomicCompareAndSet) {
|
|
79
|
+
this.#storage.close();
|
|
80
|
+
throw new Error("Authenticated subscription storage requires atomic compare-and-set.");
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Creates one inactive authenticated subscription from a trusted topic.
|
|
85
|
+
* @param input Supplies the trusted topic and expiry.
|
|
86
|
+
* @returns The stored public subscription definition.
|
|
87
|
+
*/
|
|
88
|
+
create(input) {
|
|
89
|
+
return this.#admit(() => this.#create(input));
|
|
90
|
+
}
|
|
91
|
+
async #create(input) {
|
|
92
|
+
const id = this.#nextId();
|
|
93
|
+
if (id.trim().length === 0)
|
|
94
|
+
throw new Error("subscription ID must be non-blank");
|
|
95
|
+
const topic = fromBinary(TopicSchema, input.topic.bytes);
|
|
96
|
+
if (topic.context === undefined)
|
|
97
|
+
throw new Error("Authenticated subscription topic has no trusted context.");
|
|
98
|
+
const subscription = create(SubscriptionSchema, {
|
|
99
|
+
id: create(SubscriptionIdSchema, { value: id }),
|
|
100
|
+
topic,
|
|
101
|
+
});
|
|
102
|
+
const record = create(GatewayAuthenticatedSubscriptionSchema, {
|
|
103
|
+
id: create(SubscriptionIdSchema, { value: id }),
|
|
104
|
+
subscription: clone(SubscriptionSchema, subscription),
|
|
105
|
+
whenExpires: timestampFromMs(input.whenExpires),
|
|
106
|
+
});
|
|
107
|
+
DurableSubscriptionValues.validate(record);
|
|
108
|
+
const recordId = record.id;
|
|
109
|
+
if (recordId === undefined)
|
|
110
|
+
throw new Error("Authenticated subscription has no ID.");
|
|
111
|
+
let applied;
|
|
112
|
+
try {
|
|
113
|
+
applied = await this.#storage.compareAndSet(recordId, undefined, record);
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
const current = await this.#storage.read(recordId);
|
|
117
|
+
if (current !== undefined && DurableSubscriptionValues.same(current, record))
|
|
118
|
+
return DurableSubscriptionValues.wire(record);
|
|
119
|
+
throw error;
|
|
120
|
+
}
|
|
121
|
+
if (!applied) {
|
|
122
|
+
const current = await this.#storage.read(recordId);
|
|
123
|
+
if (current === undefined || !DurableSubscriptionValues.same(current, record))
|
|
124
|
+
throw new Error("subscription ID must be unique");
|
|
125
|
+
}
|
|
126
|
+
return DurableSubscriptionValues.wire(record);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Activates a retained definition after checking its exact authenticated context.
|
|
130
|
+
*
|
|
131
|
+
* @param input Supplies the retained ID, authenticated context, clock, callback, and cancellation signal.
|
|
132
|
+
* @returns The activation outcome.
|
|
133
|
+
*/
|
|
134
|
+
activate(input) {
|
|
135
|
+
return this.#forId(input.id, async () => {
|
|
136
|
+
if (input.signal.aborted)
|
|
137
|
+
return { kind: "denied" };
|
|
138
|
+
const record = await this.#read(input.id);
|
|
139
|
+
if (record === undefined ||
|
|
140
|
+
this.#expired(record, input.nowMs) ||
|
|
141
|
+
!DurableSubscriptionValues.owns(record, input.context))
|
|
142
|
+
return { kind: "denied" };
|
|
143
|
+
await this.#callbackForId(input.id, input.onDefinition, DurableSubscriptionValues.wire(record), input.signal, true);
|
|
144
|
+
return { kind: "activated" };
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Removes a retained definition only after backend cleanup succeeds.
|
|
149
|
+
*
|
|
150
|
+
* @param input Supplies the retained ID, authenticated context, clock, and cleanup callback.
|
|
151
|
+
* @returns The cancellation outcome.
|
|
152
|
+
*/
|
|
153
|
+
cancel(input) {
|
|
154
|
+
this.#active.get(input.id)?.abort();
|
|
155
|
+
return this.#forId(input.id, async () => {
|
|
156
|
+
const record = await this.#read(input.id);
|
|
157
|
+
if (record === undefined)
|
|
158
|
+
return { kind: "closed" };
|
|
159
|
+
if (this.#expired(record, input.nowMs) ||
|
|
160
|
+
!DurableSubscriptionValues.owns(record, input.context))
|
|
161
|
+
return { kind: "denied" };
|
|
162
|
+
await this.#callbackForId(input.id, input.onDefinition, DurableSubscriptionValues.wire(record));
|
|
163
|
+
const recordId = record.id;
|
|
164
|
+
if (recordId === undefined)
|
|
165
|
+
throw new Error("Authenticated subscription has no ID.");
|
|
166
|
+
if (await this.#storage.compareAndSet(recordId, record, undefined))
|
|
167
|
+
return { kind: "closed" };
|
|
168
|
+
return (await this.#storage.read(recordId)) === undefined
|
|
169
|
+
? { kind: "closed" }
|
|
170
|
+
: { kind: "denied" };
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Removes at most the earliest 25 expired definitions.
|
|
175
|
+
*
|
|
176
|
+
* @param nowMs Supplies the current epoch milliseconds.
|
|
177
|
+
* @returns A completion result after the bounded cleanup pass.
|
|
178
|
+
*/
|
|
179
|
+
purgeExpired(nowMs) {
|
|
180
|
+
try {
|
|
181
|
+
this.#open();
|
|
182
|
+
}
|
|
183
|
+
catch {
|
|
184
|
+
return Promise.reject(new Error("authenticated subscription store is closed"));
|
|
185
|
+
}
|
|
186
|
+
if (this.#purging !== undefined) {
|
|
187
|
+
const coveredHorizon = Math.max(this.#activePurgeHorizon ?? Number.NEGATIVE_INFINITY, this.#purgeHorizon ?? Number.NEGATIVE_INFINITY);
|
|
188
|
+
if (nowMs > coveredHorizon)
|
|
189
|
+
this.#purgeHorizon = nowMs;
|
|
190
|
+
return this.#purging;
|
|
191
|
+
}
|
|
192
|
+
this.#purgeHorizon = Math.max(this.#purgeHorizon ?? nowMs, nowMs);
|
|
193
|
+
const task = this.#drainPurges();
|
|
194
|
+
this.#purging = task;
|
|
195
|
+
this.#track(task);
|
|
196
|
+
void task.then(() => {
|
|
197
|
+
if (this.#purging === task)
|
|
198
|
+
this.#purging = undefined;
|
|
199
|
+
}, () => {
|
|
200
|
+
if (this.#purging === task)
|
|
201
|
+
this.#purging = undefined;
|
|
202
|
+
});
|
|
203
|
+
return task;
|
|
204
|
+
}
|
|
205
|
+
async #drainPurges() {
|
|
206
|
+
while (this.#purgeHorizon !== undefined) {
|
|
207
|
+
const horizon = this.#purgeHorizon;
|
|
208
|
+
this.#purgeHorizon = undefined;
|
|
209
|
+
this.#activePurgeHorizon = horizon;
|
|
210
|
+
try {
|
|
211
|
+
await this.#purgeExpired(horizon);
|
|
212
|
+
}
|
|
213
|
+
finally {
|
|
214
|
+
this.#activePurgeHorizon = undefined;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
async #purgeExpired(nowMs) {
|
|
219
|
+
const records = await this.#storage.queryEntries({
|
|
220
|
+
sort: [{ field: "when_expires" }, { field: "id" }],
|
|
221
|
+
limit: expiryBatchSize,
|
|
222
|
+
});
|
|
223
|
+
for (const { id: slotId, record } of records) {
|
|
224
|
+
DurableSubscriptionValues.validate(record, slotId);
|
|
225
|
+
if (!this.#expired(record, nowMs))
|
|
226
|
+
break;
|
|
227
|
+
const id = slotId.value;
|
|
228
|
+
this.#active.get(id)?.abort();
|
|
229
|
+
await this.#forId(id, () => this.#removeExpired(record), true);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Restores every unexpired durable definition and removes expired rows.
|
|
234
|
+
*
|
|
235
|
+
* @param input Supplies the current epoch milliseconds and rehydration callback.
|
|
236
|
+
* @returns A completion result after recovery.
|
|
237
|
+
*/
|
|
238
|
+
recoverActive(input) {
|
|
239
|
+
return this.#admit(() => this.#recoverActive(input));
|
|
240
|
+
}
|
|
241
|
+
async #recoverActive(input) {
|
|
242
|
+
let after;
|
|
243
|
+
for (;;) {
|
|
244
|
+
const page = await this.#storage.queryEntries({
|
|
245
|
+
sort: [{ field: "id" }],
|
|
246
|
+
limit: expiryBatchSize,
|
|
247
|
+
...(after === undefined ? {} : { after }),
|
|
248
|
+
});
|
|
249
|
+
if (page.length === 0)
|
|
250
|
+
return;
|
|
251
|
+
for (const { id: slotId, record } of page) {
|
|
252
|
+
DurableSubscriptionValues.validate(record, slotId);
|
|
253
|
+
const id = slotId.value;
|
|
254
|
+
await this.#forId(id, async () => {
|
|
255
|
+
if (this.#expired(record, input.nowMs))
|
|
256
|
+
await this.#removeExpired(record);
|
|
257
|
+
else
|
|
258
|
+
await input.onDefinition(DurableSubscriptionValues.wire(record), DurableSubscriptionValues.expiryMs(record.whenExpires));
|
|
259
|
+
}, true);
|
|
260
|
+
}
|
|
261
|
+
const last = page.at(-1);
|
|
262
|
+
if (last === undefined)
|
|
263
|
+
throw new Error("Authenticated subscription recovery page is invalid.");
|
|
264
|
+
after = { id: last.id, values: [{ field: "id", value: last.id }] };
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Stops local operations while leaving durable rows for the next Gateway.
|
|
269
|
+
*
|
|
270
|
+
* @returns A completion result after local operations settle and storage closes.
|
|
271
|
+
*/
|
|
272
|
+
close() {
|
|
273
|
+
this.#closing ??= this.#close();
|
|
274
|
+
return this.#closing;
|
|
275
|
+
}
|
|
276
|
+
async #close() {
|
|
277
|
+
this.#closed = true;
|
|
278
|
+
for (const controller of this.#active.values())
|
|
279
|
+
controller.abort();
|
|
280
|
+
const joined = Promise.allSettled([...this.#running]);
|
|
281
|
+
let rejectTimeout = () => undefined;
|
|
282
|
+
const limit = new Promise((_, onReject) => {
|
|
283
|
+
rejectTimeout = onReject;
|
|
284
|
+
});
|
|
285
|
+
const timeout = setTimeout(() => {
|
|
286
|
+
rejectTimeout(new Error("subscription shutdown timed out"));
|
|
287
|
+
}, this.#limits.shutdownTimeoutMs);
|
|
288
|
+
try {
|
|
289
|
+
await Promise.race([joined, limit]);
|
|
290
|
+
}
|
|
291
|
+
finally {
|
|
292
|
+
clearTimeout(timeout);
|
|
293
|
+
this.#storage.close();
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
async #removeExpired(record) {
|
|
297
|
+
try {
|
|
298
|
+
const id = record.id?.value;
|
|
299
|
+
if (id === undefined)
|
|
300
|
+
throw new Error("Authenticated subscription has no ID.");
|
|
301
|
+
await this.#callbackForId(id, durableCleanupFor(this), DurableSubscriptionValues.wire(record));
|
|
302
|
+
}
|
|
303
|
+
catch {
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
if (record.id !== undefined)
|
|
307
|
+
await this.#storage.compareAndSet(record.id, record, undefined);
|
|
308
|
+
}
|
|
309
|
+
async #read(id) {
|
|
310
|
+
if (id.length === 0)
|
|
311
|
+
return undefined;
|
|
312
|
+
const record = await this.#storage.read(create(SubscriptionIdSchema, { value: id }));
|
|
313
|
+
if (record !== undefined)
|
|
314
|
+
DurableSubscriptionValues.validate(record, create(SubscriptionIdSchema, { value: id }));
|
|
315
|
+
return record;
|
|
316
|
+
}
|
|
317
|
+
#expired(record, nowMs) {
|
|
318
|
+
DurableSubscriptionValues.validate(record);
|
|
319
|
+
return DurableSubscriptionValues.expiryMs(record.whenExpires) <= nowMs;
|
|
320
|
+
}
|
|
321
|
+
async #forId(id, operation, admitted = false) {
|
|
322
|
+
if (!admitted)
|
|
323
|
+
this.#open();
|
|
324
|
+
const previous = this.#pending.get(id) ?? Promise.resolve();
|
|
325
|
+
const queued = this.#queued.get(id) ?? 0;
|
|
326
|
+
const waits = this.#pending.has(id);
|
|
327
|
+
if (waits && queued >= this.#limits.pendingOperationLimit)
|
|
328
|
+
throw new Error("binding-busy");
|
|
329
|
+
if (waits)
|
|
330
|
+
this.#queued.set(id, queued + 1);
|
|
331
|
+
const start = () => {
|
|
332
|
+
if (waits) {
|
|
333
|
+
const remaining = (this.#queued.get(id) ?? 1) - 1;
|
|
334
|
+
if (remaining === 0)
|
|
335
|
+
this.#queued.delete(id);
|
|
336
|
+
else
|
|
337
|
+
this.#queued.set(id, remaining);
|
|
338
|
+
}
|
|
339
|
+
return operation();
|
|
340
|
+
};
|
|
341
|
+
const task = previous.then(start, start);
|
|
342
|
+
this.#pending.set(id, task);
|
|
343
|
+
this.#track(task);
|
|
344
|
+
try {
|
|
345
|
+
return await task;
|
|
346
|
+
}
|
|
347
|
+
finally {
|
|
348
|
+
if (this.#pending.get(id) === task)
|
|
349
|
+
this.#pending.delete(id);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
#admit(operation) {
|
|
353
|
+
try {
|
|
354
|
+
this.#open();
|
|
355
|
+
}
|
|
356
|
+
catch {
|
|
357
|
+
return Promise.reject(new Error("authenticated subscription store is closed"));
|
|
358
|
+
}
|
|
359
|
+
const task = operation();
|
|
360
|
+
this.#track(task);
|
|
361
|
+
return task;
|
|
362
|
+
}
|
|
363
|
+
#track(task) {
|
|
364
|
+
this.#running.add(task);
|
|
365
|
+
void task.then(() => {
|
|
366
|
+
this.#running.delete(task);
|
|
367
|
+
}, () => {
|
|
368
|
+
this.#running.delete(task);
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
#open() {
|
|
372
|
+
if (this.#closed)
|
|
373
|
+
throw new Error("authenticated subscription store is closed");
|
|
374
|
+
}
|
|
375
|
+
async #callback(callback, wire, controller) {
|
|
376
|
+
let rejectTimeout = () => undefined;
|
|
377
|
+
const timeout = new Promise((_, onReject) => {
|
|
378
|
+
rejectTimeout = onReject;
|
|
379
|
+
});
|
|
380
|
+
const timer = setTimeout(() => {
|
|
381
|
+
controller.abort();
|
|
382
|
+
rejectTimeout(new Error("subscription operation timed out"));
|
|
383
|
+
}, this.#limits.operationTimeoutMs);
|
|
384
|
+
try {
|
|
385
|
+
await Promise.race([callback(wire, controller.signal), timeout]);
|
|
386
|
+
}
|
|
387
|
+
finally {
|
|
388
|
+
clearTimeout(timer);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
async #callbackForId(id, callback, wire, signal, active = false) {
|
|
392
|
+
const controller = new AbortController();
|
|
393
|
+
const abort = () => {
|
|
394
|
+
controller.abort();
|
|
395
|
+
};
|
|
396
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
397
|
+
if (signal?.aborted)
|
|
398
|
+
controller.abort();
|
|
399
|
+
this.#active.set(id, controller);
|
|
400
|
+
try {
|
|
401
|
+
if (active)
|
|
402
|
+
await this.#runActiveCallback(callback, wire, controller);
|
|
403
|
+
else
|
|
404
|
+
await this.#callback(callback, wire, controller);
|
|
405
|
+
}
|
|
406
|
+
finally {
|
|
407
|
+
signal?.removeEventListener("abort", abort);
|
|
408
|
+
if (this.#active.get(id) === controller)
|
|
409
|
+
this.#active.delete(id);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
async #runActiveCallback(callback, wire, controller) {
|
|
413
|
+
let observeAbort = () => undefined;
|
|
414
|
+
const aborted = new Promise((resolve) => {
|
|
415
|
+
observeAbort = () => {
|
|
416
|
+
resolve("aborted");
|
|
417
|
+
};
|
|
418
|
+
controller.signal.addEventListener("abort", observeAbort, { once: true });
|
|
419
|
+
});
|
|
420
|
+
try {
|
|
421
|
+
if (controller.signal.aborted)
|
|
422
|
+
return;
|
|
423
|
+
const effect = callback(wire, controller.signal);
|
|
424
|
+
const result = await Promise.race([effect.then(() => "settled"), aborted]);
|
|
425
|
+
if (result === "settled")
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
finally {
|
|
429
|
+
controller.signal.removeEventListener("abort", observeAbort);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* Checks whether bindings use the direct durable authenticated subscription implementation.
|
|
435
|
+
*
|
|
436
|
+
* @param bindings Supplies bindings to check.
|
|
437
|
+
* @returns Whether the bindings are durable authenticated subscription bindings.
|
|
438
|
+
*/
|
|
439
|
+
export function isDurableSubscriptionBindings(bindings) {
|
|
440
|
+
return bindings instanceof DurableSubscriptionBindings;
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* Attaches BrowserServer cancellation alongside the caller cleanup.
|
|
444
|
+
*
|
|
445
|
+
* @internal
|
|
446
|
+
* @param bindings Durable bindings receiving the internal cancellation effect.
|
|
447
|
+
* @param cleanup BrowserServer backend cancellation callback.
|
|
448
|
+
*/
|
|
449
|
+
export function attachDurableSubscriptionCleanup(bindings, cleanup) {
|
|
450
|
+
const state = durableCleanupStates.get(bindings);
|
|
451
|
+
if (state === undefined)
|
|
452
|
+
throw new Error("Authenticated subscription cleanup state is unavailable.");
|
|
453
|
+
if (state.backend !== undefined)
|
|
454
|
+
throw new Error("Authenticated subscription cleanup is already attached.");
|
|
455
|
+
state.backend = cleanup;
|
|
456
|
+
}
|
|
457
|
+
function durableCleanupFor(bindings) {
|
|
458
|
+
const state = durableCleanupStates.get(bindings);
|
|
459
|
+
if (state === undefined)
|
|
460
|
+
throw new Error("Authenticated subscription cleanup state is unavailable.");
|
|
461
|
+
return async (definition, signal) => {
|
|
462
|
+
if (state.backend !== undefined)
|
|
463
|
+
await state.backend(definition, signal);
|
|
464
|
+
await state.caller(definition, signal);
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
const DurableSubscriptionValues = Object.freeze({
|
|
468
|
+
expiryMs(timestamp) {
|
|
469
|
+
if (timestamp === undefined)
|
|
470
|
+
return Number.NEGATIVE_INFINITY;
|
|
471
|
+
const seconds = Number(timestamp.seconds);
|
|
472
|
+
const nanos = timestamp.nanos;
|
|
473
|
+
const milliseconds = seconds * 1_000 + Math.floor(nanos / 1_000_000);
|
|
474
|
+
return Number.isSafeInteger(seconds) &&
|
|
475
|
+
Number.isInteger(nanos) &&
|
|
476
|
+
nanos >= 0 &&
|
|
477
|
+
nanos < 1_000_000_000 &&
|
|
478
|
+
Number.isSafeInteger(milliseconds)
|
|
479
|
+
? milliseconds
|
|
480
|
+
: Number.NEGATIVE_INFINITY;
|
|
481
|
+
},
|
|
482
|
+
wire(record) {
|
|
483
|
+
if (record.subscription === undefined)
|
|
484
|
+
throw new Error("Authenticated subscription has no definition.");
|
|
485
|
+
return {
|
|
486
|
+
kind: "public-subscription",
|
|
487
|
+
bytes: toBinary(SubscriptionSchema, record.subscription),
|
|
488
|
+
};
|
|
489
|
+
},
|
|
490
|
+
same(left, right) {
|
|
491
|
+
const first = toBinary(GatewayAuthenticatedSubscriptionSchema, left);
|
|
492
|
+
const second = toBinary(GatewayAuthenticatedSubscriptionSchema, right);
|
|
493
|
+
return (first.byteLength === second.byteLength &&
|
|
494
|
+
first.every((value, index) => value === second[index]));
|
|
495
|
+
},
|
|
496
|
+
owns(record, context) {
|
|
497
|
+
const retained = record.subscription?.topic?.context;
|
|
498
|
+
return (retained !== undefined &&
|
|
499
|
+
retained.actor?.value === context.actor?.value &&
|
|
500
|
+
DurableSubscriptionValues.tenantsEqual(retained.tenantId, context.tenantId));
|
|
501
|
+
},
|
|
502
|
+
tenantsEqual(left, right) {
|
|
503
|
+
if (left === undefined || right === undefined)
|
|
504
|
+
return left === right;
|
|
505
|
+
const first = toBinary(TenantIdSchema, left);
|
|
506
|
+
const second = toBinary(TenantIdSchema, right);
|
|
507
|
+
return (first.byteLength === second.byteLength &&
|
|
508
|
+
first.every((value, index) => value === second[index]));
|
|
509
|
+
},
|
|
510
|
+
validate(record, slotId) {
|
|
511
|
+
const id = record.id?.value;
|
|
512
|
+
const nestedId = record.subscription?.id?.value;
|
|
513
|
+
const context = record.subscription?.topic?.context;
|
|
514
|
+
const expires = record.whenExpires;
|
|
515
|
+
if (id === undefined ||
|
|
516
|
+
id.length === 0 ||
|
|
517
|
+
(slotId !== undefined && slotId.value !== id) ||
|
|
518
|
+
nestedId !== id ||
|
|
519
|
+
context?.actor?.value === undefined ||
|
|
520
|
+
DurableSubscriptionValues.expiryMs(expires) === Number.NEGATIVE_INFINITY)
|
|
521
|
+
throw new Error("Authenticated subscription record is invalid.");
|
|
522
|
+
},
|
|
523
|
+
});
|
|
524
|
+
//# sourceMappingURL=durable-subscription-bindings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"durable-subscription-bindings.js","sourceRoot":"","sources":["../../src/server/durable-subscription-bindings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACrF,OAAO,EAAE,eAAe,EAAkB,MAAM,wBAAwB,CAAC;AACzE,OAAO,EACL,sCAAsC,GAEvC,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,WAAW,GAEZ,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAqB,MAAM,2BAA2B,CAAC;AAS9E,OAAO,EACL,WAAW,EACX,YAAY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