@amalgm/core 0.5.1-preview.34318364556 → 0.5.1-preview.34402139187

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.
@@ -0,0 +1,37 @@
1
+ /**
2
+ * The display projection of an authenticated user (axiom 2: identity is one
3
+ * story). An auth record carries loose provider metadata; every surface that
4
+ * shows a person — realtime presence, sharing chrome, invite mail — needs the
5
+ * SAME bounded name and avatar, or the same person appears as two people.
6
+ *
7
+ * Three laws, and each is load-bearing:
8
+ *
9
+ * 1. PREFERENCE. `full_name` beats `name` beats the email address. The email
10
+ * is the terminal fallback, never a preference.
11
+ * 2. BOUNDS. Text is trimmed, then capped; whitespace-only is absence, not an
12
+ * empty name. A provider may return an arbitrarily long string and it must
13
+ * not become an arbitrarily long frame.
14
+ * 3. SAFETY. An avatar is a URL only when it parses AND its protocol is
15
+ * `https:`. `javascript:`, `data:` and `http:` are absent avatars — a
16
+ * display projection crosses into rendered chrome, so an unsafe scheme is
17
+ * dropped here rather than at each caller.
18
+ *
19
+ * Absence is expressible throughout: a user with neither name nor avatar
20
+ * projects to `undefined`, not to an empty object. Pure over the record; no
21
+ * clock, network or storage.
22
+ */
23
+ /** The fields of an auth user this projection reads. Provider metadata is
24
+ * loose JSON, so it is typed as it truly is and validated key by key. */
25
+ export interface AuthDisplayUser {
26
+ email?: string | null;
27
+ user_metadata?: Record<string, unknown> | null;
28
+ }
29
+ /** The bounded, safe display data a surface may show for a person. The stable
30
+ * person id is NOT part of it: this is the face, never the identity. */
31
+ export interface DisplayProfile {
32
+ name?: string;
33
+ avatarUrl?: string;
34
+ }
35
+ /** Pure, bounded projection shared by realtime presence and sharing chrome. */
36
+ export declare function displayProfileForAuthUser(user: AuthDisplayUser | null | undefined): DisplayProfile | undefined;
37
+ //# sourceMappingURL=display-profile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"display-profile.d.ts","sourceRoot":"","sources":["../../src/identity/display-profile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAKH;yEACyE;AACzE,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CAChD;AAED;wEACwE;AACxE,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAkBD,+EAA+E;AAC/E,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,eAAe,GAAG,IAAI,GAAG,SAAS,GAAG,cAAc,GAAG,SAAS,CAQ9G"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * The display projection of an authenticated user (axiom 2: identity is one
3
+ * story). An auth record carries loose provider metadata; every surface that
4
+ * shows a person — realtime presence, sharing chrome, invite mail — needs the
5
+ * SAME bounded name and avatar, or the same person appears as two people.
6
+ *
7
+ * Three laws, and each is load-bearing:
8
+ *
9
+ * 1. PREFERENCE. `full_name` beats `name` beats the email address. The email
10
+ * is the terminal fallback, never a preference.
11
+ * 2. BOUNDS. Text is trimmed, then capped; whitespace-only is absence, not an
12
+ * empty name. A provider may return an arbitrarily long string and it must
13
+ * not become an arbitrarily long frame.
14
+ * 3. SAFETY. An avatar is a URL only when it parses AND its protocol is
15
+ * `https:`. `javascript:`, `data:` and `http:` are absent avatars — a
16
+ * display projection crosses into rendered chrome, so an unsafe scheme is
17
+ * dropped here rather than at each caller.
18
+ *
19
+ * Absence is expressible throughout: a user with neither name nor avatar
20
+ * projects to `undefined`, not to an empty object. Pure over the record; no
21
+ * clock, network or storage.
22
+ */
23
+ const MAX_DISPLAY_NAME_LENGTH = 120;
24
+ const MAX_AVATAR_URL_LENGTH = 2_048;
25
+ function cappedText(value, limit) {
26
+ if (typeof value !== 'string')
27
+ return undefined;
28
+ const normalized = value.trim();
29
+ return normalized ? normalized.slice(0, limit) : undefined;
30
+ }
31
+ function httpsUrl(value) {
32
+ const candidate = cappedText(value, MAX_AVATAR_URL_LENGTH);
33
+ if (!candidate)
34
+ return undefined;
35
+ try {
36
+ return new URL(candidate).protocol === 'https:' ? candidate : undefined;
37
+ }
38
+ catch {
39
+ return undefined;
40
+ }
41
+ }
42
+ /** Pure, bounded projection shared by realtime presence and sharing chrome. */
43
+ export function displayProfileForAuthUser(user) {
44
+ if (!user)
45
+ return undefined;
46
+ const metadata = user.user_metadata || {};
47
+ const name = cappedText(metadata['full_name'], MAX_DISPLAY_NAME_LENGTH)
48
+ ?? cappedText(metadata['name'], MAX_DISPLAY_NAME_LENGTH)
49
+ ?? cappedText(user.email, MAX_DISPLAY_NAME_LENGTH);
50
+ const avatarUrl = httpsUrl(metadata['avatar_url']) ?? httpsUrl(metadata['picture']);
51
+ return name || avatarUrl ? { ...(name ? { name } : {}), ...(avatarUrl ? { avatarUrl } : {}) } : undefined;
52
+ }
53
+ //# sourceMappingURL=display-profile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"display-profile.js","sourceRoot":"","sources":["../../src/identity/display-profile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,MAAM,uBAAuB,GAAG,GAAG,CAAC;AACpC,MAAM,qBAAqB,GAAG,KAAK,CAAC;AAgBpC,SAAS,UAAU,CAAC,KAAc,EAAE,KAAa;IAC/C,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IAChD,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAChC,OAAO,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAC7D,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,MAAM,SAAS,GAAG,UAAU,CAAC,KAAK,EAAE,qBAAqB,CAAC,CAAC;IAC3D,IAAI,CAAC,SAAS;QAAE,OAAO,SAAS,CAAC;IACjC,IAAI,CAAC;QACH,OAAO,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;IAC1E,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,yBAAyB,CAAC,IAAwC;IAChF,IAAI,CAAC,IAAI;QAAE,OAAO,SAAS,CAAC;IAC5B,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,IAAI,EAAE,CAAC;IAC1C,MAAM,IAAI,GAAG,UAAU,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,uBAAuB,CAAC;WAClE,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,uBAAuB,CAAC;WACrD,UAAU,CAAC,IAAI,CAAC,KAAK,EAAE,uBAAuB,CAAC,CAAC;IACrD,MAAM,SAAS,GAAG,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;IACpF,OAAO,IAAI,IAAI,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAC5G,CAAC"}
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * IDENTITY — who this machine is, for which user, on which branch (axiom 2:
3
3
  * identity is one story). The pure laws behind `~/amalgm` layout, runtime
