@topolo/sdk 0.17.1 → 0.19.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/README.md +13 -0
- package/dist/index.cjs +111 -4
- package/dist/index.d.cts +36 -6
- package/dist/index.d.ts +36 -6
- package/dist/index.js +107 -4
- package/dist/node/credential-store.d.cts +9 -5
- package/dist/node/credential-store.d.ts +9 -5
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -160,6 +160,19 @@ input and resource before sending its canonical base64url representation in
|
|
|
160
160
|
`X-Topolo-Actor-Envelope`; the envelope request ID also becomes the transport
|
|
161
161
|
request ID.
|
|
162
162
|
|
|
163
|
+
Use `projectActorAuditEvent` when persisting or rendering immutable audit
|
|
164
|
+
events. The role remains explicit and the friendly label is derived without
|
|
165
|
+
rewriting either identity:
|
|
166
|
+
|
|
167
|
+
```ts
|
|
168
|
+
const executedBy = projectActorAuditEvent(actorEnvelope, 'executed_by');
|
|
169
|
+
// executedBy.label === 'Ashley Lane via codex'
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
The frozen projection retains the accountable subject, actual performer,
|
|
173
|
+
delegation, channel, assurance, resource, request, action and canonical input
|
|
174
|
+
hash for consistent application queries and exports.
|
|
175
|
+
|
|
163
176
|
## Modules
|
|
164
177
|
|
|
165
178
|
| Surface | Methods |
|
package/dist/index.cjs
CHANGED
|
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
ACTION_CATALOG_DIGEST_ALGORITHM: () => ACTION_CATALOG_DIGEST_ALGORITHM,
|
|
24
|
+
ACTOR_AUDIT_PROJECTION_VERSION: () => ACTOR_AUDIT_PROJECTION_VERSION,
|
|
24
25
|
ACTOR_ENVELOPE_VERSION: () => ACTOR_ENVELOPE_VERSION,
|
|
25
26
|
ActorEnvelopeValidationError: () => ActorEnvelopeValidationError,
|
|
26
27
|
CrmModule: () => CrmModule,
|
|
@@ -45,6 +46,7 @@ __export(index_exports, {
|
|
|
45
46
|
actionContractCompleteness: () => actionContractCompleteness,
|
|
46
47
|
applicationEntryFromCatalog: () => applicationEntryFromCatalog,
|
|
47
48
|
assertTopoloServiceUrlEnvironment: () => assertTopoloServiceUrlEnvironment,
|
|
49
|
+
calculateDpopJkt: () => calculateDpopJkt,
|
|
48
50
|
canonicalJson: () => canonicalJson,
|
|
49
51
|
canonicalTopoloErrorCode: () => canonicalTopoloErrorCode,
|
|
50
52
|
canonicalTopoloRequestId: () => canonicalTopoloRequestId,
|
|
@@ -56,6 +58,7 @@ __export(index_exports, {
|
|
|
56
58
|
compactActionPreparation: () => compactActionPreparation,
|
|
57
59
|
compactActionResult: () => compactActionResult,
|
|
58
60
|
compactActionValidation: () => compactActionValidation,
|
|
61
|
+
createDpopProof: () => createDpopProof,
|
|
59
62
|
createTopolo: () => createTopolo,
|
|
60
63
|
createTopoloAgentExecutionContext: () => createTopoloAgentExecutionContext,
|
|
61
64
|
createTopoloWidgetError: () => createTopoloWidgetError,
|
|
@@ -81,6 +84,7 @@ __export(index_exports, {
|
|
|
81
84
|
preferExactActionMatches: () => preferExactActionMatches,
|
|
82
85
|
prepareTopoloActionBase64UploadInput: () => prepareTopoloActionBase64UploadInput,
|
|
83
86
|
prepareTopoloActionUploadInput: () => prepareTopoloActionUploadInput,
|
|
87
|
+
projectActorAuditEvent: () => projectActorAuditEvent,
|
|
84
88
|
publicTopoloErrorMessage: () => publicTopoloErrorMessage,
|
|
85
89
|
resolveApplicationDirectoryEntry: () => resolveApplicationDirectoryEntry,
|
|
86
90
|
resolveCatalogServiceUrl: () => resolveCatalogServiceUrl,
|
|
@@ -99,7 +103,7 @@ function applyAuthHeaders(headers, credential) {
|
|
|
99
103
|
headers.set("X-Api-Key", credential.apiKey);
|
|
100
104
|
return;
|
|
101
105
|
}
|
|
102
|
-
headers.set("Authorization",
|
|
106
|
+
headers.set("Authorization", `${credential.kind === "dpop_access_token" ? "DPoP" : "Bearer"} ${credential.accessToken}`);
|
|
103
107
|
}
|
|
104
108
|
function applyAuditHeaders(headers, agent, requestId) {
|
|
105
109
|
headers.set("X-Topolo-Client", `${agent.clientName}/${agent.clientVersion}`);
|
|
@@ -113,6 +117,60 @@ function generateRequestId() {
|
|
|
113
117
|
return `req_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 10)}`;
|
|
114
118
|
}
|
|
115
119
|
|
|
120
|
+
// src/dpop.ts
|
|
121
|
+
var encoder = new TextEncoder();
|
|
122
|
+
function encodeBase64Url(value) {
|
|
123
|
+
const bytes = value instanceof Uint8Array ? value : new Uint8Array(value);
|
|
124
|
+
let binary = "";
|
|
125
|
+
for (const byte of bytes) binary += String.fromCharCode(byte);
|
|
126
|
+
return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, "");
|
|
127
|
+
}
|
|
128
|
+
function encodeJson(value) {
|
|
129
|
+
return encodeBase64Url(encoder.encode(JSON.stringify(value)));
|
|
130
|
+
}
|
|
131
|
+
async function sha256Base64Url(value) {
|
|
132
|
+
return encodeBase64Url(await crypto.subtle.digest("SHA-256", encoder.encode(value)));
|
|
133
|
+
}
|
|
134
|
+
function publicJwk(privateJwk) {
|
|
135
|
+
const { crv, kty, x, y } = privateJwk;
|
|
136
|
+
if (kty !== "EC" || crv !== "P-256" || !x || !y || !privateJwk.d) {
|
|
137
|
+
throw new TypeError("A private P-256 JSON Web Key is required for DPoP signing.");
|
|
138
|
+
}
|
|
139
|
+
return { crv, kty, x, y };
|
|
140
|
+
}
|
|
141
|
+
function canonicalTargetUrl(value) {
|
|
142
|
+
const url = new URL(value);
|
|
143
|
+
return `${url.origin}${url.pathname}`;
|
|
144
|
+
}
|
|
145
|
+
async function calculateDpopJkt(privateJwk) {
|
|
146
|
+
const jwk = publicJwk(privateJwk);
|
|
147
|
+
return sha256Base64Url(JSON.stringify({ crv: jwk.crv, kty: jwk.kty, x: jwk.x, y: jwk.y }));
|
|
148
|
+
}
|
|
149
|
+
async function createDpopProof(input) {
|
|
150
|
+
const jwk = publicJwk(input.privateJwk);
|
|
151
|
+
const key = await crypto.subtle.importKey(
|
|
152
|
+
"jwk",
|
|
153
|
+
input.privateJwk,
|
|
154
|
+
{ name: "ECDSA", namedCurve: "P-256" },
|
|
155
|
+
false,
|
|
156
|
+
["sign"]
|
|
157
|
+
);
|
|
158
|
+
const header = encodeJson({ alg: "ES256", typ: "dpop+jwt", jwk });
|
|
159
|
+
const claims = encodeJson({
|
|
160
|
+
jti: crypto.randomUUID(),
|
|
161
|
+
iat: Math.floor(Date.now() / 1e3),
|
|
162
|
+
htm: input.method.toUpperCase(),
|
|
163
|
+
htu: canonicalTargetUrl(input.targetUrl),
|
|
164
|
+
ath: await sha256Base64Url(input.accessToken)
|
|
165
|
+
});
|
|
166
|
+
const signature = await crypto.subtle.sign(
|
|
167
|
+
{ name: "ECDSA", hash: "SHA-256" },
|
|
168
|
+
key,
|
|
169
|
+
encoder.encode(`${header}.${claims}`)
|
|
170
|
+
);
|
|
171
|
+
return `${header}.${claims}.${encodeBase64Url(signature)}`;
|
|
172
|
+
}
|
|
173
|
+
|
|
116
174
|
// src/errors.ts
|
|
117
175
|
var TopoloSdkError = class extends Error {
|
|
118
176
|
code;
|
|
@@ -1469,7 +1527,6 @@ var TopoloClient = class _TopoloClient {
|
|
|
1469
1527
|
if (opts.body !== void 0) headers.set("Content-Type", "application/json");
|
|
1470
1528
|
const platformAppId = resolveConfiguredAppId(resolvedService.serviceKey, this.appIds);
|
|
1471
1529
|
if (platformAppId) headers.set("X-App-ID", platformAppId);
|
|
1472
|
-
applyAuthHeaders(headers, this.credential);
|
|
1473
1530
|
const actorEnvelope = opts.actorEnvelope === void 0 ? void 0 : parseActorEnvelope(opts.actorEnvelope);
|
|
1474
1531
|
const requestId = actorEnvelope?.action.requestId ?? generateRequestId();
|
|
1475
1532
|
applyAuditHeaders(headers, this.agent, requestId);
|
|
@@ -1503,9 +1560,19 @@ var TopoloClient = class _TopoloClient {
|
|
|
1503
1560
|
}, this.timeoutMs);
|
|
1504
1561
|
const signal = opts.signal ? mergeSignals(opts.signal, controller.signal) : controller.signal;
|
|
1505
1562
|
try {
|
|
1563
|
+
const requestHeaders = new Headers(headers);
|
|
1564
|
+
applyAuthHeaders(requestHeaders, this.credential);
|
|
1565
|
+
if (this.credential.kind === "dpop_access_token") {
|
|
1566
|
+
requestHeaders.set("DPoP", await createDpopProof({
|
|
1567
|
+
accessToken: this.credential.accessToken,
|
|
1568
|
+
method,
|
|
1569
|
+
targetUrl: urlStr,
|
|
1570
|
+
privateJwk: this.credential.privateJwk
|
|
1571
|
+
}));
|
|
1572
|
+
}
|
|
1506
1573
|
return await this.fetchImpl(urlStr, {
|
|
1507
1574
|
method,
|
|
1508
|
-
headers:
|
|
1575
|
+
headers: requestHeaders,
|
|
1509
1576
|
body: opts.rawBody ?? (opts.body !== void 0 ? JSON.stringify(opts.body) : null),
|
|
1510
1577
|
signal
|
|
1511
1578
|
});
|
|
@@ -1542,7 +1609,6 @@ var TopoloClient = class _TopoloClient {
|
|
|
1542
1609
|
await res.body?.cancel().catch(() => void 0);
|
|
1543
1610
|
const refreshed = await this.refreshRejectedAccessToken(attemptedCredential.accessToken);
|
|
1544
1611
|
if (refreshed) {
|
|
1545
|
-
applyAuthHeaders(headers, refreshed);
|
|
1546
1612
|
res = await fetchWithReadRetry();
|
|
1547
1613
|
}
|
|
1548
1614
|
}
|
|
@@ -3344,6 +3410,43 @@ var IdentityModule = class {
|
|
|
3344
3410
|
}
|
|
3345
3411
|
};
|
|
3346
3412
|
|
|
3413
|
+
// src/actor-audit.ts
|
|
3414
|
+
var ACTOR_AUDIT_PROJECTION_VERSION = 1;
|
|
3415
|
+
var EVENT_ROLES = /* @__PURE__ */ new Set([
|
|
3416
|
+
"requested_by",
|
|
3417
|
+
"acting_on_behalf_of",
|
|
3418
|
+
"approved_by",
|
|
3419
|
+
"executed_by"
|
|
3420
|
+
]);
|
|
3421
|
+
function projectActorAuditEvent(value, role) {
|
|
3422
|
+
if (!EVENT_ROLES.has(role)) throw new TypeError("Unsupported actor audit event role");
|
|
3423
|
+
const envelope = parseActorEnvelope(value);
|
|
3424
|
+
const subjectLabel = envelope.accountableSubject.displayName || envelope.accountableSubject.principalId;
|
|
3425
|
+
const performerLabel = envelope.performer.displayName || envelope.performer.model || envelope.performer.provider || envelope.performer.principalId;
|
|
3426
|
+
const direct = envelope.performer.principalType === envelope.accountableSubject.principalType && envelope.performer.principalId === envelope.accountableSubject.principalId;
|
|
3427
|
+
return deepFreeze({
|
|
3428
|
+
schemaVersion: ACTOR_AUDIT_PROJECTION_VERSION,
|
|
3429
|
+
role,
|
|
3430
|
+
label: direct ? subjectLabel : `${subjectLabel} via ${performerLabel}`,
|
|
3431
|
+
organizationId: envelope.organizationId,
|
|
3432
|
+
accountableSubject: envelope.accountableSubject,
|
|
3433
|
+
performer: envelope.performer,
|
|
3434
|
+
delegation: envelope.delegation,
|
|
3435
|
+
channel: envelope.channel,
|
|
3436
|
+
assurance: envelope.assurance,
|
|
3437
|
+
action: envelope.action,
|
|
3438
|
+
issuedAt: envelope.issuedAt,
|
|
3439
|
+
...envelope.expiresAt ? { expiresAt: envelope.expiresAt } : {}
|
|
3440
|
+
});
|
|
3441
|
+
}
|
|
3442
|
+
function deepFreeze(value) {
|
|
3443
|
+
if (value && typeof value === "object" && !Object.isFrozen(value)) {
|
|
3444
|
+
Object.freeze(value);
|
|
3445
|
+
for (const nested of Object.values(value)) deepFreeze(nested);
|
|
3446
|
+
}
|
|
3447
|
+
return value;
|
|
3448
|
+
}
|
|
3449
|
+
|
|
3347
3450
|
// src/modules/workspaces.ts
|
|
3348
3451
|
var ACTIONS = {
|
|
3349
3452
|
list: "app_topolo_auth.workspaces.list",
|
|
@@ -4835,6 +4938,7 @@ function createTopolo(options) {
|
|
|
4835
4938
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4836
4939
|
0 && (module.exports = {
|
|
4837
4940
|
ACTION_CATALOG_DIGEST_ALGORITHM,
|
|
4941
|
+
ACTOR_AUDIT_PROJECTION_VERSION,
|
|
4838
4942
|
ACTOR_ENVELOPE_VERSION,
|
|
4839
4943
|
ActorEnvelopeValidationError,
|
|
4840
4944
|
CrmModule,
|
|
@@ -4859,6 +4963,7 @@ function createTopolo(options) {
|
|
|
4859
4963
|
actionContractCompleteness,
|
|
4860
4964
|
applicationEntryFromCatalog,
|
|
4861
4965
|
assertTopoloServiceUrlEnvironment,
|
|
4966
|
+
calculateDpopJkt,
|
|
4862
4967
|
canonicalJson,
|
|
4863
4968
|
canonicalTopoloErrorCode,
|
|
4864
4969
|
canonicalTopoloRequestId,
|
|
@@ -4870,6 +4975,7 @@ function createTopolo(options) {
|
|
|
4870
4975
|
compactActionPreparation,
|
|
4871
4976
|
compactActionResult,
|
|
4872
4977
|
compactActionValidation,
|
|
4978
|
+
createDpopProof,
|
|
4873
4979
|
createTopolo,
|
|
4874
4980
|
createTopoloAgentExecutionContext,
|
|
4875
4981
|
createTopoloWidgetError,
|
|
@@ -4895,6 +5001,7 @@ function createTopolo(options) {
|
|
|
4895
5001
|
preferExactActionMatches,
|
|
4896
5002
|
prepareTopoloActionBase64UploadInput,
|
|
4897
5003
|
prepareTopoloActionUploadInput,
|
|
5004
|
+
projectActorAuditEvent,
|
|
4898
5005
|
publicTopoloErrorMessage,
|
|
4899
5006
|
resolveApplicationDirectoryEntry,
|
|
4900
5007
|
resolveCatalogServiceUrl,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Auth credential types used by the SDK.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Supported modes:
|
|
5
5
|
* - `api_key`: a single platform API key (service-scoped at issuance).
|
|
6
|
-
*
|
|
6
|
+
* Used for service integrations that are not installation-bound.
|
|
7
7
|
* - `access_token`: a short-lived JWT from the interactive login flow.
|
|
8
8
|
* Used by TopoloCli after `topolo auth login`.
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* PKCE flow in TopoloAuth. Those will plug in as a third variant.
|
|
9
|
+
* - `dpop_access_token`: a short-lived delegated token bound to an external
|
|
10
|
+
* agent installation key. Every request proves possession of that key.
|
|
12
11
|
*/
|
|
13
12
|
type TopoloCredential = {
|
|
14
13
|
kind: 'api_key';
|
|
@@ -18,6 +17,11 @@ type TopoloCredential = {
|
|
|
18
17
|
accessToken: string;
|
|
19
18
|
refreshToken?: string;
|
|
20
19
|
expiresAt?: number;
|
|
20
|
+
} | {
|
|
21
|
+
kind: 'dpop_access_token';
|
|
22
|
+
accessToken: string;
|
|
23
|
+
privateJwk: JsonWebKey;
|
|
24
|
+
expiresAt?: number;
|
|
21
25
|
};
|
|
22
26
|
interface AgentIdentity {
|
|
23
27
|
/** Display name of the agent or tool making requests. Included in audit headers. */
|
|
@@ -761,6 +765,14 @@ declare function actionContractCompleteness(
|
|
|
761
765
|
action: ActionContractSource,
|
|
762
766
|
): Record<string, boolean>;
|
|
763
767
|
|
|
768
|
+
declare function calculateDpopJkt(privateJwk: JsonWebKey): Promise<string>;
|
|
769
|
+
declare function createDpopProof(input: {
|
|
770
|
+
accessToken: string;
|
|
771
|
+
method: string;
|
|
772
|
+
targetUrl: string;
|
|
773
|
+
privateJwk: JsonWebKey;
|
|
774
|
+
}): Promise<string>;
|
|
775
|
+
|
|
764
776
|
/**
|
|
765
777
|
* Bootstrap seed URLs — the ONLY static service endpoints in the SDK.
|
|
766
778
|
*
|
|
@@ -984,6 +996,24 @@ declare class IdentityModule {
|
|
|
984
996
|
whoami(): Promise<CredentialIntrospection>;
|
|
985
997
|
}
|
|
986
998
|
|
|
999
|
+
declare const ACTOR_AUDIT_PROJECTION_VERSION: 1;
|
|
1000
|
+
type ActorAuditEventRole = 'requested_by' | 'acting_on_behalf_of' | 'approved_by' | 'executed_by';
|
|
1001
|
+
interface ActorAuditProjection {
|
|
1002
|
+
readonly schemaVersion: typeof ACTOR_AUDIT_PROJECTION_VERSION;
|
|
1003
|
+
readonly role: ActorAuditEventRole;
|
|
1004
|
+
readonly label: string;
|
|
1005
|
+
readonly organizationId: string;
|
|
1006
|
+
readonly accountableSubject: Readonly<AccountableSubject>;
|
|
1007
|
+
readonly performer: Readonly<ActorIdentity>;
|
|
1008
|
+
readonly delegation: Readonly<NonNullable<ActorEnvelope['delegation']>> | null;
|
|
1009
|
+
readonly channel: ActorEnvelope['channel'];
|
|
1010
|
+
readonly assurance: Readonly<ActorEnvelope['assurance']>;
|
|
1011
|
+
readonly action: Readonly<ActorEnvelope['action']>;
|
|
1012
|
+
readonly issuedAt: string;
|
|
1013
|
+
readonly expiresAt?: string;
|
|
1014
|
+
}
|
|
1015
|
+
declare function projectActorAuditEvent(value: unknown, role: ActorAuditEventRole): ActorAuditProjection;
|
|
1016
|
+
|
|
987
1017
|
interface TopoloWorkspace {
|
|
988
1018
|
id: string;
|
|
989
1019
|
appId: string;
|
|
@@ -1676,4 +1706,4 @@ declare function createTopolo(options: TopoloClientOptions): {
|
|
|
1676
1706
|
};
|
|
1677
1707
|
type Topolo = ReturnType<typeof createTopolo>;
|
|
1678
1708
|
|
|
1679
|
-
export { ACTION_CATALOG_DIGEST_ALGORITHM, ACTOR_ENVELOPE_VERSION, type AccountableSubject, type AccountableSubjectType, type ActionContractManifest, type ActionContractSource, type ActorAssurance, type ActorChannel, type ActorDelegationHop, type ActorEnvelope, ActorEnvelopeValidationError, type ActorIdentity, type ActorPrincipalType, type AgentIdentity, type AppApiId, type ApplicationCatalogEntry, type ApplicationDeployTarget, type ApplicationDirectory, type ApplicationDirectoryApplication, type ApplicationDirectoryClient, type ApplicationDirectorySource, type ApplicationId, type CredentialIntrospection, type CrmContactSummary, CrmModule, DEFAULT_APP_URLS, type DeviceAuthorizationResponse, IdentityModule, type ListContactsOptions, type ListContactsResult, type OAuthHelperOptions, type P2PActionDetail, type P2PActionRequestInput, type P2PActionRequestResult, type P2PActionRow, type P2PActionRun, type P2PCapability, type P2PConnection, type P2PHold, type P2PLedgerEntry, P2PModule, type P2PPolicy, type P2PPricingModel, type P2PSettlementBatch, type P2PSettlementGroup, type PublishCapabilityInput, type RequestOptions, type ServiceCatalogUrlEntry, TOPOLO_ACTOR_ENVELOPE_HEADER, TOPOLO_ENVIRONMENT_SERVICE_URLS, TOPOLO_RUNTIME_ENVIRONMENTS, TOPOLO_WIDGET_CONTRACT_VERSION, TOPOLO_WIDGET_ENDPOINT, TOPOLO_WIDGET_OUTPUT_SCHEMA, TOPOLO_WIDGET_REFRESH_INTERVAL_MS, type TokenResponse, type Topolo, type TopoloActionAgentContract, type TopoloActionCatalogEntry, type TopoloActionCatalogSummary, type TopoloActionDigestInput, type TopoloActionPlan, type TopoloActionPreparation, type TopoloActionUploadOptions, type TopoloActionValidationIssue, type TopoloActionValidationResult, type TopoloActionsWidget, type TopoloActivityWidget, type TopoloAgentExecutionContext, type TopoloApiKeyResourceMetadata, TopoloAuthError, type TopoloBinaryResponse, type TopoloBindableResource, type TopoloBindableResourceCatalog, type TopoloChartWidget, TopoloClient, type TopoloClientOptions, TopoloConfirmationRequiredError, type TopoloCredential, type TopoloDebugEvent, TopoloHttpError, type TopoloInlineBase64UploadContract, type TopoloJsonSchema, type TopoloNotificationsWidget, TopoloOAuth, TopoloPermissionError, type TopoloRuntimeEnvironment, TopoloSdkError, type TopoloServiceCatalogEntry, type TopoloStatsWidget, type TopoloWidget, type TopoloWidgetAccessibility, type TopoloWidgetActionBinding, type TopoloWidgetActionRecovery, type TopoloWidgetActivityItem, type TopoloWidgetApiError, type TopoloWidgetApiErrorResponse, type TopoloWidgetApiResponse, type TopoloWidgetApiSuccessResponse, type TopoloWidgetBase, type TopoloWidgetConfig, type TopoloWidgetConfiguration, type TopoloWidgetConfigurationField, type TopoloWidgetConfigurationOption, type TopoloWidgetContext, type TopoloWidgetContribution, type TopoloWidgetDatasetDefinition, type TopoloWidgetDimension, type TopoloWidgetDimensionDefinition, type TopoloWidgetDraft, type TopoloWidgetDrilldown, type TopoloWidgetErrorResponseOptions, type TopoloWidgetEventDefinition, type TopoloWidgetLifecycleStage, type TopoloWidgetLocalization, type TopoloWidgetMetric, type TopoloWidgetMetricAggregation, type TopoloWidgetMetricComparison, type TopoloWidgetMetricDefinition, type TopoloWidgetMetricSemantic, type TopoloWidgetNotificationItem, type TopoloWidgetPeriod, type TopoloWidgetPresentation, type TopoloWidgetRefreshPolicy, type TopoloWidgetResourceBinding, type TopoloWidgetResponseOptions, type TopoloWidgetSeries, type TopoloWidgetSeriesDefinition, type TopoloWidgetSeriesPoint, type TopoloWidgetSize, type TopoloWidgetState, type TopoloWidgetStatus, type TopoloWidgetType, type TopoloWidgetValidationResult, type TopoloWidgetVisualizationFamily, type TopoloWidgetWorkspaceSelector, type TopoloWorkspace, type TopoloWorkspaceListResult, type TopoloWorkspaceMutationResult, type TopoloWorkspacePolicy, WorkspacesModule, actionContractCompleteness, applicationEntryFromCatalog, assertTopoloServiceUrlEnvironment, canonicalJson, canonicalTopoloErrorCode, canonicalTopoloRequestId, canonicalTopoloRequired, canonicalTopoloRetryAfter, canonicalizeActorEnvelope, compactActionCatalogEntry, compactActionPlan, compactActionPreparation, compactActionResult, compactActionValidation, createTopolo, createTopoloAgentExecutionContext, createTopoloWidgetError, createTopoloWidgetResponse, decodeActorEnvelopeHeader, defineTopoloActionsWidget, defineTopoloActivityWidget, defineTopoloChartWidget, defineTopoloNotificationsWidget, defineTopoloStatsWidget, digestTopoloActionCatalog, encodeActorEnvelopeHeader, encodeTopoloActionBase64, enrichActionContract, extractTopoloServiceErrorCode, extractTopoloServiceErrorDetails, formatDirectoryApplicationIds, friendlyAppId, isTopoloWidgetOutputSchema, listApplicationDirectory, parseActorEnvelope, parseTopoloActionUploadContract, preferExactActionMatches, prepareTopoloActionBase64UploadInput, prepareTopoloActionUploadInput, publicTopoloErrorMessage, resolveApplicationDirectoryEntry, resolveCatalogServiceUrl, resolveServiceUrl, sha256CanonicalValue, topoloErrorHint, topoloServiceOrigins, validateTopoloActionInput, validateTopoloWidgetResponse };
|
|
1709
|
+
export { ACTION_CATALOG_DIGEST_ALGORITHM, ACTOR_AUDIT_PROJECTION_VERSION, ACTOR_ENVELOPE_VERSION, type AccountableSubject, type AccountableSubjectType, type ActionContractManifest, type ActionContractSource, type ActorAssurance, type ActorAuditEventRole, type ActorAuditProjection, type ActorChannel, type ActorDelegationHop, type ActorEnvelope, ActorEnvelopeValidationError, type ActorIdentity, type ActorPrincipalType, type AgentIdentity, type AppApiId, type ApplicationCatalogEntry, type ApplicationDeployTarget, type ApplicationDirectory, type ApplicationDirectoryApplication, type ApplicationDirectoryClient, type ApplicationDirectorySource, type ApplicationId, type CredentialIntrospection, type CrmContactSummary, CrmModule, DEFAULT_APP_URLS, type DeviceAuthorizationResponse, IdentityModule, type ListContactsOptions, type ListContactsResult, type OAuthHelperOptions, type P2PActionDetail, type P2PActionRequestInput, type P2PActionRequestResult, type P2PActionRow, type P2PActionRun, type P2PCapability, type P2PConnection, type P2PHold, type P2PLedgerEntry, P2PModule, type P2PPolicy, type P2PPricingModel, type P2PSettlementBatch, type P2PSettlementGroup, type PublishCapabilityInput, type RequestOptions, type ServiceCatalogUrlEntry, TOPOLO_ACTOR_ENVELOPE_HEADER, TOPOLO_ENVIRONMENT_SERVICE_URLS, TOPOLO_RUNTIME_ENVIRONMENTS, TOPOLO_WIDGET_CONTRACT_VERSION, TOPOLO_WIDGET_ENDPOINT, TOPOLO_WIDGET_OUTPUT_SCHEMA, TOPOLO_WIDGET_REFRESH_INTERVAL_MS, type TokenResponse, type Topolo, type TopoloActionAgentContract, type TopoloActionCatalogEntry, type TopoloActionCatalogSummary, type TopoloActionDigestInput, type TopoloActionPlan, type TopoloActionPreparation, type TopoloActionUploadOptions, type TopoloActionValidationIssue, type TopoloActionValidationResult, type TopoloActionsWidget, type TopoloActivityWidget, type TopoloAgentExecutionContext, type TopoloApiKeyResourceMetadata, TopoloAuthError, type TopoloBinaryResponse, type TopoloBindableResource, type TopoloBindableResourceCatalog, type TopoloChartWidget, TopoloClient, type TopoloClientOptions, TopoloConfirmationRequiredError, type TopoloCredential, type TopoloDebugEvent, TopoloHttpError, type TopoloInlineBase64UploadContract, type TopoloJsonSchema, type TopoloNotificationsWidget, TopoloOAuth, TopoloPermissionError, type TopoloRuntimeEnvironment, TopoloSdkError, type TopoloServiceCatalogEntry, type TopoloStatsWidget, type TopoloWidget, type TopoloWidgetAccessibility, type TopoloWidgetActionBinding, type TopoloWidgetActionRecovery, type TopoloWidgetActivityItem, type TopoloWidgetApiError, type TopoloWidgetApiErrorResponse, type TopoloWidgetApiResponse, type TopoloWidgetApiSuccessResponse, type TopoloWidgetBase, type TopoloWidgetConfig, type TopoloWidgetConfiguration, type TopoloWidgetConfigurationField, type TopoloWidgetConfigurationOption, type TopoloWidgetContext, type TopoloWidgetContribution, type TopoloWidgetDatasetDefinition, type TopoloWidgetDimension, type TopoloWidgetDimensionDefinition, type TopoloWidgetDraft, type TopoloWidgetDrilldown, type TopoloWidgetErrorResponseOptions, type TopoloWidgetEventDefinition, type TopoloWidgetLifecycleStage, type TopoloWidgetLocalization, type TopoloWidgetMetric, type TopoloWidgetMetricAggregation, type TopoloWidgetMetricComparison, type TopoloWidgetMetricDefinition, type TopoloWidgetMetricSemantic, type TopoloWidgetNotificationItem, type TopoloWidgetPeriod, type TopoloWidgetPresentation, type TopoloWidgetRefreshPolicy, type TopoloWidgetResourceBinding, type TopoloWidgetResponseOptions, type TopoloWidgetSeries, type TopoloWidgetSeriesDefinition, type TopoloWidgetSeriesPoint, type TopoloWidgetSize, type TopoloWidgetState, type TopoloWidgetStatus, type TopoloWidgetType, type TopoloWidgetValidationResult, type TopoloWidgetVisualizationFamily, type TopoloWidgetWorkspaceSelector, type TopoloWorkspace, type TopoloWorkspaceListResult, type TopoloWorkspaceMutationResult, type TopoloWorkspacePolicy, WorkspacesModule, actionContractCompleteness, applicationEntryFromCatalog, assertTopoloServiceUrlEnvironment, calculateDpopJkt, canonicalJson, canonicalTopoloErrorCode, canonicalTopoloRequestId, canonicalTopoloRequired, canonicalTopoloRetryAfter, canonicalizeActorEnvelope, compactActionCatalogEntry, compactActionPlan, compactActionPreparation, compactActionResult, compactActionValidation, createDpopProof, createTopolo, createTopoloAgentExecutionContext, createTopoloWidgetError, createTopoloWidgetResponse, decodeActorEnvelopeHeader, defineTopoloActionsWidget, defineTopoloActivityWidget, defineTopoloChartWidget, defineTopoloNotificationsWidget, defineTopoloStatsWidget, digestTopoloActionCatalog, encodeActorEnvelopeHeader, encodeTopoloActionBase64, enrichActionContract, extractTopoloServiceErrorCode, extractTopoloServiceErrorDetails, formatDirectoryApplicationIds, friendlyAppId, isTopoloWidgetOutputSchema, listApplicationDirectory, parseActorEnvelope, parseTopoloActionUploadContract, preferExactActionMatches, prepareTopoloActionBase64UploadInput, prepareTopoloActionUploadInput, projectActorAuditEvent, publicTopoloErrorMessage, resolveApplicationDirectoryEntry, resolveCatalogServiceUrl, resolveServiceUrl, sha256CanonicalValue, topoloErrorHint, topoloServiceOrigins, validateTopoloActionInput, validateTopoloWidgetResponse };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Auth credential types used by the SDK.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Supported modes:
|
|
5
5
|
* - `api_key`: a single platform API key (service-scoped at issuance).
|
|
6
|
-
*
|
|
6
|
+
* Used for service integrations that are not installation-bound.
|
|
7
7
|
* - `access_token`: a short-lived JWT from the interactive login flow.
|
|
8
8
|
* Used by TopoloCli after `topolo auth login`.
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* PKCE flow in TopoloAuth. Those will plug in as a third variant.
|
|
9
|
+
* - `dpop_access_token`: a short-lived delegated token bound to an external
|
|
10
|
+
* agent installation key. Every request proves possession of that key.
|
|
12
11
|
*/
|
|
13
12
|
type TopoloCredential = {
|
|
14
13
|
kind: 'api_key';
|
|
@@ -18,6 +17,11 @@ type TopoloCredential = {
|
|
|
18
17
|
accessToken: string;
|
|
19
18
|
refreshToken?: string;
|
|
20
19
|
expiresAt?: number;
|
|
20
|
+
} | {
|
|
21
|
+
kind: 'dpop_access_token';
|
|
22
|
+
accessToken: string;
|
|
23
|
+
privateJwk: JsonWebKey;
|
|
24
|
+
expiresAt?: number;
|
|
21
25
|
};
|
|
22
26
|
interface AgentIdentity {
|
|
23
27
|
/** Display name of the agent or tool making requests. Included in audit headers. */
|
|
@@ -761,6 +765,14 @@ declare function actionContractCompleteness(
|
|
|
761
765
|
action: ActionContractSource,
|
|
762
766
|
): Record<string, boolean>;
|
|
763
767
|
|
|
768
|
+
declare function calculateDpopJkt(privateJwk: JsonWebKey): Promise<string>;
|
|
769
|
+
declare function createDpopProof(input: {
|
|
770
|
+
accessToken: string;
|
|
771
|
+
method: string;
|
|
772
|
+
targetUrl: string;
|
|
773
|
+
privateJwk: JsonWebKey;
|
|
774
|
+
}): Promise<string>;
|
|
775
|
+
|
|
764
776
|
/**
|
|
765
777
|
* Bootstrap seed URLs — the ONLY static service endpoints in the SDK.
|
|
766
778
|
*
|
|
@@ -984,6 +996,24 @@ declare class IdentityModule {
|
|
|
984
996
|
whoami(): Promise<CredentialIntrospection>;
|
|
985
997
|
}
|
|
986
998
|
|
|
999
|
+
declare const ACTOR_AUDIT_PROJECTION_VERSION: 1;
|
|
1000
|
+
type ActorAuditEventRole = 'requested_by' | 'acting_on_behalf_of' | 'approved_by' | 'executed_by';
|
|
1001
|
+
interface ActorAuditProjection {
|
|
1002
|
+
readonly schemaVersion: typeof ACTOR_AUDIT_PROJECTION_VERSION;
|
|
1003
|
+
readonly role: ActorAuditEventRole;
|
|
1004
|
+
readonly label: string;
|
|
1005
|
+
readonly organizationId: string;
|
|
1006
|
+
readonly accountableSubject: Readonly<AccountableSubject>;
|
|
1007
|
+
readonly performer: Readonly<ActorIdentity>;
|
|
1008
|
+
readonly delegation: Readonly<NonNullable<ActorEnvelope['delegation']>> | null;
|
|
1009
|
+
readonly channel: ActorEnvelope['channel'];
|
|
1010
|
+
readonly assurance: Readonly<ActorEnvelope['assurance']>;
|
|
1011
|
+
readonly action: Readonly<ActorEnvelope['action']>;
|
|
1012
|
+
readonly issuedAt: string;
|
|
1013
|
+
readonly expiresAt?: string;
|
|
1014
|
+
}
|
|
1015
|
+
declare function projectActorAuditEvent(value: unknown, role: ActorAuditEventRole): ActorAuditProjection;
|
|
1016
|
+
|
|
987
1017
|
interface TopoloWorkspace {
|
|
988
1018
|
id: string;
|
|
989
1019
|
appId: string;
|
|
@@ -1676,4 +1706,4 @@ declare function createTopolo(options: TopoloClientOptions): {
|
|
|
1676
1706
|
};
|
|
1677
1707
|
type Topolo = ReturnType<typeof createTopolo>;
|
|
1678
1708
|
|
|
1679
|
-
export { ACTION_CATALOG_DIGEST_ALGORITHM, ACTOR_ENVELOPE_VERSION, type AccountableSubject, type AccountableSubjectType, type ActionContractManifest, type ActionContractSource, type ActorAssurance, type ActorChannel, type ActorDelegationHop, type ActorEnvelope, ActorEnvelopeValidationError, type ActorIdentity, type ActorPrincipalType, type AgentIdentity, type AppApiId, type ApplicationCatalogEntry, type ApplicationDeployTarget, type ApplicationDirectory, type ApplicationDirectoryApplication, type ApplicationDirectoryClient, type ApplicationDirectorySource, type ApplicationId, type CredentialIntrospection, type CrmContactSummary, CrmModule, DEFAULT_APP_URLS, type DeviceAuthorizationResponse, IdentityModule, type ListContactsOptions, type ListContactsResult, type OAuthHelperOptions, type P2PActionDetail, type P2PActionRequestInput, type P2PActionRequestResult, type P2PActionRow, type P2PActionRun, type P2PCapability, type P2PConnection, type P2PHold, type P2PLedgerEntry, P2PModule, type P2PPolicy, type P2PPricingModel, type P2PSettlementBatch, type P2PSettlementGroup, type PublishCapabilityInput, type RequestOptions, type ServiceCatalogUrlEntry, TOPOLO_ACTOR_ENVELOPE_HEADER, TOPOLO_ENVIRONMENT_SERVICE_URLS, TOPOLO_RUNTIME_ENVIRONMENTS, TOPOLO_WIDGET_CONTRACT_VERSION, TOPOLO_WIDGET_ENDPOINT, TOPOLO_WIDGET_OUTPUT_SCHEMA, TOPOLO_WIDGET_REFRESH_INTERVAL_MS, type TokenResponse, type Topolo, type TopoloActionAgentContract, type TopoloActionCatalogEntry, type TopoloActionCatalogSummary, type TopoloActionDigestInput, type TopoloActionPlan, type TopoloActionPreparation, type TopoloActionUploadOptions, type TopoloActionValidationIssue, type TopoloActionValidationResult, type TopoloActionsWidget, type TopoloActivityWidget, type TopoloAgentExecutionContext, type TopoloApiKeyResourceMetadata, TopoloAuthError, type TopoloBinaryResponse, type TopoloBindableResource, type TopoloBindableResourceCatalog, type TopoloChartWidget, TopoloClient, type TopoloClientOptions, TopoloConfirmationRequiredError, type TopoloCredential, type TopoloDebugEvent, TopoloHttpError, type TopoloInlineBase64UploadContract, type TopoloJsonSchema, type TopoloNotificationsWidget, TopoloOAuth, TopoloPermissionError, type TopoloRuntimeEnvironment, TopoloSdkError, type TopoloServiceCatalogEntry, type TopoloStatsWidget, type TopoloWidget, type TopoloWidgetAccessibility, type TopoloWidgetActionBinding, type TopoloWidgetActionRecovery, type TopoloWidgetActivityItem, type TopoloWidgetApiError, type TopoloWidgetApiErrorResponse, type TopoloWidgetApiResponse, type TopoloWidgetApiSuccessResponse, type TopoloWidgetBase, type TopoloWidgetConfig, type TopoloWidgetConfiguration, type TopoloWidgetConfigurationField, type TopoloWidgetConfigurationOption, type TopoloWidgetContext, type TopoloWidgetContribution, type TopoloWidgetDatasetDefinition, type TopoloWidgetDimension, type TopoloWidgetDimensionDefinition, type TopoloWidgetDraft, type TopoloWidgetDrilldown, type TopoloWidgetErrorResponseOptions, type TopoloWidgetEventDefinition, type TopoloWidgetLifecycleStage, type TopoloWidgetLocalization, type TopoloWidgetMetric, type TopoloWidgetMetricAggregation, type TopoloWidgetMetricComparison, type TopoloWidgetMetricDefinition, type TopoloWidgetMetricSemantic, type TopoloWidgetNotificationItem, type TopoloWidgetPeriod, type TopoloWidgetPresentation, type TopoloWidgetRefreshPolicy, type TopoloWidgetResourceBinding, type TopoloWidgetResponseOptions, type TopoloWidgetSeries, type TopoloWidgetSeriesDefinition, type TopoloWidgetSeriesPoint, type TopoloWidgetSize, type TopoloWidgetState, type TopoloWidgetStatus, type TopoloWidgetType, type TopoloWidgetValidationResult, type TopoloWidgetVisualizationFamily, type TopoloWidgetWorkspaceSelector, type TopoloWorkspace, type TopoloWorkspaceListResult, type TopoloWorkspaceMutationResult, type TopoloWorkspacePolicy, WorkspacesModule, actionContractCompleteness, applicationEntryFromCatalog, assertTopoloServiceUrlEnvironment, canonicalJson, canonicalTopoloErrorCode, canonicalTopoloRequestId, canonicalTopoloRequired, canonicalTopoloRetryAfter, canonicalizeActorEnvelope, compactActionCatalogEntry, compactActionPlan, compactActionPreparation, compactActionResult, compactActionValidation, createTopolo, createTopoloAgentExecutionContext, createTopoloWidgetError, createTopoloWidgetResponse, decodeActorEnvelopeHeader, defineTopoloActionsWidget, defineTopoloActivityWidget, defineTopoloChartWidget, defineTopoloNotificationsWidget, defineTopoloStatsWidget, digestTopoloActionCatalog, encodeActorEnvelopeHeader, encodeTopoloActionBase64, enrichActionContract, extractTopoloServiceErrorCode, extractTopoloServiceErrorDetails, formatDirectoryApplicationIds, friendlyAppId, isTopoloWidgetOutputSchema, listApplicationDirectory, parseActorEnvelope, parseTopoloActionUploadContract, preferExactActionMatches, prepareTopoloActionBase64UploadInput, prepareTopoloActionUploadInput, publicTopoloErrorMessage, resolveApplicationDirectoryEntry, resolveCatalogServiceUrl, resolveServiceUrl, sha256CanonicalValue, topoloErrorHint, topoloServiceOrigins, validateTopoloActionInput, validateTopoloWidgetResponse };
|
|
1709
|
+
export { ACTION_CATALOG_DIGEST_ALGORITHM, ACTOR_AUDIT_PROJECTION_VERSION, ACTOR_ENVELOPE_VERSION, type AccountableSubject, type AccountableSubjectType, type ActionContractManifest, type ActionContractSource, type ActorAssurance, type ActorAuditEventRole, type ActorAuditProjection, type ActorChannel, type ActorDelegationHop, type ActorEnvelope, ActorEnvelopeValidationError, type ActorIdentity, type ActorPrincipalType, type AgentIdentity, type AppApiId, type ApplicationCatalogEntry, type ApplicationDeployTarget, type ApplicationDirectory, type ApplicationDirectoryApplication, type ApplicationDirectoryClient, type ApplicationDirectorySource, type ApplicationId, type CredentialIntrospection, type CrmContactSummary, CrmModule, DEFAULT_APP_URLS, type DeviceAuthorizationResponse, IdentityModule, type ListContactsOptions, type ListContactsResult, type OAuthHelperOptions, type P2PActionDetail, type P2PActionRequestInput, type P2PActionRequestResult, type P2PActionRow, type P2PActionRun, type P2PCapability, type P2PConnection, type P2PHold, type P2PLedgerEntry, P2PModule, type P2PPolicy, type P2PPricingModel, type P2PSettlementBatch, type P2PSettlementGroup, type PublishCapabilityInput, type RequestOptions, type ServiceCatalogUrlEntry, TOPOLO_ACTOR_ENVELOPE_HEADER, TOPOLO_ENVIRONMENT_SERVICE_URLS, TOPOLO_RUNTIME_ENVIRONMENTS, TOPOLO_WIDGET_CONTRACT_VERSION, TOPOLO_WIDGET_ENDPOINT, TOPOLO_WIDGET_OUTPUT_SCHEMA, TOPOLO_WIDGET_REFRESH_INTERVAL_MS, type TokenResponse, type Topolo, type TopoloActionAgentContract, type TopoloActionCatalogEntry, type TopoloActionCatalogSummary, type TopoloActionDigestInput, type TopoloActionPlan, type TopoloActionPreparation, type TopoloActionUploadOptions, type TopoloActionValidationIssue, type TopoloActionValidationResult, type TopoloActionsWidget, type TopoloActivityWidget, type TopoloAgentExecutionContext, type TopoloApiKeyResourceMetadata, TopoloAuthError, type TopoloBinaryResponse, type TopoloBindableResource, type TopoloBindableResourceCatalog, type TopoloChartWidget, TopoloClient, type TopoloClientOptions, TopoloConfirmationRequiredError, type TopoloCredential, type TopoloDebugEvent, TopoloHttpError, type TopoloInlineBase64UploadContract, type TopoloJsonSchema, type TopoloNotificationsWidget, TopoloOAuth, TopoloPermissionError, type TopoloRuntimeEnvironment, TopoloSdkError, type TopoloServiceCatalogEntry, type TopoloStatsWidget, type TopoloWidget, type TopoloWidgetAccessibility, type TopoloWidgetActionBinding, type TopoloWidgetActionRecovery, type TopoloWidgetActivityItem, type TopoloWidgetApiError, type TopoloWidgetApiErrorResponse, type TopoloWidgetApiResponse, type TopoloWidgetApiSuccessResponse, type TopoloWidgetBase, type TopoloWidgetConfig, type TopoloWidgetConfiguration, type TopoloWidgetConfigurationField, type TopoloWidgetConfigurationOption, type TopoloWidgetContext, type TopoloWidgetContribution, type TopoloWidgetDatasetDefinition, type TopoloWidgetDimension, type TopoloWidgetDimensionDefinition, type TopoloWidgetDraft, type TopoloWidgetDrilldown, type TopoloWidgetErrorResponseOptions, type TopoloWidgetEventDefinition, type TopoloWidgetLifecycleStage, type TopoloWidgetLocalization, type TopoloWidgetMetric, type TopoloWidgetMetricAggregation, type TopoloWidgetMetricComparison, type TopoloWidgetMetricDefinition, type TopoloWidgetMetricSemantic, type TopoloWidgetNotificationItem, type TopoloWidgetPeriod, type TopoloWidgetPresentation, type TopoloWidgetRefreshPolicy, type TopoloWidgetResourceBinding, type TopoloWidgetResponseOptions, type TopoloWidgetSeries, type TopoloWidgetSeriesDefinition, type TopoloWidgetSeriesPoint, type TopoloWidgetSize, type TopoloWidgetState, type TopoloWidgetStatus, type TopoloWidgetType, type TopoloWidgetValidationResult, type TopoloWidgetVisualizationFamily, type TopoloWidgetWorkspaceSelector, type TopoloWorkspace, type TopoloWorkspaceListResult, type TopoloWorkspaceMutationResult, type TopoloWorkspacePolicy, WorkspacesModule, actionContractCompleteness, applicationEntryFromCatalog, assertTopoloServiceUrlEnvironment, calculateDpopJkt, canonicalJson, canonicalTopoloErrorCode, canonicalTopoloRequestId, canonicalTopoloRequired, canonicalTopoloRetryAfter, canonicalizeActorEnvelope, compactActionCatalogEntry, compactActionPlan, compactActionPreparation, compactActionResult, compactActionValidation, createDpopProof, createTopolo, createTopoloAgentExecutionContext, createTopoloWidgetError, createTopoloWidgetResponse, decodeActorEnvelopeHeader, defineTopoloActionsWidget, defineTopoloActivityWidget, defineTopoloChartWidget, defineTopoloNotificationsWidget, defineTopoloStatsWidget, digestTopoloActionCatalog, encodeActorEnvelopeHeader, encodeTopoloActionBase64, enrichActionContract, extractTopoloServiceErrorCode, extractTopoloServiceErrorDetails, formatDirectoryApplicationIds, friendlyAppId, isTopoloWidgetOutputSchema, listApplicationDirectory, parseActorEnvelope, parseTopoloActionUploadContract, preferExactActionMatches, prepareTopoloActionBase64UploadInput, prepareTopoloActionUploadInput, projectActorAuditEvent, publicTopoloErrorMessage, resolveApplicationDirectoryEntry, resolveCatalogServiceUrl, resolveServiceUrl, sha256CanonicalValue, topoloErrorHint, topoloServiceOrigins, validateTopoloActionInput, validateTopoloWidgetResponse };
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ function applyAuthHeaders(headers, credential) {
|
|
|
4
4
|
headers.set("X-Api-Key", credential.apiKey);
|
|
5
5
|
return;
|
|
6
6
|
}
|
|
7
|
-
headers.set("Authorization",
|
|
7
|
+
headers.set("Authorization", `${credential.kind === "dpop_access_token" ? "DPoP" : "Bearer"} ${credential.accessToken}`);
|
|
8
8
|
}
|
|
9
9
|
function applyAuditHeaders(headers, agent, requestId) {
|
|
10
10
|
headers.set("X-Topolo-Client", `${agent.clientName}/${agent.clientVersion}`);
|
|
@@ -18,6 +18,60 @@ function generateRequestId() {
|
|
|
18
18
|
return `req_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 10)}`;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
// src/dpop.ts
|
|
22
|
+
var encoder = new TextEncoder();
|
|
23
|
+
function encodeBase64Url(value) {
|
|
24
|
+
const bytes = value instanceof Uint8Array ? value : new Uint8Array(value);
|
|
25
|
+
let binary = "";
|
|
26
|
+
for (const byte of bytes) binary += String.fromCharCode(byte);
|
|
27
|
+
return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, "");
|
|
28
|
+
}
|
|
29
|
+
function encodeJson(value) {
|
|
30
|
+
return encodeBase64Url(encoder.encode(JSON.stringify(value)));
|
|
31
|
+
}
|
|
32
|
+
async function sha256Base64Url(value) {
|
|
33
|
+
return encodeBase64Url(await crypto.subtle.digest("SHA-256", encoder.encode(value)));
|
|
34
|
+
}
|
|
35
|
+
function publicJwk(privateJwk) {
|
|
36
|
+
const { crv, kty, x, y } = privateJwk;
|
|
37
|
+
if (kty !== "EC" || crv !== "P-256" || !x || !y || !privateJwk.d) {
|
|
38
|
+
throw new TypeError("A private P-256 JSON Web Key is required for DPoP signing.");
|
|
39
|
+
}
|
|
40
|
+
return { crv, kty, x, y };
|
|
41
|
+
}
|
|
42
|
+
function canonicalTargetUrl(value) {
|
|
43
|
+
const url = new URL(value);
|
|
44
|
+
return `${url.origin}${url.pathname}`;
|
|
45
|
+
}
|
|
46
|
+
async function calculateDpopJkt(privateJwk) {
|
|
47
|
+
const jwk = publicJwk(privateJwk);
|
|
48
|
+
return sha256Base64Url(JSON.stringify({ crv: jwk.crv, kty: jwk.kty, x: jwk.x, y: jwk.y }));
|
|
49
|
+
}
|
|
50
|
+
async function createDpopProof(input) {
|
|
51
|
+
const jwk = publicJwk(input.privateJwk);
|
|
52
|
+
const key = await crypto.subtle.importKey(
|
|
53
|
+
"jwk",
|
|
54
|
+
input.privateJwk,
|
|
55
|
+
{ name: "ECDSA", namedCurve: "P-256" },
|
|
56
|
+
false,
|
|
57
|
+
["sign"]
|
|
58
|
+
);
|
|
59
|
+
const header = encodeJson({ alg: "ES256", typ: "dpop+jwt", jwk });
|
|
60
|
+
const claims = encodeJson({
|
|
61
|
+
jti: crypto.randomUUID(),
|
|
62
|
+
iat: Math.floor(Date.now() / 1e3),
|
|
63
|
+
htm: input.method.toUpperCase(),
|
|
64
|
+
htu: canonicalTargetUrl(input.targetUrl),
|
|
65
|
+
ath: await sha256Base64Url(input.accessToken)
|
|
66
|
+
});
|
|
67
|
+
const signature = await crypto.subtle.sign(
|
|
68
|
+
{ name: "ECDSA", hash: "SHA-256" },
|
|
69
|
+
key,
|
|
70
|
+
encoder.encode(`${header}.${claims}`)
|
|
71
|
+
);
|
|
72
|
+
return `${header}.${claims}.${encodeBase64Url(signature)}`;
|
|
73
|
+
}
|
|
74
|
+
|
|
21
75
|
// src/errors.ts
|
|
22
76
|
var TopoloSdkError = class extends Error {
|
|
23
77
|
code;
|
|
@@ -1374,7 +1428,6 @@ var TopoloClient = class _TopoloClient {
|
|
|
1374
1428
|
if (opts.body !== void 0) headers.set("Content-Type", "application/json");
|
|
1375
1429
|
const platformAppId = resolveConfiguredAppId(resolvedService.serviceKey, this.appIds);
|
|
1376
1430
|
if (platformAppId) headers.set("X-App-ID", platformAppId);
|
|
1377
|
-
applyAuthHeaders(headers, this.credential);
|
|
1378
1431
|
const actorEnvelope = opts.actorEnvelope === void 0 ? void 0 : parseActorEnvelope(opts.actorEnvelope);
|
|
1379
1432
|
const requestId = actorEnvelope?.action.requestId ?? generateRequestId();
|
|
1380
1433
|
applyAuditHeaders(headers, this.agent, requestId);
|
|
@@ -1408,9 +1461,19 @@ var TopoloClient = class _TopoloClient {
|
|
|
1408
1461
|
}, this.timeoutMs);
|
|
1409
1462
|
const signal = opts.signal ? mergeSignals(opts.signal, controller.signal) : controller.signal;
|
|
1410
1463
|
try {
|
|
1464
|
+
const requestHeaders = new Headers(headers);
|
|
1465
|
+
applyAuthHeaders(requestHeaders, this.credential);
|
|
1466
|
+
if (this.credential.kind === "dpop_access_token") {
|
|
1467
|
+
requestHeaders.set("DPoP", await createDpopProof({
|
|
1468
|
+
accessToken: this.credential.accessToken,
|
|
1469
|
+
method,
|
|
1470
|
+
targetUrl: urlStr,
|
|
1471
|
+
privateJwk: this.credential.privateJwk
|
|
1472
|
+
}));
|
|
1473
|
+
}
|
|
1411
1474
|
return await this.fetchImpl(urlStr, {
|
|
1412
1475
|
method,
|
|
1413
|
-
headers:
|
|
1476
|
+
headers: requestHeaders,
|
|
1414
1477
|
body: opts.rawBody ?? (opts.body !== void 0 ? JSON.stringify(opts.body) : null),
|
|
1415
1478
|
signal
|
|
1416
1479
|
});
|
|
@@ -1447,7 +1510,6 @@ var TopoloClient = class _TopoloClient {
|
|
|
1447
1510
|
await res.body?.cancel().catch(() => void 0);
|
|
1448
1511
|
const refreshed = await this.refreshRejectedAccessToken(attemptedCredential.accessToken);
|
|
1449
1512
|
if (refreshed) {
|
|
1450
|
-
applyAuthHeaders(headers, refreshed);
|
|
1451
1513
|
res = await fetchWithReadRetry();
|
|
1452
1514
|
}
|
|
1453
1515
|
}
|
|
@@ -3249,6 +3311,43 @@ var IdentityModule = class {
|
|
|
3249
3311
|
}
|
|
3250
3312
|
};
|
|
3251
3313
|
|
|
3314
|
+
// src/actor-audit.ts
|
|
3315
|
+
var ACTOR_AUDIT_PROJECTION_VERSION = 1;
|
|
3316
|
+
var EVENT_ROLES = /* @__PURE__ */ new Set([
|
|
3317
|
+
"requested_by",
|
|
3318
|
+
"acting_on_behalf_of",
|
|
3319
|
+
"approved_by",
|
|
3320
|
+
"executed_by"
|
|
3321
|
+
]);
|
|
3322
|
+
function projectActorAuditEvent(value, role) {
|
|
3323
|
+
if (!EVENT_ROLES.has(role)) throw new TypeError("Unsupported actor audit event role");
|
|
3324
|
+
const envelope = parseActorEnvelope(value);
|
|
3325
|
+
const subjectLabel = envelope.accountableSubject.displayName || envelope.accountableSubject.principalId;
|
|
3326
|
+
const performerLabel = envelope.performer.displayName || envelope.performer.model || envelope.performer.provider || envelope.performer.principalId;
|
|
3327
|
+
const direct = envelope.performer.principalType === envelope.accountableSubject.principalType && envelope.performer.principalId === envelope.accountableSubject.principalId;
|
|
3328
|
+
return deepFreeze({
|
|
3329
|
+
schemaVersion: ACTOR_AUDIT_PROJECTION_VERSION,
|
|
3330
|
+
role,
|
|
3331
|
+
label: direct ? subjectLabel : `${subjectLabel} via ${performerLabel}`,
|
|
3332
|
+
organizationId: envelope.organizationId,
|
|
3333
|
+
accountableSubject: envelope.accountableSubject,
|
|
3334
|
+
performer: envelope.performer,
|
|
3335
|
+
delegation: envelope.delegation,
|
|
3336
|
+
channel: envelope.channel,
|
|
3337
|
+
assurance: envelope.assurance,
|
|
3338
|
+
action: envelope.action,
|
|
3339
|
+
issuedAt: envelope.issuedAt,
|
|
3340
|
+
...envelope.expiresAt ? { expiresAt: envelope.expiresAt } : {}
|
|
3341
|
+
});
|
|
3342
|
+
}
|
|
3343
|
+
function deepFreeze(value) {
|
|
3344
|
+
if (value && typeof value === "object" && !Object.isFrozen(value)) {
|
|
3345
|
+
Object.freeze(value);
|
|
3346
|
+
for (const nested of Object.values(value)) deepFreeze(nested);
|
|
3347
|
+
}
|
|
3348
|
+
return value;
|
|
3349
|
+
}
|
|
3350
|
+
|
|
3252
3351
|
// src/modules/workspaces.ts
|
|
3253
3352
|
var ACTIONS = {
|
|
3254
3353
|
list: "app_topolo_auth.workspaces.list",
|
|
@@ -4739,6 +4838,7 @@ function createTopolo(options) {
|
|
|
4739
4838
|
}
|
|
4740
4839
|
export {
|
|
4741
4840
|
ACTION_CATALOG_DIGEST_ALGORITHM,
|
|
4841
|
+
ACTOR_AUDIT_PROJECTION_VERSION,
|
|
4742
4842
|
ACTOR_ENVELOPE_VERSION,
|
|
4743
4843
|
ActorEnvelopeValidationError,
|
|
4744
4844
|
CrmModule,
|
|
@@ -4763,6 +4863,7 @@ export {
|
|
|
4763
4863
|
actionContractCompleteness,
|
|
4764
4864
|
applicationEntryFromCatalog,
|
|
4765
4865
|
assertTopoloServiceUrlEnvironment,
|
|
4866
|
+
calculateDpopJkt,
|
|
4766
4867
|
canonicalJson,
|
|
4767
4868
|
canonicalTopoloErrorCode,
|
|
4768
4869
|
canonicalTopoloRequestId,
|
|
@@ -4774,6 +4875,7 @@ export {
|
|
|
4774
4875
|
compactActionPreparation,
|
|
4775
4876
|
compactActionResult,
|
|
4776
4877
|
compactActionValidation,
|
|
4878
|
+
createDpopProof,
|
|
4777
4879
|
createTopolo,
|
|
4778
4880
|
createTopoloAgentExecutionContext,
|
|
4779
4881
|
createTopoloWidgetError,
|
|
@@ -4799,6 +4901,7 @@ export {
|
|
|
4799
4901
|
preferExactActionMatches,
|
|
4800
4902
|
prepareTopoloActionBase64UploadInput,
|
|
4801
4903
|
prepareTopoloActionUploadInput,
|
|
4904
|
+
projectActorAuditEvent,
|
|
4802
4905
|
publicTopoloErrorMessage,
|
|
4803
4906
|
resolveApplicationDirectoryEntry,
|
|
4804
4907
|
resolveCatalogServiceUrl,
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Auth credential types used by the SDK.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Supported modes:
|
|
5
5
|
* - `api_key`: a single platform API key (service-scoped at issuance).
|
|
6
|
-
*
|
|
6
|
+
* Used for service integrations that are not installation-bound.
|
|
7
7
|
* - `access_token`: a short-lived JWT from the interactive login flow.
|
|
8
8
|
* Used by TopoloCli after `topolo auth login`.
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* PKCE flow in TopoloAuth. Those will plug in as a third variant.
|
|
9
|
+
* - `dpop_access_token`: a short-lived delegated token bound to an external
|
|
10
|
+
* agent installation key. Every request proves possession of that key.
|
|
12
11
|
*/
|
|
13
12
|
type TopoloCredential = {
|
|
14
13
|
kind: 'api_key';
|
|
@@ -18,6 +17,11 @@ type TopoloCredential = {
|
|
|
18
17
|
accessToken: string;
|
|
19
18
|
refreshToken?: string;
|
|
20
19
|
expiresAt?: number;
|
|
20
|
+
} | {
|
|
21
|
+
kind: 'dpop_access_token';
|
|
22
|
+
accessToken: string;
|
|
23
|
+
privateJwk: JsonWebKey;
|
|
24
|
+
expiresAt?: number;
|
|
21
25
|
};
|
|
22
26
|
|
|
23
27
|
declare const TOPOLO_RUNTIME_ENVIRONMENTS: readonly ["production", "staging", "development", "local"];
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Auth credential types used by the SDK.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Supported modes:
|
|
5
5
|
* - `api_key`: a single platform API key (service-scoped at issuance).
|
|
6
|
-
*
|
|
6
|
+
* Used for service integrations that are not installation-bound.
|
|
7
7
|
* - `access_token`: a short-lived JWT from the interactive login flow.
|
|
8
8
|
* Used by TopoloCli after `topolo auth login`.
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* PKCE flow in TopoloAuth. Those will plug in as a third variant.
|
|
9
|
+
* - `dpop_access_token`: a short-lived delegated token bound to an external
|
|
10
|
+
* agent installation key. Every request proves possession of that key.
|
|
12
11
|
*/
|
|
13
12
|
type TopoloCredential = {
|
|
14
13
|
kind: 'api_key';
|
|
@@ -18,6 +17,11 @@ type TopoloCredential = {
|
|
|
18
17
|
accessToken: string;
|
|
19
18
|
refreshToken?: string;
|
|
20
19
|
expiresAt?: number;
|
|
20
|
+
} | {
|
|
21
|
+
kind: 'dpop_access_token';
|
|
22
|
+
accessToken: string;
|
|
23
|
+
privateJwk: JsonWebKey;
|
|
24
|
+
expiresAt?: number;
|
|
21
25
|
};
|
|
22
26
|
|
|
23
27
|
declare const TOPOLO_RUNTIME_ENVIRONMENTS: readonly ["production", "staging", "development", "local"];
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@topolo/sdk",
|
|
3
3
|
"packageManager": "pnpm@10.17.1",
|
|
4
|
-
"version": "0.
|
|
5
|
-
"topoloPublishedVersion": "0.
|
|
4
|
+
"version": "0.19.0",
|
|
5
|
+
"topoloPublishedVersion": "0.19.0",
|
|
6
6
|
"description": "Typed client SDK for the Topolo platform. Used by TopoloCli, TopoloMCP, and third-party agents.",
|
|
7
7
|
"license": "UNLICENSED",
|
|
8
8
|
"author": "Topolo",
|