@~lyre/auth 0.7.0 → 0.9.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
@@ -123,7 +123,34 @@ interface GroupMember {
123
123
  name?: string | null;
124
124
  firstName?: string | null;
125
125
  lastName?: string | null;
126
+ /**
127
+ * The group MEMBERSHIP role (`owner` / `admin` / `member`) — how this person relates to the
128
+ * workspace itself. NOT the app's account type; see `appRoles`.
129
+ */
126
130
  role?: string | null;
131
+ /**
132
+ * The app's own RBAC roles for this member, scoped to this group (e.g. `engage:admin`,
133
+ * `engage:agent`). This is what "account type" means to a consumer, and what an account-type
134
+ * change writes. Empty when the member holds no group-scoped app role.
135
+ */
136
+ appRoles?: string[];
137
+ /** Set when the account is deactivated in Accounts; null for an active account. */
138
+ disabledAt?: string | null;
139
+ /** When the user account was created (ISO). */
140
+ createdAt?: string | null;
141
+ /**
142
+ * Last sign-in (ISO), or null for someone who has never signed in.
143
+ *
144
+ * Derived from `MAX(sessions.last_seen_at)` — the definition Accounts uses everywhere else for
145
+ * this question. There is no separate `last_login_at` column.
146
+ */
147
+ lastSeenAt?: string | null;
148
+ /**
149
+ * App-scoped profile values (`phone_number`, `assignable`, `availability`, …). Present only when
150
+ * the request passed an `appId`; profile data is app-scoped by definition. Values are strings —
151
+ * the store is an EAV of text — so a boolean reads as `'true'` / `'false'`.
152
+ */
153
+ profileData?: Record<string, string>;
127
154
  }
128
155
  /** Thrown on a non-2xx Accounts response so callers can surface the upstream message + status. */
129
156
  declare class AccountsAdminError extends Error {
@@ -173,6 +200,33 @@ declare class AccountsAdmin {
173
200
  * Accounts drops any key the app does not collect, so authorization-shaped values
174
201
  * (role, assignability) can never be set from here. */
175
202
  profileData?: Record<string, string> | null;
203
+ /**
204
+ * The inviting app's OAuth callback — where accepting the invite should land the invitee.
205
+ *
206
+ * Acceptance hands off to `/auth/authorize`, which requires a redirect_uri it can validate
207
+ * against the app's authorized list; without one the invitee reaches the gateway app
208
+ * chooser instead of the app that invited them. Must already be in that allowlist — an
209
+ * unauthorized value is rejected at invite time (400) rather than stored.
210
+ */
211
+ redirectUri?: string | null;
212
+ /**
213
+ * The roles to grant when this invite is accepted, overriding the app's configured default
214
+ * invite roles. Role IDS resolved by the caller from its own vocabulary — Accounts has no
215
+ * notion of "admin" or "agent".
216
+ *
217
+ * A LIST because one account type commonly means several roles. Each id is validated as
218
+ * grantable by the inviting app at invite time (400 if not), so a bad invite fails the
219
+ * person creating it rather than the person accepting it.
220
+ */
221
+ invitedRoleIds?: string[] | null;
222
+ /**
223
+ * App-scoped `assignable` default, written to the invitee's profile on acceptance.
224
+ *
225
+ * A COLUMN on the invite, not a `profileData` key: it is authorization (whether work can be
226
+ * routed to this person) and the profile bag is invitee-editable, so Accounts drops it from
227
+ * there by design. Omit to leave unset — readers treat missing as assignable.
228
+ */
229
+ assignable?: boolean | null;
176
230
  }): Promise<InviteResult>;
177
231
  /**
178
232
  * The profile fields this app collects about a SUBJECT — the spec to render a form from.
@@ -223,6 +277,23 @@ declare class AccountsAdmin {
223
277
  * reads membership — so without this a "deleted" user keeps reappearing in the workspace.
224
278
  */
225
279
  removeGroupMember(groupId: string, userId: string): Promise<void>;
