@hainiva/agent-sdk 0.0.0-stage → 0.3.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/CHANGELOG.md +73 -0
- package/LICENSE +21 -0
- package/README.md +278 -2
- package/SECURITY.md +33 -0
- package/dist/cjs/agent.cjs +320 -0
- package/dist/cjs/agent.d.cts +239 -0
- package/dist/cjs/calls.cjs +277 -0
- package/dist/cjs/calls.d.cts +232 -0
- package/dist/cjs/contract.cjs +14 -0
- package/dist/cjs/contract.d.cts +225 -0
- package/dist/cjs/embed.cjs +253 -0
- package/dist/cjs/embed.d.cts +187 -0
- package/dist/cjs/emitter.cjs +50 -0
- package/dist/cjs/emitter.d.cts +22 -0
- package/dist/cjs/errors.cjs +28 -0
- package/dist/cjs/errors.d.cts +15 -0
- package/dist/cjs/events.cjs +97 -0
- package/dist/cjs/events.d.cts +97 -0
- package/dist/cjs/index.cjs +72 -0
- package/dist/cjs/index.d.cts +28 -0
- package/dist/cjs/livekit.cjs +56 -0
- package/dist/cjs/livekit.d.cts +35 -0
- package/dist/cjs/log.cjs +15 -0
- package/dist/cjs/log.d.cts +5 -0
- package/dist/cjs/react-native.cjs +32 -0
- package/dist/cjs/react-native.d.cts +39 -0
- package/dist/cjs/reactNativeDesk.cjs +107 -0
- package/dist/cjs/reactNativeDesk.d.cts +53 -0
- package/dist/cjs/redact.cjs +71 -0
- package/dist/cjs/redact.d.cts +21 -0
- package/dist/cjs/rest.cjs +286 -0
- package/dist/cjs/rest.d.cts +172 -0
- package/dist/cjs/session.cjs +159 -0
- package/dist/cjs/session.d.cts +101 -0
- package/dist/cjs/singleFlight.cjs +49 -0
- package/dist/cjs/singleFlight.d.cts +32 -0
- package/dist/cjs/url.cjs +39 -0
- package/dist/cjs/url.d.cts +13 -0
- package/dist/cjs/web.cjs +28 -0
- package/dist/cjs/web.d.cts +23 -0
- package/dist/cjs/ws.cjs +246 -0
- package/dist/cjs/ws.d.cts +134 -0
- package/dist/esm/agent.d.ts +240 -0
- package/dist/esm/agent.d.ts.map +1 -0
- package/dist/esm/agent.js +317 -0
- package/dist/esm/agent.js.map +1 -0
- package/dist/esm/calls.d.ts +233 -0
- package/dist/esm/calls.d.ts.map +1 -0
- package/dist/esm/calls.js +271 -0
- package/dist/esm/calls.js.map +1 -0
- package/dist/esm/contract.d.ts +226 -0
- package/dist/esm/contract.d.ts.map +1 -0
- package/dist/esm/contract.js +12 -0
- package/dist/esm/contract.js.map +1 -0
- package/dist/esm/embed.d.ts +188 -0
- package/dist/esm/embed.d.ts.map +1 -0
- package/dist/esm/embed.js +247 -0
- package/dist/esm/embed.js.map +1 -0
- package/dist/esm/emitter.d.ts +23 -0
- package/dist/esm/emitter.d.ts.map +1 -0
- package/dist/esm/emitter.js +47 -0
- package/dist/esm/emitter.js.map +1 -0
- package/dist/esm/errors.d.ts +16 -0
- package/dist/esm/errors.d.ts.map +1 -0
- package/dist/esm/errors.js +25 -0
- package/dist/esm/errors.js.map +1 -0
- package/dist/esm/events.d.ts +98 -0
- package/dist/esm/events.d.ts.map +1 -0
- package/dist/esm/events.js +90 -0
- package/dist/esm/events.js.map +1 -0
- package/dist/esm/index.d.ts +29 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +29 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/livekit.d.ts +36 -0
- package/dist/esm/livekit.d.ts.map +1 -0
- package/dist/esm/livekit.js +54 -0
- package/dist/esm/livekit.js.map +1 -0
- package/dist/esm/log.d.ts +6 -0
- package/dist/esm/log.d.ts.map +1 -0
- package/dist/esm/log.js +13 -0
- package/dist/esm/log.js.map +1 -0
- package/dist/esm/react-native.d.ts +40 -0
- package/dist/esm/react-native.d.ts.map +1 -0
- package/dist/esm/react-native.js +26 -0
- package/dist/esm/react-native.js.map +1 -0
- package/dist/esm/reactNativeDesk.d.ts +54 -0
- package/dist/esm/reactNativeDesk.d.ts.map +1 -0
- package/dist/esm/reactNativeDesk.js +103 -0
- package/dist/esm/reactNativeDesk.js.map +1 -0
- package/dist/esm/redact.d.ts +22 -0
- package/dist/esm/redact.d.ts.map +1 -0
- package/dist/esm/redact.js +66 -0
- package/dist/esm/redact.js.map +1 -0
- package/dist/esm/rest.d.ts +173 -0
- package/dist/esm/rest.d.ts.map +1 -0
- package/dist/esm/rest.js +281 -0
- package/dist/esm/rest.js.map +1 -0
- package/dist/esm/session.d.ts +102 -0
- package/dist/esm/session.d.ts.map +1 -0
- package/dist/esm/session.js +155 -0
- package/dist/esm/session.js.map +1 -0
- package/dist/esm/singleFlight.d.ts +33 -0
- package/dist/esm/singleFlight.d.ts.map +1 -0
- package/dist/esm/singleFlight.js +46 -0
- package/dist/esm/singleFlight.js.map +1 -0
- package/dist/esm/url.d.ts +14 -0
- package/dist/esm/url.d.ts.map +1 -0
- package/dist/esm/url.js +37 -0
- package/dist/esm/url.js.map +1 -0
- package/dist/esm/web.d.ts +24 -0
- package/dist/esm/web.d.ts.map +1 -0
- package/dist/esm/web.js +23 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/esm/ws.d.ts +135 -0
- package/dist/esm/ws.d.ts.map +1 -0
- package/dist/esm/ws.js +242 -0
- package/dist/esm/ws.js.map +1 -0
- package/package.json +117 -4
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `/agent/v1/ws` protocol (v1) as ReconnectingSocket options, and the
|
|
3
|
+
* mapping of its events to the SDK's typed events and to the call state machine.
|
|
4
|
+
*
|
|
5
|
+
* client → auth {token, lastSeq?} FIRST frame (the token never rides in the URL)
|
|
6
|
+
* → token.refresh {token, id} swap in a refreshed access token
|
|
7
|
+
* → ping
|
|
8
|
+
* server → ready {seq, expiresAt}
|
|
9
|
+
* → event {seq, event, data, at}
|
|
10
|
+
* → resync_required {fromSeq} events after your lastSeq are gone: refetch over REST
|
|
11
|
+
* → ack {id, ok, error?} · session.expiring {expiresAt} · pong · error {code}
|
|
12
|
+
* close 4001 token refused/expired (refresh, reconnect) · 4003 revoked (stop)
|
|
13
|
+
* 4008 auth timeout · 4029 rate limited (reconnect with backoff)
|
|
14
|
+
* 4009 too many sockets · 1003 binary frame (stop: retrying cannot fix them)
|
|
15
|
+
*
|
|
16
|
+
* The resume position travels in the auth frame, so the server replays from it
|
|
17
|
+
* atomically with authentication (no window in which a live event overtakes
|
|
18
|
+
* the replay).
|
|
19
|
+
*/
|
|
20
|
+
import type { CallEvent, CallInfo, CallsState } from "./calls.js";
|
|
21
|
+
import type { AgentEventName } from "./contract.js";
|
|
22
|
+
import type { SocketOptions } from "./ws.js";
|
|
23
|
+
export type { AgentEventName } from "./contract.js";
|
|
24
|
+
/** One event frame from the server. */
|
|
25
|
+
export interface AgentEventFrame<D = Record<string, unknown>> {
|
|
26
|
+
v?: number;
|
|
27
|
+
type: "event";
|
|
28
|
+
event: AgentEventName;
|
|
29
|
+
seq: number;
|
|
30
|
+
at: string;
|
|
31
|
+
data: D;
|
|
32
|
+
}
|
|
33
|
+
/** Any frame from the server. */
|
|
34
|
+
export type AgentServerFrame = AgentEventFrame | {
|
|
35
|
+
v?: number;
|
|
36
|
+
type: "ready";
|
|
37
|
+
seq: number;
|
|
38
|
+
expiresAt?: string;
|
|
39
|
+
protocol?: number;
|
|
40
|
+
} | {
|
|
41
|
+
v?: number;
|
|
42
|
+
type: "resync_required";
|
|
43
|
+
fromSeq: number;
|
|
44
|
+
} | {
|
|
45
|
+
v?: number;
|
|
46
|
+
type: "ack";
|
|
47
|
+
id: string;
|
|
48
|
+
ok: boolean;
|
|
49
|
+
error?: string;
|
|
50
|
+
expiresAt?: string;
|
|
51
|
+
} | {
|
|
52
|
+
v?: number;
|
|
53
|
+
type: "session.expiring";
|
|
54
|
+
expiresAt: string;
|
|
55
|
+
} | {
|
|
56
|
+
v?: number;
|
|
57
|
+
type: "pong";
|
|
58
|
+
} | {
|
|
59
|
+
v?: number;
|
|
60
|
+
type: "error";
|
|
61
|
+
code?: string;
|
|
62
|
+
};
|
|
63
|
+
export type AgentClientFrame = {
|
|
64
|
+
type: "auth";
|
|
65
|
+
token: string;
|
|
66
|
+
lastSeq?: number;
|
|
67
|
+
} | {
|
|
68
|
+
type: "token.refresh";
|
|
69
|
+
token: string;
|
|
70
|
+
id: string;
|
|
71
|
+
} | {
|
|
72
|
+
type: "resume";
|
|
73
|
+
lastSeq: number;
|
|
74
|
+
id?: string;
|
|
75
|
+
} | {
|
|
76
|
+
type: "ping";
|
|
77
|
+
};
|
|
78
|
+
export declare const AGENT_CLOSE_CODES: {
|
|
79
|
+
readonly tokenExpired: 4001;
|
|
80
|
+
readonly revoked: 4003;
|
|
81
|
+
readonly authTimeout: 4008;
|
|
82
|
+
readonly tooManySockets: 4009;
|
|
83
|
+
readonly rateLimited: 4029;
|
|
84
|
+
};
|
|
85
|
+
/** The protocol as ReconnectingSocket options. `lastSeq()` is read when the auth frame is built. */
|
|
86
|
+
export declare function agentSocketBindings(lastSeq: () => number): Pick<SocketOptions<AgentServerFrame, AgentClientFrame>, "authFrame" | "isReady" | "resume" | "seqOf" | "tokenFrame" | "closeCodes" | "heartbeat">;
|
|
87
|
+
/** Is this a well-formed event frame with a name this SDK knows? Unknown names are passed on as `event.unknown`. */
|
|
88
|
+
export declare function isEventFrame(f: unknown): f is AgentEventFrame;
|
|
89
|
+
export declare const isKnownEvent: (name: string) => name is AgentEventName;
|
|
90
|
+
/** Pure: call.ringing data → the state machine's CallInfo (null when malformed). */
|
|
91
|
+
export declare function ringInfo(d: Record<string, unknown>, now: number, defaultRingMs: number): CallInfo | null;
|
|
92
|
+
/**
|
|
93
|
+
* Pure: an event → the state-machine events it causes (empty when it is not
|
|
94
|
+
* about calls this device knows). `state` resolves a call.ended that names only
|
|
95
|
+
* the conversation.
|
|
96
|
+
*/
|
|
97
|
+
export declare function toCallEvents(frame: AgentEventFrame, state: CallsState, now: number, defaultRingMs?: number): CallEvent[];
|
|
98
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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AAQ,GAAG,IAAI,CAmBxG;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,EAAE,aAAa,SAAS,GAAG,SAAS,EAAE,CA2BxH"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { AGENT_EVENT_NAMES } from "./contract.js";
|
|
2
|
+
export const AGENT_CLOSE_CODES = { tokenExpired: 4001, revoked: 4003, authTimeout: 4008, tooManySockets: 4009, rateLimited: 4029 };
|
|
3
|
+
let tokenFrameSeq = 0;
|
|
4
|
+
/** The protocol as ReconnectingSocket options. `lastSeq()` is read when the auth frame is built. */
|
|
5
|
+
export function agentSocketBindings(lastSeq) {
|
|
6
|
+
return {
|
|
7
|
+
authFrame: (token) => {
|
|
8
|
+
const s = lastSeq();
|
|
9
|
+
return s > 0 ? { type: "auth", token, lastSeq: s } : { type: "auth", token };
|
|
10
|
+
},
|
|
11
|
+
isReady: (f) => f?.type === "ready",
|
|
12
|
+
// Resume rides in the auth frame (above): no separate frame after ready.
|
|
13
|
+
resume: () => null,
|
|
14
|
+
seqOf: (f) => (f?.type === "event" && typeof f.seq === "number" && Number.isInteger(f.seq) ? f.seq : undefined),
|
|
15
|
+
tokenFrame: (token) => ({ type: "token.refresh", token, id: `t${++tokenFrameSeq}` }),
|
|
16
|
+
closeCodes: { tokenExpired: AGENT_CLOSE_CODES.tokenExpired, revoked: AGENT_CLOSE_CODES.revoked, fatal: [AGENT_CLOSE_CODES.tooManySockets, 1003] },
|
|
17
|
+
// The server closes a socket that sends more than 120 frames a minute; 20 s is 3.
|
|
18
|
+
heartbeat: { intervalMs: 20000, timeoutMs: 60000, frame: () => ({ type: "ping" }) },
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/** Is this a well-formed event frame with a name this SDK knows? Unknown names are passed on as `event.unknown`. */
|
|
22
|
+
export function isEventFrame(f) {
|
|
23
|
+
const x = f;
|
|
24
|
+
return !!x && x["type"] === "event" && typeof x["event"] === "string" && typeof x["seq"] === "number"
|
|
25
|
+
&& !!x["data"] && typeof x["data"] === "object" && !Array.isArray(x["data"]);
|
|
26
|
+
}
|
|
27
|
+
export const isKnownEvent = (name) => AGENT_EVENT_NAMES.includes(name);
|
|
28
|
+
const str = (v) => (typeof v === "string" && v ? v : null);
|
|
29
|
+
/** Pure: call.ringing data → the state machine's CallInfo (null when malformed). */
|
|
30
|
+
export function ringInfo(d, now, defaultRingMs) {
|
|
31
|
+
const r = d;
|
|
32
|
+
const callId = str(r.callId);
|
|
33
|
+
if (!callId)
|
|
34
|
+
return null;
|
|
35
|
+
const path = r.path === "direct" || r.path === "queue" || r.path === "transfer" ? r.path : "queue";
|
|
36
|
+
const exp = str(r.expiresAt) ? Date.parse(r.expiresAt) : NaN;
|
|
37
|
+
const conversationId = str(r.conversationId);
|
|
38
|
+
const line = str(r.line);
|
|
39
|
+
return {
|
|
40
|
+
id: callId,
|
|
41
|
+
...(conversationId ? { conversationId } : {}),
|
|
42
|
+
direction: "inbound",
|
|
43
|
+
path,
|
|
44
|
+
from: str(r.contactName) ?? str(r.callerNumber) ?? str(r.fromAgentName) ?? "",
|
|
45
|
+
...(line ? { line } : {}),
|
|
46
|
+
// A ring without an end the server knows still ends: a lost cancel must not leave a ghost ring.
|
|
47
|
+
expiresAt: Number.isFinite(exp) ? exp : now + defaultRingMs,
|
|
48
|
+
...(path === "transfer" ? { transfer: { mode: r.transferMode === "blind" ? "blind" : "warm" } } : {}),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Pure: an event → the state-machine events it causes (empty when it is not
|
|
53
|
+
* about calls this device knows). `state` resolves a call.ended that names only
|
|
54
|
+
* the conversation.
|
|
55
|
+
*/
|
|
56
|
+
export function toCallEvents(frame, state, now, defaultRingMs = 60000) {
|
|
57
|
+
if (frame.event === "call.ringing") {
|
|
58
|
+
const call = ringInfo(frame.data, now, defaultRingMs);
|
|
59
|
+
return call ? [{ type: "ring", call, at: now }] : [];
|
|
60
|
+
}
|
|
61
|
+
if (frame.event !== "call.ended")
|
|
62
|
+
return [];
|
|
63
|
+
const d = frame.data;
|
|
64
|
+
const ids = [];
|
|
65
|
+
const callId = str(d.callId);
|
|
66
|
+
if (callId)
|
|
67
|
+
ids.push(callId);
|
|
68
|
+
else if (str(d.conversationId)) {
|
|
69
|
+
for (const c of Object.values(state.calls))
|
|
70
|
+
if (c.info.conversationId === d.conversationId && c.phase !== "ended")
|
|
71
|
+
ids.push(c.info.id);
|
|
72
|
+
}
|
|
73
|
+
const out = [];
|
|
74
|
+
for (const id of ids) {
|
|
75
|
+
const c = state.calls[id];
|
|
76
|
+
if (!c || c.phase === "ended")
|
|
77
|
+
continue;
|
|
78
|
+
if (c.phase === "ringing" || c.phase === "connecting") {
|
|
79
|
+
const reason = d.reason === "answered_elsewhere" ? "answered_elsewhere"
|
|
80
|
+
: d.reason === "ended" || d.reason === "failed" ? "remote_ended" : "cancelled";
|
|
81
|
+
out.push({ type: "ring_cancelled", id, reason, at: now });
|
|
82
|
+
}
|
|
83
|
+
else if (d.reason !== "answered_elsewhere") {
|
|
84
|
+
// On the call: the caller hung up, the server ended it, or a blind transfer handed it over.
|
|
85
|
+
out.push({ type: "remote_end", id, at: now });
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return out;
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/events.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AA+BlD,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAW,CAAC;AAE5I,IAAI,aA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KAAK,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,WAAW,CAAC;YACjF,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;QAC5D,CAAC;aAAM,IAAI,CAAC,CAAC,MAAM,KAAK,oBAAoB,EAAE,CAAC;YAC7C,4FAA4F;YAC5F,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @hainiva/agent-sdk — build your own agent app on HAINIVA AICC: staff sign-in
|
|
3
|
+
* with your backend's assertion, the live event stream, and calls.
|
|
4
|
+
*
|
|
5
|
+
* Entry points:
|
|
6
|
+
* "@hainiva/agent-sdk" transport-agnostic core (this file) — no LiveKit, no DOM, no React Native
|
|
7
|
+
* "@hainiva/agent-sdk/web" localStorage store (opt-in), LiveKit call media
|
|
8
|
+
* "@hainiva/agent-sdk/react-native" secure-store session, LiveKit call media, <HainivaDesk/>
|
|
9
|
+
* "@hainiva/agent-sdk/embed" mountDesk(): the HAINIVA desk in your web page (iframe)
|
|
10
|
+
*
|
|
11
|
+
* Start with HainivaAgent (./agent): it wires the session, the REST client,
|
|
12
|
+
* the event socket and the call state machine together. The parts are exported
|
|
13
|
+
* too, for apps that want their own wiring.
|
|
14
|
+
*/
|
|
15
|
+
export declare const SDK_VERSION = "0.3.0";
|
|
16
|
+
export { HainivaAgentError } from "./errors.js";
|
|
17
|
+
export { Redactor, redactString, redactValue } from "./redact.js";
|
|
18
|
+
export { safeLogger, type Logger } from "./log.js";
|
|
19
|
+
export { assertSafeUrl, type UrlRules } from "./url.js";
|
|
20
|
+
export { TypedEmitter } from "./emitter.js";
|
|
21
|
+
export { singleFlight, createTokenRefresher, type RefreshedToken, type TokenRefresher, type TokenRefresherOptions } from "./singleFlight.js";
|
|
22
|
+
export { SessionManager, memoryStore, type AgentSession, type GetAssertion, type SessionEvents, type SessionManagerOptions, type SessionStore, type SessionTransport, } from "./session.js";
|
|
23
|
+
export { ReconnectingSocket, backoffDelay, type ConnectionState, type SocketEvents, type SocketOptions, type WebSocketCtor, type WebSocketLike, } from "./ws.js";
|
|
24
|
+
export { CallStore, transition, activeCall, ringingCalls, initialCallsState, type Call, type CallDirection, type CallEffect, type CallEvent, type CallInfo, type CallPath, type CallPhase, type CallsState, type CallStoreEvents, type CallStoreOptions, type EndReason, type Transition, type TransferState, type TransferTarget, } from "./calls.js";
|
|
25
|
+
export { HainivaAgent, type HainivaAgentEvents, type HainivaAgentOptions, type JoinMedia, type MediaSession } from "./agent.js";
|
|
26
|
+
export { AgentRestClient, errorFromResponse, newIdempotencyKey, type AgentRestOptions, type AgentStatus, type CallTransferTarget, type ConversationListQuery, type MediaCredentials, type RequestOptions, type TokenSource, } from "./rest.js";
|
|
27
|
+
export { AGENT_CLOSE_CODES, agentSocketBindings, isEventFrame, ringInfo, toCallEvents, type AgentClientFrame, type AgentEventFrame, type AgentServerFrame, } from "./events.js";
|
|
28
|
+
export * from "./contract.js";
|
|
29
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,eAAO,MAAM,WAAW,UAAU,CAAC;AAEnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,KAAK,MAAM,EAAE,MAAM,UAAU,CAAC;AACnD,OAAO,EAAE,aAAa,EA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;AACnB,OAAO,EACL,iBAAiB,EAAE,mBAAmB,EAAE,YAAY,EAAE,QAAQ,EAAE,YAAY,EAC5E,KAAK,gBAAgB,EAAE,KAAK,eAAe,EAAE,KAAK,gBAAgB,GACnE,MAAM,aAAa,CAAC;AACrB,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @hainiva/agent-sdk — build your own agent app on HAINIVA AICC: staff sign-in
|
|
3
|
+
* with your backend's assertion, the live event stream, and calls.
|
|
4
|
+
*
|
|
5
|
+
* Entry points:
|
|
6
|
+
* "@hainiva/agent-sdk" transport-agnostic core (this file) — no LiveKit, no DOM, no React Native
|
|
7
|
+
* "@hainiva/agent-sdk/web" localStorage store (opt-in), LiveKit call media
|
|
8
|
+
* "@hainiva/agent-sdk/react-native" secure-store session, LiveKit call media, <HainivaDesk/>
|
|
9
|
+
* "@hainiva/agent-sdk/embed" mountDesk(): the HAINIVA desk in your web page (iframe)
|
|
10
|
+
*
|
|
11
|
+
* Start with HainivaAgent (./agent): it wires the session, the REST client,
|
|
12
|
+
* the event socket and the call state machine together. The parts are exported
|
|
13
|
+
* too, for apps that want their own wiring.
|
|
14
|
+
*/
|
|
15
|
+
export const SDK_VERSION = "0.3.0";
|
|
16
|
+
export { HainivaAgentError } from "./errors.js";
|
|
17
|
+
export { Redactor, redactString, redactValue } from "./redact.js";
|
|
18
|
+
export { safeLogger } from "./log.js";
|
|
19
|
+
export { assertSafeUrl } from "./url.js";
|
|
20
|
+
export { TypedEmitter } from "./emitter.js";
|
|
21
|
+
export { singleFlight, createTokenRefresher } from "./singleFlight.js";
|
|
22
|
+
export { SessionManager, memoryStore, } from "./session.js";
|
|
23
|
+
export { ReconnectingSocket, backoffDelay, } from "./ws.js";
|
|
24
|
+
export { CallStore, transition, activeCall, ringingCalls, initialCallsState, } from "./calls.js";
|
|
25
|
+
export { HainivaAgent } from "./agent.js";
|
|
26
|
+
export { AgentRestClient, errorFromResponse, newIdempotencyKey, } from "./rest.js";
|
|
27
|
+
export { AGENT_CLOSE_CODES, agentSocketBindings, isEventFrame, ringInfo, toCallEvents, } from "./events.js";
|
|
28
|
+
export * from "./contract.js";
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC;AAEnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,UAAU,EAAe,MAAM,UAAU,CAAC;AACnD,OAAO,EAAE,aAAa,EAAiB,MAAM,UAAU,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAwE,MAAM,mBAAmB,CAAC;AAC7I,OAAO,EACL,cAAc,EAAE,WAAW,GAE5B,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,kBAAkB,EAAE,YAAY,GAEjC,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,iBAAiB,GAGnE,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,YAAY,EAAwF,MAAM,YAAY,CAAC;AAChI,OAAO,EACL,eAAe,EAAE,iBAAiB,EAAE,iBAAiB,GAEtD,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,iBAAiB,EAAE,mBAAmB,EAAE,YAAY,EAAE,QAAQ,EAAE,YAAY,GAE7E,MAAM,aAAa,CAAC;AACrB,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Joining a call's LiveKit room. Used by the /web and /react-native entry points
|
|
3
|
+
* only: `livekit-client` is a peer dependency, and the core never imports it.
|
|
4
|
+
*/
|
|
5
|
+
import { Room, type RoomConnectOptions, type RoomOptions } from "livekit-client";
|
|
6
|
+
import { Redactor } from "./redact.js";
|
|
7
|
+
export interface MediaJoin {
|
|
8
|
+
/** wss:// LiveKit URL. */
|
|
9
|
+
url: string;
|
|
10
|
+
/** Room token for this call — kept out of every error. */
|
|
11
|
+
token: string;
|
|
12
|
+
}
|
|
13
|
+
export interface JoinOptions {
|
|
14
|
+
/** Start with the microphone on. Default true. */
|
|
15
|
+
microphone?: boolean;
|
|
16
|
+
roomOptions?: RoomOptions;
|
|
17
|
+
connectOptions?: RoomConnectOptions;
|
|
18
|
+
/** ws://localhost in development. Default false. */
|
|
19
|
+
allowInsecureLocalhost?: boolean;
|
|
20
|
+
redactor?: Redactor;
|
|
21
|
+
}
|
|
22
|
+
export interface MediaCall {
|
|
23
|
+
readonly room: Room;
|
|
24
|
+
setMuted(muted: boolean): Promise<void>;
|
|
25
|
+
/** Leave the room (idempotent). */
|
|
26
|
+
leave(): Promise<void>;
|
|
27
|
+
/** The room closed (far end hung up, server ended it, network lost). Returns an unsubscribe. */
|
|
28
|
+
onDisconnected(fn: () => void): () => void;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Join with the call's media credentials, microphone on. The token is handed to
|
|
32
|
+
* LiveKit only; errors are redacted (LiveKit's own error text can contain its
|
|
33
|
+
* signalling URL, which carries the token).
|
|
34
|
+
*/
|
|
35
|
+
export declare function joinCallRoom(join: MediaJoin, o?: JoinOptions): Promise<MediaCall>;
|
|
36
|
+
//# sourceMappingURL=livekit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"livekit.d.ts","sourceRoot":"","sources":["../../src/livekit.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,IAAI,EAAa,KAAK,kBAAkB,EAAE,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG5F,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvC,MAAM,WAAW,SAAS;IACxB,0BAA0B;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,0DAA0D;IAC1D,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,WAAW;IAC1B,kDAAkD;IAClD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,cAAc,CAAC,EAAE,kBAAkB,CAAC;IACpC,oDAAoD;IACpD,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxC,mCAAmC;IACnC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,gGAAgG;IAChG,cAAc,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC;CAC5C;AAED;;;;GAIG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC,GAAE,WAAgB,GAAG,OAAO,CAAC,SAAS,CAAC,CA+B3F"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Joining a call's LiveKit room. Used by the /web and /react-native entry points
|
|
3
|
+
* only: `livekit-client` is a peer dependency, and the core never imports it.
|
|
4
|
+
*/
|
|
5
|
+
import { Room, RoomEvent } from "livekit-client";
|
|
6
|
+
import { HainivaAgentError } from "./errors.js";
|
|
7
|
+
import { Redactor } from "./redact.js";
|
|
8
|
+
import { assertSafeUrl } from "./url.js";
|
|
9
|
+
/**
|
|
10
|
+
* Join with the call's media credentials, microphone on. The token is handed to
|
|
11
|
+
* LiveKit only; errors are redacted (LiveKit's own error text can contain its
|
|
12
|
+
* signalling URL, which carries the token).
|
|
13
|
+
*/
|
|
14
|
+
export async function joinCallRoom(join, o = {}) {
|
|
15
|
+
const redactor = o.redactor ?? new Redactor();
|
|
16
|
+
redactor.add(join.token);
|
|
17
|
+
assertSafeUrl(join.url, { kind: "ws", ...(o.allowInsecureLocalhost ? { allowInsecureLocalhost: true } : {}) });
|
|
18
|
+
if (!join.token)
|
|
19
|
+
throw new HainivaAgentError(0, "no_media_token");
|
|
20
|
+
const room = new Room(o.roomOptions);
|
|
21
|
+
try {
|
|
22
|
+
await room.connect(join.url, join.token, { autoSubscribe: true, ...o.connectOptions });
|
|
23
|
+
if (o.microphone !== false)
|
|
24
|
+
await room.localParticipant.setMicrophoneEnabled(true);
|
|
25
|
+
}
|
|
26
|
+
catch (e) {
|
|
27
|
+
await room.disconnect().catch(() => undefined);
|
|
28
|
+
throw HainivaAgentError.from(e, "media_connect_failed", redactor);
|
|
29
|
+
}
|
|
30
|
+
let left = false;
|
|
31
|
+
return {
|
|
32
|
+
room,
|
|
33
|
+
async setMuted(muted) {
|
|
34
|
+
try {
|
|
35
|
+
await room.localParticipant.setMicrophoneEnabled(!muted);
|
|
36
|
+
}
|
|
37
|
+
catch (e) {
|
|
38
|
+
throw HainivaAgentError.from(e, "media_mute_failed", redactor);
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
async leave() {
|
|
42
|
+
if (left)
|
|
43
|
+
return;
|
|
44
|
+
left = true;
|
|
45
|
+
await room.disconnect().catch(() => undefined);
|
|
46
|
+
},
|
|
47
|
+
onDisconnected(fn) {
|
|
48
|
+
const h = () => fn();
|
|
49
|
+
room.on(RoomEvent.Disconnected, h);
|
|
50
|
+
return () => { room.off(RoomEvent.Disconnected, h); };
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=livekit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"livekit.js","sourceRoot":"","sources":["../../src/livekit.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EAAE,CAAC,SAAS,CAAC,CAAC;QAC/C,MAAM,iBAAiB,CAAC,IAAI,CAAC,CAAC,EAAE,sBAAsB,EAAE,QAAQ,CAAC,CAAC;IACpE,CAAC;IACD,IAAI,IAAI,GAAG,KAAK,CAAC;IACjB,OAAO;QACL,IAAI;QACJ,KAAK,CAAC,QAAQ,CAAC,KAAK;YAClB,IAAI,CAAC;gBAAC,MAAM,IAAI,CAAC,gBAAgB,CAAC,oBAAoB,CAAC,CAAC,KAAK,CAAC,CAAC;YAAC,CAAC;YACjE,OAAO,CAAC,EAAE,CAAC;gBAAC,MAAM,iBAAiB,CAAC,IAAI,CAAC,CAAC,EAAE,mBAAmB,EAAE,QAAQ,CAAC,CAAC;YAAC,CAAC;QAC/E,CAAC;QACD,KAAK,CAAC,KAAK;YACT,IAAI,IAAI;gBAAE,OAAO;YACjB,IAAI,GAAG,IAAI,CAAC;YACZ,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QACjD,CAAC;QACD,cAAc,CAAC,EAAE;YACf,MAAM,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;YACrB,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;YACnC,OAAO,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACxD,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Redactor } from "./redact.js";
|
|
2
|
+
/** The partner's logger. The SDK logs nothing unless one is given. */
|
|
3
|
+
export type Logger = (event: string, detail?: unknown) => void;
|
|
4
|
+
/** A logger that redacts every detail before the partner's logger sees it. */
|
|
5
|
+
export declare function safeLogger(log: Logger | undefined, redactor?: Redactor): Logger;
|
|
6
|
+
//# sourceMappingURL=log.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/log.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,sEAAsE;AACtE,MAAM,MAAM,MAAM,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;AAE/D,8EAA8E;AAC9E,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,EAAE,QAAQ,GAAE,QAAyB,GAAG,MAAM,CAO/F"}
|
package/dist/esm/log.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Redactor } from "./redact.js";
|
|
2
|
+
/** A logger that redacts every detail before the partner's logger sees it. */
|
|
3
|
+
export function safeLogger(log, redactor = new Redactor()) {
|
|
4
|
+
if (!log)
|
|
5
|
+
return () => { };
|
|
6
|
+
return (event, detail) => {
|
|
7
|
+
try {
|
|
8
|
+
log(redactor.string(event), detail === undefined ? undefined : redactor.value(detail));
|
|
9
|
+
}
|
|
10
|
+
catch { /* a broken logger must not break a call */ }
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=log.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../src/log.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAKvC,8EAA8E;AAC9E,MAAM,UAAU,UAAU,CAAC,GAAuB,EAAE,WAAqB,IAAI,QAAQ,EAAE;IACrF,IAAI,CAAC,GAAG;QAAE,OAAO,GAAG,EAAE,GAAE,CAAC,CAAC;IAC1B,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;QACvB,IAAI,CAAC;YACH,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;QACzF,CAAC;QAAC,MAAM,CAAC,CAAC,2CAA2C,CAAC,CAAC;IACzD,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @hainiva/agent-sdk/react-native — React Native adapters: the session in the
|
|
3
|
+
* Keychain / Android Keystore (expo-secure-store) and LiveKit call media.
|
|
4
|
+
*
|
|
5
|
+
* Call `registerGlobals()` from `@livekit/react-native` once at startup before
|
|
6
|
+
* joining a room. Native ringing (CallKit / Android call notification) is
|
|
7
|
+
* `@hainiva/react-native-call`.
|
|
8
|
+
*/
|
|
9
|
+
import type { SessionStore } from "./session.js";
|
|
10
|
+
export { joinCallRoom, type JoinOptions, type MediaCall, type MediaJoin } from "./livekit.js";
|
|
11
|
+
/** The part of `expo-secure-store` this adapter uses: pass the module itself. */
|
|
12
|
+
export interface SecureStoreModule {
|
|
13
|
+
getItemAsync(key: string, options?: Record<string, unknown>): Promise<string | null>;
|
|
14
|
+
setItemAsync(key: string, value: string, options?: Record<string, unknown>): Promise<void>;
|
|
15
|
+
deleteItemAsync(key: string, options?: Record<string, unknown>): Promise<void>;
|
|
16
|
+
/** expo-secure-store's constant; used as the default accessibility. */
|
|
17
|
+
AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY?: unknown;
|
|
18
|
+
}
|
|
19
|
+
export interface SecureStoreSessionOptions {
|
|
20
|
+
/** Default "hainiva.agent.session". Letters, digits, ".", "-" and "_" only. */
|
|
21
|
+
key?: string;
|
|
22
|
+
/**
|
|
23
|
+
* iPhone Keychain accessibility. Default AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY:
|
|
24
|
+
* readable while the phone is locked (a call that wakes the app must find the
|
|
25
|
+
* session) and never migrated to another device.
|
|
26
|
+
*/
|
|
27
|
+
keychainAccessible?: unknown;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The session (and so the refresh token) in secure storage only. There is
|
|
31
|
+
* deliberately no fallback to AsyncStorage or another plain store: if secure
|
|
32
|
+
* storage fails, the session stays in memory and the next launch signs in again
|
|
33
|
+
* with a fresh assertion.
|
|
34
|
+
*
|
|
35
|
+
* import * as SecureStore from "expo-secure-store";
|
|
36
|
+
* const store = secureStoreSessionStore(SecureStore);
|
|
37
|
+
*/
|
|
38
|
+
export declare function secureStoreSessionStore(secure: SecureStoreModule, o?: SecureStoreSessionOptions): SessionStore;
|
|
39
|
+
export { HainivaDesk, deskBridgeScript, type HainivaDeskProps, type WebViewLike } from "./reactNativeDesk.js";
|
|
40
|
+
//# sourceMappingURL=react-native.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-native.d.ts","sourceRoot":"","sources":["../../src/react-native.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9F,iFAAiF;AACjF,MAAM,WAAW,iBAAiB;IAChC,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACrF,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3F,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/E,uEAAuE;IACvE,mCAAmC,CAAC,EAAE,OAAO,CAAC;CAC/C;AAED,MAAM,WAAW,yBAAyB;IACxC,+EAA+E;IAC/E,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,iBAAiB,EAAE,CAAC,GAAE,yBAA8B,GAAG,YAAY,CAUlH;AAID,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export { joinCallRoom } from "./livekit.js";
|
|
2
|
+
/**
|
|
3
|
+
* The session (and so the refresh token) in secure storage only. There is
|
|
4
|
+
* deliberately no fallback to AsyncStorage or another plain store: if secure
|
|
5
|
+
* storage fails, the session stays in memory and the next launch signs in again
|
|
6
|
+
* with a fresh assertion.
|
|
7
|
+
*
|
|
8
|
+
* import * as SecureStore from "expo-secure-store";
|
|
9
|
+
* const store = secureStoreSessionStore(SecureStore);
|
|
10
|
+
*/
|
|
11
|
+
export function secureStoreSessionStore(secure, o = {}) {
|
|
12
|
+
const key = o.key ?? "hainiva.agent.session";
|
|
13
|
+
if (!/^[A-Za-z0-9._-]+$/.test(key))
|
|
14
|
+
throw new Error("secureStoreSessionStore: key may use only letters, digits, '.', '-' and '_'");
|
|
15
|
+
const access = o.keychainAccessible ?? secure.AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY;
|
|
16
|
+
const opts = access === undefined ? {} : { keychainAccessible: access };
|
|
17
|
+
return {
|
|
18
|
+
get: () => secure.getItemAsync(key, opts),
|
|
19
|
+
set: (v) => secure.setItemAsync(key, v, opts),
|
|
20
|
+
remove: () => secure.deleteItemAsync(key, opts),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
// The embedded HAINIVA desk in a WebView (react-native-webview, an optional
|
|
24
|
+
// peer), signed in with your agent session; calls stay native in your app.
|
|
25
|
+
export { HainivaDesk, deskBridgeScript } from "./reactNativeDesk.js";
|
|
26
|
+
//# sourceMappingURL=react-native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-native.js","sourceRoot":"","sources":["../../src/react-native.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,YAAY,EAAoD,MAAM,cAAc,CAAC;AAsB9F;;;;;;;;GAQG;AACH,MAAM,UAAU,uBAAuB,CAAC,MAAyB,EAAE,IAA+B,EAAE;IAClG,MAAM,GAAG,GAAG,CAAC,CAAC,GAAG,IAAI,uBAAuB,CAAC;IAC7C,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,6EAA6E,CAAC,CAAC;IACnI,MAAM,MAAM,GAAG,CAAC,CAAC,kBAAkB,IAAI,MAAM,CAAC,mCAAmC,CAAC;IAClF,MAAM,IAAI,GAA4B,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,kBAAkB,EAAE,MAAM,EAAE,CAAC;IACjG,OAAO;QACL,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,IAAI,CAAC;QACzC,GAAG,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC,EAAE,IAAI,CAAC;QAC7C,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,eAAe,CAAC,GAAG,EAAE,IAAI,CAAC;KAChD,CAAC;AACJ,CAAC;AAED,4EAA4E;AAC5E,2EAA2E;AAC3E,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAA2C,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `<HainivaDesk/>` — the HAINIVA desk inside your React Native app.
|
|
3
|
+
*
|
|
4
|
+
* import { WebView } from "react-native-webview";
|
|
5
|
+
* import { HainivaDesk } from "@hainiva/agent-sdk/react-native";
|
|
6
|
+
*
|
|
7
|
+
* <HainivaDesk agent={agent} appId={APP_ID} baseUrl="https://app.hainiva.com"
|
|
8
|
+
* onDial={(number, contactId) => placeNativeCall(number, contactId)}
|
|
9
|
+
* onEnded={(reason) => goToSignIn(reason)} />
|
|
10
|
+
*
|
|
11
|
+
* The split is the HAINIVA Agent app's: YOUR app rings and carries call audio
|
|
12
|
+
* natively (@hainiva/react-native-call + this SDK's CallStore); the desk shows
|
|
13
|
+
* the work and hands calls to you (`onDial`, `onDialer`).
|
|
14
|
+
*
|
|
15
|
+
* Security:
|
|
16
|
+
* - `originWhitelist` and `onShouldStartLoadWithRequest` keep the WebView on
|
|
17
|
+
* the HAINIVA desk origin; any other URL is refused there (and offered to
|
|
18
|
+
* `onOpenUrl`, if you pass one);
|
|
19
|
+
* - no window.open passthrough (`setSupportMultipleWindows={false}`,
|
|
20
|
+
* `javaScriptCanOpenWindowsAutomatically={false}`);
|
|
21
|
+
* - the bridge is installed before the desk's scripts and ONLY when the page
|
|
22
|
+
* is on the desk origin; the desk token goes in by injectJavaScript, never
|
|
23
|
+
* in the URL, and is not written to storage.
|
|
24
|
+
*/
|
|
25
|
+
import * as React from "react";
|
|
26
|
+
import { type DeskCallbacks, type DeskTokenSource, type HostToDesk } from "./embed.js";
|
|
27
|
+
/** The parts of react-native-webview's WebView this component uses. */
|
|
28
|
+
export interface WebViewLike {
|
|
29
|
+
injectJavaScript(script: string): void;
|
|
30
|
+
}
|
|
31
|
+
type WebViewComponent = React.ComponentType<Record<string, unknown> & {
|
|
32
|
+
ref?: React.Ref<WebViewLike>;
|
|
33
|
+
}>;
|
|
34
|
+
export interface HainivaDeskProps extends DeskCallbacks {
|
|
35
|
+
agent: DeskTokenSource;
|
|
36
|
+
appId: string;
|
|
37
|
+
/** The HAINIVA desk, e.g. https://app.hainiva.com. */
|
|
38
|
+
baseUrl: string;
|
|
39
|
+
theme?: "light" | "dark";
|
|
40
|
+
locale?: "vi" | "en";
|
|
41
|
+
/** react-native-webview's WebView. Default: required from "react-native-webview". */
|
|
42
|
+
WebView?: WebViewComponent;
|
|
43
|
+
/** Passed to the WebView. */
|
|
44
|
+
style?: unknown;
|
|
45
|
+
/** Local development only (http://localhost desk). */
|
|
46
|
+
allowInsecureLocalhost?: boolean;
|
|
47
|
+
}
|
|
48
|
+
/** Runs before the desk's scripts, on the desk origin only: the partner-rn bridge the desk looks for. */
|
|
49
|
+
export declare function deskBridgeScript(deskOrigin: string, appId: string): string;
|
|
50
|
+
/** A message to the desk, as a script: JSON twice (a string literal of the JSON), nothing interpolated raw. */
|
|
51
|
+
export declare function deliverScript(m: HostToDesk): string;
|
|
52
|
+
export declare function HainivaDesk(props: HainivaDeskProps): React.ReactElement;
|
|
53
|
+
export {};
|
|
54
|
+
//# sourceMappingURL=reactNativeDesk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reactNativeDesk.d.ts","sourceRoot":"","sources":["../../src/reactNativeDesk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAqB,KAAK,aAAa,EAAE,KAAK,eAAe,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAE1G,uEAAuE;AACvE,MAAM,WAAW,WAAW;IAC1B,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACxC;AACD,KAAK,gBAAgB,GAAG,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAAE,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;CAAE,CAAC,CAAC;AAExG,MAAM,WAAW,gBAAiB,SAAQ,aAAa;IACrD,KAAK,EAAE,eA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