@tinycloud/node-sdk 3.0.0-beta.6 → 3.0.0-beta.8
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/{core-UWQ41yuo.d.cts → core-WJQ9KiSD.d.cts} +4 -4
- package/dist/{core-UWQ41yuo.d.ts → core-WJQ9KiSD.d.ts} +4 -4
- package/dist/core.cjs +38 -58
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.js +40 -60
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +38 -58
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +40 -60
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ISessionStorage, PersistedSessionData, AutoSignStrategy, AutoRejectStrategy, CallbackStrategy, IUserAuthorization, ISigner, ISpaceCreationHandler, LocalNodeIdentityStore, IWasmBindings, ISessionManager, SiweConfig, Manifest, ComposedManifestRequest, ClientSession, TinyCloudSession, Extension, SignRequest, SignInOptions, CapabilityPresentationEnvelopeV1, Delegation, DelegatedResource, PermissionEntry, TelemetryConfig, IKVService, ISQLService, IDuckDbService, IHooksService, CreateOwnerDelegationParams as CreateOwnerDelegationParams$1, OwnerDelegationReceipt as OwnerDelegationReceipt$1, INotificationHandler, IENSResolver, AccountService, InvokeAnyFunction as InvokeAnyFunction$1, UnifiedPolicyCapability,
|
|
1
|
+
import { ISessionStorage, PersistedSessionData, AutoSignStrategy, AutoRejectStrategy, CallbackStrategy, IUserAuthorization, ISigner, ISpaceCreationHandler, LocalNodeIdentityStore, IWasmBindings, ISessionManager, SiweConfig, Manifest, ComposedManifestRequest, ClientSession, TinyCloudSession, Extension, SignRequest, SignInOptions, CapabilityPresentationEnvelopeV1, Delegation, DelegatedResource, PermissionEntry, TelemetryConfig, IKVService, ISQLService, IDuckDbService, IHooksService, CreateOwnerDelegationParams as CreateOwnerDelegationParams$1, OwnerDelegationReceipt as OwnerDelegationReceipt$1, INotificationHandler, IENSResolver, AccountService, InvokeAnyFunction as InvokeAnyFunction$1, UnifiedPolicyCapability, RegisterPolicyV3Input, RegisterPolicyV3Receipt, ShareDeliveryAuthorizationReceipt, CanonicalJson, ShareDeliveryAuthorizationV3Receipt, IDataVaultService, IEncryptionService, NetworkDescriptor, ISecretsService, ICapabilityKeyRegistry, DelegationManager, ISpaceService, ISpace, ISharingService, CreateDelegationParams, DelegationResult, DelegationRevocationReceipt, DelegationStatus, ResolvedDelegate, KeyProvider, JWK } from '@tinycloud/sdk-core';
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
3
|
import { InvokeFunction, InvokeAnyFunction } from '@tinycloud/sdk-services';
|
|
4
4
|
|
|
@@ -1811,9 +1811,9 @@ declare class TinyCloudNode {
|
|
|
1811
1811
|
* @internal
|
|
1812
1812
|
*/
|
|
1813
1813
|
createOwnerDelegation(params: CreateOwnerDelegationParams, assertActive?: () => void): Promise<OwnerDelegationReceipt>;
|
|
1814
|
-
/** Register a policy
|
|
1815
|
-
|
|
1816
|
-
/**
|
|
1814
|
+
/** Register a signed policy and sibling roots with this Node's Policy/v3 runtime. */
|
|
1815
|
+
registerPolicy(params: Omit<RegisterPolicyV3Input, "nodeOrigin" | "fetch">): Promise<RegisterPolicyV3Receipt>;
|
|
1816
|
+
/** @deprecated Policy/v2 delivery transport is retired. Use authorizeShareDeliveryV3. */
|
|
1817
1817
|
authorizeShareDelivery(input: {
|
|
1818
1818
|
readonly envelopeCid: string;
|
|
1819
1819
|
readonly shareCid: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ISessionStorage, PersistedSessionData, AutoSignStrategy, AutoRejectStrategy, CallbackStrategy, IUserAuthorization, ISigner, ISpaceCreationHandler, LocalNodeIdentityStore, IWasmBindings, ISessionManager, SiweConfig, Manifest, ComposedManifestRequest, ClientSession, TinyCloudSession, Extension, SignRequest, SignInOptions, CapabilityPresentationEnvelopeV1, Delegation, DelegatedResource, PermissionEntry, TelemetryConfig, IKVService, ISQLService, IDuckDbService, IHooksService, CreateOwnerDelegationParams as CreateOwnerDelegationParams$1, OwnerDelegationReceipt as OwnerDelegationReceipt$1, INotificationHandler, IENSResolver, AccountService, InvokeAnyFunction as InvokeAnyFunction$1, UnifiedPolicyCapability,
|
|
1
|
+
import { ISessionStorage, PersistedSessionData, AutoSignStrategy, AutoRejectStrategy, CallbackStrategy, IUserAuthorization, ISigner, ISpaceCreationHandler, LocalNodeIdentityStore, IWasmBindings, ISessionManager, SiweConfig, Manifest, ComposedManifestRequest, ClientSession, TinyCloudSession, Extension, SignRequest, SignInOptions, CapabilityPresentationEnvelopeV1, Delegation, DelegatedResource, PermissionEntry, TelemetryConfig, IKVService, ISQLService, IDuckDbService, IHooksService, CreateOwnerDelegationParams as CreateOwnerDelegationParams$1, OwnerDelegationReceipt as OwnerDelegationReceipt$1, INotificationHandler, IENSResolver, AccountService, InvokeAnyFunction as InvokeAnyFunction$1, UnifiedPolicyCapability, RegisterPolicyV3Input, RegisterPolicyV3Receipt, ShareDeliveryAuthorizationReceipt, CanonicalJson, ShareDeliveryAuthorizationV3Receipt, IDataVaultService, IEncryptionService, NetworkDescriptor, ISecretsService, ICapabilityKeyRegistry, DelegationManager, ISpaceService, ISpace, ISharingService, CreateDelegationParams, DelegationResult, DelegationRevocationReceipt, DelegationStatus, ResolvedDelegate, KeyProvider, JWK } from '@tinycloud/sdk-core';
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
3
|
import { InvokeFunction, InvokeAnyFunction } from '@tinycloud/sdk-services';
|
|
4
4
|
|
|
@@ -1811,9 +1811,9 @@ declare class TinyCloudNode {
|
|
|
1811
1811
|
* @internal
|
|
1812
1812
|
*/
|
|
1813
1813
|
createOwnerDelegation(params: CreateOwnerDelegationParams, assertActive?: () => void): Promise<OwnerDelegationReceipt>;
|
|
1814
|
-
/** Register a policy
|
|
1815
|
-
|
|
1816
|
-
/**
|
|
1814
|
+
/** Register a signed policy and sibling roots with this Node's Policy/v3 runtime. */
|
|
1815
|
+
registerPolicy(params: Omit<RegisterPolicyV3Input, "nodeOrigin" | "fetch">): Promise<RegisterPolicyV3Receipt>;
|
|
1816
|
+
/** @deprecated Policy/v2 delivery transport is retired. Use authorizeShareDeliveryV3. */
|
|
1817
1817
|
authorizeShareDelivery(input: {
|
|
1818
1818
|
readonly envelopeCid: string;
|
|
1819
1819
|
readonly shareCid: string;
|
package/dist/core.cjs
CHANGED
|
@@ -115,6 +115,7 @@ __export(core_exports, {
|
|
|
115
115
|
parseCanonicalNetworkId: () => import_sdk_core11.parseCanonicalNetworkId,
|
|
116
116
|
parseExpiry: () => import_sdk_core12.parseExpiry,
|
|
117
117
|
parsePkhDid: () => import_sdk_core11.parsePkhDid,
|
|
118
|
+
parseSecretCatalogKey: () => import_sdk_core16.parseSecretCatalogKey,
|
|
118
119
|
parseSpaceUri: () => import_sdk_core19.parseSpaceUri,
|
|
119
120
|
pkhDid: () => import_sdk_core11.pkhDid,
|
|
120
121
|
principalDid: () => import_sdk_core11.principalDid,
|
|
@@ -2081,6 +2082,11 @@ var NodeSecretsService = class {
|
|
|
2081
2082
|
if (!permission.ok) return permission;
|
|
2082
2083
|
return options === void 0 ? this.service.list() : this.service.list(options);
|
|
2083
2084
|
}
|
|
2085
|
+
async listAll() {
|
|
2086
|
+
const permission = await this.ensurePermission("", void 0, "list");
|
|
2087
|
+
if (!permission.ok) return permission;
|
|
2088
|
+
return this.service.listAll();
|
|
2089
|
+
}
|
|
2084
2090
|
get service() {
|
|
2085
2091
|
return this.config.getService();
|
|
2086
2092
|
}
|
|
@@ -2142,7 +2148,11 @@ var NodeSecretsService = class {
|
|
|
2142
2148
|
(entry) => manifests.some((candidate) => {
|
|
2143
2149
|
const resolved = (0, import_sdk_core7.resolveManifest)(candidate);
|
|
2144
2150
|
return resolved.resources.some(
|
|
2145
|
-
(resource) => resource.service === entry.service && spaceMatches(
|
|
2151
|
+
(resource) => resource.service === entry.service && spaceMatches(
|
|
2152
|
+
resource.space,
|
|
2153
|
+
entry.space,
|
|
2154
|
+
this.config.resolveSpace
|
|
2155
|
+
) && resource.path === entry.path && entry.actions.every((action) => resource.actions.includes(action))
|
|
2146
2156
|
);
|
|
2147
2157
|
})
|
|
2148
2158
|
);
|
|
@@ -5184,63 +5194,19 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
5184
5194
|
}
|
|
5185
5195
|
};
|
|
5186
5196
|
}
|
|
5187
|
-
/** Register a policy
|
|
5188
|
-
async
|
|
5197
|
+
/** Register a signed policy and sibling roots with this Node's Policy/v3 runtime. */
|
|
5198
|
+
async registerPolicy(params) {
|
|
5189
5199
|
this._serviceGraph.assertActive();
|
|
5190
|
-
|
|
5191
|
-
|
|
5192
|
-
|
|
5193
|
-
|
|
5194
|
-
body: JSON.stringify({
|
|
5195
|
-
policy: { bytes: base64UrlEncode(params.policy.bytes), cid: params.policy.cid, proof: params.policy.proof },
|
|
5196
|
-
ownerDelegation: { cid: params.ownerDelegation.delegationCid, dagCbor: base64UrlEncode(params.ownerDelegation.signedDagCbor) },
|
|
5197
|
-
enforcementDelegation: params.enforcementDelegation,
|
|
5198
|
-
contentSourceDigest: params.contentSourceDigest
|
|
5199
|
-
})
|
|
5200
|
+
return (0, import_sdk_core8.registerPolicyV3)({
|
|
5201
|
+
...params,
|
|
5202
|
+
nodeOrigin: this.config.host,
|
|
5203
|
+
fetch: globalThis.fetch.bind(globalThis)
|
|
5200
5204
|
});
|
|
5201
|
-
if (!response.ok) {
|
|
5202
|
-
let code = "";
|
|
5203
|
-
try {
|
|
5204
|
-
const body = await response.clone().json();
|
|
5205
|
-
if (typeof body.error?.code === "string") code = ` ${body.error.code}`;
|
|
5206
|
-
} catch {
|
|
5207
|
-
}
|
|
5208
|
-
throw new Error(`Owner share policy registration failed: ${response.status}${code}`);
|
|
5209
|
-
}
|
|
5210
|
-
const responseBytes = new Uint8Array(await response.arrayBuffer());
|
|
5211
|
-
return (0, import_sdk_core8.validateOwnerSharePolicyRegistrationBytes)(responseBytes, params);
|
|
5212
5205
|
}
|
|
5213
|
-
/**
|
|
5206
|
+
/** @deprecated Policy/v2 delivery transport is retired. Use authorizeShareDeliveryV3. */
|
|
5214
5207
|
async authorizeShareDelivery(input) {
|
|
5215
|
-
|
|
5216
|
-
|
|
5217
|
-
if (!session || !serviceSession) throw new Error("Share delivery requires an authenticated session");
|
|
5218
|
-
const body = {
|
|
5219
|
-
envelopeCid: input.envelopeCid,
|
|
5220
|
-
shareCid: input.shareCid,
|
|
5221
|
-
shareId: input.shareId,
|
|
5222
|
-
registrationCid: input.registrationCid,
|
|
5223
|
-
policyCid: input.policyCid,
|
|
5224
|
-
delegationCid: input.delegationCid,
|
|
5225
|
-
enforcementDelegationCid: input.enforcementDelegationCid,
|
|
5226
|
-
recipientEmail: input.recipientEmail,
|
|
5227
|
-
shareUrl: input.shareUrl,
|
|
5228
|
-
documentName: input.documentName,
|
|
5229
|
-
jti: base64UrlEncode(crypto.getRandomValues(new Uint8Array(16))),
|
|
5230
|
-
idempotencyKey: input.idempotencyKey,
|
|
5231
|
-
expiresAt: input.expiresAt
|
|
5232
|
-
};
|
|
5233
|
-
const requestBodyDigest = base64UrlEncode(new Uint8Array(await crypto.subtle.digest("SHA-256", new TextEncoder().encode((0, import_sdk_core8.canonicalizeEncryptionJson)(body)))));
|
|
5234
|
-
const request = { ...body, requestBodyDigest };
|
|
5235
|
-
const authorization = authorizationHeader(this.invokeAnyWithRuntimePermissions(serviceSession, [{ spaceId: session.spaceId, service: "kv", path: input.resourcePath, action: "tinycloud.kv/get" }]));
|
|
5236
|
-
const response = await fetch(`${this.config.host}/share/v2/deliveries/authorize`, {
|
|
5237
|
-
method: "POST",
|
|
5238
|
-
headers: { accept: "application/json", "content-type": "application/json", authorization },
|
|
5239
|
-
body: (0, import_sdk_core8.canonicalizeEncryptionJson)(request)
|
|
5240
|
-
});
|
|
5241
|
-
if (!response.ok) throw new Error(`Share delivery authorization failed: ${response.status}`);
|
|
5242
|
-
const responseBytes = new Uint8Array(await response.arrayBuffer());
|
|
5243
|
-
return (0, import_sdk_core8.validateShareDeliveryAuthorizationBytes)(responseBytes, { request, nodeProof: input.nodeProof, credentialsAudience: input.credentialsAudience });
|
|
5208
|
+
void input;
|
|
5209
|
+
throw new Error("Policy/v2 share delivery is retired; use authorizeShareDeliveryV3");
|
|
5244
5210
|
}
|
|
5245
5211
|
/** Authorize one short-lived v3 delivery against the signed v3 envelope and registered roots. */
|
|
5246
5212
|
async authorizeShareDeliveryV3(input) {
|
|
@@ -5256,22 +5222,35 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
5256
5222
|
shareUrl: input.shareUrl,
|
|
5257
5223
|
documentName: input.documentName,
|
|
5258
5224
|
jti: base64UrlEncode(crypto.getRandomValues(new Uint8Array(16))),
|
|
5259
|
-
expiresAt: input.expiresAt
|
|
5225
|
+
expiresAt: new Date(input.expiresAt).toISOString().replace(/\.\d{3}Z$/, "Z")
|
|
5260
5226
|
};
|
|
5261
5227
|
const requestBodyDigest = base64UrlEncode(new Uint8Array(await crypto.subtle.digest("SHA-256", new TextEncoder().encode((0, import_sdk_core8.canonicalizeEncryptionJson)(body)))));
|
|
5262
5228
|
const request = { ...body, requestBodyDigest };
|
|
5263
5229
|
const authorization = authorizationHeader(this.invokeAnyWithRuntimePermissions(serviceSession, [{ spaceId: session.spaceId, service: "kv", path: input.resourcePath, action: "tinycloud.kv/get" }]));
|
|
5264
|
-
const response = await fetch(`${this.config.host}/
|
|
5230
|
+
const response = await fetch(`${this.config.host}/policy/v3/deliveries/authorize`, {
|
|
5265
5231
|
method: "POST",
|
|
5266
5232
|
headers: { accept: "application/json", "content-type": "application/json", authorization },
|
|
5267
5233
|
body: (0, import_sdk_core8.canonicalizeEncryptionJson)(request)
|
|
5268
5234
|
});
|
|
5269
5235
|
if (!response.ok) throw new Error(`V3 share delivery authorization failed: ${response.status}`);
|
|
5270
|
-
|
|
5236
|
+
const verified = (0, import_sdk_core8.validateShareDeliveryAuthorizationV3Bytes)(new Uint8Array(await response.arrayBuffer()), {
|
|
5271
5237
|
request,
|
|
5272
|
-
|
|
5238
|
+
senderKeyDid: this.credentialHolderDid,
|
|
5273
5239
|
credentialsAudience: input.credentialsAudience
|
|
5274
5240
|
});
|
|
5241
|
+
void input.nodeProof;
|
|
5242
|
+
const requestDigest = new Uint8Array(await crypto.subtle.digest(
|
|
5243
|
+
"SHA-256",
|
|
5244
|
+
new TextEncoder().encode(`${import_sdk_core8.CREDENTIAL_INVITATION_REQUEST_DOMAIN}${(0, import_sdk_core8.canonicalizeEncryptionJson)(verified.request)}`)
|
|
5245
|
+
));
|
|
5246
|
+
return {
|
|
5247
|
+
...verified,
|
|
5248
|
+
proof: {
|
|
5249
|
+
alg: "EdDSA",
|
|
5250
|
+
kid: this.credentialHolderDid,
|
|
5251
|
+
signature: base64UrlEncode(await this.signSessionBytes(requestDigest))
|
|
5252
|
+
}
|
|
5253
|
+
};
|
|
5275
5254
|
}
|
|
5276
5255
|
async createRootDelegationForSharing(params, assertActive) {
|
|
5277
5256
|
try {
|
|
@@ -7821,6 +7800,7 @@ var import_sdk_core21 = require("@tinycloud/sdk-core");
|
|
|
7821
7800
|
parseCanonicalNetworkId,
|
|
7822
7801
|
parseExpiry,
|
|
7823
7802
|
parsePkhDid,
|
|
7803
|
+
parseSecretCatalogKey,
|
|
7824
7804
|
parseSpaceUri,
|
|
7825
7805
|
pkhDid,
|
|
7826
7806
|
principalDid,
|