@tinycloud/share-sdk 1.0.0-beta.4 → 1.0.0-beta.5

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.d.cts CHANGED
@@ -587,7 +587,6 @@ interface AddressedSharePublishOptions {
587
587
  readonly onDeliveryMaterial?: (input: PublishedShareDeliveryMaterial) => void;
588
588
  readonly authority: AddressedPublishAuthority;
589
589
  }
590
- /** Canonical application-neutral Policy/v3 addressed publisher shared by browser and CLI. */
591
590
  declare function publishAddressedShare(options: AddressedSharePublishOptions): Promise<PublishedShare>;
592
591
 
593
592
  interface ShareCacheKey {
package/dist/index.d.ts CHANGED
@@ -587,7 +587,6 @@ interface AddressedSharePublishOptions {
587
587
  readonly onDeliveryMaterial?: (input: PublishedShareDeliveryMaterial) => void;
588
588
  readonly authority: AddressedPublishAuthority;
589
589
  }
590
- /** Canonical application-neutral Policy/v3 addressed publisher shared by browser and CLI. */
591
590
  declare function publishAddressedShare(options: AddressedSharePublishOptions): Promise<PublishedShare>;
592
591
 
593
592
  interface ShareCacheKey {
package/dist/index.js CHANGED
@@ -6650,10 +6650,23 @@ function publicationResult(input) {
6650
6650
  Object.defineProperty(result, "deliveryMaterial", { enumerable: false, value: input.deliveryMaterial });
6651
6651
  return result;
6652
6652
  }
6653
+ var EMAIL_DOMAIN_PROFILE = { id: "tinycloud.email-domain-proof/v1", version: 1 };
6654
+ var EMAIL_CREDENTIAL_TYPE = { id: "opencredentials.email/v1", version: 1 };
6655
+ var EMAIL_DOMAIN_DESCRIPTOR_DIGEST = "33X5mAkZZgApdD3xh_T-3KS5moop0J2Nloi2nqWsdWY";
6656
+ function assertEmailDomainPolicy(options, domain) {
6657
+ if (!options.actions.every((action) => action === "read" || action === "list") || !options.policyActions.every((action) => action === "tinycloud.kv/get" || action === "tinycloud.kv/list" || action === "tinycloud.kv/metadata")) throw new TypeError("email-domain shares are view-only");
6658
+ if (options.deliveryEmail !== void 0) throw new TypeError("email-domain shares are not emailed");
6659
+ const commitment = options.credentialRequirement;
6660
+ if (commitment === void 0) throw new TypeError("email-domain shares require a credential requirement");
6661
+ if (canonicalize(commitment.profile) !== canonicalize(EMAIL_DOMAIN_PROFILE) || canonicalize(commitment.credentialType) !== canonicalize(EMAIL_CREDENTIAL_TYPE) || commitment.descriptorDigest !== EMAIL_DOMAIN_DESCRIPTOR_DIGEST) throw new TypeError("email-domain shares require the email-domain credential profile");
6662
+ const expected = { type: "TinyCloudCredentialRequirement", version: 1, profile: EMAIL_DOMAIN_PROFILE, credentialType: EMAIL_CREDENTIAL_TYPE, claims: { emailDomain: domain }, maxAgeSeconds: 300 };
6663
+ if (toBase64Url(sha2563(textEncoder.encode(canonicalize(expected)))) !== commitment.requirementDigest) throw new TypeError("credential requirement is not bound to the email domain");
6664
+ }
6653
6665
  async function publishAddressedShare(options) {
6654
6666
  assertSafeInput(options);
6655
6667
  const target = normalizeShareTarget(options.target);
6656
6668
  if (target.kind === "bearer") throw new TypeError("addressed target is required");
6669
+ if (target.kind === "emailDomain") assertEmailDomainPolicy(options, target.domain);
6657
6670
  const expiry = rfc3339Seconds(options.expiresAt);
6658
6671
  const matcher = targetMatcher(target);
6659
6672
  const capabilities = sortCanonical([