@approvio/ts-sdk 0.0.25 → 0.0.27
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/index.cjs +49 -27
- package/dist/index.d.cts +4 -2
- package/dist/index.d.mts +4 -2
- package/dist/index.mjs +25 -3
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -22,15 +22,15 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
22
22
|
}) : target, mod));
|
|
23
23
|
//#endregion
|
|
24
24
|
let jose = require("jose");
|
|
25
|
-
jose = __toESM(jose);
|
|
25
|
+
jose = __toESM(jose, 1);
|
|
26
26
|
let _approvio_api = require("@approvio/api");
|
|
27
27
|
let axios = require("axios");
|
|
28
|
-
axios = __toESM(axios);
|
|
28
|
+
axios = __toESM(axios, 1);
|
|
29
29
|
let node_crypto = require("node:crypto");
|
|
30
|
-
node_crypto = __toESM(node_crypto);
|
|
31
|
-
let
|
|
32
|
-
|
|
33
|
-
let
|
|
30
|
+
node_crypto = __toESM(node_crypto, 1);
|
|
31
|
+
let fp_ts_lib_TaskEither_js = require("fp-ts/lib/TaskEither.js");
|
|
32
|
+
fp_ts_lib_TaskEither_js = __toESM(fp_ts_lib_TaskEither_js, 1);
|
|
33
|
+
let fp_ts_lib_function_js = require("fp-ts/lib/function.js");
|
|
34
34
|
//#region src/auth/utils.ts
|
|
35
35
|
function isJwtTokenExpired(token) {
|
|
36
36
|
if (!token) return true;
|
|
@@ -57,7 +57,7 @@ function validateURL(url) {
|
|
|
57
57
|
function removeTrailingSlash(url) {
|
|
58
58
|
return url.endsWith("/") ? url.slice(0, -1) : url;
|
|
59
59
|
}
|
|
60
|
-
const USER_AGENT = `Approvio-TS-SDK/0.0.
|
|
60
|
+
const USER_AGENT = `Approvio-TS-SDK/0.0.27`;
|
|
61
61
|
//#endregion
|
|
62
62
|
//#region src/client/http.ts
|
|
63
63
|
/**
|
|
@@ -79,6 +79,9 @@ function createAxiosInstance(config) {
|
|
|
79
79
|
* Handles automatic token renewal using a refresh token when the access token expires.
|
|
80
80
|
*/
|
|
81
81
|
var CliUserAuthenticator = class {
|
|
82
|
+
accessToken;
|
|
83
|
+
refreshToken;
|
|
84
|
+
onTokenRefreshed;
|
|
82
85
|
endpoint;
|
|
83
86
|
axios;
|
|
84
87
|
constructor(endpoint, accessToken, refreshToken, onTokenRefreshed) {
|
|
@@ -168,7 +171,7 @@ var AuthHelper = class {
|
|
|
168
171
|
* Prompts the backend to return an authorization URL for the IDP.
|
|
169
172
|
*/
|
|
170
173
|
initiateCliLogin(redirectUri) {
|
|
171
|
-
return
|
|
174
|
+
return fp_ts_lib_TaskEither_js.tryCatch(async () => {
|
|
172
175
|
return (await this.axios.post("/auth/cli/initiate", { redirectUri })).data.authorizationUrl;
|
|
173
176
|
}, (error) => this.handleError(error));
|
|
174
177
|
}
|
|
@@ -181,7 +184,7 @@ var AuthHelper = class {
|
|
|
181
184
|
code,
|
|
182
185
|
state
|
|
183
186
|
};
|
|
184
|
-
return
|
|
187
|
+
return fp_ts_lib_TaskEither_js.tryCatch(async () => {
|
|
185
188
|
return (await this.axios.post("/auth/cli/token", request)).data;
|
|
186
189
|
}, (error) => this.handleError(error));
|
|
187
190
|
}
|
|
@@ -193,7 +196,7 @@ var AuthHelper = class {
|
|
|
193
196
|
* 4. Exchange the assertion for an access token.
|
|
194
197
|
*/
|
|
195
198
|
authenticateAgent(agentName, privateKeyPem) {
|
|
196
|
-
return
|
|
199
|
+
return fp_ts_lib_TaskEither_js.tryCatch(async () => {
|
|
197
200
|
const challengeRequest = { agentName };
|
|
198
201
|
const { challenge: b64EncodedChallenge } = (await this.axios.post("/auth/agents/challenge", challengeRequest)).data;
|
|
199
202
|
const encryptedBuffer = Buffer.from(b64EncodedChallenge, "base64");
|
|
@@ -240,6 +243,10 @@ var AuthHelper = class {
|
|
|
240
243
|
* Handles automatic token renewal using a refresh token and DPoP proof when the access token expires.
|
|
241
244
|
*/
|
|
242
245
|
var AgentAuthenticator = class {
|
|
246
|
+
privateKey;
|
|
247
|
+
accessToken;
|
|
248
|
+
refreshToken;
|
|
249
|
+
onTokenRefreshed;
|
|
243
250
|
endpoint;
|
|
244
251
|
axios;
|
|
245
252
|
constructor(endpoint, privateKey, accessToken, refreshToken, onTokenRefreshed) {
|
|
@@ -301,6 +308,8 @@ var NetworkError = class extends Error {
|
|
|
301
308
|
}
|
|
302
309
|
};
|
|
303
310
|
var UnexpectedEntityTypeError = class extends Error {
|
|
311
|
+
expected;
|
|
312
|
+
received;
|
|
304
313
|
constructor(expected, received) {
|
|
305
314
|
super(`Expected entity type ${expected} but received ${received}`);
|
|
306
315
|
this.expected = expected;
|
|
@@ -319,6 +328,8 @@ const networkCodes = [
|
|
|
319
328
|
* Base client for Approvio API.
|
|
320
329
|
*/
|
|
321
330
|
var BaseApprovioClient = class {
|
|
331
|
+
config;
|
|
332
|
+
authenticator;
|
|
322
333
|
axios;
|
|
323
334
|
constructor(config, authenticator) {
|
|
324
335
|
this.config = config;
|
|
@@ -347,7 +358,7 @@ var BaseApprovioClient = class {
|
|
|
347
358
|
* Performs a GET request.
|
|
348
359
|
*/
|
|
349
360
|
get(url, params) {
|
|
350
|
-
return
|
|
361
|
+
return fp_ts_lib_TaskEither_js.tryCatch(async () => {
|
|
351
362
|
return (await this.axios.get(url, { params })).data;
|
|
352
363
|
}, (error) => this.handleError(error));
|
|
353
364
|
}
|
|
@@ -355,12 +366,12 @@ var BaseApprovioClient = class {
|
|
|
355
366
|
* Performs a POST request.
|
|
356
367
|
*/
|
|
357
368
|
post(url, data) {
|
|
358
|
-
return
|
|
369
|
+
return fp_ts_lib_TaskEither_js.tryCatch(async () => {
|
|
359
370
|
return (await this.axios.post(url, data)).data;
|
|
360
371
|
}, (error) => this.handleError(error));
|
|
361
372
|
}
|
|
362
373
|
postWithLocation(url, data) {
|
|
363
|
-
return
|
|
374
|
+
return fp_ts_lib_TaskEither_js.tryCatch(async () => {
|
|
364
375
|
const response = await this.axios.post(url, data);
|
|
365
376
|
const location = response.headers["location"];
|
|
366
377
|
if (!location) throw new LocationNotFoundError();
|
|
@@ -374,7 +385,7 @@ var BaseApprovioClient = class {
|
|
|
374
385
|
* Performs a PUT request.
|
|
375
386
|
*/
|
|
376
387
|
put(url, data) {
|
|
377
|
-
return
|
|
388
|
+
return fp_ts_lib_TaskEither_js.tryCatch(async () => {
|
|
378
389
|
return (await this.axios.put(url, data)).data;
|
|
379
390
|
}, (error) => this.handleError(error));
|
|
380
391
|
}
|
|
@@ -382,7 +393,7 @@ var BaseApprovioClient = class {
|
|
|
382
393
|
* Performs a DELETE request.
|
|
383
394
|
*/
|
|
384
395
|
delete(url, data) {
|
|
385
|
-
return
|
|
396
|
+
return fp_ts_lib_TaskEither_js.tryCatch(async () => {
|
|
386
397
|
const config = data !== void 0 ? { data } : void 0;
|
|
387
398
|
return (await this.axios.delete(url, config)).data;
|
|
388
399
|
}, (error) => this.handleError(error));
|
|
@@ -438,6 +449,12 @@ var BaseApprovioClient = class {
|
|
|
438
449
|
listVotes(workflowId, params) {
|
|
439
450
|
return this.get(`/workflows/${workflowId}/votes`, params);
|
|
440
451
|
}
|
|
452
|
+
/**
|
|
453
|
+
* Get available authentication providers.
|
|
454
|
+
*/
|
|
455
|
+
getAuthProviders() {
|
|
456
|
+
return this.get("/auth/providers");
|
|
457
|
+
}
|
|
441
458
|
};
|
|
442
459
|
//#endregion
|
|
443
460
|
//#region src/client/user.client.ts
|
|
@@ -445,6 +462,7 @@ var BaseApprovioClient = class {
|
|
|
445
462
|
* Client for Approvio API (Human/User).
|
|
446
463
|
*/
|
|
447
464
|
var ApprovioUserClient = class extends BaseApprovioClient {
|
|
465
|
+
authenticator;
|
|
448
466
|
constructor(config, authenticator) {
|
|
449
467
|
super(config, authenticator);
|
|
450
468
|
this.authenticator = authenticator;
|
|
@@ -462,10 +480,10 @@ var ApprovioUserClient = class extends BaseApprovioClient {
|
|
|
462
480
|
return this.delete(`/agents/${agentId}/roles`, data);
|
|
463
481
|
}
|
|
464
482
|
createUser(data) {
|
|
465
|
-
return (0,
|
|
483
|
+
return (0, fp_ts_lib_function_js.pipe)(this.postWithLocation("/users", data), fp_ts_lib_TaskEither_js.map(({ location }) => location), fp_ts_lib_TaskEither_js.chain((location) => {
|
|
466
484
|
const id = location.split("/").pop();
|
|
467
|
-
if (!id) return
|
|
468
|
-
return
|
|
485
|
+
if (!id) return fp_ts_lib_TaskEither_js.left(/* @__PURE__ */ new Error("Invalid location"));
|
|
486
|
+
return fp_ts_lib_TaskEither_js.right(id);
|
|
469
487
|
}));
|
|
470
488
|
}
|
|
471
489
|
getUser(userId) {
|
|
@@ -493,10 +511,10 @@ var ApprovioUserClient = class extends BaseApprovioClient {
|
|
|
493
511
|
return this.post(`/workflow-templates/${templateName}/deprecate`, data);
|
|
494
512
|
}
|
|
495
513
|
createGroup(data) {
|
|
496
|
-
return (0,
|
|
514
|
+
return (0, fp_ts_lib_function_js.pipe)(this.postWithLocation("/groups", data), fp_ts_lib_TaskEither_js.map(({ location }) => location), fp_ts_lib_TaskEither_js.chain((location) => {
|
|
497
515
|
const id = location.split("/").pop();
|
|
498
|
-
if (!id) return
|
|
499
|
-
return
|
|
516
|
+
if (!id) return fp_ts_lib_TaskEither_js.left(/* @__PURE__ */ new Error("Invalid location"));
|
|
517
|
+
return fp_ts_lib_TaskEither_js.right(id);
|
|
500
518
|
}));
|
|
501
519
|
}
|
|
502
520
|
listGroups(params) {
|
|
@@ -539,9 +557,9 @@ var ApprovioUserClient = class extends BaseApprovioClient {
|
|
|
539
557
|
return this.get(`/agents/${agentId}`);
|
|
540
558
|
}
|
|
541
559
|
getEntityInfo() {
|
|
542
|
-
return (0,
|
|
543
|
-
if (info.entityType === "user") return
|
|
544
|
-
return
|
|
560
|
+
return (0, fp_ts_lib_function_js.pipe)(super.getEntityInfo(), fp_ts_lib_TaskEither_js.chain((info) => {
|
|
561
|
+
if (info.entityType === "user") return fp_ts_lib_TaskEither_js.right(info);
|
|
562
|
+
return fp_ts_lib_TaskEither_js.left(new UnexpectedEntityTypeError("user", info.entityType));
|
|
545
563
|
}));
|
|
546
564
|
}
|
|
547
565
|
listAuditLogs(params) {
|
|
@@ -550,6 +568,9 @@ var ApprovioUserClient = class extends BaseApprovioClient {
|
|
|
550
568
|
listMyAuditLogs(params) {
|
|
551
569
|
return this.get("/audit-logs/me", params);
|
|
552
570
|
}
|
|
571
|
+
resolveResources(params) {
|
|
572
|
+
return this.post("/resources/resolve", params);
|
|
573
|
+
}
|
|
553
574
|
logout() {
|
|
554
575
|
return this.post("/auth/web/logout");
|
|
555
576
|
}
|
|
@@ -560,6 +581,7 @@ var ApprovioUserClient = class extends BaseApprovioClient {
|
|
|
560
581
|
* Client for Approvio API (Agent).
|
|
561
582
|
*/
|
|
562
583
|
var ApprovioAgentClient = class extends BaseApprovioClient {
|
|
584
|
+
authenticator;
|
|
563
585
|
constructor(config, authenticator) {
|
|
564
586
|
super(config, authenticator);
|
|
565
587
|
this.authenticator = authenticator;
|
|
@@ -568,9 +590,9 @@ var ApprovioAgentClient = class extends BaseApprovioClient {
|
|
|
568
590
|
return this.authenticator;
|
|
569
591
|
}
|
|
570
592
|
getEntityInfo() {
|
|
571
|
-
return (0,
|
|
572
|
-
if (info.entityType === "agent") return
|
|
573
|
-
return
|
|
593
|
+
return (0, fp_ts_lib_function_js.pipe)(super.getEntityInfo(), fp_ts_lib_TaskEither_js.chain((info) => {
|
|
594
|
+
if (info.entityType === "agent") return fp_ts_lib_TaskEither_js.right(info);
|
|
595
|
+
return fp_ts_lib_TaskEither_js.left(new UnexpectedEntityTypeError("agent", info.entityType));
|
|
574
596
|
}));
|
|
575
597
|
}
|
|
576
598
|
};
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AxiosInstance } from "axios";
|
|
2
|
-
import { APIError, AddGroupEntitiesRequest, AgentGet200Response, AgentRegistrationRequest, AgentRegistrationResponse, AgentTokenResponse, CanVoteResponse, GetEntityInfo200Response, GetEntityInfoAgentResponse, GetEntityInfoUserResponse, GetWorkflowParams, GetWorkflowVotes200Response, Group, GroupCreate, ListAuditLogs200Response, ListAuditLogsParams, ListGroupEntities200Response, ListGroups200Response, ListGroupsParams, ListMyAuditLogsParams, ListOrganizationAdminsForOrg200Response, ListRoleTemplates200Response, ListSpaces200Response, ListSpacesParams, ListUsers200Response, ListUsersParams, ListWorkflowTemplates200Response, ListWorkflowTemplatesParams, ListWorkflowVotesParams, ListWorkflows200Response, ListWorkflowsParams, OrganizationAdminCreate, OrganizationAdminRemove, RemoveGroupEntitiesRequest, RoleAssignmentRequest, RoleRemovalRequest, Space, SpaceCreate, TokenResponse, User, UserCreate, Workflow, WorkflowCreate, WorkflowTemplate, WorkflowTemplateCreate, WorkflowTemplateDeprecate, WorkflowTemplateUpdate, WorkflowVoteRequest } from "@approvio/api";
|
|
3
|
-
import * as TE from "fp-ts/TaskEither";
|
|
2
|
+
import { APIError, AddGroupEntitiesRequest, AgentGet200Response, AgentRegistrationRequest, AgentRegistrationResponse, AgentTokenResponse, AuthProvider, CanVoteResponse, GetEntityInfo200Response, GetEntityInfoAgentResponse, GetEntityInfoUserResponse, GetWorkflowParams, GetWorkflowVotes200Response, Group, GroupCreate, ListAuditLogs200Response, ListAuditLogsParams, ListGroupEntities200Response, ListGroups200Response, ListGroupsParams, ListMyAuditLogsParams, ListOrganizationAdminsForOrg200Response, ListRoleTemplates200Response, ListSpaces200Response, ListSpacesParams, ListUsers200Response, ListUsersParams, ListWorkflowTemplates200Response, ListWorkflowTemplatesParams, ListWorkflowVotesParams, ListWorkflows200Response, ListWorkflowsParams, OrganizationAdminCreate, OrganizationAdminRemove, RemoveGroupEntitiesRequest, ResourceResolveRequest, ResourceResolveResponse, RoleAssignmentRequest, RoleRemovalRequest, Space, SpaceCreate, TokenResponse, User, UserCreate, Workflow, WorkflowCreate, WorkflowTemplate, WorkflowTemplateCreate, WorkflowTemplateDeprecate, WorkflowTemplateUpdate, WorkflowVoteRequest } from "@approvio/api";
|
|
3
|
+
import * as TE from "fp-ts/lib/TaskEither.js";
|
|
4
4
|
|
|
5
5
|
//#region src/interfaces.d.ts
|
|
6
6
|
interface Authenticator {
|
|
@@ -61,6 +61,7 @@ declare abstract class BaseApprovioClient {
|
|
|
61
61
|
listRoleTemplates(): TE.TaskEither<ApprovioError, ListRoleTemplates200Response>;
|
|
62
62
|
getEntityInfo(): TE.TaskEither<ApprovioError, GetEntityInfo200Response>;
|
|
63
63
|
listVotes(workflowId: string, params?: ListWorkflowVotesParams): TE.TaskEither<ApprovioError, GetWorkflowVotes200Response>;
|
|
64
|
+
getAuthProviders(): TE.TaskEither<ApprovioError, AuthProvider[]>;
|
|
64
65
|
}
|
|
65
66
|
//#endregion
|
|
66
67
|
//#region src/auth/auth.helpers.d.ts
|
|
@@ -130,6 +131,7 @@ declare class ApprovioUserClient extends BaseApprovioClient {
|
|
|
130
131
|
getEntityInfo(): TE.TaskEither<ApprovioError, GetEntityInfoUserResponse>;
|
|
131
132
|
listAuditLogs(params?: ListAuditLogsParams): TE.TaskEither<ApprovioError, ListAuditLogs200Response>;
|
|
132
133
|
listMyAuditLogs(params?: ListMyAuditLogsParams): TE.TaskEither<ApprovioError, ListAuditLogs200Response>;
|
|
134
|
+
resolveResources(params: ResourceResolveRequest): TE.TaskEither<ApprovioError, ResourceResolveResponse>;
|
|
133
135
|
logout(): TE.TaskEither<ApprovioError, void>;
|
|
134
136
|
}
|
|
135
137
|
//#endregion
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { APIError, AddGroupEntitiesRequest, AgentGet200Response, AgentRegistrationRequest, AgentRegistrationResponse, AgentTokenResponse, CanVoteResponse, GetEntityInfo200Response, GetEntityInfoAgentResponse, GetEntityInfoUserResponse, GetWorkflowParams, GetWorkflowVotes200Response, Group, GroupCreate, ListAuditLogs200Response, ListAuditLogsParams, ListGroupEntities200Response, ListGroups200Response, ListGroupsParams, ListMyAuditLogsParams, ListOrganizationAdminsForOrg200Response, ListRoleTemplates200Response, ListSpaces200Response, ListSpacesParams, ListUsers200Response, ListUsersParams, ListWorkflowTemplates200Response, ListWorkflowTemplatesParams, ListWorkflowVotesParams, ListWorkflows200Response, ListWorkflowsParams, OrganizationAdminCreate, OrganizationAdminRemove, RemoveGroupEntitiesRequest, RoleAssignmentRequest, RoleRemovalRequest, Space, SpaceCreate, TokenResponse, User, UserCreate, Workflow, WorkflowCreate, WorkflowTemplate, WorkflowTemplateCreate, WorkflowTemplateDeprecate, WorkflowTemplateUpdate, WorkflowVoteRequest } from "@approvio/api";
|
|
1
|
+
import { APIError, AddGroupEntitiesRequest, AgentGet200Response, AgentRegistrationRequest, AgentRegistrationResponse, AgentTokenResponse, AuthProvider, CanVoteResponse, GetEntityInfo200Response, GetEntityInfoAgentResponse, GetEntityInfoUserResponse, GetWorkflowParams, GetWorkflowVotes200Response, Group, GroupCreate, ListAuditLogs200Response, ListAuditLogsParams, ListGroupEntities200Response, ListGroups200Response, ListGroupsParams, ListMyAuditLogsParams, ListOrganizationAdminsForOrg200Response, ListRoleTemplates200Response, ListSpaces200Response, ListSpacesParams, ListUsers200Response, ListUsersParams, ListWorkflowTemplates200Response, ListWorkflowTemplatesParams, ListWorkflowVotesParams, ListWorkflows200Response, ListWorkflowsParams, OrganizationAdminCreate, OrganizationAdminRemove, RemoveGroupEntitiesRequest, ResourceResolveRequest, ResourceResolveResponse, RoleAssignmentRequest, RoleRemovalRequest, Space, SpaceCreate, TokenResponse, User, UserCreate, Workflow, WorkflowCreate, WorkflowTemplate, WorkflowTemplateCreate, WorkflowTemplateDeprecate, WorkflowTemplateUpdate, WorkflowVoteRequest } from "@approvio/api";
|
|
2
2
|
import { AxiosInstance } from "axios";
|
|
3
|
-
import * as TE from "fp-ts/TaskEither";
|
|
3
|
+
import * as TE from "fp-ts/lib/TaskEither.js";
|
|
4
4
|
|
|
5
5
|
//#region src/interfaces.d.ts
|
|
6
6
|
interface Authenticator {
|
|
@@ -61,6 +61,7 @@ declare abstract class BaseApprovioClient {
|
|
|
61
61
|
listRoleTemplates(): TE.TaskEither<ApprovioError, ListRoleTemplates200Response>;
|
|
62
62
|
getEntityInfo(): TE.TaskEither<ApprovioError, GetEntityInfo200Response>;
|
|
63
63
|
listVotes(workflowId: string, params?: ListWorkflowVotesParams): TE.TaskEither<ApprovioError, GetWorkflowVotes200Response>;
|
|
64
|
+
getAuthProviders(): TE.TaskEither<ApprovioError, AuthProvider[]>;
|
|
64
65
|
}
|
|
65
66
|
//#endregion
|
|
66
67
|
//#region src/auth/auth.helpers.d.ts
|
|
@@ -130,6 +131,7 @@ declare class ApprovioUserClient extends BaseApprovioClient {
|
|
|
130
131
|
getEntityInfo(): TE.TaskEither<ApprovioError, GetEntityInfoUserResponse>;
|
|
131
132
|
listAuditLogs(params?: ListAuditLogsParams): TE.TaskEither<ApprovioError, ListAuditLogs200Response>;
|
|
132
133
|
listMyAuditLogs(params?: ListMyAuditLogsParams): TE.TaskEither<ApprovioError, ListAuditLogs200Response>;
|
|
134
|
+
resolveResources(params: ResourceResolveRequest): TE.TaskEither<ApprovioError, ResourceResolveResponse>;
|
|
133
135
|
logout(): TE.TaskEither<ApprovioError, void>;
|
|
134
136
|
}
|
|
135
137
|
//#endregion
|
package/dist/index.mjs
CHANGED
|
@@ -3,8 +3,8 @@ import { decodeJwt } from "jose";
|
|
|
3
3
|
import { isAPIError } from "@approvio/api";
|
|
4
4
|
import axios from "axios";
|
|
5
5
|
import * as crypto$1 from "node:crypto";
|
|
6
|
-
import * as TE from "fp-ts/TaskEither";
|
|
7
|
-
import { pipe } from "fp-ts/function";
|
|
6
|
+
import * as TE from "fp-ts/lib/TaskEither.js";
|
|
7
|
+
import { pipe } from "fp-ts/lib/function.js";
|
|
8
8
|
//#region src/auth/utils.ts
|
|
9
9
|
function isJwtTokenExpired(token) {
|
|
10
10
|
if (!token) return true;
|
|
@@ -31,7 +31,7 @@ function validateURL(url) {
|
|
|
31
31
|
function removeTrailingSlash(url) {
|
|
32
32
|
return url.endsWith("/") ? url.slice(0, -1) : url;
|
|
33
33
|
}
|
|
34
|
-
const USER_AGENT = `Approvio-TS-SDK/0.0.
|
|
34
|
+
const USER_AGENT = `Approvio-TS-SDK/0.0.27`;
|
|
35
35
|
//#endregion
|
|
36
36
|
//#region src/client/http.ts
|
|
37
37
|
/**
|
|
@@ -53,6 +53,9 @@ function createAxiosInstance(config) {
|
|
|
53
53
|
* Handles automatic token renewal using a refresh token when the access token expires.
|
|
54
54
|
*/
|
|
55
55
|
var CliUserAuthenticator = class {
|
|
56
|
+
accessToken;
|
|
57
|
+
refreshToken;
|
|
58
|
+
onTokenRefreshed;
|
|
56
59
|
endpoint;
|
|
57
60
|
axios;
|
|
58
61
|
constructor(endpoint, accessToken, refreshToken, onTokenRefreshed) {
|
|
@@ -214,6 +217,10 @@ var AuthHelper = class {
|
|
|
214
217
|
* Handles automatic token renewal using a refresh token and DPoP proof when the access token expires.
|
|
215
218
|
*/
|
|
216
219
|
var AgentAuthenticator = class {
|
|
220
|
+
privateKey;
|
|
221
|
+
accessToken;
|
|
222
|
+
refreshToken;
|
|
223
|
+
onTokenRefreshed;
|
|
217
224
|
endpoint;
|
|
218
225
|
axios;
|
|
219
226
|
constructor(endpoint, privateKey, accessToken, refreshToken, onTokenRefreshed) {
|
|
@@ -275,6 +282,8 @@ var NetworkError = class extends Error {
|
|
|
275
282
|
}
|
|
276
283
|
};
|
|
277
284
|
var UnexpectedEntityTypeError = class extends Error {
|
|
285
|
+
expected;
|
|
286
|
+
received;
|
|
278
287
|
constructor(expected, received) {
|
|
279
288
|
super(`Expected entity type ${expected} but received ${received}`);
|
|
280
289
|
this.expected = expected;
|
|
@@ -293,6 +302,8 @@ const networkCodes = [
|
|
|
293
302
|
* Base client for Approvio API.
|
|
294
303
|
*/
|
|
295
304
|
var BaseApprovioClient = class {
|
|
305
|
+
config;
|
|
306
|
+
authenticator;
|
|
296
307
|
axios;
|
|
297
308
|
constructor(config, authenticator) {
|
|
298
309
|
this.config = config;
|
|
@@ -412,6 +423,12 @@ var BaseApprovioClient = class {
|
|
|
412
423
|
listVotes(workflowId, params) {
|
|
413
424
|
return this.get(`/workflows/${workflowId}/votes`, params);
|
|
414
425
|
}
|
|
426
|
+
/**
|
|
427
|
+
* Get available authentication providers.
|
|
428
|
+
*/
|
|
429
|
+
getAuthProviders() {
|
|
430
|
+
return this.get("/auth/providers");
|
|
431
|
+
}
|
|
415
432
|
};
|
|
416
433
|
//#endregion
|
|
417
434
|
//#region src/client/user.client.ts
|
|
@@ -419,6 +436,7 @@ var BaseApprovioClient = class {
|
|
|
419
436
|
* Client for Approvio API (Human/User).
|
|
420
437
|
*/
|
|
421
438
|
var ApprovioUserClient = class extends BaseApprovioClient {
|
|
439
|
+
authenticator;
|
|
422
440
|
constructor(config, authenticator) {
|
|
423
441
|
super(config, authenticator);
|
|
424
442
|
this.authenticator = authenticator;
|
|
@@ -524,6 +542,9 @@ var ApprovioUserClient = class extends BaseApprovioClient {
|
|
|
524
542
|
listMyAuditLogs(params) {
|
|
525
543
|
return this.get("/audit-logs/me", params);
|
|
526
544
|
}
|
|
545
|
+
resolveResources(params) {
|
|
546
|
+
return this.post("/resources/resolve", params);
|
|
547
|
+
}
|
|
527
548
|
logout() {
|
|
528
549
|
return this.post("/auth/web/logout");
|
|
529
550
|
}
|
|
@@ -534,6 +555,7 @@ var ApprovioUserClient = class extends BaseApprovioClient {
|
|
|
534
555
|
* Client for Approvio API (Agent).
|
|
535
556
|
*/
|
|
536
557
|
var ApprovioAgentClient = class extends BaseApprovioClient {
|
|
558
|
+
authenticator;
|
|
537
559
|
constructor(config, authenticator) {
|
|
538
560
|
super(config, authenticator);
|
|
539
561
|
this.authenticator = authenticator;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@approvio/ts-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.27",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"prepublishOnly": "yarn format && yarn lint && yarn build"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@approvio/api": "0.0.
|
|
37
|
+
"@approvio/api": "0.0.57",
|
|
38
38
|
"axios": "1.16.1",
|
|
39
39
|
"jose": "6.2.3"
|
|
40
40
|
},
|
|
@@ -55,10 +55,10 @@
|
|
|
55
55
|
"fp-ts": "2.16.11",
|
|
56
56
|
"io-ts": "2.2.20",
|
|
57
57
|
"jest": "29.7.0",
|
|
58
|
-
"prettier": "3.
|
|
58
|
+
"prettier": "3.8.3",
|
|
59
59
|
"semver": "^7.8.0",
|
|
60
60
|
"ts-jest": "29.4.6",
|
|
61
|
-
"tsdown": "^0.
|
|
61
|
+
"tsdown": "^0.22.3",
|
|
62
62
|
"typescript": "5.9.3"
|
|
63
63
|
}
|
|
64
64
|
}
|