@tinycloud/node-sdk 3.0.0-beta.6 → 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-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 +26 -57
- 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 +28 -59
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +26 -57
- 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 +28 -59
- 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;
|
|
@@ -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
|
@@ -5184,63 +5184,19 @@ 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) {
|
|
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 });
|
|
5198
|
+
void input;
|
|
5199
|
+
throw new Error("Policy/v2 share delivery is retired; use authorizeShareDeliveryV3");
|
|
5244
5200
|
}
|
|
5245
5201
|
/** Authorize one short-lived v3 delivery against the signed v3 envelope and registered roots. */
|
|
5246
5202
|
async authorizeShareDeliveryV3(input) {
|
|
@@ -5256,22 +5212,35 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
5256
5212
|
shareUrl: input.shareUrl,
|
|
5257
5213
|
documentName: input.documentName,
|
|
5258
5214
|
jti: base64UrlEncode(crypto.getRandomValues(new Uint8Array(16))),
|
|
5259
|
-
expiresAt: input.expiresAt
|
|
5215
|
+
expiresAt: new Date(input.expiresAt).toISOString().replace(/\.\d{3}Z$/, "Z")
|
|
5260
5216
|
};
|
|
5261
5217
|
const requestBodyDigest = base64UrlEncode(new Uint8Array(await crypto.subtle.digest("SHA-256", new TextEncoder().encode((0, import_sdk_core8.canonicalizeEncryptionJson)(body)))));
|
|
5262
5218
|
const request = { ...body, requestBodyDigest };
|
|
5263
5219
|
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}/
|
|
5220
|
+
const response = await fetch(`${this.config.host}/policy/v3/deliveries/authorize`, {
|
|
5265
5221
|
method: "POST",
|
|
5266
5222
|
headers: { accept: "application/json", "content-type": "application/json", authorization },
|
|
5267
5223
|
body: (0, import_sdk_core8.canonicalizeEncryptionJson)(request)
|
|
5268
5224
|
});
|
|
5269
5225
|
if (!response.ok) throw new Error(`V3 share delivery authorization failed: ${response.status}`);
|
|
5270
|
-
|
|
5226
|
+
const verified = (0, import_sdk_core8.validateShareDeliveryAuthorizationV3Bytes)(new Uint8Array(await response.arrayBuffer()), {
|
|
5271
5227
|
request,
|
|
5272
|
-
|
|
5228
|
+
senderKeyDid: this.credentialHolderDid,
|
|
5273
5229
|
credentialsAudience: input.credentialsAudience
|
|
5274
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
|
+
};
|
|
5275
5244
|
}
|
|
5276
5245
|
async createRootDelegationForSharing(params, assertActive) {
|
|
5277
5246
|
try {
|