@tinycloud/share-sdk 1.0.0-beta.7 → 1.0.0-beta.8
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 +39 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +37 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { ShareEnvelopeV2, ShareEnvelopeV3, UnifiedPolicyCapability, ShareAction, UnifiedContentSource, PolicyCredentialRequirementV1 } from '@tinycloud/share-envelope';
|
|
2
2
|
export { CheckBearerDelegationOptions, DelegationCheckResult, canonicalize, checkBearerDelegation, fromBase64Url, requiredResourceUri, resourceUriCovers, toBase64Url } from '@tinycloud/share-envelope';
|
|
3
3
|
|
|
4
|
+
declare function hasUnsafeFilenameCodePoint(value: string): boolean;
|
|
5
|
+
/** A single display/download filename, never a path. Returns the NFC form. */
|
|
6
|
+
declare function canonicalShareFilename(value: string): string;
|
|
7
|
+
|
|
4
8
|
/** The only interactive boundary exposed by the headless SDK. */
|
|
5
9
|
type ShareAuthorizationMethod = "openkey-device" | "email-claim" | "email-otp";
|
|
6
10
|
interface ShareAuthorizationRequired {
|
|
@@ -613,7 +617,7 @@ interface PreparedAddressedShare {
|
|
|
613
617
|
*/
|
|
614
618
|
declare function prepareAddressedShare(request: AddressedShareRequest): PreparedAddressedShare;
|
|
615
619
|
/** Canonical application-neutral Policy/v3 addressed publisher shared by browser and CLI. */
|
|
616
|
-
declare function publishAddressedShare(
|
|
620
|
+
declare function publishAddressedShare(input: AddressedSharePublishOptions): Promise<PublishedShare>;
|
|
617
621
|
|
|
618
622
|
interface ShareCacheKey {
|
|
619
623
|
readonly cid: string;
|
|
@@ -1120,4 +1124,4 @@ declare function parseNativeShareUrl(value: string): string;
|
|
|
1120
1124
|
/** Receive through the public SDK without creating another transport protocol. */
|
|
1121
1125
|
declare function openNativeShare(sharing: NativeSharingService, link: string): Promise<unknown>;
|
|
1122
1126
|
|
|
1123
|
-
export { type AddressedOwnerRootInput, type AddressedOwnerRootReceipt, type AddressedPolicyRegistrationInput, type AddressedPolicyRegistrationReceipt, type AddressedPublishAuthority, type AddressedSharePublishOptions, type AddressedShareRequest, type CreateOwnerDelegationParams, CredentialInvitationError, type CredentialInvitationErrorCode, type CredentialInvitationReceipt, type CredentialInvitationResult, DEFAULT_MAX_CONTENT_BLOB_BYTES, DEFAULT_MAX_SEALED_BLOB_BYTES, DEFAULT_SHARE_LIFETIME_MS, type DelegatedShareKey, EncryptedSenderShareHistory, type EncryptedShareHistoryStorage, MAX_CONTENT_BYTES, MemoryEncryptedShareHistoryStorage, MemorySenderShareKeyStorage, MemorySenderShareRecordStorage, MemoryShareCache, NATIVE_SHARE_FRAGMENT_PARAMETER, type NativeShareResult, type NativeSharingService, OWNER_SHARE_REGISTRATION_DOMAIN, type OwnerDelegationPermission, type OwnerDelegationReceipt, type OwnerShareAction, type OwnerShareDecryption, type OwnerShareMatcher, type OwnerSharePolicyRegistration, type OwnerSharePolicyRegistrationReceipt, type OwnerSharePolicyV2, type ParsedAddressedEnvelope, type PreparedAddressedShare, type PublishedShare, type PublishedShareDeliveryMaterial, type PublishedShareMetadata, type RegisterOwnerSharePolicyParams, SHARE_CONTENT_LIMIT, SHARE_PUBLISH_RESULT_VERSION, SHARE_RESULT_VERSION, SHARE_V2_PROTOCOL, type SenderShareKeyStorage, type SenderShareRecord, type SenderShareRecordStorage, type SenderShareRevocationScope, SenderShareStore, type ShareAuthorizationAdapter, type ShareAuthorizationDenied, type ShareAuthorizationMethod, type ShareAuthorizationReady, type ShareAuthorizationRequired, type ShareAuthorizationResult, type ShareAuthorizedContent, type ShareCache, type ShareCacheEntry, type ShareCacheKey, type ShareCacheMetadata, type ShareDeliveryAdapter, type ShareErrorCode, type ShareErrorInfo, type ShareFetchOptions, type ShareHistoryView, type ShareInspection, type ShareMetadata, type ShareNodeTrust, ShareNotifyError, type ShareNotifyInput, type ShareNotifyResult, type ShareNotifyState, type SharePolicyChallenge, type SharePolicyPublishAdapter, type SharePolicyRootRevocation, type SharePolicySession, type SharePresentationMaterial, SharePublishError, type SharePublishErrorCode, type SharePublishOptions, type SharePublishTarget, type ShareReceiveAuthorizationRequired, ShareReceiveError, type ShareReceiveOutcome, type ShareReceiveResult, ShareRecipientClient, type ShareRecipientClientOptions, type ShareRevocationAdapter, type ShareRevocationResult, type ShareTarget, type SignedDelegation, type TargetPublishAdapter, type TargetPublishInput, type TargetPublishOutcome, addressedCredentialRequirement, authorizationMethodForTarget, authorizeShare, canonicalOwnerSharePolicy, claimShare, computeOwnerShareRegistrationCid, createAddressedAuthorization, createDelegatedShareKey, createNativeShare, createPolicyEnforcementDelegation, createShareV2HolderBindingArtifact, deliverCredentialInvitation, historyRecordForPublishedShare, inspectShare, listShares, normalizeShareTarget, notifyShare, openNativeShare, parseAddressedEnvelope, parseNativeShareUrl, prepareAddressedShare, publishAddressedShare, publishPolicyShare, publishTargetShare, receiveShare, recipientMatchesShareRecord, redactPublishedShare, restoreDelegatedShareKey, resumeShareAuthorization, revokeShare, showShare, targetAuthorizationMethod, toShareErrorInfo, validateOwnerSharePolicyRegistration, validateOwnerSharePolicyRegistrationBytes };
|
|
1127
|
+
export { type AddressedOwnerRootInput, type AddressedOwnerRootReceipt, type AddressedPolicyRegistrationInput, type AddressedPolicyRegistrationReceipt, type AddressedPublishAuthority, type AddressedSharePublishOptions, type AddressedShareRequest, type CreateOwnerDelegationParams, CredentialInvitationError, type CredentialInvitationErrorCode, type CredentialInvitationReceipt, type CredentialInvitationResult, DEFAULT_MAX_CONTENT_BLOB_BYTES, DEFAULT_MAX_SEALED_BLOB_BYTES, DEFAULT_SHARE_LIFETIME_MS, type DelegatedShareKey, EncryptedSenderShareHistory, type EncryptedShareHistoryStorage, MAX_CONTENT_BYTES, MemoryEncryptedShareHistoryStorage, MemorySenderShareKeyStorage, MemorySenderShareRecordStorage, MemoryShareCache, NATIVE_SHARE_FRAGMENT_PARAMETER, type NativeShareResult, type NativeSharingService, OWNER_SHARE_REGISTRATION_DOMAIN, type OwnerDelegationPermission, type OwnerDelegationReceipt, type OwnerShareAction, type OwnerShareDecryption, type OwnerShareMatcher, type OwnerSharePolicyRegistration, type OwnerSharePolicyRegistrationReceipt, type OwnerSharePolicyV2, type ParsedAddressedEnvelope, type PreparedAddressedShare, type PublishedShare, type PublishedShareDeliveryMaterial, type PublishedShareMetadata, type RegisterOwnerSharePolicyParams, SHARE_CONTENT_LIMIT, SHARE_PUBLISH_RESULT_VERSION, SHARE_RESULT_VERSION, SHARE_V2_PROTOCOL, type SenderShareKeyStorage, type SenderShareRecord, type SenderShareRecordStorage, type SenderShareRevocationScope, SenderShareStore, type ShareAuthorizationAdapter, type ShareAuthorizationDenied, type ShareAuthorizationMethod, type ShareAuthorizationReady, type ShareAuthorizationRequired, type ShareAuthorizationResult, type ShareAuthorizedContent, type ShareCache, type ShareCacheEntry, type ShareCacheKey, type ShareCacheMetadata, type ShareDeliveryAdapter, type ShareErrorCode, type ShareErrorInfo, type ShareFetchOptions, type ShareHistoryView, type ShareInspection, type ShareMetadata, type ShareNodeTrust, ShareNotifyError, type ShareNotifyInput, type ShareNotifyResult, type ShareNotifyState, type SharePolicyChallenge, type SharePolicyPublishAdapter, type SharePolicyRootRevocation, type SharePolicySession, type SharePresentationMaterial, SharePublishError, type SharePublishErrorCode, type SharePublishOptions, type SharePublishTarget, type ShareReceiveAuthorizationRequired, ShareReceiveError, type ShareReceiveOutcome, type ShareReceiveResult, ShareRecipientClient, type ShareRecipientClientOptions, type ShareRevocationAdapter, type ShareRevocationResult, type ShareTarget, type SignedDelegation, type TargetPublishAdapter, type TargetPublishInput, type TargetPublishOutcome, addressedCredentialRequirement, authorizationMethodForTarget, authorizeShare, canonicalOwnerSharePolicy, canonicalShareFilename, claimShare, computeOwnerShareRegistrationCid, createAddressedAuthorization, createDelegatedShareKey, createNativeShare, createPolicyEnforcementDelegation, createShareV2HolderBindingArtifact, deliverCredentialInvitation, hasUnsafeFilenameCodePoint, historyRecordForPublishedShare, inspectShare, listShares, normalizeShareTarget, notifyShare, openNativeShare, parseAddressedEnvelope, parseNativeShareUrl, prepareAddressedShare, publishAddressedShare, publishPolicyShare, publishTargetShare, receiveShare, recipientMatchesShareRecord, redactPublishedShare, restoreDelegatedShareKey, resumeShareAuthorization, revokeShare, showShare, targetAuthorizationMethod, toShareErrorInfo, validateOwnerSharePolicyRegistration, validateOwnerSharePolicyRegistrationBytes };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { ShareEnvelopeV2, ShareEnvelopeV3, UnifiedPolicyCapability, ShareAction, UnifiedContentSource, PolicyCredentialRequirementV1 } from '@tinycloud/share-envelope';
|
|
2
2
|
export { CheckBearerDelegationOptions, DelegationCheckResult, canonicalize, checkBearerDelegation, fromBase64Url, requiredResourceUri, resourceUriCovers, toBase64Url } from '@tinycloud/share-envelope';
|
|
3
3
|
|
|
4
|
+
declare function hasUnsafeFilenameCodePoint(value: string): boolean;
|
|
5
|
+
/** A single display/download filename, never a path. Returns the NFC form. */
|
|
6
|
+
declare function canonicalShareFilename(value: string): string;
|
|
7
|
+
|
|
4
8
|
/** The only interactive boundary exposed by the headless SDK. */
|
|
5
9
|
type ShareAuthorizationMethod = "openkey-device" | "email-claim" | "email-otp";
|
|
6
10
|
interface ShareAuthorizationRequired {
|
|
@@ -613,7 +617,7 @@ interface PreparedAddressedShare {
|
|
|
613
617
|
*/
|
|
614
618
|
declare function prepareAddressedShare(request: AddressedShareRequest): PreparedAddressedShare;
|
|
615
619
|
/** Canonical application-neutral Policy/v3 addressed publisher shared by browser and CLI. */
|
|
616
|
-
declare function publishAddressedShare(
|
|
620
|
+
declare function publishAddressedShare(input: AddressedSharePublishOptions): Promise<PublishedShare>;
|
|
617
621
|
|
|
618
622
|
interface ShareCacheKey {
|
|
619
623
|
readonly cid: string;
|
|
@@ -1120,4 +1124,4 @@ declare function parseNativeShareUrl(value: string): string;
|
|
|
1120
1124
|
/** Receive through the public SDK without creating another transport protocol. */
|
|
1121
1125
|
declare function openNativeShare(sharing: NativeSharingService, link: string): Promise<unknown>;
|
|
1122
1126
|
|
|
1123
|
-
export { type AddressedOwnerRootInput, type AddressedOwnerRootReceipt, type AddressedPolicyRegistrationInput, type AddressedPolicyRegistrationReceipt, type AddressedPublishAuthority, type AddressedSharePublishOptions, type AddressedShareRequest, type CreateOwnerDelegationParams, CredentialInvitationError, type CredentialInvitationErrorCode, type CredentialInvitationReceipt, type CredentialInvitationResult, DEFAULT_MAX_CONTENT_BLOB_BYTES, DEFAULT_MAX_SEALED_BLOB_BYTES, DEFAULT_SHARE_LIFETIME_MS, type DelegatedShareKey, EncryptedSenderShareHistory, type EncryptedShareHistoryStorage, MAX_CONTENT_BYTES, MemoryEncryptedShareHistoryStorage, MemorySenderShareKeyStorage, MemorySenderShareRecordStorage, MemoryShareCache, NATIVE_SHARE_FRAGMENT_PARAMETER, type NativeShareResult, type NativeSharingService, OWNER_SHARE_REGISTRATION_DOMAIN, type OwnerDelegationPermission, type OwnerDelegationReceipt, type OwnerShareAction, type OwnerShareDecryption, type OwnerShareMatcher, type OwnerSharePolicyRegistration, type OwnerSharePolicyRegistrationReceipt, type OwnerSharePolicyV2, type ParsedAddressedEnvelope, type PreparedAddressedShare, type PublishedShare, type PublishedShareDeliveryMaterial, type PublishedShareMetadata, type RegisterOwnerSharePolicyParams, SHARE_CONTENT_LIMIT, SHARE_PUBLISH_RESULT_VERSION, SHARE_RESULT_VERSION, SHARE_V2_PROTOCOL, type SenderShareKeyStorage, type SenderShareRecord, type SenderShareRecordStorage, type SenderShareRevocationScope, SenderShareStore, type ShareAuthorizationAdapter, type ShareAuthorizationDenied, type ShareAuthorizationMethod, type ShareAuthorizationReady, type ShareAuthorizationRequired, type ShareAuthorizationResult, type ShareAuthorizedContent, type ShareCache, type ShareCacheEntry, type ShareCacheKey, type ShareCacheMetadata, type ShareDeliveryAdapter, type ShareErrorCode, type ShareErrorInfo, type ShareFetchOptions, type ShareHistoryView, type ShareInspection, type ShareMetadata, type ShareNodeTrust, ShareNotifyError, type ShareNotifyInput, type ShareNotifyResult, type ShareNotifyState, type SharePolicyChallenge, type SharePolicyPublishAdapter, type SharePolicyRootRevocation, type SharePolicySession, type SharePresentationMaterial, SharePublishError, type SharePublishErrorCode, type SharePublishOptions, type SharePublishTarget, type ShareReceiveAuthorizationRequired, ShareReceiveError, type ShareReceiveOutcome, type ShareReceiveResult, ShareRecipientClient, type ShareRecipientClientOptions, type ShareRevocationAdapter, type ShareRevocationResult, type ShareTarget, type SignedDelegation, type TargetPublishAdapter, type TargetPublishInput, type TargetPublishOutcome, addressedCredentialRequirement, authorizationMethodForTarget, authorizeShare, canonicalOwnerSharePolicy, claimShare, computeOwnerShareRegistrationCid, createAddressedAuthorization, createDelegatedShareKey, createNativeShare, createPolicyEnforcementDelegation, createShareV2HolderBindingArtifact, deliverCredentialInvitation, historyRecordForPublishedShare, inspectShare, listShares, normalizeShareTarget, notifyShare, openNativeShare, parseAddressedEnvelope, parseNativeShareUrl, prepareAddressedShare, publishAddressedShare, publishPolicyShare, publishTargetShare, receiveShare, recipientMatchesShareRecord, redactPublishedShare, restoreDelegatedShareKey, resumeShareAuthorization, revokeShare, showShare, targetAuthorizationMethod, toShareErrorInfo, validateOwnerSharePolicyRegistration, validateOwnerSharePolicyRegistrationBytes };
|
|
1127
|
+
export { type AddressedOwnerRootInput, type AddressedOwnerRootReceipt, type AddressedPolicyRegistrationInput, type AddressedPolicyRegistrationReceipt, type AddressedPublishAuthority, type AddressedSharePublishOptions, type AddressedShareRequest, type CreateOwnerDelegationParams, CredentialInvitationError, type CredentialInvitationErrorCode, type CredentialInvitationReceipt, type CredentialInvitationResult, DEFAULT_MAX_CONTENT_BLOB_BYTES, DEFAULT_MAX_SEALED_BLOB_BYTES, DEFAULT_SHARE_LIFETIME_MS, type DelegatedShareKey, EncryptedSenderShareHistory, type EncryptedShareHistoryStorage, MAX_CONTENT_BYTES, MemoryEncryptedShareHistoryStorage, MemorySenderShareKeyStorage, MemorySenderShareRecordStorage, MemoryShareCache, NATIVE_SHARE_FRAGMENT_PARAMETER, type NativeShareResult, type NativeSharingService, OWNER_SHARE_REGISTRATION_DOMAIN, type OwnerDelegationPermission, type OwnerDelegationReceipt, type OwnerShareAction, type OwnerShareDecryption, type OwnerShareMatcher, type OwnerSharePolicyRegistration, type OwnerSharePolicyRegistrationReceipt, type OwnerSharePolicyV2, type ParsedAddressedEnvelope, type PreparedAddressedShare, type PublishedShare, type PublishedShareDeliveryMaterial, type PublishedShareMetadata, type RegisterOwnerSharePolicyParams, SHARE_CONTENT_LIMIT, SHARE_PUBLISH_RESULT_VERSION, SHARE_RESULT_VERSION, SHARE_V2_PROTOCOL, type SenderShareKeyStorage, type SenderShareRecord, type SenderShareRecordStorage, type SenderShareRevocationScope, SenderShareStore, type ShareAuthorizationAdapter, type ShareAuthorizationDenied, type ShareAuthorizationMethod, type ShareAuthorizationReady, type ShareAuthorizationRequired, type ShareAuthorizationResult, type ShareAuthorizedContent, type ShareCache, type ShareCacheEntry, type ShareCacheKey, type ShareCacheMetadata, type ShareDeliveryAdapter, type ShareErrorCode, type ShareErrorInfo, type ShareFetchOptions, type ShareHistoryView, type ShareInspection, type ShareMetadata, type ShareNodeTrust, ShareNotifyError, type ShareNotifyInput, type ShareNotifyResult, type ShareNotifyState, type SharePolicyChallenge, type SharePolicyPublishAdapter, type SharePolicyRootRevocation, type SharePolicySession, type SharePresentationMaterial, SharePublishError, type SharePublishErrorCode, type SharePublishOptions, type SharePublishTarget, type ShareReceiveAuthorizationRequired, ShareReceiveError, type ShareReceiveOutcome, type ShareReceiveResult, ShareRecipientClient, type ShareRecipientClientOptions, type ShareRevocationAdapter, type ShareRevocationResult, type ShareTarget, type SignedDelegation, type TargetPublishAdapter, type TargetPublishInput, type TargetPublishOutcome, addressedCredentialRequirement, authorizationMethodForTarget, authorizeShare, canonicalOwnerSharePolicy, canonicalShareFilename, claimShare, computeOwnerShareRegistrationCid, createAddressedAuthorization, createDelegatedShareKey, createNativeShare, createPolicyEnforcementDelegation, createShareV2HolderBindingArtifact, deliverCredentialInvitation, hasUnsafeFilenameCodePoint, historyRecordForPublishedShare, inspectShare, listShares, normalizeShareTarget, notifyShare, openNativeShare, parseAddressedEnvelope, parseNativeShareUrl, prepareAddressedShare, publishAddressedShare, publishPolicyShare, publishTargetShare, receiveShare, recipientMatchesShareRecord, redactPublishedShare, restoreDelegatedShareKey, resumeShareAuthorization, revokeShare, showShare, targetAuthorizationMethod, toShareErrorInfo, validateOwnerSharePolicyRegistration, validateOwnerSharePolicyRegistrationBytes };
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,19 @@ var __export = (target, all) => {
|
|
|
4
4
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
5
|
};
|
|
6
6
|
|
|
7
|
+
// src/filename-policy.ts
|
|
8
|
+
var UNSAFE_FILENAME_CODE_POINT = /[\p{Cc}\p{Cf}\p{Cs}\u2028\u2029]/u;
|
|
9
|
+
function hasUnsafeFilenameCodePoint(value) {
|
|
10
|
+
return UNSAFE_FILENAME_CODE_POINT.test(value);
|
|
11
|
+
}
|
|
12
|
+
function canonicalShareFilename(value) {
|
|
13
|
+
const canonical = value.normalize("NFC");
|
|
14
|
+
if (canonical.length === 0 || canonical === "." || canonical === ".." || canonical.includes("/") || canonical.includes("\\") || hasUnsafeFilenameCodePoint(canonical)) {
|
|
15
|
+
throw new TypeError("share filename is unsafe");
|
|
16
|
+
}
|
|
17
|
+
return canonical;
|
|
18
|
+
}
|
|
19
|
+
|
|
7
20
|
// ../share-envelope/dist/index.js
|
|
8
21
|
import { sha256 } from "@noble/hashes/sha2";
|
|
9
22
|
import { ed25519 } from "@noble/curves/ed25519";
|
|
@@ -6485,8 +6498,17 @@ function normalizeShareTarget(target) {
|
|
|
6485
6498
|
function targetAuthorizationMethod(target) {
|
|
6486
6499
|
return authorizationMethodForTarget(target);
|
|
6487
6500
|
}
|
|
6501
|
+
function publishFilename(value) {
|
|
6502
|
+
try {
|
|
6503
|
+
return canonicalShareFilename(value);
|
|
6504
|
+
} catch {
|
|
6505
|
+
throw new SharePublishError("invalid-argument", hasUnsafeFilenameCodePoint(value) ? "filename contains control or invisible characters" : "filename must be one safe path segment");
|
|
6506
|
+
}
|
|
6507
|
+
}
|
|
6488
6508
|
async function publishTargetShare(input) {
|
|
6489
6509
|
const target = normalizeShareTarget(input.target);
|
|
6510
|
+
const filename = publishFilename(input.filename);
|
|
6511
|
+
const files = input.files?.map((file) => ({ ...file, filename: publishFilename(file.filename) }));
|
|
6490
6512
|
if (input.targetAdapter === void 0) {
|
|
6491
6513
|
if (target.kind === "bearer") throw new SharePublishError("authority-required", "native bearer publication requires an authenticated TinyCloud node");
|
|
6492
6514
|
return {
|
|
@@ -6512,9 +6534,6 @@ async function publishTargetShare(input) {
|
|
|
6512
6534
|
return bytes3;
|
|
6513
6535
|
})();
|
|
6514
6536
|
if (source.byteLength === 0) throw new SharePublishError("invalid-argument", "share content is empty");
|
|
6515
|
-
if (!input.filename || input.filename === "." || input.filename === ".." || /[/\\\u0000-\u001f\u007f]/.test(input.filename)) {
|
|
6516
|
-
throw new SharePublishError("invalid-argument", "filename must be one safe path segment");
|
|
6517
|
-
}
|
|
6518
6537
|
if (target.kind === "bearer" && input.allowBinary !== true) {
|
|
6519
6538
|
try {
|
|
6520
6539
|
new TextDecoder("utf-8", { fatal: true }).decode(source);
|
|
@@ -6522,10 +6541,10 @@ async function publishTargetShare(input) {
|
|
|
6522
6541
|
throw new SharePublishError("invalid-argument", "Markdown input must be valid UTF-8");
|
|
6523
6542
|
}
|
|
6524
6543
|
}
|
|
6525
|
-
const
|
|
6544
|
+
const publishFiles = files === void 0 || files.length === 0 ? [{ bytes: source }] : files;
|
|
6526
6545
|
const limit = input.maxBytes ?? SHARE_CONTENT_LIMIT;
|
|
6527
6546
|
let totalBytes = 0;
|
|
6528
|
-
for (const file of
|
|
6547
|
+
for (const file of publishFiles) {
|
|
6529
6548
|
totalBytes += file.bytes.byteLength;
|
|
6530
6549
|
if (!Number.isSafeInteger(totalBytes) || totalBytes > limit) {
|
|
6531
6550
|
throw new SharePublishError("max-bytes-exceeded", "share publication exceeds the combined byte limit");
|
|
@@ -6536,8 +6555,8 @@ async function publishTargetShare(input) {
|
|
|
6536
6555
|
if (!Number.isFinite(expiresAt.getTime()) || expiresAt.getTime() <= nowMs) throw new SharePublishError("invalid-argument", "expiresAt must be a valid future time");
|
|
6537
6556
|
return input.targetAdapter.publish({
|
|
6538
6557
|
source,
|
|
6539
|
-
filename
|
|
6540
|
-
...
|
|
6558
|
+
filename,
|
|
6559
|
+
...files === void 0 ? {} : { files },
|
|
6541
6560
|
...input.mediaType === void 0 ? {} : { mediaType: input.mediaType },
|
|
6542
6561
|
...input.resourceKind === void 0 ? {} : { resourceKind: input.resourceKind },
|
|
6543
6562
|
...input.actions === void 0 ? {} : { actions: input.actions },
|
|
@@ -6687,7 +6706,11 @@ function addressedCredentialRequirement(target) {
|
|
|
6687
6706
|
return mailboxCredentialCommitment(normalized);
|
|
6688
6707
|
}
|
|
6689
6708
|
function prepareAddressedShare(request) {
|
|
6690
|
-
|
|
6709
|
+
try {
|
|
6710
|
+
canonicalShareFilename(request.filename);
|
|
6711
|
+
} catch {
|
|
6712
|
+
throw new TypeError("addressed filename is invalid");
|
|
6713
|
+
}
|
|
6691
6714
|
if (request.actions.length === 0 || request.policyActions.length === 0) throw new TypeError("addressed share actions are empty");
|
|
6692
6715
|
const target = normalizeShareTarget(request.target);
|
|
6693
6716
|
if (target.kind === "bearer") throw new TypeError("addressed target is required");
|
|
@@ -6705,9 +6728,10 @@ function assertMailboxCommitment(commitment, target) {
|
|
|
6705
6728
|
if (canonicalize(commitment.profile) !== canonicalize(expected.profile) || canonicalize(commitment.credentialType) !== canonicalize(expected.credentialType) || commitment.descriptorDigest !== expected.descriptorDigest || commitment.issuerDid !== expected.issuerDid || commitment.issuerKid !== expected.issuerKid) throw new TypeError(`${label} shares require the ${label} credential profile`);
|
|
6706
6729
|
if (commitment.requirementDigest !== expected.requirementDigest) throw new TypeError(`credential requirement is not bound to the email ${target.kind === "email" ? "address" : "domain"}`);
|
|
6707
6730
|
}
|
|
6708
|
-
async function publishAddressedShare(
|
|
6709
|
-
assertSafeInput(
|
|
6710
|
-
const { target } = prepareAddressedShare(
|
|
6731
|
+
async function publishAddressedShare(input) {
|
|
6732
|
+
assertSafeInput(input);
|
|
6733
|
+
const { target } = prepareAddressedShare(input);
|
|
6734
|
+
const options = { ...input, filename: canonicalShareFilename(input.filename) };
|
|
6711
6735
|
if (target.kind !== "recipientDid") assertMailboxCommitment(options.credentialRequirement, target);
|
|
6712
6736
|
const expiry = rfc3339Seconds(options.expiresAt);
|
|
6713
6737
|
const matcher = targetMatcher(target);
|
|
@@ -8573,6 +8597,7 @@ export {
|
|
|
8573
8597
|
authorizationMethodForTarget,
|
|
8574
8598
|
authorizeShare,
|
|
8575
8599
|
canonicalOwnerSharePolicy,
|
|
8600
|
+
canonicalShareFilename,
|
|
8576
8601
|
canonicalize,
|
|
8577
8602
|
checkBearerDelegation,
|
|
8578
8603
|
claimShare,
|
|
@@ -8584,6 +8609,7 @@ export {
|
|
|
8584
8609
|
createShareV2HolderBindingArtifact,
|
|
8585
8610
|
deliverCredentialInvitation,
|
|
8586
8611
|
fromBase64Url,
|
|
8612
|
+
hasUnsafeFilenameCodePoint,
|
|
8587
8613
|
historyRecordForPublishedShare,
|
|
8588
8614
|
inspectShare,
|
|
8589
8615
|
listShares,
|