@~lyre/auth 0.6.0 → 0.8.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 +51 -4
- package/dist/admin.js +60 -4
- package/package.json +71 -71
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
|
|
171
|
-
*
|
|
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
|
*
|
|
@@ -193,6 +223,23 @@ declare class AccountsAdmin {
|
|
|
193
223
|
* reads membership — so without this a "deleted" user keeps reappearing in the workspace.
|
|
194
224
|
*/
|
|
195
225
|
removeGroupMember(groupId: string, userId: string): Promise<void>;
|
|
226
|
+
/**
|
|
227
|
+
* Deactivate or reactivate a user account GLOBALLY. Service-key authed (`users:write`).
|
|
228
|
+
*
|
|
229
|
+
* `disabled: true` sets `users.disabled_at`; `false` clears it. A disabled user cannot
|
|
230
|
+
* authenticate by ANY route (password, OAuth exchange, token) across EVERY app — this is an
|
|
231
|
+
* account-level gate, not a per-workspace one. Their rows are retained, so anything they own
|
|
232
|
+
* (audit history, assigned tickets, migrated connections) keeps a valid owner.
|
|
233
|
+
*
|
|
234
|
+
* Accounts also revokes their live sessions across every tenant and emits `session.revoked`, so
|
|
235
|
+
* deactivation takes effect immediately rather than whenever the last session happens to expire.
|
|
236
|
+
*
|
|
237
|
+
* This is the counterpart to `removeGroupMember`, NOT a synonym for it. Removing a membership
|
|
238
|
+
* deletes the row the members list is built from, so the person disappears and can never be
|
|
239
|
+
* reactivated from the UI; disabling keeps them listed with `disabledAt` set, which is what the
|
|
240
|
+
* Active/Deactivated badge reads.
|
|
241
|
+
*/
|
|
242
|
+
setUserDisabled(userId: string, disabled: boolean): Promise<void>;
|
|
196
243
|
/** Revoke a pending invite (withdraw one sent in error). Session-authed. */
|
|
197
244
|
revokeAppInvite(appSlug: string, inviteId: string): Promise<void>;
|
|
198
245
|
/** Everyone with access to an app. Session-authed. */
|
|
@@ -270,4 +317,4 @@ declare class AccountsAdmin {
|
|
|
270
317
|
/** Convenience factory mirroring the SDK's other `create*` helpers. */
|
|
271
318
|
declare function createAccountsAdmin(opts: AccountsAdminOptions): AccountsAdmin;
|
|
272
319
|
|
|
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 };
|
|
320
|
+
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
|
|
84
|
-
*
|
|
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
|
*
|
|
@@ -129,6 +159,32 @@ var AccountsAdmin = class {
|
|
|
129
159
|
{ auth: "key" }
|
|
130
160
|
);
|
|
131
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
|
+
}
|
|
132
188
|
/** Revoke a pending invite (withdraw one sent in error). Session-authed. */
|
|
133
189
|
async revokeAppInvite(appSlug, inviteId) {
|
|
134
190
|
await this.request(
|
package/package.json
CHANGED
|
@@ -1,73 +1,73 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
2
|
+
"name": "@~lyre/auth",
|
|
3
|
+
"version": "0.8.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
|
}
|