@interop/was-client 0.91.0 → 0.93.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 +176 -13
- package/dist/Collection.d.ts +43 -6
- package/dist/Collection.d.ts.map +1 -1
- package/dist/Collection.js +96 -21
- package/dist/Collection.js.map +1 -1
- package/dist/Resource.d.ts +35 -2
- package/dist/Resource.d.ts.map +1 -1
- package/dist/Resource.js +49 -5
- package/dist/Resource.js.map +1 -1
- package/dist/Space.d.ts +85 -1
- package/dist/Space.d.ts.map +1 -1
- package/dist/Space.js +160 -1
- package/dist/Space.js.map +1 -1
- package/dist/codec.d.ts +26 -0
- package/dist/codec.d.ts.map +1 -1
- package/dist/edv/EdvCodec.d.ts +20 -1
- package/dist/edv/EdvCodec.d.ts.map +1 -1
- package/dist/edv/EdvCodec.js +161 -85
- package/dist/edv/EdvCodec.js.map +1 -1
- package/dist/edv/WasTransport.d.ts.map +1 -1
- package/dist/edv/WasTransport.js +10 -7
- package/dist/edv/WasTransport.js.map +1 -1
- package/dist/errors.d.ts +13 -5
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +98 -49
- package/dist/errors.js.map +1 -1
- package/dist/identity/agents.d.ts +14 -6
- package/dist/identity/agents.d.ts.map +1 -1
- package/dist/identity/agents.js +19 -7
- package/dist/identity/agents.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/internal/blob.d.ts +16 -1
- package/dist/internal/blob.d.ts.map +1 -1
- package/dist/internal/blob.js +34 -1
- package/dist/internal/blob.js.map +1 -1
- package/dist/internal/codec.d.ts +3 -2
- package/dist/internal/codec.d.ts.map +1 -1
- package/dist/internal/codec.js +26 -3
- package/dist/internal/codec.js.map +1 -1
- package/dist/internal/content.d.ts +65 -10
- package/dist/internal/content.d.ts.map +1 -1
- package/dist/internal/content.js +88 -11
- package/dist/internal/content.js.map +1 -1
- package/dist/internal/describe.d.ts.map +1 -1
- package/dist/internal/describe.js +6 -1
- package/dist/internal/describe.js.map +1 -1
- package/dist/internal/paths.d.ts +17 -11
- package/dist/internal/paths.d.ts.map +1 -1
- package/dist/internal/paths.js +23 -11
- package/dist/internal/paths.js.map +1 -1
- package/dist/sync/port.d.ts.map +1 -1
- package/dist/sync/port.js +6 -10
- package/dist/sync/port.js.map +1 -1
- package/dist/sync/types.d.ts +5 -8
- package/dist/sync/types.d.ts.map +1 -1
- package/dist/types.d.ts +12 -6
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -3
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
* WAS account/Space.
|
|
9
9
|
*
|
|
10
10
|
* The derivation: secret or 32-byte seed enters `CapabilityAgent` under the
|
|
11
|
-
*
|
|
12
|
-
* every account's data identity derives through these exact strings, so
|
|
13
|
-
*
|
|
11
|
+
* pinned `'bootstrap'` / `'bootstrap-key'` names. Both are derivation inputs:
|
|
12
|
+
* every account's data identity derives through these exact strings, so a
|
|
13
|
+
* change to either renames every existing account. The resulting Ed25519
|
|
14
14
|
* signing key backs a did:key DID, a `ZcapClient` for signing storage
|
|
15
15
|
* requests, and -- via did:key's encryption-key derivation (the Montgomery
|
|
16
16
|
* form of the signing key) -- the X25519 key agreement key (KAK) the EDV
|
|
@@ -21,11 +21,11 @@ import { CapabilityAgent } from '@interop/capability-agent';
|
|
|
21
21
|
import { ZcapClient } from '@interop/ezcap';
|
|
22
22
|
import type { IKeyAgreementKey, IKeyResolver } from '@interop/data-integrity-core';
|
|
23
23
|
/**
|
|
24
|
-
* The
|
|
25
|
-
*
|
|
24
|
+
* The pinned `CapabilityAgent` derivation names (see the module doc: both are
|
|
25
|
+
* inputs to every account's key derivation).
|
|
26
26
|
*/
|
|
27
27
|
export declare const BOOTSTRAP_HANDLE = "bootstrap";
|
|
28
|
-
export declare const BOOTSTRAP_KEY_NAME = "
|
|
28
|
+
export declare const BOOTSTRAP_KEY_NAME = "bootstrap-key";
|
|
29
29
|
/**
|
|
30
30
|
* The agents derived from a controller secret or seed: the signing
|
|
31
31
|
* CapabilityAgent / did:key, a ZcapClient for signing storage requests, and
|
|
@@ -58,6 +58,14 @@ export declare function agentsFromSeed({ seed }: {
|
|
|
58
58
|
* Passing a string keeps every secret typeable/scannable into a login form
|
|
59
59
|
* (the cross-wallet linking flow).
|
|
60
60
|
*
|
|
61
|
+
* The secret is trimmed before derivation, so leading and trailing whitespace
|
|
62
|
+
* (a pasted passphrase, a scanned code) does not change the identity. An
|
|
63
|
+
* empty or whitespace-only secret is rejected with `ValidationError`: the
|
|
64
|
+
* handle and key name are public constants, so the identity such a secret
|
|
65
|
+
* would derive is computable by anyone, and a caller passing an unfilled
|
|
66
|
+
* field would otherwise land silently in that shared account. No minimum
|
|
67
|
+
* length is enforced beyond that.
|
|
68
|
+
*
|
|
61
69
|
* @param options {object}
|
|
62
70
|
* @param options.secret {string} the controller secret (see above)
|
|
63
71
|
* @returns {Promise<ProfileAgents>}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../src/identity/agents.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAE3C,OAAO,KAAK,EACV,gBAAgB,EAChB,YAAY,EACb,MAAM,8BAA8B,CAAA;AAKrC;;;GAGG;AACH,eAAO,MAAM,gBAAgB,cAAc,CAAA;AAC3C,eAAO,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../src/identity/agents.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAE3C,OAAO,KAAK,EACV,gBAAgB,EAChB,YAAY,EACb,MAAM,8BAA8B,CAAA;AAKrC;;;GAGG;AACH,eAAO,MAAM,gBAAgB,cAAc,CAAA;AAC3C,eAAO,MAAM,kBAAkB,kBAAkB,CAAA;AAEjD;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,aAAa,EAAE,MAAM,CAAA;IACrB,QAAQ,EAAE,eAAe,CAAA;IACzB,UAAU,EAAE,UAAU,CAAA;IACtB,eAAe,EAAE,gBAAgB,CAAA;IACjC,WAAW,EAAE,YAAY,CAAA;CAC1B;AAED;;;;;;;;GAQG;AACH,wBAAsB,cAAc,CAAC,EACnC,IAAI,EACL,EAAE;IACD,IAAI,EAAE,UAAU,CAAA;CACjB,GAAG,OAAO,CAAC,aAAa,CAAC,CAYzB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,gBAAgB,CAAC,EACrC,MAAM,EACP,EAAE;IACD,MAAM,EAAE,MAAM,CAAA;CACf,GAAG,OAAO,CAAC,aAAa,CAAC,CAazB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,QAAQ,EACT,EAAE;IACD,QAAQ,EAAE,eAAe,CAAA;CAC1B,GAAG,aAAa,CAoBhB"}
|
package/dist/identity/agents.js
CHANGED
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
* WAS account/Space.
|
|
9
9
|
*
|
|
10
10
|
* The derivation: secret or 32-byte seed enters `CapabilityAgent` under the
|
|
11
|
-
*
|
|
12
|
-
* every account's data identity derives through these exact strings, so
|
|
13
|
-
*
|
|
11
|
+
* pinned `'bootstrap'` / `'bootstrap-key'` names. Both are derivation inputs:
|
|
12
|
+
* every account's data identity derives through these exact strings, so a
|
|
13
|
+
* change to either renames every existing account. The resulting Ed25519
|
|
14
14
|
* signing key backs a did:key DID, a `ZcapClient` for signing storage
|
|
15
15
|
* requests, and -- via did:key's encryption-key derivation (the Montgomery
|
|
16
16
|
* form of the signing key) -- the X25519 key agreement key (KAK) the EDV
|
|
@@ -24,11 +24,11 @@ import { ValidationError } from '../errors.js';
|
|
|
24
24
|
import { zcapClientForSigner } from '../zcapClient.js';
|
|
25
25
|
import { singleKeyResolver } from './keyResolver.js';
|
|
26
26
|
/**
|
|
27
|
-
* The
|
|
28
|
-
*
|
|
27
|
+
* The pinned `CapabilityAgent` derivation names (see the module doc: both are
|
|
28
|
+
* inputs to every account's key derivation).
|
|
29
29
|
*/
|
|
30
30
|
export const BOOTSTRAP_HANDLE = 'bootstrap';
|
|
31
|
-
export const BOOTSTRAP_KEY_NAME = '
|
|
31
|
+
export const BOOTSTRAP_KEY_NAME = 'bootstrap-key';
|
|
32
32
|
/**
|
|
33
33
|
* Derives the WAS agents from an already-derived 32-byte seed, skipping the
|
|
34
34
|
* salted-hash step (`CapabilityAgent.fromSeed` semantics: a stored seed
|
|
@@ -57,13 +57,25 @@ export async function agentsFromSeed({ seed }) {
|
|
|
57
57
|
* Passing a string keeps every secret typeable/scannable into a login form
|
|
58
58
|
* (the cross-wallet linking flow).
|
|
59
59
|
*
|
|
60
|
+
* The secret is trimmed before derivation, so leading and trailing whitespace
|
|
61
|
+
* (a pasted passphrase, a scanned code) does not change the identity. An
|
|
62
|
+
* empty or whitespace-only secret is rejected with `ValidationError`: the
|
|
63
|
+
* handle and key name are public constants, so the identity such a secret
|
|
64
|
+
* would derive is computable by anyone, and a caller passing an unfilled
|
|
65
|
+
* field would otherwise land silently in that shared account. No minimum
|
|
66
|
+
* length is enforced beyond that.
|
|
67
|
+
*
|
|
60
68
|
* @param options {object}
|
|
61
69
|
* @param options.secret {string} the controller secret (see above)
|
|
62
70
|
* @returns {Promise<ProfileAgents>}
|
|
63
71
|
*/
|
|
64
72
|
export async function agentsFromSecret({ secret }) {
|
|
73
|
+
const trimmed = secret.trim();
|
|
74
|
+
if (trimmed.length === 0) {
|
|
75
|
+
throw new ValidationError('Expected a non-empty controller secret, got an empty or whitespace-only string.');
|
|
76
|
+
}
|
|
65
77
|
const keyAgent = await CapabilityAgent.fromSecret({
|
|
66
|
-
secret,
|
|
78
|
+
secret: trimmed,
|
|
67
79
|
handle: BOOTSTRAP_HANDLE,
|
|
68
80
|
keyName: BOOTSTRAP_KEY_NAME
|
|
69
81
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../../src/identity/agents.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAA;AAK7E,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAEpD;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,WAAW,CAAA;AAC3C,MAAM,CAAC,MAAM,kBAAkB,GAAG,
|
|
1
|
+
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../../src/identity/agents.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAA;AAK7E,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAEpD;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,WAAW,CA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CAC3D,QAAQ,CAAC,sBAAsB,EAAE,CAClC,CAAA;IACD,MAAM,WAAW,GAAG,iBAAiB,CAAC,EAAE,eAAe,EAAE,CAAC,CAAA;IAE1D,OAAO;QACL,aAAa,EAAE,QAAQ,CAAC,EAAE;QAC1B,QAAQ;QACR,UAAU;QACV,mEAAmE;QACnE,iEAAiE;QACjE,eAAe,EAAE,eAAmC;QACpD,WAAW;KACZ,CAAA;AACH,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -15,12 +15,12 @@ export { parseSpaceTarget } from './internal/paths.js';
|
|
|
15
15
|
export type { ParsedSpacePath } from './internal/paths.js';
|
|
16
16
|
export { readEtag, writeHeaders } from './internal/conditional.js';
|
|
17
17
|
export { isGovernedDescriptor } from './internal/describe.js';
|
|
18
|
-
export { isJsonResourceChange, isResourceChange } from '@interop/storage-core';
|
|
18
|
+
export { isJsonResourceChange, isResourceChange, ProblemTypes } from '@interop/storage-core';
|
|
19
19
|
export type { WritePrecondition } from './internal/conditional.js';
|
|
20
20
|
export { WasError, NotFoundError, CapabilityRevokedError, CapabilityExpiredError, ValidationError, AlreadyRevokedError, AuthRequiredError, NotImplementedError, NotSupportedError, IncompatibleServerError, ConflictError, PreconditionFailedError, PayloadTooLargeError, QuotaExceededError, EncryptionError, EncryptOnlyCipherError, UnverifiedDescriptorError, KeyUnwrapError, IntegrityError, WasSyncAuthError, WasSyncCheckpointError, WasSyncConflictError, WasSyncNotFoundError, WasServerError, httpStatus, mapError } from './errors.js';
|
|
21
21
|
export { isChunkedWrite } from './codec.js';
|
|
22
|
-
export type { ResourceCodec, EncryptionProvider, ChunkedWrite, CodecRequestContext, CodecWrite, MetaReadSlot, MetaWriteSlot, EncodedWrite, ResponseLike, BlindedQuery, CodecIndexing, IndexDeclaration, IndexSchema } from './codec.js';
|
|
23
|
-
export type { Json, JsonPrimitive, JsonObject, JsonArray, ResourceData, Action, ActionInput, ChangeDocument, ChangesCheckpoint, ChangesPage, ContainerChangeDocument, PolicyChangeDocument, ResourceChangeDocument, SpaceMetadata, CollectionWritableFields, CollectionEncryption, CollectionEncryptionEpoch, CollectionEncryptionRecipient, CollectionEncryptionHmac, EncryptionWithHmac, CollectionSummary, CollectionsList, SpaceSummary, SpaceListing, ResourceSummary, CollectionResourcesList, ResourceMetadata, ResourceMetadataCustom, ResourceMetadataCustomInput, CollectionMetadata, CollectionGenerator, AddResult, FindPage, ImportStats, PolicyDocument, PolicyTombstone, LinkSet, LinkSetEntry, HandleOptions, EncryptionOverride, BackendReference, BackendDescriptor, BackendRegistration, BackendConnectionInput, BackendConnectionPublic, StorageLimit, CollectionUsage, BackendUsage, SpaceQuotaReport, ServiceDescription, ServiceDescriptionVersionEntry, PwsVersionEntry, ServiceInfo, GrantOptions, RequestInput, IZcap, IDelegatedZcap, IRootZcap, IDID, ISigner } from './types.js';
|
|
22
|
+
export type { DecodedStream, ResourceCodec, EncryptionProvider, ChunkedWrite, CodecRequestContext, CodecWrite, MetaReadSlot, MetaWriteSlot, EncodedWrite, ResponseLike, BlindedQuery, CodecIndexing, IndexDeclaration, IndexSchema } from './codec.js';
|
|
23
|
+
export type { Json, JsonPrimitive, JsonObject, JsonArray, ResourceData, Action, ActionInput, ChangeDocument, ChangesCheckpoint, ChangesPage, ContainerChangeDocument, PolicyChangeDocument, ResourceChangeDocument, SpaceMetadata, CollectionWritableFields, CollectionEncryption, CollectionEncryptionEpoch, CollectionEncryptionRecipient, CollectionEncryptionHmac, EncryptionWithHmac, CollectionSummary, CollectionsList, SpaceSummary, SpaceListing, ResourceSummary, CollectionResourcesList, ResourceMetadata, ResourceMetadataCustom, ResourceMetadataCustomInput, CollectionMetadata, CollectionGenerator, AddResult, FindPage, ImportStats, PolicyDocument, PolicyTombstone, LinkSet, LinkSetEntry, HandleOptions, EncryptionOverride, BackendReference, BackendDescriptor, BackendRegistration, BackendConnectionInput, BackendConnectionPublic, StorageLimit, CollectionUsage, BackendUsage, SpaceQuotaReport, ReplicaRegistration, ReplicaSummary, ReplicaRole, ReplicaListing, ReplicaStatus, ReplicaCollectionStatus, ReplicaStallReason, WriteStamp, ServiceDescription, ServiceDescriptionVersionEntry, PwsVersionEntry, ServiceInfo, GrantOptions, RequestInput, IZcap, IDelegatedZcap, IRootZcap, IDID, ISigner } from './types.js';
|
|
24
24
|
/**
|
|
25
25
|
* The Collection Metadata `custom` object as the blinded-index code sees it --
|
|
26
26
|
* the user's own properties plus the `indexSchema` `declareIndex` persists.
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;GAGG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACtD,YAAY,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;GAGG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,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AW,EACX,uBAAuB,EACvB,oBAAoB,EACpB,sBAAsB,EACtB,aAAa,EACb,wBAAwB,EACxB,oBAAoB,EACpB,yBAAyB,EACzB,6BAA6B,EAC7B,wBAAwB,EACxB,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,uBAAuB,EACvB,gBAAgB,EAChB,sBAAsB,EACtB,2BAA2B,EAC3B,kBAAkB,EAClB,mBAAmB,EACnB,SAAS,EACT,QAAQ,EACR,WAAW,EACX,cAAc,EACd,eAAe,EACf,OAAO,EACP,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,EACtB,uBAAuB,EACvB,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,mBAAmB,EACnB,cAAc,EACd,WAAW,EACX,cAAc,EACd,aAAa,EACb,uBAAuB,EACvB,kBAAkB,EAClB,UAAU,EACV,kBAAkB,EAClB,8BAA8B,EAC9B,eAAe,EACf,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,KAAK,EACL,cAAc,EACd,SAAS,EACT,IAAI,EACJ,OAAO,EACR,MAAM,YAAY,CAAA;AAEnB;;;;GAIG;AACH,YAAY,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -15,8 +15,10 @@ export { parseSpaceTarget } from './internal/paths.js';
|
|
|
15
15
|
export { readEtag, writeHeaders } from './internal/conditional.js';
|
|
16
16
|
export { isGovernedDescriptor } from './internal/describe.js';
|
|
17
17
|
// The `changes` feed guards a consumer filters `Collection.changes()` pages
|
|
18
|
-
// with,
|
|
19
|
-
|
|
18
|
+
// with, and the problem-type registry a consumer tells one `ConflictError`
|
|
19
|
+
// kind from another by, so a consumer needs no direct `@interop/storage-core`
|
|
20
|
+
// dependency.
|
|
21
|
+
export { isJsonResourceChange, isResourceChange, ProblemTypes } from '@interop/storage-core';
|
|
20
22
|
export { WasError, NotFoundError, CapabilityRevokedError, CapabilityExpiredError, ValidationError, AlreadyRevokedError, AuthRequiredError, NotImplementedError, NotSupportedError, IncompatibleServerError, ConflictError, PreconditionFailedError, PayloadTooLargeError, QuotaExceededError, EncryptionError, EncryptOnlyCipherError, UnverifiedDescriptorError, KeyUnwrapError, IntegrityError, WasSyncAuthError, WasSyncCheckpointError, WasSyncConflictError, WasSyncNotFoundError, WasServerError, httpStatus, mapError } from './errors.js';
|
|
21
23
|
export { isChunkedWrite } from './codec.js';
|
|
22
24
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;GAGG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAEtD,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC7D,4EAA4E;AAC5E,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;GAGG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAEtD,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC7D,4EAA4E;AAC5E,2EAA2E;AAC3E,8EAA8E;AAC9E,cAAc;AACd,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,YAAY,EACb,MAAM,uBAAuB,CAAA;AAG9B,OAAO,EACL,QAAQ,EACR,aAAa,EACb,sBAAsB,EACtB,sBAAsB,EACtB,eAAe,EACf,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,uBAAuB,EACvB,aAAa,EACb,uBAAuB,EACvB,oBAAoB,EACpB,kBAAkB,EAClB,eAAe,EACf,sBAAsB,EACtB,yBAAyB,EACzB,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,sBAAsB,EACtB,oBAAoB,EACpB,oBAAoB,EACpB,cAAc,EACd,UAAU,EACV,QAAQ,EACT,MAAM,aAAa,CAAA;AAEpB,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA"}
|
package/dist/internal/blob.d.ts
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
|
-
* Portable `Blob` reads
|
|
5
|
+
* Portable `Blob` reads, plus the one-way conversion of in-hand bytes to a
|
|
6
|
+
* byte stream.
|
|
6
7
|
*
|
|
7
8
|
* A `Blob` in a browser or in Node implements `text()` and `arrayBuffer()`, so
|
|
8
9
|
* reading one is a single await. React Native's built-in `Blob` implements
|
|
@@ -32,4 +33,18 @@ export declare function blobText(blob: Blob): Promise<string>;
|
|
|
32
33
|
* @returns {Promise<Uint8Array>}
|
|
33
34
|
*/
|
|
34
35
|
export declare function blobBytes(blob: Blob): Promise<Uint8Array>;
|
|
36
|
+
/**
|
|
37
|
+
* Presents a binary payload as a `ReadableStream<Uint8Array>`. Bytes already
|
|
38
|
+
* in hand become a one-chunk stream over that same buffer (no copy), so a
|
|
39
|
+
* caller whose consumer reads across many awaits snapshots the buffer itself
|
|
40
|
+
* if it may be reused meanwhile. A `Blob` is immutable and streams itself
|
|
41
|
+
* where it implements `stream()`; React Native's built-in `Blob` does not, so
|
|
42
|
+
* there the stream reads the blob's bytes through {@link blobBytes} on first
|
|
43
|
+
* pull. A consumer that re-chunks what it reads (the EDV encrypt stream) is
|
|
44
|
+
* unaffected by the shape of the source stream.
|
|
45
|
+
*
|
|
46
|
+
* @param data {Blob | Uint8Array}
|
|
47
|
+
* @returns {ReadableStream<Uint8Array>}
|
|
48
|
+
*/
|
|
49
|
+
export declare function bytesToStream(data: Blob | Uint8Array): ReadableStream<Uint8Array>;
|
|
35
50
|
//# sourceMappingURL=blob.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blob.d.ts","sourceRoot":"","sources":["../../src/internal/blob.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH
|
|
1
|
+
{"version":3,"file":"blob.d.ts","sourceRoot":"","sources":["../../src/internal/blob.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;GAiBG;AA0EH;;;;;GAKG;AACH,wBAAsB,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAe1D;AAED;;;;;GAKG;AACH,wBAAsB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,UAAU,CAAC,CA0B/D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,IAAI,GAAG,UAAU,GACtB,cAAc,CAAC,UAAU,CAAC,CAkB5B"}
|
package/dist/internal/blob.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
|
-
* Portable `Blob` reads
|
|
5
|
+
* Portable `Blob` reads, plus the one-way conversion of in-hand bytes to a
|
|
6
|
+
* byte stream.
|
|
6
7
|
*
|
|
7
8
|
* A `Blob` in a browser or in Node implements `text()` and `arrayBuffer()`, so
|
|
8
9
|
* reading one is a single await. React Native's built-in `Blob` implements
|
|
@@ -111,4 +112,36 @@ export async function blobBytes(blob) {
|
|
|
111
112
|
}
|
|
112
113
|
throw new TypeError('FileReader.readAsArrayBuffer did not yield an ArrayBuffer.');
|
|
113
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* Presents a binary payload as a `ReadableStream<Uint8Array>`. Bytes already
|
|
117
|
+
* in hand become a one-chunk stream over that same buffer (no copy), so a
|
|
118
|
+
* caller whose consumer reads across many awaits snapshots the buffer itself
|
|
119
|
+
* if it may be reused meanwhile. A `Blob` is immutable and streams itself
|
|
120
|
+
* where it implements `stream()`; React Native's built-in `Blob` does not, so
|
|
121
|
+
* there the stream reads the blob's bytes through {@link blobBytes} on first
|
|
122
|
+
* pull. A consumer that re-chunks what it reads (the EDV encrypt stream) is
|
|
123
|
+
* unaffected by the shape of the source stream.
|
|
124
|
+
*
|
|
125
|
+
* @param data {Blob | Uint8Array}
|
|
126
|
+
* @returns {ReadableStream<Uint8Array>}
|
|
127
|
+
*/
|
|
128
|
+
export function bytesToStream(data) {
|
|
129
|
+
if (data instanceof Uint8Array) {
|
|
130
|
+
return new ReadableStream({
|
|
131
|
+
start(controller) {
|
|
132
|
+
controller.enqueue(data);
|
|
133
|
+
controller.close();
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
if (typeof data.stream === 'function') {
|
|
138
|
+
return data.stream();
|
|
139
|
+
}
|
|
140
|
+
return new ReadableStream({
|
|
141
|
+
async pull(controller) {
|
|
142
|
+
controller.enqueue(await blobBytes(data));
|
|
143
|
+
controller.close();
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
}
|
|
114
147
|
//# sourceMappingURL=blob.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blob.js","sourceRoot":"","sources":["../../src/internal/blob.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH
|
|
1
|
+
{"version":3,"file":"blob.js","sourceRoot":"","sources":["../../src/internal/blob.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;GAiBG;AAgBH;;;;;GAKG;AACH,SAAS,qBAAqB;IAC5B,MAAM,IAAI,GAAI,UAAuC,CAAC,UAAU,CAAA;IAChE,OAAO,OAAO,IAAI,KAAK,UAAU;QAC/B,CAAC,CAAE,IAAiC;QACpC,CAAC,CAAC,SAAS,CAAA;AACf,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,KAAK,UAAU,kBAAkB,CAAC,EAChC,IAAI,EACJ,IAAI,EACJ,IAAI,EAKL;IACC,MAAM,cAAc,GAAG,qBAAqB,EAAE,CAAA;IAC9C,IAAI,cAAc,KAAK,SAAS,EAAE,CAAC;QACjC,MAAM,IAAI,SAAS,CACjB,eAAe,IAAI,iDAAiD;YAClE,2DAA2D,CAC9D,CAAA;IACH,CAAC;IACD,OAAO,MAAM,IAAI,OAAO,CAAU,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACpD,MAAM,MAAM,GAAG,IAAI,cAAc,EAAE,CAAA;QACnC,MAAM,CAAC,MAAM,GAAG,GAAG,EAAE;YACnB,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;QACxB,CAAC,CAAA;QACD,MAAM,CAAC,OAAO,GAAG,GAAG,EAAE;YACpB,MAAM,CACJ,MAAM,CAAC,KAAK,YAAY,KAA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W,EAAE,CAAC;QAClC,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,CAAA;IAC/B,CAAC;IACD,IAAI,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;QAC/B,OAAO,IAAI,UAAU,CACnB,MAAM,CAAC,MAAqB,EAC5B,MAAM,CAAC,UAAU,EACjB,MAAM,CAAC,UAAU,CAClB,CAAA;IACH,CAAC;IACD,MAAM,IAAI,SAAS,CACjB,4DAA4D,CAC7D,CAAA;AACH,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,aAAa,CAC3B,IAAuB;IAEvB,IAAI,IAAI,YAAY,UAAU,EAAE,CAAC;QAC/B,OAAO,IAAI,cAAc,CAAa;YACpC,KAAK,CAAC,UAAU;gBACd,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;gBACxB,UAAU,CAAC,KAAK,EAAE,CAAA;YACpB,CAAC;SACF,CAAC,CAAA;IACJ,CAAC;IACD,IAAI,OAAO,IAAI,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;QACtC,OAAO,IAAI,CAAC,MAAM,EAAgC,CAAA;IACpD,CAAC;IACD,OAAO,IAAI,cAAc,CAAa;QACpC,KAAK,CAAC,IAAI,CAAC,UAAU;YACnB,UAAU,CAAC,OAAO,CAAC,MAAM,SAAS,CAAC,IAAI,CAAC,CAAC,CAAA;YACzC,UAAU,CAAC,KAAK,EAAE,CAAA;QACpB,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
|
package/dist/internal/codec.d.ts
CHANGED
|
@@ -91,8 +91,9 @@ export declare function collectionCodecHolder(context: ClientContext, options: C
|
|
|
91
91
|
* caller's `id` (so `put(id, ...)` is a `PUT` and `add(...)`, with no id, stays
|
|
92
92
|
* a server-minting `POST`) and reuses `prepareBody` -- including the
|
|
93
93
|
* filename-extension content-type guess when an id is present. `decode` reuses
|
|
94
|
-
* `parseResource
|
|
95
|
-
*
|
|
94
|
+
* `parseResource`, and `decodeStream` hands back the response body itself.
|
|
95
|
+
* `encodeMeta` / `decodeMeta` are the identity transform, so metadata
|
|
96
|
+
* round-trips as server-visible plaintext byte-for-byte.
|
|
96
97
|
*/
|
|
97
98
|
export declare const identityCodec: ResourceCodec;
|
|
98
99
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../../src/internal/codec.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../../src/internal/codec.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAA+B,aAAa,EAAE,MAAM,aAAa,CAAA;AAC7E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAkBjD,OAAO,KAAK,EACV,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,KAAK,EAKN,MAAM,aAAa,CAAA;AAEpB;;;;;;;GAOG;AACH,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,aAAa,CAAA;IACpB,IAAI,CAAC,EAAE,CAAC,kBAAkB,GAAG;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG,IAAI,CAAA;CACvD;AAED;;;;;;;;;;;;GAYG;AACH,qBAAa,WAAW;;IAGtB;;;OAGG;gBACS,OAAO,EAAE,MAAM,OAAO,CAAC,eAAe,CAAC;IAInD;;;;;OAKG;IACG,GAAG,IAAI,OAAO,CAAC,aAAa,CAAC;IAMnC;;;;;;;;;OASG;IACG,OAAO,IAAI,OAAO,CAAC,eAAe,CAAC;IAUzC;;;;OAIG;IACH,KAAK,IAAI,IAAI;CAGd;AAED;;;;;GAKG;AACH,UAAU,WAAW;IACnB,OAAO,EAAE,MAAM,CAAA;IACf,YAAY,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,kBAAkB,CAAA;IAC7B,UAAU,CAAC,EAAE,KAAK,CAAA;CACnB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE,WAAW,GACnB,WAAW,CAEb;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,EAAE,aAyD3B,CAAA;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,YAAY,CAChC,OAAO,EAAE,aAAa,EACtB,EAAE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,WAAW,GAC3D,OAAO,CAAC,eAAe,CAAC,CA4E1B;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,aAAa,EACtB,EACE,OAAO,EACP,YAAY,EACZ,UAAU,EACX,EAAE;IACD,OAAO,EAAE,MAAM,CAAA;IACf,YAAY,EAAE,MAAM,CAAA;IACpB,UAAU,CAAC,EAAE,oBAAoB,CAAA;CAClC,GACA,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAc/B"}
|
package/dist/internal/codec.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { prepareBody, parseResource } from './content.js';
|
|
1
|
+
import { decodedStream, mediaType, prepareBody, parseResource } from './content.js';
|
|
2
|
+
import { bytesToStream } from './blob.js';
|
|
2
3
|
import { asCollectionMetadata, storedEncryption, unreadableDescriptionError } from './describe.js';
|
|
3
4
|
import { readCollectionMetadata } from './meta.js';
|
|
4
5
|
import { readIndexSchema } from './indexSchema.js';
|
|
@@ -86,8 +87,9 @@ export function collectionCodecHolder(context, options) {
|
|
|
86
87
|
* caller's `id` (so `put(id, ...)` is a `PUT` and `add(...)`, with no id, stays
|
|
87
88
|
* a server-minting `POST`) and reuses `prepareBody` -- including the
|
|
88
89
|
* filename-extension content-type guess when an id is present. `decode` reuses
|
|
89
|
-
* `parseResource
|
|
90
|
-
*
|
|
90
|
+
* `parseResource`, and `decodeStream` hands back the response body itself.
|
|
91
|
+
* `encodeMeta` / `decodeMeta` are the identity transform, so metadata
|
|
92
|
+
* round-trips as server-visible plaintext byte-for-byte.
|
|
91
93
|
*/
|
|
92
94
|
export const identityCodec = {
|
|
93
95
|
async encode({ id, data, contentType }) {
|
|
@@ -100,6 +102,27 @@ export const identityCodec = {
|
|
|
100
102
|
async decode(response) {
|
|
101
103
|
return (await parseResource(response));
|
|
102
104
|
},
|
|
105
|
+
// Narrowed to `HttpResponse` like `decode`. A body the http-client already
|
|
106
|
+
// parsed into `data` (a JSON content type) has a spent stream, so it is
|
|
107
|
+
// re-serialized through `decodedStream`: semantically identical JSON, not
|
|
108
|
+
// guaranteed byte-identical. Any other body is passed on unread, and an
|
|
109
|
+
// absent body (a bodiless response) reads as an empty stream. The reported
|
|
110
|
+
// type is the bare media type (no `; charset=...`), as the seam documents
|
|
111
|
+
// and as an encrypting codec's sealed type is, so a caller sees one shape
|
|
112
|
+
// whichever codec served the read.
|
|
113
|
+
async decodeStream(response) {
|
|
114
|
+
const contentType = mediaType(response.headers.get('content-type') ?? '') || undefined;
|
|
115
|
+
if (response.data !== undefined) {
|
|
116
|
+
return decodedStream({
|
|
117
|
+
value: response.data,
|
|
118
|
+
...(contentType !== undefined && { contentType })
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
const stream = response.body
|
|
122
|
+
? response.body
|
|
123
|
+
: bytesToStream(new Uint8Array(0));
|
|
124
|
+
return { stream, ...(contentType !== undefined && { contentType }) };
|
|
125
|
+
},
|
|
103
126
|
async encodeMeta({ custom }) {
|
|
104
127
|
return { custom };
|
|
105
128
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codec.js","sourceRoot":"","sources":["../../src/internal/codec.ts"],"names":[],"mappings":"AA8BA,OAAO,
|
|
1
|
+
{"version":3,"file":"codec.js","sourceRoot":"","sources":["../../src/internal/codec.ts"],"names":[],"mappings":"AA8BA,OAAO,EACL,aAAa,EACb,SAAS,EACT,WAAW,EACX,aAAa,EACd,MAAM,cAAc,CAAA;AACrB,O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AAE,CAAC;QAClB,OAAO,IAAI,CAAA;IACb,CAAC;IACD,OAAO,YAAY,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAA;AACtC,CAAC"}
|
|
@@ -7,10 +7,12 @@
|
|
|
7
7
|
* as JSON; a `Blob`/`Uint8Array`/`Buffer` is sent as binary, with the
|
|
8
8
|
* content-type taken from `options.contentType`, the `Blob.type`, a guess from
|
|
9
9
|
* the resource id's file extension (`options.filename`), or
|
|
10
|
-
* `application/octet-stream`.
|
|
10
|
+
* `application/octet-stream`. A `ReadableStream<Uint8Array>` is classified as
|
|
11
|
+
* a stream, which only an encrypting codec can store; the plaintext path
|
|
12
|
+
* refuses it.
|
|
11
13
|
*/
|
|
12
14
|
import type { HttpResponse } from '@interop/http-client';
|
|
13
|
-
import type { ResponseLike } from '../codec.js';
|
|
15
|
+
import type { DecodedStream, ResponseLike } from '../codec.js';
|
|
14
16
|
import type { Json, ResourceData } from '../types.js';
|
|
15
17
|
/**
|
|
16
18
|
* The content type a resource log is stored under (JSON Lines, not JSON --
|
|
@@ -34,6 +36,14 @@ export declare const ENCODER: TextEncoder;
|
|
|
34
36
|
* path, protected-header bytes on the read path.
|
|
35
37
|
*/
|
|
36
38
|
export declare const DECODER: TextDecoder;
|
|
39
|
+
/**
|
|
40
|
+
* The bare media type of a `Content-Type` value: `text/plain; charset=utf-8`
|
|
41
|
+
* is `text/plain`. Case is kept as given.
|
|
42
|
+
*
|
|
43
|
+
* @param contentType {string}
|
|
44
|
+
* @returns {string}
|
|
45
|
+
*/
|
|
46
|
+
export declare function mediaType(contentType: string): string;
|
|
37
47
|
/**
|
|
38
48
|
* Whether a content type denotes UTF-8-safe text that should be stored inline as
|
|
39
49
|
* a plain string (legible, no ~33% base64 inflation) rather than as opaque
|
|
@@ -67,6 +77,17 @@ export declare function guessContentTypeFromId(id: string): string | undefined;
|
|
|
67
77
|
* @returns {boolean}
|
|
68
78
|
*/
|
|
69
79
|
export declare function isBlob(value: unknown): value is Blob;
|
|
80
|
+
/**
|
|
81
|
+
* Whether a value is a `ReadableStream`. Duck-typed on `getReader` rather
|
|
82
|
+
* than `instanceof`, so a stream from another realm or a polyfill counts (and
|
|
83
|
+
* so it works where the `ReadableStream` global is undefined): no JSON value
|
|
84
|
+
* has a `getReader` method, and classifying such a stream as JSON would
|
|
85
|
+
* silently store `{}`.
|
|
86
|
+
*
|
|
87
|
+
* @param value {unknown}
|
|
88
|
+
* @returns {boolean}
|
|
89
|
+
*/
|
|
90
|
+
export declare function isReadableStream(value: unknown): value is ReadableStream<Uint8Array>;
|
|
70
91
|
/**
|
|
71
92
|
* Coerces a `Uint8Array` (including a Node `Buffer`, which is a subclass) to a
|
|
72
93
|
* plain `Uint8Array` view, as ezcap's `body` type expects.
|
|
@@ -77,35 +98,45 @@ export declare function isBlob(value: unknown): value is Blob;
|
|
|
77
98
|
export declare function toPlainBytes(bytes: Uint8Array): Uint8Array;
|
|
78
99
|
/**
|
|
79
100
|
* Write data classified by `resolvePayload`: binary (a `Blob`/`Uint8Array`
|
|
80
|
-
* with its resolved content-type),
|
|
81
|
-
*
|
|
101
|
+
* with its resolved content-type), a stream (a `ReadableStream<Uint8Array>`
|
|
102
|
+
* with its resolved content-type, size unknown), JSON (a plain object/array),
|
|
103
|
+
* or invalid (a bare primitive -- the caller throws its own error message).
|
|
82
104
|
*/
|
|
83
105
|
type ResolvedPayload = {
|
|
84
106
|
kind: 'binary';
|
|
85
107
|
data: Blob | Uint8Array;
|
|
86
108
|
contentType: string;
|
|
109
|
+
} | {
|
|
110
|
+
kind: 'stream';
|
|
111
|
+
data: ReadableStream<Uint8Array>;
|
|
112
|
+
contentType: string;
|
|
87
113
|
} | {
|
|
88
114
|
kind: 'json';
|
|
89
115
|
} | {
|
|
90
116
|
kind: 'invalid';
|
|
91
117
|
};
|
|
92
118
|
/**
|
|
93
|
-
* Classifies write data as binary or JSON and resolves the binary
|
|
94
|
-
* content-type -- the single source of the detection and precedence
|
|
95
|
-
* shared by the plaintext `prepareBody` and the EDV codec's document
|
|
119
|
+
* Classifies write data as binary, a stream, or JSON and resolves the binary
|
|
120
|
+
* or stream content-type -- the single source of the detection and precedence
|
|
121
|
+
* rules shared by the plaintext `prepareBody` and the EDV codec's document
|
|
122
|
+
* builder.
|
|
96
123
|
*
|
|
97
124
|
* The binary content-type resolves in precedence order: an explicit
|
|
98
125
|
* `contentType`, then a non-empty `Blob.type`, then a guess from the resource
|
|
99
126
|
* `id`'s extension, then `application/octet-stream`. (Coalescing with `||`
|
|
100
127
|
* rather than `??` so an empty-string `Blob.type` -- a typeless Blob -- falls
|
|
101
|
-
* through to the guess instead of becoming an empty content-type.)
|
|
128
|
+
* through to the guess instead of becoming an empty content-type.) A stream
|
|
129
|
+
* resolves the same way as a `Uint8Array`, since it has no `Blob.type`: an
|
|
130
|
+
* explicit `contentType`, then the extension guess, then
|
|
131
|
+
* `application/octet-stream`. A stream is tested before the JSON branch, so it
|
|
132
|
+
* is never mistaken for a plain object.
|
|
102
133
|
*
|
|
103
134
|
* @param options {object}
|
|
104
135
|
* @param options.data {ResourceData} the resource content
|
|
105
136
|
* @param [options.contentType] {string} overrides the inferred content-type
|
|
106
|
-
* for binary data
|
|
137
|
+
* for binary or stream data
|
|
107
138
|
* @param [options.id] {string} resource id used to guess a
|
|
108
|
-
* content-type by extension when none is given (binary data only)
|
|
139
|
+
* content-type by extension when none is given (binary or stream data only)
|
|
109
140
|
* @returns {ResolvedPayload}
|
|
110
141
|
*/
|
|
111
142
|
export declare function resolvePayload({ data, contentType, id }: {
|
|
@@ -117,6 +148,10 @@ export declare function resolvePayload({ data, contentType, id }: {
|
|
|
117
148
|
* Inspects write data and resolves it to a JSON or binary payload, using
|
|
118
149
|
* {@link resolvePayload} for the detection and content-type precedence rules.
|
|
119
150
|
*
|
|
151
|
+
* A `ReadableStream` is refused with `ValidationError`. A plaintext resource
|
|
152
|
+
* has no chunked representation, and every signed request carries a `Digest`
|
|
153
|
+
* of its whole body, so a stream cannot be sent as one plaintext resource.
|
|
154
|
+
*
|
|
120
155
|
* @param data {ResourceData} the resource content
|
|
121
156
|
* @param options {object}
|
|
122
157
|
* @param [options.contentType] {string} overrides the inferred content-type
|
|
@@ -221,5 +256,25 @@ export declare function parseResource(response: HttpResponse | null): Promise<Js
|
|
|
221
256
|
* @returns {Promise<string>}
|
|
222
257
|
*/
|
|
223
258
|
export declare function decodedText(value: Json | Blob): Promise<string>;
|
|
259
|
+
/**
|
|
260
|
+
* Presents a decoded resource value (the `Json | Blob` a codec's `decode`
|
|
261
|
+
* produces) as a byte stream -- the in-memory fallback of a streaming read,
|
|
262
|
+
* for a value that is already buffered. A `Blob` streams its bytes; a parsed
|
|
263
|
+
* JSON value is re-serialized to UTF-8, matching {@link decodedText}
|
|
264
|
+
* (semantically identical JSON, not guaranteed byte-identical).
|
|
265
|
+
*
|
|
266
|
+
* The reported content type is the caller's `contentType` when it knows the
|
|
267
|
+
* resource type (an encrypting codec's sealed plaintext type), else a
|
|
268
|
+
* non-empty `Blob.type` for a blob, or `application/json` for a JSON value.
|
|
269
|
+
*
|
|
270
|
+
* @param options {object}
|
|
271
|
+
* @param options.value {Json | Blob} the decoded value
|
|
272
|
+
* @param [options.contentType] {string} the plaintext resource type
|
|
273
|
+
* @returns {DecodedStream}
|
|
274
|
+
*/
|
|
275
|
+
export declare function decodedStream({ value, contentType }: {
|
|
276
|
+
value: Json | Blob;
|
|
277
|
+
contentType?: string;
|
|
278
|
+
}): DecodedStream;
|
|
224
279
|
export {};
|
|
225
280
|
//# sourceMappingURL=content.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../src/internal/content.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH
|
|
1
|
+
{"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../src/internal/content.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,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