@auctra/sdk 0.7.18 → 0.7.19
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/CHANGELOG.md +8 -0
- package/README.md +3 -0
- package/dist/cjs/capability.js +90 -0
- package/dist/cjs/index.js +8 -1
- package/dist/cjs/types.js +1 -1
- package/dist/esm/capability.d.ts +55 -0
- package/dist/esm/capability.d.ts.map +1 -0
- package/dist/esm/capability.js +85 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/types.d.ts +1 -1
- package/dist/esm/types.js +1 -1
- package/package.json +1 -1
- package/src/capability.ts +140 -0
- package/src/index.ts +15 -0
- package/src/types.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.7.19
|
|
4
|
+
|
|
5
|
+
**Interop — OpenAPI catalog ingest is untrusted discovery**
|
|
6
|
+
|
|
7
|
+
- `ingestOpenApiDocument` / `discoveryGrantsAuthority` for integrator apps.
|
|
8
|
+
- Spec prose and `securitySchemes` are not grants. Mapping is an explicit table only.
|
|
9
|
+
- Does not call Cloud and does not store catalogs.
|
|
10
|
+
|
|
3
11
|
## 0.7.18
|
|
4
12
|
|
|
5
13
|
**Security — bind lease consume to the evaluated request fingerprint**
|
package/README.md
CHANGED
|
@@ -42,6 +42,9 @@ auctra.listPolicyTemplates() / applyPolicyTemplate() # Pro+
|
|
|
42
42
|
auctra.approveActionRequest() / rejectActionRequest() / escalateActionRequest() # admin API key
|
|
43
43
|
|
|
44
44
|
auctra.evidence.verify()
|
|
45
|
+
|
|
46
|
+
ingestOpenApiDocument() # local, untrusted catalog → capability records
|
|
47
|
+
discoveryGrantsAuthority() # always false
|
|
45
48
|
```
|
|
46
49
|
|
|
47
50
|
API keys are **created in the console only** (`listApiKeys` is available in the SDK). Approvals via SDK require an **admin** key (not write-only).
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Vendor-neutral OpenAPI ingest for integrator apps.
|
|
4
|
+
* Catalog membership is not a grant. Mapping is an explicit table only.
|
|
5
|
+
* Keep behavior aligned with @auctra/authority-protocol capability.openapi.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.DEFAULT_OPENAPI_OPERATION_MAP = exports.INTEROP_CONTRACT_VERSION = exports.CAPABILITY_FORMAT = exports.OPENAPI_ADAPTER_ID = void 0;
|
|
9
|
+
exports.discoveryGrantsAuthority = discoveryGrantsAuthority;
|
|
10
|
+
exports.ingestOpenApiDocument = ingestOpenApiDocument;
|
|
11
|
+
exports.OPENAPI_ADAPTER_ID = "auctra.openapi-catalog.v0.1";
|
|
12
|
+
exports.CAPABILITY_FORMAT = "auctra-capability.v0.1";
|
|
13
|
+
exports.INTEROP_CONTRACT_VERSION = "0.1";
|
|
14
|
+
exports.DEFAULT_OPENAPI_OPERATION_MAP = {
|
|
15
|
+
createTransfer: "send_payment",
|
|
16
|
+
listTransfers: "read_sensitive_data",
|
|
17
|
+
};
|
|
18
|
+
/** Catalog rows never grant Auctra authority. */
|
|
19
|
+
function discoveryGrantsAuthority(_record) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
function issue(code, message) {
|
|
23
|
+
return { code, message };
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Ingest an OpenAPI 3 document as untrusted capability metadata.
|
|
27
|
+
* Does not call Auctra Cloud. Does not grant authority.
|
|
28
|
+
*/
|
|
29
|
+
function ingestOpenApiDocument(doc, opts = {}) {
|
|
30
|
+
const openapi = typeof doc.openapi === "string" ? doc.openapi : "";
|
|
31
|
+
if (!openapi.startsWith("3.")) {
|
|
32
|
+
return { ok: false, issues: [issue("not_openapi3", "Only OpenAPI 3.x documents are accepted")] };
|
|
33
|
+
}
|
|
34
|
+
const paths = doc.paths;
|
|
35
|
+
if (!paths || typeof paths !== "object" || Array.isArray(paths)) {
|
|
36
|
+
return { ok: false, issues: [issue("missing_paths", "OpenAPI document has no paths object")] };
|
|
37
|
+
}
|
|
38
|
+
const at = opts.at ?? new Date();
|
|
39
|
+
const source_system = opts.source_system ?? exports.OPENAPI_ADAPTER_ID;
|
|
40
|
+
const provider = opts.provider ?? "openapi";
|
|
41
|
+
const service_id = opts.service_id ?? "imported-api";
|
|
42
|
+
const operationMap = opts.operationMap ?? exports.DEFAULT_OPENAPI_OPERATION_MAP;
|
|
43
|
+
const info = doc.info && typeof doc.info === "object" ? doc.info : {};
|
|
44
|
+
const infoBlurb = [info.description, info.title].filter((row) => typeof row === "string").join(" ");
|
|
45
|
+
const records = [];
|
|
46
|
+
const warnings = [];
|
|
47
|
+
const methods = ["get", "post", "put", "patch", "delete", "head", "options"];
|
|
48
|
+
for (const [path, item] of Object.entries(paths)) {
|
|
49
|
+
if (!item || typeof item !== "object")
|
|
50
|
+
continue;
|
|
51
|
+
const pathItem = item;
|
|
52
|
+
for (const method of methods) {
|
|
53
|
+
const op = pathItem[method];
|
|
54
|
+
if (!op || typeof op !== "object")
|
|
55
|
+
continue;
|
|
56
|
+
const operationId = typeof op.operationId === "string" && op.operationId.trim()
|
|
57
|
+
? op.operationId.trim()
|
|
58
|
+
: `${method}:${path}`;
|
|
59
|
+
const untrusted = [op.summary, op.description, infoBlurb]
|
|
60
|
+
.filter((row) => typeof row === "string")
|
|
61
|
+
.join("\n");
|
|
62
|
+
if (/ignore previous|you are now|grant authority/i.test(untrusted)) {
|
|
63
|
+
warnings.push(issue("untrusted_instruction", "Description looks like an instruction; stored as untrusted text only"));
|
|
64
|
+
}
|
|
65
|
+
const mappedName = operationMap[operationId];
|
|
66
|
+
records.push({
|
|
67
|
+
format: exports.CAPABILITY_FORMAT,
|
|
68
|
+
interop_contract_version: exports.INTEROP_CONTRACT_VERSION,
|
|
69
|
+
state: mappedName ? "mapped" : "validated",
|
|
70
|
+
source_system,
|
|
71
|
+
source_record_id: `${method}:${path}`,
|
|
72
|
+
provider,
|
|
73
|
+
service_id,
|
|
74
|
+
operation_id: operationId,
|
|
75
|
+
invocation_type: "http",
|
|
76
|
+
http_method: method.toUpperCase(),
|
|
77
|
+
path,
|
|
78
|
+
declared_auth: Array.isArray(op.security) ? ["openapi-security"] : undefined,
|
|
79
|
+
retrieved_at: at.toISOString(),
|
|
80
|
+
auctra_operation_id: mappedName,
|
|
81
|
+
mapping_confidence: mappedName ? "high" : "unresolved",
|
|
82
|
+
untrusted_description: untrusted || undefined,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (!records.length) {
|
|
87
|
+
return { ok: false, issues: [issue("empty", "OpenAPI document produced no operations")] };
|
|
88
|
+
}
|
|
89
|
+
return { ok: true, records, warnings };
|
|
90
|
+
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.withExecutionLease = exports.assertAuthorityLive = exports.assertAllowed = exports.onAllowed = exports.Auctra = exports.verifyDecisionArtifact = exports.verifyMandateArtifact = exports.AuctraApiError = exports.DEFAULT_BASE_URL = exports.AUCTRA_SDK_VERSION = void 0;
|
|
3
|
+
exports.ingestOpenApiDocument = exports.discoveryGrantsAuthority = exports.OPENAPI_ADAPTER_ID = exports.INTEROP_CONTRACT_VERSION = exports.DEFAULT_OPENAPI_OPERATION_MAP = exports.CAPABILITY_FORMAT = exports.withExecutionLease = exports.assertAuthorityLive = exports.assertAllowed = exports.onAllowed = exports.Auctra = exports.verifyDecisionArtifact = exports.verifyMandateArtifact = exports.AuctraApiError = exports.DEFAULT_BASE_URL = exports.AUCTRA_SDK_VERSION = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* @auctra/sdk — Stage 1.0 public surface.
|
|
6
6
|
*
|
|
@@ -21,3 +21,10 @@ Object.defineProperty(exports, "onAllowed", { enumerable: true, get: function ()
|
|
|
21
21
|
Object.defineProperty(exports, "assertAllowed", { enumerable: true, get: function () { return action_js_1.assertAllowed; } });
|
|
22
22
|
Object.defineProperty(exports, "assertAuthorityLive", { enumerable: true, get: function () { return action_js_1.assertAuthorityLive; } });
|
|
23
23
|
Object.defineProperty(exports, "withExecutionLease", { enumerable: true, get: function () { return action_js_1.withExecutionLease; } });
|
|
24
|
+
var capability_js_1 = require("./capability.js");
|
|
25
|
+
Object.defineProperty(exports, "CAPABILITY_FORMAT", { enumerable: true, get: function () { return capability_js_1.CAPABILITY_FORMAT; } });
|
|
26
|
+
Object.defineProperty(exports, "DEFAULT_OPENAPI_OPERATION_MAP", { enumerable: true, get: function () { return capability_js_1.DEFAULT_OPENAPI_OPERATION_MAP; } });
|
|
27
|
+
Object.defineProperty(exports, "INTEROP_CONTRACT_VERSION", { enumerable: true, get: function () { return capability_js_1.INTEROP_CONTRACT_VERSION; } });
|
|
28
|
+
Object.defineProperty(exports, "OPENAPI_ADAPTER_ID", { enumerable: true, get: function () { return capability_js_1.OPENAPI_ADAPTER_ID; } });
|
|
29
|
+
Object.defineProperty(exports, "discoveryGrantsAuthority", { enumerable: true, get: function () { return capability_js_1.discoveryGrantsAuthority; } });
|
|
30
|
+
Object.defineProperty(exports, "ingestOpenApiDocument", { enumerable: true, get: function () { return capability_js_1.ingestOpenApiDocument; } });
|
package/dist/cjs/types.js
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
/** @auctra/sdk — Authority Protocol client (Stage 1.0 modular layout). */
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.DEFAULT_BASE_URL = exports.AUCTRA_SDK_VERSION = void 0;
|
|
5
|
-
exports.AUCTRA_SDK_VERSION = "0.7.
|
|
5
|
+
exports.AUCTRA_SDK_VERSION = "0.7.19";
|
|
6
6
|
/** Production API + console host (Architecture A: colocated on app.auctra.tech). */
|
|
7
7
|
exports.DEFAULT_BASE_URL = "https://app.auctra.tech";
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vendor-neutral OpenAPI ingest for integrator apps.
|
|
3
|
+
* Catalog membership is not a grant. Mapping is an explicit table only.
|
|
4
|
+
* Keep behavior aligned with @auctra/authority-protocol capability.openapi.
|
|
5
|
+
*/
|
|
6
|
+
export declare const OPENAPI_ADAPTER_ID = "auctra.openapi-catalog.v0.1";
|
|
7
|
+
export declare const CAPABILITY_FORMAT = "auctra-capability.v0.1";
|
|
8
|
+
export declare const INTEROP_CONTRACT_VERSION = "0.1";
|
|
9
|
+
export declare const DEFAULT_OPENAPI_OPERATION_MAP: Record<string, string>;
|
|
10
|
+
export type CapabilityState = "discovered" | "validated" | "mapped" | "evaluated" | "authorized_request";
|
|
11
|
+
export type IngestIssue = {
|
|
12
|
+
code: string;
|
|
13
|
+
message: string;
|
|
14
|
+
};
|
|
15
|
+
export type CapabilityRecord = {
|
|
16
|
+
format: typeof CAPABILITY_FORMAT;
|
|
17
|
+
interop_contract_version: typeof INTEROP_CONTRACT_VERSION;
|
|
18
|
+
state: CapabilityState;
|
|
19
|
+
source_system: string;
|
|
20
|
+
source_record_id: string;
|
|
21
|
+
provider: string;
|
|
22
|
+
service_id: string;
|
|
23
|
+
operation_id: string;
|
|
24
|
+
invocation_type: "http";
|
|
25
|
+
http_method?: string;
|
|
26
|
+
path?: string;
|
|
27
|
+
declared_auth?: string[];
|
|
28
|
+
retrieved_at: string;
|
|
29
|
+
auctra_operation_id?: string;
|
|
30
|
+
mapping_confidence: "unresolved" | "high";
|
|
31
|
+
untrusted_description?: string;
|
|
32
|
+
};
|
|
33
|
+
export type OpenApiIngestOk = {
|
|
34
|
+
ok: true;
|
|
35
|
+
records: CapabilityRecord[];
|
|
36
|
+
warnings: IngestIssue[];
|
|
37
|
+
};
|
|
38
|
+
export type OpenApiIngestFail = {
|
|
39
|
+
ok: false;
|
|
40
|
+
issues: IngestIssue[];
|
|
41
|
+
};
|
|
42
|
+
/** Catalog rows never grant Auctra authority. */
|
|
43
|
+
export declare function discoveryGrantsAuthority(_record?: CapabilityRecord): false;
|
|
44
|
+
/**
|
|
45
|
+
* Ingest an OpenAPI 3 document as untrusted capability metadata.
|
|
46
|
+
* Does not call Auctra Cloud. Does not grant authority.
|
|
47
|
+
*/
|
|
48
|
+
export declare function ingestOpenApiDocument(doc: Record<string, unknown>, opts?: {
|
|
49
|
+
source_system?: string;
|
|
50
|
+
provider?: string;
|
|
51
|
+
service_id?: string;
|
|
52
|
+
at?: Date;
|
|
53
|
+
operationMap?: Record<string, string>;
|
|
54
|
+
}): OpenApiIngestOk | OpenApiIngestFail;
|
|
55
|
+
//# sourceMappingURL=capability.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capability.d.ts","sourceRoot":"","sources":["../../src/capability.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,eAAO,MAAM,kBAAkB,gCAAgC,CAAC;AAChE,eAAO,MAAM,iBAAiB,2BAA2B,CAAC;AAC1D,eAAO,MAAM,wBAAwB,QAAQ,CAAC;AAE9C,eAAO,MAAM,6BAA6B,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAGhE,CAAC;AAEF,MAAM,MAAM,eAAe,GACvB,YAAY,GACZ,WAAW,GACX,QAAQ,GACR,WAAW,GACX,oBAAoB,CAAC;AAEzB,MAAM,MAAM,WAAW,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAE5D,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,OAAO,iBAAiB,CAAC;IACjC,wBAAwB,EAAE,OAAO,wBAAwB,CAAC;IAC1D,KAAK,EAAE,eAAe,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,kBAAkB,EAAE,YAAY,GAAG,MAAM,CAAC;IAC1C,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,EAAE,EAAE,IAAI,CAAC;IACT,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B,QAAQ,EAAE,WAAW,EAAE,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,WAAW,EAAE,CAAA;CAAE,CAAC;AAErE,iDAAiD;AACjD,wBAAgB,wBAAwB,CAAC,OAAO,CAAC,EAAE,gBAAgB,GAAG,KAAK,CAE1E;AAMD;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,IAAI,GAAE;IACJ,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,EAAE,CAAC,EAAE,IAAI,CAAC;IACV,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC,GACL,eAAe,GAAG,iBAAiB,CAkErC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vendor-neutral OpenAPI ingest for integrator apps.
|
|
3
|
+
* Catalog membership is not a grant. Mapping is an explicit table only.
|
|
4
|
+
* Keep behavior aligned with @auctra/authority-protocol capability.openapi.
|
|
5
|
+
*/
|
|
6
|
+
export const OPENAPI_ADAPTER_ID = "auctra.openapi-catalog.v0.1";
|
|
7
|
+
export const CAPABILITY_FORMAT = "auctra-capability.v0.1";
|
|
8
|
+
export const INTEROP_CONTRACT_VERSION = "0.1";
|
|
9
|
+
export const DEFAULT_OPENAPI_OPERATION_MAP = {
|
|
10
|
+
createTransfer: "send_payment",
|
|
11
|
+
listTransfers: "read_sensitive_data",
|
|
12
|
+
};
|
|
13
|
+
/** Catalog rows never grant Auctra authority. */
|
|
14
|
+
export function discoveryGrantsAuthority(_record) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
function issue(code, message) {
|
|
18
|
+
return { code, message };
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Ingest an OpenAPI 3 document as untrusted capability metadata.
|
|
22
|
+
* Does not call Auctra Cloud. Does not grant authority.
|
|
23
|
+
*/
|
|
24
|
+
export function ingestOpenApiDocument(doc, opts = {}) {
|
|
25
|
+
const openapi = typeof doc.openapi === "string" ? doc.openapi : "";
|
|
26
|
+
if (!openapi.startsWith("3.")) {
|
|
27
|
+
return { ok: false, issues: [issue("not_openapi3", "Only OpenAPI 3.x documents are accepted")] };
|
|
28
|
+
}
|
|
29
|
+
const paths = doc.paths;
|
|
30
|
+
if (!paths || typeof paths !== "object" || Array.isArray(paths)) {
|
|
31
|
+
return { ok: false, issues: [issue("missing_paths", "OpenAPI document has no paths object")] };
|
|
32
|
+
}
|
|
33
|
+
const at = opts.at ?? new Date();
|
|
34
|
+
const source_system = opts.source_system ?? OPENAPI_ADAPTER_ID;
|
|
35
|
+
const provider = opts.provider ?? "openapi";
|
|
36
|
+
const service_id = opts.service_id ?? "imported-api";
|
|
37
|
+
const operationMap = opts.operationMap ?? DEFAULT_OPENAPI_OPERATION_MAP;
|
|
38
|
+
const info = doc.info && typeof doc.info === "object" ? doc.info : {};
|
|
39
|
+
const infoBlurb = [info.description, info.title].filter((row) => typeof row === "string").join(" ");
|
|
40
|
+
const records = [];
|
|
41
|
+
const warnings = [];
|
|
42
|
+
const methods = ["get", "post", "put", "patch", "delete", "head", "options"];
|
|
43
|
+
for (const [path, item] of Object.entries(paths)) {
|
|
44
|
+
if (!item || typeof item !== "object")
|
|
45
|
+
continue;
|
|
46
|
+
const pathItem = item;
|
|
47
|
+
for (const method of methods) {
|
|
48
|
+
const op = pathItem[method];
|
|
49
|
+
if (!op || typeof op !== "object")
|
|
50
|
+
continue;
|
|
51
|
+
const operationId = typeof op.operationId === "string" && op.operationId.trim()
|
|
52
|
+
? op.operationId.trim()
|
|
53
|
+
: `${method}:${path}`;
|
|
54
|
+
const untrusted = [op.summary, op.description, infoBlurb]
|
|
55
|
+
.filter((row) => typeof row === "string")
|
|
56
|
+
.join("\n");
|
|
57
|
+
if (/ignore previous|you are now|grant authority/i.test(untrusted)) {
|
|
58
|
+
warnings.push(issue("untrusted_instruction", "Description looks like an instruction; stored as untrusted text only"));
|
|
59
|
+
}
|
|
60
|
+
const mappedName = operationMap[operationId];
|
|
61
|
+
records.push({
|
|
62
|
+
format: CAPABILITY_FORMAT,
|
|
63
|
+
interop_contract_version: INTEROP_CONTRACT_VERSION,
|
|
64
|
+
state: mappedName ? "mapped" : "validated",
|
|
65
|
+
source_system,
|
|
66
|
+
source_record_id: `${method}:${path}`,
|
|
67
|
+
provider,
|
|
68
|
+
service_id,
|
|
69
|
+
operation_id: operationId,
|
|
70
|
+
invocation_type: "http",
|
|
71
|
+
http_method: method.toUpperCase(),
|
|
72
|
+
path,
|
|
73
|
+
declared_auth: Array.isArray(op.security) ? ["openapi-security"] : undefined,
|
|
74
|
+
retrieved_at: at.toISOString(),
|
|
75
|
+
auctra_operation_id: mappedName,
|
|
76
|
+
mapping_confidence: mappedName ? "high" : "unresolved",
|
|
77
|
+
untrusted_description: untrusted || undefined,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (!records.length) {
|
|
82
|
+
return { ok: false, issues: [issue("empty", "OpenAPI document produced no operations")] };
|
|
83
|
+
}
|
|
84
|
+
return { ok: true, records, warnings };
|
|
85
|
+
}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -10,4 +10,6 @@ export { AuctraApiError, verifyMandateArtifact, verifyDecisionArtifact } from ".
|
|
|
10
10
|
export { Auctra } from "./client.js";
|
|
11
11
|
export { onAllowed, assertAllowed, assertAuthorityLive, withExecutionLease } from "./action.js";
|
|
12
12
|
export type { AuthorityLivenessClient } from "./action.js";
|
|
13
|
+
export { CAPABILITY_FORMAT, DEFAULT_OPENAPI_OPERATION_MAP, INTEROP_CONTRACT_VERSION, OPENAPI_ADAPTER_ID, discoveryGrantsAuthority, ingestOpenApiDocument, } from "./capability.js";
|
|
14
|
+
export type { CapabilityRecord, CapabilityState, IngestIssue, OpenApiIngestFail, OpenApiIngestOk, } from "./capability.js";
|
|
13
15
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAClE,mBAAmB,YAAY,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAC/F,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAChG,YAAY,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAClE,mBAAmB,YAAY,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAC/F,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAChG,YAAY,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EACL,iBAAiB,EACjB,6BAA6B,EAC7B,wBAAwB,EACxB,kBAAkB,EAClB,wBAAwB,EACxB,qBAAqB,GACtB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,iBAAiB,EACjB,eAAe,GAChB,MAAM,iBAAiB,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -8,3 +8,4 @@ export { AUCTRA_SDK_VERSION, DEFAULT_BASE_URL } from "./types.js";
|
|
|
8
8
|
export { AuctraApiError, verifyMandateArtifact, verifyDecisionArtifact } from "./artifacts.js";
|
|
9
9
|
export { Auctra } from "./client.js";
|
|
10
10
|
export { onAllowed, assertAllowed, assertAuthorityLive, withExecutionLease } from "./action.js";
|
|
11
|
+
export { CAPABILITY_FORMAT, DEFAULT_OPENAPI_OPERATION_MAP, INTEROP_CONTRACT_VERSION, OPENAPI_ADAPTER_ID, discoveryGrantsAuthority, ingestOpenApiDocument, } from "./capability.js";
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** @auctra/sdk — Authority Protocol client (Stage 1.0 modular layout). */
|
|
2
|
-
export declare const AUCTRA_SDK_VERSION = "0.7.
|
|
2
|
+
export declare const AUCTRA_SDK_VERSION = "0.7.19";
|
|
3
3
|
/** Production API + console host (Architecture A: colocated on app.auctra.tech). */
|
|
4
4
|
export declare const DEFAULT_BASE_URL = "https://app.auctra.tech";
|
|
5
5
|
export type AgentEnvironment = "dev" | "staging" | "production";
|
package/dist/esm/types.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/** @auctra/sdk — Authority Protocol client (Stage 1.0 modular layout). */
|
|
2
|
-
export const AUCTRA_SDK_VERSION = "0.7.
|
|
2
|
+
export const AUCTRA_SDK_VERSION = "0.7.19";
|
|
3
3
|
/** Production API + console host (Architecture A: colocated on app.auctra.tech). */
|
|
4
4
|
export const DEFAULT_BASE_URL = "https://app.auctra.tech";
|
package/package.json
CHANGED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vendor-neutral OpenAPI ingest for integrator apps.
|
|
3
|
+
* Catalog membership is not a grant. Mapping is an explicit table only.
|
|
4
|
+
* Keep behavior aligned with @auctra/authority-protocol capability.openapi.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export const OPENAPI_ADAPTER_ID = "auctra.openapi-catalog.v0.1";
|
|
8
|
+
export const CAPABILITY_FORMAT = "auctra-capability.v0.1";
|
|
9
|
+
export const INTEROP_CONTRACT_VERSION = "0.1";
|
|
10
|
+
|
|
11
|
+
export const DEFAULT_OPENAPI_OPERATION_MAP: Record<string, string> = {
|
|
12
|
+
createTransfer: "send_payment",
|
|
13
|
+
listTransfers: "read_sensitive_data",
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type CapabilityState =
|
|
17
|
+
| "discovered"
|
|
18
|
+
| "validated"
|
|
19
|
+
| "mapped"
|
|
20
|
+
| "evaluated"
|
|
21
|
+
| "authorized_request";
|
|
22
|
+
|
|
23
|
+
export type IngestIssue = { code: string; message: string };
|
|
24
|
+
|
|
25
|
+
export type CapabilityRecord = {
|
|
26
|
+
format: typeof CAPABILITY_FORMAT;
|
|
27
|
+
interop_contract_version: typeof INTEROP_CONTRACT_VERSION;
|
|
28
|
+
state: CapabilityState;
|
|
29
|
+
source_system: string;
|
|
30
|
+
source_record_id: string;
|
|
31
|
+
provider: string;
|
|
32
|
+
service_id: string;
|
|
33
|
+
operation_id: string;
|
|
34
|
+
invocation_type: "http";
|
|
35
|
+
http_method?: string;
|
|
36
|
+
path?: string;
|
|
37
|
+
declared_auth?: string[];
|
|
38
|
+
retrieved_at: string;
|
|
39
|
+
auctra_operation_id?: string;
|
|
40
|
+
mapping_confidence: "unresolved" | "high";
|
|
41
|
+
untrusted_description?: string;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export type OpenApiIngestOk = {
|
|
45
|
+
ok: true;
|
|
46
|
+
records: CapabilityRecord[];
|
|
47
|
+
warnings: IngestIssue[];
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export type OpenApiIngestFail = { ok: false; issues: IngestIssue[] };
|
|
51
|
+
|
|
52
|
+
/** Catalog rows never grant Auctra authority. */
|
|
53
|
+
export function discoveryGrantsAuthority(_record?: CapabilityRecord): false {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function issue(code: string, message: string): IngestIssue {
|
|
58
|
+
return { code, message };
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Ingest an OpenAPI 3 document as untrusted capability metadata.
|
|
63
|
+
* Does not call Auctra Cloud. Does not grant authority.
|
|
64
|
+
*/
|
|
65
|
+
export function ingestOpenApiDocument(
|
|
66
|
+
doc: Record<string, unknown>,
|
|
67
|
+
opts: {
|
|
68
|
+
source_system?: string;
|
|
69
|
+
provider?: string;
|
|
70
|
+
service_id?: string;
|
|
71
|
+
at?: Date;
|
|
72
|
+
operationMap?: Record<string, string>;
|
|
73
|
+
} = {},
|
|
74
|
+
): OpenApiIngestOk | OpenApiIngestFail {
|
|
75
|
+
const openapi = typeof doc.openapi === "string" ? doc.openapi : "";
|
|
76
|
+
if (!openapi.startsWith("3.")) {
|
|
77
|
+
return { ok: false, issues: [issue("not_openapi3", "Only OpenAPI 3.x documents are accepted")] };
|
|
78
|
+
}
|
|
79
|
+
const paths = doc.paths;
|
|
80
|
+
if (!paths || typeof paths !== "object" || Array.isArray(paths)) {
|
|
81
|
+
return { ok: false, issues: [issue("missing_paths", "OpenAPI document has no paths object")] };
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const at = opts.at ?? new Date();
|
|
85
|
+
const source_system = opts.source_system ?? OPENAPI_ADAPTER_ID;
|
|
86
|
+
const provider = opts.provider ?? "openapi";
|
|
87
|
+
const service_id = opts.service_id ?? "imported-api";
|
|
88
|
+
const operationMap = opts.operationMap ?? DEFAULT_OPENAPI_OPERATION_MAP;
|
|
89
|
+
const info = doc.info && typeof doc.info === "object" ? (doc.info as Record<string, unknown>) : {};
|
|
90
|
+
const infoBlurb = [info.description, info.title].filter((row) => typeof row === "string").join(" ");
|
|
91
|
+
|
|
92
|
+
const records: CapabilityRecord[] = [];
|
|
93
|
+
const warnings: IngestIssue[] = [];
|
|
94
|
+
const methods = ["get", "post", "put", "patch", "delete", "head", "options"] as const;
|
|
95
|
+
|
|
96
|
+
for (const [path, item] of Object.entries(paths as Record<string, unknown>)) {
|
|
97
|
+
if (!item || typeof item !== "object") continue;
|
|
98
|
+
const pathItem = item as Record<string, Record<string, unknown>>;
|
|
99
|
+
for (const method of methods) {
|
|
100
|
+
const op = pathItem[method];
|
|
101
|
+
if (!op || typeof op !== "object") continue;
|
|
102
|
+
const operationId =
|
|
103
|
+
typeof op.operationId === "string" && op.operationId.trim()
|
|
104
|
+
? op.operationId.trim()
|
|
105
|
+
: `${method}:${path}`;
|
|
106
|
+
const untrusted = [op.summary, op.description, infoBlurb]
|
|
107
|
+
.filter((row) => typeof row === "string")
|
|
108
|
+
.join("\n");
|
|
109
|
+
if (/ignore previous|you are now|grant authority/i.test(untrusted)) {
|
|
110
|
+
warnings.push(
|
|
111
|
+
issue("untrusted_instruction", "Description looks like an instruction; stored as untrusted text only"),
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
const mappedName = operationMap[operationId];
|
|
115
|
+
records.push({
|
|
116
|
+
format: CAPABILITY_FORMAT,
|
|
117
|
+
interop_contract_version: INTEROP_CONTRACT_VERSION,
|
|
118
|
+
state: mappedName ? "mapped" : "validated",
|
|
119
|
+
source_system,
|
|
120
|
+
source_record_id: `${method}:${path}`,
|
|
121
|
+
provider,
|
|
122
|
+
service_id,
|
|
123
|
+
operation_id: operationId,
|
|
124
|
+
invocation_type: "http",
|
|
125
|
+
http_method: method.toUpperCase(),
|
|
126
|
+
path,
|
|
127
|
+
declared_auth: Array.isArray(op.security) ? ["openapi-security"] : undefined,
|
|
128
|
+
retrieved_at: at.toISOString(),
|
|
129
|
+
auctra_operation_id: mappedName,
|
|
130
|
+
mapping_confidence: mappedName ? "high" : "unresolved",
|
|
131
|
+
untrusted_description: untrusted || undefined,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (!records.length) {
|
|
137
|
+
return { ok: false, issues: [issue("empty", "OpenAPI document produced no operations")] };
|
|
138
|
+
}
|
|
139
|
+
return { ok: true, records, warnings };
|
|
140
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -10,3 +10,18 @@ export { AuctraApiError, verifyMandateArtifact, verifyDecisionArtifact } from ".
|
|
|
10
10
|
export { Auctra } from "./client.js";
|
|
11
11
|
export { onAllowed, assertAllowed, assertAuthorityLive, withExecutionLease } from "./action.js";
|
|
12
12
|
export type { AuthorityLivenessClient } from "./action.js";
|
|
13
|
+
export {
|
|
14
|
+
CAPABILITY_FORMAT,
|
|
15
|
+
DEFAULT_OPENAPI_OPERATION_MAP,
|
|
16
|
+
INTEROP_CONTRACT_VERSION,
|
|
17
|
+
OPENAPI_ADAPTER_ID,
|
|
18
|
+
discoveryGrantsAuthority,
|
|
19
|
+
ingestOpenApiDocument,
|
|
20
|
+
} from "./capability.js";
|
|
21
|
+
export type {
|
|
22
|
+
CapabilityRecord,
|
|
23
|
+
CapabilityState,
|
|
24
|
+
IngestIssue,
|
|
25
|
+
OpenApiIngestFail,
|
|
26
|
+
OpenApiIngestOk,
|
|
27
|
+
} from "./capability.js";
|
package/src/types.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** @auctra/sdk — Authority Protocol client (Stage 1.0 modular layout). */
|
|
2
2
|
|
|
3
|
-
export const AUCTRA_SDK_VERSION = "0.7.
|
|
3
|
+
export const AUCTRA_SDK_VERSION = "0.7.19";
|
|
4
4
|
|
|
5
5
|
/** Production API + console host (Architecture A: colocated on app.auctra.tech). */
|
|
6
6
|
export const DEFAULT_BASE_URL = "https://app.auctra.tech";
|