@prvt/mini-app-sdk 0.1.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/README.md +33 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +149 -0
- package/dist/index.js.map +1 -0
- package/dist/standalone.d.ts +12 -0
- package/dist/standalone.d.ts.map +1 -0
- package/dist/standalone.js +9 -0
- package/dist/standalone.js.map +1 -0
- package/package.json +38 -0
package/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# `@prvt/mini-app-sdk`
|
|
2
|
+
|
|
3
|
+
Browser SDK for apps opened inside a prvt room. The host keeps the LiveKit
|
|
4
|
+
connection and integration credentials; this package communicates with the
|
|
5
|
+
host through the typed `postMessage` bridge.
|
|
6
|
+
|
|
7
|
+
For a no-build integration, load the stable deployment URL instead:
|
|
8
|
+
|
|
9
|
+
```html
|
|
10
|
+
<script src="https://call.example.com/prvt-mini-app.js"></script>
|
|
11
|
+
<script>
|
|
12
|
+
const app = Prvt.MiniApp.create({ hostOrigin: "https://call.example.com" });
|
|
13
|
+
app.ready().then(() => app.request("queue.add", { trackId: "track_123" }));
|
|
14
|
+
</script>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
The script exposes `window.Prvt.MiniApp.create` and is generated from the same
|
|
18
|
+
source as this package.
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { createPrvtMiniApp } from "@prvt/mini-app-sdk";
|
|
22
|
+
|
|
23
|
+
const app = createPrvtMiniApp({ hostOrigin: "https://call.example.com" });
|
|
24
|
+
const context = await app.ready();
|
|
25
|
+
|
|
26
|
+
const result = await app.request("queue.add", { trackId: "track_123" });
|
|
27
|
+
app.close();
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
The `hostOrigin` should be the canonical prvt application origin. The context
|
|
31
|
+
contains only display context and capabilities; it never contains a room code,
|
|
32
|
+
participant token, or integration key. Actions are handled by the integration
|
|
33
|
+
that opened the app and should be validated and idempotent on that backend.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export type PrvtMiniAppTheme = {
|
|
2
|
+
colorScheme: "dark";
|
|
3
|
+
backgroundColor: string;
|
|
4
|
+
accentColor: string;
|
|
5
|
+
};
|
|
6
|
+
export type PrvtMiniAppContext = {
|
|
7
|
+
v: 1;
|
|
8
|
+
type: "init";
|
|
9
|
+
instanceId: string;
|
|
10
|
+
appUrl: string;
|
|
11
|
+
locale: "en" | "ru";
|
|
12
|
+
theme: PrvtMiniAppTheme;
|
|
13
|
+
participant: {
|
|
14
|
+
displayName: string;
|
|
15
|
+
};
|
|
16
|
+
capabilities: readonly ["request", "close"];
|
|
17
|
+
};
|
|
18
|
+
export type PrvtMiniAppOptions = {
|
|
19
|
+
hostOrigin?: string;
|
|
20
|
+
parentWindow?: Window;
|
|
21
|
+
requestTimeoutMs?: number;
|
|
22
|
+
};
|
|
23
|
+
export declare class PrvtMiniApp {
|
|
24
|
+
#private;
|
|
25
|
+
constructor(options?: PrvtMiniAppOptions);
|
|
26
|
+
ready(): Promise<PrvtMiniAppContext>;
|
|
27
|
+
request(action: string, payload?: unknown): Promise<unknown>;
|
|
28
|
+
close(): void;
|
|
29
|
+
dispose(): void;
|
|
30
|
+
}
|
|
31
|
+
export declare const createPrvtMiniApp: (options?: PrvtMiniAppOptions) => PrvtMiniApp;
|
|
32
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,CAAC,EAAE,CAAC,CAAC;IACL,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,IAAI,GAAG,IAAI,CAAC;IACpB,KAAK,EAAE,gBAAgB,CAAC;IACxB,WAAW,EAAE;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC;IACrC,YAAY,EAAE,SAAS,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;CAC7C,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AA6DF,qBAAa,WAAW;;gBAYV,OAAO,GAAE,kBAAuB;IAyCtC,KAAK,IAAI,OAAO,CAAC,kBAAkB,CAAC;IAIpC,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAiBlE,KAAK,IAAI,IAAI;IAMb,OAAO,IAAI,IAAI;CAShB;AAED,eAAO,MAAM,iBAAiB,GAAI,UAAU,kBAAkB,KAAG,WAAuC,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
const identifierPattern = /^[A-Za-z0-9_-]{8,128}$/;
|
|
2
|
+
const actionPattern = /^[A-Za-z0-9_.:-]{1,96}$/;
|
|
3
|
+
const encoder = new TextEncoder();
|
|
4
|
+
const isRecord = (value) => (typeof value === "object" && value !== null && !Array.isArray(value));
|
|
5
|
+
const isJsonValue = (value) => {
|
|
6
|
+
if (value === null || typeof value === "string" || typeof value === "boolean")
|
|
7
|
+
return true;
|
|
8
|
+
if (typeof value === "number")
|
|
9
|
+
return Number.isFinite(value);
|
|
10
|
+
if (Array.isArray(value))
|
|
11
|
+
return value.every(isJsonValue);
|
|
12
|
+
return isRecord(value) && Object.values(value).every(isJsonValue);
|
|
13
|
+
};
|
|
14
|
+
const isSafeAppUrl = (value) => {
|
|
15
|
+
if (typeof value !== "string")
|
|
16
|
+
return false;
|
|
17
|
+
try {
|
|
18
|
+
const url = new URL(value);
|
|
19
|
+
return url.protocol === "https:" && url.username === "" && url.password === "" && url.search === "" && url.hash === "";
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
const isResponse = (value) => {
|
|
26
|
+
if (!isRecord(value) || value.v !== 1 || value.type !== "response")
|
|
27
|
+
return false;
|
|
28
|
+
return typeof value.instanceId === "string" && identifierPattern.test(value.instanceId)
|
|
29
|
+
&& typeof value.requestId === "string" && identifierPattern.test(value.requestId)
|
|
30
|
+
&& typeof value.ok === "boolean"
|
|
31
|
+
&& (value.ok
|
|
32
|
+
? value.error === undefined
|
|
33
|
+
: typeof value.error === "string" && value.error.trim().length > 0 && value.error.length <= 256)
|
|
34
|
+
&& (value.result === undefined || isJsonValue(value.result));
|
|
35
|
+
};
|
|
36
|
+
const isInit = (value) => {
|
|
37
|
+
if (!isRecord(value) || value.v !== 1 || value.type !== "init")
|
|
38
|
+
return false;
|
|
39
|
+
return typeof value.instanceId === "string" && identifierPattern.test(value.instanceId)
|
|
40
|
+
&& isSafeAppUrl(value.appUrl)
|
|
41
|
+
&& (value.locale === "en" || value.locale === "ru")
|
|
42
|
+
&& isRecord(value.theme) && value.theme.colorScheme === "dark"
|
|
43
|
+
&& typeof value.theme.backgroundColor === "string" && typeof value.theme.accentColor === "string"
|
|
44
|
+
&& isRecord(value.participant) && typeof value.participant.displayName === "string"
|
|
45
|
+
&& Array.isArray(value.capabilities) && value.capabilities.length === 2
|
|
46
|
+
&& value.capabilities[0] === "request" && value.capabilities[1] === "close";
|
|
47
|
+
};
|
|
48
|
+
export class PrvtMiniApp {
|
|
49
|
+
#parentWindow;
|
|
50
|
+
#hostOrigin;
|
|
51
|
+
#requestTimeoutMs;
|
|
52
|
+
#pending = new Map();
|
|
53
|
+
#readyPromise;
|
|
54
|
+
#resolveReady;
|
|
55
|
+
#rejectReady;
|
|
56
|
+
#context = null;
|
|
57
|
+
#connectedOrigin = null;
|
|
58
|
+
#messageHandler;
|
|
59
|
+
constructor(options = {}) {
|
|
60
|
+
if (typeof window === "undefined")
|
|
61
|
+
throw new Error("@prvt/mini-app-sdk requires a browser");
|
|
62
|
+
this.#parentWindow = options.parentWindow ?? window.parent;
|
|
63
|
+
this.#hostOrigin = options.hostOrigin ?? "*";
|
|
64
|
+
this.#requestTimeoutMs = options.requestTimeoutMs ?? 15_000;
|
|
65
|
+
if (this.#hostOrigin !== "*") {
|
|
66
|
+
let parsedOrigin;
|
|
67
|
+
try {
|
|
68
|
+
parsedOrigin = new URL(this.#hostOrigin);
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
throw new TypeError("hostOrigin must be an HTTPS origin");
|
|
72
|
+
}
|
|
73
|
+
if (parsedOrigin.protocol !== "https:" || parsedOrigin.origin !== this.#hostOrigin)
|
|
74
|
+
throw new TypeError("hostOrigin must be an HTTPS origin");
|
|
75
|
+
}
|
|
76
|
+
this.#readyPromise = new Promise((resolve, reject) => {
|
|
77
|
+
this.#resolveReady = resolve;
|
|
78
|
+
this.#rejectReady = reject;
|
|
79
|
+
});
|
|
80
|
+
this.#messageHandler = (event) => {
|
|
81
|
+
if (event.source !== this.#parentWindow)
|
|
82
|
+
return;
|
|
83
|
+
if (this.#context === null) {
|
|
84
|
+
if (!isInit(event.data))
|
|
85
|
+
return;
|
|
86
|
+
if (this.#hostOrigin !== "*" && event.origin !== this.#hostOrigin)
|
|
87
|
+
return;
|
|
88
|
+
this.#context = event.data;
|
|
89
|
+
this.#connectedOrigin = event.origin;
|
|
90
|
+
this.#resolveReady(event.data);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (event.origin !== this.#connectedOrigin)
|
|
94
|
+
return;
|
|
95
|
+
if (!isResponse(event.data) || event.data.instanceId !== this.#context.instanceId)
|
|
96
|
+
return;
|
|
97
|
+
const pending = this.#pending.get(event.data.requestId);
|
|
98
|
+
if (!pending)
|
|
99
|
+
return;
|
|
100
|
+
this.#pending.delete(event.data.requestId);
|
|
101
|
+
window.clearTimeout(pending.timeout);
|
|
102
|
+
if (event.data.ok)
|
|
103
|
+
pending.resolve(event.data.result);
|
|
104
|
+
else
|
|
105
|
+
pending.reject(new Error(event.data.error ?? "The app action failed"));
|
|
106
|
+
};
|
|
107
|
+
window.addEventListener("message", this.#messageHandler);
|
|
108
|
+
this.#parentWindow.postMessage({ v: 1, type: "ready" }, this.#hostOrigin);
|
|
109
|
+
}
|
|
110
|
+
async ready() {
|
|
111
|
+
return this.#readyPromise;
|
|
112
|
+
}
|
|
113
|
+
async request(action, payload) {
|
|
114
|
+
const context = await this.ready();
|
|
115
|
+
if (!actionPattern.test(action))
|
|
116
|
+
throw new TypeError("action must use 1 to 96 letters, numbers, underscores, dots, colons, or hyphens");
|
|
117
|
+
if (payload !== undefined && !isJsonValue(payload))
|
|
118
|
+
throw new TypeError("payload must be JSON");
|
|
119
|
+
const requestId = crypto.randomUUID().replaceAll("-", "");
|
|
120
|
+
const message = { v: 1, type: "request", instanceId: context.instanceId, requestId, action, ...(payload === undefined ? {} : { payload }) };
|
|
121
|
+
if (encoder.encode(JSON.stringify(message)).byteLength > 8_192)
|
|
122
|
+
throw new TypeError("request is too large");
|
|
123
|
+
return new Promise((resolve, reject) => {
|
|
124
|
+
const timeout = window.setTimeout(() => {
|
|
125
|
+
this.#pending.delete(requestId);
|
|
126
|
+
reject(new Error("The host did not respond in time"));
|
|
127
|
+
}, this.#requestTimeoutMs);
|
|
128
|
+
this.#pending.set(requestId, { resolve, reject, timeout });
|
|
129
|
+
this.#parentWindow.postMessage(message, this.#connectedOrigin);
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
close() {
|
|
133
|
+
const targetOrigin = this.#connectedOrigin ?? this.#hostOrigin;
|
|
134
|
+
this.#parentWindow.postMessage({ v: 1, type: "close" }, targetOrigin);
|
|
135
|
+
this.dispose();
|
|
136
|
+
}
|
|
137
|
+
dispose() {
|
|
138
|
+
window.removeEventListener("message", this.#messageHandler);
|
|
139
|
+
for (const pending of this.#pending.values()) {
|
|
140
|
+
window.clearTimeout(pending.timeout);
|
|
141
|
+
pending.reject(new Error("The app was disposed"));
|
|
142
|
+
}
|
|
143
|
+
this.#pending.clear();
|
|
144
|
+
if (this.#context === null)
|
|
145
|
+
this.#rejectReady(new Error("The app was disposed"));
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
export const createPrvtMiniApp = (options) => new PrvtMiniApp(options);
|
|
149
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAkCA,MAAM,iBAAiB,GAAG,wBAAwB,CAAC;AACnD,MAAM,aAAa,GAAG,yBAAyB,CAAC;AAChD,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;AAElC,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAoC,EAAE,CAAC,CACrE,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CACrE,CAAC;AAEF,MAAM,WAAW,GAAG,CAAC,KAAc,EAAW,EAAE;IAC9C,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IAC3F,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC7D,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAC1D,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,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+
import { type PrvtMiniApp, type PrvtMiniAppOptions } from "./index.js";
|
|
2
|
+
declare global {
|
|
3
|
+
interface Window {
|
|
4
|
+
Prvt?: {
|
|
5
|
+
MiniApp: {
|
|
6
|
+
create(options?: PrvtMiniAppOptions): PrvtMiniApp;
|
|
7
|
+
version: string;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=standalone.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"standalone.d.ts","sourceRoot":"","sources":["../src/standalone.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,WAAW,EAAE,KAAK,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAE1F,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,IAAI,CAAC,EAAE;YACL,OAAO,EAAE;gBACP,MAAM,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,WAAW,CAAC;gBAClD,OAAO,EAAE,MAAM,CAAC;aACjB,CAAC;SACH,CAAC;KACH;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"standalone.js","sourceRoot":"","sources":["../src/standalone.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAA6C,MAAM,YAAY,CAAC;AAa1F,MAAM,YAAY,GAAG,UAA2D,CAAC;AACjF,YAAY,CAAC,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC;IAChC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC;QACrB,MAAM,EAAE,iBAAiB;QACzB,OAAO,EAAE,OAAO;KACjB,CAAC;CACH,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@prvt/mini-app-sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Browser SDK for prvt room web apps.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"files": ["dist", "README.md"],
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"module": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.js",
|
|
15
|
+
"default": "./dist/index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"clean": "bun -e \"import { rm } from 'node:fs/promises'; await rm('dist', { recursive: true, force: true })\"",
|
|
20
|
+
"build": "bun run clean && tsc -p tsconfig.build.json",
|
|
21
|
+
"test": "bun test",
|
|
22
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
23
|
+
"prepack": "bun run build",
|
|
24
|
+
"prepublishOnly": "bun run test && bun run typecheck"
|
|
25
|
+
},
|
|
26
|
+
"engines": { "node": ">=18" },
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/bun": "^1.4.1",
|
|
29
|
+
"typescript": "^5.9.2"
|
|
30
|
+
},
|
|
31
|
+
"publishConfig": { "access": "public" },
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "git+https://github.com/yerofey/prvt.git",
|
|
35
|
+
"directory": "packages/mini-app-sdk"
|
|
36
|
+
},
|
|
37
|
+
"keywords": ["prvt", "mini-app", "iframe", "postmessage"]
|
|
38
|
+
}
|