@tinycloud/operations 0.7.0-beta.34 → 0.7.0-beta.35
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/artifacts.d.cts +1 -1
- package/dist/artifacts.d.ts +1 -1
- package/dist/cli-runtime.cjs +82 -40
- package/dist/cli-runtime.cjs.map +1 -1
- package/dist/cli-runtime.d.cts +1 -1
- package/dist/cli-runtime.d.ts +1 -1
- package/dist/cli-runtime.js +82 -39
- package/dist/cli-runtime.js.map +1 -1
- package/dist/{contract-zRklonbR.d.cts → contract-DrtFhVsg.d.cts} +1 -1
- package/dist/{contract-zRklonbR.d.ts → contract-DrtFhVsg.d.ts} +1 -1
- package/dist/delegation-binding.d.cts +2 -2
- package/dist/delegation-binding.d.ts +2 -2
- package/dist/index-CVP0YT2f.d.cts +12 -0
- package/dist/index-D-72hsQ_.d.ts +12 -0
- package/dist/index.cjs +82 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -10
- package/dist/index.d.ts +2 -10
- package/dist/index.js +82 -39
- package/dist/index.js.map +1 -1
- package/dist/mcp-authority.cjs +486 -0
- package/dist/mcp-authority.cjs.map +1 -0
- package/dist/mcp-authority.d.cts +19 -0
- package/dist/mcp-authority.d.ts +19 -0
- package/dist/mcp-authority.js +470 -0
- package/dist/mcp-authority.js.map +1 -0
- package/dist/profile.d.cts +1 -1
- package/dist/profile.d.ts +1 -1
- package/dist/recovery.d.cts +1 -1
- package/dist/recovery.d.ts +1 -1
- package/dist/secret-request.d.cts +1 -1
- package/dist/secret-request.d.ts +1 -1
- package/package.json +7 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,10 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
/** Value-free counters; the caller owns this optional diagnostic sink. */
|
|
4
|
-
interface OperationMetrics {
|
|
5
|
-
replayedGrants: number;
|
|
6
|
-
}
|
|
7
|
-
/** The sole projection-facing execution API. */
|
|
8
|
-
declare function invokeOperation(operationId: string, operationVersion: number, invocationTarget: InvocationTarget, unknownInput: unknown, metrics?: OperationMetrics): Promise<OperationResult<unknown>>;
|
|
9
|
-
|
|
10
|
-
export { OperationResult, invokeOperation };
|
|
1
|
+
export { i as invokeOperation } from './index-CVP0YT2f.cjs';
|
|
2
|
+
export { a as OperationResult } from './contract-DrtFhVsg.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
/** Value-free counters; the caller owns this optional diagnostic sink. */
|
|
4
|
-
interface OperationMetrics {
|
|
5
|
-
replayedGrants: number;
|
|
6
|
-
}
|
|
7
|
-
/** The sole projection-facing execution API. */
|
|
8
|
-
declare function invokeOperation(operationId: string, operationVersion: number, invocationTarget: InvocationTarget, unknownInput: unknown, metrics?: OperationMetrics): Promise<OperationResult<unknown>>;
|
|
9
|
-
|
|
10
|
-
export { OperationResult, invokeOperation };
|
|
1
|
+
export { i as invokeOperation } from './index-D-72hsQ_.js';
|
|
2
|
+
export { a as OperationResult } from './contract-DrtFhVsg.js';
|
package/dist/index.js
CHANGED
|
@@ -5668,6 +5668,34 @@ var init_artifacts = __esm({
|
|
|
5668
5668
|
}
|
|
5669
5669
|
});
|
|
5670
5670
|
|
|
5671
|
+
// src/contract.ts
|
|
5672
|
+
var STORED_GRANT_SKIP_REASONS, DELEGATION_CID_PATTERN;
|
|
5673
|
+
var init_contract = __esm({
|
|
5674
|
+
"src/contract.ts"() {
|
|
5675
|
+
"use strict";
|
|
5676
|
+
STORED_GRANT_SKIP_REASONS = [
|
|
5677
|
+
"malformed",
|
|
5678
|
+
"unbound",
|
|
5679
|
+
"outside_request",
|
|
5680
|
+
"host_mismatch",
|
|
5681
|
+
"expired",
|
|
5682
|
+
"cid_mismatch",
|
|
5683
|
+
"authority_invalid",
|
|
5684
|
+
"proof_missing",
|
|
5685
|
+
"proof_invalid",
|
|
5686
|
+
"owner_mismatch",
|
|
5687
|
+
"audience_mismatch",
|
|
5688
|
+
"resources_mismatch",
|
|
5689
|
+
"unsupported",
|
|
5690
|
+
"activation_rejected",
|
|
5691
|
+
"activation_unavailable",
|
|
5692
|
+
"activation_unauthenticated",
|
|
5693
|
+
"invalid"
|
|
5694
|
+
];
|
|
5695
|
+
DELEGATION_CID_PATTERN = "^bafkr4i[a-z2-7]{52}$";
|
|
5696
|
+
}
|
|
5697
|
+
});
|
|
5698
|
+
|
|
5671
5699
|
// src/recovery.ts
|
|
5672
5700
|
function signInRecovery(profile, posture) {
|
|
5673
5701
|
if (!SAFE_PROFILE_TOKEN.test(profile)) return { action: "sign_in" };
|
|
@@ -5889,6 +5917,26 @@ var init_revoked_grant = __esm({
|
|
|
5889
5917
|
|
|
5890
5918
|
// src/kv-failure.ts
|
|
5891
5919
|
import { authorizationVerdictOf as authorizationVerdictOf2, validatedCapabilityOf } from "@tinycloud/sdk-services";
|
|
5920
|
+
function nodeRevocationOf(error) {
|
|
5921
|
+
if (typeof error !== "object" || error === null || !("service" in error) || error.service !== "kv" || !("code" in error) || error.code !== "AUTH_UNAUTHORIZED" && error.code !== "AUTH_DELEGATION_REVOKED" && error.code !== "AUTH_DELEGATION_ANCESTOR_REVOKED" || !("message" in error) || typeof error.message !== "string" || !("meta" in error) || typeof error.meta !== "object" || error.meta === null || !("status" in error.meta) || error.meta.status !== 401 || authorizationVerdictOf2(error) !== "unauthenticated") return void 0;
|
|
5922
|
+
const { code, message } = error;
|
|
5923
|
+
const separator = ": 401 - ";
|
|
5924
|
+
const start = message.indexOf(separator);
|
|
5925
|
+
if (start < 0) return void 0;
|
|
5926
|
+
const body = message.slice(start + separator.length);
|
|
5927
|
+
const match = NODE_REVOCATION_BODY.exec(body);
|
|
5928
|
+
if (match === null || match[0] !== body) return void 0;
|
|
5929
|
+
if (match[1] !== void 0 && code !== "AUTH_DELEGATION_ANCESTOR_REVOKED") {
|
|
5930
|
+
const revokedCid = match[2];
|
|
5931
|
+
return DELEGATION_CID2.test(revokedCid) ? { reason: "delegation_revoked", revokedCid } : void 0;
|
|
5932
|
+
}
|
|
5933
|
+
if (match[3] !== void 0 && code !== "AUTH_DELEGATION_REVOKED") {
|
|
5934
|
+
const ancestorCid = match[4];
|
|
5935
|
+
const revokedCid = match[5];
|
|
5936
|
+
return DELEGATION_CID2.test(ancestorCid) && DELEGATION_CID2.test(revokedCid) ? { reason: "delegation_ancestor_revoked", revokedCid, ancestorCid } : void 0;
|
|
5937
|
+
}
|
|
5938
|
+
return void 0;
|
|
5939
|
+
}
|
|
5892
5940
|
function kvRefusal(error) {
|
|
5893
5941
|
const verdict = authorizationVerdictOf2(error);
|
|
5894
5942
|
if (verdict === "unauthenticated") {
|
|
@@ -5898,22 +5946,30 @@ function kvRefusal(error) {
|
|
|
5898
5946
|
}
|
|
5899
5947
|
function authorizationFailure(error, action) {
|
|
5900
5948
|
switch (kvRefusal(error)) {
|
|
5901
|
-
case "auth_required":
|
|
5902
|
-
|
|
5903
|
-
|
|
5904
|
-
|
|
5905
|
-
|
|
5949
|
+
case "auth_required": {
|
|
5950
|
+
const revocation = nodeRevocationOf(error);
|
|
5951
|
+
return {
|
|
5952
|
+
status: "error",
|
|
5953
|
+
error: operationError("AUTH_REQUIRED", isRevokedGrantRefusal(error) ? REVOKED_GRANT_MESSAGE : `Authentication is required to ${action}.`, {
|
|
5954
|
+
...revocation === void 0 ? {} : { details: revocation }
|
|
5955
|
+
})
|
|
5956
|
+
};
|
|
5957
|
+
}
|
|
5906
5958
|
case "permission_denied":
|
|
5907
5959
|
return { status: "error", error: operationError("PERMISSION_DENIED", `Permission is denied to ${action}.`) };
|
|
5908
5960
|
case void 0:
|
|
5909
5961
|
return void 0;
|
|
5910
5962
|
}
|
|
5911
5963
|
}
|
|
5964
|
+
var DELEGATION_CID2, NODE_REVOCATION_BODY;
|
|
5912
5965
|
var init_kv_failure = __esm({
|
|
5913
5966
|
"src/kv-failure.ts"() {
|
|
5914
5967
|
"use strict";
|
|
5968
|
+
init_contract();
|
|
5915
5969
|
init_errors2();
|
|
5916
5970
|
init_revoked_grant();
|
|
5971
|
+
DELEGATION_CID2 = new RegExp(DELEGATION_CID_PATTERN);
|
|
5972
|
+
NODE_REVOCATION_BODY = /^(?:Invalid invocation: )?delegation-(?:(revoked): ([A-Za-z0-9]+)|(ancestor-revoked): ancestor=([A-Za-z0-9]+) invoked=([A-Za-z0-9]+))$/;
|
|
5917
5973
|
}
|
|
5918
5974
|
});
|
|
5919
5975
|
|
|
@@ -9500,34 +9556,6 @@ var init_secrets_status = __esm({
|
|
|
9500
9556
|
}
|
|
9501
9557
|
});
|
|
9502
9558
|
|
|
9503
|
-
// src/contract.ts
|
|
9504
|
-
var STORED_GRANT_SKIP_REASONS, DELEGATION_CID_PATTERN;
|
|
9505
|
-
var init_contract = __esm({
|
|
9506
|
-
"src/contract.ts"() {
|
|
9507
|
-
"use strict";
|
|
9508
|
-
STORED_GRANT_SKIP_REASONS = [
|
|
9509
|
-
"malformed",
|
|
9510
|
-
"unbound",
|
|
9511
|
-
"outside_request",
|
|
9512
|
-
"host_mismatch",
|
|
9513
|
-
"expired",
|
|
9514
|
-
"cid_mismatch",
|
|
9515
|
-
"authority_invalid",
|
|
9516
|
-
"proof_missing",
|
|
9517
|
-
"proof_invalid",
|
|
9518
|
-
"owner_mismatch",
|
|
9519
|
-
"audience_mismatch",
|
|
9520
|
-
"resources_mismatch",
|
|
9521
|
-
"unsupported",
|
|
9522
|
-
"activation_rejected",
|
|
9523
|
-
"activation_unavailable",
|
|
9524
|
-
"activation_unauthenticated",
|
|
9525
|
-
"invalid"
|
|
9526
|
-
];
|
|
9527
|
-
DELEGATION_CID_PATTERN = "^bafkr4i[a-z2-7]{52}$";
|
|
9528
|
-
}
|
|
9529
|
-
});
|
|
9530
|
-
|
|
9531
9559
|
// src/delegation-binding.ts
|
|
9532
9560
|
import { join as join3 } from "path";
|
|
9533
9561
|
import * as nodeSdk5 from "@tinycloud/node-sdk";
|
|
@@ -9680,7 +9708,7 @@ function verifiedStoredCid(node, entry) {
|
|
|
9680
9708
|
const cid = delegation?.cid;
|
|
9681
9709
|
if (typeof cid !== "string" || typeof header?.Authorization !== "string" || typeof node.computeDelegationCid !== "function") return void 0;
|
|
9682
9710
|
try {
|
|
9683
|
-
return node.computeDelegationCid(header.Authorization) === cid &&
|
|
9711
|
+
return node.computeDelegationCid(header.Authorization) === cid && DELEGATION_CID3.test(cid) ? cid : void 0;
|
|
9684
9712
|
} catch {
|
|
9685
9713
|
return void 0;
|
|
9686
9714
|
}
|
|
@@ -9787,7 +9815,7 @@ function recordKey(entry) {
|
|
|
9787
9815
|
function isRecord4(value) {
|
|
9788
9816
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9789
9817
|
}
|
|
9790
|
-
var REQUEST_ID_PREFIX, BINDING_NOTES, MIGRATION_LOCK_TIMEOUT_MS, NOT_REPLAYED,
|
|
9818
|
+
var REQUEST_ID_PREFIX, BINDING_NOTES, MIGRATION_LOCK_TIMEOUT_MS, NOT_REPLAYED, DELEGATION_CID3;
|
|
9791
9819
|
var init_delegation_binding = __esm({
|
|
9792
9820
|
"src/delegation-binding.ts"() {
|
|
9793
9821
|
"use strict";
|
|
@@ -9810,7 +9838,7 @@ var init_delegation_binding = __esm({
|
|
|
9810
9838
|
};
|
|
9811
9839
|
MIGRATION_LOCK_TIMEOUT_MS = 250;
|
|
9812
9840
|
NOT_REPLAYED = { status: "not-replayed" };
|
|
9813
|
-
|
|
9841
|
+
DELEGATION_CID3 = new RegExp(DELEGATION_CID_PATTERN);
|
|
9814
9842
|
}
|
|
9815
9843
|
});
|
|
9816
9844
|
|
|
@@ -10491,6 +10519,7 @@ import {
|
|
|
10491
10519
|
} from "@tinycloud/node-sdk";
|
|
10492
10520
|
|
|
10493
10521
|
// src/redaction.ts
|
|
10522
|
+
init_contract();
|
|
10494
10523
|
init_recovery();
|
|
10495
10524
|
import { RUNTIME_DELEGATION_REJECTIONS } from "@tinycloud/node-sdk";
|
|
10496
10525
|
|
|
@@ -10557,6 +10586,7 @@ function decodeBase58(value) {
|
|
|
10557
10586
|
}
|
|
10558
10587
|
|
|
10559
10588
|
// src/redaction.ts
|
|
10589
|
+
var DELEGATION_CID = new RegExp(DELEGATION_CID_PATTERN);
|
|
10560
10590
|
function redactOperationError(_definition, error) {
|
|
10561
10591
|
const details = error.details === void 0 ? void 0 : redactSafeErrorDetails(error.code, error.details);
|
|
10562
10592
|
return {
|
|
@@ -10629,6 +10659,19 @@ function redactSafeErrorDetails(code, details) {
|
|
|
10629
10659
|
const value = sanitize(details[key]);
|
|
10630
10660
|
if (value !== void 0) safeDetails[key] = value;
|
|
10631
10661
|
}
|
|
10662
|
+
if (code === "AUTH_REQUIRED") {
|
|
10663
|
+
const { reason, revokedCid, ancestorCid } = details;
|
|
10664
|
+
if (typeof revokedCid === "string" && DELEGATION_CID.exec(revokedCid)?.[0] === revokedCid) {
|
|
10665
|
+
if (reason === "delegation_revoked") {
|
|
10666
|
+
safeDetails.reason = reason;
|
|
10667
|
+
safeDetails.revokedCid = revokedCid;
|
|
10668
|
+
} else if (reason === "delegation_ancestor_revoked" && typeof ancestorCid === "string" && DELEGATION_CID.exec(ancestorCid)?.[0] === ancestorCid) {
|
|
10669
|
+
safeDetails.reason = reason;
|
|
10670
|
+
safeDetails.revokedCid = revokedCid;
|
|
10671
|
+
safeDetails.ancestorCid = ancestorCid;
|
|
10672
|
+
}
|
|
10673
|
+
}
|
|
10674
|
+
}
|
|
10632
10675
|
return Object.keys(safeDetails).length === 0 ? void 0 : safeDetails;
|
|
10633
10676
|
}
|
|
10634
10677
|
function safeIssueCodes(value) {
|
|
@@ -11028,7 +11071,7 @@ async function executePreparedInvocation(prepared, options = {}) {
|
|
|
11028
11071
|
operation,
|
|
11029
11072
|
context: runtimeResolution.context.summary,
|
|
11030
11073
|
setup: outcome.setup,
|
|
11031
|
-
retry:
|
|
11074
|
+
retry: operationRetryDescriptor(
|
|
11032
11075
|
operation,
|
|
11033
11076
|
parsedInput.data,
|
|
11034
11077
|
outcome.requiresCallerInput ?? false
|
|
@@ -11103,7 +11146,7 @@ function unresolvedContextSummary(target = {}) {
|
|
|
11103
11146
|
function errorResult(operation, context, error) {
|
|
11104
11147
|
return { status: "error", operation, context, error };
|
|
11105
11148
|
}
|
|
11106
|
-
function
|
|
11149
|
+
function operationRetryDescriptor(operation, input, requiresCallerInput = false) {
|
|
11107
11150
|
return {
|
|
11108
11151
|
operationId: operation.operationId,
|
|
11109
11152
|
operationVersion: operation.operationVersion,
|
|
@@ -11173,7 +11216,7 @@ function authorityRequiredResult(operation, context, input, request, missing, no
|
|
|
11173
11216
|
missing,
|
|
11174
11217
|
request,
|
|
11175
11218
|
approval: approvalAction(request, node),
|
|
11176
|
-
retry:
|
|
11219
|
+
retry: operationRetryDescriptor(operation, input, requiresCallerInput)
|
|
11177
11220
|
};
|
|
11178
11221
|
}
|
|
11179
11222
|
function approvalAction(request, node) {
|