@opendatalabs/vana-sdk 4.3.2 → 4.4.0-connect-sheet.0-pr.218.295a8da
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/README.md +131 -0
- package/dist/connect/account-origin.cjs +72 -0
- package/dist/connect/account-origin.cjs.map +1 -0
- package/dist/connect/account-origin.d.ts +92 -0
- package/dist/connect/account-origin.js +47 -0
- package/dist/connect/account-origin.js.map +1 -0
- package/dist/connect/account-origin.test.d.ts +1 -0
- package/dist/connect/chrome.cjs +221 -0
- package/dist/connect/chrome.cjs.map +1 -0
- package/dist/connect/chrome.d.ts +40 -0
- package/dist/connect/chrome.js +193 -0
- package/dist/connect/chrome.js.map +1 -0
- package/dist/connect/http-transports.cjs +100 -0
- package/dist/connect/http-transports.cjs.map +1 -0
- package/dist/connect/http-transports.d.ts +77 -0
- package/dist/connect/http-transports.js +75 -0
- package/dist/connect/http-transports.js.map +1 -0
- package/dist/connect/http-transports.test.d.ts +1 -0
- package/dist/connect/launcher.cjs +224 -0
- package/dist/connect/launcher.cjs.map +1 -0
- package/dist/connect/launcher.d.ts +122 -0
- package/dist/connect/launcher.js +210 -0
- package/dist/connect/launcher.js.map +1 -0
- package/dist/connect/launcher.test.d.ts +1 -0
- package/dist/connect/protocol.cjs +244 -0
- package/dist/connect/protocol.cjs.map +1 -0
- package/dist/connect/protocol.d.ts +307 -0
- package/dist/connect/protocol.js +203 -0
- package/dist/connect/protocol.js.map +1 -0
- package/dist/connect/protocol.test.d.ts +1 -0
- package/dist/connect.cjs +55 -0
- package/dist/connect.cjs.map +1 -0
- package/dist/connect.d.ts +35 -0
- package/dist/connect.js +34 -0
- package/dist/connect.js.map +1 -0
- package/dist/direct/connect-flow-sheet.test.d.ts +1 -0
- package/dist/direct/connect-flow.cjs +211 -1
- package/dist/direct/connect-flow.cjs.map +1 -1
- package/dist/direct/connect-flow.d.ts +75 -0
- package/dist/direct/connect-flow.js +213 -1
- package/dist/direct/connect-flow.js.map +1 -1
- package/dist/direct/connect-handler.cjs +493 -0
- package/dist/direct/connect-handler.cjs.map +1 -0
- package/dist/direct/connect-handler.d.ts +241 -0
- package/dist/direct/connect-handler.js +476 -0
- package/dist/direct/connect-handler.js.map +1 -0
- package/dist/direct/connect-handler.test.d.ts +1 -0
- package/dist/direct/controller.cjs +58 -3
- package/dist/direct/controller.cjs.map +1 -1
- package/dist/direct/controller.d.ts +79 -3
- package/dist/direct/controller.js +54 -2
- package/dist/direct/controller.js.map +1 -1
- package/dist/direct/endpoints.cjs +5 -2
- package/dist/direct/endpoints.cjs.map +1 -1
- package/dist/direct/endpoints.js +5 -2
- package/dist/direct/endpoints.js.map +1 -1
- package/dist/direct/request-authorization.cjs +65 -0
- package/dist/direct/request-authorization.cjs.map +1 -0
- package/dist/direct/request-authorization.d.ts +65 -0
- package/dist/direct/request-authorization.js +39 -0
- package/dist/direct/request-authorization.js.map +1 -0
- package/dist/direct/request-authorization.test.d.ts +1 -0
- package/dist/direct/types.cjs.map +1 -1
- package/dist/direct/types.d.ts +6 -0
- package/dist/direct/types.js.map +1 -1
- package/dist/direct/use-direct-vana-connect.cjs +18 -1
- package/dist/direct/use-direct-vana-connect.cjs.map +1 -1
- package/dist/direct/use-direct-vana-connect.js +18 -1
- package/dist/direct/use-direct-vana-connect.js.map +1 -1
- package/dist/direct/use-vana-connect.cjs +84 -0
- package/dist/direct/use-vana-connect.cjs.map +1 -0
- package/dist/direct/use-vana-connect.d.ts +59 -0
- package/dist/direct/use-vana-connect.js +64 -0
- package/dist/direct/use-vana-connect.js.map +1 -0
- package/dist/direct/use-vana-connect.test.d.ts +1 -0
- package/dist/react.cjs +10 -2
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.ts +4 -1
- package/dist/react.js +11 -1
- package/dist/react.js.map +1 -1
- package/dist/server.cjs +44 -2
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.ts +6 -2
- package/dist/server.js +49 -3
- package/dist/server.js.map +1 -1
- package/package.json +11 -1
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var launcher_exports = {};
|
|
20
|
+
__export(launcher_exports, {
|
|
21
|
+
connect: () => connect,
|
|
22
|
+
open: () => open,
|
|
23
|
+
openConnectSheet: () => openConnectSheet
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(launcher_exports);
|
|
26
|
+
var import_chrome = require("./chrome");
|
|
27
|
+
var import_protocol = require("./protocol");
|
|
28
|
+
const DEFAULT_READY_TIMEOUT_MS = 1e4;
|
|
29
|
+
let closeCurrent = null;
|
|
30
|
+
function open(options) {
|
|
31
|
+
const vanaOrigin = resolveTarget(options);
|
|
32
|
+
closeCurrent?.("replaced");
|
|
33
|
+
const emit = (event) => options.onEvent?.(event);
|
|
34
|
+
const previousFocus = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
35
|
+
const previousOverflow = document.body.style.overflow;
|
|
36
|
+
let closed = false;
|
|
37
|
+
let ready = false;
|
|
38
|
+
let pendingStatus = null;
|
|
39
|
+
let chrome = null;
|
|
40
|
+
const post = (message) => {
|
|
41
|
+
chrome?.iframe.contentWindow?.postMessage(message, vanaOrigin);
|
|
42
|
+
};
|
|
43
|
+
const close = (reason) => {
|
|
44
|
+
if (closed) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
closed = true;
|
|
48
|
+
window.clearTimeout(readyTimer);
|
|
49
|
+
window.removeEventListener("message", onMessage);
|
|
50
|
+
document.removeEventListener("keydown", onKeyDown);
|
|
51
|
+
chrome?.remove();
|
|
52
|
+
document.body.style.overflow = previousOverflow;
|
|
53
|
+
previousFocus?.focus();
|
|
54
|
+
if (closeCurrent === close) {
|
|
55
|
+
closeCurrent = null;
|
|
56
|
+
}
|
|
57
|
+
emit({ reason, type: "close" });
|
|
58
|
+
};
|
|
59
|
+
const requestFromPartner = () => {
|
|
60
|
+
options.getRequest().then(
|
|
61
|
+
(request) => {
|
|
62
|
+
if (!closed) {
|
|
63
|
+
post({ request, type: "vana:request", v: import_protocol.PROTOCOL_VERSION });
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
() => {
|
|
67
|
+
if (!closed) {
|
|
68
|
+
emit({ code: "request_failed", type: "error" });
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
};
|
|
73
|
+
const handleSheetMessage = (message) => {
|
|
74
|
+
switch (message.type) {
|
|
75
|
+
case "vana:ready":
|
|
76
|
+
if (ready) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
window.clearTimeout(readyTimer);
|
|
80
|
+
ready = true;
|
|
81
|
+
if (pendingStatus) {
|
|
82
|
+
post({
|
|
83
|
+
status: pendingStatus,
|
|
84
|
+
type: "vana:request-status",
|
|
85
|
+
v: import_protocol.PROTOCOL_VERSION
|
|
86
|
+
});
|
|
87
|
+
pendingStatus = null;
|
|
88
|
+
}
|
|
89
|
+
emit({ type: "ready" });
|
|
90
|
+
return;
|
|
91
|
+
case "vana:resize":
|
|
92
|
+
if (message.height >= import_protocol.MIN_SHEET_HEIGHT_PX) {
|
|
93
|
+
chrome?.setContentHeight(message.height);
|
|
94
|
+
}
|
|
95
|
+
return;
|
|
96
|
+
case "vana:signed-in":
|
|
97
|
+
emit({ type: "signed-in" });
|
|
98
|
+
return;
|
|
99
|
+
case "vana:request-needed":
|
|
100
|
+
requestFromPartner();
|
|
101
|
+
return;
|
|
102
|
+
case "vana:connected":
|
|
103
|
+
emit({
|
|
104
|
+
completion: message.completion,
|
|
105
|
+
status: message.status,
|
|
106
|
+
type: "connected"
|
|
107
|
+
});
|
|
108
|
+
return;
|
|
109
|
+
case "vana:progress":
|
|
110
|
+
emit({ phase: message.phase, type: "progress" });
|
|
111
|
+
return;
|
|
112
|
+
case "vana:close":
|
|
113
|
+
close("sheet");
|
|
114
|
+
return;
|
|
115
|
+
case "vana:error":
|
|
116
|
+
window.clearTimeout(readyTimer);
|
|
117
|
+
emit({ code: message.code, type: "error" });
|
|
118
|
+
return;
|
|
119
|
+
default:
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
function onMessage(event) {
|
|
124
|
+
if (event.origin !== vanaOrigin || !chrome || event.source !== chrome.iframe.contentWindow) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if ((0, import_protocol.readIncompatibleVersion)(event.data) !== null) {
|
|
128
|
+
emit({ code: "incompatible_version", type: "error" });
|
|
129
|
+
close("incompatible_version");
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
const message = (0, import_protocol.parseSheetMessage)(event.data);
|
|
133
|
+
if (message) {
|
|
134
|
+
handleSheetMessage(message);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
function onKeyDown(event) {
|
|
138
|
+
if (event.key === "Escape") {
|
|
139
|
+
close("escape");
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
const handle = {
|
|
143
|
+
close: () => {
|
|
144
|
+
close("api");
|
|
145
|
+
},
|
|
146
|
+
setRequestStatus(status) {
|
|
147
|
+
if (!ready) {
|
|
148
|
+
pendingStatus = status;
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
post({ status, type: "vana:request-status", v: import_protocol.PROTOCOL_VERSION });
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
window.addEventListener("message", onMessage);
|
|
155
|
+
document.addEventListener("keydown", onKeyDown);
|
|
156
|
+
const readyTimer = window.setTimeout(() => {
|
|
157
|
+
emit({ code: "frame_blocked", type: "error" });
|
|
158
|
+
close("frame_blocked");
|
|
159
|
+
}, options.readyTimeoutMs ?? DEFAULT_READY_TIMEOUT_MS);
|
|
160
|
+
checkClient(
|
|
161
|
+
(0, import_protocol.clientCheckUrl)({
|
|
162
|
+
clientId: options.clientId,
|
|
163
|
+
partnerOrigin: window.location.origin,
|
|
164
|
+
vanaOrigin
|
|
165
|
+
}),
|
|
166
|
+
() => {
|
|
167
|
+
if (!(closed || ready)) {
|
|
168
|
+
emit({ code: "origin_not_registered", type: "error" });
|
|
169
|
+
close("origin_not_registered");
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
);
|
|
173
|
+
chrome = (0, import_chrome.createSheetChrome)({
|
|
174
|
+
ariaLabel: `${options.appName} uses Vana`,
|
|
175
|
+
container: options.container ?? document.body,
|
|
176
|
+
onClose: close,
|
|
177
|
+
src: (0, import_protocol.sheetUrl)({
|
|
178
|
+
clientId: options.clientId,
|
|
179
|
+
partnerOrigin: window.location.origin,
|
|
180
|
+
vanaOrigin
|
|
181
|
+
})
|
|
182
|
+
});
|
|
183
|
+
document.body.style.overflow = "hidden";
|
|
184
|
+
chrome.show();
|
|
185
|
+
chrome.iframe.focus();
|
|
186
|
+
closeCurrent = close;
|
|
187
|
+
return handle;
|
|
188
|
+
}
|
|
189
|
+
function resolveTarget(target) {
|
|
190
|
+
const { env, vanaOrigin } = target;
|
|
191
|
+
if (env === void 0 === (vanaOrigin === void 0)) {
|
|
192
|
+
throw new TypeError("Pass exactly one of env and vanaOrigin");
|
|
193
|
+
}
|
|
194
|
+
if (env !== void 0) {
|
|
195
|
+
if (env !== "production" && env !== "dev") {
|
|
196
|
+
throw new TypeError('env must be "production" or "dev"');
|
|
197
|
+
}
|
|
198
|
+
return import_protocol.VANA_ACCOUNT_ORIGINS[env];
|
|
199
|
+
}
|
|
200
|
+
const origin = typeof vanaOrigin === "string" ? (0, import_protocol.normalizeOrigin)(vanaOrigin) : null;
|
|
201
|
+
if (!origin) {
|
|
202
|
+
throw new TypeError("vanaOrigin must be an http(s) origin");
|
|
203
|
+
}
|
|
204
|
+
return origin;
|
|
205
|
+
}
|
|
206
|
+
function checkClient(url, onRefused) {
|
|
207
|
+
if (typeof fetch !== "function") {
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
fetch(url, { cache: "no-store", credentials: "omit" }).then((response) => response.ok ? response.json() : null).then((body) => {
|
|
211
|
+
if ((0, import_protocol.parseClientCheck)(body)?.registered === false) {
|
|
212
|
+
onRefused();
|
|
213
|
+
}
|
|
214
|
+
}).catch(() => void 0);
|
|
215
|
+
}
|
|
216
|
+
const openConnectSheet = open;
|
|
217
|
+
const connect = { open };
|
|
218
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
219
|
+
0 && (module.exports = {
|
|
220
|
+
connect,
|
|
221
|
+
open,
|
|
222
|
+
openConnectSheet
|
|
223
|
+
});
|
|
224
|
+
//# sourceMappingURL=launcher.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/connect/launcher.ts"],"sourcesContent":["/**\n * Partner-side launcher for the Vana connect sheet.\n *\n * @remarks\n * `connect.open({ clientId, appName, env, getRequest, onEvent })` returns\n * `{ close, setRequestStatus }`. Only launcher, chrome and message\n * protocol live here. Identity, consent and signing live in the Vana-hosted\n * iframe and Vana's servers; no token ever crosses into the partner page.\n *\n * Most apps should not call this directly: `createDirectConnectFlow` (and\n * `useVanaConnect`) with `presentation: \"sheet\"` open it and wire it to the\n * request, the status poll and the read.\n *\n * Ported from `@vana-unity/connect-embed` with two differences: the version\n * handshake (`incompatible_version`), and no default Vana origin (pass `env`\n * or `vanaOrigin`).\n *\n * `connected` means the person approved; it is not delivery. Treat the data\n * as delivered only once your backend's status poll and read say so (the\n * connect flow's `done`).\n *\n * @category Connect\n * @module connect/launcher\n */\n\nimport {\n type CloseReason,\n createSheetChrome,\n type SheetChrome,\n} from \"./chrome\";\nimport {\n type ConnectCompletion,\n type ConnectProgressPhase,\n type ConnectRequest,\n clientCheckUrl,\n MIN_SHEET_HEIGHT_PX,\n normalizeOrigin,\n type PartnerMessage,\n PROTOCOL_VERSION,\n parseClientCheck,\n parseSheetMessage,\n readIncompatibleVersion,\n type RequestStatus,\n type SheetErrorCode,\n type SheetMessage,\n sheetUrl,\n VANA_ACCOUNT_ORIGINS,\n type VanaConnectEnv,\n} from \"./protocol\";\n\nconst DEFAULT_READY_TIMEOUT_MS = 10_000;\n\n/**\n * What the launcher reports to `onEvent`.\n *\n * @remarks\n * `connected` is approval, not delivery: data is delivered only when the\n * partner's backend reads it. The sheet sends no terminal \"delivered\" event\n * today; the connect flow settles from the status poll instead.\n */\nexport type ConnectEvent =\n | { type: \"ready\" }\n | { type: \"signed-in\" }\n | { completion: ConnectCompletion; status: \"approved\"; type: \"connected\" }\n | { phase: ConnectProgressPhase; type: \"progress\" }\n | { reason: ConnectCloseReason; type: \"close\" }\n | { code: SheetErrorCode | \"request_failed\"; type: \"error\" };\n\n/** Every close says why, so a sheet never disappears unexplained. */\nexport type ConnectCloseReason =\n | CloseReason\n | \"api\"\n | \"escape\"\n | \"frame_blocked\"\n | \"incompatible_version\"\n | \"origin_not_registered\"\n | \"replaced\"\n | \"sheet\";\n\n/**\n * Which Vana Account serves the sheet: an environment, or an exact origin\n * (resolve preview origins with `resolveVanaAccountOrigin`). Required, so a\n * dev app never silently frames production.\n */\nexport type ConnectTarget =\n | {\n /** Vana deployment; the sheet comes from `VANA_ACCOUNT_ORIGINS[env]`. */\n env: VanaConnectEnv;\n vanaOrigin?: undefined;\n }\n | {\n /** Vana Account origin. */\n vanaOrigin: string;\n env?: undefined;\n };\n\n/** Options for {@link open}, besides the {@link ConnectTarget}. */\nexport interface ConnectOpenBaseOptions {\n /** Chrome label only. Vana never trusts it; the sheet shows registered names. */\n appName: string;\n /** Registered embed client id. */\n clientId: string;\n /** Defaults to `document.body`. */\n container?: HTMLElement;\n /**\n * Called when the sheet asks for the request (after sign-in). The partner's\n * backend creates the request or re-signs its short-lived read capability.\n */\n getRequest: () => Promise<ConnectRequest>;\n onEvent?: (event: ConnectEvent) => void;\n /**\n * CSP-blocked frames still fire `load`, so only `vana:ready` proves the\n * sheet runs. Without it by this deadline the sheet closes with\n * `frame_blocked`.\n */\n readyTimeoutMs?: number;\n}\n\n/** Options for {@link open}. */\nexport type ConnectOpenOptions = ConnectOpenBaseOptions & ConnectTarget;\n\n/** The open sheet. */\nexport interface ConnectHandle {\n /** Close the sheet; emits `close` with reason `\"api\"`. */\n close(): void;\n /** Report the request outcome the partner's backend observed. */\n setRequestStatus(status: RequestStatus): void;\n}\n\n/** Closes the open sheet, if any. One sheet at a time. */\nlet closeCurrent: ((reason: ConnectCloseReason) => void) | null = null;\n\n/**\n * Open the Vana connect sheet over the page. One sheet exists at a time;\n * opening another closes the first with reason `\"replaced\"`.\n *\n * @param options - Client id, app name, the request source and event sink.\n * @remarks\n * Alongside framing, it asks Vana (`GET /api/embed/connect/client`, no\n * credentials, no cache) whether this page's origin is registered for the\n * client id, and closes with `origin_not_registered` on a definite no. If\n * that check cannot be answered, the ready deadline decides.\n *\n * @param options - Client id, app name, Vana target, the request source and\n * event sink.\n * @returns A handle to close the sheet and report status.\n * @throws TypeError when neither (or both) of `env` and `vanaOrigin` is\n * given, or `vanaOrigin` is not an http(s) origin.\n */\nexport function open(options: ConnectOpenOptions): ConnectHandle {\n const vanaOrigin = resolveTarget(options);\n closeCurrent?.(\"replaced\");\n\n const emit = (event: ConnectEvent) => options.onEvent?.(event);\n const previousFocus =\n document.activeElement instanceof HTMLElement\n ? document.activeElement\n : null;\n const previousOverflow = document.body.style.overflow;\n let closed = false;\n let ready = false;\n /** Latest status reported before the sheet was ready, sent on ready. */\n let pendingStatus: RequestStatus | null = null;\n let chrome: SheetChrome | null = null;\n\n const post = (message: PartnerMessage) => {\n chrome?.iframe.contentWindow?.postMessage(message, vanaOrigin);\n };\n\n const close = (reason: ConnectCloseReason) => {\n if (closed) {\n return;\n }\n closed = true;\n window.clearTimeout(readyTimer);\n window.removeEventListener(\"message\", onMessage);\n document.removeEventListener(\"keydown\", onKeyDown);\n chrome?.remove();\n document.body.style.overflow = previousOverflow;\n previousFocus?.focus();\n if (closeCurrent === close) {\n closeCurrent = null;\n }\n emit({ reason, type: \"close\" });\n };\n\n const requestFromPartner = () => {\n options.getRequest().then(\n (request) => {\n if (!closed) {\n post({ request, type: \"vana:request\", v: PROTOCOL_VERSION });\n }\n },\n () => {\n if (!closed) {\n emit({ code: \"request_failed\", type: \"error\" });\n }\n },\n );\n };\n\n const handleSheetMessage = (message: SheetMessage) => {\n switch (message.type) {\n case \"vana:ready\":\n // A sheet that mounts twice (strict-mode dev builds) says ready twice.\n if (ready) {\n return;\n }\n window.clearTimeout(readyTimer);\n ready = true;\n if (pendingStatus) {\n post({\n status: pendingStatus,\n type: \"vana:request-status\",\n v: PROTOCOL_VERSION,\n });\n pendingStatus = null;\n }\n emit({ type: \"ready\" });\n return;\n case \"vana:resize\":\n if (message.height >= MIN_SHEET_HEIGHT_PX) {\n chrome?.setContentHeight(message.height);\n }\n return;\n case \"vana:signed-in\":\n emit({ type: \"signed-in\" });\n return;\n case \"vana:request-needed\":\n requestFromPartner();\n return;\n case \"vana:connected\":\n emit({\n completion: message.completion,\n status: message.status,\n type: \"connected\",\n });\n return;\n case \"vana:progress\":\n emit({ phase: message.phase, type: \"progress\" });\n return;\n case \"vana:close\":\n close(\"sheet\");\n return;\n case \"vana:error\":\n // The frame runs, so it is not blocked; the sheet stays open to say why.\n window.clearTimeout(readyTimer);\n emit({ code: message.code, type: \"error\" });\n return;\n default:\n return;\n }\n };\n\n function onMessage(event: MessageEvent) {\n if (\n event.origin !== vanaOrigin ||\n !chrome ||\n event.source !== chrome.iframe.contentWindow\n ) {\n return;\n }\n // A sheet at a version this launcher cannot speak is up but unusable:\n // say so, rather than waiting out the ready timeout as \"frame_blocked\".\n if (readIncompatibleVersion(event.data) !== null) {\n emit({ code: \"incompatible_version\", type: \"error\" });\n close(\"incompatible_version\");\n return;\n }\n const message = parseSheetMessage(event.data);\n if (message) {\n handleSheetMessage(message);\n }\n }\n\n function onKeyDown(event: KeyboardEvent) {\n if (event.key === \"Escape\") {\n close(\"escape\");\n }\n }\n\n const handle: ConnectHandle = {\n close: () => {\n close(\"api\");\n },\n setRequestStatus(status) {\n // Before ready the frame still holds about:blank; posting would be lost.\n if (!ready) {\n pendingStatus = status;\n return;\n }\n post({ status, type: \"vana:request-status\", v: PROTOCOL_VERSION });\n },\n };\n\n window.addEventListener(\"message\", onMessage);\n document.addEventListener(\"keydown\", onKeyDown);\n const readyTimer = window.setTimeout(() => {\n emit({ code: \"frame_blocked\", type: \"error\" });\n close(\"frame_blocked\");\n }, options.readyTimeoutMs ?? DEFAULT_READY_TIMEOUT_MS);\n\n checkClient(\n clientCheckUrl({\n clientId: options.clientId,\n partnerOrigin: window.location.origin,\n vanaOrigin,\n }),\n () => {\n if (!(closed || ready)) {\n emit({ code: \"origin_not_registered\", type: \"error\" });\n close(\"origin_not_registered\");\n }\n },\n );\n\n chrome = createSheetChrome({\n ariaLabel: `${options.appName} uses Vana`,\n container: options.container ?? document.body,\n onClose: close,\n src: sheetUrl({\n clientId: options.clientId,\n partnerOrigin: window.location.origin,\n vanaOrigin,\n }),\n });\n document.body.style.overflow = \"hidden\";\n chrome.show();\n chrome.iframe.focus();\n\n closeCurrent = close;\n return handle;\n}\n\nfunction resolveTarget(target: ConnectTarget): string {\n const { env, vanaOrigin } = target as {\n env?: unknown;\n vanaOrigin?: unknown;\n };\n if ((env === undefined) === (vanaOrigin === undefined)) {\n throw new TypeError(\"Pass exactly one of env and vanaOrigin\");\n }\n if (env !== undefined) {\n if (env !== \"production\" && env !== \"dev\") {\n throw new TypeError('env must be \"production\" or \"dev\"');\n }\n return VANA_ACCOUNT_ORIGINS[env];\n }\n const origin =\n typeof vanaOrigin === \"string\" ? normalizeOrigin(vanaOrigin) : null;\n if (!origin) {\n throw new TypeError(\"vanaOrigin must be an http(s) origin\");\n }\n return origin;\n}\n\n/**\n * Ask Vana whether this page may frame the sheet, alongside framing it, and\n * call `onRefused` only on a definite no. Any failure to ask leaves the ready\n * deadline to decide, so the check can only end the sheet sooner.\n */\nfunction checkClient(url: string, onRefused: () => void): void {\n if (typeof fetch !== \"function\") {\n return;\n }\n fetch(url, { cache: \"no-store\", credentials: \"omit\" })\n .then((response) => (response.ok ? response.json() : null))\n .then((body: unknown) => {\n if (parseClientCheck(body)?.registered === false) {\n onRefused();\n }\n })\n .catch(() => undefined);\n}\n\n/** Alias of {@link open}, for call sites where `open` would be ambiguous. */\nexport const openConnectSheet = open;\n\n/** Namespace form: `connect.open(...)`. */\nexport const connect = { open } as const;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAyBA,oBAIO;AACP,sBAkBO;AAEP,MAAM,2BAA2B;AAgFjC,IAAI,eAA8D;AAmB3D,SAAS,KAAK,SAA4C;AAC/D,QAAM,aAAa,cAAc,OAAO;AACxC,iBAAe,UAAU;AAEzB,QAAM,OAAO,CAAC,UAAwB,QAAQ,UAAU,KAAK;AAC7D,QAAM,gBACJ,SAAS,yBAAyB,cAC9B,SAAS,gBACT;AACN,QAAM,mBAAmB,SAAS,KAAK,MAAM;AAC7C,MAAI,SAAS;AACb,MAAI,QAAQ;AAEZ,MAAI,gBAAsC;AAC1C,MAAI,SAA6B;AAEjC,QAAM,OAAO,CAAC,YAA4B;AACxC,YAAQ,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c,SAAS,KAAK,SAAS,KAAK,IAAI,IAAK,EACzD,KAAK,CAAC,SAAkB;AACvB,YAAI,kCAAiB,IAAI,GAAG,eAAe,OAAO;AAChD,gBAAU;AAAA,IACZ;AAAA,EACF,CAAC,EACA,MAAM,MAAM,MAAS;AAC1B;AAGO,MAAM,mBAAmB;AAGzB,MAAM,UAAU,EAAE,KAAK;","names":[]}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Partner-side launcher for the Vana connect sheet.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* `connect.open({ clientId, appName, env, getRequest, onEvent })` returns
|
|
6
|
+
* `{ close, setRequestStatus }`. Only launcher, chrome and message
|
|
7
|
+
* protocol live here. Identity, consent and signing live in the Vana-hosted
|
|
8
|
+
* iframe and Vana's servers; no token ever crosses into the partner page.
|
|
9
|
+
*
|
|
10
|
+
* Most apps should not call this directly: `createDirectConnectFlow` (and
|
|
11
|
+
* `useVanaConnect`) with `presentation: "sheet"` open it and wire it to the
|
|
12
|
+
* request, the status poll and the read.
|
|
13
|
+
*
|
|
14
|
+
* Ported from `@vana-unity/connect-embed` with two differences: the version
|
|
15
|
+
* handshake (`incompatible_version`), and no default Vana origin (pass `env`
|
|
16
|
+
* or `vanaOrigin`).
|
|
17
|
+
*
|
|
18
|
+
* `connected` means the person approved; it is not delivery. Treat the data
|
|
19
|
+
* as delivered only once your backend's status poll and read say so (the
|
|
20
|
+
* connect flow's `done`).
|
|
21
|
+
*
|
|
22
|
+
* @category Connect
|
|
23
|
+
* @module connect/launcher
|
|
24
|
+
*/
|
|
25
|
+
import { type CloseReason } from "./chrome.js";
|
|
26
|
+
import { type ConnectCompletion, type ConnectProgressPhase, type ConnectRequest, type RequestStatus, type SheetErrorCode, type VanaConnectEnv } from "./protocol.js";
|
|
27
|
+
/**
|
|
28
|
+
* What the launcher reports to `onEvent`.
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* `connected` is approval, not delivery: data is delivered only when the
|
|
32
|
+
* partner's backend reads it. The sheet sends no terminal "delivered" event
|
|
33
|
+
* today; the connect flow settles from the status poll instead.
|
|
34
|
+
*/
|
|
35
|
+
export type ConnectEvent = {
|
|
36
|
+
type: "ready";
|
|
37
|
+
} | {
|
|
38
|
+
type: "signed-in";
|
|
39
|
+
} | {
|
|
40
|
+
completion: ConnectCompletion;
|
|
41
|
+
status: "approved";
|
|
42
|
+
type: "connected";
|
|
43
|
+
} | {
|
|
44
|
+
phase: ConnectProgressPhase;
|
|
45
|
+
type: "progress";
|
|
46
|
+
} | {
|
|
47
|
+
reason: ConnectCloseReason;
|
|
48
|
+
type: "close";
|
|
49
|
+
} | {
|
|
50
|
+
code: SheetErrorCode | "request_failed";
|
|
51
|
+
type: "error";
|
|
52
|
+
};
|
|
53
|
+
/** Every close says why, so a sheet never disappears unexplained. */
|
|
54
|
+
export type ConnectCloseReason = CloseReason | "api" | "escape" | "frame_blocked" | "incompatible_version" | "origin_not_registered" | "replaced" | "sheet";
|
|
55
|
+
/**
|
|
56
|
+
* Which Vana Account serves the sheet: an environment, or an exact origin
|
|
57
|
+
* (resolve preview origins with `resolveVanaAccountOrigin`). Required, so a
|
|
58
|
+
* dev app never silently frames production.
|
|
59
|
+
*/
|
|
60
|
+
export type ConnectTarget = {
|
|
61
|
+
/** Vana deployment; the sheet comes from `VANA_ACCOUNT_ORIGINS[env]`. */
|
|
62
|
+
env: VanaConnectEnv;
|
|
63
|
+
vanaOrigin?: undefined;
|
|
64
|
+
} | {
|
|
65
|
+
/** Vana Account origin. */
|
|
66
|
+
vanaOrigin: string;
|
|
67
|
+
env?: undefined;
|
|
68
|
+
};
|
|
69
|
+
/** Options for {@link open}, besides the {@link ConnectTarget}. */
|
|
70
|
+
export interface ConnectOpenBaseOptions {
|
|
71
|
+
/** Chrome label only. Vana never trusts it; the sheet shows registered names. */
|
|
72
|
+
appName: string;
|
|
73
|
+
/** Registered embed client id. */
|
|
74
|
+
clientId: string;
|
|
75
|
+
/** Defaults to `document.body`. */
|
|
76
|
+
container?: HTMLElement;
|
|
77
|
+
/**
|
|
78
|
+
* Called when the sheet asks for the request (after sign-in). The partner's
|
|
79
|
+
* backend creates the request or re-signs its short-lived read capability.
|
|
80
|
+
*/
|
|
81
|
+
getRequest: () => Promise<ConnectRequest>;
|
|
82
|
+
onEvent?: (event: ConnectEvent) => void;
|
|
83
|
+
/**
|
|
84
|
+
* CSP-blocked frames still fire `load`, so only `vana:ready` proves the
|
|
85
|
+
* sheet runs. Without it by this deadline the sheet closes with
|
|
86
|
+
* `frame_blocked`.
|
|
87
|
+
*/
|
|
88
|
+
readyTimeoutMs?: number;
|
|
89
|
+
}
|
|
90
|
+
/** Options for {@link open}. */
|
|
91
|
+
export type ConnectOpenOptions = ConnectOpenBaseOptions & ConnectTarget;
|
|
92
|
+
/** The open sheet. */
|
|
93
|
+
export interface ConnectHandle {
|
|
94
|
+
/** Close the sheet; emits `close` with reason `"api"`. */
|
|
95
|
+
close(): void;
|
|
96
|
+
/** Report the request outcome the partner's backend observed. */
|
|
97
|
+
setRequestStatus(status: RequestStatus): void;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Open the Vana connect sheet over the page. One sheet exists at a time;
|
|
101
|
+
* opening another closes the first with reason `"replaced"`.
|
|
102
|
+
*
|
|
103
|
+
* @param options - Client id, app name, the request source and event sink.
|
|
104
|
+
* @remarks
|
|
105
|
+
* Alongside framing, it asks Vana (`GET /api/embed/connect/client`, no
|
|
106
|
+
* credentials, no cache) whether this page's origin is registered for the
|
|
107
|
+
* client id, and closes with `origin_not_registered` on a definite no. If
|
|
108
|
+
* that check cannot be answered, the ready deadline decides.
|
|
109
|
+
*
|
|
110
|
+
* @param options - Client id, app name, Vana target, the request source and
|
|
111
|
+
* event sink.
|
|
112
|
+
* @returns A handle to close the sheet and report status.
|
|
113
|
+
* @throws TypeError when neither (or both) of `env` and `vanaOrigin` is
|
|
114
|
+
* given, or `vanaOrigin` is not an http(s) origin.
|
|
115
|
+
*/
|
|
116
|
+
export declare function open(options: ConnectOpenOptions): ConnectHandle;
|
|
117
|
+
/** Alias of {@link open}, for call sites where `open` would be ambiguous. */
|
|
118
|
+
export declare const openConnectSheet: typeof open;
|
|
119
|
+
/** Namespace form: `connect.open(...)`. */
|
|
120
|
+
export declare const connect: {
|
|
121
|
+
readonly open: typeof open;
|
|
122
|
+
};
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createSheetChrome
|
|
3
|
+
} from "./chrome.js";
|
|
4
|
+
import {
|
|
5
|
+
clientCheckUrl,
|
|
6
|
+
MIN_SHEET_HEIGHT_PX,
|
|
7
|
+
normalizeOrigin,
|
|
8
|
+
PROTOCOL_VERSION,
|
|
9
|
+
parseClientCheck,
|
|
10
|
+
parseSheetMessage,
|
|
11
|
+
readIncompatibleVersion,
|
|
12
|
+
sheetUrl,
|
|
13
|
+
VANA_ACCOUNT_ORIGINS
|
|
14
|
+
} from "./protocol.js";
|
|
15
|
+
const DEFAULT_READY_TIMEOUT_MS = 1e4;
|
|
16
|
+
let closeCurrent = null;
|
|
17
|
+
function open(options) {
|
|
18
|
+
const vanaOrigin = resolveTarget(options);
|
|
19
|
+
closeCurrent?.("replaced");
|
|
20
|
+
const emit = (event) => options.onEvent?.(event);
|
|
21
|
+
const previousFocus = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
22
|
+
const previousOverflow = document.body.style.overflow;
|
|
23
|
+
let closed = false;
|
|
24
|
+
let ready = false;
|
|
25
|
+
let pendingStatus = null;
|
|
26
|
+
let chrome = null;
|
|
27
|
+
const post = (message) => {
|
|
28
|
+
chrome?.iframe.contentWindow?.postMessage(message, vanaOrigin);
|
|
29
|
+
};
|
|
30
|
+
const close = (reason) => {
|
|
31
|
+
if (closed) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
closed = true;
|
|
35
|
+
window.clearTimeout(readyTimer);
|
|
36
|
+
window.removeEventListener("message", onMessage);
|
|
37
|
+
document.removeEventListener("keydown", onKeyDown);
|
|
38
|
+
chrome?.remove();
|
|
39
|
+
document.body.style.overflow = previousOverflow;
|
|
40
|
+
previousFocus?.focus();
|
|
41
|
+
if (closeCurrent === close) {
|
|
42
|
+
closeCurrent = null;
|
|
43
|
+
}
|
|
44
|
+
emit({ reason, type: "close" });
|
|
45
|
+
};
|
|
46
|
+
const requestFromPartner = () => {
|
|
47
|
+
options.getRequest().then(
|
|
48
|
+
(request) => {
|
|
49
|
+
if (!closed) {
|
|
50
|
+
post({ request, type: "vana:request", v: PROTOCOL_VERSION });
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
() => {
|
|
54
|
+
if (!closed) {
|
|
55
|
+
emit({ code: "request_failed", type: "error" });
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
const handleSheetMessage = (message) => {
|
|
61
|
+
switch (message.type) {
|
|
62
|
+
case "vana:ready":
|
|
63
|
+
if (ready) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
window.clearTimeout(readyTimer);
|
|
67
|
+
ready = true;
|
|
68
|
+
if (pendingStatus) {
|
|
69
|
+
post({
|
|
70
|
+
status: pendingStatus,
|
|
71
|
+
type: "vana:request-status",
|
|
72
|
+
v: PROTOCOL_VERSION
|
|
73
|
+
});
|
|
74
|
+
pendingStatus = null;
|
|
75
|
+
}
|
|
76
|
+
emit({ type: "ready" });
|
|
77
|
+
return;
|
|
78
|
+
case "vana:resize":
|
|
79
|
+
if (message.height >= MIN_SHEET_HEIGHT_PX) {
|
|
80
|
+
chrome?.setContentHeight(message.height);
|
|
81
|
+
}
|
|
82
|
+
return;
|
|
83
|
+
case "vana:signed-in":
|
|
84
|
+
emit({ type: "signed-in" });
|
|
85
|
+
return;
|
|
86
|
+
case "vana:request-needed":
|
|
87
|
+
requestFromPartner();
|
|
88
|
+
return;
|
|
89
|
+
case "vana:connected":
|
|
90
|
+
emit({
|
|
91
|
+
completion: message.completion,
|
|
92
|
+
status: message.status,
|
|
93
|
+
type: "connected"
|
|
94
|
+
});
|
|
95
|
+
return;
|
|
96
|
+
case "vana:progress":
|
|
97
|
+
emit({ phase: message.phase, type: "progress" });
|
|
98
|
+
return;
|
|
99
|
+
case "vana:close":
|
|
100
|
+
close("sheet");
|
|
101
|
+
return;
|
|
102
|
+
case "vana:error":
|
|
103
|
+
window.clearTimeout(readyTimer);
|
|
104
|
+
emit({ code: message.code, type: "error" });
|
|
105
|
+
return;
|
|
106
|
+
default:
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
function onMessage(event) {
|
|
111
|
+
if (event.origin !== vanaOrigin || !chrome || event.source !== chrome.iframe.contentWindow) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
if (readIncompatibleVersion(event.data) !== null) {
|
|
115
|
+
emit({ code: "incompatible_version", type: "error" });
|
|
116
|
+
close("incompatible_version");
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const message = parseSheetMessage(event.data);
|
|
120
|
+
if (message) {
|
|
121
|
+
handleSheetMessage(message);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
function onKeyDown(event) {
|
|
125
|
+
if (event.key === "Escape") {
|
|
126
|
+
close("escape");
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
const handle = {
|
|
130
|
+
close: () => {
|
|
131
|
+
close("api");
|
|
132
|
+
},
|
|
133
|
+
setRequestStatus(status) {
|
|
134
|
+
if (!ready) {
|
|
135
|
+
pendingStatus = status;
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
post({ status, type: "vana:request-status", v: PROTOCOL_VERSION });
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
window.addEventListener("message", onMessage);
|
|
142
|
+
document.addEventListener("keydown", onKeyDown);
|
|
143
|
+
const readyTimer = window.setTimeout(() => {
|
|
144
|
+
emit({ code: "frame_blocked", type: "error" });
|
|
145
|
+
close("frame_blocked");
|
|
146
|
+
}, options.readyTimeoutMs ?? DEFAULT_READY_TIMEOUT_MS);
|
|
147
|
+
checkClient(
|
|
148
|
+
clientCheckUrl({
|
|
149
|
+
clientId: options.clientId,
|
|
150
|
+
partnerOrigin: window.location.origin,
|
|
151
|
+
vanaOrigin
|
|
152
|
+
}),
|
|
153
|
+
() => {
|
|
154
|
+
if (!(closed || ready)) {
|
|
155
|
+
emit({ code: "origin_not_registered", type: "error" });
|
|
156
|
+
close("origin_not_registered");
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
);
|
|
160
|
+
chrome = createSheetChrome({
|
|
161
|
+
ariaLabel: `${options.appName} uses Vana`,
|
|
162
|
+
container: options.container ?? document.body,
|
|
163
|
+
onClose: close,
|
|
164
|
+
src: sheetUrl({
|
|
165
|
+
clientId: options.clientId,
|
|
166
|
+
partnerOrigin: window.location.origin,
|
|
167
|
+
vanaOrigin
|
|
168
|
+
})
|
|
169
|
+
});
|
|
170
|
+
document.body.style.overflow = "hidden";
|
|
171
|
+
chrome.show();
|
|
172
|
+
chrome.iframe.focus();
|
|
173
|
+
closeCurrent = close;
|
|
174
|
+
return handle;
|
|
175
|
+
}
|
|
176
|
+
function resolveTarget(target) {
|
|
177
|
+
const { env, vanaOrigin } = target;
|
|
178
|
+
if (env === void 0 === (vanaOrigin === void 0)) {
|
|
179
|
+
throw new TypeError("Pass exactly one of env and vanaOrigin");
|
|
180
|
+
}
|
|
181
|
+
if (env !== void 0) {
|
|
182
|
+
if (env !== "production" && env !== "dev") {
|
|
183
|
+
throw new TypeError('env must be "production" or "dev"');
|
|
184
|
+
}
|
|
185
|
+
return VANA_ACCOUNT_ORIGINS[env];
|
|
186
|
+
}
|
|
187
|
+
const origin = typeof vanaOrigin === "string" ? normalizeOrigin(vanaOrigin) : null;
|
|
188
|
+
if (!origin) {
|
|
189
|
+
throw new TypeError("vanaOrigin must be an http(s) origin");
|
|
190
|
+
}
|
|
191
|
+
return origin;
|
|
192
|
+
}
|
|
193
|
+
function checkClient(url, onRefused) {
|
|
194
|
+
if (typeof fetch !== "function") {
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
fetch(url, { cache: "no-store", credentials: "omit" }).then((response) => response.ok ? response.json() : null).then((body) => {
|
|
198
|
+
if (parseClientCheck(body)?.registered === false) {
|
|
199
|
+
onRefused();
|
|
200
|
+
}
|
|
201
|
+
}).catch(() => void 0);
|
|
202
|
+
}
|
|
203
|
+
const openConnectSheet = open;
|
|
204
|
+
const connect = { open };
|
|
205
|
+
export {
|
|
206
|
+
connect,
|
|
207
|
+
open,
|
|
208
|
+
openConnectSheet
|
|
209
|
+
};
|
|
210
|
+
//# sourceMappingURL=launcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/connect/launcher.ts"],"sourcesContent":["/**\n * Partner-side launcher for the Vana connect sheet.\n *\n * @remarks\n * `connect.open({ clientId, appName, env, getRequest, onEvent })` returns\n * `{ close, setRequestStatus }`. Only launcher, chrome and message\n * protocol live here. Identity, consent and signing live in the Vana-hosted\n * iframe and Vana's servers; no token ever crosses into the partner page.\n *\n * Most apps should not call this directly: `createDirectConnectFlow` (and\n * `useVanaConnect`) with `presentation: \"sheet\"` open it and wire it to the\n * request, the status poll and the read.\n *\n * Ported from `@vana-unity/connect-embed` with two differences: the version\n * handshake (`incompatible_version`), and no default Vana origin (pass `env`\n * or `vanaOrigin`).\n *\n * `connected` means the person approved; it is not delivery. Treat the data\n * as delivered only once your backend's status poll and read say so (the\n * connect flow's `done`).\n *\n * @category Connect\n * @module connect/launcher\n */\n\nimport {\n type CloseReason,\n createSheetChrome,\n type SheetChrome,\n} from \"./chrome\";\nimport {\n type ConnectCompletion,\n type ConnectProgressPhase,\n type ConnectRequest,\n clientCheckUrl,\n MIN_SHEET_HEIGHT_PX,\n normalizeOrigin,\n type PartnerMessage,\n PROTOCOL_VERSION,\n parseClientCheck,\n parseSheetMessage,\n readIncompatibleVersion,\n type RequestStatus,\n type SheetErrorCode,\n type SheetMessage,\n sheetUrl,\n VANA_ACCOUNT_ORIGINS,\n type VanaConnectEnv,\n} from \"./protocol\";\n\nconst DEFAULT_READY_TIMEOUT_MS = 10_000;\n\n/**\n * What the launcher reports to `onEvent`.\n *\n * @remarks\n * `connected` is approval, not delivery: data is delivered only when the\n * partner's backend reads it. The sheet sends no terminal \"delivered\" event\n * today; the connect flow settles from the status poll instead.\n */\nexport type ConnectEvent =\n | { type: \"ready\" }\n | { type: \"signed-in\" }\n | { completion: ConnectCompletion; status: \"approved\"; type: \"connected\" }\n | { phase: ConnectProgressPhase; type: \"progress\" }\n | { reason: ConnectCloseReason; type: \"close\" }\n | { code: SheetErrorCode | \"request_failed\"; type: \"error\" };\n\n/** Every close says why, so a sheet never disappears unexplained. */\nexport type ConnectCloseReason =\n | CloseReason\n | \"api\"\n | \"escape\"\n | \"frame_blocked\"\n | \"incompatible_version\"\n | \"origin_not_registered\"\n | \"replaced\"\n | \"sheet\";\n\n/**\n * Which Vana Account serves the sheet: an environment, or an exact origin\n * (resolve preview origins with `resolveVanaAccountOrigin`). Required, so a\n * dev app never silently frames production.\n */\nexport type ConnectTarget =\n | {\n /** Vana deployment; the sheet comes from `VANA_ACCOUNT_ORIGINS[env]`. */\n env: VanaConnectEnv;\n vanaOrigin?: undefined;\n }\n | {\n /** Vana Account origin. */\n vanaOrigin: string;\n env?: undefined;\n };\n\n/** Options for {@link open}, besides the {@link ConnectTarget}. */\nexport interface ConnectOpenBaseOptions {\n /** Chrome label only. Vana never trusts it; the sheet shows registered names. */\n appName: string;\n /** Registered embed client id. */\n clientId: string;\n /** Defaults to `document.body`. */\n container?: HTMLElement;\n /**\n * Called when the sheet asks for the request (after sign-in). The partner's\n * backend creates the request or re-signs its short-lived read capability.\n */\n getRequest: () => Promise<ConnectRequest>;\n onEvent?: (event: ConnectEvent) => void;\n /**\n * CSP-blocked frames still fire `load`, so only `vana:ready` proves the\n * sheet runs. Without it by this deadline the sheet closes with\n * `frame_blocked`.\n */\n readyTimeoutMs?: number;\n}\n\n/** Options for {@link open}. */\nexport type ConnectOpenOptions = ConnectOpenBaseOptions & ConnectTarget;\n\n/** The open sheet. */\nexport interface ConnectHandle {\n /** Close the sheet; emits `close` with reason `\"api\"`. */\n close(): void;\n /** Report the request outcome the partner's backend observed. */\n setRequestStatus(status: RequestStatus): void;\n}\n\n/** Closes the open sheet, if any. One sheet at a time. */\nlet closeCurrent: ((reason: ConnectCloseReason) => void) | null = null;\n\n/**\n * Open the Vana connect sheet over the page. One sheet exists at a time;\n * opening another closes the first with reason `\"replaced\"`.\n *\n * @param options - Client id, app name, the request source and event sink.\n * @remarks\n * Alongside framing, it asks Vana (`GET /api/embed/connect/client`, no\n * credentials, no cache) whether this page's origin is registered for the\n * client id, and closes with `origin_not_registered` on a definite no. If\n * that check cannot be answered, the ready deadline decides.\n *\n * @param options - Client id, app name, Vana target, the request source and\n * event sink.\n * @returns A handle to close the sheet and report status.\n * @throws TypeError when neither (or both) of `env` and `vanaOrigin` is\n * given, or `vanaOrigin` is not an http(s) origin.\n */\nexport function open(options: ConnectOpenOptions): ConnectHandle {\n const vanaOrigin = resolveTarget(options);\n closeCurrent?.(\"replaced\");\n\n const emit = (event: ConnectEvent) => options.onEvent?.(event);\n const previousFocus =\n document.activeElement instanceof HTMLElement\n ? document.activeElement\n : null;\n const previousOverflow = document.body.style.overflow;\n let closed = false;\n let ready = false;\n /** Latest status reported before the sheet was ready, sent on ready. */\n let pendingStatus: RequestStatus | null = null;\n let chrome: SheetChrome | null = null;\n\n const post = (message: PartnerMessage) => {\n chrome?.iframe.contentWindow?.postMessage(message, vanaOrigin);\n };\n\n const close = (reason: ConnectCloseReason) => {\n if (closed) {\n return;\n }\n closed = true;\n window.clearTimeout(readyTimer);\n window.removeEventListener(\"message\", onMessage);\n document.removeEventListener(\"keydown\", onKeyDown);\n chrome?.remove();\n document.body.style.overflow = previousOverflow;\n previousFocus?.focus();\n if (closeCurrent === close) {\n closeCurrent = null;\n }\n emit({ reason, type: \"close\" });\n };\n\n const requestFromPartner = () => {\n options.getRequest().then(\n (request) => {\n if (!closed) {\n post({ request, type: \"vana:request\", v: PROTOCOL_VERSION });\n }\n },\n () => {\n if (!closed) {\n emit({ code: \"request_failed\", type: \"error\" });\n }\n },\n );\n };\n\n const handleSheetMessage = (message: SheetMessage) => {\n switch (message.type) {\n case \"vana:ready\":\n // A sheet that mounts twice (strict-mode dev builds) says ready twice.\n if (ready) {\n return;\n }\n window.clearTimeout(readyTimer);\n ready = true;\n if (pendingStatus) {\n post({\n status: pendingStatus,\n type: \"vana:request-status\",\n v: PROTOCOL_VERSION,\n });\n pendingStatus = null;\n }\n emit({ type: \"ready\" });\n return;\n case \"vana:resize\":\n if (message.height >= MIN_SHEET_HEIGHT_PX) {\n chrome?.setContentHeight(message.height);\n }\n return;\n case \"vana:signed-in\":\n emit({ type: \"signed-in\" });\n return;\n case \"vana:request-needed\":\n requestFromPartner();\n return;\n case \"vana:connected\":\n emit({\n completion: message.completion,\n status: message.status,\n type: \"connected\",\n });\n return;\n case \"vana:progress\":\n emit({ phase: message.phase, type: \"progress\" });\n return;\n case \"vana:close\":\n close(\"sheet\");\n return;\n case \"vana:error\":\n // The frame runs, so it is not blocked; the sheet stays open to say why.\n window.clearTimeout(readyTimer);\n emit({ code: message.code, type: \"error\" });\n return;\n default:\n return;\n }\n };\n\n function onMessage(event: MessageEvent) {\n if (\n event.origin !== vanaOrigin ||\n !chrome ||\n event.source !== chrome.iframe.contentWindow\n ) {\n return;\n }\n // A sheet at a version this launcher cannot speak is up but unusable:\n // say so, rather than waiting out the ready timeout as \"frame_blocked\".\n if (readIncompatibleVersion(event.data) !== null) {\n emit({ code: \"incompatible_version\", type: \"error\" });\n close(\"incompatible_version\");\n return;\n }\n const message = parseSheetMessage(event.data);\n if (message) {\n handleSheetMessage(message);\n }\n }\n\n function onKeyDown(event: KeyboardEvent) {\n if (event.key === \"Escape\") {\n close(\"escape\");\n }\n }\n\n const handle: ConnectHandle = {\n close: () => {\n close(\"api\");\n },\n setRequestStatus(status) {\n // Before ready the frame still holds about:blank; posting would be lost.\n if (!ready) {\n pendingStatus = status;\n return;\n }\n post({ status, type: \"vana:request-status\", v: PROTOCOL_VERSION });\n },\n };\n\n window.addEventListener(\"message\", onMessage);\n document.addEventListener(\"keydown\", onKeyDown);\n const readyTimer = window.setTimeout(() => {\n emit({ code: \"frame_blocked\", type: \"error\" });\n close(\"frame_blocked\");\n }, options.readyTimeoutMs ?? DEFAULT_READY_TIMEOUT_MS);\n\n checkClient(\n clientCheckUrl({\n clientId: options.clientId,\n partnerOrigin: window.location.origin,\n vanaOrigin,\n }),\n () => {\n if (!(closed || ready)) {\n emit({ code: \"origin_not_registered\", type: \"error\" });\n close(\"origin_not_registered\");\n }\n },\n );\n\n chrome = createSheetChrome({\n ariaLabel: `${options.appName} uses Vana`,\n container: options.container ?? document.body,\n onClose: close,\n src: sheetUrl({\n clientId: options.clientId,\n partnerOrigin: window.location.origin,\n vanaOrigin,\n }),\n });\n document.body.style.overflow = \"hidden\";\n chrome.show();\n chrome.iframe.focus();\n\n closeCurrent = close;\n return handle;\n}\n\nfunction resolveTarget(target: ConnectTarget): string {\n const { env, vanaOrigin } = target as {\n env?: unknown;\n vanaOrigin?: unknown;\n };\n if ((env === undefined) === (vanaOrigin === undefined)) {\n throw new TypeError(\"Pass exactly one of env and vanaOrigin\");\n }\n if (env !== undefined) {\n if (env !== \"production\" && env !== \"dev\") {\n throw new TypeError('env must be \"production\" or \"dev\"');\n }\n return VANA_ACCOUNT_ORIGINS[env];\n }\n const origin =\n typeof vanaOrigin === \"string\" ? normalizeOrigin(vanaOrigin) : null;\n if (!origin) {\n throw new TypeError(\"vanaOrigin must be an http(s) origin\");\n }\n return origin;\n}\n\n/**\n * Ask Vana whether this page may frame the sheet, alongside framing it, and\n * call `onRefused` only on a definite no. Any failure to ask leaves the ready\n * deadline to decide, so the check can only end the sheet sooner.\n */\nfunction checkClient(url: string, onRefused: () => void): void {\n if (typeof fetch !== \"function\") {\n return;\n }\n fetch(url, { cache: \"no-store\", credentials: \"omit\" })\n .then((response) => (response.ok ? response.json() : null))\n .then((body: unknown) => {\n if (parseClientCheck(body)?.registered === false) {\n onRefused();\n }\n })\n .catch(() => undefined);\n}\n\n/** Alias of {@link open}, for call sites where `open` would be ambiguous. */\nexport const openConnectSheet = open;\n\n/** Namespace form: `connect.open(...)`. */\nexport const connect = { open } as const;\n"],"mappings":"AAyBA;AAAA,EAEE;AAAA,OAEK;AACP;AAAA,EAIE;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAIA;AAAA,EACA;AAAA,OAEK;AAEP,MAAM,2BAA2B;AAgFjC,IAAI,eAA8D;AAmB3D,SAAS,KAAK,SAA4C;AAC/D,QAAM,aAAa,cAAc,OAAO;AACxC,iBAAe,UAAU;AAEzB,QAAM,OAAO,CAAC,UAAwB,QAAQ,UAAU,KAAK;AAC7D,QAAM,gBACJ,SAAS,yBAAyB,cAC9B,SAAS,gBACT;AACN,QAAM,mBAAmB,SAAS,KAAK,MAAM;AAC7C,MAAI,SAAS;AACb,MAAI,QAAQ;AAEZ,MAAI,gBAAsC;AAC1C,MAAI,SAA6B;AAEjC,QAAM,OAAO,CAAC,YAA4B;AACxC,YAAQ,OAAO,eAAe,YAAY,SAAS,UAAU;AAAA,EAC/D;AAEA,QAAM,QAAQ,CAAC,WAA+B;AAC5C,QAAI,QAAQ;AACV;AAAA,IACF;AACA,aAAS;AACT,WAAO,aAAa,UAAU;AAC9B,WAAO,oBAAoB,WAAW,SAAS;AAC/C,aAAS,oBAAoB,WAAW,SAAS;AACjD,YAAQ,OAAO;AACf,aAAS,KAAK,MAAM,WAAW;AAC/B,mBAAe,MAAM;AACrB,QAAI,iBAAiB,OAAO;AAC1B,qBAAe;AAAA,IACjB;AACA,SAAK,EAAE,QAAQ,MAAM,QAAQ,CAAC;AAAA,EACh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