@tinycloud/node-sdk 3.0.0-beta.5 → 3.0.0-beta.7
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-C6Czyr52.d.cts → core-WJQ9KiSD.d.cts} +21 -4
- package/dist/{core-C6Czyr52.d.ts → core-WJQ9KiSD.d.ts} +21 -4
- package/dist/core.cjs +36 -36
- 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 +39 -38
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +36 -36
- 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 +39 -38
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -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;
|
|
@@ -1836,6 +1836,23 @@ declare class TinyCloudNode {
|
|
|
1836
1836
|
/** The trusted OpenCredentials witness origin from the same trust bundle as `nodeProof`. */
|
|
1837
1837
|
readonly credentialsAudience: string;
|
|
1838
1838
|
}): Promise<ShareDeliveryAuthorizationReceipt>;
|
|
1839
|
+
/** Authorize one short-lived v3 delivery against the signed v3 envelope and registered roots. */
|
|
1840
|
+
authorizeShareDeliveryV3(input: {
|
|
1841
|
+
readonly envelope: Record<string, CanonicalJson | undefined>;
|
|
1842
|
+
readonly sealedEnvelope: string;
|
|
1843
|
+
readonly envelopeKey: string;
|
|
1844
|
+
readonly shareCid: string;
|
|
1845
|
+
readonly resourcePath: string;
|
|
1846
|
+
readonly recipientEmail: string;
|
|
1847
|
+
readonly shareUrl: string;
|
|
1848
|
+
readonly documentName: string;
|
|
1849
|
+
readonly expiresAt: string;
|
|
1850
|
+
readonly nodeProof: {
|
|
1851
|
+
readonly kid: string;
|
|
1852
|
+
readonly publicKey: Uint8Array;
|
|
1853
|
+
};
|
|
1854
|
+
readonly credentialsAudience: string;
|
|
1855
|
+
}): Promise<ShareDeliveryAuthorizationV3Receipt>;
|
|
1839
1856
|
private createRootDelegationForSharing;
|
|
1840
1857
|
/**
|
|
1841
1858
|
* Track a received delegation in the capability registry.
|
|
@@ -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;
|
|
@@ -1836,6 +1836,23 @@ declare class TinyCloudNode {
|
|
|
1836
1836
|
/** The trusted OpenCredentials witness origin from the same trust bundle as `nodeProof`. */
|
|
1837
1837
|
readonly credentialsAudience: string;
|
|
1838
1838
|
}): Promise<ShareDeliveryAuthorizationReceipt>;
|
|
1839
|
+
/** Authorize one short-lived v3 delivery against the signed v3 envelope and registered roots. */
|
|
1840
|
+
authorizeShareDeliveryV3(input: {
|
|
1841
|
+
readonly envelope: Record<string, CanonicalJson | undefined>;
|
|
1842
|
+
readonly sealedEnvelope: string;
|
|
1843
|
+
readonly envelopeKey: string;
|
|
1844
|
+
readonly shareCid: string;
|
|
1845
|
+
readonly resourcePath: string;
|
|
1846
|
+
readonly recipientEmail: string;
|
|
1847
|
+
readonly shareUrl: string;
|
|
1848
|
+
readonly documentName: string;
|
|
1849
|
+
readonly expiresAt: string;
|
|
1850
|
+
readonly nodeProof: {
|
|
1851
|
+
readonly kid: string;
|
|
1852
|
+
readonly publicKey: Uint8Array;
|
|
1853
|
+
};
|
|
1854
|
+
readonly credentialsAudience: string;
|
|
1855
|
+
}): Promise<ShareDeliveryAuthorizationV3Receipt>;
|
|
1839
1856
|
private createRootDelegationForSharing;
|
|
1840
1857
|
/**
|
|
1841
1858
|
* Track a received delegation in the capability registry.
|
package/dist/core.cjs
CHANGED
|
@@ -5184,63 +5184,63 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
5184
5184
|
}
|
|
5185
5185
|
};
|
|
5186
5186
|
}
|
|
5187
|
-
/** Register a policy
|
|
5188
|
-
async
|
|
5187
|
+
/** Register a signed policy and sibling roots with this Node's Policy/v3 runtime. */
|
|
5188
|
+
async registerPolicy(params) {
|
|
5189
5189
|
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
|
-
})
|
|
5190
|
+
return (0, import_sdk_core8.registerPolicyV3)({
|
|
5191
|
+
...params,
|
|
5192
|
+
nodeOrigin: this.config.host,
|
|
5193
|
+
fetch: globalThis.fetch.bind(globalThis)
|
|
5200
5194
|
});
|
|
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
5195
|
}
|
|
5213
|
-
/**
|
|
5196
|
+
/** @deprecated Policy/v2 delivery transport is retired. Use authorizeShareDeliveryV3. */
|
|
5214
5197
|
async authorizeShareDelivery(input) {
|
|
5198
|
+
void input;
|
|
5199
|
+
throw new Error("Policy/v2 share delivery is retired; use authorizeShareDeliveryV3");
|
|
5200
|
+
}
|
|
5201
|
+
/** Authorize one short-lived v3 delivery against the signed v3 envelope and registered roots. */
|
|
5202
|
+
async authorizeShareDeliveryV3(input) {
|
|
5215
5203
|
const session = this.currentTinyCloudSession();
|
|
5216
5204
|
const serviceSession = this._serviceContext?.session;
|
|
5217
5205
|
if (!session || !serviceSession) throw new Error("Share delivery requires an authenticated session");
|
|
5218
5206
|
const body = {
|
|
5219
|
-
|
|
5207
|
+
envelope: input.envelope,
|
|
5208
|
+
sealedEnvelope: input.sealedEnvelope,
|
|
5209
|
+
envelopeKey: input.envelopeKey,
|
|
5220
5210
|
shareCid: input.shareCid,
|
|
5221
|
-
shareId: input.shareId,
|
|
5222
|
-
registrationCid: input.registrationCid,
|
|
5223
|
-
policyCid: input.policyCid,
|
|
5224
|
-
delegationCid: input.delegationCid,
|
|
5225
|
-
enforcementDelegationCid: input.enforcementDelegationCid,
|
|
5226
5211
|
recipientEmail: input.recipientEmail,
|
|
5227
5212
|
shareUrl: input.shareUrl,
|
|
5228
5213
|
documentName: input.documentName,
|
|
5229
5214
|
jti: base64UrlEncode(crypto.getRandomValues(new Uint8Array(16))),
|
|
5230
|
-
|
|
5231
|
-
expiresAt: input.expiresAt
|
|
5215
|
+
expiresAt: new Date(input.expiresAt).toISOString().replace(/\.\d{3}Z$/, "Z")
|
|
5232
5216
|
};
|
|
5233
5217
|
const requestBodyDigest = base64UrlEncode(new Uint8Array(await crypto.subtle.digest("SHA-256", new TextEncoder().encode((0, import_sdk_core8.canonicalizeEncryptionJson)(body)))));
|
|
5234
5218
|
const request = { ...body, requestBodyDigest };
|
|
5235
5219
|
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}/
|
|
5220
|
+
const response = await fetch(`${this.config.host}/policy/v3/deliveries/authorize`, {
|
|
5237
5221
|
method: "POST",
|
|
5238
5222
|
headers: { accept: "application/json", "content-type": "application/json", authorization },
|
|
5239
5223
|
body: (0, import_sdk_core8.canonicalizeEncryptionJson)(request)
|
|
5240
5224
|
});
|
|
5241
|
-
if (!response.ok) throw new Error(`
|
|
5242
|
-
const
|
|
5243
|
-
|
|
5225
|
+
if (!response.ok) throw new Error(`V3 share delivery authorization failed: ${response.status}`);
|
|
5226
|
+
const verified = (0, import_sdk_core8.validateShareDeliveryAuthorizationV3Bytes)(new Uint8Array(await response.arrayBuffer()), {
|
|
5227
|
+
request,
|
|
5228
|
+
senderKeyDid: this.credentialHolderDid,
|
|
5229
|
+
credentialsAudience: input.credentialsAudience
|
|
5230
|
+
});
|
|
5231
|
+
void input.nodeProof;
|
|
5232
|
+
const requestDigest = new Uint8Array(await crypto.subtle.digest(
|
|
5233
|
+
"SHA-256",
|
|
5234
|
+
new TextEncoder().encode(`${import_sdk_core8.CREDENTIAL_INVITATION_REQUEST_DOMAIN}${(0, import_sdk_core8.canonicalizeEncryptionJson)(verified.request)}`)
|
|
5235
|
+
));
|
|
5236
|
+
return {
|
|
5237
|
+
...verified,
|
|
5238
|
+
proof: {
|
|
5239
|
+
alg: "EdDSA",
|
|
5240
|
+
kid: this.credentialHolderDid,
|
|
5241
|
+
signature: base64UrlEncode(await this.signSessionBytes(requestDigest))
|
|
5242
|
+
}
|
|
5243
|
+
};
|
|
5244
5244
|
}
|
|
5245
5245
|
async createRootDelegationForSharing(params, assertActive) {
|
|
5246
5246
|
try {
|