4
- * labels and channels, id minting/validation, and credential-record
5
- * shaping. Every effect (hash, random, clock, path resolution, env) arrives
4
+ * labels and channels, id minting/validation, credential-record shaping,
5
+ * and the bounded display projection of an authenticated user. Every effect (hash, random, clock, path resolution, env) arrives
6
6
  * as an injected port from `./ports.js`.
7
7
  */
8
8
  export * from './ports.js';
@@ -15,5 +15,6 @@ export * from './credentials/index.js';
15
15
  export * from './authorization/index.js';
16
16
  export * from './ids.js';
17
17
  export * from './auth-records.js';
18
+ export * from './display-profile.js';
18
19
  export * from './machine-setup.js';
19
20
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/identity/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/identity/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC"}
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * IDENTITY — who this machine is, for which user, on which branch (axiom 2:
3
3
  * identity is one story). The pure laws behind `~/amalgm` layout, runtime
4
- * labels and channels, id minting/validation, and credential-record
5
- * shaping. Every effect (hash, random, clock, path resolution, env) arrives
4
+ * labels and channels, id minting/validation, credential-record shaping,
5
+ * and the bounded display projection of an authenticated user. Every effect (hash, random, clock, path resolution, env) arrives
6
6
  * as an injected port from `./ports.js`.
7
7
  */
8
8
  export * from './ports.js';
@@ -15,5 +15,6 @@ export * from './credentials/index.js';
15
15
  export * from './authorization/index.js';
16
16
  export * from './ids.js';
17
17
  export * from './auth-records.js';
18
+ export * from './display-profile.js';
18
19
  export * from './machine-setup.js';
19
20
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/identity/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/identity/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amalgm/core",
3
- "version": "0.5.1-preview.34318364556",
3
+ "version": "0.5.1-preview.34402139187",
4
4
  "description": "The Amalgm kernel SDK — identity, transport, supervision, and host capability contracts behind host-injected adapters.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",
@@ -95,11 +95,11 @@
95
95
  "verify": "test",
96
96
  "cli": []
97
97
  },
98
- "gitHead": "554cebf796326451b53867c5ecbdff17fd31e250",
98
+ "gitHead": "5302d617d068a09cef28a3d9544d8953f2b016c3",
99
99
  "amalgmSource": {
100
100
  "repository": "amalgm-inc/amalgm-core",
101
101
  "branch": "preview",
102
- "commit": "554cebf796326451b53867c5ecbdff17fd31e250",
103
- "occurrence": "34318364556"
102
+ "commit": "5302d617d068a09cef28a3d9544d8953f2b016c3",
103
+ "occurrence": "34402139187"
104
104
  }
105
105
  }