@ambasada/sdk 0.8.2 → 0.8.3
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/dist/define.d.ts +22 -1
- package/dist/platform.d.ts +2 -1
- package/dist/platform.js +11 -0
- package/package.json +2 -2
package/dist/define.d.ts
CHANGED
|
@@ -2,18 +2,39 @@
|
|
|
2
2
|
* `ambasada.config.ts` (docs/PLATFORM.md §3). Types and checks only; the CLI reads the values
|
|
3
3
|
* (`ambasada dev`, `deploy`, `link`, `check`). Add-ons add their own keys (the village: `idea`, `offerings`, `agent`).
|
|
4
4
|
*/
|
|
5
|
+
/**
|
|
6
|
+
* The app's Ambasada mini app (docs/MINI-APPS.md §15, decision 15.6): optional. With it, `ambasada dev` and `deploy`
|
|
7
|
+
* serve /.well-known/ambasada.json (from this and `id`, `name`, `description`), `ambasada check` runs the mini-app
|
|
8
|
+
* rules on the entry, and the deploy registers the app with the Ambasada app. `ambasada miniapp enable` adds it.
|
|
9
|
+
*/
|
|
10
|
+
export interface MiniAppConfig {
|
|
11
|
+
/** The path the Ambasada app opens: "/app" (the in-app layout under it), or "/" for the whole site. */
|
|
12
|
+
entry: string;
|
|
13
|
+
/** A 1024×1024 opaque PNG, a path on the app (default "/icon.png"). */
|
|
14
|
+
icon?: string;
|
|
15
|
+
/** Manifest fields beyond the defaults (docs/MINI-APPS.md §2). */
|
|
16
|
+
category?: "shopping" | "food" | "events" | "tools" | "learning" | "community" | "games" | "finance" | "other";
|
|
17
|
+
accent?: string;
|
|
18
|
+
/** What the app asks the shell for (default: identity and notifications, which the templates' routes serve). */
|
|
19
|
+
scopes?: ("identity" | "notifications")[];
|
|
20
|
+
visibility?: "public" | "builders" | "unlisted" | `event:${string}`;
|
|
21
|
+
}
|
|
5
22
|
export interface AppConfig {
|
|
6
23
|
/** The app's slug (lowercase): it lives at https://<id>.ambasada.dev. */
|
|
7
24
|
id: string;
|
|
8
25
|
/** Display name. */
|
|
9
26
|
name: string;
|
|
10
|
-
/** One line about the app
|
|
27
|
+
/** One line about the app (the mini app's subtitle and description, when there is one). */
|
|
11
28
|
description?: string;
|
|
12
29
|
/** Where the app runs; `ambasada link` sets it when you host elsewhere. */
|
|
13
30
|
product?: {
|
|
14
31
|
url?: string;
|
|
15
32
|
};
|
|
33
|
+
/** The mini app inside the Ambasada app, at a path of this one. Off without it. */
|
|
34
|
+
miniapp?: MiniAppConfig;
|
|
16
35
|
/** Add-ons to load besides the ones found in node_modules (package names, e.g. "@ambasada/village"). */
|
|
17
36
|
addons?: string[];
|
|
18
37
|
}
|
|
38
|
+
/** A path the mini app may open at: absolute, no query, hash, `..` or `//`. */
|
|
39
|
+
export declare const MINIAPP_ENTRY: RegExp;
|
|
19
40
|
export declare function defineApp<T extends AppConfig>(config: T): T;
|
package/dist/platform.d.ts
CHANGED
|
@@ -10,7 +10,8 @@ export type * from "./types.js";
|
|
|
10
10
|
export { getHeader } from "./headers.js";
|
|
11
11
|
export type { HeaderSource } from "./headers.js";
|
|
12
12
|
export { defineApp } from "./define.js";
|
|
13
|
-
export
|
|
13
|
+
export { MINIAPP_ENTRY } from "./define.js";
|
|
14
|
+
export type { AppConfig, MiniAppConfig } from "./define.js";
|
|
14
15
|
export { AmbasadaAuth, AUTH_PATHS, JWKS_TTL_MS, SESSION_TTL_S } from "./auth.js";
|
|
15
16
|
export type { AmbasadaUser, AuthConfig, LoginOptions, ShellUser, WithHeaders } from "./auth.js";
|
|
16
17
|
export { AmbasadaApps, APP_SIGNATURE_HEADER, APP_TIMESTAMP_HEADER, appWebhookHeaders, signAppWebhook } from "./apps.js";
|
package/dist/platform.js
CHANGED
|
@@ -777,8 +777,18 @@ function getHeader(headers, name) {
|
|
|
777
777
|
}
|
|
778
778
|
|
|
779
779
|
// src/define.ts
|
|
780
|
+
var MINIAPP_ENTRY = /^\/(?:[A-Za-z0-9._~-]+(?:\/[A-Za-z0-9._~-]+)*)?$/;
|
|
780
781
|
function defineApp(config) {
|
|
781
782
|
if (typeof config.id !== "string" || !/^[a-z0-9][a-z0-9-]{0,62}$/.test(config.id)) throw new Error(`app id "${String(config.id)}" must be a lowercase slug (a-z, 0-9, -)`);
|
|
783
|
+
const m = config.miniapp;
|
|
784
|
+
if (m !== void 0) {
|
|
785
|
+
if (!m || typeof m !== "object") throw new Error(`${config.id}: miniapp must be { entry: "/app" }`);
|
|
786
|
+
if (typeof m.entry !== "string" || !MINIAPP_ENTRY.test(m.entry) || m.entry.split("/").includes("..")) {
|
|
787
|
+
throw new Error(`${config.id}: miniapp.entry must be a path like "/app" or "/" (got ${JSON.stringify(m.entry)})`);
|
|
788
|
+
}
|
|
789
|
+
if (m.icon !== void 0 && (typeof m.icon !== "string" || !m.icon.startsWith("/"))) throw new Error(`${config.id}: miniapp.icon must be a path like "/icon.png"`);
|
|
790
|
+
if (m.accent !== void 0 && !/^#[0-9a-fA-F]{6}$/.test(m.accent)) throw new Error(`${config.id}: miniapp.accent must be a #RRGGBB colour`);
|
|
791
|
+
}
|
|
782
792
|
return config;
|
|
783
793
|
}
|
|
784
794
|
|
|
@@ -796,6 +806,7 @@ export {
|
|
|
796
806
|
DEFAULT_API_URL,
|
|
797
807
|
ERROR_STATUS,
|
|
798
808
|
JWKS_TTL_MS,
|
|
809
|
+
MINIAPP_ENTRY,
|
|
799
810
|
SESSION_TTL_S,
|
|
800
811
|
WebhookInvalidError,
|
|
801
812
|
ambasada,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ambasada/sdk",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.3",
|
|
4
4
|
"description": "The Ambasada platform SDK: Sign in with Ambasada, mini-app notifications, the project store, files.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"node": ">=22"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@ambasada/village": "^0.8.
|
|
30
|
+
"@ambasada/village": "^0.8.3"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/node": "^22.20.5",
|