@milaboratories/pl-client 3.15.0 → 3.16.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/dist/core/capabilities.cjs.map +1 -1
- package/dist/core/capabilities.d.ts +1 -1
- package/dist/core/capabilities.d.ts.map +1 -1
- package/dist/core/capabilities.js.map +1 -1
- package/dist/core/ll_client.cjs +35 -18
- package/dist/core/ll_client.cjs.map +1 -1
- package/dist/core/ll_client.d.ts +12 -5
- package/dist/core/ll_client.d.ts.map +1 -1
- package/dist/core/ll_client.js +35 -18
- package/dist/core/ll_client.js.map +1 -1
- package/dist/core/transaction.cjs +2 -1
- package/dist/core/transaction.cjs.map +1 -1
- package/dist/core/transaction.d.ts.map +1 -1
- package/dist/core/transaction.js +2 -1
- package/dist/core/transaction.js.map +1 -1
- package/dist/core/unauth_client.cjs +79 -32
- package/dist/core/unauth_client.cjs.map +1 -1
- package/dist/core/unauth_client.d.ts +49 -14
- package/dist/core/unauth_client.d.ts.map +1 -1
- package/dist/core/unauth_client.js +79 -32
- package/dist/core/unauth_client.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.cjs +150 -18
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.cjs.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.d.ts +127 -9
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.d.ts.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.js +150 -18
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.js.map +1 -1
- package/dist/proto-rest/plapi.d.ts +8 -2
- package/dist/proto-rest/plapi.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/core/capabilities.ts +4 -0
- package/src/core/ll_client.ts +25 -13
- package/src/core/transaction.ts +2 -0
- package/src/core/unauth_client.test.ts +69 -1
- package/src/core/unauth_client.ts +108 -34
- package/src/core/unauth_client_branch.test.ts +416 -5
- package/src/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.ts +225 -15
- package/src/proto-rest/plapi.ts +8 -2
|
@@ -12,6 +12,7 @@ export type SSOFlowType = "public_pkce";
|
|
|
12
12
|
* may surface (`userIdClaim`, `groupsClaim`). */
|
|
13
13
|
export type SSOAuthMethod = {
|
|
14
14
|
id: string;
|
|
15
|
+
title: string;
|
|
15
16
|
description: string;
|
|
16
17
|
issuer: string;
|
|
17
18
|
clientId: string;
|
|
@@ -40,6 +41,22 @@ export type SSOLoginAttempt = {
|
|
|
40
41
|
* desktop exchanges the code as a confidential client. */
|
|
41
42
|
clientSecret?: string;
|
|
42
43
|
};
|
|
44
|
+
/** One login method the backend advertises, of any kind. Every advertised method keeps its own
|
|
45
|
+
* `id`, `title`, `description` and kind. Two same-kind methods, such as two LDAP directories, are
|
|
46
|
+
* two entries a caller can name apart and never collapsed into one. See {@link UnauthenticatedPlClient.loginMethods}. */
|
|
47
|
+
export type LoginMethod = {
|
|
48
|
+
kind: "basic";
|
|
49
|
+
id: string;
|
|
50
|
+
title: string;
|
|
51
|
+
description: string;
|
|
52
|
+
} | {
|
|
53
|
+
kind: "token";
|
|
54
|
+
id: string;
|
|
55
|
+
title: string;
|
|
56
|
+
description: string;
|
|
57
|
+
} | ({
|
|
58
|
+
kind: "sso";
|
|
59
|
+
} & SSOAuthMethod);
|
|
43
60
|
/** Primarily used for initial authentication (login) */
|
|
44
61
|
export declare class UnauthenticatedPlClient {
|
|
45
62
|
readonly ll: LLPlClient;
|
|
@@ -53,31 +70,49 @@ export declare class UnauthenticatedPlClient {
|
|
|
53
70
|
hasCapability(capability: BackendCapability): boolean;
|
|
54
71
|
/** Classifies the advertised authentication methods by credential scheme.
|
|
55
72
|
* On legacy backends (no auth:v2) the typed oneof is empty; callers fall through to {@link login}
|
|
56
|
-
* which uses the legacy GetJWTToken path.
|
|
73
|
+
* which uses the legacy GetJWTToken path.
|
|
74
|
+
* @deprecated collapses every basic-kind method into one boolean; use {@link loginMethods} to
|
|
75
|
+
* see each advertised method's own id. `login()` still reads this to choose the credential path. */
|
|
57
76
|
get supportedAuthSchemes(): {
|
|
58
77
|
basic: boolean;
|
|
59
78
|
token: boolean;
|
|
60
79
|
};
|
|
80
|
+
/** Builds the {@link SSOAuthMethod} projection an advertised SSO entry carries, or `undefined`
|
|
81
|
+
* for a flow no client here can drive. Shared by {@link ssoConfig} and {@link loginMethods},
|
|
82
|
+
* which each apply their own rule for an unsupported flow. */
|
|
83
|
+
private toSSOAuthMethod;
|
|
61
84
|
/** Projection of the first advertised SSO method, derived from {@link authMethodsSync}.
|
|
62
|
-
* v1: at most one SSO method per deployment, so callers do not need to discriminate.
|
|
85
|
+
* v1: at most one SSO method per deployment, so callers do not need to discriminate.
|
|
86
|
+
* @deprecated surfaces only the first advertised SSO method; use {@link loginMethods} to see
|
|
87
|
+
* every advertised method, of every kind. */
|
|
63
88
|
ssoConfig(): SSOAuthMethod | undefined;
|
|
64
|
-
/**
|
|
89
|
+
/** Every login method the backend advertises, of every kind, in advertised order, each
|
|
90
|
+
* keeping its own `id`, `title`, `description` and kind. An entry with no usable method arm, or an
|
|
91
|
+
* SSO entry whose flow no client here can drive, is dropped rather than failing the whole
|
|
92
|
+
* list, which is why this accessor skips where {@link ssoConfig} throws. */
|
|
93
|
+
loginMethods(): LoginMethod[];
|
|
94
|
+
/** Login with username and password.
|
|
65
95
|
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
* - if only token auth is offered, treats `password` as an opaque bearer token and
|
|
69
|
-
* sends {@link LLPlClient.loginWithToken} (so deployments configured for static-token
|
|
70
|
-
* auth still log in without the caller switching methods).
|
|
96
|
+
* Routes to {@link LLPlClient.loginBasic} or {@link LLPlClient.loginWithToken} based on the
|
|
97
|
+
* advertised method `idP` names. On legacy backends, uses GetJWTToken with Basic header.
|
|
71
98
|
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
|
|
99
|
+
* `idP` names the advertised method. A named basic-kind method routes to the basic branch;
|
|
100
|
+
* a named token-kind method routes to the token branch even when the backend also advertises
|
|
101
|
+
* a basic method — the token wire carries no selector, so the id itself is dropped there and
|
|
102
|
+
* only the branch choice is kept. Omitted, or naming no advertised method, falls back to
|
|
103
|
+
* today's first-match behavior: basic wins over token when both are advertised. */
|
|
104
|
+
login(user: string, password: string, idP?: string): Promise<AuthInformation>;
|
|
75
105
|
/** Request fresh server-issued login material. v1 only emits the public-PKCE flow;
|
|
76
|
-
* desktop MUST place the returned `nonce` verbatim into the OIDC auth-request.
|
|
77
|
-
|
|
78
|
-
|
|
106
|
+
* desktop MUST place the returned `nonce` verbatim into the OIDC auth-request. `idP` names
|
|
107
|
+
* the advertised SSO method to route to; omitted, the backend keeps its current first-match
|
|
108
|
+
* behaviour. */
|
|
109
|
+
beginSSOLogin(idP?: string): Promise<SSOLoginAttempt>;
|
|
110
|
+
/** Forward the verbatim IdP `/token` response body and receive a Platforma JWT. `idP` names
|
|
111
|
+
* the advertised SSO method to route to; omitted, the backend keeps its current first-match
|
|
112
|
+
* behaviour. */
|
|
79
113
|
loginSSO(payload: {
|
|
80
114
|
tokenResponse: Uint8Array;
|
|
115
|
+
idP?: string;
|
|
81
116
|
}): Promise<AuthInformation>;
|
|
82
117
|
}
|
|
83
118
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unauth_client.d.ts","names":[],"sources":["../../src/core/unauth_client.ts"],"mappings":";;;;;;;;YAaY;;;;YAKA;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,UAAU;;;;EAIV;;;;YAKU;EACV;EACA;EACA,WAAW;;;;;EAKX
|
|
1
|
+
{"version":3,"file":"unauth_client.d.ts","names":[],"sources":["../../src/core/unauth_client.ts"],"mappings":";;;;;;;;YAaY;;;;YAKA;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,UAAU;;;;EAIV;;;;YAKU;EACV;EACA;EACA,WAAW;;;;;EAKX;;;;;YAMU;EACN;EAAe;EAAY;EAAe;;EAC1C;EAAe;EAAY;EAAe;;EACzC;IAAgB;;qBAGV;WACK,IAAI;UAEb;SAIa,MAClB,iBAAiB,yBACjB;IAAQ,SAAS;MAChB,QAAQ;EAKE,QAAQ,QAAQ;EAIhB,eAAe,QAAQ;EAIvB,eAAe;EAIrB,cAAc,YAAY;;;;;;MAStB;IAA0B;IAAgB;;;;;UAY7C;;;;;EA4BD,aAAa;;;;;EAgBb,gBAAgB;;;;;;;;;;;EAoCV,MAAM,cAAc,kBAAkB,eAAe,QAAQ;;;;;EAqC7D,cAAc,eAAe,QAAQ;;;;EAcrC,SAAS;IACpB,eAAe;IACf;MACE,QAAQ"}
|
|
@@ -26,7 +26,9 @@ var UnauthenticatedPlClient = class UnauthenticatedPlClient {
|
|
|
26
26
|
}
|
|
27
27
|
/** Classifies the advertised authentication methods by credential scheme.
|
|
28
28
|
* On legacy backends (no auth:v2) the typed oneof is empty; callers fall through to {@link login}
|
|
29
|
-
* which uses the legacy GetJWTToken path.
|
|
29
|
+
* which uses the legacy GetJWTToken path.
|
|
30
|
+
* @deprecated collapses every basic-kind method into one boolean; use {@link loginMethods} to
|
|
31
|
+
* see each advertised method's own id. `login()` still reads this to choose the credential path. */
|
|
30
32
|
get supportedAuthSchemes() {
|
|
31
33
|
const result = {
|
|
32
34
|
basic: false,
|
|
@@ -36,46 +38,87 @@ var UnauthenticatedPlClient = class UnauthenticatedPlClient {
|
|
|
36
38
|
else if (m.method.oneofKind === "token") result.token = true;
|
|
37
39
|
return result;
|
|
38
40
|
}
|
|
41
|
+
/** Builds the {@link SSOAuthMethod} projection an advertised SSO entry carries, or `undefined`
|
|
42
|
+
* for a flow no client here can drive. Shared by {@link ssoConfig} and {@link loginMethods},
|
|
43
|
+
* which each apply their own rule for an unsupported flow. */
|
|
44
|
+
toSSOAuthMethod(method) {
|
|
45
|
+
if (method.method.oneofKind !== "sso") return void 0;
|
|
46
|
+
const sso = method.method.sso;
|
|
47
|
+
if (sso.flowType !== 0) return void 0;
|
|
48
|
+
return {
|
|
49
|
+
id: method.id,
|
|
50
|
+
title: method.title || method.description || method.id,
|
|
51
|
+
description: method.description,
|
|
52
|
+
issuer: sso.issuer,
|
|
53
|
+
clientId: sso.clientId,
|
|
54
|
+
scopes: sso.scopes,
|
|
55
|
+
resource: sso.resource,
|
|
56
|
+
prompt: sso.prompt,
|
|
57
|
+
redirectPorts: sso.redirectPorts,
|
|
58
|
+
subjectTokenSource: sso.subjectTokenSource,
|
|
59
|
+
userIdClaim: sso.userIdClaim,
|
|
60
|
+
groupsClaim: sso.groupsClaim,
|
|
61
|
+
accessType: sso.accessType || void 0,
|
|
62
|
+
flowType: "public_pkce"
|
|
63
|
+
};
|
|
64
|
+
}
|
|
39
65
|
/** Projection of the first advertised SSO method, derived from {@link authMethodsSync}.
|
|
40
|
-
* v1: at most one SSO method per deployment, so callers do not need to discriminate.
|
|
66
|
+
* v1: at most one SSO method per deployment, so callers do not need to discriminate.
|
|
67
|
+
* @deprecated surfaces only the first advertised SSO method; use {@link loginMethods} to see
|
|
68
|
+
* every advertised method, of every kind. */
|
|
41
69
|
ssoConfig() {
|
|
42
70
|
for (const method of this.ll.authMethodsSync.methods) {
|
|
43
71
|
if (method.method.oneofKind !== "sso") continue;
|
|
44
72
|
const sso = method.method.sso;
|
|
45
73
|
if (sso.flowType !== 0) throw new Error(`ssoConfig: unsupported SSO flow type ${sso.flowType}`);
|
|
46
|
-
return
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
74
|
+
return this.toSSOAuthMethod(method);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/** Every login method the backend advertises, of every kind, in advertised order, each
|
|
78
|
+
* keeping its own `id`, `title`, `description` and kind. An entry with no usable method arm, or an
|
|
79
|
+
* SSO entry whose flow no client here can drive, is dropped rather than failing the whole
|
|
80
|
+
* list, which is why this accessor skips where {@link ssoConfig} throws. */
|
|
81
|
+
loginMethods() {
|
|
82
|
+
const picked = [];
|
|
83
|
+
for (const method of this.ll.authMethodsSync.methods) switch (method.method.oneofKind) {
|
|
84
|
+
case "basic":
|
|
85
|
+
case "token":
|
|
86
|
+
picked.push({
|
|
87
|
+
kind: method.method.oneofKind,
|
|
88
|
+
id: method.id,
|
|
89
|
+
title: method.title || method.description || method.id,
|
|
90
|
+
description: method.description
|
|
91
|
+
});
|
|
92
|
+
break;
|
|
93
|
+
case "sso": {
|
|
94
|
+
const sso = this.toSSOAuthMethod(method);
|
|
95
|
+
if (sso !== void 0) picked.push({
|
|
96
|
+
kind: "sso",
|
|
97
|
+
...sso
|
|
98
|
+
});
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
default: break;
|
|
61
102
|
}
|
|
103
|
+
return picked;
|
|
62
104
|
}
|
|
63
|
-
/** Login with username
|
|
105
|
+
/** Login with username and password.
|
|
64
106
|
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
* - if only token auth is offered, treats `password` as an opaque bearer token and
|
|
68
|
-
* sends {@link LLPlClient.loginWithToken} (so deployments configured for static-token
|
|
69
|
-
* auth still log in without the caller switching methods).
|
|
107
|
+
* Routes to {@link LLPlClient.loginBasic} or {@link LLPlClient.loginWithToken} based on the
|
|
108
|
+
* advertised method `idP` names. On legacy backends, uses GetJWTToken with Basic header.
|
|
70
109
|
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
|
|
110
|
+
* `idP` names the advertised method. A named basic-kind method routes to the basic branch;
|
|
111
|
+
* a named token-kind method routes to the token branch even when the backend also advertises
|
|
112
|
+
* a basic method — the token wire carries no selector, so the id itself is dropped there and
|
|
113
|
+
* only the branch choice is kept. Omitted, or naming no advertised method, falls back to
|
|
114
|
+
* today's first-match behavior: basic wins over token when both are advertised. */
|
|
115
|
+
async login(user, password, idP) {
|
|
74
116
|
try {
|
|
75
117
|
let token;
|
|
76
118
|
if (this.ll.hasCapability("auth:v2")) {
|
|
77
119
|
const schemes = this.supportedAuthSchemes;
|
|
78
|
-
if (
|
|
120
|
+
if ((idP === void 0 ? void 0 : this.loginMethods().find((m) => m.id === idP)?.kind) === "token") token = await this.ll.loginWithToken(password);
|
|
121
|
+
else if (schemes.basic) token = idP === void 0 ? await this.ll.loginBasic(user, password) : await this.ll.loginBasic(user, password, { idP });
|
|
79
122
|
else if (schemes.token) token = await this.ll.loginWithToken(password);
|
|
80
123
|
else throw new Error("backend advertises no supported authentication methods");
|
|
81
124
|
} else token = await this.ll.getJwtToken(BigInt(this.ll.conf.authTTLSeconds), { authorization: "Basic " + Buffer.from(user + ":" + password).toString("base64") });
|
|
@@ -88,9 +131,11 @@ var UnauthenticatedPlClient = class UnauthenticatedPlClient {
|
|
|
88
131
|
}
|
|
89
132
|
}
|
|
90
133
|
/** Request fresh server-issued login material. v1 only emits the public-PKCE flow;
|
|
91
|
-
* desktop MUST place the returned `nonce` verbatim into the OIDC auth-request.
|
|
92
|
-
|
|
93
|
-
|
|
134
|
+
* desktop MUST place the returned `nonce` verbatim into the OIDC auth-request. `idP` names
|
|
135
|
+
* the advertised SSO method to route to; omitted, the backend keeps its current first-match
|
|
136
|
+
* behaviour. */
|
|
137
|
+
async beginSSOLogin(idP) {
|
|
138
|
+
const attempt = idP === void 0 ? await this.ll.beginSSOLogin() : await this.ll.beginSSOLogin(idP);
|
|
94
139
|
return {
|
|
95
140
|
flow: "public_pkce",
|
|
96
141
|
nonce: attempt.nonce,
|
|
@@ -98,10 +143,12 @@ var UnauthenticatedPlClient = class UnauthenticatedPlClient {
|
|
|
98
143
|
clientSecret: attempt.clientSecret
|
|
99
144
|
};
|
|
100
145
|
}
|
|
101
|
-
/** Forward the verbatim IdP `/token` response body and receive a Platforma JWT.
|
|
146
|
+
/** Forward the verbatim IdP `/token` response body and receive a Platforma JWT. `idP` names
|
|
147
|
+
* the advertised SSO method to route to; omitted, the backend keeps its current first-match
|
|
148
|
+
* behaviour. */
|
|
102
149
|
async loginSSO(payload) {
|
|
103
150
|
try {
|
|
104
|
-
const jwtToken = await this.ll.loginSSO(payload.tokenResponse);
|
|
151
|
+
const jwtToken = payload.idP === void 0 ? await this.ll.loginSSO(payload.tokenResponse) : await this.ll.loginSSO(payload.tokenResponse, payload.idP);
|
|
105
152
|
if (jwtToken === "") throw new Error("empty token");
|
|
106
153
|
return { jwtToken };
|
|
107
154
|
} catch (e) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unauth_client.js","names":[],"sources":["../../src/core/unauth_client.ts"],"sourcesContent":["import type { AuthInformation, PlClientConfig } from \"./config\";\nimport {\n type AuthAPI_ListMethods_Response,\n type MaintenanceAPI_Ping_Response,\n AuthAPI_ListMethods_SSOAuthMethod_FlowType,\n} from \"../proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api\";\nimport { LLPlClient } from \"./ll_client\";\nimport { type MiLogger, notEmpty } from \"@milaboratories/ts-helpers\";\nimport { UnauthenticatedError } from \"./errors\";\nimport type { BackendCapability } from \"./capabilities\";\n\n/** Login-flow shape advertised by the backend for a given SSO method. Extension\n * point: future flow variants (e.g. backend-driven) sit alongside `public_pkce`. */\nexport type SSOFlowType = \"public_pkce\";\n\n/** Typed projection of `AuthAPI.ListMethods.SSOAuthMethod` for desktop consumption.\n * Carries everything needed to drive the PKCE flow + diagnostics fields the renderer\n * may surface (`userIdClaim`, `groupsClaim`). */\nexport type SSOAuthMethod = {\n id: string;\n description: string;\n issuer: string;\n clientId: string;\n scopes: string;\n resource: string;\n prompt: string;\n redirectPorts: number[];\n subjectTokenSource: string;\n userIdClaim: string;\n groupsClaim: string;\n flowType: SSOFlowType;\n /** OIDC `access_type` auth-request param (\"online\" | \"offline\"). Google-specific:\n * \"offline\" makes Google issue a refresh token; other IdPs ignore it. Absent when\n * the server does not set it — never send an empty string to the IdP. */\n accessType?: string;\n};\n\n/** Server-issued material returned by {@link UnauthenticatedPlClient.beginSSOLogin}.\n * Discriminated on `flow`; future flow variants extend the union. */\nexport type SSOLoginAttempt = {\n flow: \"public_pkce\";\n nonce: string;\n expiresAt: Date;\n /** Confidential-client secret for the IdP token exchange; absent for public clients.\n * Google's OIDC has no public-client mode — it requires a client_secret at the token\n * endpoint even with PKCE — so for Google the backend forwards its secret here and the\n * desktop exchanges the code as a confidential client. */\n clientSecret?: string;\n};\n\n/** Primarily used for initial authentication (login) */\nexport class UnauthenticatedPlClient {\n public readonly ll: LLPlClient;\n\n private constructor(ll: LLPlClient) {\n this.ll = ll;\n }\n\n public static async build(\n configOrAddress: PlClientConfig | string,\n ops?: { logger?: MiLogger },\n ): Promise<UnauthenticatedPlClient> {\n const ll = await LLPlClient.build(configOrAddress, ops);\n return new UnauthenticatedPlClient(ll);\n }\n\n public async ping(): Promise<MaintenanceAPI_Ping_Response> {\n return await this.ll.ping();\n }\n\n public async authMethods(): Promise<AuthAPI_ListMethods_Response> {\n return await this.ll.authMethods();\n }\n\n public async requireAuth(): Promise<boolean> {\n return (await this.authMethods()).methods.length > 0;\n }\n\n public hasCapability(capability: BackendCapability): boolean {\n return this.ll.hasCapability(capability);\n }\n\n /** Classifies the advertised authentication methods by credential scheme.\n * On legacy backends (no auth:v2) the typed oneof is empty; callers fall through to {@link login}\n * which uses the legacy GetJWTToken path. SSO is surfaced via {@link ssoConfig}, not here. */\n public get supportedAuthSchemes(): { basic: boolean; token: boolean } {\n const result = { basic: false, token: false };\n for (const m of this.ll.authMethodsSync.methods) {\n if (m.method.oneofKind === \"basic\") result.basic = true;\n else if (m.method.oneofKind === \"token\") result.token = true;\n }\n return result;\n }\n\n /** Projection of the first advertised SSO method, derived from {@link authMethodsSync}.\n * v1: at most one SSO method per deployment, so callers do not need to discriminate. */\n public ssoConfig(): SSOAuthMethod | undefined {\n for (const method of this.ll.authMethodsSync.methods) {\n if (method.method.oneofKind !== \"sso\") continue;\n const sso = method.method.sso;\n if (sso.flowType !== AuthAPI_ListMethods_SSOAuthMethod_FlowType.PUBLIC_PKCE) {\n throw new Error(`ssoConfig: unsupported SSO flow type ${sso.flowType}`);\n }\n return {\n id: method.id,\n description: method.description,\n issuer: sso.issuer,\n clientId: sso.clientId,\n scopes: sso.scopes,\n resource: sso.resource,\n prompt: sso.prompt,\n redirectPorts: sso.redirectPorts,\n subjectTokenSource: sso.subjectTokenSource,\n userIdClaim: sso.userIdClaim,\n groupsClaim: sso.groupsClaim,\n accessType: sso.accessType || undefined,\n flowType: \"public_pkce\",\n };\n }\n return undefined;\n }\n\n /** Login with username+password.\n *\n * On auth:v2 backends the client inspects the advertised AuthMethods:\n * - if basic auth is offered, sends {@link LLPlClient.loginBasic};\n * - if only token auth is offered, treats `password` as an opaque bearer token and\n * sends {@link LLPlClient.loginWithToken} (so deployments configured for static-token\n * auth still log in without the caller switching methods).\n *\n * On legacy backends (no auth:v2) it falls through to GetJWTToken with the Basic header,\n * preserving original behavior. */\n public async login(user: string, password: string): Promise<AuthInformation> {\n try {\n let token: string;\n if (this.ll.hasCapability(\"auth:v2\")) {\n const schemes = this.supportedAuthSchemes;\n if (schemes.basic) {\n token = await this.ll.loginBasic(user, password);\n } else if (schemes.token) {\n token = await this.ll.loginWithToken(password);\n } else {\n throw new Error(\"backend advertises no supported authentication methods\");\n }\n } else {\n token = await this.ll.getJwtToken(BigInt(this.ll.conf.authTTLSeconds), {\n authorization: \"Basic \" + Buffer.from(user + \":\" + password).toString(\"base64\"),\n });\n }\n const jwtToken = notEmpty(token);\n if (jwtToken === \"\") throw new Error(\"empty token\");\n return { jwtToken };\n } catch (e: any) {\n if (e.code === \"UNAUTHENTICATED\") throw new UnauthenticatedError(e.message);\n throw new Error(e);\n }\n }\n\n /** Request fresh server-issued login material. v1 only emits the public-PKCE flow;\n * desktop MUST place the returned `nonce` verbatim into the OIDC auth-request. */\n public async beginSSOLogin(): Promise<SSOLoginAttempt> {\n const attempt = await this.ll.beginSSOLogin();\n return {\n flow: \"public_pkce\",\n nonce: attempt.nonce,\n expiresAt: attempt.expiresAt,\n clientSecret: attempt.clientSecret,\n };\n }\n\n /** Forward the verbatim IdP `/token` response body and receive a Platforma JWT. */\n public async loginSSO(payload: { tokenResponse: Uint8Array }): Promise<AuthInformation> {\n try {\n const jwtToken = await this.ll.loginSSO(payload.tokenResponse);\n if (jwtToken === \"\") throw new Error(\"empty token\");\n return { jwtToken };\n } catch (e: any) {\n if (e.code === \"UNAUTHENTICATED\") throw new UnauthenticatedError(e.message);\n throw new Error(e);\n }\n }\n}\n"],"mappings":";;;;;;AAmDA,IAAa,0BAAb,MAAa,wBAAwB;CACnC;CAEA,YAAoB,IAAgB;EAClC,KAAK,KAAK;CACZ;CAEA,aAAoB,MAClB,iBACA,KACkC;EAElC,OAAO,IAAI,wBAAwB,MADlB,WAAW,MAAM,iBAAiB,GAAG,CACjB;CACvC;CAEA,MAAa,OAA8C;EACzD,OAAO,MAAM,KAAK,GAAG,KAAK;CAC5B;CAEA,MAAa,cAAqD;EAChE,OAAO,MAAM,KAAK,GAAG,YAAY;CACnC;CAEA,MAAa,cAAgC;EAC3C,QAAQ,MAAM,KAAK,YAAY,EAAA,CAAG,QAAQ,SAAS;CACrD;CAEA,cAAqB,YAAwC;EAC3D,OAAO,KAAK,GAAG,cAAc,UAAU;CACzC;;;;CAKA,IAAW,uBAA2D;EACpE,MAAM,SAAS;GAAE,OAAO;GAAO,OAAO;EAAM;EAC5C,KAAK,MAAM,KAAK,KAAK,GAAG,gBAAgB,SACtC,IAAI,EAAE,OAAO,cAAc,SAAS,OAAO,QAAQ;OAC9C,IAAI,EAAE,OAAO,cAAc,SAAS,OAAO,QAAQ;EAE1D,OAAO;CACT;;;CAIA,YAA8C;EAC5C,KAAK,MAAM,UAAU,KAAK,GAAG,gBAAgB,SAAS;GACpD,IAAI,OAA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ACxB;CACF;;CAGA,MAAa,SAAS,SAAkE;EACtF,IAAI;GACF,MAAM,WAAW,MAAM,KAAK,GAAG,SAAS,QAAQ,aAAa;GAC7D,IAAI,aAAa,IAAI,MAAM,IAAI,MAAM,aAAa;GAClD,OAAO,EAAE,SAAS;EACpB,SAAS,GAAQ;GACf,IAAI,EAAE,SAAS,mBAAmB,MAAM,IAAI,qBAAqB,EAAE,OAAO;GAC1E,MAAM,IAAI,MAAM,CAAC;EACnB;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"unauth_client.js","names":[],"sources":["../../src/core/unauth_client.ts"],"sourcesContent":["import type { AuthInformation, PlClientConfig } from \"./config\";\nimport {\n type AuthAPI_ListMethods_Response,\n type MaintenanceAPI_Ping_Response,\n AuthAPI_ListMethods_SSOAuthMethod_FlowType,\n} from \"../proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api\";\nimport { LLPlClient } from \"./ll_client\";\nimport { type MiLogger, notEmpty } from \"@milaboratories/ts-helpers\";\nimport { UnauthenticatedError } from \"./errors\";\nimport type { BackendCapability } from \"./capabilities\";\n\n/** Login-flow shape advertised by the backend for a given SSO method. Extension\n * point: future flow variants (e.g. backend-driven) sit alongside `public_pkce`. */\nexport type SSOFlowType = \"public_pkce\";\n\n/** Typed projection of `AuthAPI.ListMethods.SSOAuthMethod` for desktop consumption.\n * Carries everything needed to drive the PKCE flow + diagnostics fields the renderer\n * may surface (`userIdClaim`, `groupsClaim`). */\nexport type SSOAuthMethod = {\n id: string;\n title: string;\n description: string;\n issuer: string;\n clientId: string;\n scopes: string;\n resource: string;\n prompt: string;\n redirectPorts: number[];\n subjectTokenSource: string;\n userIdClaim: string;\n groupsClaim: string;\n flowType: SSOFlowType;\n /** OIDC `access_type` auth-request param (\"online\" | \"offline\"). Google-specific:\n * \"offline\" makes Google issue a refresh token; other IdPs ignore it. Absent when\n * the server does not set it — never send an empty string to the IdP. */\n accessType?: string;\n};\n\n/** Server-issued material returned by {@link UnauthenticatedPlClient.beginSSOLogin}.\n * Discriminated on `flow`; future flow variants extend the union. */\nexport type SSOLoginAttempt = {\n flow: \"public_pkce\";\n nonce: string;\n expiresAt: Date;\n /** Confidential-client secret for the IdP token exchange; absent for public clients.\n * Google's OIDC has no public-client mode — it requires a client_secret at the token\n * endpoint even with PKCE — so for Google the backend forwards its secret here and the\n * desktop exchanges the code as a confidential client. */\n clientSecret?: string;\n};\n\n/** One login method the backend advertises, of any kind. Every advertised method keeps its own\n * `id`, `title`, `description` and kind. Two same-kind methods, such as two LDAP directories, are\n * two entries a caller can name apart and never collapsed into one. See {@link UnauthenticatedPlClient.loginMethods}. */\nexport type LoginMethod =\n | { kind: \"basic\"; id: string; title: string; description: string }\n | { kind: \"token\"; id: string; title: string; description: string }\n | ({ kind: \"sso\" } & SSOAuthMethod);\n\n/** Primarily used for initial authentication (login) */\nexport class UnauthenticatedPlClient {\n public readonly ll: LLPlClient;\n\n private constructor(ll: LLPlClient) {\n this.ll = ll;\n }\n\n public static async build(\n configOrAddress: PlClientConfig | string,\n ops?: { logger?: MiLogger },\n ): Promise<UnauthenticatedPlClient> {\n const ll = await LLPlClient.build(configOrAddress, ops);\n return new UnauthenticatedPlClient(ll);\n }\n\n public async ping(): Promise<MaintenanceAPI_Ping_Response> {\n return await this.ll.ping();\n }\n\n public async authMethods(): Promise<AuthAPI_ListMethods_Response> {\n return await this.ll.authMethods();\n }\n\n public async requireAuth(): Promise<boolean> {\n return (await this.authMethods()).methods.length > 0;\n }\n\n public hasCapability(capability: BackendCapability): boolean {\n return this.ll.hasCapability(capability);\n }\n\n /** Classifies the advertised authentication methods by credential scheme.\n * On legacy backends (no auth:v2) the typed oneof is empty; callers fall through to {@link login}\n * which uses the legacy GetJWTToken path.\n * @deprecated collapses every basic-kind method into one boolean; use {@link loginMethods} to\n * see each advertised method's own id. `login()` still reads this to choose the credential path. */\n public get supportedAuthSchemes(): { basic: boolean; token: boolean } {\n const result = { basic: false, token: false };\n for (const m of this.ll.authMethodsSync.methods) {\n if (m.method.oneofKind === \"basic\") result.basic = true;\n else if (m.method.oneofKind === \"token\") result.token = true;\n }\n return result;\n }\n\n /** Builds the {@link SSOAuthMethod} projection an advertised SSO entry carries, or `undefined`\n * for a flow no client here can drive. Shared by {@link ssoConfig} and {@link loginMethods},\n * which each apply their own rule for an unsupported flow. */\n private toSSOAuthMethod(\n method: AuthAPI_ListMethods_Response[\"methods\"][number],\n ): SSOAuthMethod | undefined {\n if (method.method.oneofKind !== \"sso\") return undefined;\n const sso = method.method.sso;\n if (sso.flowType !== AuthAPI_ListMethods_SSOAuthMethod_FlowType.PUBLIC_PKCE) return undefined;\n return {\n id: method.id,\n title: method.title || method.description || method.id,\n description: method.description,\n issuer: sso.issuer,\n clientId: sso.clientId,\n scopes: sso.scopes,\n resource: sso.resource,\n prompt: sso.prompt,\n redirectPorts: sso.redirectPorts,\n subjectTokenSource: sso.subjectTokenSource,\n userIdClaim: sso.userIdClaim,\n groupsClaim: sso.groupsClaim,\n accessType: sso.accessType || undefined,\n flowType: \"public_pkce\",\n };\n }\n\n /** Projection of the first advertised SSO method, derived from {@link authMethodsSync}.\n * v1: at most one SSO method per deployment, so callers do not need to discriminate.\n * @deprecated surfaces only the first advertised SSO method; use {@link loginMethods} to see\n * every advertised method, of every kind. */\n public ssoConfig(): SSOAuthMethod | undefined {\n for (const method of this.ll.authMethodsSync.methods) {\n if (method.method.oneofKind !== \"sso\") continue;\n const sso = method.method.sso;\n if (sso.flowType !== AuthAPI_ListMethods_SSOAuthMethod_FlowType.PUBLIC_PKCE) {\n throw new Error(`ssoConfig: unsupported SSO flow type ${sso.flowType}`);\n }\n return this.toSSOAuthMethod(method);\n }\n return undefined;\n }\n\n /** Every login method the backend advertises, of every kind, in advertised order, each\n * keeping its own `id`, `title`, `description` and kind. An entry with no usable method arm, or an\n * SSO entry whose flow no client here can drive, is dropped rather than failing the whole\n * list, which is why this accessor skips where {@link ssoConfig} throws. */\n public loginMethods(): LoginMethod[] {\n const picked: LoginMethod[] = [];\n for (const method of this.ll.authMethodsSync.methods) {\n switch (method.method.oneofKind) {\n case \"basic\":\n case \"token\":\n picked.push({\n kind: method.method.oneofKind,\n id: method.id,\n title: method.title || method.description || method.id,\n description: method.description,\n });\n break;\n case \"sso\": {\n const sso = this.toSSOAuthMethod(method);\n if (sso !== undefined) picked.push({ kind: \"sso\", ...sso });\n break;\n }\n default:\n // No arm at all — a legacy backend advertising nothing pickable.\n break;\n }\n }\n return picked;\n }\n\n /** Login with username and password.\n *\n * Routes to {@link LLPlClient.loginBasic} or {@link LLPlClient.loginWithToken} based on the\n * advertised method `idP` names. On legacy backends, uses GetJWTToken with Basic header.\n *\n * `idP` names the advertised method. A named basic-kind method routes to the basic branch;\n * a named token-kind method routes to the token branch even when the backend also advertises\n * a basic method — the token wire carries no selector, so the id itself is dropped there and\n * only the branch choice is kept. Omitted, or naming no advertised method, falls back to\n * today's first-match behavior: basic wins over token when both are advertised. */\n public async login(user: string, password: string, idP?: string): Promise<AuthInformation> {\n try {\n let token: string;\n if (this.ll.hasCapability(\"auth:v2\")) {\n const schemes = this.supportedAuthSchemes;\n const namedKind =\n idP === undefined ? undefined : this.loginMethods().find((m) => m.id === idP)?.kind;\n if (namedKind === \"token\") {\n token = await this.ll.loginWithToken(password);\n } else if (schemes.basic) {\n token =\n idP === undefined\n ? await this.ll.loginBasic(user, password)\n : await this.ll.loginBasic(user, password, { idP });\n } else if (schemes.token) {\n token = await this.ll.loginWithToken(password);\n } else {\n throw new Error(\"backend advertises no supported authentication methods\");\n }\n } else {\n token = await this.ll.getJwtToken(BigInt(this.ll.conf.authTTLSeconds), {\n authorization: \"Basic \" + Buffer.from(user + \":\" + password).toString(\"base64\"),\n });\n }\n const jwtToken = notEmpty(token);\n if (jwtToken === \"\") throw new Error(\"empty token\");\n return { jwtToken };\n } catch (e: any) {\n if (e.code === \"UNAUTHENTICATED\") throw new UnauthenticatedError(e.message);\n throw new Error(e);\n }\n }\n\n /** Request fresh server-issued login material. v1 only emits the public-PKCE flow;\n * desktop MUST place the returned `nonce` verbatim into the OIDC auth-request. `idP` names\n * the advertised SSO method to route to; omitted, the backend keeps its current first-match\n * behaviour. */\n public async beginSSOLogin(idP?: string): Promise<SSOLoginAttempt> {\n const attempt =\n idP === undefined ? await this.ll.beginSSOLogin() : await this.ll.beginSSOLogin(idP);\n return {\n flow: \"public_pkce\",\n nonce: attempt.nonce,\n expiresAt: attempt.expiresAt,\n clientSecret: attempt.clientSecret,\n };\n }\n\n /** Forward the verbatim IdP `/token` response body and receive a Platforma JWT. `idP` names\n * the advertised SSO method to route to; omitted, the backend keeps its current first-match\n * behaviour. */\n public async loginSSO(payload: {\n tokenResponse: Uint8Array;\n idP?: string;\n }): Promise<AuthInformation> {\n try {\n const jwtToken =\n payload.idP === undefined\n ? await this.ll.loginSSO(payload.tokenResponse)\n : await this.ll.loginSSO(payload.tokenResponse, payload.idP);\n if (jwtToken === \"\") throw new Error(\"empty token\");\n return { jwtToken };\n } catch (e: any) {\n if (e.code === \"UNAUTHENTICATED\") throw new UnauthenticatedError(e.message);\n throw new Error(e);\n }\n }\n}\n"],"mappings":";;;;;;AA4DA,IAAa,0BAAb,MAAa,wBAAwB;CACnC;CAEA,YAAoB,IAAgB;EAClC,KAAK,KAAK;CACZ;CAEA,aAAoB,MAClB,iBACA,KACkC;EAElC,OAAO,IAAI,wBAAwB,MADlB,WAAW,MAAM,iBAAiB,GAAG,CACjB;CACvC;CAEA,MAAa,OAA8C;EACzD,OAAO,MAAM,KAAK,GAAG,KAAK;CAC5B;CAEA,MAAa,cAAqD;EAChE,OAAO,MAAM,KAAK,GAAG,YAAY;CACnC;CAEA,MAAa,cAAgC;EAC3C,QAAQ,MAAM,KAAK,YAAY,EAAA,CAAG,QAAQ,SAAS;CACrD;CAEA,cAAqB,YAAwC;EAC3D,OAAO,KAAK,GAAG,cAAc,UAAU;CACzC;;;;;;CAOA,IAAW,uBAA2D;EACpE,MAAM,SAAS;GAAE,OAAO;GAAO,OAAO;EAAM;EAC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Q;EACxB;CACF;;;;CAKA,MAAa,SAAS,SAGO;EAC3B,IAAI;GACF,MAAM,WACJ,QAAQ,QAAQ,KAAA,IACZ,MAAM,KAAK,GAAG,SAAS,QAAQ,aAAa,IAC5C,MAAM,KAAK,GAAG,SAAS,QAAQ,eAAe,QAAQ,GAAG;GAC/D,IAAI,aAAa,IAAI,MAAM,IAAI,MAAM,aAAa;GAClD,OAAO,EAAE,SAAS;EACpB,SAAS,GAAQ;GACf,IAAI,EAAE,SAAS,mBAAmB,MAAM,IAAI,qBAAqB,EAAE,OAAO;GAC1E,MAAM,IAAI,MAAM,CAAC;EACnB;CACF;AACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -12,10 +12,10 @@ import { GrantEntry, StorageInfo, TxRunner, UserDeletionReport, UserEntry, UserR
|
|
|
12
12
|
import { PlClient, TxOps } from "./core/client.js";
|
|
13
13
|
import { DisconnectedError, PermissionDeniedError, PlError, PlErrorCodeNotFound, RESTError, RecoverablePlError, UnauthenticatedError, UnrecoverablePlError, isAbortedError, isCancelError, isConnectionProblem, isNotFoundError, isPermissionDenied, isTimeoutError, isTimeoutOrCancelError, isTransientCallFailure, isUnauthenticated, isUnimplementedError, rethrowMeaningfulError, throwPlNotFoundError } from "./core/errors.js";
|
|
14
14
|
import { defaultPlClient, tryGetFileConfig } from "./core/default_client.js";
|
|
15
|
-
import { SSOAuthMethod, SSOFlowType, SSOLoginAttempt, UnauthenticatedPlClient } from "./core/unauth_client.js";
|
|
15
|
+
import { LoginMethod, SSOAuthMethod, SSOFlowType, SSOLoginAttempt, UnauthenticatedPlClient } from "./core/unauth_client.js";
|
|
16
16
|
import { expirationFromAuthInformation, inferAuthRefreshTime } from "./core/auth.js";
|
|
17
17
|
import { Filter, Property, treeFilter } from "./core/tree_filter.js";
|
|
18
18
|
import { ValErr, valErr } from "./helpers/tx_helpers.js";
|
|
19
19
|
import { ContinuePolling, DefaultPollingRetryOptions, PollFieldTraverseOps, PollResourceAccessor, PollTxAccessor, poll } from "./helpers/poll.js";
|
|
20
20
|
import { test_config_d_exports } from "./test/test_config.js";
|
|
21
|
-
export { AnonymousAuthInformation, AnyFieldId, AnyFieldRef, AnyRef, AnyResourceId, AnyResourceRef, AuthInformation, AuthOps, BackendCapability, BasicResourceData, ColorProof, ContinuePolling, DEFAULT_AUTH_MAX_REFRESH, DEFAULT_LOGIN_TIMEOUT, DEFAULT_MAX_CACHE_BYTES, DEFAULT_REQUEST_TIMEOUT, DEFAULT_RETRY_BACKOFF_ALGORITHM, DEFAULT_RETRY_EXPONENTIAL_BACKOFF_MULTIPLIER, DEFAULT_RETRY_INITIAL_DELAY, DEFAULT_RETRY_JITTER, DEFAULT_RETRY_LINEAR_BACKOFF_STEP, DEFAULT_RETRY_MAX_ATTEMPTS, DEFAULT_RETRY_MAX_DELAY, DEFAULT_RO_TX_TIMEOUT, DEFAULT_RW_TX_TIMEOUT, DEFAULT_TOKEN_TTL_SECONDS, DefaultFinalResourceDataPredicate, DefaultPollingRetryOptions, DefaultRetryOptions, DisconnectedError, FieldData, FieldId, FieldRef, FieldStatus, FieldType, Filter, ResourceAPI_Tree_Filter_OperatorType as FilterOperatorType, ResourceAPI_Tree_Filter_Property as FilterProperty, FinalResourceDataPredicate, FutureFieldType, GlobalResourceId, GrantEntry, GrantPermissions, GrantType, GrpcConnection, KeyValue, KeyValueString, LocalFieldId, LocalResourceId, MAX_ADAPTIVE_REQUEST_TIMEOUT, MaxLocalId, MaxTxId, NullResourceId, NullSignedResourceId, OptionalAnyResourceId, OptionalSignedResourceId, PermissionDeniedError, pl_d_exports as Pl, PlClient, PlClientConfig, PlConnectionStatus, PlConnectionStatusListener, PlDriver, PlDriverDefinition, PlError, PlErrorCodeNotFound, PlTransaction, PollFieldTraverseOps, PollResourceAccessor, PollTxAccessor, Property, RESTError, RTT_DEADLINE_MULTIPLIER, RTT_SMOOTHING_ALPHA, RecoverablePlError, type ResourceAPI_Tree_Filter, ResourceData, ResourceIdWithSignature, ResourceKind, ResourceRef, ResourceSignature, ResourceTreeFrame, ResourceTreeItem, ResourceType, ResourceTypeName, ResourceTypePrefix, index_d_exports as RestAPI, RestConnection, Role, SSOAuthMethod, SSOFlowType, SSOLoginAttempt, SUPPORTED_WIRE_PROTOCOLS, SignedResourceId, StorageInfo, test_config_d_exports as TestHelpers, TxCommitConflict, TxOps, TxRunner, UnauthenticatedError, UnauthenticatedPlClient, UnrecoverablePlError, UserDeletionReport, UserEntry, UserResources, ValErr, WireClientProvider, WireClientProviderFactory, WireConnection, addRTypeToMetadata, anyResourceIdToBigint, asSignedResourceId, base64UrlToSignature, checkLocalityOfResourceId, createGlobalResourceId, createLocalResourceId, createRTypeRoutingHeader, createSignedResourceId, defaultPlClient, deriveUnaryDeadline, ensureSignedResourceIdNotNull, expirationFromAuthInformation, extractBasicResourceData, extractTxId, field, getField, hasCapability, inferAuthRefreshTime, isAbortedError, isAnyResourceId, isCancelError, isConnectionProblem, isEveryoneUserLogin, isField, isFieldRef, isLocalResourceId, isNotFoundError, isNotNullSignedResourceId, isNullSignedResourceId, isPermissionDenied, isResource, isResourceId, isResourceRef, isRootResourceId, isSignedResourceId, isTimeoutError, isTimeoutOrCancelError, isTransientCallFailure, isUnauthenticated, isUnimplementedError, jsonToData, parseResourceType, parseSignedResourceId, plAddressToConfig, poll, readyOrDuplicateOrError, resDataToJson, resourceIdFromString, resourceIdToString, resourceType, resourceTypeToString, resourceTypesEqual, rethrowMeaningfulError, setResourceSignaturesRequired, signatureToBase64Url, smoothRtt, stringifyWithResourceId, throwPlNotFoundError, toFieldId, toGlobalFieldId, toGlobalResourceId, toResourceSignature, treeFilter, tryGetFileConfig, valErr, wireProtocol };
|
|
21
|
+
export { AnonymousAuthInformation, AnyFieldId, AnyFieldRef, AnyRef, AnyResourceId, AnyResourceRef, AuthInformation, AuthOps, BackendCapability, BasicResourceData, ColorProof, ContinuePolling, DEFAULT_AUTH_MAX_REFRESH, DEFAULT_LOGIN_TIMEOUT, DEFAULT_MAX_CACHE_BYTES, DEFAULT_REQUEST_TIMEOUT, DEFAULT_RETRY_BACKOFF_ALGORITHM, DEFAULT_RETRY_EXPONENTIAL_BACKOFF_MULTIPLIER, DEFAULT_RETRY_INITIAL_DELAY, DEFAULT_RETRY_JITTER, DEFAULT_RETRY_LINEAR_BACKOFF_STEP, DEFAULT_RETRY_MAX_ATTEMPTS, DEFAULT_RETRY_MAX_DELAY, DEFAULT_RO_TX_TIMEOUT, DEFAULT_RW_TX_TIMEOUT, DEFAULT_TOKEN_TTL_SECONDS, DefaultFinalResourceDataPredicate, DefaultPollingRetryOptions, DefaultRetryOptions, DisconnectedError, FieldData, FieldId, FieldRef, FieldStatus, FieldType, Filter, ResourceAPI_Tree_Filter_OperatorType as FilterOperatorType, ResourceAPI_Tree_Filter_Property as FilterProperty, FinalResourceDataPredicate, FutureFieldType, GlobalResourceId, GrantEntry, GrantPermissions, GrantType, GrpcConnection, KeyValue, KeyValueString, LocalFieldId, LocalResourceId, LoginMethod, MAX_ADAPTIVE_REQUEST_TIMEOUT, MaxLocalId, MaxTxId, NullResourceId, NullSignedResourceId, OptionalAnyResourceId, OptionalSignedResourceId, PermissionDeniedError, pl_d_exports as Pl, PlClient, PlClientConfig, PlConnectionStatus, PlConnectionStatusListener, PlDriver, PlDriverDefinition, PlError, PlErrorCodeNotFound, PlTransaction, PollFieldTraverseOps, PollResourceAccessor, PollTxAccessor, Property, RESTError, RTT_DEADLINE_MULTIPLIER, RTT_SMOOTHING_ALPHA, RecoverablePlError, type ResourceAPI_Tree_Filter, ResourceData, ResourceIdWithSignature, ResourceKind, ResourceRef, ResourceSignature, ResourceTreeFrame, ResourceTreeItem, ResourceType, ResourceTypeName, ResourceTypePrefix, index_d_exports as RestAPI, RestConnection, Role, SSOAuthMethod, SSOFlowType, SSOLoginAttempt, SUPPORTED_WIRE_PROTOCOLS, SignedResourceId, StorageInfo, test_config_d_exports as TestHelpers, TxCommitConflict, TxOps, TxRunner, UnauthenticatedError, UnauthenticatedPlClient, UnrecoverablePlError, UserDeletionReport, UserEntry, UserResources, ValErr, WireClientProvider, WireClientProviderFactory, WireConnection, addRTypeToMetadata, anyResourceIdToBigint, asSignedResourceId, base64UrlToSignature, checkLocalityOfResourceId, createGlobalResourceId, createLocalResourceId, createRTypeRoutingHeader, createSignedResourceId, defaultPlClient, deriveUnaryDeadline, ensureSignedResourceIdNotNull, expirationFromAuthInformation, extractBasicResourceData, extractTxId, field, getField, hasCapability, inferAuthRefreshTime, isAbortedError, isAnyResourceId, isCancelError, isConnectionProblem, isEveryoneUserLogin, isField, isFieldRef, isLocalResourceId, isNotFoundError, isNotNullSignedResourceId, isNullSignedResourceId, isPermissionDenied, isResource, isResourceId, isResourceRef, isRootResourceId, isSignedResourceId, isTimeoutError, isTimeoutOrCancelError, isTransientCallFailure, isUnauthenticated, isUnimplementedError, jsonToData, parseResourceType, parseSignedResourceId, plAddressToConfig, poll, readyOrDuplicateOrError, resDataToJson, resourceIdFromString, resourceIdToString, resourceType, resourceTypeToString, resourceTypesEqual, rethrowMeaningfulError, setResourceSignaturesRequired, signatureToBase64Url, smoothRtt, stringifyWithResourceId, throwPlNotFoundError, toFieldId, toGlobalFieldId, toGlobalResourceId, toResourceSignature, treeFilter, tryGetFileConfig, valErr, wireProtocol };
|