280
+ /**
281
+ * Deactivate or reactivate a user account GLOBALLY. Service-key authed (`users:write`).
282
+ *
283
+ * `disabled: true` sets `users.disabled_at`; `false` clears it. A disabled user cannot
284
+ * authenticate by ANY route (password, OAuth exchange, token) across EVERY app — this is an
285
+ * account-level gate, not a per-workspace one. Their rows are retained, so anything they own
286
+ * (audit history, assigned tickets, migrated connections) keeps a valid owner.
287
+ *
288
+ * Accounts also revokes their live sessions across every tenant and emits `session.revoked`, so
289
+ * deactivation takes effect immediately rather than whenever the last session happens to expire.
290
+ *
291
+ * This is the counterpart to `removeGroupMember`, NOT a synonym for it. Removing a membership
292
+ * deletes the row the members list is built from, so the person disappears and can never be
293
+ * reactivated from the UI; disabling keeps them listed with `disabledAt` set, which is what the
294
+ * Active/Deactivated badge reads.
295
+ */
296
+ setUserDisabled(userId: string, disabled: boolean): Promise<void>;
226
297
  /** Revoke a pending invite (withdraw one sent in error). Session-authed. */
227
298
  revokeAppInvite(appSlug: string, inviteId: string): Promise<void>;
228
299
  /** Everyone with access to an app. Session-authed. */
package/dist/admin.js CHANGED
@@ -159,6 +159,32 @@ var AccountsAdmin = class {
159
159
  { auth: "key" }
160
160
  );
161
161
  }
162
+ /**
163
+ * Deactivate or reactivate a user account GLOBALLY. Service-key authed (`users:write`).
164
+ *
165
+ * `disabled: true` sets `users.disabled_at`; `false` clears it. A disabled user cannot
166
+ * authenticate by ANY route (password, OAuth exchange, token) across EVERY app — this is an
167
+ * account-level gate, not a per-workspace one. Their rows are retained, so anything they own
168
+ * (audit history, assigned tickets, migrated connections) keeps a valid owner.
169
+ *
170
+ * Accounts also revokes their live sessions across every tenant and emits `session.revoked`, so
171
+ * deactivation takes effect immediately rather than whenever the last session happens to expire.
172
+ *
173
+ * This is the counterpart to `removeGroupMember`, NOT a synonym for it. Removing a membership
174
+ * deletes the row the members list is built from, so the person disappears and can never be
175
+ * reactivated from the UI; disabling keeps them listed with `disabledAt` set, which is what the
176
+ * Active/Deactivated badge reads.
177
+ */
178
+ async setUserDisabled(userId, disabled) {
179
+ await this.request(
180
+ "PATCH",
181
+ `/api/auth/admin/users/${encodeURIComponent(userId)}`,
182
+ {
183
+ auth: "key",
184
+ body: { disabledAt: disabled ? (/* @__PURE__ */ new Date()).toISOString() : null }
185
+ }
186
+ );
187
+ }
162
188
  /** Revoke a pending invite (withdraw one sent in error). Session-authed. */
