@tinycloud/share-sdk 1.3.0-beta.0 → 1.4.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 +6 -0
- package/dist/{addressed-publish-Db-6rqkA.d.cts → addressed-publish-BP6nsgRq.d.cts} +58 -2
- package/dist/{addressed-publish-CAdGCqiX.d.ts → addressed-publish-CpkwV-Au.d.ts} +58 -2
- package/dist/artifact.cjs +2 -2
- package/dist/artifact.cjs.map +1 -1
- package/dist/artifact.js +2 -2
- package/dist/artifact.js.map +1 -1
- package/dist/{history-ZJFHV-IU.d.cts → history-Bg25JIsi.d.cts} +1 -1
- package/dist/{history-q0ALXTv7.d.ts → history-kwJxrZgq.d.ts} +1 -1
- package/dist/index.cjs +304 -154
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +290 -154
- package/dist/index.js.map +1 -1
- package/dist/{owner-policy-CRFeEC98.d.cts → owner-policy-aPmXIR3e.d.cts} +1 -1
- package/dist/{owner-policy-CRFeEC98.d.ts → owner-policy-aPmXIR3e.d.ts} +1 -1
- package/dist/share-index.cjs +47 -87
- package/dist/share-index.cjs.map +1 -1
- package/dist/share-index.d.cts +28 -30
- package/dist/share-index.d.ts +28 -30
- package/dist/share-index.js +46 -86
- package/dist/share-index.js.map +1 -1
- package/dist/share-root.cjs +2 -2
- package/dist/share-root.cjs.map +1 -1
- package/dist/share-root.d.cts +2 -2
- package/dist/share-root.d.ts +2 -2
- package/dist/share-root.js +2 -2
- package/dist/share-root.js.map +1 -1
- package/dist/{web-recipient-entry-D9IJEyRA.d.cts → web-recipient-entry-CiUzdSQs.d.cts} +9 -1
- package/dist/{web-recipient-entry-CKA_vCi5.d.ts → web-recipient-entry-DVyTQBl0.d.ts} +9 -1
- package/dist/web-recipient.cjs +76 -105
- 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 +66 -105
- package/dist/web-recipient.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -3,3 +3,9 @@
|
|
|
3
3
|
## Subpath exports
|
|
4
4
|
|
|
5
5
|
- `@tinycloud/share-sdk/web-recipient`: `inspectShare`, `ShareRecipientClient`, and the `ShareMetadata` type. The browser recipient surface, imported without the package root barrel. Its contents are fixed to these three names.
|
|
6
|
+
|
|
7
|
+
The web-recipient subpath is its own build entry, built with splitting: false, so it ships its own copies of inspectShare and ShareRecipientClient. Use the subpath's exports together, and check results by their fields rather than by class identity.
|
|
8
|
+
|
|
9
|
+
The credential witness answers browser requests only for the origins it is configured with.
|
|
10
|
+
|
|
11
|
+
openerOrigin and completionOrigin must be https origins (openerOrigin defaults to the page's own origin): web-sdk credential acquisition rejects anything else, and the witness enforces the same rule.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UnifiedPolicyCapability, ShareAction, UnifiedContentSource, PolicyCredentialRequirementV1, ArtifactPin } from '@tinycloud/share-envelope';
|
|
2
|
-
import { d as SharePublishTarget, c as PublishedShare, e as SharePublishOptions, O as OwnerShareAction, P as PublishedShareDeliveryMaterial } from './owner-policy-
|
|
2
|
+
import { d as SharePublishTarget, c as PublishedShare, e as SharePublishOptions, O as OwnerShareAction, P as PublishedShareDeliveryMaterial, f as SharePublishError } from './owner-policy-aPmXIR3e.cjs';
|
|
3
3
|
import { S as ShareAuthorizationRequired, a as ShareAuthorizationMethod } from './authorization-CmP1skO8.cjs';
|
|
4
4
|
|
|
5
5
|
type ShareTarget = SharePublishTarget;
|
|
@@ -112,6 +112,8 @@ interface AddressedPublishAuthority {
|
|
|
112
112
|
interface AddressedSharePublishOptions {
|
|
113
113
|
readonly shareId: string;
|
|
114
114
|
readonly shareOrigin: string;
|
|
115
|
+
/** The links API origin written into the signed header as its audience. Defaults to `https://api.tinycloud.xyz`. */
|
|
116
|
+
readonly apiOrigin?: string;
|
|
115
117
|
readonly nodeOrigin: string;
|
|
116
118
|
readonly nodeAudience: string;
|
|
117
119
|
readonly enforcerDid: string;
|
|
@@ -163,5 +165,59 @@ interface PreparedAddressedShare {
|
|
|
163
165
|
declare function prepareAddressedShare(request: AddressedShareRequest): PreparedAddressedShare;
|
|
164
166
|
/** Canonical application-neutral Policy/v3 addressed publisher shared by browser and CLI. */
|
|
165
167
|
declare function publishAddressedShare(input: AddressedSharePublishOptions): Promise<PublishedShare>;
|
|
168
|
+
/** The text a share gets when its sealed envelope cannot fit in a link. */
|
|
169
|
+
declare const ADDRESSED_SHARE_TOO_LARGE_MESSAGE = "This share is too large to send as a link, so nothing was shared. Use a shorter path or fewer folders.";
|
|
170
|
+
/** What a publish has written by the time its sealed envelope is measured. */
|
|
171
|
+
interface AddressedShareWrites {
|
|
172
|
+
readonly policyCid: string;
|
|
173
|
+
readonly policyRootCid: string;
|
|
174
|
+
readonly enforcementRootCid: string;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Thrown by `publishAddressedShare` when the sealed envelope, measured after
|
|
178
|
+
* the policy registration, is over `MAX_LINK_BODY_BYTES`. The size bound makes
|
|
179
|
+
* this unreachable for a correct caller; if it happens, `written` names what
|
|
180
|
+
* the publish registered so the caller can remove it. No link was built.
|
|
181
|
+
*/
|
|
182
|
+
declare class AddressedShareOverLimitError extends SharePublishError {
|
|
183
|
+
readonly written: AddressedShareWrites;
|
|
184
|
+
constructor(written: AddressedShareWrites);
|
|
185
|
+
}
|
|
186
|
+
/** What a sender knows before any write; see {@link addressedShareBodyUpperBound}. */
|
|
187
|
+
interface AddressedShareBoundInput extends AddressedShareRequest {
|
|
188
|
+
readonly shareId: string;
|
|
189
|
+
readonly ownerDid: string;
|
|
190
|
+
readonly nodeOrigin: string;
|
|
191
|
+
readonly nodeAudience: string;
|
|
192
|
+
readonly enforcerDid: string;
|
|
193
|
+
readonly spaceId: string;
|
|
194
|
+
readonly resource: {
|
|
195
|
+
readonly kind: "exact" | "prefix";
|
|
196
|
+
};
|
|
197
|
+
/** Where the content will be stored: a path, or the id and stored file name of an artifact (whose version number the publish assigns). */
|
|
198
|
+
readonly storage: {
|
|
199
|
+
readonly path: string;
|
|
200
|
+
} | {
|
|
201
|
+
readonly artifactId: string;
|
|
202
|
+
readonly storageName: string;
|
|
203
|
+
};
|
|
204
|
+
/** The owner's encryption network for the space. */
|
|
205
|
+
readonly encryptionNetwork: string;
|
|
206
|
+
readonly mediaType: string;
|
|
207
|
+
readonly byteLength: number;
|
|
208
|
+
readonly artifact?: "html";
|
|
209
|
+
readonly expiresAt: Date;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* The largest sealed envelope a share can have, in bytes, computed before any
|
|
213
|
+
* write (upload, registration, registry or KV write): the same envelope the
|
|
214
|
+
* publish builds, with every value a write returns at its maximum encoded
|
|
215
|
+
* length (see `sealedBodyUpperBound`). Compare it with `MAX_LINK_BODY_BYTES`.
|
|
216
|
+
* For an artifact share the version, the manifest digest and the stored size
|
|
217
|
+
* are taken at their largest.
|
|
218
|
+
*/
|
|
219
|
+
declare function addressedShareBodyUpperBound(input: AddressedShareBoundInput): Promise<number>;
|
|
220
|
+
/** Refuses (`SharePublishError`, code `max-bytes-exceeded`, {@link ADDRESSED_SHARE_TOO_LARGE_MESSAGE}) a share whose largest sealed envelope is over `MAX_LINK_BODY_BYTES`. Call it before any write. */
|
|
221
|
+
declare function assertAddressedShareFits(input: AddressedShareBoundInput): Promise<void>;
|
|
166
222
|
|
|
167
|
-
export { type AddressedOwnerRootInput as A, type PreparedAddressedShare as P, type ShareTarget as S, type TargetPublishOutcome as T, type AddressedOwnerRootReceipt as a, type AddressedPublishAuthority as b, type TargetPublishInput as c, type AddressedPolicyRegistrationInput as
|
|
223
|
+
export { type AddressedOwnerRootInput as A, type PreparedAddressedShare as P, type ShareTarget as S, type TargetPublishOutcome as T, type AddressedOwnerRootReceipt as a, type AddressedPublishAuthority as b, type TargetPublishInput as c, ADDRESSED_SHARE_TOO_LARGE_MESSAGE as d, type AddressedPolicyRegistrationInput as e, type AddressedPolicyRegistrationReceipt as f, type AddressedShareBoundInput as g, AddressedShareOverLimitError as h, type AddressedSharePublishOptions as i, type AddressedShareRequest as j, type AddressedShareWrites as k, type TargetPublishAdapter as l, addressedCredentialRequirement as m, addressedShareBodyUpperBound as n, assertAddressedShareFits as o, normalizeShareTarget as p, prepareAddressedShare as q, publishAddressedShare as r, publishTargetShare as s, targetAuthorizationMethod as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UnifiedPolicyCapability, ShareAction, UnifiedContentSource, PolicyCredentialRequirementV1, ArtifactPin } from '@tinycloud/share-envelope';
|
|
2
|
-
import { d as SharePublishTarget, c as PublishedShare, e as SharePublishOptions, O as OwnerShareAction, P as PublishedShareDeliveryMaterial } from './owner-policy-
|
|
2
|
+
import { d as SharePublishTarget, c as PublishedShare, e as SharePublishOptions, O as OwnerShareAction, P as PublishedShareDeliveryMaterial, f as SharePublishError } from './owner-policy-aPmXIR3e.js';
|
|
3
3
|
import { S as ShareAuthorizationRequired, a as ShareAuthorizationMethod } from './authorization-CmP1skO8.js';
|
|
4
4
|
|
|
5
5
|
type ShareTarget = SharePublishTarget;
|
|
@@ -112,6 +112,8 @@ interface AddressedPublishAuthority {
|
|
|
112
112
|
interface AddressedSharePublishOptions {
|
|
113
113
|
readonly shareId: string;
|
|
114
114
|
readonly shareOrigin: string;
|
|
115
|
+
/** The links API origin written into the signed header as its audience. Defaults to `https://api.tinycloud.xyz`. */
|
|
116
|
+
readonly apiOrigin?: string;
|
|
115
117
|
readonly nodeOrigin: string;
|
|
116
118
|
readonly nodeAudience: string;
|
|
117
119
|
readonly enforcerDid: string;
|
|
@@ -163,5 +165,59 @@ interface PreparedAddressedShare {
|
|
|
163
165
|
declare function prepareAddressedShare(request: AddressedShareRequest): PreparedAddressedShare;
|
|
164
166
|
/** Canonical application-neutral Policy/v3 addressed publisher shared by browser and CLI. */
|
|
165
167
|
declare function publishAddressedShare(input: AddressedSharePublishOptions): Promise<PublishedShare>;
|
|
168
|
+
/** The text a share gets when its sealed envelope cannot fit in a link. */
|
|
169
|
+
declare const ADDRESSED_SHARE_TOO_LARGE_MESSAGE = "This share is too large to send as a link, so nothing was shared. Use a shorter path or fewer folders.";
|
|
170
|
+
/** What a publish has written by the time its sealed envelope is measured. */
|
|
171
|
+
interface AddressedShareWrites {
|
|
172
|
+
readonly policyCid: string;
|
|
173
|
+
readonly policyRootCid: string;
|
|
174
|
+
readonly enforcementRootCid: string;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Thrown by `publishAddressedShare` when the sealed envelope, measured after
|
|
178
|
+
* the policy registration, is over `MAX_LINK_BODY_BYTES`. The size bound makes
|
|
179
|
+
* this unreachable for a correct caller; if it happens, `written` names what
|
|
180
|
+
* the publish registered so the caller can remove it. No link was built.
|
|
181
|
+
*/
|
|
182
|
+
declare class AddressedShareOverLimitError extends SharePublishError {
|
|
183
|
+
readonly written: AddressedShareWrites;
|
|
184
|
+
constructor(written: AddressedShareWrites);
|
|
185
|
+
}
|
|
186
|
+
/** What a sender knows before any write; see {@link addressedShareBodyUpperBound}. */
|
|
187
|
+
interface AddressedShareBoundInput extends AddressedShareRequest {
|
|
188
|
+
readonly shareId: string;
|
|
189
|
+
readonly ownerDid: string;
|
|
190
|
+
readonly nodeOrigin: string;
|
|
191
|
+
readonly nodeAudience: string;
|
|
192
|
+
readonly enforcerDid: string;
|
|
193
|
+
readonly spaceId: string;
|
|
194
|
+
readonly resource: {
|
|
195
|
+
readonly kind: "exact" | "prefix";
|
|
196
|
+
};
|
|
197
|
+
/** Where the content will be stored: a path, or the id and stored file name of an artifact (whose version number the publish assigns). */
|
|
198
|
+
readonly storage: {
|
|
199
|
+
readonly path: string;
|
|
200
|
+
} | {
|
|
201
|
+
readonly artifactId: string;
|
|
202
|
+
readonly storageName: string;
|
|
203
|
+
};
|
|
204
|
+
/** The owner's encryption network for the space. */
|
|
205
|
+
readonly encryptionNetwork: string;
|
|
206
|
+
readonly mediaType: string;
|
|
207
|
+
readonly byteLength: number;
|
|
208
|
+
readonly artifact?: "html";
|
|
209
|
+
readonly expiresAt: Date;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* The largest sealed envelope a share can have, in bytes, computed before any
|
|
213
|
+
* write (upload, registration, registry or KV write): the same envelope the
|
|
214
|
+
* publish builds, with every value a write returns at its maximum encoded
|
|
215
|
+
* length (see `sealedBodyUpperBound`). Compare it with `MAX_LINK_BODY_BYTES`.
|
|
216
|
+
* For an artifact share the version, the manifest digest and the stored size
|
|
217
|
+
* are taken at their largest.
|
|
218
|
+
*/
|
|
219
|
+
declare function addressedShareBodyUpperBound(input: AddressedShareBoundInput): Promise<number>;
|
|
220
|
+
/** Refuses (`SharePublishError`, code `max-bytes-exceeded`, {@link ADDRESSED_SHARE_TOO_LARGE_MESSAGE}) a share whose largest sealed envelope is over `MAX_LINK_BODY_BYTES`. Call it before any write. */
|
|
221
|
+
declare function assertAddressedShareFits(input: AddressedShareBoundInput): Promise<void>;
|
|
166
222
|
|
|
167
|
-
export { type AddressedOwnerRootInput as A, type PreparedAddressedShare as P, type ShareTarget as S, type TargetPublishOutcome as T, type AddressedOwnerRootReceipt as a, type AddressedPublishAuthority as b, type TargetPublishInput as c, type AddressedPolicyRegistrationInput as
|
|
223
|
+
export { type AddressedOwnerRootInput as A, type PreparedAddressedShare as P, type ShareTarget as S, type TargetPublishOutcome as T, type AddressedOwnerRootReceipt as a, type AddressedPublishAuthority as b, type TargetPublishInput as c, ADDRESSED_SHARE_TOO_LARGE_MESSAGE as d, type AddressedPolicyRegistrationInput as e, type AddressedPolicyRegistrationReceipt as f, type AddressedShareBoundInput as g, AddressedShareOverLimitError as h, type AddressedSharePublishOptions as i, type AddressedShareRequest as j, type AddressedShareWrites as k, type TargetPublishAdapter as l, addressedCredentialRequirement as m, addressedShareBodyUpperBound as n, assertAddressedShareFits as o, normalizeShareTarget as p, prepareAddressedShare as q, publishAddressedShare as r, publishTargetShare as s, targetAuthorizationMethod as t };
|
package/dist/artifact.cjs
CHANGED
|
@@ -4955,7 +4955,8 @@ function isCanonicalRawCid(cidString) {
|
|
|
4955
4955
|
} catch {
|
|
4956
4956
|
return false;
|
|
4957
4957
|
}
|
|
4958
|
-
return cid.version === 1 && cid.code === code && cid.multihash.code === SHA256_CODE &&
|
|
4958
|
+
return cid.version === 1 && cid.code === code && cid.multihash.code === SHA256_CODE && // `toString` of a parsed CID gives back the string it was parsed from; a fresh CID is encoded again.
|
|
4959
|
+
CID.createV1(cid.code, cid.multihash).toString() === cidString;
|
|
4959
4960
|
}
|
|
4960
4961
|
var base64 = rfc4648({
|
|
4961
4962
|
prefix: "m",
|
|
@@ -5460,7 +5461,6 @@ function serialize(value) {
|
|
|
5460
5461
|
function canonicalize(value) {
|
|
5461
5462
|
return serialize(value);
|
|
5462
5463
|
}
|
|
5463
|
-
var MAX_INLINE_BYTES = 256 * 1024;
|
|
5464
5464
|
|
|
5465
5465
|
// src/artifact.ts
|
|
5466
5466
|
var import_sha2562 = require("@noble/hashes/sha256");
|