@~lyre/auth 0.5.0 → 0.6.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
@@ -177,10 +177,33 @@ declare class AccountsAdmin {
177
177
  * Session-authed.
178
178
  */
179
179
  checkInviteEmail(appSlug: string, email: string): Promise<InviteEmailCheck>;
180
+ /**
181
+ * Add a user to a workspace group. Service-key authed (`users:write`).
182
+ *
183
+ * Membership was read-only over the API, which is why "reactivate user" had to fall back to
184
+ * re-INVITING an existing colleague. Use this to restore membership instead.
185
+ */
186
+ addGroupMember(groupId: string, userId: string, opts?: {
187
+ role?: string;
188
+ }): Promise<void>;
189
+ /**
190
+ * Remove a user from a workspace group. Service-key authed (`users:write`). Idempotent.
191
+ *
192
+ * Removing a user's APP access does NOT remove their group membership, and the members list
193
+ * reads membership — so without this a "deleted" user keeps reappearing in the workspace.
194
+ */
195
+ removeGroupMember(groupId: string, userId: string): Promise<void>;
180
196
  /** Revoke a pending invite (withdraw one sent in error). Session-authed. */
181
197
  revokeAppInvite(appSlug: string, inviteId: string): Promise<void>;
182
198
  /** Everyone with access to an app. Session-authed. */
183
199
  listAppUsers(appSlug: string): Promise<AppMember[]>;
200
+ /**
201
+ * Restore an existing user's access to an app. Session-authed. Idempotent.
202
+ *
203
+ * The counterpart to `removeAppUser`. Distinct from `inviteToApp`: this is for an account that
204
+ * already exists and already consented, so it must NOT put the person through registration again.
205
+ */
206
+ addAppUser(appSlug: string, userId: string): Promise<void>;
184
207
  /** Revoke a user's access to an app. Session-authed. */
185
208
  removeAppUser(appSlug: string, userId: string): Promise<void>;
186
209
  /** Members of a user_group (the workspace's agents). Service-key authed (`stats:read`). */
package/dist/admin.js CHANGED
@@ -103,6 +103,32 @@ var AccountsAdmin = class {
103
103
  { auth: "session" }
104
104
  );
105
105
  }
106
+ /**
107
+ * Add a user to a workspace group. Service-key authed (`users:write`).
108
+ *
109
+ * Membership was read-only over the API, which is why "reactivate user" had to fall back to
110
+ * re-INVITING an existing colleague. Use this to restore membership instead.
111
+ */
112
+ async addGroupMember(groupId, userId, opts = {}) {
113
+ await this.request(
114
+ "POST",
115
+ `/api/auth/user-groups/${encodeURIComponent(groupId)}/members`,
116
+ { auth: "key", body: { userId, ...opts.role ? { role: opts.role } : {} } }
117
+ );
118
+ }
119
+ /**
120
+ * Remove a user from a workspace group. Service-key authed (`users:write`). Idempotent.
121
+ *
122
+ * Removing a user's APP access does NOT remove their group membership, and the members list
123
+ * reads membership — so without this a "deleted" user keeps reappearing in the workspace.
124
+ */
125
+ async removeGroupMember(groupId, userId) {
126
+ await this.request(
127
+ "DELETE",
128
+ `/api/auth/user-groups/${encodeURIComponent(groupId)}/members?userId=${encodeURIComponent(userId)}`,
129
+ { auth: "key" }
130
+ );
131
+ }
106
132
  /** Revoke a pending invite (withdraw one sent in error). Session-authed. */
107
133
  async revokeAppInvite(appSlug, inviteId) {
108
134
  await this.request(
@@ -120,6 +146,19 @@ var AccountsAdmin = class {
120
146
  );
121
147
  return data.users ?? [];
122
148
  }
149
+ /**
150
+ * Restore an existing user's access to an app. Session-authed. Idempotent.
151
+ *
152
+ * The counterpart to `removeAppUser`. Distinct from `inviteToApp`: this is for an account that
153
+ * already exists and already consented, so it must NOT put the person through registration again.
154
+ */
155
+ async addAppUser(appSlug, userId) {
156
+ await this.request(
157
+ "POST",
158
+ `/api/auth/apps/${encodeURIComponent(appSlug)}/users`,
159
+ { auth: "session", body: { userId } }
160
+ );
161
+ }
123
162
  /** Revoke a user's access to an app. Session-authed. */
124
163
  async removeAppUser(appSlug, userId) {
125
164
  await this.request(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@~lyre/auth",
3
- "version": "0.5.0",
3
+ "version": "0.6.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,