@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
package/dist/index.cjs
CHANGED
|
@@ -8940,6 +8940,10 @@ function matchesInitialCiphertextDigest(bytes3, expected) {
|
|
|
8940
8940
|
function canonicalHashHex(value) {
|
|
8941
8941
|
return hex3((0, import_sha2565.sha256)(new TextEncoder().encode(canonicalize(value))));
|
|
8942
8942
|
}
|
|
8943
|
+
function registeredWrappedKeyDigest(encryptedSymmetricKey, pathBound) {
|
|
8944
|
+
const rawDigest = hex3((0, import_sha2565.sha256)(fromBase64(encryptedSymmetricKey, "v3 encrypted symmetric key")));
|
|
8945
|
+
return pathBound ? rawDigest : canonicalHashHex(encryptedSymmetricKey);
|
|
8946
|
+
}
|
|
8943
8947
|
async function aesGcmDecrypt(key, blob, aad) {
|
|
8944
8948
|
if (key.length !== 32 || blob.length < 28) throw new Error("encrypted content is malformed");
|
|
8945
8949
|
const cryptoKey = await crypto.subtle.importKey("raw", key, "AES-GCM", false, ["decrypt"]);
|
|
@@ -8966,7 +8970,7 @@ function parseV3InlineEncryptedEnvelope(bytes3, expected) {
|
|
|
8966
8970
|
const record = value;
|
|
8967
8971
|
const allowed = ["v", "networkId", "keyPath", "alg", "keyVersion", "encryptedSymmetricKey", "encryptedSymmetricKeyHash", "ciphertext", "aad", "metadata"];
|
|
8968
8972
|
const source = expected.contentSource;
|
|
8969
|
-
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" ||
|
|
8973
|
+
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"))) {
|
|
8970
8974
|
throw new Error("encrypted content envelope binding is invalid");
|
|
8971
8975
|
}
|
|
8972
8976
|
return record;
|
|
@@ -9087,7 +9091,11 @@ var ShareRecipientClient = class {
|
|
|
9087
9091
|
this.session = { sessionId: delegation.sessionCid, expiresAt: new Date(compact.payload.exp * 1e3).toISOString(), actions: envelope.actions, resource: envelope.resource };
|
|
9088
9092
|
return this.session;
|
|
9089
9093
|
}
|
|
9090
|
-
/**
|
|
9094
|
+
/**
|
|
9095
|
+
* Decrypt unscoped v1 or path-bound v2 content. The wrapped-key digest is compared by source kind: the raw-byte digest
|
|
9096
|
+
* when the source has `encryptionKeyPath`, the canonical hash for a no-path source. The envelope's own canonical hash
|
|
9097
|
+
* is checked independently either way.
|
|
9098
|
+
*/
|
|
9091
9099
|
async decryptV3Content(bytes3) {
|
|
9092
9100
|
const envelope = this.options.envelope;
|
|
9093
9101
|
const signer = this.nativeSigner ?? this.signer;
|