@tinycloud/sdk-core 3.1.0-beta.11 → 3.1.0-beta.12
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/{credential-admission-CO9WMtGs.d.ts → credential-admission-BaP4pdpy.d.ts} +9 -1
- package/dist/{credential-admission-BxpkckU0.d.cts → credential-admission-ohx0XnQr.d.cts} +9 -1
- package/dist/delegations/index.cjs +19 -12
- package/dist/delegations/index.cjs.map +1 -1
- package/dist/delegations/index.d.cts +2 -2
- package/dist/delegations/index.d.ts +2 -2
- package/dist/delegations/index.js +19 -12
- package/dist/delegations/index.js.map +1 -1
- package/dist/index.cjs +45 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +45 -12
- package/dist/index.js.map +1 -1
- package/dist/policy/index.cjs +27 -0
- package/dist/policy/index.cjs.map +1 -1
- package/dist/policy/index.d.cts +2 -2
- package/dist/policy/index.d.ts +2 -2
- package/dist/policy/index.js +27 -0
- package/dist/policy/index.js.map +1 -1
- package/dist/{recipient-types.schema-_JkBDZB6.d.cts → recipient-types.schema-D-IMys0b.d.cts} +4 -1
- package/dist/{recipient-types.schema-_JkBDZB6.d.ts → recipient-types.schema-D-IMys0b.d.ts} +4 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -400,6 +400,7 @@ __export(index_exports, {
|
|
|
400
400
|
parseSecretCatalogKey: () => import_sdk_services9.parseSecretCatalogKey,
|
|
401
401
|
parseShareArtifact: () => parseShareArtifact,
|
|
402
402
|
parseShareUrl: () => parseShareUrl,
|
|
403
|
+
parseSignedCompactUcanAttenuation: () => parseSignedCompactUcanAttenuation,
|
|
403
404
|
parseSpaceUri: () => parseSpaceUri,
|
|
404
405
|
pkhDid: () => pkhDid,
|
|
405
406
|
policyCidFromCanonicalBytes: () => policyCidFromCanonicalBytes,
|
|
@@ -4682,6 +4683,32 @@ function parseCompactUcanAuthorization(input, expectedCid) {
|
|
|
4682
4683
|
throw new Error("compact UCAN CID does not match exact Authorization bytes");
|
|
4683
4684
|
return { authorization: input, cid: cid2, header, payload };
|
|
4684
4685
|
}
|
|
4686
|
+
var SignedCompactAttenuationSchema = import_zod2.z.record(import_zod2.z.record(import_zod2.z.array(import_zod2.z.unknown()).min(1)));
|
|
4687
|
+
function parseSignedCompactUcanAttenuation(input, expectedCid) {
|
|
4688
|
+
if (typeof input !== "string" || /\s/.test(input))
|
|
4689
|
+
throw new Error("Authorization must be compact UCAN bytes");
|
|
4690
|
+
const segments = input.split(".");
|
|
4691
|
+
if (segments.length !== 3 || segments.some((segment) => segment.length === 0))
|
|
4692
|
+
throw new Error("Authorization must have three compact segments");
|
|
4693
|
+
const [headerSegment, payloadSegment, signatureSegment] = segments;
|
|
4694
|
+
const headerValue = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(decodeBase64Url2(headerSegment)));
|
|
4695
|
+
const payloadValue = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(decodeBase64Url2(payloadSegment)));
|
|
4696
|
+
if (!isRecordValue(headerValue) || !isRecordValue(headerValue.jwk) || headerValue.alg !== "EdDSA" || headerValue.typ !== "JWT" || headerValue.ucv !== "0.10.0" || headerValue.jwk.kty !== "OKP" || headerValue.jwk.crv !== "Ed25519" || !isRecordValue(payloadValue) || typeof payloadValue.iss !== "string")
|
|
4697
|
+
throw new Error("Authorization has an invalid signed UCAN header or issuer");
|
|
4698
|
+
const att = SignedCompactAttenuationSchema.parse(payloadValue.att);
|
|
4699
|
+
const principal = payloadValue.iss.split("#", 1)[0];
|
|
4700
|
+
const didMaterial = principal.startsWith("did:key:") ? base58btc.decode(principal.slice("did:key:".length)) : new Uint8Array();
|
|
4701
|
+
const publicKey = didMaterial.length === 34 && didMaterial[0] === 237 && didMaterial[1] === 1 ? didMaterial.slice(2) : new Uint8Array();
|
|
4702
|
+
const jwkKey = typeof headerValue.jwk.x === "string" ? decodeBase64Url2(headerValue.jwk.x) : new Uint8Array();
|
|
4703
|
+
if (publicKey.length !== 32 || !equalBytes(publicKey, jwkKey))
|
|
4704
|
+
throw new Error("compact UCAN JWK does not bind issuer");
|
|
4705
|
+
const signature = decodeBase64Url2(signatureSegment);
|
|
4706
|
+
if (!import_ed255193.ed25519.verify(signature, new TextEncoder().encode(`${headerSegment}.${payloadSegment}`), publicKey))
|
|
4707
|
+
throw new Error("compact UCAN signature is invalid");
|
|
4708
|
+
const cid2 = CID.createV1(85, create(30, (0, import_blake3.blake3)(new TextEncoder().encode(input)))).toString();
|
|
4709
|
+
if (expectedCid !== void 0 && cid2 !== expectedCid) throw new Error("compact UCAN CID does not match exact Authorization bytes");
|
|
4710
|
+
return { cid: cid2, payload: { att } };
|
|
4711
|
+
}
|
|
4685
4712
|
function parsePolicySessionUcan(authorization, expectedProofs) {
|
|
4686
4713
|
const parsed = parseCompactUcanAuthorization(authorization);
|
|
4687
4714
|
const fact = parsed.payload.fct[0];
|
|
@@ -7169,7 +7196,7 @@ var DelegationManager = class {
|
|
|
7169
7196
|
* }
|
|
7170
7197
|
* ```
|
|
7171
7198
|
*/
|
|
7172
|
-
async revoke(cid2) {
|
|
7199
|
+
async revoke(cid2, options2) {
|
|
7173
7200
|
if (!cid2) {
|
|
7174
7201
|
return {
|
|
7175
7202
|
ok: false,
|
|
@@ -7189,15 +7216,20 @@ var DelegationManager = class {
|
|
|
7189
7216
|
)
|
|
7190
7217
|
};
|
|
7191
7218
|
}
|
|
7192
|
-
const
|
|
7193
|
-
|
|
7194
|
-
|
|
7195
|
-
|
|
7196
|
-
|
|
7197
|
-
|
|
7198
|
-
|
|
7199
|
-
|
|
7200
|
-
|
|
7219
|
+
const entry = {
|
|
7220
|
+
resource: `urn:cid:${cid2}`,
|
|
7221
|
+
...options2?.targetSpaceId === void 0 ? {} : { spaceId: options2.targetSpaceId },
|
|
7222
|
+
service: "delegation",
|
|
7223
|
+
path: "",
|
|
7224
|
+
action: DelegationAction.REVOKE
|
|
7225
|
+
};
|
|
7226
|
+
if (options2?.authorityCid !== void 0) {
|
|
7227
|
+
Object.defineProperty(entry, "revokeAuthorityCid", {
|
|
7228
|
+
value: options2.authorityCid,
|
|
7229
|
+
enumerable: false
|
|
7230
|
+
});
|
|
7231
|
+
}
|
|
7232
|
+
const headers = this.invokeAny(this.session, [entry]);
|
|
7201
7233
|
const response = await this.fetchFn(`${this.host}/revoke`, {
|
|
7202
7234
|
method: "POST",
|
|
7203
7235
|
headers
|
|
@@ -7355,7 +7387,8 @@ var DelegationManager = class {
|
|
|
7355
7387
|
)
|
|
7356
7388
|
};
|
|
7357
7389
|
}
|
|
7358
|
-
|
|
7390
|
+
const accountSpaceId = this.accountSpaceId;
|
|
7391
|
+
if (!accountSpaceId) {
|
|
7359
7392
|
return {
|
|
7360
7393
|
ok: false,
|
|
7361
7394
|
error: createError(
|
|
@@ -7366,7 +7399,7 @@ var DelegationManager = class {
|
|
|
7366
7399
|
}
|
|
7367
7400
|
try {
|
|
7368
7401
|
const invocationHeaders = this.invokeAny(this.session, [{
|
|
7369
|
-
spaceId:
|
|
7402
|
+
spaceId: accountSpaceId,
|
|
7370
7403
|
service: "delegation",
|
|
7371
7404
|
path: "",
|
|
7372
7405
|
action: DelegationAction.LIST
|