@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
package/LICENSE
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# @softomnitel/omnicall-kit
|
|
2
|
+
|
|
3
|
+
Browser SDK client for OmniCall Desktop.
|
|
4
|
+
|
|
5
|
+
**Status:** product namespaces through SDK-08 + official browser WebSocket transport defaults.
|
|
6
|
+
Call/operator/account mutations and lifecycle are on `OmniCallClient`.
|
|
7
|
+
|
|
8
|
+
Depends on `@softomnitel/omnicall-protocol` only. Must never import OmniCall Desktop Domain,
|
|
9
|
+
Application, Electron, JsSIP, React, or Zustand.
|
|
10
|
+
|
|
11
|
+
Public surface (highlights):
|
|
12
|
+
|
|
13
|
+
- `createAuthClient` — pairing / PoP / capabilities
|
|
14
|
+
- `createOmniCallClient` — product API on top of auth
|
|
15
|
+
- `createBrowserWebSocketTransport` — official `TransportPort` over browser `WebSocket`
|
|
16
|
+
- `createBrowserScheduler` / `createBrowserJitterSource` — production timer/jitter defaults
|
|
17
|
+
- `createIndexedDbPopKeyStore` / `createMemoryPopKeyStore` — PoP persistence
|
|
18
|
+
- Type helpers: `OmniCallEventOf`, snapshot/capability re-exports, typed error readers
|
|
19
|
+
(`readInteractionRequiredDetails`, …) — see `docs/guide/typescript.md`
|
|
20
|
+
|
|
21
|
+
Constructor options `transportFactory`, `scheduler`, and `jitter` are **optional** in
|
|
22
|
+
browsers (defaults above). Unit tests should still inject FakeTransport + fake scheduler.
|
|
23
|
+
|
|
24
|
+
Internal production modules (not all exported as helpers):
|
|
25
|
+
|
|
26
|
+
- explicit connection state machine
|
|
27
|
+
- request correlation, timeouts, abort/disconnect cleanup
|
|
28
|
+
- heartbeat and bounded jittered reconnect
|
|
29
|
+
- snapshot cache, sequence-gap resync, redaction-safe diagnostics
|
|
30
|
+
|
|
31
|
+
`FakeTransport` / test helpers live under `src/internal/` for unit tests only and are
|
|
32
|
+
excluded from the published `dist/` tarball.
|
|
33
|
+
|
|
34
|
+
See `docs/guide/transport.md` for the transport contract.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@softomnitel/omnicall-kit` — browser client for OmniCall Desktop local protocol.
|
|
3
|
+
*
|
|
4
|
+
* SDK-08+: OmniCallClient with namespaced product APIs + official browser WebSocket transport.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
export { createAuthClient, type AuthClient, type AuthClientOptions, type AuthSessionSnapshot, type PairingRequiredInfo } from './public/auth-client.js';
|
|
9
|
+
export { OmniCallClientError, createOmniCallClient, isOmniCallClientError, isConflictError, isInteractionRequiredError, isOperationFailedError, isOriginBlockedError, PUBLIC_EVENT_TYPES, readConflictErrorDetails, readInteractionRequiredDetails, readOperationFailedDetails, type ActivateProfileMode, type ActivateProfileResult, type OmniCallAccountApi, type OmniCallCallsApi, type OmniCallClient, type OmniCallClientOptions, type OmniCallEvent, type OmniCallEventOf, type OmniCallOperatorApi, type OmniCallWindowApi, type CallMutationResult, type CapabilityId, type ConflictErrorDetails, type InteractionRequiredDetails, type LogoutResult, type OperationFailedDetails, type OperatorFinishAppealResult, type OperatorReason, type OperatorReasonsResult, type OperatorStatusChangeKind, type OperatorStatusChangeResult, type ProtocolErrorCode, type PublicEventType, type PublicOperatorStatus, type SnapshotCallSummary, type SnapshotMessage, type SnapshotSections, type WireJsonObject } from './public/omnicall-client.js';
|
|
10
|
+
export { SDK_ACTIVATE_CLIENT_TIMEOUT_MS, SDK_ACTIVATE_CONSENT_TTL_MS, SDK_ACTIVATE_OCP_AUTH_BUDGET_MS, SDK_ACTIVATE_SIP_ONLY_AUTH_BUDGET_MS } from '@softomnitel/omnicall-protocol';
|
|
11
|
+
export { CONNECTION_STATES, type ConnectionState } from './internal/connection-state.js';
|
|
12
|
+
export { createIndexedDbPopKeyStore, createMemoryPopKeyStore, type PopKeyStore, type StoredPopIdentity } from './internal/pop-key-store.js';
|
|
13
|
+
export { createBrowserWebSocketTransport, type BrowserWebSocketConstructor, type BrowserWebSocketLike, type CreateBrowserWebSocketTransportOptions } from './internal/browser-websocket-transport.js';
|
|
14
|
+
export type { TransportCloseInfo, TransportErrorInfo, TransportFactory, TransportPort } from './internal/transport-port.js';
|
|
15
|
+
export type { FakeScheduler, JitterSource, Scheduler, TimerHandle } from './internal/scheduler.js';
|
|
16
|
+
export { createBrowserJitterSource, createBrowserScheduler, createFakeScheduler, createFixedJitterSource } from './internal/scheduler.js';
|
|
17
|
+
export type { ReconnectPolicy } from './internal/reconnect-policy.js';
|
|
18
|
+
export type { HeartbeatPolicy } from './internal/heartbeat-controller.js';
|
|
19
|
+
export type { DiagnosticEvent, DiagnosticLevel, DiagnosticResult, DiagnosticsSink } from './internal/diagnostics.js';
|
|
20
|
+
export { createRecordingDiagnosticsSink } from './internal/diagnostics.js';
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","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B,EAC/B,KAAK,2BAA2B,EAChC,KAAK,oBAAoB,EACzB,KAAK,sCAAsC,EAC5C,MAAM,2CAA2C,CAAC;AAEnD,YAAY,EACV,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EACd,MAAM,8BAA8B,CAAC;AAEtC,YAAY,EACV,aAAa,EACb,YAAY,EACZ,SAAS,EACT,WAAW,EACZ,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,yBAAyB,EACzB,sBAAsB,EACtB,mBAAmB,EACnB,uBAAuB,EACxB,MAAM,yBAAyB,CAAC;AAEjC,YAAY,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACtE,YAAY,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAE1E,YAAY,EACV,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,eAAe,EAChB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,8BAA8B,EAAE,MAAM,2BAA2B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@softomnitel/omnicall-kit` — browser client for OmniCall Desktop local protocol.
|
|
3
|
+
*
|
|
4
|
+
* SDK-08+: OmniCallClient with namespaced product APIs + official browser WebSocket transport.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
export { createAuthClient } from './public/auth-client.js';
|
|
9
|
+
export { OmniCallClientError, createOmniCallClient, isOmniCallClientError, isConflictError, isInteractionRequiredError, isOperationFailedError, isOriginBlockedError, PUBLIC_EVENT_TYPES, readConflictErrorDetails, readInteractionRequiredDetails, readOperationFailedDetails } from './public/omnicall-client.js';
|
|
10
|
+
export { SDK_ACTIVATE_CLIENT_TIMEOUT_MS, SDK_ACTIVATE_CONSENT_TTL_MS, SDK_ACTIVATE_OCP_AUTH_BUDGET_MS, SDK_ACTIVATE_SIP_ONLY_AUTH_BUDGET_MS } from '@softomnitel/omnicall-protocol';
|
|
11
|
+
export { CONNECTION_STATES } from './internal/connection-state.js';
|
|
12
|
+
export { createIndexedDbPopKeyStore, createMemoryPopKeyStore } from './internal/pop-key-store.js';
|
|
13
|
+
export { createBrowserWebSocketTransport } from './internal/browser-websocket-transport.js';
|
|
14
|
+
export { createBrowserJitterSource, createBrowserScheduler, createFakeScheduler, createFixedJitterSource } from './internal/scheduler.js';
|
|
15
|
+
export { createRecordingDiagnosticsSink } from './internal/diagnostics.js';
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,gBAAgB,EAKjB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,eAAe,EACf,0BAA0B,EAC1B,sBAAsB,EACtB,oBAAoB,EACpB,kBAAkB,EAClB,wBAAwB,EACxB,8BAA8B,EAC9B,0BAA0B,EA6B3B,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,8BAA8B,EAC9B,2BAA2B,EAC3B,+BAA+B,EAC/B,oCAAoC,EACrC,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACL,iBAAiB,EAElB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACL,0BAA0B,EAC1B,uBAAuB,EAGxB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,+BAA+B,EAIhC,MAAM,2CAA2C,CAAC;AAenD,OAAO,EACL,yBAAyB,EACzB,sBAAsB,EACtB,mBAAmB,EACnB,uBAAuB,EACxB,MAAM,yBAAyB,CAAC;AAWjC,OAAO,EAAE,8BAA8B,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capability-gated saved-profile activation runner (SDK-08).
|
|
3
|
+
* Privileged `account.activate` — server-granted only; never pairing-default.
|
|
4
|
+
*/
|
|
5
|
+
import type { CapabilityId } from '@softomnitel/omnicall-protocol';
|
|
6
|
+
import type { ConnectionSession } from './connection-session.js';
|
|
7
|
+
import type { Scheduler } from './scheduler.js';
|
|
8
|
+
/** Documented activate modes accepted by protocol v1 desktop. @public */
|
|
9
|
+
export type ActivateProfileMode = 'sip_only' | 'ocp';
|
|
10
|
+
/** Successful activate-profile. @public */
|
|
11
|
+
export type ActivateProfileResult = {
|
|
12
|
+
readonly activated: true;
|
|
13
|
+
readonly mode: ActivateProfileMode;
|
|
14
|
+
readonly profileLabel?: string;
|
|
15
|
+
readonly alreadyAuthenticated?: boolean;
|
|
16
|
+
readonly revision: number;
|
|
17
|
+
};
|
|
18
|
+
export type AccountActivateCommandApi = {
|
|
19
|
+
readonly activateProfile: (input: {
|
|
20
|
+
readonly login: string;
|
|
21
|
+
readonly expectedRevision: number;
|
|
22
|
+
readonly mode?: ActivateProfileMode;
|
|
23
|
+
}) => Promise<ActivateProfileResult>;
|
|
24
|
+
};
|
|
25
|
+
export declare function createAccountActivateCommandApi(deps: {
|
|
26
|
+
readonly connection: ConnectionSession;
|
|
27
|
+
readonly scheduler: Scheduler;
|
|
28
|
+
readonly getGrantedCapabilities: () => readonly CapabilityId[];
|
|
29
|
+
}): AccountActivateCommandApi;
|
|
30
|
+
//# sourceMappingURL=account-activate-commands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account-activate-commands.d.ts","sourceRoot":"","sources":["../../src/internal/account-activate-commands.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAKnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAOjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAYhD,yEAAyE;AACzE,MAAM,MAAM,mBAAmB,GAAG,UAAU,GAAG,KAAK,CAAC;AAErD,2CAA2C;AAC3C,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,mBAAmB,CAAC;IACnC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,oBAAoB,CAAC,EAAE,OAAO,CAAC;IACxC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,QAAQ,CAAC,eAAe,EAAE,CAAC,KAAK,EAAE;QAChC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;QAClC,QAAQ,CAAC,IAAI,CAAC,EAAE,mBAAmB,CAAC;KACrC,KAAK,OAAO,CAAC,qBAAqB,CAAC,CAAC;CACtC,CAAC;AAuGF,wBAAgB,+BAA+B,CAAC,IAAI,EAAE;IACpD,QAAQ,CAAC,UAAU,EAAE,iBAAiB,CAAC;IACvC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,sBAAsB,EAAE,MAAM,SAAS,YAAY,EAAE,CAAC;CAChE,GAAG,yBAAyB,CAI5B"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capability-gated saved-profile activation runner (SDK-08).
|
|
3
|
+
* Privileged `account.activate` — server-granted only; never pairing-default.
|
|
4
|
+
*/
|
|
5
|
+
import { SDK_ACTIVATE_CLIENT_TIMEOUT_MS } from '@softomnitel/omnicall-protocol';
|
|
6
|
+
import { buildAccountActivateProfileBody } from './account-activate-wire.js';
|
|
7
|
+
import { createClientError } from './client-errors.js';
|
|
8
|
+
import { guardCapability, guardReady, mapReplyFailure, requireWireIdentity } from './product-commands.js';
|
|
9
|
+
const SECRET_RESULT_KEYS = new Set([
|
|
10
|
+
'password',
|
|
11
|
+
'apiKey',
|
|
12
|
+
'sipPassword',
|
|
13
|
+
'token',
|
|
14
|
+
'secret',
|
|
15
|
+
'pairingSecret',
|
|
16
|
+
'privateKey'
|
|
17
|
+
]);
|
|
18
|
+
function isActivateProfileMode(value) {
|
|
19
|
+
return value === 'sip_only' || value === 'ocp';
|
|
20
|
+
}
|
|
21
|
+
function hasSecretResultKeys(result) {
|
|
22
|
+
for (const key of Object.keys(result)) {
|
|
23
|
+
if (SECRET_RESULT_KEYS.has(key)) {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
function readActivateProfileResult(reply) {
|
|
30
|
+
if (hasSecretResultKeys(reply.result)) {
|
|
31
|
+
throw createClientError({ code: 'invalid_payload', retryable: false });
|
|
32
|
+
}
|
|
33
|
+
const activated = reply.result['activated'];
|
|
34
|
+
const mode = reply.result['mode'];
|
|
35
|
+
if (activated !== true ||
|
|
36
|
+
typeof mode !== 'string' ||
|
|
37
|
+
!isActivateProfileMode(mode)) {
|
|
38
|
+
throw createClientError({ code: 'invalid_payload', retryable: false });
|
|
39
|
+
}
|
|
40
|
+
const profileLabel = reply.result['profileLabel'];
|
|
41
|
+
const alreadyAuthenticated = reply.result['alreadyAuthenticated'];
|
|
42
|
+
if (profileLabel !== undefined) {
|
|
43
|
+
if (typeof profileLabel !== 'string' || profileLabel.length === 0) {
|
|
44
|
+
throw createClientError({ code: 'invalid_payload', retryable: false });
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (alreadyAuthenticated !== undefined &&
|
|
48
|
+
typeof alreadyAuthenticated !== 'boolean') {
|
|
49
|
+
throw createClientError({ code: 'invalid_payload', retryable: false });
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
activated: true,
|
|
53
|
+
mode,
|
|
54
|
+
...(profileLabel === undefined ? {} : { profileLabel }),
|
|
55
|
+
...(alreadyAuthenticated === undefined ? {} : { alreadyAuthenticated }),
|
|
56
|
+
revision: reply.revision
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
async function runActivateProfile(deps, input) {
|
|
60
|
+
const notReady = guardReady(deps.connection);
|
|
61
|
+
if (notReady !== undefined) {
|
|
62
|
+
return Promise.reject(notReady);
|
|
63
|
+
}
|
|
64
|
+
const missingCap = guardCapability(deps.getGrantedCapabilities(), 'account.activate');
|
|
65
|
+
if (missingCap !== undefined) {
|
|
66
|
+
return Promise.reject(missingCap);
|
|
67
|
+
}
|
|
68
|
+
const identity = requireWireIdentity(deps.connection);
|
|
69
|
+
if ('code' in identity) {
|
|
70
|
+
return Promise.reject(identity);
|
|
71
|
+
}
|
|
72
|
+
const requestId = crypto.randomUUID();
|
|
73
|
+
const result = await deps.connection.request({
|
|
74
|
+
requestId,
|
|
75
|
+
commandType: 'account:activate-profile',
|
|
76
|
+
timeoutMs: SDK_ACTIVATE_CLIENT_TIMEOUT_MS,
|
|
77
|
+
body: buildAccountActivateProfileBody({
|
|
78
|
+
requestId,
|
|
79
|
+
serverInstanceId: identity.serverInstanceId,
|
|
80
|
+
sessionEpoch: identity.sessionEpoch,
|
|
81
|
+
occurredAtMs: deps.scheduler.now()
|
|
82
|
+
}, input)
|
|
83
|
+
});
|
|
84
|
+
if (!result.ok || !result.reply.ok) {
|
|
85
|
+
return Promise.reject(mapReplyFailure(result));
|
|
86
|
+
}
|
|
87
|
+
return readActivateProfileResult(result.reply);
|
|
88
|
+
}
|
|
89
|
+
export function createAccountActivateCommandApi(deps) {
|
|
90
|
+
return {
|
|
91
|
+
activateProfile: (input) => runActivateProfile(deps, input)
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=account-activate-commands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account-activate-commands.js","sourceRoot":"","sources":["../../src/internal/account-activate-commands.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,8BAA8B,EAAE,MAAM,gCAAgC,CAAC;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|
6
|
+
readonly serverInstanceId: string;
|
|
7
|
+
readonly sessionEpoch: string;
|
|
8
|
+
readonly occurredAtMs: number;
|
|
9
|
+
};
|
|
10
|
+
export declare function buildAccountActivateProfileBody(identity: WireIdentity, input: {
|
|
11
|
+
readonly login: string;
|
|
12
|
+
readonly expectedRevision: number;
|
|
13
|
+
readonly mode?: 'sip_only' | 'ocp';
|
|
14
|
+
}): string;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=account-activate-wire.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account-activate-wire.d.ts","sourceRoot":"","sources":["../../src/internal/account-activate-wire.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,KAAK,YAAY,GAAG;IAClB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B,CAAC;AAEF,wBAAgB,+BAA+B,CAC7C,QAAQ,EAAE,YAAY,EACtB,KAAK,EAAE;IACL,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,IAAI,CAAC,EAAE,UAAU,GAAG,KAAK,CAAC;CACpC,GACA,MAAM,CAeR"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Account activate-profile wire builder (SDK-08). Schema-aligned outbound frames.
|
|
3
|
+
*/
|
|
4
|
+
import { PROTOCOL_MAJOR } from '@softomnitel/omnicall-protocol';
|
|
5
|
+
import { isoNow } from './auth-wire.js';
|
|
6
|
+
export function buildAccountActivateProfileBody(identity, input) {
|
|
7
|
+
return JSON.stringify({
|
|
8
|
+
protocolVersion: PROTOCOL_MAJOR,
|
|
9
|
+
kind: 'command',
|
|
10
|
+
type: 'account:activate-profile',
|
|
11
|
+
requestId: identity.requestId,
|
|
12
|
+
serverInstanceId: identity.serverInstanceId,
|
|
13
|
+
sessionEpoch: identity.sessionEpoch,
|
|
14
|
+
occurredAt: isoNow(identity.occurredAtMs),
|
|
15
|
+
payload: {
|
|
16
|
+
login: input.login,
|
|
17
|
+
expectedRevision: input.expectedRevision,
|
|
18
|
+
...(input.mode === undefined ? {} : { mode: input.mode })
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=account-activate-wire.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account-activate-wire.js","sourceRoot":"","sources":["../../src/internal/account-activate-wire.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAEhE,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AASxC,MAAM,UAAU,+BAA+B,CAC7C,QAAsB,EACtB,KAIC;IAED,OAAO,IAAI,CAAC,SAAS,CAAC;QACpB,eAAe,EAAE,cAAc;QAC/B,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,0BAA0B;QAChC,SAAS,EAAE,QAAQ,CAAC,SAAS;QAC7B,gBAAgB,EAAE,QAAQ,CAAC,gBAAgB;QAC3C,YAAY,EAAE,QAAQ,CAAC,YAAY;QACnC,UAAU,EAAE,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC;QACzC,OAAO,EAAE;YACP,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,gBAAgB,EAAE,KAAK,CAAC,gBAAgB;YACxC,GAAG,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;SAC1D;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capability-gated single-shot account logout (session.logout).
|
|
3
|
+
*/
|
|
4
|
+
import type { CapabilityId } from '@softomnitel/omnicall-protocol';
|
|
5
|
+
import type { ConnectionSession } from './connection-session.js';
|
|
6
|
+
import type { Scheduler } from './scheduler.js';
|
|
7
|
+
/** Successful account:logout. @public */
|
|
8
|
+
export type LogoutResult = {
|
|
9
|
+
readonly loggedOut: true;
|
|
10
|
+
readonly revision: number;
|
|
11
|
+
};
|
|
12
|
+
export type AccountLogoutCommandApi = {
|
|
13
|
+
readonly logout: (input: {
|
|
14
|
+
readonly reasonId?: number;
|
|
15
|
+
readonly expectedRevision: number;
|
|
16
|
+
}) => Promise<LogoutResult>;
|
|
17
|
+
};
|
|
18
|
+
export declare function createAccountLogoutCommandApi(deps: {
|
|
19
|
+
readonly connection: ConnectionSession;
|
|
20
|
+
readonly scheduler: Scheduler;
|
|
21
|
+
readonly getGrantedCapabilities: () => readonly CapabilityId[];
|
|
22
|
+
}): AccountLogoutCommandApi;
|
|
23
|
+
//# sourceMappingURL=account-logout-commands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account-logout-commands.d.ts","sourceRoot":"","sources":["../../src/internal/account-logout-commands.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAe,MAAM,gCAAgC,CAAC;AAIhF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAOjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,yCAAyC;AACzC,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE;QACvB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAC3B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;KACnC,KAAK,OAAO,CAAC,YAAY,CAAC,CAAC;CAC7B,CAAC;AAgBF,wBAAgB,6BAA6B,CAAC,IAAI,EAAE;IAClD,QAAQ,CAAC,UAAU,EAAE,iBAAiB,CAAC;IACvC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,sBAAsB,EAAE,MAAM,SAAS,YAAY,EAAE,CAAC;CAChE,GAAG,uBAAuB,CAoC1B"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capability-gated single-shot account logout (session.logout).
|
|
3
|
+
*/
|
|
4
|
+
import { buildAccountLogoutBody } from './account-logout-wire.js';
|
|
5
|
+
import { createClientError } from './client-errors.js';
|
|
6
|
+
import { guardCapability, guardReady, mapReplyFailure, requireWireIdentity } from './product-commands.js';
|
|
7
|
+
function readLogoutResult(reply) {
|
|
8
|
+
const loggedOut = reply.result['loggedOut'];
|
|
9
|
+
if (loggedOut !== true) {
|
|
10
|
+
throw createClientError({ code: 'invalid_payload', retryable: false });
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
loggedOut: true,
|
|
14
|
+
revision: reply.revision
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export function createAccountLogoutCommandApi(deps) {
|
|
18
|
+
return {
|
|
19
|
+
logout: async (input) => {
|
|
20
|
+
const notReady = guardReady(deps.connection);
|
|
21
|
+
if (notReady !== undefined) {
|
|
22
|
+
return Promise.reject(notReady);
|
|
23
|
+
}
|
|
24
|
+
const missingCap = guardCapability(deps.getGrantedCapabilities(), 'session.logout');
|
|
25
|
+
if (missingCap !== undefined) {
|
|
26
|
+
return Promise.reject(missingCap);
|
|
27
|
+
}
|
|
28
|
+
const identity = requireWireIdentity(deps.connection);
|
|
29
|
+
if ('code' in identity) {
|
|
30
|
+
return Promise.reject(identity);
|
|
31
|
+
}
|
|
32
|
+
const requestId = crypto.randomUUID();
|
|
33
|
+
const fields = {
|
|
34
|
+
requestId,
|
|
35
|
+
serverInstanceId: identity.serverInstanceId,
|
|
36
|
+
sessionEpoch: identity.sessionEpoch,
|
|
37
|
+
occurredAtMs: deps.scheduler.now()
|
|
38
|
+
};
|
|
39
|
+
const result = await deps.connection.request({
|
|
40
|
+
requestId,
|
|
41
|
+
commandType: 'account:logout',
|
|
42
|
+
body: buildAccountLogoutBody(fields, input)
|
|
43
|
+
});
|
|
44
|
+
if (!result.ok || !result.reply.ok) {
|
|
45
|
+
return Promise.reject(mapReplyFailure(result));
|
|
46
|
+
}
|
|
47
|
+
return readLogoutResult(result.reply);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=account-logout-commands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account-logout-commands.js","sourceRoot":"","sources":["../../src/internal/account-logout-commands.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,EACL,eAAe,EACf,UAAU,EACV,eAAe,EACf,mBAAmB,EACpB,MAAM,uBAAuB,CAAC;AAgB/B,SAAS,gBAAgB,CAAC,KAGzB;IACC,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAC5C,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;QACvB,MAAM,iBAAiB,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;IACzE,CAAC;IACD,OAAO;QACL,SAAS,EAAE,IAAI;QACf,QAAQ,EAAE,KAAK,CAAC,QAAQ;KACzB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,6BAA6B,CAAC,IAI7C;IACC,OAAO;QACL,MAAM,EAA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CAAC,CAAC;QACxC,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Account logout wire builder — single-shot `account:logout`.
|
|
3
|
+
*/
|
|
4
|
+
type WireIdentity = {
|
|
5
|
+
readonly requestId: string;
|
|
6
|
+
readonly serverInstanceId: string;
|
|
7
|
+
readonly sessionEpoch: string;
|
|
8
|
+
readonly occurredAtMs: number;
|
|
9
|
+
};
|
|
10
|
+
export declare function buildAccountLogoutBody(identity: WireIdentity, input: {
|
|
11
|
+
readonly reasonId?: number;
|
|
12
|
+
readonly expectedRevision: number;
|
|
13
|
+
}): string;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=account-logout-wire.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account-logout-wire.d.ts","sourceRoot":"","sources":["../../src/internal/account-logout-wire.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,KAAK,YAAY,GAAG;IAClB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B,CAAC;AAmBF,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,YAAY,EACtB,KAAK,EAAE;IACL,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;CACnC,GACA,MAAM,CAKR"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Account logout wire builder — single-shot `account:logout`.
|
|
3
|
+
*/
|
|
4
|
+
import { PROTOCOL_MAJOR } from '@softomnitel/omnicall-protocol';
|
|
5
|
+
import { isoNow } from './auth-wire.js';
|
|
6
|
+
function envelope(type, identity, payload) {
|
|
7
|
+
return JSON.stringify({
|
|
8
|
+
protocolVersion: PROTOCOL_MAJOR,
|
|
9
|
+
kind: 'command',
|
|
10
|
+
type,
|
|
11
|
+
requestId: identity.requestId,
|
|
12
|
+
serverInstanceId: identity.serverInstanceId,
|
|
13
|
+
sessionEpoch: identity.sessionEpoch,
|
|
14
|
+
occurredAt: isoNow(identity.occurredAtMs),
|
|
15
|
+
payload
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export function buildAccountLogoutBody(identity, input) {
|
|
19
|
+
return envelope('account:logout', identity, {
|
|
20
|
+
expectedRevision: input.expectedRevision,
|
|
21
|
+
...(input.reasonId !== undefined ? { reasonId: input.reasonId } : {})
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=account-logout-wire.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account-logout-wire.js","sourceRoot":"","sources":["../../src/internal/account-logout-wire.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAEhE,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AASxC,SAAS,QAAQ,CACf,IAAY,EACZ,QAAsB,EACtB,OAA0C;IAE1C,OAAO,IAAI,CAAC,SAAS,CAAC;QACpB,eAAe,EAAE,cAAc;QAC/B,IAAI,EAAE,SAAS;QACf,IAAI;QACJ,SAAS,EAAE,QAAQ,CAAC,SAAS;QAC7B,gBAAgB,EAAE,QAAQ,CAAC,gBAAgB;QAC3C,YAAY,EAAE,QAAQ,CAAC,YAAY;QACnC,UAAU,EAAE,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC;QACzC,OAAO;KACR,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,sBAAsB,CACpC,QAAsB,EACtB,KAGC;IAED,OAAO,QAAQ,CAAC,gBAAgB,EAAE,QAAQ,EAAE;QAC1C,gBAAgB,EAAE,KAAK,CAAC,gBAAgB;QACxC,GAAG,CAAC,KAAK,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACtE,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server-authoritative capability grant parsing (fail closed).
|
|
3
|
+
*/
|
|
4
|
+
import { type CapabilityId } from '@softomnitel/omnicall-protocol';
|
|
5
|
+
export declare function parseGrantedCapabilities(values: readonly string[]): readonly CapabilityId[] | undefined;
|
|
6
|
+
//# sourceMappingURL=auth-grants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-grants.d.ts","sourceRoot":"","sources":["../../src/internal/auth-grants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAEvF,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,SAAS,MAAM,EAAE,GACxB,SAAS,YAAY,EAAE,GAAG,SAAS,CAUrC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server-authoritative capability grant parsing (fail closed).
|
|
3
|
+
*/
|
|
4
|
+
import { CapabilityIdSchema } from '@softomnitel/omnicall-protocol';
|
|
5
|
+
export function parseGrantedCapabilities(values) {
|
|
6
|
+
const out = [];
|
|
7
|
+
for (const value of values) {
|
|
8
|
+
const parsed = CapabilityIdSchema.safeParse(value);
|
|
9
|
+
if (!parsed.success) {
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
out.push(parsed.data);
|
|
13
|
+
}
|
|
14
|
+
return out;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=auth-grants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-grants.js","sourceRoot":"","sources":["../../src/internal/auth-grants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,kBAAkB,EAAqB,MAAM,gCAAgC,CAAC;AAEvF,MAAM,UAAU,wBAAwB,CACtC,MAAyB;IAEzB,MAAM,GAAG,GAAmB,EAAE,CAAC;IAC/B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,MAAM,GAAG,kBAAkB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACnD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse inbound auth/handshake/pairing/control messages (unknown → schema).
|
|
3
|
+
*/
|
|
4
|
+
import { type AuthChallenge, type PairingApproved, type PairingDenied, type PairingPending, type ServerHello } from '@softomnitel/omnicall-protocol';
|
|
5
|
+
export type InboundAuthMessage = {
|
|
6
|
+
readonly kind: 'server_hello';
|
|
7
|
+
readonly message: ServerHello;
|
|
8
|
+
} | {
|
|
9
|
+
readonly kind: 'incompatible';
|
|
10
|
+
} | {
|
|
11
|
+
readonly kind: 'pairing_pending';
|
|
12
|
+
readonly message: PairingPending;
|
|
13
|
+
} | {
|
|
14
|
+
readonly kind: 'pairing_approved';
|
|
15
|
+
readonly message: PairingApproved;
|
|
16
|
+
} | {
|
|
17
|
+
readonly kind: 'pairing_denied';
|
|
18
|
+
readonly message: PairingDenied;
|
|
19
|
+
} | {
|
|
20
|
+
readonly kind: 'permission_changed';
|
|
21
|
+
readonly grantedCapabilities: readonly string[];
|
|
22
|
+
} | {
|
|
23
|
+
readonly kind: 'revoked';
|
|
24
|
+
readonly reasonCode: string;
|
|
25
|
+
} | {
|
|
26
|
+
readonly kind: 'origin_denied';
|
|
27
|
+
} | {
|
|
28
|
+
readonly kind: 'preauth_product';
|
|
29
|
+
readonly type: string;
|
|
30
|
+
} | {
|
|
31
|
+
readonly kind: 'ignored';
|
|
32
|
+
};
|
|
33
|
+
export declare function parseInboundAuthMessage(raw: string): InboundAuthMessage;
|
|
34
|
+
export declare function challengeFromHello(hello: ServerHello): AuthChallenge | undefined;
|
|
35
|
+
//# sourceMappingURL=auth-inbound.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-inbound.d.ts","sourceRoot":"","sources":["../../src/internal/auth-inbound.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EASL,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,WAAW,EACjB,MAAM,gCAAgC,CAAC;AAIxC,MAAM,MAAM,kBAAkB,GAC1B;IAAE,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAA;CAAE,GAChE;IAAE,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAA;CAAE,GACjC;IAAE,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAA;CAAE,GACtE;IAAE,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAA;CAAE,GACxE;IAAE,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAA;CAAE,GACpE;IAAE,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAAC;IAAC,QAAQ,CAAC,mBAAmB,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GACxF;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GACzD;IAAE,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAA;CAAE,GAClC;IAAE,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC3D;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC;AAEjC,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,kBAAkB,CA6EvE;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,WAAW,GAAG,aAAa,GAAG,SAAS,CAEhF"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse inbound auth/handshake/pairing/control messages (unknown → schema).
|
|
3
|
+
*/
|
|
4
|
+
import { EventMessageSchema, PairingApprovedSchema, PairingDeniedSchema, PairingPendingSchema, ReplyMessageSchema, ServerHelloSchema, SnapshotMessageSchema, validateWithSchema } from '@softomnitel/omnicall-protocol';
|
|
5
|
+
import { isOriginDeniedWireDetails } from './origin-policy-errors.js';
|
|
6
|
+
export function parseInboundAuthMessage(raw) {
|
|
7
|
+
let parsed;
|
|
8
|
+
try {
|
|
9
|
+
parsed = JSON.parse(raw);
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return { kind: 'ignored' };
|
|
13
|
+
}
|
|
14
|
+
if (typeof parsed !== 'object' || parsed === null) {
|
|
15
|
+
return { kind: 'ignored' };
|
|
16
|
+
}
|
|
17
|
+
const type = 'type' in parsed ? parsed.type : undefined;
|
|
18
|
+
const kind = 'kind' in parsed ? parsed.kind : undefined;
|
|
19
|
+
if (kind === 'reply') {
|
|
20
|
+
const reply = validateWithSchema(ReplyMessageSchema, parsed);
|
|
21
|
+
if (reply.success &&
|
|
22
|
+
!reply.data.ok &&
|
|
23
|
+
reply.data.error.code === 'forbidden' &&
|
|
24
|
+
isOriginDeniedWireDetails(reply.data.error.details)) {
|
|
25
|
+
return { kind: 'origin_denied' };
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (type === 'sdk:server-hello') {
|
|
29
|
+
const result = validateWithSchema(ServerHelloSchema, parsed);
|
|
30
|
+
if (result.success) {
|
|
31
|
+
return { kind: 'server_hello', message: result.data };
|
|
32
|
+
}
|
|
33
|
+
if (result.code === 'incompatible_version') {
|
|
34
|
+
return { kind: 'incompatible' };
|
|
35
|
+
}
|
|
36
|
+
return { kind: 'ignored' };
|
|
37
|
+
}
|
|
38
|
+
if (type === 'pairing:pending') {
|
|
39
|
+
const result = validateWithSchema(PairingPendingSchema, parsed);
|
|
40
|
+
return result.success
|
|
41
|
+
? { kind: 'pairing_pending', message: result.data }
|
|
42
|
+
: { kind: 'ignored' };
|
|
43
|
+
}
|
|
44
|
+
if (type === 'pairing:approved') {
|
|
45
|
+
const result = validateWithSchema(PairingApprovedSchema, parsed);
|
|
46
|
+
return result.success
|
|
47
|
+
? { kind: 'pairing_approved', message: result.data }
|
|
48
|
+
: { kind: 'ignored' };
|
|
49
|
+
}
|
|
50
|
+
if (type === 'pairing:denied') {
|
|
51
|
+
const result = validateWithSchema(PairingDeniedSchema, parsed);
|
|
52
|
+
return result.success
|
|
53
|
+
? { kind: 'pairing_denied', message: result.data }
|
|
54
|
+
: { kind: 'ignored' };
|
|
55
|
+
}
|
|
56
|
+
if (type === 'sdk:permission-changed') {
|
|
57
|
+
const result = validateWithSchema(EventMessageSchema, parsed);
|
|
58
|
+
if (!result.success || result.data.type !== 'sdk:permission-changed') {
|
|
59
|
+
return { kind: 'ignored' };
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
kind: 'permission_changed',
|
|
63
|
+
grantedCapabilities: result.data.payload.grantedCapabilities
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
if (type === 'sdk:revoked') {
|
|
67
|
+
const result = validateWithSchema(EventMessageSchema, parsed);
|
|
68
|
+
if (!result.success || result.data.type !== 'sdk:revoked') {
|
|
69
|
+
return { kind: 'ignored' };
|
|
70
|
+
}
|
|
71
|
+
return { kind: 'revoked', reasonCode: result.data.payload.reasonCode };
|
|
72
|
+
}
|
|
73
|
+
const snapshot = validateWithSchema(SnapshotMessageSchema, parsed);
|
|
74
|
+
if (snapshot.success) {
|
|
75
|
+
return { kind: 'preauth_product', type: 'snapshot' };
|
|
76
|
+
}
|
|
77
|
+
const event = validateWithSchema(EventMessageSchema, parsed);
|
|
78
|
+
if (event.success) {
|
|
79
|
+
return { kind: 'preauth_product', type: event.data.type };
|
|
80
|
+
}
|
|
81
|
+
return { kind: 'ignored' };
|
|
82
|
+
}
|
|
83
|
+
export function challengeFromHello(hello) {
|
|
84
|
+
return hello.authChallenge;
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=auth-inbound.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-inbound.js","sourceRoot":"","sources":["../../src/internal/auth-inbound.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,EAMnB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AActE,MAAM,UAAU,uBAAuB,CAAC,GAAW;IACjD,IAAI,MAAe,CAAC;IACpB,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAY,CAAC;IACtC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;IAC7B,CAAC;IACD,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QAClD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;IAC7B,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,IAAI,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CA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1D,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;QAC7B,CAAC;QACD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;IACzE,CAAC;IACD,MAAM,QAAQ,GAAG,kBAAkB,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;IACnE,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;QACrB,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;IACvD,CAAC;IACD,MAAM,KAAK,GAAG,kBAAkB,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;IAC7D,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;QAClB,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IAC5D,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,KAAkB;IACnD,OAAO,KAAK,CAAC,aAAa,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pairing + PoP orchestration composed onto ConnectionSession.
|
|
3
|
+
*/
|
|
4
|
+
import { type ApplicationIdentity, type CapabilityId, type PairingProfile } from '@softomnitel/omnicall-protocol';
|
|
5
|
+
import type { ConnectionSession } from './connection-session.js';
|
|
6
|
+
import type { DiagnosticsSink } from './diagnostics.js';
|
|
7
|
+
import type { PopKeyStore } from './pop-key-store.js';
|
|
8
|
+
import type { SessionIdentity } from './session-identity.js';
|
|
9
|
+
import type { Scheduler } from './scheduler.js';
|
|
10
|
+
export type AuthOrchestratorDeps = {
|
|
11
|
+
readonly connection: ConnectionSession;
|
|
12
|
+
readonly origin: string;
|
|
13
|
+
readonly application: ApplicationIdentity;
|
|
14
|
+
readonly sdkVersion: string;
|
|
15
|
+
readonly requestedProfile: PairingProfile;
|
|
16
|
+
readonly requestedCapabilities: readonly CapabilityId[];
|
|
17
|
+
readonly keyStore: PopKeyStore;
|
|
18
|
+
readonly scheduler: Scheduler;
|
|
19
|
+
readonly diagnostics?: DiagnosticsSink;
|
|
20
|
+
readonly onPairingRequired: (info: {
|
|
21
|
+
readonly origin: string;
|
|
22
|
+
readonly requestedProfile: PairingProfile;
|
|
23
|
+
readonly clientId: string | undefined;
|
|
24
|
+
}) => void;
|
|
25
|
+
};
|
|
26
|
+
export type AuthOrchestrator = {
|
|
27
|
+
readonly getSession: () => SessionIdentity | undefined;
|
|
28
|
+
readonly getGrantedCapabilities: () => readonly CapabilityId[];
|
|
29
|
+
readonly preauthDropCount: () => number;
|
|
30
|
+
readonly prepareConnect: () => Promise<void>;
|
|
31
|
+
readonly onHandshaking: () => void;
|
|
32
|
+
readonly onUnhandledMessage: (raw: string) => void;
|
|
33
|
+
readonly clearSession: () => void;
|
|
34
|
+
};
|
|
35
|
+
export declare function createAuthOrchestrator(deps: AuthOrchestratorDeps): AuthOrchestrator;
|
|
36
|
+
//# sourceMappingURL=auth-orchestrator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-orchestrator.d.ts","sourceRoot":"","sources":["../../src/internal/auth-orchestrator.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAGL,KAAK,mBAAmB,EACxB,KAAK,YAAY,EACjB,KAAK,cAAc,EAEpB,MAAM,gCAAgC,CAAC;AAMxC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGxD,OAAO,KAAK,EAAE,WAAW,EAAqB,MAAM,oBAAoB,CAAC;AAEzE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,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