163
189
  async revokeAppInvite(appSlug, inviteId) {
164
190
  await this.request(
package/package.json CHANGED
@@ -1,73 +1,73 @@
1
1
  {
2
- "name": "@~lyre/auth",
3
- "version": "0.7.0",
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
- "type": "module",
6
- "sideEffects": false,
7
- "license": "MIT",
8
- "author": "Britam Trust Services / Lyre",
9
- "repository": {
10
- "type": "git",
11
- "url": "git+https://github.com/kigathi-chege/lyre-auth-sdk.git"
12
- },
13
- "homepage": "https://github.com/kigathi-chege/lyre-auth-sdk#readme",
14
- "bugs": {
15
- "url": "https://github.com/kigathi-chege/lyre-auth-sdk/issues"
16
- },
17
- "keywords": [
18
- "auth",
19
- "sso",
20
- "accounts",
21
- "session",
22
- "sveltekit",
23
- "hmac",
24
- "lyre"
25
- ],
26
- "main": "./dist/index.js",
27
- "types": "./dist/index.d.ts",
28
- "exports": {
29
- ".": {
30
- "types": "./dist/index.d.ts",
31
- "import": "./dist/index.js"
32
- },
33
- "./sveltekit": {
34
- "types": "./dist/sveltekit.d.ts",
35
- "import": "./dist/sveltekit.js"
36
- },
37
- "./nest": {
38
- "types": "./dist/nest.d.ts",
39
- "import": "./dist/nest.js"
40
- },
41
- "./admin": {
42
- "types": "./dist/admin.d.ts",
43
- "import": "./dist/admin.js"
44
- },
45
- "./package.json": "./package.json"
46
- },
47
- "files": [
48
- "dist",
49
- "README.md",
50
- "LICENSE"
51
- ],
52
- "scripts": {
53
- "build": "tsup src/index.ts src/sveltekit.ts src/nest.ts src/admin.ts --format esm --dts --clean",
54
- "check": "tsc --noEmit"
55
- },
56
- "peerDependencies": {
57
- "@sveltejs/kit": "^2.0.0"
58
- },
59
- "peerDependenciesMeta": {
60
- "@sveltejs/kit": {
61
- "optional": true
62
- }
63
- },
64
- "devDependencies": {
65
- "@sveltejs/kit": "^2.0.0",
66
- "@types/node": "^22",
67
- "tsup": "^8.3.5",
68
- "typescript": "^6.0.2"
69
- },
70
- "publishConfig": {
71
- "access": "public"
72
- }
2
+ "name": "@~lyre/auth",
3
+ "version": "0.9.0",
4
+ "description": "Shared Axis Accounts auth SDK — framework-agnostic session/identity core (HMAC-signed cookies, accounts login/callback/logout) plus an optional turnkey SvelteKit adapter.",
5
+ "type": "module",
6
+ "sideEffects": false,
7
+ "license": "MIT",
8
+ "author": "Britam Trust Services / Lyre",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/kigathi-chege/lyre-auth-sdk.git"
12
+ },
13
+ "homepage": "https://github.com/kigathi-chege/lyre-auth-sdk#readme",
14
+ "bugs": {
15
+ "url": "https://github.com/kigathi-chege/lyre-auth-sdk/issues"
16
+ },
17
+ "keywords": [
18
+ "auth",
19
+ "sso",
20
+ "accounts",
21
+ "session",
22
+ "sveltekit",
23
+ "hmac",
24
+ "lyre"
25
+ ],
26
+ "main": "./dist/index.js",
27
+ "types": "./dist/index.d.ts",
28
+ "exports": {
29
+ ".": {
30
+ "types": "./dist/index.d.ts",
31
+ "import": "./dist/index.js"
32
+ },
33
+ "./sveltekit": {
34
+ "types": "./dist/sveltekit.d.ts",
35
+ "import": "./dist/sveltekit.js"
36
+ },
37
+ "./nest": {
38
+ "types": "./dist/nest.d.ts",
39
+ "import": "./dist/nest.js"
40
+ },
41
+ "./admin": {
42
+ "types": "./dist/admin.d.ts",
43
+ "import": "./dist/admin.js"
44
+ },
45
+ "./package.json": "./package.json"
46
+ },
47
+ "files": [
48
+ "dist",
49
+ "README.md",
50
+ "LICENSE"
51
+ ],
52
+ "scripts": {
53
+ "build": "tsup src/index.ts src/sveltekit.ts src/nest.ts src/admin.ts --format esm --dts --clean",
54
+ "check": "tsc --noEmit"
55
+ },
56
+ "peerDependencies": {
57
+ "@sveltejs/kit": "^2.0.0"
58
+ },
59
+ "peerDependenciesMeta": {
60
+ "@sveltejs/kit": {
61
+ "optional": true
62
+ }
63
+ },
64
+ "devDependencies": {
65
+ "@sveltejs/kit": "^2.0.0",
66
+ "@types/node": "^22",
67
+ "tsup": "^8.3.5",
68
+ "typescript": "^6.0.2"
69
+ },
70
+ "publishConfig": {
71
+ "access": "public"
72
+ }
73
73
  }