@adonis-agora/authkit-sdk 0.6.4 → 0.7.1
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/build/index.d.ts +6 -5
- package/build/index.js +3 -2
- package/build/src/embedded_driver.js +11 -9
- package/build/src/types.d.ts +48 -8
- package/build/src/types.js +12 -1
- package/package.json +8 -8
package/build/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
export { createAuthkit } from './src/factory.js';
|
|
2
|
-
export type { CreateAuthkitOptions } from './src/factory.js';
|
|
3
|
-
export { createRemoteAuthkit } from './src/remote_driver.js';
|
|
4
|
-
export type { RemoteOptions } from './src/remote_driver.js';
|
|
5
|
-
export { createEmbeddedAuthkit } from './src/embedded_driver.js';
|
|
6
1
|
export type { EmbeddedOptions } from './src/embedded_driver.js';
|
|
2
|
+
export { createEmbeddedAuthkit } from './src/embedded_driver.js';
|
|
7
3
|
export { AuthkitApiError } from './src/errors.js';
|
|
4
|
+
export type { CreateAuthkitOptions } from './src/factory.js';
|
|
5
|
+
export { createAuthkit } from './src/factory.js';
|
|
6
|
+
export type { RemoteOptions } from './src/remote_driver.js';
|
|
7
|
+
export { createRemoteAuthkit } from './src/remote_driver.js';
|
|
8
8
|
export type * from './src/types.js';
|
|
9
|
+
export { ADMIN_LIST_DEFAULT_SIZE, ADMIN_LIST_MAX_SIZE, LIST_FIRST_PAGE, } from './src/types.js';
|
package/build/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { createAuthkit } from './src/factory.js';
|
|
2
|
-
export { createRemoteAuthkit } from './src/remote_driver.js';
|
|
3
1
|
export { createEmbeddedAuthkit } from './src/embedded_driver.js';
|
|
4
2
|
export { AuthkitApiError } from './src/errors.js';
|
|
3
|
+
export { createAuthkit } from './src/factory.js';
|
|
4
|
+
export { createRemoteAuthkit } from './src/remote_driver.js';
|
|
5
|
+
export { ADMIN_LIST_DEFAULT_SIZE, ADMIN_LIST_MAX_SIZE, LIST_FIRST_PAGE, } from './src/types.js';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ADMIN_LIST_DEFAULT_SIZE, ADMIN_LIST_MAX_SIZE, LIST_FIRST_PAGE } from './types.js';
|
|
1
2
|
/** Audit actor used for SDK-originated writes — mirrors the REST `admin-api` source. */
|
|
2
3
|
const ACTOR = { actorId: null, ip: null, source: 'admin-api' };
|
|
3
4
|
/**
|
|
@@ -131,11 +132,11 @@ export async function createEmbeddedAuthkit(opts) {
|
|
|
131
132
|
users: {
|
|
132
133
|
async list(params = {}) {
|
|
133
134
|
const search = (params.search ?? '').trim();
|
|
134
|
-
const page = Math.max(
|
|
135
|
-
const
|
|
136
|
-
const result = await cfg.accountStore.listAccounts({ search, page,
|
|
135
|
+
const page = Math.max(LIST_FIRST_PAGE, params.page ?? LIST_FIRST_PAGE);
|
|
136
|
+
const size = Math.max(1, Math.min(ADMIN_LIST_MAX_SIZE, params.size ?? ADMIN_LIST_DEFAULT_SIZE));
|
|
137
|
+
const result = await cfg.accountStore.listAccounts({ search, page, size });
|
|
137
138
|
const data = await Promise.all(result.data.map((u) => userDto(u)));
|
|
138
|
-
return {
|
|
139
|
+
return { meta: { page, size, total: result.total }, data };
|
|
139
140
|
},
|
|
140
141
|
async get(id) {
|
|
141
142
|
const account = await cfg.accountStore.findById(id);
|
|
@@ -292,12 +293,12 @@ export async function createEmbeddedAuthkit(opts) {
|
|
|
292
293
|
if (!sink || typeof sink.list !== 'function') {
|
|
293
294
|
throw new Error('O sink de auditoria configurado não suporta consulta.');
|
|
294
295
|
}
|
|
295
|
-
const page = Math.max(
|
|
296
|
-
const
|
|
296
|
+
const page = Math.max(LIST_FIRST_PAGE, params.page ?? LIST_FIRST_PAGE);
|
|
297
|
+
const size = Math.max(1, Math.min(ADMIN_LIST_MAX_SIZE, params.size ?? ADMIN_LIST_DEFAULT_SIZE));
|
|
297
298
|
const type = params.type?.trim() || undefined;
|
|
298
299
|
const subject = params.subject?.trim() || undefined;
|
|
299
|
-
const result = await sink.list({ page,
|
|
300
|
-
return {
|
|
300
|
+
const result = await sink.list({ page, size, type, subject });
|
|
301
|
+
return { meta: { page, size, total: result.total }, data: result.data.map(auditDto) };
|
|
301
302
|
},
|
|
302
303
|
},
|
|
303
304
|
async stats() {
|
|
@@ -311,7 +312,8 @@ export async function createEmbeddedAuthkit(opts) {
|
|
|
311
312
|
},
|
|
312
313
|
},
|
|
313
314
|
organizations: (() => {
|
|
314
|
-
|
|
315
|
+
// `service` é obrigatório para a remoção revogar os grants da org na hora.
|
|
316
|
+
const orgsService = new AdminOrgsService(cfg, service);
|
|
315
317
|
const ACTOR = { actorId: null, ip: null, source: 'admin-api' };
|
|
316
318
|
const origin = (cfg.issuer ?? '').replace(/\/+$/, '');
|
|
317
319
|
function orgDto(org) {
|
package/build/src/types.d.ts
CHANGED
|
@@ -6,6 +6,18 @@
|
|
|
6
6
|
* kit. The embedded driver maps the server's runtime values into these exact
|
|
7
7
|
* shapes — keep them in sync with the server DTOs.
|
|
8
8
|
*/
|
|
9
|
+
/**
|
|
10
|
+
* Shared offset-pagination constants for the Authkit SDK listings. They mirror
|
|
11
|
+
* the `@adonis-agora/authkit-server` values of the same name (and, structurally,
|
|
12
|
+
* `@adonis-agora/filter`'s `{ page, size }` contract) — declared locally so the
|
|
13
|
+
* SDK keeps working against any supported server version.
|
|
14
|
+
*/
|
|
15
|
+
/** First page — pagination is 1-based. */
|
|
16
|
+
export declare const LIST_FIRST_PAGE = 1;
|
|
17
|
+
/** Default page size when a listing call omits `size`. */
|
|
18
|
+
export declare const ADMIN_LIST_DEFAULT_SIZE = 20;
|
|
19
|
+
/** Hard cap applied to a caller-supplied `size`. */
|
|
20
|
+
export declare const ADMIN_LIST_MAX_SIZE = 200;
|
|
9
21
|
/** A user/account as projected by the Admin API (`userDto`). */
|
|
10
22
|
export interface AuthkitUser {
|
|
11
23
|
id: string;
|
|
@@ -19,16 +31,40 @@ export interface AuthkitUser {
|
|
|
19
31
|
export interface AuthkitCreatedUser extends AuthkitUser {
|
|
20
32
|
invited: boolean;
|
|
21
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Offset pagination for `users.list`.
|
|
36
|
+
*
|
|
37
|
+
* `{ page, size }` intentionally mirrors `@adonis-agora/filter`'s
|
|
38
|
+
* `FilterInput.page`/`.size` so every `@adonis-agora/*` package exposes the same
|
|
39
|
+
* pagination interface. The match is STRUCTURAL on purpose — there is no
|
|
40
|
+
* dependency on `@adonis-agora/filter` here.
|
|
41
|
+
*/
|
|
22
42
|
export interface ListUsersParams {
|
|
23
43
|
search?: string;
|
|
44
|
+
/** 1-based page number. Default: 1. */
|
|
24
45
|
page?: number;
|
|
25
|
-
|
|
46
|
+
/** Page size. Default: 20; capped at {@link ADMIN_LIST_MAX_SIZE}. */
|
|
47
|
+
size?: number;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Pagination envelope of every paginated authkit listing.
|
|
51
|
+
*
|
|
52
|
+
* The `meta` key (and keeping `{ page, size }` inside it) is Lucid's own
|
|
53
|
+
* `.paginate()` convention — `{ meta, data }` — which is where
|
|
54
|
+
* `@adonis-agora/filter`'s offset path lands, and therefore the envelope every
|
|
55
|
+
* `@adonis-agora/*` package answers with.
|
|
56
|
+
*/
|
|
57
|
+
export interface ListMeta {
|
|
58
|
+
/** 1-based page returned. */
|
|
59
|
+
page: number;
|
|
60
|
+
/** Page size actually applied (already normalized/capped). */
|
|
61
|
+
size: number;
|
|
62
|
+
/** Absolute number of matching items across all pages. */
|
|
63
|
+
total: number;
|
|
26
64
|
}
|
|
27
65
|
export interface ListUsersResult {
|
|
66
|
+
meta: ListMeta;
|
|
28
67
|
data: AuthkitUser[];
|
|
29
|
-
total: number;
|
|
30
|
-
page: number;
|
|
31
|
-
limit: number;
|
|
32
68
|
}
|
|
33
69
|
export interface CreateUserInput {
|
|
34
70
|
email: string;
|
|
@@ -125,17 +161,21 @@ export interface AuthkitAuditEvent {
|
|
|
125
161
|
metadata: Record<string, unknown> | null;
|
|
126
162
|
createdAt: string;
|
|
127
163
|
}
|
|
164
|
+
/**
|
|
165
|
+
* Offset pagination for `audit.list` — same `{ page, size }` shape as
|
|
166
|
+
* {@link ListUsersParams} and `@adonis-agora/filter`.
|
|
167
|
+
*/
|
|
128
168
|
export interface ListAuditParams {
|
|
129
169
|
type?: string;
|
|
130
170
|
subject?: string;
|
|
171
|
+
/** 1-based page number. Default: 1. */
|
|
131
172
|
page?: number;
|
|
132
|
-
|
|
173
|
+
/** Page size. Default: 20; capped at {@link ADMIN_LIST_MAX_SIZE}. */
|
|
174
|
+
size?: number;
|
|
133
175
|
}
|
|
134
176
|
export interface ListAuditResult {
|
|
177
|
+
meta: ListMeta;
|
|
135
178
|
data: AuthkitAuditEvent[];
|
|
136
|
-
total: number;
|
|
137
|
-
page: number;
|
|
138
|
-
limit: number;
|
|
139
179
|
}
|
|
140
180
|
/** A daily series point (ISO `YYYY-MM-DD` day + count). */
|
|
141
181
|
export interface AuthkitDailyPoint {
|
package/build/src/types.js
CHANGED
|
@@ -6,4 +6,15 @@
|
|
|
6
6
|
* kit. The embedded driver maps the server's runtime values into these exact
|
|
7
7
|
* shapes — keep them in sync with the server DTOs.
|
|
8
8
|
*/
|
|
9
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Shared offset-pagination constants for the Authkit SDK listings. They mirror
|
|
11
|
+
* the `@adonis-agora/authkit-server` values of the same name (and, structurally,
|
|
12
|
+
* `@adonis-agora/filter`'s `{ page, size }` contract) — declared locally so the
|
|
13
|
+
* SDK keeps working against any supported server version.
|
|
14
|
+
*/
|
|
15
|
+
/** First page — pagination is 1-based. */
|
|
16
|
+
export const LIST_FIRST_PAGE = 1;
|
|
17
|
+
/** Default page size when a listing call omits `size`. */
|
|
18
|
+
export const ADMIN_LIST_DEFAULT_SIZE = 20;
|
|
19
|
+
/** Hard cap applied to a caller-supplied `size`. */
|
|
20
|
+
export const ADMIN_LIST_MAX_SIZE = 200;
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adonis-agora/authkit-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "Backend SDK for the AuthKit Admin API with one typed interface and two drivers: remote (HTTP/Bearer) and embedded (in-process when the IdP runs in the same AdonisJS app).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "dudousxd",
|
|
7
|
-
"homepage": "https://github.com/DavideCarvalho/adonis-agora-authkit/tree/main/packages/authkit-sdk#readme",
|
|
8
7
|
"repository": {
|
|
9
8
|
"type": "git",
|
|
10
9
|
"url": "https://github.com/DavideCarvalho/adonis-agora-authkit.git",
|
|
11
10
|
"directory": "packages/authkit-sdk"
|
|
12
11
|
},
|
|
12
|
+
"homepage": "https://davidecarvalho.github.io/agora/docs/authkit",
|
|
13
13
|
"bugs": {
|
|
14
14
|
"url": "https://github.com/DavideCarvalho/adonis-agora-authkit/issues"
|
|
15
15
|
},
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"./types": "./build/index.js"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"@
|
|
39
|
-
"@
|
|
38
|
+
"@adonis-agora/authkit-server": ">=0.10.0 <1.0.0",
|
|
39
|
+
"@adonisjs/core": "7.5.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependenciesMeta": {
|
|
42
42
|
"@adonisjs/core": {
|
|
@@ -47,14 +47,14 @@
|
|
|
47
47
|
}
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@
|
|
50
|
+
"@adonis-agora/authkit-server": "0.73.0",
|
|
51
|
+
"@adonisjs/core": "7.5.0",
|
|
51
52
|
"@adonisjs/tsconfig": "2.0.0",
|
|
52
53
|
"@japa/assert": "4.2.0",
|
|
53
54
|
"@japa/runner": "5.3.0",
|
|
54
55
|
"@poppinss/ts-exec": "1.4.4",
|
|
55
|
-
"@types/node": "
|
|
56
|
-
"typescript": "
|
|
57
|
-
"@adonis-agora/authkit-server": "0.58.1"
|
|
56
|
+
"@types/node": "26.5.1",
|
|
57
|
+
"typescript": "7.0.2"
|
|
58
58
|
},
|
|
59
59
|
"scripts": {
|
|
60
60
|
"build": "tsc",
|