@appshell/react 1.0.0-alpha.44 → 1.0.0-alpha.46

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,47 @@
1
+ /**
2
+ * Who is looking at the page, as the registry was told by the gateway.
3
+ *
4
+ * Unlike vars this is not scope-specific — there is one visitor per page, not one
5
+ * per package — so it lives in the main entry rather than needing the subpath
6
+ * trick `@appshell/runtime/vars` uses to get a per-package scope substituted.
7
+ *
8
+ * It is also not delivered through the vars store, and that is a constraint rather
9
+ * than a preference: `setVars` freezes on first write and throws on replacement,
10
+ * which is what stops one package overwriting another's configuration. Identity
11
+ * changes — sign-in, sign-out, token refresh — so it cannot live behind a
12
+ * write-once door without either breaking that guarantee or never updating.
13
+ */
14
+ /**
15
+ * A discriminated union rather than an optional user, so `username` cannot be read
16
+ * without the anonymous case having been handled. The compiler enforces what a
17
+ * convention would only ask for.
18
+ */
19
+ export type Identity = {
20
+ authenticated: false;
21
+ } | {
22
+ authenticated: true;
23
+ subject: string;
24
+ username: string;
25
+ roles: string[];
26
+ };
27
+ export declare const ANONYMOUS: Identity;
28
+ declare global {
29
+ interface Window {
30
+ __appshell_identity__?: unknown;
31
+ }
32
+ }
33
+ /**
34
+ * The visitor, or the anonymous identity when there is none.
35
+ *
36
+ * Never throws and never returns undefined — an absent or malformed value is
37
+ * anonymous, which is a state every caller already has to handle. That is the
38
+ * opposite of `readVars`, which throws when a scope is missing, and the difference
39
+ * is deliberate: a package with no configuration cannot do its job, while a package
40
+ * with no signed-in user usually can and simply renders differently.
41
+ *
42
+ * This is a typed accessor, not a boundary. The value is inlined into the document
43
+ * and any script on the page can read it directly, exactly as with vars. Treat it
44
+ * as what the server said about the visitor, never as proof of anything: it carries
45
+ * no token and grants nothing. Anything that matters is re-checked server-side.
46
+ */
47
+ export declare const getIdentity: () => Identity;
@@ -1,4 +1,6 @@
1
1
  export { MissingScopeError, MissingVarsError, VarsConflictError } from './errors';
2
+ export { ANONYMOUS, getIdentity } from './identity';
3
+ export type { Identity } from './identity';
2
4
  export { hasVars, readVars, resetVars, setVars } from './store';
3
5
  export type { Vars } from './types';
4
6
  export type { AppshellIndex, AppshellRemote, Metadata } from './wire';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appshell/react",
3
- "version": "1.0.0-alpha.44",
3
+ "version": "1.0.0-alpha.46",
4
4
  "description": "React utilities for building micro-frontends with Appshell and Module Federation",
5
5
  "main": "dist/main.js",
6
6
  "types": "dist/types/react/src/index.d.ts",
@@ -33,8 +33,8 @@
33
33
  "react": "^18.2.0",
34
34
  "react-dom": "^18.2.0"
35
35
  },
36
- "gitHead": "814f81383214fa613c4d92a05236f53fcc1921bb",
36
+ "gitHead": "8ef63d50e61a09ee1205cac64548b5331e7b8472",
37
37
  "dependencies": {
38
- "@appshell/runtime": "^1.0.0-alpha.44"
38
+ "@appshell/runtime": "^1.0.0-alpha.46"
39
39
  }
40
40
  }