@tinycloud/share-sdk 1.4.4 → 1.5.0-beta.1
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/artifact.cjs +1 -0
- package/dist/artifact.cjs.map +1 -1
- package/dist/artifact.js +1 -0
- package/dist/artifact.js.map +1 -1
- package/dist/index.cjs +3 -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 +3 -27
- package/dist/index.js.map +1 -1
- package/dist/share-index.cjs +1 -0
- package/dist/share-index.cjs.map +1 -1
- package/dist/share-index.js +1 -0
- package/dist/share-index.js.map +1 -1
- package/dist/share-root.cjs +2 -1
- package/dist/share-root.cjs.map +1 -1
- package/dist/share-root.d.cts +1 -1
- package/dist/share-root.d.ts +1 -1
- package/dist/share-root.js +2 -1
- package/dist/share-root.js.map +1 -1
- package/dist/web-recipient.cjs +1 -0
- package/dist/web-recipient.cjs.map +1 -1
- package/dist/web-recipient.js +1 -0
- package/dist/web-recipient.js.map +1 -1
- package/package.json +2 -2
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
|
@@ -5761,6 +5761,7 @@ function canonicalMailbox(value) {
|
|
|
5761
5761
|
if (local.length > 64 || !/^[a-z0-9#$&'*+/=?^_`{|}~-]+(?:\.[a-z0-9#$&'*+/=?^_`{|}~-]+)*$/.test(local) || !isCanonicalEmailDomain(domain)) return void 0;
|
|
5762
5762
|
return Object.freeze({ email, domain });
|
|
5763
5763
|
}
|
|
5764
|
+
var POLICY_ROOT_MAX_LIFETIME_SECONDS = 31 * 24 * 60 * 60;
|
|
5764
5765
|
async function signCompactUcanAuthorization(input) {
|
|
5765
5766
|
if (input.notBefore >= input.expiresAt || input.expiresAt - input.notBefore > 60) {
|
|
5766
5767
|
throw new TypeError("compact invocation lifetime must be between one and 60 seconds");
|
|
@@ -6520,7 +6521,7 @@ function canonicalKeyHashHex(encryptedSymmetricKey) {
|
|
|
6520
6521
|
}
|
|
6521
6522
|
function pathBoundSessionPermissions(input) {
|
|
6522
6523
|
const encryptionNetwork = assertNetwork(input.encryptionNetwork);
|
|
6523
|
-
return [{ service: "tinycloud.encryption", path: `${encryptionNetwork}/share/`, actions: ["tinycloud.encryption/decrypt"
|
|
6524
|
+
return [{ service: "tinycloud.encryption", path: `${encryptionNetwork}/share/`, actions: ["tinycloud.encryption/decrypt"] }];
|
|
6524
6525
|
}
|
|
6525
6526
|
function planPathBoundShare(input) {
|
|
6526
6527
|
const keyPath = pathBoundKeyPath(input.shareId);
|
|
@@ -6531,9 +6532,7 @@ function planPathBoundShare(input) {
|
|
|
6531
6532
|
encryptionNetwork,
|
|
6532
6533
|
keyPath,
|
|
6533
6534
|
keyResource,
|
|
6534
|
-
|
|
6535
|
-
sessionPermissions: pathBoundSessionPermissions({ encryptionNetwork }),
|
|
6536
|
-
registrationPermissions: [{ service: "tinycloud.encryption", path: `${encryptionNetwork}/share/`, actions: ["tinycloud.encryption/decrypt"] }],
|
|
6535
|
+
registrationPermissions: pathBoundSessionPermissions({ encryptionNetwork }),
|
|
6537
6536
|
encryptOptions: (extra) => ({ networkId: encryptionNetwork, ...extra?.metadata === void 0 ? {} : { metadata: { ...extra.metadata } } })
|
|
6538
6537
|
};
|
|
6539
6538
|
}
|
|
@@ -6587,34 +6586,11 @@ function bindPathBoundContentSource(input) {
|
|
|
6587
6586
|
initialCiphertextDigestHex: hex2(sha2563(expected))
|
|
6588
6587
|
};
|
|
6589
6588
|
}
|
|
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
6589
|
async function encryptAddressedShareContent(input) {
|
|
6595
6590
|
const { plan, keys } = input;
|
|
6596
6591
|
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
6592
|
const envelope = await keys.encrypt(plan.keyPath, input.plaintext, plan.encryptOptions(input.metadata === void 0 ? void 0 : { metadata: input.metadata }));
|
|
6614
6593
|
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
6594
|
const storedBytes = pathBoundStoredBytes(envelope);
|
|
6619
6595
|
return { envelope, storedBytes, byteLength };
|
|
6620
6596
|
}
|