@tinycloud/share-sdk 1.4.1-beta.3 → 1.4.1-beta.4
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/index.cjs +10 -2
- 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 +10 -2
- package/dist/index.js.map +1 -1
- package/dist/{web-recipient-entry-Bn3yRB7g.d.cts → web-recipient-entry-DF_BMFq8.d.cts} +5 -1
- package/dist/{web-recipient-entry-CTFoIH8l.d.ts → web-recipient-entry-mcC6d4ao.d.ts} +5 -1
- package/dist/web-recipient.cjs +10 -2
- package/dist/web-recipient.cjs.map +1 -1
- package/dist/web-recipient.d.cts +1 -1
- package/dist/web-recipient.d.ts +1 -1
- package/dist/web-recipient.js +10 -2
- package/dist/web-recipient.js.map +1 -1
- package/package.json +1 -1
|
@@ -226,7 +226,11 @@ declare class ShareRecipientClient {
|
|
|
226
226
|
authorize(envelope: ShareEnvelopeV2): Promise<ShareAuthorizedContent>;
|
|
227
227
|
establishPolicySession(): Promise<SharePolicySession>;
|
|
228
228
|
private establishV3;
|
|
229
|
-
/**
|
|
229
|
+
/**
|
|
230
|
+
* Decrypt unscoped v1 or path-bound v2 content. The wrapped-key digest is compared by source kind: the raw-byte digest
|
|
231
|
+
* when the source has `encryptionKeyPath`, the canonical hash for a no-path source. The envelope's own canonical hash
|
|
232
|
+
* is checked independently either way.
|
|
233
|
+
*/
|
|
230
234
|
decryptV3Content(bytes: Uint8Array): Promise<{
|
|
231
235
|
readonly bytes: Uint8Array;
|
|
232
236
|
readonly mediaType: string;
|
|
@@ -226,7 +226,11 @@ declare class ShareRecipientClient {
|
|
|
226
226
|
authorize(envelope: ShareEnvelopeV2): Promise<ShareAuthorizedContent>;
|
|
227
227
|
establishPolicySession(): Promise<SharePolicySession>;
|
|
228
228
|
private establishV3;
|
|
229
|
-
/**
|
|
229
|
+
/**
|
|
230
|
+
* Decrypt unscoped v1 or path-bound v2 content. The wrapped-key digest is compared by source kind: the raw-byte digest
|
|
231
|
+
* when the source has `encryptionKeyPath`, the canonical hash for a no-path source. The envelope's own canonical hash
|
|
232
|
+
* is checked independently either way.
|
|
233
|
+
*/
|
|
230
234
|
decryptV3Content(bytes: Uint8Array): Promise<{
|
|
231
235
|
readonly bytes: Uint8Array;
|
|
232
236
|
readonly mediaType: string;
|
package/dist/web-recipient.cjs
CHANGED
|
@@ -6249,6 +6249,10 @@ function matchesInitialCiphertextDigest(bytes, expected) {
|
|
|
6249
6249
|
function canonicalHashHex(value) {
|
|
6250
6250
|
return hex2((0, import_sha2562.sha256)(new TextEncoder().encode(canonicalize(value))));
|
|
6251
6251
|
}
|
|
6252
|
+
function registeredWrappedKeyDigest(encryptedSymmetricKey, pathBound) {
|
|
6253
|
+
const rawDigest = hex2((0, import_sha2562.sha256)(fromBase64(encryptedSymmetricKey, "v3 encrypted symmetric key")));
|
|
6254
|
+
return pathBound ? rawDigest : canonicalHashHex(encryptedSymmetricKey);
|
|
6255
|
+
}
|
|
6252
6256
|
async function aesGcmDecrypt(key, blob, aad) {
|
|
6253
6257
|
if (key.length !== 32 || blob.length < 28) throw new Error("encrypted content is malformed");
|
|
6254
6258
|
const cryptoKey = await crypto.subtle.importKey("raw", key, "AES-GCM", false, ["decrypt"]);
|
|
@@ -6275,7 +6279,7 @@ function parseV3InlineEncryptedEnvelope(bytes, expected) {
|
|
|
6275
6279
|
const record = value;
|
|
6276
6280
|
const allowed = ["v", "networkId", "keyPath", "alg", "keyVersion", "encryptedSymmetricKey", "encryptedSymmetricKeyHash", "ciphertext", "aad", "metadata"];
|
|
6277
6281
|
const source = expected.contentSource;
|
|
6278
|
-
if (Object.keys(record).some((key) => !allowed.includes(key)) || record.v !== (source.encryptionKeyPath === void 0 ? 1 : 2) || record.networkId !== source.encryptionNetwork || record.networkId !== expected.encryptionNetwork || record.keyPath !== source.encryptionKeyPath || record.keyPath !== void 0 && record.keyPath !== `share/${expected.shareId}` || record.alg !== "x25519-aes256gcm/v1" || record.keyVersion !== source.keyVersion || typeof record.encryptedSymmetricKey !== "string" || typeof record.encryptedSymmetricKeyHash !== "string" ||
|
|
6282
|
+
if (Object.keys(record).some((key) => !allowed.includes(key)) || record.v !== (source.encryptionKeyPath === void 0 ? 1 : 2) || record.networkId !== source.encryptionNetwork || record.networkId !== expected.encryptionNetwork || record.keyPath !== source.encryptionKeyPath || record.keyPath !== void 0 && record.keyPath !== `share/${expected.shareId}` || record.alg !== "x25519-aes256gcm/v1" || record.keyVersion !== source.keyVersion || typeof record.encryptedSymmetricKey !== "string" || typeof record.encryptedSymmetricKeyHash !== "string" || registeredWrappedKeyDigest(record.encryptedSymmetricKey, source.encryptionKeyPath !== void 0) !== source.encryptedSymmetricKeyDigestHex || record.encryptedSymmetricKeyHash !== canonicalHashHex(record.encryptedSymmetricKey) || typeof record.ciphertext !== "string" || record.aad !== void 0 && typeof record.aad !== "string" || record.metadata !== void 0 && (record.metadata === null || typeof record.metadata !== "object" || Array.isArray(record.metadata) || Object.values(record.metadata).some((entry) => typeof entry !== "string"))) {
|
|
6279
6283
|
throw new Error("encrypted content envelope binding is invalid");
|
|
6280
6284
|
}
|
|
6281
6285
|
return record;
|
|
@@ -6396,7 +6400,11 @@ var ShareRecipientClient = class {
|
|
|
6396
6400
|
this.session = { sessionId: delegation.sessionCid, expiresAt: new Date(compact.payload.exp * 1e3).toISOString(), actions: envelope.actions, resource: envelope.resource };
|
|
6397
6401
|
return this.session;
|
|
6398
6402
|
}
|
|
6399
|
-
/**
|
|
6403
|
+
/**
|
|
6404
|
+
* Decrypt unscoped v1 or path-bound v2 content. The wrapped-key digest is compared by source kind: the raw-byte digest
|
|
6405
|
+
* when the source has `encryptionKeyPath`, the canonical hash for a no-path source. The envelope's own canonical hash
|
|
6406
|
+
* is checked independently either way.
|
|
6407
|
+
*/
|
|
6400
6408
|
async decryptV3Content(bytes) {
|
|
6401
6409
|
const envelope = this.options.envelope;
|
|
6402
6410
|
const signer = this.nativeSigner ?? this.signer;
|