@~lyre/auth 0.6.0 → 0.7.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/dist/admin.d.ts CHANGED
@@ -96,6 +96,14 @@ interface InviteEmailCheck {
96
96
  /** When the pending invite lapses — only for `invited`. */
97
97
  expiresAt?: string;
98
98
  }
99
+ /** A workspace (user_group) with its app-scoped profile values. */
100
+ interface WorkspaceProfile {
101
+ id: string;
102
+ slug: string;
103
+ displayName: string;
104
+ /** App-scoped values keyed by field name — e.g. `support_email`. Empty when no app was scoped. */
105
+ profileData: Record<string, string>;
106
+ }
99
107
  /** A pending (not yet accepted, not yet expired) app invitation. */
100
108
  interface PendingInvite {
101
109
  id: string;
@@ -167,16 +175,38 @@ declare class AccountsAdmin {
167
175
  profileData?: Record<string, string> | null;
168
176
  }): Promise<InviteResult>;
169
177
  /**
170
- * The profile fields this app collects about a user — the spec to render an invite form from.
171
- * Session-authed. Never includes email: that is the invite's identity, not a profile value.
178
+ * The profile fields this app collects about a SUBJECT — the spec to render a form from.
179
+ * `ownerType: 'user'` (default) is what an invite form collects about a person; `'user_group'` is
180
+ * what a workspace's edit form collects about itself. Session-authed. A user's email is never
181
+ * included: that is identity, not a profile value.
172
182
  */
173
- listAppProfileFields(appSlug: string): Promise<ProfileFieldSpec[]>;
183
+ listAppProfileFields(appSlug: string, ownerType?: 'user' | 'user_group'): Promise<ProfileFieldSpec[]>;
174
184
  /**
175
185
  * Whether an email can be invited — for a live check on an invite form, so the inviter learns
176
186
  * BEFORE submitting that someone is already a member or already invited. Email only, exact match.
177
187
  * Session-authed.
178
188
  */
179
189
  checkInviteEmail(appSlug: string, email: string): Promise<InviteEmailCheck>;
190
+ /**
191
+ * A workspace's own details — name plus its app-scoped profile values (support email, …).
192
+ * Service-key authed (`stats:read`). Pass `appId` to scope the profile values.
193
+ *
194
+ * Workspace details live in Accounts, which owns the group. Consumers previously had no way to
195
+ * read them and fell back to a retiring legacy system's copy.
196
+ */
197
+ getUserGroup(groupId: string, opts?: {
198
+ appId?: string;
199
+ }): Promise<WorkspaceProfile>;
200
+ /**
201
+ * Update a workspace's name and/or its app-scoped profile values. Service-key authed
202
+ * (`users:write`). An empty profile value CLEARS that field rather than storing an empty string.
203
+ * Accounts drops any key the app does not declare for `user_group`.
204
+ */
205
+ updateUserGroup(groupId: string, input: {
206
+ displayName?: string;
207
+ profileData?: Record<string, string>;
208
+ appId?: string;
209
+ }): Promise<WorkspaceProfile>;
180
210
  /**
181
211
  * Add a user to a workspace group. Service-key authed (`users:write`).
182
212
  *
@@ -270,4 +300,4 @@ declare class AccountsAdmin {
270
300
  /** Convenience factory mirroring the SDK's other `create*` helpers. */
271
301
  declare function createAccountsAdmin(opts: AccountsAdminOptions): AccountsAdmin;
272
302
 
273
- export { AccountsAdmin, AccountsAdminError, type AccountsAdminOptions, type AccountsUser, type AppMember, type ChangePasswordResult, type GroupMember, type InviteEmailCheck, type InviteResult, type ListUsersQuery, type ListUsersResult, type PendingInvite, type ProfileFieldSpec, createAccountsAdmin };
303
+ export { AccountsAdmin, AccountsAdminError, type AccountsAdminOptions, type AccountsUser, type AppMember, type ChangePasswordResult, type GroupMember, type InviteEmailCheck, type InviteResult, type ListUsersQuery, type ListUsersResult, type PendingInvite, type ProfileFieldSpec, type WorkspaceProfile, createAccountsAdmin };
package/dist/admin.js CHANGED
@@ -80,13 +80,16 @@ var AccountsAdmin = class {
80
80
  });
81
81
  }
82
82
  /**
83
- * The profile fields this app collects about a user — the spec to render an invite form from.
84
- * Session-authed. Never includes email: that is the invite's identity, not a profile value.
83
+ * The profile fields this app collects about a SUBJECT — the spec to render a form from.
84
+ * `ownerType: 'user'` (default) is what an invite form collects about a person; `'user_group'` is
85
+ * what a workspace's edit form collects about itself. Session-authed. A user's email is never
86
+ * included: that is identity, not a profile value.
85
87
  */
86
- async listAppProfileFields(appSlug) {
88
+ async listAppProfileFields(appSlug, ownerType = "user") {
89
+ const suffix = ownerType === "user_group" ? "?ownerType=user_group" : "";
87
90
  const data = await this.request(
88
91
  "GET",
89
- `/api/auth/apps/${encodeURIComponent(appSlug)}/profile-fields`,
92
+ `/api/auth/apps/${encodeURIComponent(appSlug)}/profile-fields${suffix}`,
90
93
  { auth: "session" }
91
94
  );
92
95
  return data.fields ?? [];
@@ -103,6 +106,33 @@ var AccountsAdmin = class {
103
106
  { auth: "session" }
104
107
  );
105
108
  }
109
+ /**
110
+ * A workspace's own details — name plus its app-scoped profile values (support email, …).
111
+ * Service-key authed (`stats:read`). Pass `appId` to scope the profile values.
112
+ *
113
+ * Workspace details live in Accounts, which owns the group. Consumers previously had no way to
114
+ * read them and fell back to a retiring legacy system's copy.
115
+ */
116
+ async getUserGroup(groupId, opts = {}) {
117
+ const suffix = opts.appId ? `?appId=${encodeURIComponent(opts.appId)}` : "";
118
+ return this.request(
119
+ "GET",
120
+ `/api/auth/user-groups/${encodeURIComponent(groupId)}${suffix}`,
121
+ { auth: "key" }
122
+ );
123
+ }
124
+ /**
125
+ * Update a workspace's name and/or its app-scoped profile values. Service-key authed
126
+ * (`users:write`). An empty profile value CLEARS that field rather than storing an empty string.
127
+ * Accounts drops any key the app does not declare for `user_group`.
128
+ */
129
+ async updateUserGroup(groupId, input) {
130
+ return this.request(
131
+ "PATCH",
132
+ `/api/auth/user-groups/${encodeURIComponent(groupId)}`,
133
+ { auth: "key", body: input }
134
+ );
135
+ }
106
136
  /**
107
137
  * Add a user to a workspace group. Service-key authed (`users:write`).
108
138
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@~lyre/auth",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Shared Axis Accounts auth SDK \u2014 framework-agnostic session/identity core (HMAC-signed cookies, accounts login/callback/logout) plus an optional turnkey SvelteKit adapter.",
5
5
  "type": "module",
6
6
  "sideEffects": false,