@tinycloud/node-sdk 3.0.0-beta.2 → 3.0.0-beta.6
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-UWQ41yuo.d.cts} +18 -1
- package/dist/{core-C6Czyr52.d.ts → core-UWQ41yuo.d.ts} +18 -1
- package/dist/core.cjs +31 -0
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/core.js +32 -0
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +31 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +32 -0
- 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, RegisterOwnerSharePolicyParams, OwnerSharePolicyRegistrationReceipt, ShareDeliveryAuthorizationReceipt, IDataVaultService, IEncryptionService, NetworkDescriptor, ISecretsService, ICapabilityKeyRegistry, DelegationManager, ISpaceService, ISpace, ISharingService, CreateDelegationParams, DelegationResult, DelegationRevocationReceipt, DelegationStatus, ResolvedDelegate, KeyProvider, JWK } from '@tinycloud/sdk-core';
|
|
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, RegisterOwnerSharePolicyParams, OwnerSharePolicyRegistrationReceipt, 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
|
|
|
@@ -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, RegisterOwnerSharePolicyParams, OwnerSharePolicyRegistrationReceipt, ShareDeliveryAuthorizationReceipt, IDataVaultService, IEncryptionService, NetworkDescriptor, ISecretsService, ICapabilityKeyRegistry, DelegationManager, ISpaceService, ISpace, ISharingService, CreateDelegationParams, DelegationResult, DelegationRevocationReceipt, DelegationStatus, ResolvedDelegate, KeyProvider, JWK } from '@tinycloud/sdk-core';
|
|
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, RegisterOwnerSharePolicyParams, OwnerSharePolicyRegistrationReceipt, 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
|
|
|
@@ -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
|
@@ -5242,6 +5242,37 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
5242
5242
|
const responseBytes = new Uint8Array(await response.arrayBuffer());
|
|
5243
5243
|
return (0, import_sdk_core8.validateShareDeliveryAuthorizationBytes)(responseBytes, { request, nodeProof: input.nodeProof, credentialsAudience: input.credentialsAudience });
|
|
5244
5244
|
}
|
|
5245
|
+
/** Authorize one short-lived v3 delivery against the signed v3 envelope and registered roots. */
|
|
5246
|
+
async authorizeShareDeliveryV3(input) {
|
|
5247
|
+
const session = this.currentTinyCloudSession();
|
|
5248
|
+
const serviceSession = this._serviceContext?.session;
|
|
5249
|
+
if (!session || !serviceSession) throw new Error("Share delivery requires an authenticated session");
|
|
5250
|
+
const body = {
|
|
5251
|
+
envelope: input.envelope,
|
|
5252
|
+
sealedEnvelope: input.sealedEnvelope,
|
|
5253
|
+
envelopeKey: input.envelopeKey,
|
|
5254
|
+
shareCid: input.shareCid,
|
|
5255
|
+
recipientEmail: input.recipientEmail,
|
|
5256
|
+
shareUrl: input.shareUrl,
|
|
5257
|
+
documentName: input.documentName,
|
|
5258
|
+
jti: base64UrlEncode(crypto.getRandomValues(new Uint8Array(16))),
|
|
5259
|
+
expiresAt: input.expiresAt
|
|
5260
|
+
};
|
|
5261
|
+
const requestBodyDigest = base64UrlEncode(new Uint8Array(await crypto.subtle.digest("SHA-256", new TextEncoder().encode((0, import_sdk_core8.canonicalizeEncryptionJson)(body)))));
|
|
5262
|
+
const request = { ...body, requestBodyDigest };
|
|
5263
|
+
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}/share/v3/deliveries/authorize`, {
|
|
5265
|
+
method: "POST",
|
|
5266
|
+
headers: { accept: "application/json", "content-type": "application/json", authorization },
|
|
5267
|
+
body: (0, import_sdk_core8.canonicalizeEncryptionJson)(request)
|
|
5268
|
+
});
|
|
5269
|
+
if (!response.ok) throw new Error(`V3 share delivery authorization failed: ${response.status}`);
|
|
5270
|
+
return (0, import_sdk_core8.validateShareDeliveryAuthorizationV3Bytes)(new Uint8Array(await response.arrayBuffer()), {
|
|
5271
|
+
request,
|
|
5272
|
+
nodeProof: input.nodeProof,
|
|
5273
|
+
credentialsAudience: input.credentialsAudience
|
|
5274
|
+
});
|
|
5275
|
+
}
|
|
5245
5276
|
async createRootDelegationForSharing(params, assertActive) {
|
|
5246
5277
|
try {
|
|
5247
5278
|
return (await this.createOwnerDelegation({
|