@serve.zone/dcrouter 17.7.1 → 17.8.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/deno.json +1 -1
- package/dist_serve/bundle.js +410 -410
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/classes.dcrouter.d.ts +2 -0
- package/dist_ts/classes.dcrouter.js +23 -1
- package/dist_ts/config/classes.gateway-client-manager.js +3 -1
- package/dist_ts/db/documents/classes.cached.email.d.ts +7 -0
- package/dist_ts/db/documents/classes.cached.email.js +52 -2
- package/dist_ts/db/documents/classes.webpush-admission.doc.d.ts +19 -0
- package/dist_ts/db/documents/classes.webpush-admission.doc.js +124 -0
- package/dist_ts/db/documents/classes.webpush-binding.doc.d.ts +65 -0
- package/dist_ts/db/documents/classes.webpush-binding.doc.js +205 -0
- package/dist_ts/db/documents/classes.webpush-spool.doc.d.ts +44 -0
- package/dist_ts/db/documents/classes.webpush-spool.doc.js +277 -0
- package/dist_ts/db/documents/index.d.ts +3 -0
- package/dist_ts/db/documents/index.js +5 -1
- package/dist_ts/email/classes.accepted-email-spool.d.ts +5 -0
- package/dist_ts/email/classes.accepted-email-spool.js +28 -3
- package/dist_ts/email/classes.workapp-mail-manager.d.ts +5 -1
- package/dist_ts/email/classes.workapp-mail-manager.js +87 -12
- package/dist_ts/index.d.ts +1 -0
- package/dist_ts/index.js +3 -1
- package/dist_ts/opsserver/classes.opsserver.d.ts +2 -0
- package/dist_ts/opsserver/classes.opsserver.js +5 -1
- package/dist_ts/opsserver/handlers/gatewayclient.handler.js +11 -5
- package/dist_ts/opsserver/handlers/index.d.ts +2 -0
- package/dist_ts/opsserver/handlers/index.js +3 -1
- package/dist_ts/opsserver/handlers/webpush-app.handler.d.ts +9 -0
- package/dist_ts/opsserver/handlers/webpush-app.handler.js +66 -0
- package/dist_ts/opsserver/handlers/webpush-control.handler.d.ts +14 -0
- package/dist_ts/opsserver/handlers/webpush-control.handler.js +163 -0
- package/dist_ts/plugins.d.ts +5 -2
- package/dist_ts/plugins.js +6 -3
- package/dist_ts/webpush/classes.webpush-crypto.d.ts +38 -0
- package/dist_ts/webpush/classes.webpush-crypto.js +231 -0
- package/dist_ts/webpush/classes.webpush-manager.d.ts +153 -0
- package/dist_ts/webpush/classes.webpush-manager.js +2374 -0
- package/dist_ts/webpush/classes.webpush-transport.d.ts +45 -0
- package/dist_ts/webpush/classes.webpush-transport.js +161 -0
- package/dist_ts/webpush/helpers.webpush-endpoint.d.ts +21 -0
- package/dist_ts/webpush/helpers.webpush-endpoint.js +111 -0
- package/dist_ts/webpush/index.d.ts +4 -0
- package/dist_ts/webpush/index.js +5 -0
- package/dist_ts/webpush/webpush-indexes.d.ts +11 -0
- package/dist_ts/webpush/webpush-indexes.js +123 -0
- package/dist_ts_interfaces/data/route-management.d.ts +2 -0
- package/dist_ts_interfaces/data/route-management.js +1 -1
- package/dist_ts_migrations/index.js +221 -11
- package/dist_ts_web/00_commitinfo_data.js +1 -1
- package/package.json +12 -8
- package/readme.md +27 -0
- package/third-party-notices.md +37 -0
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/classes.dcrouter.ts +29 -0
- package/ts/config/classes.gateway-client-manager.ts +2 -0
- package/ts/db/documents/classes.cached.email.ts +47 -0
- package/ts/db/documents/classes.webpush-admission.doc.ts +48 -0
- package/ts/db/documents/classes.webpush-binding.doc.ts +147 -0
- package/ts/db/documents/classes.webpush-spool.doc.ts +136 -0
- package/ts/db/documents/index.ts +5 -0
- package/ts/email/classes.accepted-email-spool.ts +41 -2
- package/ts/email/classes.workapp-mail-manager.ts +97 -10
- package/ts/index.ts +3 -0
- package/ts/opsserver/classes.opsserver.ts +4 -0
- package/ts/opsserver/handlers/gatewayclient.handler.ts +10 -3
- package/ts/opsserver/handlers/index.ts +2 -0
- package/ts/opsserver/handlers/webpush-app.handler.ts +105 -0
- package/ts/opsserver/handlers/webpush-control.handler.ts +257 -0
- package/ts/plugins.ts +6 -0
- package/ts/webpush/classes.webpush-crypto.ts +306 -0
- package/ts/webpush/classes.webpush-manager.ts +3173 -0
- package/ts/webpush/classes.webpush-transport.ts +241 -0
- package/ts/webpush/helpers.webpush-endpoint.ts +150 -0
- package/ts/webpush/index.ts +4 -0
- package/ts/webpush/webpush-indexes.ts +141 -0
- package/ts_web/00_commitinfo_data.ts +1 -1
- package/readme.plan.md +0 -22
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import * as plugins from '../plugins.js';
|
|
2
|
+
import { WebPushBindingDoc, WebPushSpoolDoc, type IWebPushStoredCredential, type TWebPushControllerIntent } from '../db/index.js';
|
|
3
|
+
import { type IWebPushTransport } from './classes.webpush-transport.js';
|
|
4
|
+
type IWebPushBinding = plugins.servezoneInterfaces.data.IWebPushBinding;
|
|
5
|
+
type IWebPushCredentialOneTimeSecret = plugins.servezoneInterfaces.data.IWebPushCredentialOneTimeSecret;
|
|
6
|
+
type IWebPushDeliveryStatus = plugins.servezoneInterfaces.data.IWebPushDeliveryStatus;
|
|
7
|
+
type IWebPushNotificationPayload = plugins.servezoneInterfaces.data.IWebPushNotificationPayload;
|
|
8
|
+
type IWebPushResourceOwner = plugins.servezoneInterfaces.data.IWebPushResourceOwner;
|
|
9
|
+
type IWebPushServiceStatus = plugins.servezoneInterfaces.data.IWebPushServiceStatus;
|
|
10
|
+
type IWebPushSubscription = plugins.servezoneInterfaces.data.IWebPushSubscription;
|
|
11
|
+
type TWebPushBindingSync = plugins.servezoneInterfaces.requests.webpush.TWebPushBindingSync;
|
|
12
|
+
type IWebPushAppCredentialAuth = plugins.servezoneInterfaces.requests.webpush.IWebPushAppCredentialAuth;
|
|
13
|
+
type TWebPushCancellationTarget = plugins.servezoneInterfaces.data.TWebPushCancellationTarget;
|
|
14
|
+
type TWebPushDeliveryState = plugins.servezoneInterfaces.data.TWebPushDeliveryState;
|
|
15
|
+
type TWebPushUrgency = plugins.servezoneInterfaces.data.TWebPushUrgency;
|
|
16
|
+
interface IWebPushQenv {
|
|
17
|
+
getEnvVarOnDemand(nameArg: string): Promise<string | undefined>;
|
|
18
|
+
}
|
|
19
|
+
export interface IWebPushManagerOptions {
|
|
20
|
+
qenv?: IWebPushQenv;
|
|
21
|
+
transport?: IWebPushTransport;
|
|
22
|
+
startWorker?: boolean;
|
|
23
|
+
now?: () => number;
|
|
24
|
+
admissionPolicy?: Partial<IWebPushAdmissionPolicy>;
|
|
25
|
+
}
|
|
26
|
+
export interface IWebPushAdmissionPolicy {
|
|
27
|
+
shortWindowMs: number;
|
|
28
|
+
shortLimit: number;
|
|
29
|
+
longWindowMs: number;
|
|
30
|
+
longLimit: number;
|
|
31
|
+
}
|
|
32
|
+
export interface IWebPushAuthenticatedBinding {
|
|
33
|
+
binding: WebPushBindingDoc;
|
|
34
|
+
credential: IWebPushStoredCredential;
|
|
35
|
+
}
|
|
36
|
+
export interface IWebPushBindingSyncResult {
|
|
37
|
+
binding: IWebPushBinding;
|
|
38
|
+
credential?: IWebPushCredentialOneTimeSecret;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Durable controller ordering token. The controller id and epoch remain stable
|
|
42
|
+
* for an owner, while generation increases for every desired-state mutation.
|
|
43
|
+
*/
|
|
44
|
+
export interface IWebPushControllerMutation {
|
|
45
|
+
id: string;
|
|
46
|
+
epoch: string;
|
|
47
|
+
generation: number;
|
|
48
|
+
operationId: string;
|
|
49
|
+
intent: TWebPushControllerIntent;
|
|
50
|
+
}
|
|
51
|
+
export interface IWebPushBindingDelete {
|
|
52
|
+
id?: string;
|
|
53
|
+
owner: IWebPushResourceOwner;
|
|
54
|
+
controller: IWebPushControllerMutation;
|
|
55
|
+
}
|
|
56
|
+
export interface IWebPushEnqueueResult {
|
|
57
|
+
accepted: boolean;
|
|
58
|
+
spoolItemId: string;
|
|
59
|
+
}
|
|
60
|
+
export interface IWebPushCancelResult {
|
|
61
|
+
cancelledCount: number;
|
|
62
|
+
alreadyTerminalCount: number;
|
|
63
|
+
}
|
|
64
|
+
export declare function toPublicWebPushBinding(bindingArg: WebPushBindingDoc): IWebPushBinding;
|
|
65
|
+
export declare function toPublicWebPushDelivery(spoolArg: WebPushSpoolDoc): IWebPushDeliveryStatus;
|
|
66
|
+
export declare function buildWebPushTerminalUpdate(optionsArg: {
|
|
67
|
+
state: Extract<TWebPushDeliveryState, 'pushServiceAccepted' | 'invalidSubscription' | 'failed' | 'expired' | 'cancelled'>;
|
|
68
|
+
now: number;
|
|
69
|
+
pushServiceStatusCode?: number;
|
|
70
|
+
errorCode?: string;
|
|
71
|
+
}): Record<string, unknown>;
|
|
72
|
+
export declare class WebPushManager {
|
|
73
|
+
private readonly qenv;
|
|
74
|
+
private readonly transport;
|
|
75
|
+
private readonly startWorker;
|
|
76
|
+
private readonly now;
|
|
77
|
+
private readonly admissionPolicy;
|
|
78
|
+
private enabled;
|
|
79
|
+
private started;
|
|
80
|
+
private ready;
|
|
81
|
+
private crypto?;
|
|
82
|
+
private vapidSubject?;
|
|
83
|
+
private workerTimer?;
|
|
84
|
+
private activeWorkerCycle?;
|
|
85
|
+
private expiredCredentialOverlapCursor?;
|
|
86
|
+
private expiredCredentialRecoveryCursor?;
|
|
87
|
+
private retiredVapidCursor?;
|
|
88
|
+
private inactiveLifecycleCursor?;
|
|
89
|
+
constructor(optionsArg?: IWebPushManagerOptions);
|
|
90
|
+
get isEnabled(): boolean;
|
|
91
|
+
get isReady(): boolean;
|
|
92
|
+
start(): Promise<void>;
|
|
93
|
+
stop(): Promise<void>;
|
|
94
|
+
getUnavailableServiceStatus(): IWebPushServiceStatus;
|
|
95
|
+
listBindings(ownerFilterArg?: Partial<IWebPushResourceOwner>): Promise<IWebPushBinding[]>;
|
|
96
|
+
getBindingById(idArg: string): Promise<WebPushBindingDoc | null>;
|
|
97
|
+
getBindingByCredentialId(credentialIdArg: string): Promise<WebPushBindingDoc | null>;
|
|
98
|
+
syncBinding(bindingArg: TWebPushBindingSync, controllerArg: IWebPushControllerMutation, createdByArg: string): Promise<IWebPushBindingSyncResult>;
|
|
99
|
+
private resumeControllerSyncReplay;
|
|
100
|
+
deleteBinding(deleteArg: IWebPushBindingDelete, deletedByArg: string): Promise<boolean>;
|
|
101
|
+
private resumeControllerDeleteReplay;
|
|
102
|
+
rotateCredential(credentialIdArg: string): Promise<IWebPushCredentialOneTimeSecret>;
|
|
103
|
+
rotateVapidKey(bindingIdArg: string): Promise<IWebPushBinding>;
|
|
104
|
+
authenticateAppCredential(authArg: IWebPushAppCredentialAuth): Promise<IWebPushAuthenticatedBinding>;
|
|
105
|
+
getServiceStatus(authArg: IWebPushAppCredentialAuth): Promise<IWebPushServiceStatus>;
|
|
106
|
+
enqueue(authArg: IWebPushAppCredentialAuth, requestArg: {
|
|
107
|
+
idempotencyKey: string;
|
|
108
|
+
subscriptionId: string;
|
|
109
|
+
subscription: IWebPushSubscription;
|
|
110
|
+
vapidKeyId: string;
|
|
111
|
+
payload: IWebPushNotificationPayload;
|
|
112
|
+
ttlSeconds?: number;
|
|
113
|
+
urgency?: TWebPushUrgency;
|
|
114
|
+
collapseKey?: string;
|
|
115
|
+
}): Promise<IWebPushEnqueueResult>;
|
|
116
|
+
getDeliveryStatus(authArg: IWebPushAppCredentialAuth, spoolItemIdArg: string): Promise<IWebPushDeliveryStatus | undefined>;
|
|
117
|
+
cancel(authArg: IWebPushAppCredentialAuth, targetArg: TWebPushCancellationTarget): Promise<IWebPushCancelResult>;
|
|
118
|
+
processDueDeliveriesOnce(limitArg?: number): Promise<number>;
|
|
119
|
+
private requirePersistenceReady;
|
|
120
|
+
private requireReady;
|
|
121
|
+
private bindingOwner;
|
|
122
|
+
private assertBindingOwner;
|
|
123
|
+
private credentialHmacValue;
|
|
124
|
+
private createCredential;
|
|
125
|
+
private credentialRotationRecoveryAad;
|
|
126
|
+
private replayCredentialRotation;
|
|
127
|
+
private createVapidKey;
|
|
128
|
+
private spoolAadBase;
|
|
129
|
+
private assertBindingLifecycleActive;
|
|
130
|
+
private reserveAdmission;
|
|
131
|
+
private cancelSpoolIfLifecycleChanged;
|
|
132
|
+
private scrubDeletedBindingLifecycle;
|
|
133
|
+
private cleanupExpiredCredentialOverlaps;
|
|
134
|
+
private cleanupExpiredCredentialRotationRecoveries;
|
|
135
|
+
private cleanupRetiredVapidKeys;
|
|
136
|
+
private runMaintenanceOnce;
|
|
137
|
+
private cleanupInactiveBindingLifecycles;
|
|
138
|
+
private selectBindingMaintenanceBatch;
|
|
139
|
+
private requestBindingLifecyclesBeforeCancellation;
|
|
140
|
+
private drainBindingLifecyclesBefore;
|
|
141
|
+
private waitForBindingLifecyclesBeforeDrain;
|
|
142
|
+
private finishStaleCancelledSending;
|
|
143
|
+
private finishStaleCancelledSendingBefore;
|
|
144
|
+
private cancelWithinBinding;
|
|
145
|
+
private expireDueItems;
|
|
146
|
+
private claimNextItem;
|
|
147
|
+
private processClaimedItem;
|
|
148
|
+
private finishTerminal;
|
|
149
|
+
private deferOrFinish;
|
|
150
|
+
private retryDelayMs;
|
|
151
|
+
private scheduleWorker;
|
|
152
|
+
}
|
|
153
|
+
export {};
|