@softomnitel/omnicall-kit 0.1.0-rc.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/LICENSE +4 -0
- package/README.md +34 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/account-activate-commands.d.ts +30 -0
- package/dist/internal/account-activate-commands.d.ts.map +1 -0
- package/dist/internal/account-activate-commands.js +94 -0
- package/dist/internal/account-activate-commands.js.map +1 -0
- package/dist/internal/account-activate-wire.d.ts +16 -0
- package/dist/internal/account-activate-wire.d.ts.map +1 -0
- package/dist/internal/account-activate-wire.js +22 -0
- package/dist/internal/account-activate-wire.js.map +1 -0
- package/dist/internal/account-logout-commands.d.ts +23 -0
- package/dist/internal/account-logout-commands.d.ts.map +1 -0
- package/dist/internal/account-logout-commands.js +51 -0
- package/dist/internal/account-logout-commands.js.map +1 -0
- package/dist/internal/account-logout-wire.d.ts +15 -0
- package/dist/internal/account-logout-wire.d.ts.map +1 -0
- package/dist/internal/account-logout-wire.js +24 -0
- package/dist/internal/account-logout-wire.js.map +1 -0
- package/dist/internal/auth-grants.d.ts +6 -0
- package/dist/internal/auth-grants.d.ts.map +1 -0
- package/dist/internal/auth-grants.js +16 -0
- package/dist/internal/auth-grants.js.map +1 -0
- package/dist/internal/auth-inbound.d.ts +35 -0
- package/dist/internal/auth-inbound.d.ts.map +1 -0
- package/dist/internal/auth-inbound.js +86 -0
- package/dist/internal/auth-inbound.js.map +1 -0
- package/dist/internal/auth-orchestrator.d.ts +36 -0
- package/dist/internal/auth-orchestrator.d.ts.map +1 -0
- package/dist/internal/auth-orchestrator.js +217 -0
- package/dist/internal/auth-orchestrator.js.map +1 -0
- package/dist/internal/auth-pop-flow.d.ts +38 -0
- package/dist/internal/auth-pop-flow.d.ts.map +1 -0
- package/dist/internal/auth-pop-flow.js +80 -0
- package/dist/internal/auth-pop-flow.js.map +1 -0
- package/dist/internal/auth-wire.d.ts +37 -0
- package/dist/internal/auth-wire.d.ts.map +1 -0
- package/dist/internal/auth-wire.js +62 -0
- package/dist/internal/auth-wire.js.map +1 -0
- package/dist/internal/base64url.d.ts +7 -0
- package/dist/internal/base64url.d.ts.map +1 -0
- package/dist/internal/base64url.js +28 -0
- package/dist/internal/base64url.js.map +1 -0
- package/dist/internal/browser-websocket-transport.d.ts +36 -0
- package/dist/internal/browser-websocket-transport.d.ts.map +1 -0
- package/dist/internal/browser-websocket-transport.js +131 -0
- package/dist/internal/browser-websocket-transport.js.map +1 -0
- package/dist/internal/call-commands.d.ts +32 -0
- package/dist/internal/call-commands.d.ts.map +1 -0
- package/dist/internal/call-commands.js +60 -0
- package/dist/internal/call-commands.js.map +1 -0
- package/dist/internal/call-wire.d.ts +24 -0
- package/dist/internal/call-wire.d.ts.map +1 -0
- package/dist/internal/call-wire.js +37 -0
- package/dist/internal/call-wire.js.map +1 -0
- package/dist/internal/client-error-details.d.ts +60 -0
- package/dist/internal/client-error-details.d.ts.map +1 -0
- package/dist/internal/client-error-details.js +98 -0
- package/dist/internal/client-error-details.js.map +1 -0
- package/dist/internal/client-errors.d.ts +38 -0
- package/dist/internal/client-errors.d.ts.map +1 -0
- package/dist/internal/client-errors.js +37 -0
- package/dist/internal/client-errors.js.map +1 -0
- package/dist/internal/command-classification.d.ts +7 -0
- package/dist/internal/command-classification.d.ts.map +1 -0
- package/dist/internal/command-classification.js +14 -0
- package/dist/internal/command-classification.js.map +1 -0
- package/dist/internal/connection-session.d.ts +61 -0
- package/dist/internal/connection-session.d.ts.map +1 -0
- package/dist/internal/connection-session.js +333 -0
- package/dist/internal/connection-session.js.map +1 -0
- package/dist/internal/connection-state.d.ts +13 -0
- package/dist/internal/connection-state.d.ts.map +1 -0
- package/dist/internal/connection-state.js +75 -0
- package/dist/internal/connection-state.js.map +1 -0
- package/dist/internal/diagnostics.d.ts +36 -0
- package/dist/internal/diagnostics.d.ts.map +1 -0
- package/dist/internal/diagnostics.js +51 -0
- package/dist/internal/diagnostics.js.map +1 -0
- package/dist/internal/event-subscription.d.ts +23 -0
- package/dist/internal/event-subscription.d.ts.map +1 -0
- package/dist/internal/event-subscription.js +62 -0
- package/dist/internal/event-subscription.js.map +1 -0
- package/dist/internal/heartbeat-controller.d.ts +27 -0
- package/dist/internal/heartbeat-controller.d.ts.map +1 -0
- package/dist/internal/heartbeat-controller.js +58 -0
- package/dist/internal/heartbeat-controller.js.map +1 -0
- package/dist/internal/operator-commands.d.ts +46 -0
- package/dist/internal/operator-commands.d.ts.map +1 -0
- package/dist/internal/operator-commands.js +93 -0
- package/dist/internal/operator-commands.js.map +1 -0
- package/dist/internal/operator-wire.d.ts +20 -0
- package/dist/internal/operator-wire.d.ts.map +1 -0
- package/dist/internal/operator-wire.js +33 -0
- package/dist/internal/operator-wire.js.map +1 -0
- package/dist/internal/origin-policy-errors.d.ts +22 -0
- package/dist/internal/origin-policy-errors.d.ts.map +1 -0
- package/dist/internal/origin-policy-errors.js +67 -0
- package/dist/internal/origin-policy-errors.js.map +1 -0
- package/dist/internal/pop-crypto.d.ts +23 -0
- package/dist/internal/pop-crypto.d.ts.map +1 -0
- package/dist/internal/pop-crypto.js +48 -0
- package/dist/internal/pop-crypto.js.map +1 -0
- package/dist/internal/pop-key-store.d.ts +28 -0
- package/dist/internal/pop-key-store.d.ts.map +1 -0
- package/dist/internal/pop-key-store.js +153 -0
- package/dist/internal/pop-key-store.js.map +1 -0
- package/dist/internal/product-commands.d.ts +33 -0
- package/dist/internal/product-commands.d.ts.map +1 -0
- package/dist/internal/product-commands.js +70 -0
- package/dist/internal/product-commands.js.map +1 -0
- package/dist/internal/product-inbound.d.ts +15 -0
- package/dist/internal/product-inbound.d.ts.map +1 -0
- package/dist/internal/product-inbound.js +31 -0
- package/dist/internal/product-inbound.js.map +1 -0
- package/dist/internal/product-orchestrator.d.ts +46 -0
- package/dist/internal/product-orchestrator.d.ts.map +1 -0
- package/dist/internal/product-orchestrator.js +188 -0
- package/dist/internal/product-orchestrator.js.map +1 -0
- package/dist/internal/product-wire.d.ts +29 -0
- package/dist/internal/product-wire.d.ts.map +1 -0
- package/dist/internal/product-wire.js +54 -0
- package/dist/internal/product-wire.js.map +1 -0
- package/dist/internal/public-event-map.d.ts +27 -0
- package/dist/internal/public-event-map.d.ts.map +1 -0
- package/dist/internal/public-event-map.js +38 -0
- package/dist/internal/public-event-map.js.map +1 -0
- package/dist/internal/reconnect-policy.d.ts +16 -0
- package/dist/internal/reconnect-policy.d.ts.map +1 -0
- package/dist/internal/reconnect-policy.js +23 -0
- package/dist/internal/reconnect-policy.js.map +1 -0
- package/dist/internal/request-correlator.d.ts +41 -0
- package/dist/internal/request-correlator.d.ts.map +1 -0
- package/dist/internal/request-correlator.js +130 -0
- package/dist/internal/request-correlator.js.map +1 -0
- package/dist/internal/requested-capabilities.d.ts +10 -0
- package/dist/internal/requested-capabilities.d.ts.map +1 -0
- package/dist/internal/requested-capabilities.js +25 -0
- package/dist/internal/requested-capabilities.js.map +1 -0
- package/dist/internal/scheduler.d.ts +41 -0
- package/dist/internal/scheduler.d.ts.map +1 -0
- package/dist/internal/scheduler.js +104 -0
- package/dist/internal/scheduler.js.map +1 -0
- package/dist/internal/session-identity.d.ts +16 -0
- package/dist/internal/session-identity.d.ts.map +1 -0
- package/dist/internal/session-identity.js +13 -0
- package/dist/internal/session-identity.js.map +1 -0
- package/dist/internal/snapshot-acquisition.d.ts +21 -0
- package/dist/internal/snapshot-acquisition.d.ts.map +1 -0
- package/dist/internal/snapshot-acquisition.js +40 -0
- package/dist/internal/snapshot-acquisition.js.map +1 -0
- package/dist/internal/snapshot-cache.d.ts +13 -0
- package/dist/internal/snapshot-cache.d.ts.map +1 -0
- package/dist/internal/snapshot-cache.js +18 -0
- package/dist/internal/snapshot-cache.js.map +1 -0
- package/dist/internal/transport-port.d.ts +34 -0
- package/dist/internal/transport-port.d.ts.map +1 -0
- package/dist/internal/transport-port.js +7 -0
- package/dist/internal/transport-port.js.map +1 -0
- package/dist/internal/window-commands.d.ts +23 -0
- package/dist/internal/window-commands.d.ts.map +1 -0
- package/dist/internal/window-commands.js +76 -0
- package/dist/internal/window-commands.js.map +1 -0
- package/dist/public/auth-client.d.ts +87 -0
- package/dist/public/auth-client.d.ts.map +1 -0
- package/dist/public/auth-client.js +116 -0
- package/dist/public/auth-client.js.map +1 -0
- package/dist/public/omnicall-client-api.d.ts +159 -0
- package/dist/public/omnicall-client-api.d.ts.map +1 -0
- package/dist/public/omnicall-client-api.js +5 -0
- package/dist/public/omnicall-client-api.js.map +1 -0
- package/dist/public/omnicall-client.d.ts +22 -0
- package/dist/public/omnicall-client.d.ts.map +1 -0
- package/dist/public/omnicall-client.js +171 -0
- package/dist/public/omnicall-client.js.map +1 -0
- package/dist/public/protocol-reexports.d.ts +41 -0
- package/dist/public/protocol-reexports.d.ts.map +1 -0
- package/dist/public/protocol-reexports.js +7 -0
- package/dist/public/protocol-reexports.js.map +1 -0
- package/package.json +46 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Product command wire builders (SDK-05 read path + window.show).
|
|
3
|
+
*/
|
|
4
|
+
import { PROTOCOL_MAJOR } from '@softomnitel/omnicall-protocol';
|
|
5
|
+
import { isoNow } from './auth-wire.js';
|
|
6
|
+
export function buildGetSnapshotBody(input) {
|
|
7
|
+
return JSON.stringify({
|
|
8
|
+
protocolVersion: PROTOCOL_MAJOR,
|
|
9
|
+
kind: 'command',
|
|
10
|
+
type: 'sdk:get-snapshot',
|
|
11
|
+
requestId: input.requestId,
|
|
12
|
+
serverInstanceId: input.serverInstanceId,
|
|
13
|
+
sessionEpoch: input.sessionEpoch,
|
|
14
|
+
occurredAt: isoNow(input.occurredAtMs),
|
|
15
|
+
payload: {}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export function buildWindowShowBody(input) {
|
|
19
|
+
return JSON.stringify({
|
|
20
|
+
protocolVersion: PROTOCOL_MAJOR,
|
|
21
|
+
kind: 'command',
|
|
22
|
+
type: 'window:show',
|
|
23
|
+
requestId: input.requestId,
|
|
24
|
+
serverInstanceId: input.serverInstanceId,
|
|
25
|
+
sessionEpoch: input.sessionEpoch,
|
|
26
|
+
occurredAt: isoNow(input.occurredAtMs),
|
|
27
|
+
payload: {}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
export function buildWindowGetStateBody(input) {
|
|
31
|
+
return JSON.stringify({
|
|
32
|
+
protocolVersion: PROTOCOL_MAJOR,
|
|
33
|
+
kind: 'command',
|
|
34
|
+
type: 'window:get-state',
|
|
35
|
+
requestId: input.requestId,
|
|
36
|
+
serverInstanceId: input.serverInstanceId,
|
|
37
|
+
sessionEpoch: input.sessionEpoch,
|
|
38
|
+
occurredAt: isoNow(input.occurredAtMs),
|
|
39
|
+
payload: {}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
export function buildWindowHideBody(input) {
|
|
43
|
+
return JSON.stringify({
|
|
44
|
+
protocolVersion: PROTOCOL_MAJOR,
|
|
45
|
+
kind: 'command',
|
|
46
|
+
type: 'window:hide',
|
|
47
|
+
requestId: input.requestId,
|
|
48
|
+
serverInstanceId: input.serverInstanceId,
|
|
49
|
+
sessionEpoch: input.sessionEpoch,
|
|
50
|
+
occurredAt: isoNow(input.occurredAtMs),
|
|
51
|
+
payload: { expectedRevision: input.expectedRevision }
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=product-wire.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product-wire.js","sourceRoot":"","sources":["../../src/internal/product-wire.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAEhE,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,MAAM,UAAU,oBAAoB,CAAC,KAKpC;IACC,OAAO,IAAI,CAAC,SAAS,CAAC;QACpB,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AK,CAAC,gBAAgB;QACxC,YAAY,EAAE,KAAK,CAAC,YAAY;QAChC,UAAU,EAAE,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC;QACtC,OAAO,EAAE,EAAE,gBAAgB,EAAE,KAAK,CAAC,gBAAgB,EAAE;KACtD,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Anti-corruption map: wire EventMessage → public OmniCallEvent DTO.
|
|
3
|
+
* Domain Event names (CallAnswered, etc.) never appear on this surface.
|
|
4
|
+
*/
|
|
5
|
+
import type { EventMessage } from '@softomnitel/omnicall-protocol';
|
|
6
|
+
/** Product event types delivered to OmniCallClient subscribers (SDK-05). @public */
|
|
7
|
+
export declare const PUBLIC_EVENT_TYPES: readonly ["call:incoming", "call:outgoing", "call:ringing", "call:answered", "call:ended", "call:failed", "call:held", "call:resumed", "call:muted", "call:unmuted", "call:acd-context", "registration:changed", "account:session-activated", "account:session-ended", "operator:session-changed", "operator:status-changed", "operator:campaign-offered", "operator:campaign-cleared", "window:visibility-changed", "sdk:server-shutdown"];
|
|
8
|
+
/** @public */
|
|
9
|
+
export type PublicEventType = (typeof PUBLIC_EVENT_TYPES)[number];
|
|
10
|
+
/** Public anti-corruption event DTO (protocol names only). @public */
|
|
11
|
+
export type OmniCallEvent = Extract<EventMessage, {
|
|
12
|
+
type: PublicEventType;
|
|
13
|
+
}>;
|
|
14
|
+
/**
|
|
15
|
+
* Narrow `OmniCallEvent` by protocol event name (integrator helper).
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* type Incoming = OmniCallEventOf<'call:incoming'>;
|
|
19
|
+
* ```
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
export type OmniCallEventOf<T extends PublicEventType> = Extract<OmniCallEvent, {
|
|
23
|
+
type: T;
|
|
24
|
+
}>;
|
|
25
|
+
export declare function isPublicEventType(type: string): type is PublicEventType;
|
|
26
|
+
export declare function toPublicEvent(message: EventMessage): OmniCallEvent | undefined;
|
|
27
|
+
//# sourceMappingURL=public-event-map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public-event-map.d.ts","sourceRoot":"","sources":["../../src/internal/public-event-map.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAa,MAAM,gCAAgC,CAAC;AAE9E,oFAAoF;AACpF,eAAO,MAAM,kBAAkB,6aAqBU,CAAC;AAE1C,cAAc;AACd,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;AAElE,sEAAsE;AACtE,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC,YAAY,EAAE;IAAE,IAAI,EAAE,eAAe,CAAA;CAAE,CAAC,CAAC;AAE7E;;;;;;;GAOG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,eAAe,IAAI,OAAO,CAC9D,aAAa,EACb;IAAE,IAAI,EAAE,CAAC,CAAA;CAAE,CACZ,CAAC;AAIF,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,eAAe,CAEvE;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,YAAY,GAAG,aAAa,GAAG,SAAS,CAK9E"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Anti-corruption map: wire EventMessage → public OmniCallEvent DTO.
|
|
3
|
+
* Domain Event names (CallAnswered, etc.) never appear on this surface.
|
|
4
|
+
*/
|
|
5
|
+
/** Product event types delivered to OmniCallClient subscribers (SDK-05). @public */
|
|
6
|
+
export const PUBLIC_EVENT_TYPES = [
|
|
7
|
+
'call:incoming',
|
|
8
|
+
'call:outgoing',
|
|
9
|
+
'call:ringing',
|
|
10
|
+
'call:answered',
|
|
11
|
+
'call:ended',
|
|
12
|
+
'call:failed',
|
|
13
|
+
'call:held',
|
|
14
|
+
'call:resumed',
|
|
15
|
+
'call:muted',
|
|
16
|
+
'call:unmuted',
|
|
17
|
+
'call:acd-context',
|
|
18
|
+
'registration:changed',
|
|
19
|
+
'account:session-activated',
|
|
20
|
+
'account:session-ended',
|
|
21
|
+
'operator:session-changed',
|
|
22
|
+
'operator:status-changed',
|
|
23
|
+
'operator:campaign-offered',
|
|
24
|
+
'operator:campaign-cleared',
|
|
25
|
+
'window:visibility-changed',
|
|
26
|
+
'sdk:server-shutdown'
|
|
27
|
+
];
|
|
28
|
+
const PUBLIC_SET = new Set(PUBLIC_EVENT_TYPES);
|
|
29
|
+
export function isPublicEventType(type) {
|
|
30
|
+
return PUBLIC_SET.has(type);
|
|
31
|
+
}
|
|
32
|
+
export function toPublicEvent(message) {
|
|
33
|
+
if (!isPublicEventType(message.type)) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
return message;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=public-event-map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public-event-map.js","sourceRoot":"","sources":["../../src/internal/public-event-map.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,oFAAoF;AACpF,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,eAAe;IACf,eAAe;IACf,cAAc;IACd,eAAe;IACf,YAAY;IACZ,aAAa;IACb,WAAW;IACX,cAAc;IACd,YAAY;IACZ,cAAc;IACd,kBAAkB;IAClB,sBAAsB;IACtB,2BAA2B;IAC3B,uBAAuB;IACvB,0BAA0B;IAC1B,yBAAyB;IACzB,2BAA2B;IAC3B,2BAA2B;IAC3B,2BAA2B;IAC3B,qBAAqB;CACkB,CAAC;AAqB1C,MAAM,UAAU,GAAG,IAAI,GAAG,CAAS,kBAAkB,CAAC,CAAC;AAEvD,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC5C,OAAO,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,OAAqB;IACjD,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACrC,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,OAAwB,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bounded exponential backoff with jitter (SECURITY.md).
|
|
3
|
+
*/
|
|
4
|
+
import type { JitterSource } from './scheduler.js';
|
|
5
|
+
/** Bounded reconnect policy. @public */
|
|
6
|
+
export type ReconnectPolicy = {
|
|
7
|
+
readonly maxAttempts: number;
|
|
8
|
+
readonly initialDelayMs: number;
|
|
9
|
+
readonly maxDelayMs: number;
|
|
10
|
+
/** Fraction of delay applied as symmetric jitter, in [0, 1]. */
|
|
11
|
+
readonly jitterRatio: number;
|
|
12
|
+
};
|
|
13
|
+
export declare const DEFAULT_RECONNECT_POLICY: ReconnectPolicy;
|
|
14
|
+
export declare function computeReconnectDelayMs(policy: ReconnectPolicy, attemptIndex: number, jitter: JitterSource): number;
|
|
15
|
+
export declare function hasReconnectAttemptsRemaining(policy: ReconnectPolicy, attemptCount: number): boolean;
|
|
16
|
+
//# sourceMappingURL=reconnect-policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reconnect-policy.d.ts","sourceRoot":"","sources":["../../src/internal/reconnect-policy.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,wCAAwC;AACxC,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,gEAAgE;IAChE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,eAKtC,CAAC;AAEF,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,eAAe,EACvB,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,YAAY,GACnB,MAAM,CASR;AAED,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,eAAe,EACvB,YAAY,EAAE,MAAM,GACnB,OAAO,CAET"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bounded exponential backoff with jitter (SECURITY.md).
|
|
3
|
+
*/
|
|
4
|
+
export const DEFAULT_RECONNECT_POLICY = {
|
|
5
|
+
maxAttempts: 5,
|
|
6
|
+
initialDelayMs: 200,
|
|
7
|
+
maxDelayMs: 10_000,
|
|
8
|
+
jitterRatio: 0.2
|
|
9
|
+
};
|
|
10
|
+
export function computeReconnectDelayMs(policy, attemptIndex, jitter) {
|
|
11
|
+
if (attemptIndex < 0) {
|
|
12
|
+
throw new Error('attemptIndex must be >= 0');
|
|
13
|
+
}
|
|
14
|
+
const exp = policy.initialDelayMs * 2 ** attemptIndex;
|
|
15
|
+
const base = Math.min(policy.maxDelayMs, exp);
|
|
16
|
+
const spread = base * policy.jitterRatio;
|
|
17
|
+
const offset = (jitter.nextUnitInterval() * 2 - 1) * spread;
|
|
18
|
+
return Math.max(0, Math.round(base + offset));
|
|
19
|
+
}
|
|
20
|
+
export function hasReconnectAttemptsRemaining(policy, attemptCount) {
|
|
21
|
+
return attemptCount < policy.maxAttempts;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=reconnect-policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reconnect-policy.js","sourceRoot":"","sources":["../../src/internal/reconnect-policy.ts"],"names":[],"mappings":"AAAA;;GAEG;AAaH,MAAM,CAAC,MAAM,wBAAwB,GAAoB;IACvD,WAAW,EAAE,CAAC;IACd,cAAc,EAAE,GAAG;IACnB,UAAU,EAAE,MAAM;IAClB,WAAW,EAAE,GAAG;CACjB,CAAC;AAEF,MAAM,UAAU,uBAAuB,CACrC,MAAuB,EACvB,YAAoB,EACpB,MAAoB;IAEpB,IAAI,YAAY,GAAG,CAAC,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;IAC/C,CAAC;IACD,MAAM,GAAG,GAAG,MAAM,CAAC,cAAc,GAAG,CAAC,IAAI,YAAY,CAAC;IACtD,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;IAC9C,MAAM,MAAM,GAAG,IAAI,GAAG,MAAM,CAAC,WAAW,CAAC;IACzC,MAAM,MAAM,GAAG,CAAC,MAAM,CAAC,gBAAgB,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC;IAC5D,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC;AAChD,CAAC;AAED,MAAM,UAAU,6BAA6B,CAC3C,MAAuB,EACvB,YAAoB;IAEpB,OAAO,YAAY,GAAG,MAAM,CAAC,WAAW,CAAC;AAC3C,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request/reply correlation with timeout and disconnect cleanup.
|
|
3
|
+
* Never replays outbound requests after abort or disconnect.
|
|
4
|
+
*/
|
|
5
|
+
import type { ProtocolErrorCode, ReplyMessage } from '@softomnitel/omnicall-protocol';
|
|
6
|
+
import type { DiagnosticsSink } from './diagnostics.js';
|
|
7
|
+
import type { ConnectionState } from './connection-state.js';
|
|
8
|
+
import type { Scheduler } from './scheduler.js';
|
|
9
|
+
export type PendingRequestFailure = {
|
|
10
|
+
readonly ok: false;
|
|
11
|
+
readonly errorCode: ProtocolErrorCode;
|
|
12
|
+
readonly reason: 'timeout' | 'aborted' | 'disconnect' | 'invalid_reply';
|
|
13
|
+
};
|
|
14
|
+
export type PendingRequestSuccess = {
|
|
15
|
+
readonly ok: true;
|
|
16
|
+
readonly reply: ReplyMessage;
|
|
17
|
+
};
|
|
18
|
+
export type PendingRequestResult = PendingRequestSuccess | PendingRequestFailure;
|
|
19
|
+
export type CorrelatedRequest = {
|
|
20
|
+
readonly requestId: string;
|
|
21
|
+
readonly commandType: string;
|
|
22
|
+
readonly mutation: boolean;
|
|
23
|
+
};
|
|
24
|
+
export type RequestCorrelator = {
|
|
25
|
+
readonly track: (request: CorrelatedRequest, options: {
|
|
26
|
+
readonly timeoutMs: number;
|
|
27
|
+
readonly signal?: AbortSignal;
|
|
28
|
+
readonly connectionState: ConnectionState;
|
|
29
|
+
}) => Promise<PendingRequestResult>;
|
|
30
|
+
readonly handleInbound: (raw: string, connectionState: ConnectionState) => boolean;
|
|
31
|
+
readonly rejectAll: (reason: 'aborted' | 'disconnect', connectionState: ConnectionState) => void;
|
|
32
|
+
readonly pendingCount: () => number;
|
|
33
|
+
/** Count of mutation sends observed; never stores payloads/PII. */
|
|
34
|
+
readonly mutationSendCount: () => number;
|
|
35
|
+
readonly clearMutationLedger: () => void;
|
|
36
|
+
};
|
|
37
|
+
export declare function createRequestCorrelator(deps: {
|
|
38
|
+
readonly scheduler: Scheduler;
|
|
39
|
+
readonly diagnostics?: DiagnosticsSink;
|
|
40
|
+
}): RequestCorrelator;
|
|
41
|
+
//# sourceMappingURL=request-correlator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-correlator.d.ts","sourceRoot":"","sources":["../../src/internal/request-correlator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAGtF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAe,MAAM,gBAAg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BAAmB,EAAE,MAAM,IAAI,CAAC;CAC1C,CAAC;AAEF,wBAAgB,uBAAuB,CAAC,IAAI,EAAE;IAC5C,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,WAAW,CAAC,EAAE,eAAe,CAAC;CACxC,GAAG,iBAAiB,CAkIpB"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request/reply correlation with timeout and disconnect cleanup.
|
|
3
|
+
* Never replays outbound requests after abort or disconnect.
|
|
4
|
+
*/
|
|
5
|
+
import { validateWireMessage } from '@softomnitel/omnicall-protocol';
|
|
6
|
+
export function createRequestCorrelator(deps) {
|
|
7
|
+
const pending = new Map();
|
|
8
|
+
let mutationSendCount = 0;
|
|
9
|
+
const finish = (entry, result, connectionState) => {
|
|
10
|
+
entry.timer.clear();
|
|
11
|
+
entry.abortUnsubscribe?.();
|
|
12
|
+
pending.delete(entry.request.requestId);
|
|
13
|
+
const durationMs = deps.scheduler.now() - entry.startedAt;
|
|
14
|
+
deps.diagnostics?.emit({
|
|
15
|
+
level: result.ok ? 'debug' : 'warn',
|
|
16
|
+
code: result.ok ? 'request.completed' : 'request.failed',
|
|
17
|
+
connectionState,
|
|
18
|
+
requestId: entry.request.requestId,
|
|
19
|
+
commandType: entry.request.commandType,
|
|
20
|
+
durationMs,
|
|
21
|
+
result: mapResult(result),
|
|
22
|
+
...(result.ok ? {} : { errorCode: result.errorCode })
|
|
23
|
+
});
|
|
24
|
+
entry.resolve(result);
|
|
25
|
+
};
|
|
26
|
+
return {
|
|
27
|
+
track: (request, options) => {
|
|
28
|
+
if (pending.has(request.requestId)) {
|
|
29
|
+
return Promise.resolve({
|
|
30
|
+
ok: false,
|
|
31
|
+
errorCode: 'conflict',
|
|
32
|
+
reason: 'invalid_reply'
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
if (request.mutation) {
|
|
36
|
+
mutationSendCount += 1;
|
|
37
|
+
}
|
|
38
|
+
return new Promise((resolve) => {
|
|
39
|
+
const timer = deps.scheduler.setTimeout(() => {
|
|
40
|
+
const entry = pending.get(request.requestId);
|
|
41
|
+
if (entry === undefined) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
finish(entry, { ok: false, errorCode: 'timeout', reason: 'timeout' }, options.connectionState);
|
|
45
|
+
}, options.timeoutMs);
|
|
46
|
+
let abortUnsubscribe;
|
|
47
|
+
if (options.signal !== undefined) {
|
|
48
|
+
const onAbort = () => {
|
|
49
|
+
const entry = pending.get(request.requestId);
|
|
50
|
+
if (entry === undefined) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
finish(entry, { ok: false, errorCode: 'operation_failed', reason: 'aborted' }, options.connectionState);
|
|
54
|
+
};
|
|
55
|
+
if (options.signal.aborted) {
|
|
56
|
+
timer.clear();
|
|
57
|
+
resolve({
|
|
58
|
+
ok: false,
|
|
59
|
+
errorCode: 'operation_failed',
|
|
60
|
+
reason: 'aborted'
|
|
61
|
+
});
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
options.signal.addEventListener('abort', onAbort, { once: true });
|
|
65
|
+
abortUnsubscribe = () => {
|
|
66
|
+
options.signal?.removeEventListener('abort', onAbort);
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
pending.set(request.requestId, {
|
|
70
|
+
request,
|
|
71
|
+
startedAt: deps.scheduler.now(),
|
|
72
|
+
timer,
|
|
73
|
+
resolve,
|
|
74
|
+
abortUnsubscribe
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
},
|
|
78
|
+
handleInbound: (raw, connectionState) => {
|
|
79
|
+
let parsed;
|
|
80
|
+
try {
|
|
81
|
+
parsed = JSON.parse(raw);
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
const validated = validateWireMessage(parsed);
|
|
87
|
+
if (!validated.success) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
const message = validated.data;
|
|
91
|
+
if (message.kind !== 'reply') {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
const entry = pending.get(message.requestId);
|
|
95
|
+
if (entry === undefined) {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
finish(entry, { ok: true, reply: message }, connectionState);
|
|
99
|
+
return true;
|
|
100
|
+
},
|
|
101
|
+
rejectAll: (reason, connectionState) => {
|
|
102
|
+
const entries = [...pending.values()];
|
|
103
|
+
for (const entry of entries) {
|
|
104
|
+
finish(entry, {
|
|
105
|
+
ok: false,
|
|
106
|
+
errorCode: 'operation_failed',
|
|
107
|
+
reason
|
|
108
|
+
}, connectionState);
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
pendingCount: () => pending.size,
|
|
112
|
+
mutationSendCount: () => mutationSendCount,
|
|
113
|
+
clearMutationLedger: () => {
|
|
114
|
+
mutationSendCount = 0;
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function mapResult(result) {
|
|
119
|
+
if (result.ok) {
|
|
120
|
+
return 'ok';
|
|
121
|
+
}
|
|
122
|
+
if (result.reason === 'timeout') {
|
|
123
|
+
return 'timeout';
|
|
124
|
+
}
|
|
125
|
+
if (result.reason === 'aborted') {
|
|
126
|
+
return 'aborted';
|
|
127
|
+
}
|
|
128
|
+
return 'error';
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=request-correlator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-correlator.js","sourceRoot":"","sources":["../../src/internal/request-correlator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAqDrE,MAAM,UAAU,uBAAuB,CAAC,IAGvC;IACC,MAAM,OAAO,GAAG,IAAI,GAAG,EAAwB,CAAC;IAChD,IAAI,iBAAiB,GAAG,CAAC,CAAC;IAE1B,MAAM,MAAM,G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C,MAAM,EAAE,eAAe,EAAE,EAAE;YACrC,MAAM,OAAO,GAAG,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;YACtC,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;gBAC5B,MAAM,CACJ,KAAK,EACL;oBACE,EAAE,EAAE,KAAK;oBACT,SAAS,EAAE,kBAAkB;oBAC7B,MAAM;iBACP,EACD,eAAe,CAChB,CAAC;YACJ,CAAC;QACH,CAAC;QACD,YAAY,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI;QAChC,iBAAiB,EAAE,GAAG,EAAE,CAAC,iBAAiB;QAC1C,mBAAmB,EAAE,GAAG,EAAE;YACxB,iBAAiB,GAAG,CAAC,CAAC;QACxB,CAAC;KACF,CAAC;AACJ,CAAC;AAED,SAAS,SAAS,CAChB,MAA4B;IAE5B,IAAI,MAAM,CAAC,EAAE,EAAE,CAAC;QACd,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QAChC,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QAChC,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client-side requested capability sanitization (ADR-0016).
|
|
3
|
+
* Never auto-escalates; privileged caps never enter default requests.
|
|
4
|
+
*/
|
|
5
|
+
import { type CapabilityId, type PairingProfile } from '@softomnitel/omnicall-protocol';
|
|
6
|
+
export declare function sanitizeRequestedCapabilities(input: {
|
|
7
|
+
readonly profile: PairingProfile;
|
|
8
|
+
readonly requested: readonly CapabilityId[];
|
|
9
|
+
}): readonly CapabilityId[];
|
|
10
|
+
//# sourceMappingURL=requested-capabilities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requested-capabilities.d.ts","sourceRoot":"","sources":["../../src/internal/requested-capabilities.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAGL,KAAK,YAAY,EACjB,KAAK,cAAc,EACpB,MAAM,gCAAgC,CAAC;AAExC,wBAAgB,6BAA6B,CAAC,KAAK,EAAE;IACnD,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;IACjC,QAAQ,CAAC,SAAS,EAAE,SAAS,YAAY,EAAE,CAAC;CAC7C,GAAG,SAAS,YAAY,EAAE,CAoB1B"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client-side requested capability sanitization (ADR-0016).
|
|
3
|
+
* Never auto-escalates; privileged caps never enter default requests.
|
|
4
|
+
*/
|
|
5
|
+
import { defaultCapabilitiesForProfile, isPrivilegedCapability } from '@softomnitel/omnicall-protocol';
|
|
6
|
+
export function sanitizeRequestedCapabilities(input) {
|
|
7
|
+
const profileDefaults = new Set(defaultCapabilitiesForProfile(input.profile));
|
|
8
|
+
const out = [];
|
|
9
|
+
for (const id of input.requested) {
|
|
10
|
+
if (isPrivilegedCapability(id)) {
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
if (!profileDefaults.has(id)) {
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
if (!out.includes(id)) {
|
|
17
|
+
out.push(id);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
if (out.length === 0) {
|
|
21
|
+
return defaultCapabilitiesForProfile(input.profile).filter((id) => !isPrivilegedCapability(id));
|
|
22
|
+
}
|
|
23
|
+
return out;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=requested-capabilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requested-capabilities.js","sourceRoot":"","sources":["../../src/internal/requested-capabilities.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,6BAA6B,EAC7B,sBAAsB,EAGvB,MAAM,gCAAgC,CAAC;AAExC,MAAM,UAAU,6BAA6B,CAAC,KAG7C;IACC,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,6BAA6B,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IAC9E,MAAM,GAAG,GAAmB,EAAE,CAAC;IAC/B,KAAK,MAAM,EAAE,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;QACjC,IAAI,sBAAsB,CAAC,EAAE,CAAC,EAAE,CAAC;YAC/B,SAAS;QACX,CAAC;QACD,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;YAC7B,SAAS;QACX,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;YACtB,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACf,CAAC;IACH,CAAC;IACD,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrB,OAAO,6BAA6B,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,MAAM,CACxD,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,sBAAsB,CAAC,EAAE,CAAC,CACpC,CAAC;IACJ,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Injectable clock/timers for deterministic fake-time tests and leak proofs.
|
|
3
|
+
*/
|
|
4
|
+
/** @public */
|
|
5
|
+
export type TimerHandle = {
|
|
6
|
+
readonly clear: () => void;
|
|
7
|
+
};
|
|
8
|
+
/** Injectable clock/timers. @public */
|
|
9
|
+
export type Scheduler = {
|
|
10
|
+
readonly now: () => number;
|
|
11
|
+
readonly setTimeout: (callback: () => void, delayMs: number) => TimerHandle;
|
|
12
|
+
};
|
|
13
|
+
/** @public */
|
|
14
|
+
export type JitterSource = {
|
|
15
|
+
/** Uniform value in [0, 1). */
|
|
16
|
+
readonly nextUnitInterval: () => number;
|
|
17
|
+
};
|
|
18
|
+
/** Deterministic fake scheduler surface. @public */
|
|
19
|
+
export type FakeScheduler = Scheduler & {
|
|
20
|
+
readonly advanceBy: (ms: number) => void;
|
|
21
|
+
readonly advanceByAsync: (ms: number) => Promise<void>;
|
|
22
|
+
readonly pendingTimerCount: () => number;
|
|
23
|
+
readonly clearAll: () => void;
|
|
24
|
+
};
|
|
25
|
+
/** Deterministic fake scheduler for tests. @public */
|
|
26
|
+
export declare function createFakeScheduler(startMs?: number): FakeScheduler;
|
|
27
|
+
/** Fixed jitter source for deterministic reconnect tests. @public */
|
|
28
|
+
export declare function createFixedJitterSource(value: number): JitterSource;
|
|
29
|
+
/**
|
|
30
|
+
* Browser / production scheduler over `Date` and `setTimeout`.
|
|
31
|
+
* Prefer {@link createFakeScheduler} in unit tests.
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
export declare function createBrowserScheduler(): Scheduler;
|
|
35
|
+
/**
|
|
36
|
+
* Browser / production jitter via `Math.random`.
|
|
37
|
+
* Prefer {@link createFixedJitterSource} in unit tests.
|
|
38
|
+
* @public
|
|
39
|
+
*/
|
|
40
|
+
export declare function createBrowserJitterSource(): JitterSource;
|
|
41
|
+
//# sourceMappingURL=scheduler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scheduler.d.ts","sourceRoot":"","sources":["../../src/internal/scheduler.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc;AACd,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,IAAI,CAAC;CAC5B,CAAC;AAEF,uCAAuC;AACvC,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,MAAM,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,WAAW,CAAC;CAC7E,CAAC;AAEF,cAAc;AACd,MAAM,MAAM,YAAY,GAAG;IACzB,+BAA+B;IAC/B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,MAAM,CAAC;CACzC,CAAC;AAEF,oDAAoD;AACpD,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG;IACtC,QAAQ,CAAC,SAAS,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,QAAQ,CAAC,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACvD,QAAQ,CAAC,iBAAiB,EAAE,MAAM,MAAM,CAAC;IACzC,QAAQ,CAAC,QAAQ,EAAE,MAAM,IAAI,CAAC;CAC/B,CAAC;AAQF,sDAAsD;AACtD,wBAAgB,mBAAmB,CAAC,OAAO,SAAI,GAAG,aAAa,CA+D9D;AAED,qEAAqE;AACrE,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CAOnE;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,IAAI,SAAS,CAYlD;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,IAAI,YAAY,CAIxD"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Injectable clock/timers for deterministic fake-time tests and leak proofs.
|
|
3
|
+
*/
|
|
4
|
+
/** Deterministic fake scheduler for tests. @public */
|
|
5
|
+
export function createFakeScheduler(startMs = 0) {
|
|
6
|
+
let nowMs = startMs;
|
|
7
|
+
let nextId = 1;
|
|
8
|
+
const timers = new Map();
|
|
9
|
+
const runDue = () => {
|
|
10
|
+
for (;;) {
|
|
11
|
+
let due;
|
|
12
|
+
for (const timer of timers.values()) {
|
|
13
|
+
if (timer.dueAt > nowMs) {
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
if (due === undefined || timer.dueAt < due.dueAt || timer.id < due.id) {
|
|
17
|
+
due = timer;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
if (due === undefined) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
timers.delete(due.id);
|
|
24
|
+
due.callback();
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
return {
|
|
28
|
+
now: () => nowMs,
|
|
29
|
+
setTimeout: (callback, delayMs) => {
|
|
30
|
+
const id = nextId;
|
|
31
|
+
nextId += 1;
|
|
32
|
+
const delay = Math.max(0, delayMs);
|
|
33
|
+
timers.set(id, { id, dueAt: nowMs + delay, callback });
|
|
34
|
+
return {
|
|
35
|
+
clear: () => {
|
|
36
|
+
timers.delete(id);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
advanceBy: (ms) => {
|
|
41
|
+
if (ms < 0) {
|
|
42
|
+
throw new Error('advanceBy requires non-negative ms');
|
|
43
|
+
}
|
|
44
|
+
nowMs += ms;
|
|
45
|
+
runDue();
|
|
46
|
+
},
|
|
47
|
+
/**
|
|
48
|
+
* Advance time and resolve queued microtasks from timer callbacks (Promises).
|
|
49
|
+
* Call from async tests after advances that complete Promise-based work.
|
|
50
|
+
*/
|
|
51
|
+
advanceByAsync: async (ms) => {
|
|
52
|
+
if (ms < 0) {
|
|
53
|
+
throw new Error('advanceBy requires non-negative ms');
|
|
54
|
+
}
|
|
55
|
+
nowMs += ms;
|
|
56
|
+
runDue();
|
|
57
|
+
await Promise.resolve();
|
|
58
|
+
await Promise.resolve();
|
|
59
|
+
runDue();
|
|
60
|
+
},
|
|
61
|
+
pendingTimerCount: () => timers.size,
|
|
62
|
+
clearAll: () => {
|
|
63
|
+
timers.clear();
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/** Fixed jitter source for deterministic reconnect tests. @public */
|
|
68
|
+
export function createFixedJitterSource(value) {
|
|
69
|
+
if (value < 0 || value >= 1) {
|
|
70
|
+
throw new Error('fixed jitter must be in [0, 1)');
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
nextUnitInterval: () => value
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Browser / production scheduler over `Date` and `setTimeout`.
|
|
78
|
+
* Prefer {@link createFakeScheduler} in unit tests.
|
|
79
|
+
* @public
|
|
80
|
+
*/
|
|
81
|
+
export function createBrowserScheduler() {
|
|
82
|
+
return {
|
|
83
|
+
now: () => Date.now(),
|
|
84
|
+
setTimeout: (callback, delayMs) => {
|
|
85
|
+
const id = setTimeout(callback, delayMs);
|
|
86
|
+
return {
|
|
87
|
+
clear: () => {
|
|
88
|
+
clearTimeout(id);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Browser / production jitter via `Math.random`.
|
|
96
|
+
* Prefer {@link createFixedJitterSource} in unit tests.
|
|
97
|
+
* @public
|
|
98
|
+
*/
|
|
99
|
+
export function createBrowserJitterSource() {
|
|
100
|
+
return {
|
|
101
|
+
nextUnitInterval: () => Math.random()
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=scheduler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scheduler.js","sourceRoot":"","sources":["../../src/internal/scheduler.ts"],"names":[],"mappings":"AAAA;;GAEG;AAiCH,sDAAsD;AACtD,MAAM,UAAU,mBAAmB,CAAC,OAAO,GAAG,CAAC;IAC7C,IAAI,KAAK,GAAG,OAAO,CAAC;IACpB,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,MAAM,MAAM,GAAG,IAAI,GAAG,EAAwB,CAAC;IAE/C,MAAM,MAAM,GAAG,GAAS,EAAE;QACxB,SAAS,CAAC;YACR,IAAI,GAA6B,CAAC;YAClC,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC;gBACpC,IAAI,KAAK,CAAC,KAAK,GAAG,KAAK,EAAE,CAAC;oBACxB,SAAS;gBACX,C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4
|
+
import type { CapabilityId, PairingProfile } from '@softomnitel/omnicall-protocol';
|
|
5
|
+
export type SessionIdentity = {
|
|
6
|
+
readonly serverInstanceId: string;
|
|
7
|
+
readonly sessionEpoch: string;
|
|
8
|
+
readonly selectedProtocolVersion: number;
|
|
9
|
+
readonly clientId: string;
|
|
10
|
+
readonly profile: PairingProfile | undefined;
|
|
11
|
+
readonly grantedCapabilities: readonly CapabilityId[];
|
|
12
|
+
readonly heartbeatSeconds: number;
|
|
13
|
+
readonly maxMessageBytes: number;
|
|
14
|
+
};
|
|
15
|
+
export declare function clearGrantedCapabilities(identity: SessionIdentity | undefined): SessionIdentity | undefined;
|
|
16
|
+
//# sourceMappingURL=session-identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-identity.d.ts","sourceRoot":"","sources":["../../src/internal/session-identity.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAEnF,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,uBAAuB,EAAE,MAAM,CAAC;IACzC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,cAAc,GAAG,SAAS,CAAC;IAC7C,QAAQ,CAAC,mBAAmB,EAAE,SAAS,YAAY,EAAE,CAAC;IACtD,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;CAClC,CAAC;AAEF,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,eAAe,GAAG,SAAS,GACpC,eAAe,GAAG,SAAS,CAQ7B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authenticated session metadata bound after server-hello / PoP success.
|
|
3
|
+
*/
|
|
4
|
+
export function clearGrantedCapabilities(identity) {
|
|
5
|
+
if (identity === undefined) {
|
|
6
|
+
return undefined;
|
|
7
|
+
}
|
|
8
|
+
return Object.freeze({
|
|
9
|
+
...identity,
|
|
10
|
+
grantedCapabilities: Object.freeze([])
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=session-identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-identity.js","sourceRoot":"","sources":["../../src/internal/session-identity.ts"],"names":[],"mappings":"AAAA;;GAEG;AAeH,MAAM,UAAU,wBAAwB,CACtC,QAAqC;IAErC,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,GAAG,QAAQ;QACX,mBAAmB,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;KACvC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pending getSnapshot acquisitions: revision-bound resolve + typed reject.
|
|
3
|
+
*/
|
|
4
|
+
import type { SnapshotMessage } from '@softomnitel/omnicall-protocol';
|
|
5
|
+
import { type OmniCallClientError } from './client-errors.js';
|
|
6
|
+
import type { TimerHandle } from './scheduler.js';
|
|
7
|
+
export type SnapshotAcquisition = {
|
|
8
|
+
readonly requestId: string;
|
|
9
|
+
expectedRevision: number | undefined;
|
|
10
|
+
settled: boolean;
|
|
11
|
+
timer: TimerHandle | undefined;
|
|
12
|
+
readonly resolve: (value: SnapshotMessage) => void;
|
|
13
|
+
readonly reject: (error: OmniCallClientError) => void;
|
|
14
|
+
};
|
|
15
|
+
export declare function matchSnapshotRevision(snapshot: SnapshotMessage, revision: number): boolean;
|
|
16
|
+
export declare function rejectAllAcquisitions(acquisitions: readonly SnapshotAcquisition[], error: OmniCallClientError): void;
|
|
17
|
+
export declare function settleResolve(acquisition: SnapshotAcquisition, snapshot: SnapshotMessage): void;
|
|
18
|
+
export declare function settleReject(acquisition: SnapshotAcquisition, error: OmniCallClientError): void;
|
|
19
|
+
export declare function invalidateErrorForState(state: string): OmniCallClientError;
|
|
20
|
+
export declare function timeoutSnapshotError(): OmniCallClientError;
|
|
21
|
+
//# sourceMappingURL=snapshot-acquisition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot-acquisition.d.ts","sourceRoot":"","sources":["../../src/internal/snapshot-acquisition.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEtE,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,WAAW,GAAG,SAAS,CAAC;IAC/B,QAAQ,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;IACnD,QAAQ,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,CAAC;CACvD,CAAC;AAEF,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,eAAe,EACzB,QAAQ,EAAE,MAAM,GACf,OAAO,CAET;AAED,wBAAgB,qBAAqB,CACnC,YAAY,EAAE,SAAS,mBAAmB,EAAE,EAC5C,KAAK,EAAE,mBAAmB,GACzB,IAAI,CAIN;AAED,wBAAgB,aAAa,CAC3B,WAAW,EAAE,mBAAmB,EAChC,QAAQ,EAAE,eAAe,GACxB,IAAI,CAQN;AAED,wBAAgB,YAAY,CAC1B,WAAW,EAAE,mBAAmB,EAChC,KAAK,EAAE,mBAAmB,GACzB,IAAI,CAQN;AAED,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,MAAM,GACZ,mBAAmB,CAKrB;AAED,wBAAgB,oBAAoB,IAAI,mBAAmB,CAE1D"}
|