@ai-matrx/kit 0.5.1 → 0.6.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 +15 -0
- package/dist/confirm.cjs +2 -1
- package/dist/confirm.cjs.map +1 -1
- package/dist/confirm.js +2 -1
- package/dist/confirm.js.map +1 -1
- package/dist/index.cjs +2 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/react-tree.cjs +2 -1
- package/dist/react-tree.cjs.map +1 -1
- package/dist/react-tree.js +2 -1
- package/dist/react-tree.js.map +1 -1
- package/dist/short-link-react.cjs +159 -0
- package/dist/short-link-react.cjs.map +1 -0
- package/dist/short-link-react.d.cts +59 -0
- package/dist/short-link-react.d.ts +59 -0
- package/dist/short-link-react.js +139 -0
- package/dist/short-link-react.js.map +1 -0
- package/dist/short-link.cjs +97 -0
- package/dist/short-link.cjs.map +1 -0
- package/dist/short-link.d.cts +94 -0
- package/dist/short-link.d.ts +94 -0
- package/dist/short-link.js +76 -0
- package/dist/short-link.js.map +1 -0
- package/package.json +23 -2
|
@@ -0,0 +1,97 @@
|
|
|
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
|
+
|
|
20
|
+
// src/short-link.ts
|
|
21
|
+
var short_link_exports = {};
|
|
22
|
+
__export(short_link_exports, {
|
|
23
|
+
SHORT_LINK_PATH_PREFIX: () => SHORT_LINK_PATH_PREFIX,
|
|
24
|
+
SHORT_LINK_TOKEN_ALPHABET: () => SHORT_LINK_TOKEN_ALPHABET,
|
|
25
|
+
SHORT_LINK_TOKEN_LENGTH: () => SHORT_LINK_TOKEN_LENGTH,
|
|
26
|
+
isShortLinkToken: () => isShortLinkToken,
|
|
27
|
+
mintShortLink: () => mintShortLink,
|
|
28
|
+
normalizeShortLinkToken: () => normalizeShortLinkToken,
|
|
29
|
+
resolveShortLinkPath: () => resolveShortLinkPath,
|
|
30
|
+
shortLinkPath: () => shortLinkPath,
|
|
31
|
+
shortLinkUrl: () => shortLinkUrl
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(short_link_exports);
|
|
34
|
+
var SHORT_LINK_TOKEN_ALPHABET = "23456789abcdefghijkmnpqrstuvwxyz";
|
|
35
|
+
var SHORT_LINK_TOKEN_LENGTH = 10;
|
|
36
|
+
var SHORT_LINK_PATH_PREFIX = "/r/";
|
|
37
|
+
var TOKEN_RE = new RegExp(`^[${SHORT_LINK_TOKEN_ALPHABET}]{${SHORT_LINK_TOKEN_LENGTH}}$`);
|
|
38
|
+
function normalizeShortLinkToken(candidate) {
|
|
39
|
+
const token = (candidate ?? "").trim().toLowerCase();
|
|
40
|
+
return TOKEN_RE.test(token) ? token : null;
|
|
41
|
+
}
|
|
42
|
+
function isShortLinkToken(candidate) {
|
|
43
|
+
return normalizeShortLinkToken(candidate) !== null;
|
|
44
|
+
}
|
|
45
|
+
function shortLinkPath(token) {
|
|
46
|
+
const normalized = normalizeShortLinkToken(token);
|
|
47
|
+
if (!normalized) {
|
|
48
|
+
throw new Error(
|
|
49
|
+
`shortLinkPath: ${JSON.stringify(token)} is not a short-link token (${SHORT_LINK_TOKEN_LENGTH} chars of "${SHORT_LINK_TOKEN_ALPHABET}")`
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
return `${SHORT_LINK_PATH_PREFIX}${normalized}`;
|
|
53
|
+
}
|
|
54
|
+
function shortLinkUrl(origin, token) {
|
|
55
|
+
return `${origin.replace(/\/+$/, "")}${shortLinkPath(token)}`;
|
|
56
|
+
}
|
|
57
|
+
function resolveOrigin(origin) {
|
|
58
|
+
if (origin) return origin;
|
|
59
|
+
if (typeof window !== "undefined" && window.location?.origin) {
|
|
60
|
+
return window.location.origin;
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
async function mintShortLink(client, options) {
|
|
65
|
+
if (!options.path.startsWith("/") || options.path.startsWith("//")) {
|
|
66
|
+
return { ok: false, error: "Only a same-app path (starting with a single '/') can be shortened" };
|
|
67
|
+
}
|
|
68
|
+
const origin = resolveOrigin(options.origin);
|
|
69
|
+
if (!origin) {
|
|
70
|
+
return { ok: false, error: "No origin: pass options.origin outside a browser" };
|
|
71
|
+
}
|
|
72
|
+
const { data, error } = await client.rpc("shorten_app_url", {
|
|
73
|
+
p_path: options.path,
|
|
74
|
+
p_organization_id: options.organizationId,
|
|
75
|
+
...options.expiresAt ? { p_expires_at: options.expiresAt } : {}
|
|
76
|
+
});
|
|
77
|
+
if (error) return { ok: false, error: error.message };
|
|
78
|
+
const result = data;
|
|
79
|
+
const token = result?.ok ? normalizeShortLinkToken(result.token) : null;
|
|
80
|
+
if (!token) {
|
|
81
|
+
return { ok: false, error: result?.error ?? "The mint door returned no token" };
|
|
82
|
+
}
|
|
83
|
+
return { ok: true, token, path: shortLinkPath(token), url: shortLinkUrl(origin, token) };
|
|
84
|
+
}
|
|
85
|
+
async function resolveShortLinkPath(client, token) {
|
|
86
|
+
const normalized = normalizeShortLinkToken(token);
|
|
87
|
+
if (!normalized) return { ok: false };
|
|
88
|
+
const { data, error } = await client.rpc("resolve_short_link", { p_token: normalized });
|
|
89
|
+
if (error) return { ok: false };
|
|
90
|
+
const result = data;
|
|
91
|
+
const targetPath = result?.ok ? result.target_path : void 0;
|
|
92
|
+
if (!targetPath || !targetPath.startsWith("/") || targetPath.startsWith("//")) {
|
|
93
|
+
return { ok: false };
|
|
94
|
+
}
|
|
95
|
+
return { ok: true, targetPath };
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=short-link.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/short-link.ts"],"sourcesContent":["/**\n * @ai-matrx/kit/short-link — the platform short-link CONTRACT, in one place.\n *\n * The primitive itself lives in the database (migration `0557_platform_short_links`):\n * `platform.short_links` holds `token → same-app path`, org-scoped and expiring;\n * `platform.create_short_link` mints (server-side only); `public.resolve_short_link`\n * resolves (anon-callable; answers with a PATH, never content — the target route's\n * own auth gates everything). The frontend redirect route is `/r/[token]`\n * (matrx-frontend `app/(public)/r/[token]`), and the notification spine mints per\n * SMS leg (aidream `services/notifications/short_links.py`).\n *\n * This module is the shared vocabulary every client needs to speak about those\n * tokens — alphabet, length, validation, and the URL shape — so no consumer ever\n * re-declares it. 🚨 `SHORT_LINK_TOKEN_ALPHABET` and `SHORT_LINK_TOKEN_LENGTH`\n * mirror `platform.create_short_link` EXACTLY; change one and you change both.\n *\n * 🚨 A short link is a URL, not a permission. The primitive that grants\n * anonymous access to content is `platform.share_links` (`/s/[token]`, 64-hex\n * tokens) — a different system, deliberately. Never shorten by minting a share\n * link, and never share by minting a short link.\n *\n * Pure logic — no DOM, no React, no network; safe in Server Components, route\n * handlers, workers, and Node scripts.\n */\n\n/**\n * 32 characters: digits 2–9 plus a–z minus `l` and `o`. 256 % 32 = 0, so the\n * mint maps random bytes without modulo bias; lowercase-only survives channels\n * that case-mangle (the resolver lowercases before lookup); the ambiguous\n * glyphs (`0/o`, `1/l`) never appear.\n */\nexport const SHORT_LINK_TOKEN_ALPHABET = \"23456789abcdefghijkmnpqrstuvwxyz\";\n\n/** 10 characters × 5 bits = 50 bits — unguessable at any realistic probe rate. */\nexport const SHORT_LINK_TOKEN_LENGTH = 10;\n\n/** The resolve route on the app origin (matrx-frontend `app/(public)/r/[token]`). */\nexport const SHORT_LINK_PATH_PREFIX = \"/r/\";\n\nconst TOKEN_RE = new RegExp(`^[${SHORT_LINK_TOKEN_ALPHABET}]{${SHORT_LINK_TOKEN_LENGTH}}$`);\n\n/**\n * Trim, lowercase, and shape-check a candidate token. Returns the normalized\n * token, or `null` for anything outside the contract — the resolver would\n * refuse it anyway, so callers can skip the round trip.\n */\nexport function normalizeShortLinkToken(candidate: string | null | undefined): string | null {\n const token = (candidate ?? \"\").trim().toLowerCase();\n return TOKEN_RE.test(token) ? token : null;\n}\n\n/** Whether a string is a well-formed short-link token (after normalization). */\nexport function isShortLinkToken(candidate: string | null | undefined): boolean {\n return normalizeShortLinkToken(candidate) !== null;\n}\n\n/** The app-relative path a token resolves at: `/r/<token>`. */\nexport function shortLinkPath(token: string): string {\n const normalized = normalizeShortLinkToken(token);\n if (!normalized) {\n throw new Error(\n `shortLinkPath: ${JSON.stringify(token)} is not a short-link token ` +\n `(${SHORT_LINK_TOKEN_LENGTH} chars of \"${SHORT_LINK_TOKEN_ALPHABET}\")`,\n );\n }\n return `${SHORT_LINK_PATH_PREFIX}${normalized}`;\n}\n\n/**\n * The absolute short URL for a token on a given origin, e.g.\n * `shortLinkUrl(\"https://app.aimatrx.com\", token)` → `https://app.aimatrx.com/r/<token>`.\n */\nexport function shortLinkUrl(origin: string, token: string): string {\n return `${origin.replace(/\\/+$/, \"\")}${shortLinkPath(token)}`;\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// The client half — the WHOLE mint/resolve logic, so a consumer adds nothing.\n//\n// Pass your Supabase client (or anything with a compatible `.rpc`) and you are\n// done: `mintShortLink(supabase, { path, organizationId })` calls the platform's\n// authenticated mint door (`public.shorten_app_url`, org-membership-gated) and\n// hands back the finished short URL; `resolveShortLinkPath(supabase, token)`\n// calls the anon resolver (`public.resolve_short_link`). No app writes its own\n// shortener logic, ever — the only thing outside this module is the shared\n// database that stores the tokens, which is exactly where shared state lives.\n// ─────────────────────────────────────────────────────────────────────────────\n\n/** Anything with a Supabase-shaped `.rpc` — pass the Supabase client itself. */\nexport interface ShortLinkClient {\n rpc(\n fn: string,\n args?: Record<string, unknown>,\n ): PromiseLike<{ data: unknown; error: { message: string } | null }>;\n}\n\nexport interface MintShortLinkOptions {\n /** Same-app path to shorten (must start with a single `/`). */\n path: string;\n /** The organization the link belongs to — the caller must be a member. */\n organizationId: string;\n /** ISO timestamp; the platform default (365 days) applies when omitted. */\n expiresAt?: string;\n /** Origin for the returned URL; defaults to `window.location.origin`. */\n origin?: string;\n}\n\nexport type MintShortLinkResult =\n | { ok: true; token: string; path: string; url: string }\n | { ok: false; error: string };\n\nfunction resolveOrigin(origin?: string): string | null {\n if (origin) return origin;\n if (typeof window !== \"undefined\" && window.location?.origin) {\n return window.location.origin;\n }\n return null;\n}\n\n/** Mint a short link through the platform's authenticated mint door. */\nexport async function mintShortLink(\n client: ShortLinkClient,\n options: MintShortLinkOptions,\n): Promise<MintShortLinkResult> {\n if (!options.path.startsWith(\"/\") || options.path.startsWith(\"//\")) {\n return { ok: false, error: \"Only a same-app path (starting with a single '/') can be shortened\" };\n }\n const origin = resolveOrigin(options.origin);\n if (!origin) {\n return { ok: false, error: \"No origin: pass options.origin outside a browser\" };\n }\n const { data, error } = await client.rpc(\"shorten_app_url\", {\n p_path: options.path,\n p_organization_id: options.organizationId,\n ...(options.expiresAt ? { p_expires_at: options.expiresAt } : {}),\n });\n if (error) return { ok: false, error: error.message };\n const result = data as { ok?: boolean; token?: string; error?: string } | null;\n const token = result?.ok ? normalizeShortLinkToken(result.token) : null;\n if (!token) {\n return { ok: false, error: result?.error ?? \"The mint door returned no token\" };\n }\n return { ok: true, token, path: shortLinkPath(token), url: shortLinkUrl(origin, token) };\n}\n\nexport type ResolveShortLinkResult =\n | { ok: true; targetPath: string }\n | { ok: false };\n\n/**\n * Resolve a short token to its target path through the anon resolver.\n * `{ok:false}` covers invalid, unknown, and expired identically — the platform\n * deliberately does not distinguish them.\n */\nexport async function resolveShortLinkPath(\n client: ShortLinkClient,\n token: string,\n): Promise<ResolveShortLinkResult> {\n const normalized = normalizeShortLinkToken(token);\n if (!normalized) return { ok: false };\n const { data, error } = await client.rpc(\"resolve_short_link\", { p_token: normalized });\n if (error) return { ok: false };\n const result = data as { ok?: boolean; target_path?: string } | null;\n const targetPath = result?.ok ? result.target_path : undefined;\n if (!targetPath || !targetPath.startsWith(\"/\") || targetPath.startsWith(\"//\")) {\n return { ok: false };\n }\n return { ok: true, targetPath };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA+BO,IAAM,4BAA4B;AAGlC,IAAM,0BAA0B;AAGhC,IAAM,yBAAyB;AAEtC,IAAM,WAAW,IAAI,OAAO,KAAK,yBAAyB,KAAK,uBAAuB,IAAI;AAOnF,SAAS,wBAAwB,WAAqD;AAC3F,QAAM,SAAS,aAAa,IAAI,KAAK,EAAE,YAAY;AACnD,SAAO,SAAS,KAAK,KAAK,IAAI,QAAQ;AACxC;AAGO,SAAS,iBAAiB,WAA+C;AAC9E,SAAO,wBAAwB,SAAS,MAAM;AAChD;AAGO,SAAS,cAAc,OAAuB;AACnD,QAAM,aAAa,wBAAwB,KAAK;AAChD,MAAI,CAAC,YAAY;AACf,UAAM,IAAI;AAAA,MACR,kBAAkB,KAAK,UAAU,KAAK,CAAC,+BACjC,uBAAuB,cAAc,yBAAyB;AAAA,IACtE;AAAA,EACF;AACA,SAAO,GAAG,sBAAsB,GAAG,UAAU;AAC/C;AAMO,SAAS,aAAa,QAAgB,OAAuB;AAClE,SAAO,GAAG,OAAO,QAAQ,QAAQ,EAAE,CAAC,GAAG,cAAc,KAAK,CAAC;AAC7D;AAqCA,SAAS,cAAc,QAAgC;AACrD,MAAI,OAAQ,QAAO;AACnB,MAAI,OAAO,WAAW,eAAe,OAAO,UAAU,QAAQ;AAC5D,WAAO,OAAO,SAAS;AAAA,EACzB;AACA,SAAO;AACT;AAGA,eAAsB,cACpB,QACA,SAC8B;AAC9B,MAAI,CAAC,QAAQ,KAAK,WAAW,GAAG,KAAK,QAAQ,KAAK,WAAW,IAAI,GAAG;AAClE,WAAO,EAAE,IAAI,OAAO,OAAO,qEAAqE;AAAA,EAClG;AACA,QAAM,SAAS,cAAc,QAAQ,MAAM;AAC3C,MAAI,CAAC,QAAQ;AACX,WAAO,EAAE,IAAI,OAAO,OAAO,mDAAmD;AAAA,EAChF;AACA,QAAM,EAAE,MAAM,MAAM,IAAI,MAAM,OAAO,IAAI,mBAAmB;AAAA,IAC1D,QAAQ,QAAQ;AAAA,IAChB,mBAAmB,QAAQ;AAAA,IAC3B,GAAI,QAAQ,YAAY,EAAE,cAAc,QAAQ,UAAU,IAAI,CAAC;AAAA,EACjE,CAAC;AACD,MAAI,MAAO,QAAO,EAAE,IAAI,OAAO,OAAO,MAAM,QAAQ;AACpD,QAAM,SAAS;AACf,QAAM,QAAQ,QAAQ,KAAK,wBAAwB,OAAO,KAAK,IAAI;AACnE,MAAI,CAAC,OAAO;AACV,WAAO,EAAE,IAAI,OAAO,OAAO,QAAQ,SAAS,kCAAkC;AAAA,EAChF;AACA,SAAO,EAAE,IAAI,MAAM,OAAO,MAAM,cAAc,KAAK,GAAG,KAAK,aAAa,QAAQ,KAAK,EAAE;AACzF;AAWA,eAAsB,qBACpB,QACA,OACiC;AACjC,QAAM,aAAa,wBAAwB,KAAK;AAChD,MAAI,CAAC,WAAY,QAAO,EAAE,IAAI,MAAM;AACpC,QAAM,EAAE,MAAM,MAAM,IAAI,MAAM,OAAO,IAAI,sBAAsB,EAAE,SAAS,WAAW,CAAC;AACtF,MAAI,MAAO,QAAO,EAAE,IAAI,MAAM;AAC9B,QAAM,SAAS;AACf,QAAM,aAAa,QAAQ,KAAK,OAAO,cAAc;AACrD,MAAI,CAAC,cAAc,CAAC,WAAW,WAAW,GAAG,KAAK,WAAW,WAAW,IAAI,GAAG;AAC7E,WAAO,EAAE,IAAI,MAAM;AAAA,EACrB;AACA,SAAO,EAAE,IAAI,MAAM,WAAW;AAChC;","names":[]}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @ai-matrx/kit/short-link — the platform short-link CONTRACT, in one place.
|
|
3
|
+
*
|
|
4
|
+
* The primitive itself lives in the database (migration `0557_platform_short_links`):
|
|
5
|
+
* `platform.short_links` holds `token → same-app path`, org-scoped and expiring;
|
|
6
|
+
* `platform.create_short_link` mints (server-side only); `public.resolve_short_link`
|
|
7
|
+
* resolves (anon-callable; answers with a PATH, never content — the target route's
|
|
8
|
+
* own auth gates everything). The frontend redirect route is `/r/[token]`
|
|
9
|
+
* (matrx-frontend `app/(public)/r/[token]`), and the notification spine mints per
|
|
10
|
+
* SMS leg (aidream `services/notifications/short_links.py`).
|
|
11
|
+
*
|
|
12
|
+
* This module is the shared vocabulary every client needs to speak about those
|
|
13
|
+
* tokens — alphabet, length, validation, and the URL shape — so no consumer ever
|
|
14
|
+
* re-declares it. 🚨 `SHORT_LINK_TOKEN_ALPHABET` and `SHORT_LINK_TOKEN_LENGTH`
|
|
15
|
+
* mirror `platform.create_short_link` EXACTLY; change one and you change both.
|
|
16
|
+
*
|
|
17
|
+
* 🚨 A short link is a URL, not a permission. The primitive that grants
|
|
18
|
+
* anonymous access to content is `platform.share_links` (`/s/[token]`, 64-hex
|
|
19
|
+
* tokens) — a different system, deliberately. Never shorten by minting a share
|
|
20
|
+
* link, and never share by minting a short link.
|
|
21
|
+
*
|
|
22
|
+
* Pure logic — no DOM, no React, no network; safe in Server Components, route
|
|
23
|
+
* handlers, workers, and Node scripts.
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* 32 characters: digits 2–9 plus a–z minus `l` and `o`. 256 % 32 = 0, so the
|
|
27
|
+
* mint maps random bytes without modulo bias; lowercase-only survives channels
|
|
28
|
+
* that case-mangle (the resolver lowercases before lookup); the ambiguous
|
|
29
|
+
* glyphs (`0/o`, `1/l`) never appear.
|
|
30
|
+
*/
|
|
31
|
+
declare const SHORT_LINK_TOKEN_ALPHABET = "23456789abcdefghijkmnpqrstuvwxyz";
|
|
32
|
+
/** 10 characters × 5 bits = 50 bits — unguessable at any realistic probe rate. */
|
|
33
|
+
declare const SHORT_LINK_TOKEN_LENGTH = 10;
|
|
34
|
+
/** The resolve route on the app origin (matrx-frontend `app/(public)/r/[token]`). */
|
|
35
|
+
declare const SHORT_LINK_PATH_PREFIX = "/r/";
|
|
36
|
+
/**
|
|
37
|
+
* Trim, lowercase, and shape-check a candidate token. Returns the normalized
|
|
38
|
+
* token, or `null` for anything outside the contract — the resolver would
|
|
39
|
+
* refuse it anyway, so callers can skip the round trip.
|
|
40
|
+
*/
|
|
41
|
+
declare function normalizeShortLinkToken(candidate: string | null | undefined): string | null;
|
|
42
|
+
/** Whether a string is a well-formed short-link token (after normalization). */
|
|
43
|
+
declare function isShortLinkToken(candidate: string | null | undefined): boolean;
|
|
44
|
+
/** The app-relative path a token resolves at: `/r/<token>`. */
|
|
45
|
+
declare function shortLinkPath(token: string): string;
|
|
46
|
+
/**
|
|
47
|
+
* The absolute short URL for a token on a given origin, e.g.
|
|
48
|
+
* `shortLinkUrl("https://app.aimatrx.com", token)` → `https://app.aimatrx.com/r/<token>`.
|
|
49
|
+
*/
|
|
50
|
+
declare function shortLinkUrl(origin: string, token: string): string;
|
|
51
|
+
/** Anything with a Supabase-shaped `.rpc` — pass the Supabase client itself. */
|
|
52
|
+
interface ShortLinkClient {
|
|
53
|
+
rpc(fn: string, args?: Record<string, unknown>): PromiseLike<{
|
|
54
|
+
data: unknown;
|
|
55
|
+
error: {
|
|
56
|
+
message: string;
|
|
57
|
+
} | null;
|
|
58
|
+
}>;
|
|
59
|
+
}
|
|
60
|
+
interface MintShortLinkOptions {
|
|
61
|
+
/** Same-app path to shorten (must start with a single `/`). */
|
|
62
|
+
path: string;
|
|
63
|
+
/** The organization the link belongs to — the caller must be a member. */
|
|
64
|
+
organizationId: string;
|
|
65
|
+
/** ISO timestamp; the platform default (365 days) applies when omitted. */
|
|
66
|
+
expiresAt?: string;
|
|
67
|
+
/** Origin for the returned URL; defaults to `window.location.origin`. */
|
|
68
|
+
origin?: string;
|
|
69
|
+
}
|
|
70
|
+
type MintShortLinkResult = {
|
|
71
|
+
ok: true;
|
|
72
|
+
token: string;
|
|
73
|
+
path: string;
|
|
74
|
+
url: string;
|
|
75
|
+
} | {
|
|
76
|
+
ok: false;
|
|
77
|
+
error: string;
|
|
78
|
+
};
|
|
79
|
+
/** Mint a short link through the platform's authenticated mint door. */
|
|
80
|
+
declare function mintShortLink(client: ShortLinkClient, options: MintShortLinkOptions): Promise<MintShortLinkResult>;
|
|
81
|
+
type ResolveShortLinkResult = {
|
|
82
|
+
ok: true;
|
|
83
|
+
targetPath: string;
|
|
84
|
+
} | {
|
|
85
|
+
ok: false;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Resolve a short token to its target path through the anon resolver.
|
|
89
|
+
* `{ok:false}` covers invalid, unknown, and expired identically — the platform
|
|
90
|
+
* deliberately does not distinguish them.
|
|
91
|
+
*/
|
|
92
|
+
declare function resolveShortLinkPath(client: ShortLinkClient, token: string): Promise<ResolveShortLinkResult>;
|
|
93
|
+
|
|
94
|
+
export { type MintShortLinkOptions, type MintShortLinkResult, type ResolveShortLinkResult, SHORT_LINK_PATH_PREFIX, SHORT_LINK_TOKEN_ALPHABET, SHORT_LINK_TOKEN_LENGTH, type ShortLinkClient, isShortLinkToken, mintShortLink, normalizeShortLinkToken, resolveShortLinkPath, shortLinkPath, shortLinkUrl };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @ai-matrx/kit/short-link — the platform short-link CONTRACT, in one place.
|
|
3
|
+
*
|
|
4
|
+
* The primitive itself lives in the database (migration `0557_platform_short_links`):
|
|
5
|
+
* `platform.short_links` holds `token → same-app path`, org-scoped and expiring;
|
|
6
|
+
* `platform.create_short_link` mints (server-side only); `public.resolve_short_link`
|
|
7
|
+
* resolves (anon-callable; answers with a PATH, never content — the target route's
|
|
8
|
+
* own auth gates everything). The frontend redirect route is `/r/[token]`
|
|
9
|
+
* (matrx-frontend `app/(public)/r/[token]`), and the notification spine mints per
|
|
10
|
+
* SMS leg (aidream `services/notifications/short_links.py`).
|
|
11
|
+
*
|
|
12
|
+
* This module is the shared vocabulary every client needs to speak about those
|
|
13
|
+
* tokens — alphabet, length, validation, and the URL shape — so no consumer ever
|
|
14
|
+
* re-declares it. 🚨 `SHORT_LINK_TOKEN_ALPHABET` and `SHORT_LINK_TOKEN_LENGTH`
|
|
15
|
+
* mirror `platform.create_short_link` EXACTLY; change one and you change both.
|
|
16
|
+
*
|
|
17
|
+
* 🚨 A short link is a URL, not a permission. The primitive that grants
|
|
18
|
+
* anonymous access to content is `platform.share_links` (`/s/[token]`, 64-hex
|
|
19
|
+
* tokens) — a different system, deliberately. Never shorten by minting a share
|
|
20
|
+
* link, and never share by minting a short link.
|
|
21
|
+
*
|
|
22
|
+
* Pure logic — no DOM, no React, no network; safe in Server Components, route
|
|
23
|
+
* handlers, workers, and Node scripts.
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* 32 characters: digits 2–9 plus a–z minus `l` and `o`. 256 % 32 = 0, so the
|
|
27
|
+
* mint maps random bytes without modulo bias; lowercase-only survives channels
|
|
28
|
+
* that case-mangle (the resolver lowercases before lookup); the ambiguous
|
|
29
|
+
* glyphs (`0/o`, `1/l`) never appear.
|
|
30
|
+
*/
|
|
31
|
+
declare const SHORT_LINK_TOKEN_ALPHABET = "23456789abcdefghijkmnpqrstuvwxyz";
|
|
32
|
+
/** 10 characters × 5 bits = 50 bits — unguessable at any realistic probe rate. */
|
|
33
|
+
declare const SHORT_LINK_TOKEN_LENGTH = 10;
|
|
34
|
+
/** The resolve route on the app origin (matrx-frontend `app/(public)/r/[token]`). */
|
|
35
|
+
declare const SHORT_LINK_PATH_PREFIX = "/r/";
|
|
36
|
+
/**
|
|
37
|
+
* Trim, lowercase, and shape-check a candidate token. Returns the normalized
|
|
38
|
+
* token, or `null` for anything outside the contract — the resolver would
|
|
39
|
+
* refuse it anyway, so callers can skip the round trip.
|
|
40
|
+
*/
|
|
41
|
+
declare function normalizeShortLinkToken(candidate: string | null | undefined): string | null;
|
|
42
|
+
/** Whether a string is a well-formed short-link token (after normalization). */
|
|
43
|
+
declare function isShortLinkToken(candidate: string | null | undefined): boolean;
|
|
44
|
+
/** The app-relative path a token resolves at: `/r/<token>`. */
|
|
45
|
+
declare function shortLinkPath(token: string): string;
|
|
46
|
+
/**
|
|
47
|
+
* The absolute short URL for a token on a given origin, e.g.
|
|
48
|
+
* `shortLinkUrl("https://app.aimatrx.com", token)` → `https://app.aimatrx.com/r/<token>`.
|
|
49
|
+
*/
|
|
50
|
+
declare function shortLinkUrl(origin: string, token: string): string;
|
|
51
|
+
/** Anything with a Supabase-shaped `.rpc` — pass the Supabase client itself. */
|
|
52
|
+
interface ShortLinkClient {
|
|
53
|
+
rpc(fn: string, args?: Record<string, unknown>): PromiseLike<{
|
|
54
|
+
data: unknown;
|
|
55
|
+
error: {
|
|
56
|
+
message: string;
|
|
57
|
+
} | null;
|
|
58
|
+
}>;
|
|
59
|
+
}
|
|
60
|
+
interface MintShortLinkOptions {
|
|
61
|
+
/** Same-app path to shorten (must start with a single `/`). */
|
|
62
|
+
path: string;
|
|
63
|
+
/** The organization the link belongs to — the caller must be a member. */
|
|
64
|
+
organizationId: string;
|
|
65
|
+
/** ISO timestamp; the platform default (365 days) applies when omitted. */
|
|
66
|
+
expiresAt?: string;
|
|
67
|
+
/** Origin for the returned URL; defaults to `window.location.origin`. */
|
|
68
|
+
origin?: string;
|
|
69
|
+
}
|
|
70
|
+
type MintShortLinkResult = {
|
|
71
|
+
ok: true;
|
|
72
|
+
token: string;
|
|
73
|
+
path: string;
|
|
74
|
+
url: string;
|
|
75
|
+
} | {
|
|
76
|
+
ok: false;
|
|
77
|
+
error: string;
|
|
78
|
+
};
|
|
79
|
+
/** Mint a short link through the platform's authenticated mint door. */
|
|
80
|
+
declare function mintShortLink(client: ShortLinkClient, options: MintShortLinkOptions): Promise<MintShortLinkResult>;
|
|
81
|
+
type ResolveShortLinkResult = {
|
|
82
|
+
ok: true;
|
|
83
|
+
targetPath: string;
|
|
84
|
+
} | {
|
|
85
|
+
ok: false;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Resolve a short token to its target path through the anon resolver.
|
|
89
|
+
* `{ok:false}` covers invalid, unknown, and expired identically — the platform
|
|
90
|
+
* deliberately does not distinguish them.
|
|
91
|
+
*/
|
|
92
|
+
declare function resolveShortLinkPath(client: ShortLinkClient, token: string): Promise<ResolveShortLinkResult>;
|
|
93
|
+
|
|
94
|
+
export { type MintShortLinkOptions, type MintShortLinkResult, type ResolveShortLinkResult, SHORT_LINK_PATH_PREFIX, SHORT_LINK_TOKEN_ALPHABET, SHORT_LINK_TOKEN_LENGTH, type ShortLinkClient, isShortLinkToken, mintShortLink, normalizeShortLinkToken, resolveShortLinkPath, shortLinkPath, shortLinkUrl };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// src/short-link.ts
|
|
2
|
+
var SHORT_LINK_TOKEN_ALPHABET = "23456789abcdefghijkmnpqrstuvwxyz";
|
|
3
|
+
var SHORT_LINK_TOKEN_LENGTH = 10;
|
|
4
|
+
var SHORT_LINK_PATH_PREFIX = "/r/";
|
|
5
|
+
var TOKEN_RE = new RegExp(`^[${SHORT_LINK_TOKEN_ALPHABET}]{${SHORT_LINK_TOKEN_LENGTH}}$`);
|
|
6
|
+
function normalizeShortLinkToken(candidate) {
|
|
7
|
+
const token = (candidate ?? "").trim().toLowerCase();
|
|
8
|
+
return TOKEN_RE.test(token) ? token : null;
|
|
9
|
+
}
|
|
10
|
+
function isShortLinkToken(candidate) {
|
|
11
|
+
return normalizeShortLinkToken(candidate) !== null;
|
|
12
|
+
}
|
|
13
|
+
function shortLinkPath(token) {
|
|
14
|
+
const normalized = normalizeShortLinkToken(token);
|
|
15
|
+
if (!normalized) {
|
|
16
|
+
throw new Error(
|
|
17
|
+
`shortLinkPath: ${JSON.stringify(token)} is not a short-link token (${SHORT_LINK_TOKEN_LENGTH} chars of "${SHORT_LINK_TOKEN_ALPHABET}")`
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
return `${SHORT_LINK_PATH_PREFIX}${normalized}`;
|
|
21
|
+
}
|
|
22
|
+
function shortLinkUrl(origin, token) {
|
|
23
|
+
return `${origin.replace(/\/+$/, "")}${shortLinkPath(token)}`;
|
|
24
|
+
}
|
|
25
|
+
function resolveOrigin(origin) {
|
|
26
|
+
if (origin) return origin;
|
|
27
|
+
if (typeof window !== "undefined" && window.location?.origin) {
|
|
28
|
+
return window.location.origin;
|
|
29
|
+
}
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
async function mintShortLink(client, options) {
|
|
33
|
+
if (!options.path.startsWith("/") || options.path.startsWith("//")) {
|
|
34
|
+
return { ok: false, error: "Only a same-app path (starting with a single '/') can be shortened" };
|
|
35
|
+
}
|
|
36
|
+
const origin = resolveOrigin(options.origin);
|
|
37
|
+
if (!origin) {
|
|
38
|
+
return { ok: false, error: "No origin: pass options.origin outside a browser" };
|
|
39
|
+
}
|
|
40
|
+
const { data, error } = await client.rpc("shorten_app_url", {
|
|
41
|
+
p_path: options.path,
|
|
42
|
+
p_organization_id: options.organizationId,
|
|
43
|
+
...options.expiresAt ? { p_expires_at: options.expiresAt } : {}
|
|
44
|
+
});
|
|
45
|
+
if (error) return { ok: false, error: error.message };
|
|
46
|
+
const result = data;
|
|
47
|
+
const token = result?.ok ? normalizeShortLinkToken(result.token) : null;
|
|
48
|
+
if (!token) {
|
|
49
|
+
return { ok: false, error: result?.error ?? "The mint door returned no token" };
|
|
50
|
+
}
|
|
51
|
+
return { ok: true, token, path: shortLinkPath(token), url: shortLinkUrl(origin, token) };
|
|
52
|
+
}
|
|
53
|
+
async function resolveShortLinkPath(client, token) {
|
|
54
|
+
const normalized = normalizeShortLinkToken(token);
|
|
55
|
+
if (!normalized) return { ok: false };
|
|
56
|
+
const { data, error } = await client.rpc("resolve_short_link", { p_token: normalized });
|
|
57
|
+
if (error) return { ok: false };
|
|
58
|
+
const result = data;
|
|
59
|
+
const targetPath = result?.ok ? result.target_path : void 0;
|
|
60
|
+
if (!targetPath || !targetPath.startsWith("/") || targetPath.startsWith("//")) {
|
|
61
|
+
return { ok: false };
|
|
62
|
+
}
|
|
63
|
+
return { ok: true, targetPath };
|
|
64
|
+
}
|
|
65
|
+
export {
|
|
66
|
+
SHORT_LINK_PATH_PREFIX,
|
|
67
|
+
SHORT_LINK_TOKEN_ALPHABET,
|
|
68
|
+
SHORT_LINK_TOKEN_LENGTH,
|
|
69
|
+
isShortLinkToken,
|
|
70
|
+
mintShortLink,
|
|
71
|
+
normalizeShortLinkToken,
|
|
72
|
+
resolveShortLinkPath,
|
|
73
|
+
shortLinkPath,
|
|
74
|
+
shortLinkUrl
|
|
75
|
+
};
|
|
76
|
+
//# sourceMappingURL=short-link.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/short-link.ts"],"sourcesContent":["/**\n * @ai-matrx/kit/short-link — the platform short-link CONTRACT, in one place.\n *\n * The primitive itself lives in the database (migration `0557_platform_short_links`):\n * `platform.short_links` holds `token → same-app path`, org-scoped and expiring;\n * `platform.create_short_link` mints (server-side only); `public.resolve_short_link`\n * resolves (anon-callable; answers with a PATH, never content — the target route's\n * own auth gates everything). The frontend redirect route is `/r/[token]`\n * (matrx-frontend `app/(public)/r/[token]`), and the notification spine mints per\n * SMS leg (aidream `services/notifications/short_links.py`).\n *\n * This module is the shared vocabulary every client needs to speak about those\n * tokens — alphabet, length, validation, and the URL shape — so no consumer ever\n * re-declares it. 🚨 `SHORT_LINK_TOKEN_ALPHABET` and `SHORT_LINK_TOKEN_LENGTH`\n * mirror `platform.create_short_link` EXACTLY; change one and you change both.\n *\n * 🚨 A short link is a URL, not a permission. The primitive that grants\n * anonymous access to content is `platform.share_links` (`/s/[token]`, 64-hex\n * tokens) — a different system, deliberately. Never shorten by minting a share\n * link, and never share by minting a short link.\n *\n * Pure logic — no DOM, no React, no network; safe in Server Components, route\n * handlers, workers, and Node scripts.\n */\n\n/**\n * 32 characters: digits 2–9 plus a–z minus `l` and `o`. 256 % 32 = 0, so the\n * mint maps random bytes without modulo bias; lowercase-only survives channels\n * that case-mangle (the resolver lowercases before lookup); the ambiguous\n * glyphs (`0/o`, `1/l`) never appear.\n */\nexport const SHORT_LINK_TOKEN_ALPHABET = \"23456789abcdefghijkmnpqrstuvwxyz\";\n\n/** 10 characters × 5 bits = 50 bits — unguessable at any realistic probe rate. */\nexport const SHORT_LINK_TOKEN_LENGTH = 10;\n\n/** The resolve route on the app origin (matrx-frontend `app/(public)/r/[token]`). */\nexport const SHORT_LINK_PATH_PREFIX = \"/r/\";\n\nconst TOKEN_RE = new RegExp(`^[${SHORT_LINK_TOKEN_ALPHABET}]{${SHORT_LINK_TOKEN_LENGTH}}$`);\n\n/**\n * Trim, lowercase, and shape-check a candidate token. Returns the normalized\n * token, or `null` for anything outside the contract — the resolver would\n * refuse it anyway, so callers can skip the round trip.\n */\nexport function normalizeShortLinkToken(candidate: string | null | undefined): string | null {\n const token = (candidate ?? \"\").trim().toLowerCase();\n return TOKEN_RE.test(token) ? token : null;\n}\n\n/** Whether a string is a well-formed short-link token (after normalization). */\nexport function isShortLinkToken(candidate: string | null | undefined): boolean {\n return normalizeShortLinkToken(candidate) !== null;\n}\n\n/** The app-relative path a token resolves at: `/r/<token>`. */\nexport function shortLinkPath(token: string): string {\n const normalized = normalizeShortLinkToken(token);\n if (!normalized) {\n throw new Error(\n `shortLinkPath: ${JSON.stringify(token)} is not a short-link token ` +\n `(${SHORT_LINK_TOKEN_LENGTH} chars of \"${SHORT_LINK_TOKEN_ALPHABET}\")`,\n );\n }\n return `${SHORT_LINK_PATH_PREFIX}${normalized}`;\n}\n\n/**\n * The absolute short URL for a token on a given origin, e.g.\n * `shortLinkUrl(\"https://app.aimatrx.com\", token)` → `https://app.aimatrx.com/r/<token>`.\n */\nexport function shortLinkUrl(origin: string, token: string): string {\n return `${origin.replace(/\\/+$/, \"\")}${shortLinkPath(token)}`;\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// The client half — the WHOLE mint/resolve logic, so a consumer adds nothing.\n//\n// Pass your Supabase client (or anything with a compatible `.rpc`) and you are\n// done: `mintShortLink(supabase, { path, organizationId })` calls the platform's\n// authenticated mint door (`public.shorten_app_url`, org-membership-gated) and\n// hands back the finished short URL; `resolveShortLinkPath(supabase, token)`\n// calls the anon resolver (`public.resolve_short_link`). No app writes its own\n// shortener logic, ever — the only thing outside this module is the shared\n// database that stores the tokens, which is exactly where shared state lives.\n// ─────────────────────────────────────────────────────────────────────────────\n\n/** Anything with a Supabase-shaped `.rpc` — pass the Supabase client itself. */\nexport interface ShortLinkClient {\n rpc(\n fn: string,\n args?: Record<string, unknown>,\n ): PromiseLike<{ data: unknown; error: { message: string } | null }>;\n}\n\nexport interface MintShortLinkOptions {\n /** Same-app path to shorten (must start with a single `/`). */\n path: string;\n /** The organization the link belongs to — the caller must be a member. */\n organizationId: string;\n /** ISO timestamp; the platform default (365 days) applies when omitted. */\n expiresAt?: string;\n /** Origin for the returned URL; defaults to `window.location.origin`. */\n origin?: string;\n}\n\nexport type MintShortLinkResult =\n | { ok: true; token: string; path: string; url: string }\n | { ok: false; error: string };\n\nfunction resolveOrigin(origin?: string): string | null {\n if (origin) return origin;\n if (typeof window !== \"undefined\" && window.location?.origin) {\n return window.location.origin;\n }\n return null;\n}\n\n/** Mint a short link through the platform's authenticated mint door. */\nexport async function mintShortLink(\n client: ShortLinkClient,\n options: MintShortLinkOptions,\n): Promise<MintShortLinkResult> {\n if (!options.path.startsWith(\"/\") || options.path.startsWith(\"//\")) {\n return { ok: false, error: \"Only a same-app path (starting with a single '/') can be shortened\" };\n }\n const origin = resolveOrigin(options.origin);\n if (!origin) {\n return { ok: false, error: \"No origin: pass options.origin outside a browser\" };\n }\n const { data, error } = await client.rpc(\"shorten_app_url\", {\n p_path: options.path,\n p_organization_id: options.organizationId,\n ...(options.expiresAt ? { p_expires_at: options.expiresAt } : {}),\n });\n if (error) return { ok: false, error: error.message };\n const result = data as { ok?: boolean; token?: string; error?: string } | null;\n const token = result?.ok ? normalizeShortLinkToken(result.token) : null;\n if (!token) {\n return { ok: false, error: result?.error ?? \"The mint door returned no token\" };\n }\n return { ok: true, token, path: shortLinkPath(token), url: shortLinkUrl(origin, token) };\n}\n\nexport type ResolveShortLinkResult =\n | { ok: true; targetPath: string }\n | { ok: false };\n\n/**\n * Resolve a short token to its target path through the anon resolver.\n * `{ok:false}` covers invalid, unknown, and expired identically — the platform\n * deliberately does not distinguish them.\n */\nexport async function resolveShortLinkPath(\n client: ShortLinkClient,\n token: string,\n): Promise<ResolveShortLinkResult> {\n const normalized = normalizeShortLinkToken(token);\n if (!normalized) return { ok: false };\n const { data, error } = await client.rpc(\"resolve_short_link\", { p_token: normalized });\n if (error) return { ok: false };\n const result = data as { ok?: boolean; target_path?: string } | null;\n const targetPath = result?.ok ? result.target_path : undefined;\n if (!targetPath || !targetPath.startsWith(\"/\") || targetPath.startsWith(\"//\")) {\n return { ok: false };\n }\n return { ok: true, targetPath };\n}\n"],"mappings":";AA+BO,IAAM,4BAA4B;AAGlC,IAAM,0BAA0B;AAGhC,IAAM,yBAAyB;AAEtC,IAAM,WAAW,IAAI,OAAO,KAAK,yBAAyB,KAAK,uBAAuB,IAAI;AAOnF,SAAS,wBAAwB,WAAqD;AAC3F,QAAM,SAAS,aAAa,IAAI,KAAK,EAAE,YAAY;AACnD,SAAO,SAAS,KAAK,KAAK,IAAI,QAAQ;AACxC;AAGO,SAAS,iBAAiB,WAA+C;AAC9E,SAAO,wBAAwB,SAAS,MAAM;AAChD;AAGO,SAAS,cAAc,OAAuB;AACnD,QAAM,aAAa,wBAAwB,KAAK;AAChD,MAAI,CAAC,YAAY;AACf,UAAM,IAAI;AAAA,MACR,kBAAkB,KAAK,UAAU,KAAK,CAAC,+BACjC,uBAAuB,cAAc,yBAAyB;AAAA,IACtE;AAAA,EACF;AACA,SAAO,GAAG,sBAAsB,GAAG,UAAU;AAC/C;AAMO,SAAS,aAAa,QAAgB,OAAuB;AAClE,SAAO,GAAG,OAAO,QAAQ,QAAQ,EAAE,CAAC,GAAG,cAAc,KAAK,CAAC;AAC7D;AAqCA,SAAS,cAAc,QAAgC;AACrD,MAAI,OAAQ,QAAO;AACnB,MAAI,OAAO,WAAW,eAAe,OAAO,UAAU,QAAQ;AAC5D,WAAO,OAAO,SAAS;AAAA,EACzB;AACA,SAAO;AACT;AAGA,eAAsB,cACpB,QACA,SAC8B;AAC9B,MAAI,CAAC,QAAQ,KAAK,WAAW,GAAG,KAAK,QAAQ,KAAK,WAAW,IAAI,GAAG;AAClE,WAAO,EAAE,IAAI,OAAO,OAAO,qEAAqE;AAAA,EAClG;AACA,QAAM,SAAS,cAAc,QAAQ,MAAM;AAC3C,MAAI,CAAC,QAAQ;AACX,WAAO,EAAE,IAAI,OAAO,OAAO,mDAAmD;AAAA,EAChF;AACA,QAAM,EAAE,MAAM,MAAM,IAAI,MAAM,OAAO,IAAI,mBAAmB;AAAA,IAC1D,QAAQ,QAAQ;AAAA,IAChB,mBAAmB,QAAQ;AAAA,IAC3B,GAAI,QAAQ,YAAY,EAAE,cAAc,QAAQ,UAAU,IAAI,CAAC;AAAA,EACjE,CAAC;AACD,MAAI,MAAO,QAAO,EAAE,IAAI,OAAO,OAAO,MAAM,QAAQ;AACpD,QAAM,SAAS;AACf,QAAM,QAAQ,QAAQ,KAAK,wBAAwB,OAAO,KAAK,IAAI;AACnE,MAAI,CAAC,OAAO;AACV,WAAO,EAAE,IAAI,OAAO,OAAO,QAAQ,SAAS,kCAAkC;AAAA,EAChF;AACA,SAAO,EAAE,IAAI,MAAM,OAAO,MAAM,cAAc,KAAK,GAAG,KAAK,aAAa,QAAQ,KAAK,EAAE;AACzF;AAWA,eAAsB,qBACpB,QACA,OACiC;AACjC,QAAM,aAAa,wBAAwB,KAAK;AAChD,MAAI,CAAC,WAAY,QAAO,EAAE,IAAI,MAAM;AACpC,QAAM,EAAE,MAAM,MAAM,IAAI,MAAM,OAAO,IAAI,sBAAsB,EAAE,SAAS,WAAW,CAAC;AACtF,MAAI,MAAO,QAAO,EAAE,IAAI,MAAM;AAC9B,QAAM,SAAS;AACf,QAAM,aAAa,QAAQ,KAAK,OAAO,cAAc;AACrD,MAAI,CAAC,cAAc,CAAC,WAAW,WAAW,GAAG,KAAK,WAAW,WAAW,IAAI,GAAG;AAC7E,WAAO,EAAE,IAAI,MAAM;AAAA,EACrB;AACA,SAAO,EAAE,IAAI,MAAM,WAAW;AAChC;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-matrx/kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "The always-include AI Matrx kit: the little primitives every Matrx app speaks — autosave that never loses a keystroke, stale-response guards, clipboard with graceful fallbacks — one per subpath, tree-shaken to what you use.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
"markdown-streaming",
|
|
22
22
|
"indexeddb",
|
|
23
23
|
"tailwind-colors",
|
|
24
|
-
"qr-code"
|
|
24
|
+
"qr-code",
|
|
25
|
+
"short-link"
|
|
25
26
|
],
|
|
26
27
|
"repository": {
|
|
27
28
|
"type": "git",
|
|
@@ -239,6 +240,26 @@
|
|
|
239
240
|
"types": "./dist/qr.d.cts",
|
|
240
241
|
"default": "./dist/qr.cjs"
|
|
241
242
|
}
|
|
243
|
+
},
|
|
244
|
+
"./short-link": {
|
|
245
|
+
"import": {
|
|
246
|
+
"types": "./dist/short-link.d.ts",
|
|
247
|
+
"default": "./dist/short-link.js"
|
|
248
|
+
},
|
|
249
|
+
"require": {
|
|
250
|
+
"types": "./dist/short-link.d.cts",
|
|
251
|
+
"default": "./dist/short-link.cjs"
|
|
252
|
+
}
|
|
253
|
+
},
|
|
254
|
+
"./short-link-react": {
|
|
255
|
+
"import": {
|
|
256
|
+
"types": "./dist/short-link-react.d.ts",
|
|
257
|
+
"default": "./dist/short-link-react.js"
|
|
258
|
+
},
|
|
259
|
+
"require": {
|
|
260
|
+
"types": "./dist/short-link-react.d.cts",
|
|
261
|
+
"default": "./dist/short-link-react.cjs"
|
|
262
|
+
}
|
|
242
263
|
}
|
|
243
264
|
},
|
|
244
265
|
"dependencies": {
|