@ambasada/sdk 0.8.4 → 0.8.5
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 +18 -0
- package/dist/platform.d.ts +1 -1
- package/dist/platform.js +18 -1
- package/package.json +2 -2
package/dist/define.d.ts
CHANGED
|
@@ -12,6 +12,18 @@ export interface MiniAppConfig {
|
|
|
12
12
|
entry: string;
|
|
13
13
|
/** A 1024×1024 opaque PNG, a path on the app (default "/icon.png"). */
|
|
14
14
|
icon?: string;
|
|
15
|
+
/** Who it is for (default "4+"). The hub refuses to register a mini app without one; above 12+ it opens only for people old enough. */
|
|
16
|
+
age_rating?: "4+" | "9+" | "12+" | "17+";
|
|
17
|
+
/** How the Ambasada app shows it (default "tool"). */
|
|
18
|
+
kind?: "product" | "event" | "tool" | "assistant";
|
|
19
|
+
/** Where people get help: "mailto:you@team.ro" or an https URL (default: the app's `support`). Needed to be Listed. */
|
|
20
|
+
support?: string;
|
|
21
|
+
/** Up to 5 search words. */
|
|
22
|
+
tags?: string[];
|
|
23
|
+
/** Under the name on the card (≤ 40; default: `description`, cut to one line). */
|
|
24
|
+
subtitle?: string;
|
|
25
|
+
/** The store description (≤ 170; default: the app's `description`). */
|
|
26
|
+
description?: string;
|
|
15
27
|
/** Manifest fields beyond the defaults (docs/MINI-APPS.md §2). */
|
|
16
28
|
category?: "shopping" | "food" | "events" | "tools" | "learning" | "community" | "games" | "finance" | "other";
|
|
17
29
|
accent?: string;
|
|
@@ -26,6 +38,8 @@ export interface AppConfig {
|
|
|
26
38
|
name: string;
|
|
27
39
|
/** One line about the app (the mini app's subtitle and description, when there is one). */
|
|
28
40
|
description?: string;
|
|
41
|
+
/** Where people get help: an email ("you@team.ro" or "mailto:…") or an https URL. The mini app's `support` by default. */
|
|
42
|
+
support?: string;
|
|
29
43
|
/** Where the app runs; `ambasada link` sets it when you host elsewhere. */
|
|
30
44
|
product?: {
|
|
31
45
|
url?: string;
|
|
@@ -35,6 +49,10 @@ export interface AppConfig {
|
|
|
35
49
|
/** Add-ons to load besides the ones found in node_modules (package names, e.g. "@ambasada/village"). */
|
|
36
50
|
addons?: string[];
|
|
37
51
|
}
|
|
52
|
+
export declare const MINIAPP_AGE_RATINGS: readonly ["4+", "9+", "12+", "17+"];
|
|
53
|
+
export declare const MINIAPP_KINDS: readonly ["product", "event", "tool", "assistant"];
|
|
54
|
+
/** "you@team.ro" → "mailto:you@team.ro"; mailto: and https URLs as they are; anything else undefined. */
|
|
55
|
+
export declare function supportUrl(value: string | undefined): string | undefined;
|
|
38
56
|
/** A path the mini app may open at: absolute, no query, hash, `..` or `//`. */
|
|
39
57
|
export declare const MINIAPP_ENTRY: RegExp;
|
|
40
58
|
export declare function defineApp<T extends AppConfig>(config: T): T;
|
package/dist/platform.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ 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 { MINIAPP_ENTRY } from "./define.js";
|
|
13
|
+
export { MINIAPP_AGE_RATINGS, MINIAPP_ENTRY, MINIAPP_KINDS, supportUrl } from "./define.js";
|
|
14
14
|
export type { AppConfig, MiniAppConfig } from "./define.js";
|
|
15
15
|
export { AmbasadaAuth, AUTH_PATHS, JWKS_TTL_MS, SESSION_TTL_S } from "./auth.js";
|
|
16
16
|
export type { AmbasadaUser, AuthConfig, LoginOptions, ShellUser, WithHeaders } from "./auth.js";
|
package/dist/platform.js
CHANGED
|
@@ -779,6 +779,15 @@ function getHeader(headers, name) {
|
|
|
779
779
|
}
|
|
780
780
|
|
|
781
781
|
// src/define.ts
|
|
782
|
+
var MINIAPP_AGE_RATINGS = ["4+", "9+", "12+", "17+"];
|
|
783
|
+
var MINIAPP_KINDS = ["product", "event", "tool", "assistant"];
|
|
784
|
+
function supportUrl(value) {
|
|
785
|
+
const v = value?.trim();
|
|
786
|
+
if (!v) return void 0;
|
|
787
|
+
if (/^mailto:[^@\s]+@[^@\s]+$/.test(v) || /^https:\/\/\S+$/.test(v)) return v;
|
|
788
|
+
if (/^[^@\s:/]+@[^@\s]+\.[^@\s]+$/.test(v)) return `mailto:${v}`;
|
|
789
|
+
return void 0;
|
|
790
|
+
}
|
|
782
791
|
var MINIAPP_ENTRY = /^\/(?:[A-Za-z0-9._~-]+(?:\/[A-Za-z0-9._~-]+)*)?$/;
|
|
783
792
|
function defineApp(config) {
|
|
784
793
|
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, -)`);
|
|
@@ -790,7 +799,12 @@ function defineApp(config) {
|
|
|
790
799
|
}
|
|
791
800
|
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"`);
|
|
792
801
|
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`);
|
|
802
|
+
if (m.age_rating !== void 0 && !MINIAPP_AGE_RATINGS.includes(m.age_rating)) throw new Error(`${config.id}: miniapp.age_rating must be one of ${MINIAPP_AGE_RATINGS.join(", ")} (got ${JSON.stringify(m.age_rating)})`);
|
|
803
|
+
if (m.kind !== void 0 && !MINIAPP_KINDS.includes(m.kind)) throw new Error(`${config.id}: miniapp.kind must be one of ${MINIAPP_KINDS.join(", ")} (got ${JSON.stringify(m.kind)})`);
|
|
804
|
+
if (m.support !== void 0 && !supportUrl(m.support)) throw new Error(`${config.id}: miniapp.support must be an email or an https URL (got ${JSON.stringify(m.support)})`);
|
|
805
|
+
if (m.tags !== void 0 && (!Array.isArray(m.tags) || m.tags.length > 5 || m.tags.some((t) => typeof t !== "string"))) throw new Error(`${config.id}: miniapp.tags must be up to 5 strings`);
|
|
793
806
|
}
|
|
807
|
+
if (config.support !== void 0 && !supportUrl(config.support)) throw new Error(`${config.id}: support must be an email or an https URL (got ${JSON.stringify(config.support)})`);
|
|
794
808
|
return config;
|
|
795
809
|
}
|
|
796
810
|
|
|
@@ -808,7 +822,9 @@ export {
|
|
|
808
822
|
DEFAULT_API_URL,
|
|
809
823
|
ERROR_STATUS,
|
|
810
824
|
JWKS_TTL_MS,
|
|
825
|
+
MINIAPP_AGE_RATINGS,
|
|
811
826
|
MINIAPP_ENTRY,
|
|
827
|
+
MINIAPP_KINDS,
|
|
812
828
|
SESSION_TTL_S,
|
|
813
829
|
WebhookInvalidError,
|
|
814
830
|
ambasada,
|
|
@@ -819,5 +835,6 @@ export {
|
|
|
819
835
|
errorFromResponse,
|
|
820
836
|
getHeader,
|
|
821
837
|
isAmbasadaError,
|
|
822
|
-
signAppWebhook2 as signAppWebhook
|
|
838
|
+
signAppWebhook2 as signAppWebhook,
|
|
839
|
+
supportUrl
|
|
823
840
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ambasada/sdk",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.5",
|
|
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.5"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/node": "^22.20.5",
|