@gamaro.io/core-types 1.1.3 → 2.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 +5 -5
- package/dist/application-config.d.ts +4 -3
- package/dist/application-config.js +4 -6
- package/dist/session.d.ts +0 -11
- package/dist/session.js +1 -15
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -42,7 +42,7 @@ B2B qualification, scoring rules, …) stay in the workspace that owns the domai
|
|
|
42
42
|
| `viewport` | Viewport bucket helpers (`mobile` / `tablet` / `desktop`) + breakpoints |
|
|
43
43
|
| `widget-config` | `WidgetConfig` — the public contract of `createWidget(config)` |
|
|
44
44
|
| `widget-runtime-config` | Internal runtime view of the resolved widget config (after server merge) |
|
|
45
|
-
| `application-config` | Server-side Agent metadata (
|
|
45
|
+
| `application-config` | Server-side Agent metadata (allowed origins, identity) |
|
|
46
46
|
| `postmessage` | Discriminated unions for `window.postMessage` host ↔ iframe protocol |
|
|
47
47
|
| `geo` | Lightweight geo primitives (`LatLng`, `BoundingBox`) |
|
|
48
48
|
| `motion` | Motion tokens (`MOTION_DURATIONS`, `MOTION_EASINGS`, `MOTION_STAGGER`) — ADR-018 |
|
|
@@ -68,10 +68,10 @@ Some helpers are exposed on a **dedicated subpath**, deliberately kept out of
|
|
|
68
68
|
the barrel above so they carry no `zod` dependency (import them directly, not
|
|
69
69
|
from the package root):
|
|
70
70
|
|
|
71
|
-
| Subpath | Contents
|
|
72
|
-
| ---------- |
|
|
73
|
-
| `/session` | `getApplicationSessionCookieName` (App-scoped, #3577), `
|
|
74
|
-
| `/motion` | Motion tokens — also re-exported from the root barrel (ADR-018)
|
|
71
|
+
| Subpath | Contents |
|
|
72
|
+
| ---------- | ------------------------------------------------------------------------------------------------------------ |
|
|
73
|
+
| `/session` | `getApplicationSessionCookieName` (App-scoped, #3577), `isValidSessionId` — pure session cookie / id helpers |
|
|
74
|
+
| `/motion` | Motion tokens — also re-exported from the root barrel (ADR-018) |
|
|
75
75
|
|
|
76
76
|
```typescript
|
|
77
77
|
import {
|
|
@@ -4,15 +4,16 @@
|
|
|
4
4
|
* The app (`apps/app`) produces this response through a stricter server-side
|
|
5
5
|
* whitelist schema (`publicApplicationConfigSchema` in the route), and the
|
|
6
6
|
* widget (`@gamaro.io/widget`) consumes it here. Keeping the widget-side Zod
|
|
7
|
-
* schema as the canonical shape prevents drift — the server
|
|
8
|
-
*
|
|
7
|
+
* schema as the canonical shape prevents drift — every response the server
|
|
8
|
+
* schema accepts MUST parse here (it may be stricter, never more permissive).
|
|
9
|
+
* A key the server still sends but this schema no longer declares is stripped
|
|
10
|
+
* on parse, which is how a field is retired across a major (#4161).
|
|
9
11
|
*/
|
|
10
12
|
import { z } from "zod";
|
|
11
13
|
export declare const applicationConfigResponseSchema: z.ZodObject<{
|
|
12
14
|
applicationId: z.ZodString;
|
|
13
15
|
applicationSlug: z.ZodString;
|
|
14
16
|
applicationName: z.ZodString;
|
|
15
|
-
vertical: z.ZodString;
|
|
16
17
|
theme: z.ZodNullable<z.ZodObject<{
|
|
17
18
|
primaryColor: z.ZodOptional<z.ZodString>;
|
|
18
19
|
backgroundColor: z.ZodOptional<z.ZodString>;
|
|
@@ -4,8 +4,10 @@
|
|
|
4
4
|
* The app (`apps/app`) produces this response through a stricter server-side
|
|
5
5
|
* whitelist schema (`publicApplicationConfigSchema` in the route), and the
|
|
6
6
|
* widget (`@gamaro.io/widget`) consumes it here. Keeping the widget-side Zod
|
|
7
|
-
* schema as the canonical shape prevents drift — the server
|
|
8
|
-
*
|
|
7
|
+
* schema as the canonical shape prevents drift — every response the server
|
|
8
|
+
* schema accepts MUST parse here (it may be stricter, never more permissive).
|
|
9
|
+
* A key the server still sends but this schema no longer declares is stripped
|
|
10
|
+
* on parse, which is how a field is retired across a major (#4161).
|
|
9
11
|
*/
|
|
10
12
|
import { z } from "zod";
|
|
11
13
|
import { themeConfigSchema } from "./theme";
|
|
@@ -17,10 +19,6 @@ export const applicationConfigResponseSchema = z.object({
|
|
|
17
19
|
.max(100)
|
|
18
20
|
.describe("Application slug (kebab-case)"),
|
|
19
21
|
applicationName: z.string().max(200).describe("Application display name"),
|
|
20
|
-
vertical: z
|
|
21
|
-
.string()
|
|
22
|
-
.max(50)
|
|
23
|
-
.describe("Deprecated: the widget no longer reads it. Still served for already-published widgets that validate it; removed in the next major."),
|
|
24
22
|
theme: themeConfigSchema.nullable().describe("Application theme"),
|
|
25
23
|
allowedOrigins: z
|
|
26
24
|
.array(z.string().max(200))
|
package/dist/session.d.ts
CHANGED
|
@@ -21,17 +21,6 @@
|
|
|
21
21
|
* Application UUID (`AuthContext.applicationId`), globally unique.
|
|
22
22
|
*/
|
|
23
23
|
export declare function getApplicationSessionCookieName(applicationId: string): string;
|
|
24
|
-
/**
|
|
25
|
-
* Per-vertical session cookie name — LEGACY (#918 → #3577).
|
|
26
|
-
*
|
|
27
|
-
* The server no longer reads, re-emits nor purges cookies under this name
|
|
28
|
-
* (#4119): every one of them expired. The export only survives because
|
|
29
|
-
* removing it is a breaking change of this package.
|
|
30
|
-
*
|
|
31
|
-
* @deprecated Use {@link getApplicationSessionCookieName}. No server reads
|
|
32
|
-
* this name any more; the export is removed in the next major.
|
|
33
|
-
*/
|
|
34
|
-
export declare function getSessionCookieName(verticalId: string): string;
|
|
35
24
|
/**
|
|
36
25
|
* Validate the UUID shape of a session id. The length pre-check is
|
|
37
26
|
* defense-in-depth (avoids running the regex on arbitrarily long strings).
|
package/dist/session.js
CHANGED
|
@@ -13,8 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
/**
|
|
15
15
|
* Any character outside `[a-z0-9-]` (case-insensitive) is sanitized to `_`
|
|
16
|
-
* (each char maps to one `_`, no collapsing)
|
|
17
|
-
* `gamaro_session_real-estate`.
|
|
16
|
+
* (each char maps to one `_`, no collapsing); a UUID passes through intact.
|
|
18
17
|
*/
|
|
19
18
|
function sanitizeCookieId(id) {
|
|
20
19
|
return id.replace(/[^a-z0-9-]/gi, "_");
|
|
@@ -31,19 +30,6 @@ function sanitizeCookieId(id) {
|
|
|
31
30
|
export function getApplicationSessionCookieName(applicationId) {
|
|
32
31
|
return `gamaro_session_${sanitizeCookieId(applicationId)}`;
|
|
33
32
|
}
|
|
34
|
-
/**
|
|
35
|
-
* Per-vertical session cookie name — LEGACY (#918 → #3577).
|
|
36
|
-
*
|
|
37
|
-
* The server no longer reads, re-emits nor purges cookies under this name
|
|
38
|
-
* (#4119): every one of them expired. The export only survives because
|
|
39
|
-
* removing it is a breaking change of this package.
|
|
40
|
-
*
|
|
41
|
-
* @deprecated Use {@link getApplicationSessionCookieName}. No server reads
|
|
42
|
-
* this name any more; the export is removed in the next major.
|
|
43
|
-
*/
|
|
44
|
-
export function getSessionCookieName(verticalId) {
|
|
45
|
-
return `gamaro_session_${sanitizeCookieId(verticalId)}`;
|
|
46
|
-
}
|
|
47
33
|
/**
|
|
48
34
|
* Validate the UUID shape of a session id. The length pre-check is
|
|
49
35
|
* defense-in-depth (avoids running the regex on arbitrarily long strings).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gamaro.io/core-types",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Cross-workspace TypeScript contracts and Zod schemas consumed by @gamaro.io/widget. Intended as a peer of the widget SDK.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|