primitive-admin 1.3.0-alpha.1 → 1.3.0-alpha.2
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/src/commands/admins.js +91 -0
- package/dist/src/commands/admins.js.map +1 -1
- package/dist/src/commands/auth-passkeys.d.ts +7 -0
- package/dist/src/commands/auth-passkeys.js +99 -0
- package/dist/src/commands/auth-passkeys.js.map +1 -0
- package/dist/src/commands/auth-sessions.js +7 -28
- package/dist/src/commands/auth-sessions.js.map +1 -1
- package/dist/src/commands/sync-app-settings.d.ts +88 -1
- package/dist/src/commands/sync-app-settings.js +224 -8
- package/dist/src/commands/sync-app-settings.js.map +1 -1
- package/dist/src/commands/sync.d.ts +0 -13
- package/dist/src/commands/sync.js +144 -4
- package/dist/src/commands/sync.js.map +1 -1
- package/dist/src/lib/admin-login-tables.d.ts +31 -0
- package/dist/src/lib/admin-login-tables.js +75 -0
- package/dist/src/lib/admin-login-tables.js.map +1 -0
- package/dist/src/lib/api-client.d.ts +76 -0
- package/dist/src/lib/api-client.js +69 -0
- package/dist/src/lib/api-client.js.map +1 -1
- package/dist/src/lib/app-settings-descriptor.d.ts +29 -2
- package/dist/src/lib/app-settings-descriptor.js +68 -3
- package/dist/src/lib/app-settings-descriptor.js.map +1 -1
- package/dist/src/lib/function-authorize-check.js +5 -0
- package/dist/src/lib/function-authorize-check.js.map +1 -1
- package/dist/src/lib/function-authorize-view.js +5 -4
- package/dist/src/lib/function-authorize-view.js.map +1 -1
- package/dist/src/lib/function-collect.d.ts +6 -0
- package/dist/src/lib/function-collect.js +10 -2
- package/dist/src/lib/function-collect.js.map +1 -1
- package/dist/src/lib/function-sync.d.ts +62 -0
- package/dist/src/lib/function-sync.js +68 -1
- package/dist/src/lib/function-sync.js.map +1 -1
- package/dist/src/lib/generated-command-status.js +5 -0
- package/dist/src/lib/generated-command-status.js.map +1 -1
- package/dist/src/lib/generated-config-surfaces.d.ts +79 -4
- package/dist/src/lib/generated-config-surfaces.js +226 -8
- package/dist/src/lib/generated-config-surfaces.js.map +1 -1
- package/dist/src/lib/generated-sdk-types.d.ts +1 -1
- package/dist/src/lib/generated-sdk-types.js +1 -1
- package/dist/src/lib/generated-sdk-types.js.map +1 -1
- package/dist/src/types/index.d.ts +9 -0
- package/package.json +2 -2
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Admin login v2 (#5979) — the tables `primitive auth sessions list` and
|
|
3
|
+
* `primitive admins auth-events` print, and the auth-events selector check.
|
|
4
|
+
*
|
|
5
|
+
* Pure: no request is made here, so the commands' output rules are tested
|
|
6
|
+
* directly and their requests only against the live server.
|
|
7
|
+
*/
|
|
8
|
+
import { type TableColumn } from "./output.js";
|
|
9
|
+
/** The most of a session's user agent the table shows; `--json` carries it whole. */
|
|
10
|
+
export declare const USER_AGENT_COLUMN_WIDTH = 48;
|
|
11
|
+
/** A user agent cut to the table's column, ending in an ellipsis when cut. */
|
|
12
|
+
export declare function truncateUserAgent(value: unknown): string;
|
|
13
|
+
/**
|
|
14
|
+
* The columns of `primitive auth sessions list`. The login columns appear
|
|
15
|
+
* only when a row on the page was signed in by the browser login v2, so a
|
|
16
|
+
* page of older sessions prints the table it always did.
|
|
17
|
+
*/
|
|
18
|
+
export declare function sessionTableColumns(rows: readonly Record<string, any>[]): TableColumn[];
|
|
19
|
+
/** The columns of `primitive admins auth-events`. LOGIN is the login's attempt key. */
|
|
20
|
+
export declare const AUTH_EVENT_COLUMNS: readonly TableColumn[];
|
|
21
|
+
/** The refusal printed when `admins auth-events` names neither or both selectors. */
|
|
22
|
+
export declare const AUTH_EVENTS_SELECTOR_ERROR = "Name exactly one of <admin-id> and --email.";
|
|
23
|
+
/**
|
|
24
|
+
* Which events `admins auth-events` asks for: the admin id or the address,
|
|
25
|
+
* exactly one of them, or null when it names neither or both.
|
|
26
|
+
*/
|
|
27
|
+
export declare function authEventsSelector(adminId: string | undefined, email: string | undefined): {
|
|
28
|
+
adminId: string;
|
|
29
|
+
} | {
|
|
30
|
+
email: string;
|
|
31
|
+
} | null;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Admin login v2 (#5979) — the tables `primitive auth sessions list` and
|
|
3
|
+
* `primitive admins auth-events` print, and the auth-events selector check.
|
|
4
|
+
*
|
|
5
|
+
* Pure: no request is made here, so the commands' output rules are tested
|
|
6
|
+
* directly and their requests only against the live server.
|
|
7
|
+
*/
|
|
8
|
+
import { formatDate } from "./output.js";
|
|
9
|
+
/** The most of a session's user agent the table shows; `--json` carries it whole. */
|
|
10
|
+
export const USER_AGENT_COLUMN_WIDTH = 48;
|
|
11
|
+
const text = (v) => (typeof v === "string" && v ? v : "—");
|
|
12
|
+
/** A user agent cut to the table's column, ending in an ellipsis when cut. */
|
|
13
|
+
export function truncateUserAgent(value) {
|
|
14
|
+
if (typeof value !== "string" || !value)
|
|
15
|
+
return "—";
|
|
16
|
+
return value.length > USER_AGENT_COLUMN_WIDTH ? `${value.slice(0, USER_AGENT_COLUMN_WIDTH - 1)}…` : value;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The columns of `primitive auth sessions list`. The login columns appear
|
|
20
|
+
* only when a row on the page was signed in by the browser login v2, so a
|
|
21
|
+
* page of older sessions prints the table it always did.
|
|
22
|
+
*/
|
|
23
|
+
export function sessionTableColumns(rows) {
|
|
24
|
+
const loginColumns = rows.some((row) => typeof row.authMethod === "string" && row.authMethod)
|
|
25
|
+
? [
|
|
26
|
+
{ header: "METHOD", key: "authMethod", format: text },
|
|
27
|
+
{ header: "SIGNED IN", key: "authenticatedAt", format: formatDate },
|
|
28
|
+
{ header: "IP", key: "ip", format: text },
|
|
29
|
+
{ header: "USER AGENT", key: "userAgent", format: truncateUserAgent },
|
|
30
|
+
]
|
|
31
|
+
: [];
|
|
32
|
+
return [
|
|
33
|
+
{ header: "SESSION", key: "sessionId" },
|
|
34
|
+
{ header: "KIND", key: "kind" },
|
|
35
|
+
{ header: "NAME", key: "name", format: text },
|
|
36
|
+
{
|
|
37
|
+
header: "SCOPE",
|
|
38
|
+
key: "scope",
|
|
39
|
+
format: (v) => (Array.isArray(v) ? v.join(",") : String(v ?? "full")),
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
header: "APPS",
|
|
43
|
+
key: "apps",
|
|
44
|
+
format: (v) => (Array.isArray(v) && v.length > 0 ? v.join(",") : "—"),
|
|
45
|
+
},
|
|
46
|
+
{ header: "STATUS", key: "status" },
|
|
47
|
+
{ header: "CREATED", key: "createdAt", format: formatDate },
|
|
48
|
+
{ header: "LAST REFRESH", key: "lastRefreshAt", format: formatDate },
|
|
49
|
+
{ header: "EXPIRES", key: "expiresAt", format: formatDate },
|
|
50
|
+
...loginColumns,
|
|
51
|
+
{ header: "CURRENT", key: "current", format: (v) => (v ? "yes" : "") },
|
|
52
|
+
];
|
|
53
|
+
}
|
|
54
|
+
/** The columns of `primitive admins auth-events`. LOGIN is the login's attempt key. */
|
|
55
|
+
export const AUTH_EVENT_COLUMNS = [
|
|
56
|
+
{ header: "TIME", key: "createdAt", format: formatDate },
|
|
57
|
+
{ header: "TYPE", key: "type" },
|
|
58
|
+
{ header: "METHOD", key: "method", format: text },
|
|
59
|
+
{ header: "IP", key: "ip", format: text },
|
|
60
|
+
{ header: "REASON", key: "reason", format: text },
|
|
61
|
+
{ header: "ACTOR", key: "actorAdminId", format: text },
|
|
62
|
+
{ header: "LOGIN", key: "attemptKey", format: text },
|
|
63
|
+
];
|
|
64
|
+
/** The refusal printed when `admins auth-events` names neither or both selectors. */
|
|
65
|
+
export const AUTH_EVENTS_SELECTOR_ERROR = "Name exactly one of <admin-id> and --email.";
|
|
66
|
+
/**
|
|
67
|
+
* Which events `admins auth-events` asks for: the admin id or the address,
|
|
68
|
+
* exactly one of them, or null when it names neither or both.
|
|
69
|
+
*/
|
|
70
|
+
export function authEventsSelector(adminId, email) {
|
|
71
|
+
if (Boolean(adminId) === Boolean(email))
|
|
72
|
+
return null;
|
|
73
|
+
return adminId ? { adminId } : { email: email };
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=admin-login-tables.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin-login-tables.js","sourceRoot":"","sources":["../../../src/lib/admin-login-tables.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,UAAU,EAAoB,MAAM,aAAa,CAAC;AAE3D,qFAAqF;AACrF,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAE1C,MAAM,IAAI,GAAG,CAAC,CAAU,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AAEpE,8EAA8E;AAC9E,MAAM,UAAU,iBAAiB,CAAC,KAAc;IAC9C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK;QAAE,OAAO,GAAG,CAAC;IACpD,OAAO,KAAK,CAAC,MAAM,GAAG,uBAAuB,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,uBAAuB,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC;AAC5G,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAoC;IACtE,MAAM,YAAY,GAAkB,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,GAAG,CAAC,UAAU,KAAK,QAAQ,IAAI,GAAG,CAAC,UAAU,CAAC;QAC1G,CAAC,CAAC;YACE,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE;YACrD,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,EAAE,iBAAiB,EAAE,MAAM,EAAE,UAAU,EAAE;YACnE,EAAE,MAAM,EAAE,IA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,43 @@ export interface AppSecretReferences {
|
|
|
1415
1415
|
references: AppSecretReference[];
|
|
1416
1416
|
truncated: boolean;
|
|
1417
1417
|
}
|
|
1418
|
+
/** One of the caller's admin passkeys, as `GET /admin/api/auth/passkeys` lists it (#5978). */
|
|
1419
|
+
export interface AdminPasskeySummary {
|
|
1420
|
+
passkeyId: string;
|
|
1421
|
+
/** The login app's host the passkey is registered with. */
|
|
1422
|
+
rpId: string;
|
|
1423
|
+
deviceName: string | null;
|
|
1424
|
+
createdAt: string | null;
|
|
1425
|
+
lastUsedAt: string | null;
|
|
1426
|
+
}
|
|
1427
|
+
/** One admin sign-in audit event, as `GET /super-admin/api/auth-events` lists it; `null` for an absent field. */
|
|
1428
|
+
export interface AdminAuthEventItem {
|
|
1429
|
+
eventId: string;
|
|
1430
|
+
type: string;
|
|
1431
|
+
createdAt: string | null;
|
|
1432
|
+
adminId: string | null;
|
|
1433
|
+
email: string | null;
|
|
1434
|
+
method: string | null;
|
|
1435
|
+
ip: string | null;
|
|
1436
|
+
userAgent: string | null;
|
|
1437
|
+
/** The login's hashed attempt key, as the server logs it (`attempt=`). */
|
|
1438
|
+
attemptKey: string | null;
|
|
1439
|
+
sessionId: string | null;
|
|
1440
|
+
reason: string | null;
|
|
1441
|
+
passkeyId: string | null;
|
|
1442
|
+
actorAdminId: string | null;
|
|
1443
|
+
}
|
|
1444
|
+
/** What a sign-in reset answers (#5978). */
|
|
1445
|
+
export interface AdminSignInReset {
|
|
1446
|
+
adminId: string;
|
|
1447
|
+
/** Passkey rows this reset deleted. */
|
|
1448
|
+
passkeysRemoved: number;
|
|
1449
|
+
/** Whether a bound Google account was cleared. */
|
|
1450
|
+
googleSubjectCleared: boolean;
|
|
1451
|
+
resetAt: string;
|
|
1452
|
+
/** False when some passkey rows were left; they can no longer sign in, and a second reset removes them. */
|
|
1453
|
+
cleanupComplete: boolean;
|
|
1454
|
+
}
|
|
1418
1455
|
export declare class ApiClient {
|
|
1419
1456
|
/**
|
|
1420
1457
|
* Loaded on first use (`ensureAuthenticated`), never in a constructor.
|
|
@@ -2289,6 +2326,45 @@ export declare class ApiClient {
|
|
|
2289
2326
|
sessionId: string;
|
|
2290
2327
|
revokedAt: string;
|
|
2291
2328
|
}>;
|
|
2329
|
+
/** The caller's admin passkeys under every relying party, newest first (#5978). */
|
|
2330
|
+
listAdminPasskeys(): Promise<{
|
|
2331
|
+
items: AdminPasskeySummary[];
|
|
2332
|
+
hasMore: boolean;
|
|
2333
|
+
}>;
|
|
2334
|
+
/**
|
|
2335
|
+
* One page of an admin's, or an address's, sign-in audit events, newest
|
|
2336
|
+
* first (super-admin). Exactly one of `adminId` and `email` is sent.
|
|
2337
|
+
*/
|
|
2338
|
+
listAdminAuthEvents(params: {
|
|
2339
|
+
adminId?: string;
|
|
2340
|
+
email?: string;
|
|
2341
|
+
limit?: number;
|
|
2342
|
+
cursor?: string;
|
|
2343
|
+
}): Promise<{
|
|
2344
|
+
items: AdminAuthEventItem[];
|
|
2345
|
+
hasMore: boolean;
|
|
2346
|
+
nextCursor: string | null;
|
|
2347
|
+
}>;
|
|
2348
|
+
/** Delete one of the caller's admin passkeys (#5978). */
|
|
2349
|
+
deleteAdminPasskey(passkeyId: string): Promise<{
|
|
2350
|
+
passkeyId: string;
|
|
2351
|
+
deleted: boolean;
|
|
2352
|
+
}>;
|
|
2353
|
+
/**
|
|
2354
|
+
* Reset another admin's sign-in (#5978, super-admin): clear their passkeys
|
|
2355
|
+
* and bound Google account. The route needs an unpinned `admin` step-up,
|
|
2356
|
+
* so a usable stored one is sent first; otherwise the login is, and the
|
|
2357
|
+
* server's refusal names the step-up command.
|
|
2358
|
+
*/
|
|
2359
|
+
resetAdminSignIn(adminId: string): Promise<AdminSignInReset>;
|
|
2360
|
+
/**
|
|
2361
|
+
* Send one request with the stored step-up when it can act on a platform
|
|
2362
|
+
* route that needs `admin`: unexpired, holding `admin`, and unpinned.
|
|
2363
|
+
* Answers `{ sent: false }` when there is no such step-up, or when the
|
|
2364
|
+
* server answered it 401 (it is dropped); the caller then sends the login.
|
|
2365
|
+
* Any other refusal throws as `request` would.
|
|
2366
|
+
*/
|
|
2367
|
+
private sendWithAdminStepUp;
|
|
2292
2368
|
listLocks(appId: string): Promise<{
|
|
2293
2369
|
locks: any[];
|
|
2294
2370
|
}>;
|
|
@@ -1417,6 +1417,75 @@ export class ApiClient {
|
|
|
1417
1417
|
async revokeAdminSession(sessionId) {
|
|
1418
1418
|
return this.delete(`/admin/api/auth/sessions/${encodeURIComponent(sessionId)}`);
|
|
1419
1419
|
}
|
|
1420
|
+
/** The caller's admin passkeys under every relying party, newest first (#5978). */
|
|
1421
|
+
async listAdminPasskeys() {
|
|
1422
|
+
const result = await this.get("/admin/api/auth/passkeys");
|
|
1423
|
+
return { items: result?.items ?? [], hasMore: Boolean(result?.hasMore) };
|
|
1424
|
+
}
|
|
1425
|
+
/**
|
|
1426
|
+
* One page of an admin's, or an address's, sign-in audit events, newest
|
|
1427
|
+
* first (super-admin). Exactly one of `adminId` and `email` is sent.
|
|
1428
|
+
*/
|
|
1429
|
+
async listAdminAuthEvents(params) {
|
|
1430
|
+
const result = await this.get("/super-admin/api/auth-events", params);
|
|
1431
|
+
return {
|
|
1432
|
+
items: result?.items ?? [],
|
|
1433
|
+
hasMore: Boolean(result?.hasMore),
|
|
1434
|
+
nextCursor: result?.nextCursor ?? null,
|
|
1435
|
+
};
|
|
1436
|
+
}
|
|
1437
|
+
/** Delete one of the caller's admin passkeys (#5978). */
|
|
1438
|
+
async deleteAdminPasskey(passkeyId) {
|
|
1439
|
+
return this.delete(`/admin/api/auth/passkeys/${encodeURIComponent(passkeyId)}`);
|
|
1440
|
+
}
|
|
1441
|
+
/**
|
|
1442
|
+
* Reset another admin's sign-in (#5978, super-admin): clear their passkeys
|
|
1443
|
+
* and bound Google account. The route needs an unpinned `admin` step-up,
|
|
1444
|
+
* so a usable stored one is sent first; otherwise the login is, and the
|
|
1445
|
+
* server's refusal names the step-up command.
|
|
1446
|
+
*/
|
|
1447
|
+
async resetAdminSignIn(adminId) {
|
|
1448
|
+
const path = `/super-admin/api/admins/${encodeURIComponent(adminId)}/reset-sign-in`;
|
|
1449
|
+
const withStepUp = await this.sendWithAdminStepUp(path, "POST");
|
|
1450
|
+
if (withStepUp.sent)
|
|
1451
|
+
return withStepUp.body;
|
|
1452
|
+
return this.request(path, { method: "POST" });
|
|
1453
|
+
}
|
|
1454
|
+
/**
|
|
1455
|
+
* Send one request with the stored step-up when it can act on a platform
|
|
1456
|
+
* route that needs `admin`: unexpired, holding `admin`, and unpinned.
|
|
1457
|
+
* Answers `{ sent: false }` when there is no such step-up, or when the
|
|
1458
|
+
* server answered it 401 (it is dropped); the caller then sends the login.
|
|
1459
|
+
* Any other refusal throws as `request` would.
|
|
1460
|
+
*/
|
|
1461
|
+
async sendWithAdminStepUp(path, method) {
|
|
1462
|
+
const credentials = await this.ensureAuthenticated();
|
|
1463
|
+
const stepUp = credentials.stepUp;
|
|
1464
|
+
const usable = Boolean(stepUp?.accessToken) &&
|
|
1465
|
+
new Date(stepUp.expiresAt).getTime() > Date.now() &&
|
|
1466
|
+
(stepUp.scope ?? []).includes("admin") &&
|
|
1467
|
+
(stepUp.apps ?? []).length === 0;
|
|
1468
|
+
if (!usable)
|
|
1469
|
+
return { sent: false };
|
|
1470
|
+
const headers = {
|
|
1471
|
+
Authorization: `Bearer ${stepUp.accessToken}`,
|
|
1472
|
+
"Content-Type": "application/json",
|
|
1473
|
+
[CLI_VERSION_HEADER]: (cliVersion ??= cliVersionHeaderValue()),
|
|
1474
|
+
};
|
|
1475
|
+
if (credentials.globalAdminAppId) {
|
|
1476
|
+
headers["X-Global-Admin-App-Id"] = credentials.globalAdminAppId;
|
|
1477
|
+
}
|
|
1478
|
+
const response = await fetchWithTLS(`${credentials.serverUrl}${path}`, { method, headers });
|
|
1479
|
+
const text = await response.text();
|
|
1480
|
+
if (response.status === 401) {
|
|
1481
|
+
this.dropStepUp();
|
|
1482
|
+
return { sent: false };
|
|
1483
|
+
}
|
|
1484
|
+
if (!response.ok)
|
|
1485
|
+
throw this.responseError(response, text, path);
|
|
1486
|
+
this.lastStatus = response.status;
|
|
1487
|
+
return { sent: true, body: (text ? JSON.parse(text) : null) };
|
|
1488
|
+
}
|
|
1420
1489
|
// ============================================
|
|
1421
1490
|
// NAMED LOCKS (#1518)
|
|
1422
1491
|
// ============================================
|