@tinycloud/share-sdk 1.4.4 → 1.5.0-beta.0
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/README.md +9 -12
- package/dist/{addressed-publish-DorqWQJ8.d.ts → addressed-publish-D4IWNXuw.d.ts} +9 -29
- package/dist/{addressed-publish-BPFFqD5s.d.cts → addressed-publish-qp_bEVYu.d.cts} +9 -29
- package/dist/index.cjs +2 -27
- 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 +2 -27
- package/dist/index.js.map +1 -1
- package/dist/share-root.d.cts +1 -1
- package/dist/share-root.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -2,8 +2,8 @@ export { D as DEFAULT_MAX_CONTENT_BLOB_BYTES, a as DEFAULT_MAX_SEALED_BLOB_BYTES
|
|
|
2
2
|
export { C as CreateOwnerDelegationParams, h as DEFAULT_SHARE_LIFETIME_MS, D as DelegatedShareKey, M as MAX_CONTENT_BYTES, i as OWNER_SHARE_REGISTRATION_DOMAIN, j as OwnerDelegationPermission, g as OwnerDelegationReceipt, O as OwnerShareAction, k as OwnerShareDecryption, a as OwnerShareMatcher, l as OwnerSharePolicyRegistration, b as OwnerSharePolicyRegistrationReceipt, m as OwnerSharePolicyV2, c as PublishedShare, P as PublishedShareDeliveryMaterial, n as PublishedShareMetadata, R as RegisterOwnerSharePolicyParams, o as SHARE_CONTENT_LIMIT, p as SHARE_PUBLISH_RESULT_VERSION, f as SharePublishError, q as SharePublishErrorCode, e as SharePublishOptions, d as SharePublishTarget, S as SignedDelegation, r as canonicalOwnerSharePolicy, s as computeOwnerShareRegistrationCid, t as createDelegatedShareKey, u as createPolicyEnforcementDelegation, v as redactPublishedShare, w as restoreDelegatedShareKey, x as validateOwnerSharePolicyRegistration, y as validateOwnerSharePolicyRegistrationBytes } from './owner-policy-aPmXIR3e.cjs';
|
|
3
3
|
import { ShareEnvelopeV2, ArtifactPin, UnsignedShareEnvelopeV3, ShareEnvelopeV3 } from '@tinycloud/share-envelope';
|
|
4
4
|
export { CheckBearerDelegationOptions, DelegationCheckResult, canonicalize, checkBearerDelegation, fromBase64Url, requiredResourceUri, resourceUriCovers, toBase64Url } from '@tinycloud/share-envelope';
|
|
5
|
-
import { T as TargetPublishOutcome, c as TargetPublishInput, S as ShareTarget } from './addressed-publish-
|
|
6
|
-
export { d as ADDRESSED_SHARE_TOO_LARGE_MESSAGE, e as AddressedContentSourceError, f as AddressedContentSourceErrorCode, A as AddressedOwnerRootInput, a as AddressedOwnerRootReceipt, g as AddressedPolicyRegistrationInput, h as AddressedPolicyRegistrationReceipt, b as AddressedPublishAuthority, i as AddressedShareBoundInput, j as AddressedShareKeyClient, k as AddressedShareOverLimitError, l as AddressedSharePublishOptions, m as AddressedShareRequest, n as AddressedShareWrites, E as EncryptedAddressedContent, P as PathBoundContentSource, o as PathBoundEnvelope, p as PathBoundPermissionEntry, q as PathBoundSharePlan, r as PreparedAddressedShare, s as TargetPublishAdapter, t as addressedCredentialRequirement, u as addressedShareBodyUpperBound, v as assertAddressedShareFits, w as assertPathBoundContentSource, x as bindPathBoundContentSource, y as defaultEncryptionNetworkForOwner, z as encryptAddressedShareContent, B as normalizeShareTarget, C as pathBoundKeyPath, D as pathBoundSessionPermissions, F as pathBoundStoredBytes, G as planPathBoundShare, H as prepareAddressedShare, I as publishAddressedShare, J as publishTargetShare, K as targetAuthorizationMethod, L as wrappedKeyDigestHex } from './addressed-publish-
|
|
5
|
+
import { T as TargetPublishOutcome, c as TargetPublishInput, S as ShareTarget } from './addressed-publish-qp_bEVYu.cjs';
|
|
6
|
+
export { d as ADDRESSED_SHARE_TOO_LARGE_MESSAGE, e as AddressedContentSourceError, f as AddressedContentSourceErrorCode, A as AddressedOwnerRootInput, a as AddressedOwnerRootReceipt, g as AddressedPolicyRegistrationInput, h as AddressedPolicyRegistrationReceipt, b as AddressedPublishAuthority, i as AddressedShareBoundInput, j as AddressedShareKeyClient, k as AddressedShareOverLimitError, l as AddressedSharePublishOptions, m as AddressedShareRequest, n as AddressedShareWrites, E as EncryptedAddressedContent, P as PathBoundContentSource, o as PathBoundEnvelope, p as PathBoundPermissionEntry, q as PathBoundSharePlan, r as PreparedAddressedShare, s as TargetPublishAdapter, t as addressedCredentialRequirement, u as addressedShareBodyUpperBound, v as assertAddressedShareFits, w as assertPathBoundContentSource, x as bindPathBoundContentSource, y as defaultEncryptionNetworkForOwner, z as encryptAddressedShareContent, B as normalizeShareTarget, C as pathBoundKeyPath, D as pathBoundSessionPermissions, F as pathBoundStoredBytes, G as planPathBoundShare, H as prepareAddressedShare, I as publishAddressedShare, J as publishTargetShare, K as targetAuthorizationMethod, L as wrappedKeyDigestHex } from './addressed-publish-qp_bEVYu.cjs';
|
|
7
7
|
import { S as SenderShareRecord, a as SenderShareRecordStorage } from './history-Bg25JIsi.cjs';
|
|
8
8
|
export { E as EncryptedSenderShareHistory, b as EncryptedShareHistoryStorage, M as MemoryEncryptedShareHistoryStorage, c as MemorySenderShareKeyStorage, d as MemorySenderShareRecordStorage, e as SenderShareKeyStorage, f as SenderShareRecordProofs, g as SenderShareRevocationScope, h as SenderShareStore, i as historyRecordForPublishedShare } from './history-Bg25JIsi.cjs';
|
|
9
9
|
import { b as ShareAuthorizationResult, c as ShareAuthorizationAdapter } from './authorization-CmP1skO8.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ export { D as DEFAULT_MAX_CONTENT_BLOB_BYTES, a as DEFAULT_MAX_SEALED_BLOB_BYTES
|
|
|
2
2
|
export { C as CreateOwnerDelegationParams, h as DEFAULT_SHARE_LIFETIME_MS, D as DelegatedShareKey, M as MAX_CONTENT_BYTES, i as OWNER_SHARE_REGISTRATION_DOMAIN, j as OwnerDelegationPermission, g as OwnerDelegationReceipt, O as OwnerShareAction, k as OwnerShareDecryption, a as OwnerShareMatcher, l as OwnerSharePolicyRegistration, b as OwnerSharePolicyRegistrationReceipt, m as OwnerSharePolicyV2, c as PublishedShare, P as PublishedShareDeliveryMaterial, n as PublishedShareMetadata, R as RegisterOwnerSharePolicyParams, o as SHARE_CONTENT_LIMIT, p as SHARE_PUBLISH_RESULT_VERSION, f as SharePublishError, q as SharePublishErrorCode, e as SharePublishOptions, d as SharePublishTarget, S as SignedDelegation, r as canonicalOwnerSharePolicy, s as computeOwnerShareRegistrationCid, t as createDelegatedShareKey, u as createPolicyEnforcementDelegation, v as redactPublishedShare, w as restoreDelegatedShareKey, x as validateOwnerSharePolicyRegistration, y as validateOwnerSharePolicyRegistrationBytes } from './owner-policy-aPmXIR3e.js';
|
|
3
3
|
import { ShareEnvelopeV2, ArtifactPin, UnsignedShareEnvelopeV3, ShareEnvelopeV3 } from '@tinycloud/share-envelope';
|
|
4
4
|
export { CheckBearerDelegationOptions, DelegationCheckResult, canonicalize, checkBearerDelegation, fromBase64Url, requiredResourceUri, resourceUriCovers, toBase64Url } from '@tinycloud/share-envelope';
|
|
5
|
-
import { T as TargetPublishOutcome, c as TargetPublishInput, S as ShareTarget } from './addressed-publish-
|
|
6
|
-
export { d as ADDRESSED_SHARE_TOO_LARGE_MESSAGE, e as AddressedContentSourceError, f as AddressedContentSourceErrorCode, A as AddressedOwnerRootInput, a as AddressedOwnerRootReceipt, g as AddressedPolicyRegistrationInput, h as AddressedPolicyRegistrationReceipt, b as AddressedPublishAuthority, i as AddressedShareBoundInput, j as AddressedShareKeyClient, k as AddressedShareOverLimitError, l as AddressedSharePublishOptions, m as AddressedShareRequest, n as AddressedShareWrites, E as EncryptedAddressedContent, P as PathBoundContentSource, o as PathBoundEnvelope, p as PathBoundPermissionEntry, q as PathBoundSharePlan, r as PreparedAddressedShare, s as TargetPublishAdapter, t as addressedCredentialRequirement, u as addressedShareBodyUpperBound, v as assertAddressedShareFits, w as assertPathBoundContentSource, x as bindPathBoundContentSource, y as defaultEncryptionNetworkForOwner, z as encryptAddressedShareContent, B as normalizeShareTarget, C as pathBoundKeyPath, D as pathBoundSessionPermissions, F as pathBoundStoredBytes, G as planPathBoundShare, H as prepareAddressedShare, I as publishAddressedShare, J as publishTargetShare, K as targetAuthorizationMethod, L as wrappedKeyDigestHex } from './addressed-publish-
|
|
5
|
+
import { T as TargetPublishOutcome, c as TargetPublishInput, S as ShareTarget } from './addressed-publish-D4IWNXuw.js';
|
|
6
|
+
export { d as ADDRESSED_SHARE_TOO_LARGE_MESSAGE, e as AddressedContentSourceError, f as AddressedContentSourceErrorCode, A as AddressedOwnerRootInput, a as AddressedOwnerRootReceipt, g as AddressedPolicyRegistrationInput, h as AddressedPolicyRegistrationReceipt, b as AddressedPublishAuthority, i as AddressedShareBoundInput, j as AddressedShareKeyClient, k as AddressedShareOverLimitError, l as AddressedSharePublishOptions, m as AddressedShareRequest, n as AddressedShareWrites, E as EncryptedAddressedContent, P as PathBoundContentSource, o as PathBoundEnvelope, p as PathBoundPermissionEntry, q as PathBoundSharePlan, r as PreparedAddressedShare, s as TargetPublishAdapter, t as addressedCredentialRequirement, u as addressedShareBodyUpperBound, v as assertAddressedShareFits, w as assertPathBoundContentSource, x as bindPathBoundContentSource, y as defaultEncryptionNetworkForOwner, z as encryptAddressedShareContent, B as normalizeShareTarget, C as pathBoundKeyPath, D as pathBoundSessionPermissions, F as pathBoundStoredBytes, G as planPathBoundShare, H as prepareAddressedShare, I as publishAddressedShare, J as publishTargetShare, K as targetAuthorizationMethod, L as wrappedKeyDigestHex } from './addressed-publish-D4IWNXuw.js';
|
|
7
7
|
import { S as SenderShareRecord, a as SenderShareRecordStorage } from './history-kwJxrZgq.js';
|
|
8
8
|
export { E as EncryptedSenderShareHistory, b as EncryptedShareHistoryStorage, M as MemoryEncryptedShareHistoryStorage, c as MemorySenderShareKeyStorage, d as MemorySenderShareRecordStorage, e as SenderShareKeyStorage, f as SenderShareRecordProofs, g as SenderShareRevocationScope, h as SenderShareStore, i as historyRecordForPublishedShare } from './history-kwJxrZgq.js';
|
|
9
9
|
import { b as ShareAuthorizationResult, c as ShareAuthorizationAdapter } from './authorization-CmP1skO8.js';
|
package/dist/index.js
CHANGED
|
@@ -6520,7 +6520,7 @@ function canonicalKeyHashHex(encryptedSymmetricKey) {
|
|
|
6520
6520
|
}
|
|
6521
6521
|
function pathBoundSessionPermissions(input) {
|
|
6522
6522
|
const encryptionNetwork = assertNetwork(input.encryptionNetwork);
|
|
6523
|
-
return [{ service: "tinycloud.encryption", path: `${encryptionNetwork}/share/`, actions: ["tinycloud.encryption/decrypt"
|
|
6523
|
+
return [{ service: "tinycloud.encryption", path: `${encryptionNetwork}/share/`, actions: ["tinycloud.encryption/decrypt"] }];
|
|
6524
6524
|
}
|
|
6525
6525
|
function planPathBoundShare(input) {
|
|
6526
6526
|
const keyPath = pathBoundKeyPath(input.shareId);
|
|
@@ -6531,9 +6531,7 @@ function planPathBoundShare(input) {
|
|
|
6531
6531
|
encryptionNetwork,
|
|
6532
6532
|
keyPath,
|
|
6533
6533
|
keyResource,
|
|
6534
|
-
|
|
6535
|
-
sessionPermissions: pathBoundSessionPermissions({ encryptionNetwork }),
|
|
6536
|
-
registrationPermissions: [{ service: "tinycloud.encryption", path: `${encryptionNetwork}/share/`, actions: ["tinycloud.encryption/decrypt"] }],
|
|
6534
|
+
registrationPermissions: pathBoundSessionPermissions({ encryptionNetwork }),
|
|
6537
6535
|
encryptOptions: (extra) => ({ networkId: encryptionNetwork, ...extra?.metadata === void 0 ? {} : { metadata: { ...extra.metadata } } })
|
|
6538
6536
|
};
|
|
6539
6537
|
}
|
|
@@ -6587,34 +6585,11 @@ function bindPathBoundContentSource(input) {
|
|
|
6587
6585
|
initialCiphertextDigestHex: hex2(sha2563(expected))
|
|
6588
6586
|
};
|
|
6589
6587
|
}
|
|
6590
|
-
function isUnauthorized(error) {
|
|
6591
|
-
const value = error;
|
|
6592
|
-
return value !== null && typeof value === "object" && (value.status === 401 || value.status === 403 || value.code === "PERMISSION_DENIED" || value.code === "AUTH_UNAUTHORIZED");
|
|
6593
|
-
}
|
|
6594
6588
|
async function encryptAddressedShareContent(input) {
|
|
6595
6589
|
const { plan, keys } = input;
|
|
6596
6590
|
const byteLength = input.plaintext.byteLength;
|
|
6597
|
-
let receipt;
|
|
6598
|
-
try {
|
|
6599
|
-
receipt = await keys.createKey(plan.keyPath, { networkId: plan.encryptionNetwork });
|
|
6600
|
-
} catch (error) {
|
|
6601
|
-
if (isUnauthorized(error)) {
|
|
6602
|
-
const status = error.status;
|
|
6603
|
-
throw new AddressedContentSourceError(
|
|
6604
|
-
"key-not-authorized",
|
|
6605
|
-
`the owner session does not hold tinycloud.encryption/key.create on ${plan.keyResource} (the node answers "Unauthorized Action: ${plan.keyResource} / tinycloud.encryption/key.create"); hold it either at sign-in (put plan.sessionPermissions in the manifest: key.create on ${plan.encryptionNetwork}/share/) or per share (requestPermissions(plan.requiredPermissions)) before creating the key` + (status === 403 ? "; if the owner signs in through OpenKey, the request must come from a first-party TinyCloud origin" : "")
|
|
6606
|
-
);
|
|
6607
|
-
}
|
|
6608
|
-
throw error;
|
|
6609
|
-
}
|
|
6610
|
-
if (receipt.networkId !== plan.encryptionNetwork || receipt.keyPath !== plan.keyPath || receipt.state !== void 0 && receipt.state !== "active") {
|
|
6611
|
-
throw new AddressedContentSourceError("key-receipt-mismatch", "the created key does not match this share");
|
|
6612
|
-
}
|
|
6613
6591
|
const envelope = await keys.encrypt(plan.keyPath, input.plaintext, plan.encryptOptions(input.metadata === void 0 ? void 0 : { metadata: input.metadata }));
|
|
6614
6592
|
assertEnvelope(plan, envelope);
|
|
6615
|
-
if (receipt.keyVersion !== void 0 && envelope.keyVersion !== receipt.keyVersion) {
|
|
6616
|
-
throw new AddressedContentSourceError("key-receipt-mismatch", "the envelope key version does not match the created key");
|
|
6617
|
-
}
|
|
6618
6593
|
const storedBytes = pathBoundStoredBytes(envelope);
|
|
6619
6594
|
return { envelope, storedBytes, byteLength };
|
|
6620
6595
|
}
|