@fonderie/client 1.4.0 → 1.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/brain/signatures.md +90 -1
- package/dist/index.cjs +102 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +128 -2
- package/dist/index.d.ts +128 -2
- package/dist/index.js +100 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/brain/signatures.md
CHANGED
|
@@ -240,6 +240,7 @@ interface ISetConfigInput {
|
|
|
240
240
|
description?: string;
|
|
241
241
|
active?: boolean;
|
|
242
242
|
ifVersion?: number;
|
|
243
|
+
allowTypeChange?: boolean;
|
|
243
244
|
}
|
|
244
245
|
|
|
245
246
|
interface ISetSecretInput {
|
|
@@ -266,7 +267,7 @@ new ConfigAdminClient(opts: IConfigAdminClientOptions): ConfigAdminClient
|
|
|
266
267
|
|
|
267
268
|
interface IAdminClientOptions {
|
|
268
269
|
baseUrl: string;
|
|
269
|
-
adminToken
|
|
270
|
+
adminToken?: string;
|
|
270
271
|
prefix?: string;
|
|
271
272
|
actor?: string;
|
|
272
273
|
}
|
|
@@ -288,6 +289,21 @@ new AdminClient(opts: IAdminClientOptions): AdminClient
|
|
|
288
289
|
.revokeToken(id: string): Promise<IApiResponse<undefined>>
|
|
289
290
|
.migrations(): Promise<IApiResponse<IAdminMigrationsReport>>
|
|
290
291
|
.applyMigrations(module: string, expect: readonly string[]): Promise<IApiResponse<IAdminMigrationModule>>
|
|
292
|
+
.session(): Promise<IApiResponse<IAdminSession>>
|
|
293
|
+
.claim(input: { email: string; password: string; name?: string; }): Promise<IApiResponse<IAdminSession>>
|
|
294
|
+
.login(input: { email: string; password: string; }): Promise<IApiResponse<IAdminSession>>
|
|
295
|
+
.enrollment(): Promise<IApiResponse<IAdminEnrollment>>
|
|
296
|
+
.confirmEnrollment(code: string): Promise<IApiResponse<IAdminSession>>
|
|
297
|
+
.verify(factor: IAdminSecondFactor): Promise<IApiResponse<IAdminSession>>
|
|
298
|
+
.stepUp(factor: IAdminSecondFactor): Promise<IApiResponse<{ stepUpFresh: boolean; backupCodesLeft?: number; }>>
|
|
299
|
+
.logout(): Promise<IApiResponse<undefined>>
|
|
300
|
+
.inspectLink(token: string): Promise<IApiResponse<{ kind: "invite" | "recovery"; email: string; }>>
|
|
301
|
+
.redeemLink(input: { token: string; password: string; name?: string; }): Promise<IApiResponse<IAdminSession>>
|
|
302
|
+
.operators(): Promise<IApiResponse<IAdminOperatorsReport>>
|
|
303
|
+
.inviteOperator(input: { email: string; scopes: AdminScope[]; expiresInHours?: number; }): Promise<IApiResponse<IAdminCreatedLink>>
|
|
304
|
+
.recoverOperator(id: string): Promise<IApiResponse<IAdminCreatedLink>>
|
|
305
|
+
.updateOperator(id: string, input: { scopes?: AdminScope[]; name?: string; disabled?: boolean; }): Promise<IApiResponse<IAdminOperator>>
|
|
306
|
+
.revokeOperatorLink(id: string): Promise<IApiResponse<undefined>>
|
|
291
307
|
|
|
292
308
|
interface IAuthAdminClientOptions {
|
|
293
309
|
baseUrl: string;
|
|
@@ -877,6 +893,68 @@ interface IAdminTokenRecord {
|
|
|
877
893
|
lastUsedAt: string | null;
|
|
878
894
|
}
|
|
879
895
|
|
|
896
|
+
interface IAdminOperator {
|
|
897
|
+
id: string;
|
|
898
|
+
email: string;
|
|
899
|
+
name: string | null;
|
|
900
|
+
scopes: AdminScope[];
|
|
901
|
+
enrolled: boolean;
|
|
902
|
+
backupCodesLeft: number;
|
|
903
|
+
locked: boolean;
|
|
904
|
+
createdBy: string;
|
|
905
|
+
createdAt: string;
|
|
906
|
+
lastLoginAt: string | null;
|
|
907
|
+
disabledAt: string | null;
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
interface IAdminOperatorLink {
|
|
911
|
+
id: string;
|
|
912
|
+
kind: 'invite' | 'recovery';
|
|
913
|
+
email: string;
|
|
914
|
+
scopes: AdminScope[];
|
|
915
|
+
createdBy: string;
|
|
916
|
+
createdAt: string;
|
|
917
|
+
expiresAt: string;
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
interface IAdminOperatorsReport {
|
|
921
|
+
operators: IAdminOperator[];
|
|
922
|
+
links: IAdminOperatorLink[];
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
interface IAdminCreatedLink {
|
|
926
|
+
id: string;
|
|
927
|
+
email: string;
|
|
928
|
+
scopes?: AdminScope[];
|
|
929
|
+
expiresAt: string;
|
|
930
|
+
token: string;
|
|
931
|
+
url: string;
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
type AdminSessionState = 'signed-out' | 'needs-2fa' | 'needs-enrollment' | 'signed-in';
|
|
935
|
+
|
|
936
|
+
interface IAdminSession {
|
|
937
|
+
state: AdminSessionState;
|
|
938
|
+
operator: IAdminOperator | null;
|
|
939
|
+
claimable?: boolean;
|
|
940
|
+
stepUpFresh?: boolean;
|
|
941
|
+
backupCodes?: string[];
|
|
942
|
+
backupCodesLeft?: number;
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
interface IAdminEnrollment {
|
|
946
|
+
secret: string;
|
|
947
|
+
uri: string;
|
|
948
|
+
account: string;
|
|
949
|
+
issuer: string;
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
type IAdminSecondFactor = {
|
|
953
|
+
code: string;
|
|
954
|
+
} | {
|
|
955
|
+
backupCode: string;
|
|
956
|
+
};
|
|
957
|
+
|
|
880
958
|
interface IAdminIssueTokenInput {
|
|
881
959
|
name: string;
|
|
882
960
|
scopes: AdminScope[];
|
|
@@ -1602,10 +1680,14 @@ function castConfigValue(type: ConfigValueType, raw: string): CastResult
|
|
|
1602
1680
|
|
|
1603
1681
|
function configKeyProblem(key: string): string | null
|
|
1604
1682
|
|
|
1683
|
+
function configValueLabel(value: unknown): string
|
|
1684
|
+
|
|
1605
1685
|
function configValueType(value: unknown): ConfigValueType
|
|
1606
1686
|
|
|
1607
1687
|
function formatConfigValue(value: unknown, type?: ConfigValueType): string
|
|
1608
1688
|
|
|
1689
|
+
function inferConfigValue(raw: string): IInferredConfigValue
|
|
1690
|
+
|
|
1609
1691
|
type CastResult = {
|
|
1610
1692
|
ok: true;
|
|
1611
1693
|
value: unknown;
|
|
@@ -1616,6 +1698,13 @@ type CastResult = {
|
|
|
1616
1698
|
|
|
1617
1699
|
type ConfigValueType = 'string' | 'number' | 'boolean' | 'json';
|
|
1618
1700
|
|
|
1701
|
+
interface IInferredConfigValue {
|
|
1702
|
+
type: ConfigValueType;
|
|
1703
|
+
value: unknown;
|
|
1704
|
+
label: string;
|
|
1705
|
+
ambiguous: boolean;
|
|
1706
|
+
}
|
|
1707
|
+
|
|
1619
1708
|
new ConfigClient(http: HttpClient, tokens: TokenStore): ConfigClient
|
|
1620
1709
|
.load(): Promise<IRemoteConfigState>
|
|
1621
1710
|
.get<T>(key: string, fallback: T): T
|
package/dist/index.cjs
CHANGED
|
@@ -40,10 +40,12 @@ __export(index_exports, {
|
|
|
40
40
|
WorkspacesClient: () => WorkspacesClient,
|
|
41
41
|
castConfigValue: () => castConfigValue,
|
|
42
42
|
configKeyProblem: () => configKeyProblem,
|
|
43
|
+
configValueLabel: () => configValueLabel,
|
|
43
44
|
configValueType: () => configValueType,
|
|
44
45
|
createMemoryCache: () => createMemoryCache,
|
|
45
46
|
describeLocation: () => describeLocation,
|
|
46
47
|
formatConfigValue: () => formatConfigValue,
|
|
48
|
+
inferConfigValue: () => inferConfigValue,
|
|
47
49
|
isMfaRequired: () => isMfaRequired
|
|
48
50
|
});
|
|
49
51
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -1915,6 +1917,75 @@ var AdminClient = class {
|
|
|
1915
1917
|
{ expect }
|
|
1916
1918
|
);
|
|
1917
1919
|
}
|
|
1920
|
+
// ── operator sign-in (the served console's gate) ──────────────────────
|
|
1921
|
+
// Cookie-based: the server sets an HttpOnly session cookie; nothing here
|
|
1922
|
+
// ever holds it. Omit adminToken on this client — except for claim().
|
|
1923
|
+
/** Who is signed in, and whether the console can still be claimed. */
|
|
1924
|
+
session() {
|
|
1925
|
+
return this.get("/session");
|
|
1926
|
+
}
|
|
1927
|
+
/** The one-time claim. Needs the ROOT token as this client's adminToken. */
|
|
1928
|
+
claim(input) {
|
|
1929
|
+
return this.call("POST", "/session/claim", input);
|
|
1930
|
+
}
|
|
1931
|
+
login(input) {
|
|
1932
|
+
return this.call("POST", "/session/login", input);
|
|
1933
|
+
}
|
|
1934
|
+
/** The authenticator secret and otpauth URI to scan while enrolling. */
|
|
1935
|
+
enrollment() {
|
|
1936
|
+
return this.get("/session/enrollment");
|
|
1937
|
+
}
|
|
1938
|
+
/** Confirms the first code. The response carries the backup codes, once. */
|
|
1939
|
+
confirmEnrollment(code) {
|
|
1940
|
+
return this.call("POST", "/session/enrollment", { code });
|
|
1941
|
+
}
|
|
1942
|
+
/** The second factor after the password: an authenticator code or a backup code. */
|
|
1943
|
+
verify(factor) {
|
|
1944
|
+
return this.call("POST", "/session/verify", factor);
|
|
1945
|
+
}
|
|
1946
|
+
/** A fresh code for the next five minutes of dangerous actions. */
|
|
1947
|
+
stepUp(factor) {
|
|
1948
|
+
return this.call(
|
|
1949
|
+
"POST",
|
|
1950
|
+
"/session/step-up",
|
|
1951
|
+
factor
|
|
1952
|
+
);
|
|
1953
|
+
}
|
|
1954
|
+
logout() {
|
|
1955
|
+
return this.call("DELETE", "/session");
|
|
1956
|
+
}
|
|
1957
|
+
/** What an invite or recovery link is for, before setting a password. */
|
|
1958
|
+
inspectLink(token) {
|
|
1959
|
+
return this.call(
|
|
1960
|
+
"POST",
|
|
1961
|
+
"/session/link/inspect",
|
|
1962
|
+
{ token }
|
|
1963
|
+
);
|
|
1964
|
+
}
|
|
1965
|
+
redeemLink(input) {
|
|
1966
|
+
return this.call("POST", "/session/link", input);
|
|
1967
|
+
}
|
|
1968
|
+
// ── managing operators ─────────────────────────────────────────────────
|
|
1969
|
+
operators() {
|
|
1970
|
+
return this.get("/access/operators");
|
|
1971
|
+
}
|
|
1972
|
+
/** An invite link, shown once. Needs the highest scope and a fresh code. */
|
|
1973
|
+
inviteOperator(input) {
|
|
1974
|
+
return this.call("POST", "/access/operators/invites", input);
|
|
1975
|
+
}
|
|
1976
|
+
/** Lost password or authenticator: a single-use link; signs them out everywhere. */
|
|
1977
|
+
recoverOperator(id) {
|
|
1978
|
+
return this.call(
|
|
1979
|
+
"POST",
|
|
1980
|
+
`/access/operators/${encodeURIComponent(id)}/recovery`
|
|
1981
|
+
);
|
|
1982
|
+
}
|
|
1983
|
+
updateOperator(id, input) {
|
|
1984
|
+
return this.call("PUT", `/access/operators/${encodeURIComponent(id)}`, input);
|
|
1985
|
+
}
|
|
1986
|
+
revokeOperatorLink(id) {
|
|
1987
|
+
return this.call("DELETE", `/access/operators/links/${encodeURIComponent(id)}`);
|
|
1988
|
+
}
|
|
1918
1989
|
};
|
|
1919
1990
|
|
|
1920
1991
|
// src/modules/auth-admin.ts
|
|
@@ -2230,6 +2301,35 @@ function configKeyProblem(key) {
|
|
|
2230
2301
|
if (!key) return "Enter a key.";
|
|
2231
2302
|
return CONFIG_KEY_PATTERN.test(key) ? null : 'Start with a letter; use letters, digits, ".", "_" or "-" (max 128).';
|
|
2232
2303
|
}
|
|
2304
|
+
var PLAIN_NUMBER = /^-?(0|[1-9]\d*)(\.\d+)?$/;
|
|
2305
|
+
function configValueLabel(value) {
|
|
2306
|
+
if (typeof value === "string") return "Text";
|
|
2307
|
+
if (typeof value === "number") return "Number";
|
|
2308
|
+
if (typeof value === "boolean") return "On/off";
|
|
2309
|
+
if (Array.isArray(value)) return "List";
|
|
2310
|
+
if (value === null) return "Empty";
|
|
2311
|
+
return "Object";
|
|
2312
|
+
}
|
|
2313
|
+
function inferConfigValue(raw) {
|
|
2314
|
+
const t = raw.trim();
|
|
2315
|
+
if (t === "true" || t === "false") {
|
|
2316
|
+
return { type: "boolean", value: t === "true", label: "On/off", ambiguous: true };
|
|
2317
|
+
}
|
|
2318
|
+
if (PLAIN_NUMBER.test(t)) {
|
|
2319
|
+
const n = Number(t);
|
|
2320
|
+
if (Number.isFinite(n) && String(n) === t) return { type: "number", value: n, label: "Number", ambiguous: true };
|
|
2321
|
+
}
|
|
2322
|
+
if (t.startsWith("{") || t.startsWith("[")) {
|
|
2323
|
+
try {
|
|
2324
|
+
const parsed = JSON.parse(t);
|
|
2325
|
+
if (parsed !== null && typeof parsed === "object") {
|
|
2326
|
+
return { type: "json", value: parsed, label: Array.isArray(parsed) ? "List" : "Object", ambiguous: false };
|
|
2327
|
+
}
|
|
2328
|
+
} catch {
|
|
2329
|
+
}
|
|
2330
|
+
}
|
|
2331
|
+
return { type: "string", value: raw, label: "Text", ambiguous: false };
|
|
2332
|
+
}
|
|
2233
2333
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2234
2334
|
0 && (module.exports = {
|
|
2235
2335
|
AdminClient,
|
|
@@ -2252,10 +2352,12 @@ function configKeyProblem(key) {
|
|
|
2252
2352
|
WorkspacesClient,
|
|
2253
2353
|
castConfigValue,
|
|
2254
2354
|
configKeyProblem,
|
|
2355
|
+
configValueLabel,
|
|
2255
2356
|
configValueType,
|
|
2256
2357
|
createMemoryCache,
|
|
2257
2358
|
describeLocation,
|
|
2258
2359
|
formatConfigValue,
|
|
2360
|
+
inferConfigValue,
|
|
2259
2361
|
isMfaRequired
|
|
2260
2362
|
});
|
|
2261
2363
|
//# sourceMappingURL=index.cjs.map
|