@astrale-domains/shell-schema 0.3.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../identity.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB;;;;;;GAMG;AACH,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAGd;;;;;;WAMG;QACH,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAEb,CAAA;AAEF;gCACgC;AAChC,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAbb;;;;;;eAMG;YACH,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAUX,SAAS;QACT,QAAQ;QACR;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;;EASL,CAAA;AAEF;4EAC4E;AAC5E,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;EAGtB,CAAA"}
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Identity context — the workspace principals, as INTERFACES (the fundamental
3
+ * primitives) plus their DEFAULT convenience classes, co-located.
4
+ *
5
+ * Same-name interface+class is intentional (separate namespaces, the kernel's
6
+ * `Function` pattern): the interface is exported aliased `iUser`/`iGroup`, the
7
+ * class as `User`/`Group`. Edges are typed by the INTERFACES, so any implementer
8
+ * (a foreign domain's `Agent`) participates. Reach each side of the compiled `D`
9
+ * via `D.$.i('User')` / `D.$.c('User')` (the flat `D.User` resolves to the
10
+ * interface).
11
+ *
12
+ * - `iUser` / `User` a principal: an Identity that owns a Space + apps and can
13
+ * join groups. The class adds the human props + the `init`
14
+ * creation entry.
15
+ * - `iGroup` / `Group` an identity group + container; `assign` (on the
16
+ * interface) adds a member (the seeded `admin` group owns
17
+ * Root).
18
+ * - Edge `belongs_to` User → Group (semantic membership).
19
+ */
20
+ import { edgeClass, KernelSchema, nodeClass, nodeInterface } from '@astrale-os/kernel-core';
21
+ import { fn } from '@astrale-os/kernel-dsl';
22
+ import { z } from 'zod';
23
+ import { GROUP_ICON, USER_ICON } from './icons';
24
+ /**
25
+ * `User` (interface) — a workspace principal: an Identity that owns a Space + apps
26
+ * and can join groups. SOURCE of `belongs_to`, so anything
27
+ * implementing it (the default `User` class, a foreign `Agent`) participates in
28
+ * the workspace uniformly. `switchSpace` is hosted here (not on the class) so
29
+ * every implementer inherits it.
30
+ */
31
+ export const iUser = nodeInterface({
32
+ extends: [KernelSchema.interfaces.Identity],
33
+ methods: {
34
+ /**
35
+ * `user::switchSpace(space)` — make `space` the user's active space: repoints
36
+ * the `selected_space` edge to it (remove + recreate — edge identity includes
37
+ * the target). `space` is any address (path or `@id`) resolving to a Space the
38
+ * caller can READ. Caller gate mirrors `role::assign`'s user side: EDIT on the
39
+ * user (normally themselves). Idempotent — already selected ⇒ no-op.
40
+ */
41
+ switchSpace: fn({ params: { space: z.string().min(1) }, returns: z.void() }),
42
+ },
43
+ });
44
+ /** The DEFAULT `User` — a human principal implementing the `User` interface; adds
45
+ * the human props + `init`. */
46
+ export const User = nodeClass({
47
+ implements: [iUser],
48
+ icon: USER_ICON,
49
+ props: {
50
+ firstName: z.string(),
51
+ lastName: z.string(),
52
+ /** Email, when the identity provider supplies one (the WorkOS `email` claim).
53
+ * Optional — a managed identity or a name-only IdP may not carry one. */
54
+ email: z.string().optional(),
55
+ },
56
+ methods: {
57
+ /**
58
+ * `User.init(firstName?, lastName?, email?, iss?, sub?, admin?, ownerToken?, publicKey?)` — the
59
+ * SINGLE user-creation entry, serving BOTH the kernel auto-provisioning dispatch and manual
60
+ * creation. Creates ONLY the User identity node (no Space/grants — workspace furniture is a
61
+ * separate get-or-create concern) and RETURNS the kernel `Identity` shape, which the
62
+ * provisioning dispatch consumes directly as the caller's identity. Idempotent: a repeat call
63
+ * for the same `(iss, sub)` returns the existing User.
64
+ *
65
+ * Identity binding precedence:
66
+ * 1. explicit `(iss, sub)` — the AUTO-PROVISIONING path; the instance provisioning policy maps
67
+ * an unprovisioned caller's JWT claims (`iss`/`sub`/`given_name`/`family_name`/`email`) to
68
+ * these params and the kernel calls this as `__SYSTEM__` on first contact. (Names default
69
+ * when the IdP omits them; `email` is stored when present and used as the display fallback.)
70
+ * 2. `ownerToken` — manual/admin binding: decode the IdP JWT (no signature check) so the token
71
+ * holder authenticates AS this user. A `publicKey` is rejected (the kernel verifier can't
72
+ * resolve a worker-pinned key) — OIDC discovery only.
73
+ * 3. neither — managed identity (kernel-issued `iss`, `sub=user:<name-slug>`).
74
+ *
75
+ * `admin: true` additionally extends the user with the admin group (must exist — the `seed` function).
76
+ * Not used by the provisioning path (the policy handles owner→root elevation).
77
+ */
78
+ init: fn({
79
+ static: true,
80
+ params: {
81
+ firstName: z.string().optional(),
82
+ lastName: z.string().optional(),
83
+ email: z.string().optional(),
84
+ iss: z.string().optional(),
85
+ sub: z.string().optional(),
86
+ admin: z.boolean().optional(),
87
+ ownerToken: z.string().min(1).optional(),
88
+ publicKey: z.object({ jwk: z.record(z.string(), z.unknown()) }).optional(),
89
+ },
90
+ returns: z.object({
91
+ id: z.string(),
92
+ props: z.object({
93
+ iss: z.string(),
94
+ sub: z.string(),
95
+ frozen: z.boolean(),
96
+ }),
97
+ }),
98
+ }),
99
+ },
100
+ });
101
+ /**
102
+ * `Group` (interface) — an identity that is also a container; principals join it
103
+ * via `assign`, which composes the group's permissions onto the member.
104
+ */
105
+ export const iGroup = nodeInterface({
106
+ extends: [KernelSchema.interfaces.Identity, KernelSchema.interfaces.Container],
107
+ methods: {
108
+ /**
109
+ * `group::assign(user)` — add a principal to this group: records the semantic
110
+ * `belongs_to` edge AND extends the principal's identity with the group
111
+ * (`extendIdentity`), so membership genuinely composes the group's permissions
112
+ * (the `admin`-group mechanism). Group grants are set with `grantPerm`
113
+ * separately. Idempotent.
114
+ */
115
+ assign: fn({ params: { user: z.string().min(1) }, returns: z.void() }),
116
+ /**
117
+ * `group::unassign(user)` — the idempotent inverse of `assign`: removes the
118
+ * `belongs_to` edge AND reverses the identity composition (`removeExtension`),
119
+ * so the group's permissions no longer compose onto the user. Same gate as
120
+ * `assign` (SHARE on the group + EDIT on the user unless self). Not a member
121
+ * already ⇒ no-op.
122
+ */
123
+ unassign: fn({ params: { user: z.string().min(1) }, returns: z.void() }),
124
+ },
125
+ });
126
+ /** The DEFAULT `Group` — implements the `Group` interface (Identity + Container). */
127
+ export const Group = nodeClass({
128
+ implements: [iGroup],
129
+ icon: GROUP_ICON,
130
+ });
131
+ /** A user's membership in a group — the semantic, queryable side of group
132
+ * membership (the permission composition is done via `extendIdentity`). */
133
+ export const belongs_to = edgeClass({ as: 'user', types: [iUser] }, { as: 'group', types: [iGroup] });
134
+ //# sourceMappingURL=identity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity.js","sourceRoot":"","sources":["../identity.ts"],"names":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