@interop/was-client 0.1.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.
Files changed (51) hide show
  1. package/LICENSE.md +20 -0
  2. package/README.md +204 -0
  3. package/dist/Collection.d.ts +112 -0
  4. package/dist/Collection.d.ts.map +1 -0
  5. package/dist/Collection.js +209 -0
  6. package/dist/Collection.js.map +1 -0
  7. package/dist/Resource.d.ts +67 -0
  8. package/dist/Resource.d.ts.map +1 -0
  9. package/dist/Resource.js +124 -0
  10. package/dist/Resource.js.map +1 -0
  11. package/dist/Space.d.ts +99 -0
  12. package/dist/Space.d.ts.map +1 -0
  13. package/dist/Space.js +202 -0
  14. package/dist/Space.js.map +1 -0
  15. package/dist/WasClient.d.ts +115 -0
  16. package/dist/WasClient.d.ts.map +1 -0
  17. package/dist/WasClient.js +191 -0
  18. package/dist/WasClient.js.map +1 -0
  19. package/dist/errors.d.ts +72 -0
  20. package/dist/errors.d.ts.map +1 -0
  21. package/dist/errors.js +112 -0
  22. package/dist/errors.js.map +1 -0
  23. package/dist/index.d.ts +14 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +13 -0
  26. package/dist/index.js.map +1 -0
  27. package/dist/internal/content.d.ts +43 -0
  28. package/dist/internal/content.d.ts.map +1 -0
  29. package/dist/internal/content.js +66 -0
  30. package/dist/internal/content.js.map +1 -0
  31. package/dist/internal/grant.d.ts +21 -0
  32. package/dist/internal/grant.d.ts.map +1 -0
  33. package/dist/internal/grant.js +19 -0
  34. package/dist/internal/grant.js.map +1 -0
  35. package/dist/internal/paths.d.ts +70 -0
  36. package/dist/internal/paths.d.ts.map +1 -0
  37. package/dist/internal/paths.js +92 -0
  38. package/dist/internal/paths.js.map +1 -0
  39. package/dist/internal/request.d.ts +64 -0
  40. package/dist/internal/request.d.ts.map +1 -0
  41. package/dist/internal/request.js +60 -0
  42. package/dist/internal/request.js.map +1 -0
  43. package/dist/internal/reserved.d.ts +16 -0
  44. package/dist/internal/reserved.d.ts.map +1 -0
  45. package/dist/internal/reserved.js +40 -0
  46. package/dist/internal/reserved.js.map +1 -0
  47. package/dist/types.d.ts +165 -0
  48. package/dist/types.d.ts.map +1 -0
  49. package/dist/types.js +2 -0
  50. package/dist/types.js.map +1 -0
  51. package/package.json +84 -0
@@ -0,0 +1,191 @@
1
+ /*!
2
+ * Copyright (c) 2026 Interop Alliance. All rights reserved.
3
+ */
4
+ /**
5
+ * The top-level WAS client. Wraps an ezcap `ZcapClient` (which holds the active
6
+ * signer) and exposes the WAS containment model
7
+ * (`SpacesRepository > Space > Collection > Resource`) through lazy
8
+ * navigational handles. Also hosts the general delegation primitive
9
+ * (`grant`), capability-rebuilding (`fromCapability`), and the signed
10
+ * escape-hatch (`request`).
11
+ */
12
+ import { ZcapClient } from '@interop/ezcap';
13
+ import { Ed25519Signature2020 } from '@interop/ed25519-signature';
14
+ import { spacesRoot } from './internal/paths.js';
15
+ import { send, rawRequest } from './internal/request.js';
16
+ import { delegateGrant } from './internal/grant.js';
17
+ import { ValidationError } from './errors.js';
18
+ import { Space } from './Space.js';
19
+ import { Collection } from './Collection.js';
20
+ import { Resource } from './Resource.js';
21
+ export class WasClient {
22
+ serverUrl;
23
+ zcapClient;
24
+ /**
25
+ * @param options {object}
26
+ * @param options.serverUrl {string} base URL for both URL building and
27
+ * zcap `invocationTarget`s
28
+ * @param options.zcapClient {ZcapClient} an ezcap client holding the signer
29
+ */
30
+ constructor({ serverUrl, zcapClient }) {
31
+ this.serverUrl = serverUrl;
32
+ this.zcapClient = zcapClient;
33
+ }
34
+ /**
35
+ * Convenience constructor that builds the ezcap `ZcapClient` internally from
36
+ * a signer, using the `Ed25519Signature2020` suite.
37
+ *
38
+ * @param options {object}
39
+ * @param options.serverUrl {string}
40
+ * @param options.signer {ISigner}
41
+ * @returns {WasClient}
42
+ */
43
+ static fromSigner({ serverUrl, signer }) {
44
+ const zcapClient = new ZcapClient({
45
+ SuiteClass: Ed25519Signature2020,
46
+ invocationSigner: signer,
47
+ delegationSigner: signer
48
+ });
49
+ return new WasClient({ serverUrl, zcapClient });
50
+ }
51
+ /**
52
+ * The DID controlling the wrapped signer (`signer.id` without the key
53
+ * fragment). Used to default `controller` on `createSpace`.
54
+ *
55
+ * @returns {string}
56
+ */
57
+ get controllerDid() {
58
+ const signer = this.zcapClient.invocationSigner;
59
+ if (!signer?.id) {
60
+ throw new ValidationError('The wrapped ZcapClient has no invocationSigner id.');
61
+ }
62
+ return signer.id.split('#')[0];
63
+ }
64
+ get _context() {
65
+ return {
66
+ serverUrl: this.serverUrl,
67
+ zcapClient: this.zcapClient,
68
+ controllerDid: this.controllerDid
69
+ };
70
+ }
71
+ /**
72
+ * Returns a lazy handle to a space by id. No I/O.
73
+ *
74
+ * @param spaceId {string}
75
+ * @param options {object}
76
+ * @param [options.capability] {IZcap}
77
+ * @returns {Space}
78
+ */
79
+ space(spaceId, options = {}) {
80
+ return new Space({
81
+ context: this._context,
82
+ spaceId,
83
+ capability: options.capability
84
+ });
85
+ }
86
+ /**
87
+ * Creates a space (server-generated id unless `id` is given). The server
88
+ * requires `name`, and `controller` must match the wrapped signer's DID
89
+ * (which is the default).
90
+ *
91
+ * @param desc {object}
92
+ * @param [desc.id] {string}
93
+ * @param [desc.name] {string}
94
+ * @param [desc.controller] {string}
95
+ * @returns {Promise<Space>}
96
+ */
97
+ async createSpace(desc = {}) {
98
+ const controller = desc.controller ?? this.controllerDid;
99
+ const body = { controller };
100
+ if (desc.id !== undefined) {
101
+ body.id = desc.id;
102
+ }
103
+ if (desc.name !== undefined) {
104
+ body.name = desc.name;
105
+ }
106
+ const response = await send(this._context, {
107
+ path: spacesRoot(),
108
+ method: 'POST',
109
+ json: body
110
+ });
111
+ const created = response.data;
112
+ return this.space(created.id);
113
+ }
114
+ /**
115
+ * Lists the spaces in the repository. Not yet implemented by the reference
116
+ * server, which answers 501 -- so this currently throws
117
+ * `NotImplementedError`.
118
+ *
119
+ * @returns {Promise<SpaceListing>}
120
+ */
121
+ async listSpaces() {
122
+ const response = await send(this._context, {
123
+ path: spacesRoot(),
124
+ method: 'GET'
125
+ });
126
+ return response.data;
127
+ }
128
+ /**
129
+ * Rebuilds an access handle from a received capability, returning a handle at
130
+ * the depth implied by the capability's `invocationTarget` (space /
131
+ * collection / resource), pre-bound with that capability.
132
+ *
133
+ * @param zcap {IZcap}
134
+ * @returns {Space | Collection | Resource}
135
+ */
136
+ fromCapability(zcap) {
137
+ const { pathname } = new URL(zcap.invocationTarget);
138
+ const segments = pathname.split('/').filter(Boolean);
139
+ if (segments[0] !== 'space') {
140
+ throw new ValidationError(`Cannot derive a handle from invocationTarget "${zcap.invocationTarget}".`);
141
+ }
142
+ const [, spaceId, collectionId, resourceId] = segments;
143
+ if (!spaceId) {
144
+ throw new ValidationError(`invocationTarget "${zcap.invocationTarget}" has no space id.`);
145
+ }
146
+ const context = this._context;
147
+ if (resourceId) {
148
+ return new Resource({
149
+ context,
150
+ spaceId,
151
+ collectionId: collectionId,
152
+ resourceId,
153
+ capability: zcap
154
+ });
155
+ }
156
+ if (collectionId) {
157
+ return new Collection({
158
+ context,
159
+ spaceId,
160
+ collectionId,
161
+ capability: zcap
162
+ });
163
+ }
164
+ return new Space({ context, spaceId, capability: zcap });
165
+ }
166
+ /**
167
+ * The general delegation primitive. Delegates a capability per `GrantOptions`
168
+ * and returns the signed zcap to hand off out-of-band. `target` (any URL) and
169
+ * `capability` (a parent capability to attenuate) make this a superset of the
170
+ * `space`/`collection` grant sugar.
171
+ *
172
+ * @param options {GrantOptions}
173
+ * @returns {Promise<IDelegatedZcap>}
174
+ */
175
+ async grant(options) {
176
+ return delegateGrant(this._context, options);
177
+ }
178
+ /**
179
+ * The signed escape hatch, mirroring ezcap's generic `request()`. Resolves
180
+ * `path` against `serverUrl`, defaults `action` to `method`, and signs via the
181
+ * wrapped client. Returns the raw `HttpResponse` and throws raw ky/ezcap
182
+ * errors -- it does not apply the null-on-404 or typed-error conveniences.
183
+ *
184
+ * @param options {RequestInput}
185
+ * @returns {Promise<HttpResponse>}
186
+ */
187
+ async request(options) {
188
+ return rawRequest(this._context, options);
189
+ }
190
+ }
191
+ //# sourceMappingURL=WasClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WasClient.js","sourceRoot":"","sources":["../src/WasClient.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;GAOG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AAEjE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAEhD,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAWxC,MAAM,OAAO,SAAS;IACX,SAAS,CAAQ;IACjB,UAAU,CAAY;IAE/B;;;;;OAKG;IACH,YAAY,EACV,SAAS,EACT,UAAU,EAIX;QACC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAC1B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAC9B,CAAC;IAED;;;;;;;;OAQG;IACH,MAAM,CAAC,UAAU,CAAC,EAChB,SAAS,EACT,MAAM,EAIP;QACC,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC;YAChC,UAAU,EAAE,oBAAoB;YAChC,gBAAgB,EAAE,MAAM;YACxB,gBAAgB,EAAE,MAAM;SACzB,CAAC,CAAA;QACF,OAAO,IAAI,SAAS,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC,CAAA;IACjD,CAAC;IAED;;;;;O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U,CAAC;gBACpB,OAAO;gBACP,OAAO;gBACP,YAAY;gBACZ,UAAU,EAAE,IAAI;aACjB,CAAC,CAAA;QACJ,CAAC;QACD,OAAO,IAAI,KAAK,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAA;IAC1D,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,KAAK,CAAC,OAAqB;QAC/B,OAAO,aAAa,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;IAC9C,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,OAAO,CAAC,OAAqB;QACjC,OAAO,UAAU,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;IAC3C,CAAC;CACF"}
@@ -0,0 +1,72 @@
1
+ /*!
2
+ * Copyright (c) 2026 Interop Alliance. All rights reserved.
3
+ */
4
+ /**
5
+ * Typed error hierarchy for the WAS client. A `WasError` base carries the
6
+ * server's `application/problem+json` fields (`status` / `title` / `details` /
7
+ * `requestUrl`); `mapError()` translates a thrown ky/ezcap error into the
8
+ * appropriate subclass.
9
+ */
10
+ /**
11
+ * Structured fields attached to a `WasError`, sourced from the server's
12
+ * `application/problem+json` response body.
13
+ */
14
+ export interface WasErrorOptions {
15
+ status?: number;
16
+ title?: string;
17
+ details?: string[];
18
+ requestUrl?: string;
19
+ cause?: unknown;
20
+ }
21
+ /**
22
+ * Base class for all errors thrown by the high-level client methods.
23
+ */
24
+ export declare class WasError extends Error {
25
+ status?: number;
26
+ title?: string;
27
+ details?: string[];
28
+ requestUrl?: string;
29
+ constructor(message: string, options?: WasErrorOptions);
30
+ }
31
+ /**
32
+ * The target was not found -- or it exists but is not visible to the caller.
33
+ * WAS returns 404 for both not-found and unauthorized, so a `NotFoundError`
34
+ * means "not visible to you" rather than strictly "does not exist".
35
+ */
36
+ export declare class NotFoundError extends WasError {
37
+ constructor(message: string, options?: WasErrorOptions);
38
+ }
39
+ /**
40
+ * The request was malformed or rejected as invalid (HTTP 400).
41
+ */
42
+ export declare class ValidationError extends WasError {
43
+ constructor(message: string, options?: WasErrorOptions);
44
+ }
45
+ /**
46
+ * Authorization headers were missing or could not be verified (HTTP 401).
47
+ */
48
+ export declare class AuthRequiredError extends WasError {
49
+ constructor(message: string, options?: WasErrorOptions);
50
+ }
51
+ /**
52
+ * The endpoint exists in the spec but is not yet implemented by the server
53
+ * (HTTP 501).
54
+ */
55
+ export declare class NotImplementedError extends WasError {
56
+ constructor(message: string, options?: WasErrorOptions);
57
+ }
58
+ /**
59
+ * The server encountered an internal fault (HTTP 5xx).
60
+ */
61
+ export declare class WasServerError extends WasError {
62
+ constructor(message: string, options?: WasErrorOptions);
63
+ }
64
+ /**
65
+ * Translates a thrown ky/ezcap error into the appropriate `WasError` subclass,
66
+ * carrying through the server's `problem+json` fields.
67
+ *
68
+ * @param err {unknown} the caught error
69
+ * @returns {WasError}
70
+ */
71
+ export declare function mapError(err: unknown): WasError;
72
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;GAKG;AAEH;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAED;;GAEG;AACH,qBAAa,QAAS,SAAQ,KAAK;IACjC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,CAAA;gBAEP,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB;CAS3D;AAED;;;;GAIG;AACH,qBAAa,aAAc,SAAQ,QAAQ;gBAC7B,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB;CAI3D;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,QAAQ;gBAC/B,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB;CAI3D;AAED;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,QAAQ;gBACjC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB;CAI3D;AAED;;;GAGG;AACH,qBAAa,mBAAoB,SAAQ,QAAQ;gBACnC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB;CAI3D;AAED;;GAEG;AACH,qBAAa,cAAe,SAAQ,QAAQ;gBAC9B,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB;CAI3D;AAcD;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,QAAQ,CAgC/C"}
package/dist/errors.js ADDED
@@ -0,0 +1,112 @@
1
+ /*!
2
+ * Copyright (c) 2026 Interop Alliance. All rights reserved.
3
+ */
4
+ /**
5
+ * Typed error hierarchy for the WAS client. A `WasError` base carries the
6
+ * server's `application/problem+json` fields (`status` / `title` / `details` /
7
+ * `requestUrl`); `mapError()` translates a thrown ky/ezcap error into the
8
+ * appropriate subclass.
9
+ */
10
+ /**
11
+ * Base class for all errors thrown by the high-level client methods.
12
+ */
13
+ export class WasError extends Error {
14
+ status;
15
+ title;
16
+ details;
17
+ requestUrl;
18
+ constructor(message, options = {}) {
19
+ const { status, title, details, requestUrl, cause } = options;
20
+ super(message, cause !== undefined ? { cause } : undefined);
21
+ this.name = 'WasError';
22
+ this.status = status;
23
+ this.title = title;
24
+ this.details = details;
25
+ this.requestUrl = requestUrl;
26
+ }
27
+ }
28
+ /**
29
+ * The target was not found -- or it exists but is not visible to the caller.
30
+ * WAS returns 404 for both not-found and unauthorized, so a `NotFoundError`
31
+ * means "not visible to you" rather than strictly "does not exist".
32
+ */
33
+ export class NotFoundError extends WasError {
34
+ constructor(message, options = {}) {
35
+ super(message, options);
36
+ this.name = 'NotFoundError';
37
+ }
38
+ }
39
+ /**
40
+ * The request was malformed or rejected as invalid (HTTP 400).
41
+ */
42
+ export class ValidationError extends WasError {
43
+ constructor(message, options = {}) {
44
+ super(message, options);
45
+ this.name = 'ValidationError';
46
+ }
47
+ }
48
+ /**
49
+ * Authorization headers were missing or could not be verified (HTTP 401).
50
+ */
51
+ export class AuthRequiredError extends WasError {
52
+ constructor(message, options = {}) {
53
+ super(message, options);
54
+ this.name = 'AuthRequiredError';
55
+ }
56
+ }
57
+ /**
58
+ * The endpoint exists in the spec but is not yet implemented by the server
59
+ * (HTTP 501).
60
+ */
61
+ export class NotImplementedError extends WasError {
62
+ constructor(message, options = {}) {
63
+ super(message, options);
64
+ this.name = 'NotImplementedError';
65
+ }
66
+ }
67
+ /**
68
+ * The server encountered an internal fault (HTTP 5xx).
69
+ */
70
+ export class WasServerError extends WasError {
71
+ constructor(message, options = {}) {
72
+ super(message, options);
73
+ this.name = 'WasServerError';
74
+ }
75
+ }
76
+ /**
77
+ * Translates a thrown ky/ezcap error into the appropriate `WasError` subclass,
78
+ * carrying through the server's `problem+json` fields.
79
+ *
80
+ * @param err {unknown} the caught error
81
+ * @returns {WasError}
82
+ */
83
+ export function mapError(err) {
84
+ if (err instanceof WasError) {
85
+ return err;
86
+ }
87
+ const httpError = (err ?? {});
88
+ const status = httpError.status ?? httpError.response?.status;
89
+ const data = httpError.data;
90
+ const title = data?.title;
91
+ const details = data?.errors
92
+ ?.map(entry => entry.detail)
93
+ .filter((detail) => typeof detail === 'string');
94
+ const requestUrl = httpError.requestUrl;
95
+ const message = title ?? httpError.message ?? 'WAS request failed';
96
+ const options = { status, title, details, requestUrl, cause: err };
97
+ switch (status) {
98
+ case 400:
99
+ return new ValidationError(message, options);
100
+ case 401:
101
+ return new AuthRequiredError(message, options);
102
+ case 404:
103
+ return new NotFoundError(message, options);
104
+ case 501:
105
+ return new NotImplementedError(message, options);
106
+ }
107
+ if (typeof status === 'number' && status >= 500) {
108
+ return new WasServerError(message, options);
109
+ }
110
+ return new WasError(message, options);
111
+ }
112
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;GAKG;AAcH;;GAEG;AACH,MAAM,OAAO,QAAS,SAAQ,KAAK;IACjC,MAAM,CAAS;IACf,KAAK,CAAS;IACd,OAAO,CAAW;IAClB,UAAU,CAAS;IAEnB,YAAY,OAAe,EAAE,UAA2B,EAAE;QACxD,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,OAAO,CAAA;QAC7D,KAAK,CAAC,OAAO,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;QAC3D,IAAI,CAAC,IAAI,GAAG,UAAU,CAAA;QACtB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAC9B,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,OAAO,aAAc,SAAQ,QAAQ;IACzC,YAAY,OAAe,EAAE,UAA2B,EAAE;QACxD,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QACvB,IAAI,CAAC,IAAI,GAAG,eAAe,CAAA;IAC7B,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,QAAQ;IAC3C,YAAY,OAAe,EAAE,UAA2B,EAAE;QACxD,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QACvB,IAAI,CAAC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,MAAM,UAAU,GAAG,SAAS,CAAC,UAAU,CAAA;IACvC,MAAM,OAAO,GAAG,KAAK,IAAI,SAAS,CAAC,OAAO,IAAI,oBAAoB,CAAA;IAClE,MAAM,OAAO,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,EAAE,CAAA;IAElE,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,GAAG;YACN,OAAO,IAAI,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QAC9C,KAAK,GAAG;YACN,OAAO,IAAI,iBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QAChD,KAAK,GAAG;YACN,OAAO,IAAI,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QAC5C,KAAK,GAAG;YACN,OAAO,IAAI,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IACpD,CAAC;IAED,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,IAAI,GAAG,EAAE,CAAC;QAChD,OAAO,IAAI,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IAC7C,CAAC;IAED,OAAO,IAAI,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;AACvC,CAAC"}
@@ -0,0 +1,14 @@
1
+ /*!
2
+ * Copyright (c) 2026 Interop Alliance. All rights reserved.
3
+ */
4
+ /**
5
+ * Public entry point for `@interop/was-client`: the `WasClient` and its
6
+ * navigational handles, the typed error hierarchy, and the shared types.
7
+ */
8
+ export { WasClient } from './WasClient.js';
9
+ export { Space } from './Space.js';
10
+ export { Collection } from './Collection.js';
11
+ export { Resource } from './Resource.js';
12
+ export { WasError, NotFoundError, ValidationError, AuthRequiredError, NotImplementedError, WasServerError, mapError } from './errors.js';
13
+ export type { Json, JsonPrimitive, JsonObject, JsonArray, Action, ActionInput, SpaceDescription, CollectionDescription, CollectionSummary, CollectionListing, SpaceSummary, SpaceListing, ResourceSummary, ResourceListing, AddResult, ImportStats, HandleOptions, BackendReference, GrantOptions, RequestInput, IZcap, IDelegatedZcap, ISigner } from './types.js';
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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;AAExC,OAAO,EACL,QAAQ,EACR,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,QAAQ,EACT,MAAM,aAAa,CAAA;AAEpB,YAAY,EACV,IAAI,EACJ,aAAa,EACb,UAAU,EACV,SAAS,EACT,MAAM,EACN,WAAW,EACX,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,eAAe,EACf,SAAS,EACT,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,KAAK,EACL,cAAc,EACd,OAAO,EACR,MAAM,YAAY,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,13 @@
1
+ /*!
2
+ * Copyright (c) 2026 Interop Alliance. All rights reserved.
3
+ */
4
+ /**
5
+ * Public entry point for `@interop/was-client`: the `WasClient` and its
6
+ * navigational handles, the typed error hierarchy, and the shared types.
7
+ */
8
+ export { WasClient } from './WasClient.js';
9
+ export { Space } from './Space.js';
10
+ export { Collection } from './Collection.js';
11
+ export { Resource } from './Resource.js';
12
+ export { WasError, NotFoundError, ValidationError, AuthRequiredError, NotImplementedError, WasServerError, mapError } from './errors.js';
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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;AAExC,OAAO,EACL,QAAQ,EACR,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,QAAQ,EACT,MAAM,aAAa,CAAA"}
@@ -0,0 +1,43 @@
1
+ /*!
2
+ * Copyright (c) 2026 Interop Alliance. All rights reserved.
3
+ */
4
+ /**
5
+ * JSON-vs-binary detection and body coercion for resource writes, plus
6
+ * content-type-aware parsing for resource reads. A plain object/array is sent
7
+ * as JSON; a `Blob`/`Uint8Array`/`Buffer` is sent as binary, with the
8
+ * content-type taken from `options.contentType`, the `Blob.type`, or
9
+ * `application/octet-stream`.
10
+ */
11
+ import type { HttpResponse } from '@interop/http-client';
12
+ import type { Json } from '../types.js';
13
+ /**
14
+ * A write body resolved into either a JSON payload (passed to ezcap as `json`)
15
+ * or a binary payload with its content-type (passed as `body` + header).
16
+ */
17
+ export interface PreparedBody {
18
+ json?: object;
19
+ body?: Uint8Array | Blob;
20
+ contentType?: string;
21
+ }
22
+ /**
23
+ * Inspects write data and resolves it to a JSON or binary payload.
24
+ *
25
+ * @param data {Json | Blob | Uint8Array} the resource content
26
+ * @param options {object}
27
+ * @param [options.contentType] {string} overrides the inferred content-type
28
+ * for binary data
29
+ * @returns {PreparedBody}
30
+ */
31
+ export declare function prepareBody(data: Json | Blob | Uint8Array, options?: {
32
+ contentType?: string;
33
+ }): PreparedBody;
34
+ /**
35
+ * Parses a resource GET response: returns the parsed object when the stored
36
+ * content-type is JSON, otherwise a `Blob` whose `.type` carries the
37
+ * content-type. A `null` response (404) passes through as `null`.
38
+ *
39
+ * @param response {HttpResponse | null}
40
+ * @returns {Promise<Json | Blob | null>}
41
+ */
42
+ export declare function parseResource(response: HttpResponse | null): Promise<Json | Blob | null>;
43
+ //# sourceMappingURL=content.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../src/internal/content.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAExD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAIvC;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,UAAU,GAAG,IAAI,CAAA;IACxB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAoBD;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,UAAU,EAC9B,OAAO,GAAE;IAAE,WAAW,CAAC,EAAE,MAAM,CAAA;CAAO,GACrC,YAAY,CAwBd;AAED;;;;;;;GAOG;AACH,wBAAsB,aAAa,CACjC,QAAQ,EAAE,YAAY,GAAG,IAAI,GAC5B,OAAO,CAAC,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,CAS7B"}
@@ -0,0 +1,66 @@
1
+ import { ValidationError } from '../errors.js';
2
+ const OCTET_STREAM = 'application/octet-stream';
3
+ function isBlob(value) {
4
+ return typeof Blob !== 'undefined' && value instanceof Blob;
5
+ }
6
+ /**
7
+ * Coerces a `Uint8Array` (including a Node `Buffer`, which is a subclass) to a
8
+ * plain `Uint8Array` view, as ezcap's `body` type expects.
9
+ *
10
+ * @param bytes {Uint8Array}
11
+ * @returns {Uint8Array}
12
+ */
13
+ function toPlainBytes(bytes) {
14
+ if (bytes.constructor === Uint8Array) {
15
+ return bytes;
16
+ }
17
+ return new Uint8Array(bytes.buffer, bytes.byteOffset, bytes.byteLength);
18
+ }
19
+ /**
20
+ * Inspects write data and resolves it to a JSON or binary payload.
21
+ *
22
+ * @param data {Json | Blob | Uint8Array} the resource content
23
+ * @param options {object}
24
+ * @param [options.contentType] {string} overrides the inferred content-type
25
+ * for binary data
26
+ * @returns {PreparedBody}
27
+ */
28
+ export function prepareBody(data, options = {}) {
29
+ if (isBlob(data)) {
30
+ return {
31
+ body: data,
32
+ contentType: options.contentType ?? data.type ?? OCTET_STREAM
33
+ };
34
+ }
35
+ if (data instanceof Uint8Array) {
36
+ return {
37
+ body: toPlainBytes(data),
38
+ contentType: options.contentType ?? OCTET_STREAM
39
+ };
40
+ }
41
+ if (data !== null && typeof data === 'object') {
42
+ // Plain object or array -- send as JSON.
43
+ return { json: data };
44
+ }
45
+ throw new ValidationError('Resource data must be a plain object/array (JSON) or a ' +
46
+ 'Blob/Uint8Array (binary).');
47
+ }
48
+ /**
49
+ * Parses a resource GET response: returns the parsed object when the stored
50
+ * content-type is JSON, otherwise a `Blob` whose `.type` carries the
51
+ * content-type. A `null` response (404) passes through as `null`.
52
+ *
53
+ * @param response {HttpResponse | null}
54
+ * @returns {Promise<Json | Blob | null>}
55
+ */
56
+ export async function parseResource(response) {
57
+ if (response === null) {
58
+ return null;
59
+ }
60
+ const contentType = response.headers.get('content-type') ?? '';
61
+ if (contentType.includes('json')) {
62
+ return (response.data ?? (await response.json()));
63
+ }
64
+ return response.blob();
65
+ }
66
+ //# sourceMappingURL=content.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content.js","sourceRoot":"","sources":["../../src/internal/content.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAG9C,MAAM,YAAY,GAAG,0BAA0B,CAAA;AAY/C,SAAS,MAAM,CAAC,KAAc;IAC5B,OAAO,OAAO,IAAI,KAAK,WAAW,IAAI,KAAK,YAAY,IAAI,CAAA;AAC7D,CAAC;AAED;;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AI,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAS,CAAA;IAC3D,CAAC;IACD,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAA;AACxB,CAAC"}
@@ -0,0 +1,21 @@
1
+ /*!
2
+ * Copyright (c) 2026 Interop Alliance. All rights reserved.
3
+ */
4
+ /**
5
+ * The delegation primitive shared by `was.grant()` and the `space`/`collection`
6
+ * grant sugar. Maps `GrantOptions` onto `zcapClient.delegate(...)`, normalizing
7
+ * action verbs to uppercase so a lowercase grant (`'get'`) still validates on
8
+ * the server (which matches actions case-sensitively against `'GET'`).
9
+ */
10
+ import type { ClientContext } from './request.js';
11
+ import type { GrantOptions, IDelegatedZcap } from '../types.js';
12
+ /**
13
+ * Delegates a capability per `GrantOptions`, returning the signed zcap to hand
14
+ * off out-of-band.
15
+ *
16
+ * @param context {ClientContext}
17
+ * @param options {GrantOptions}
18
+ * @returns {Promise<IDelegatedZcap>}
19
+ */
20
+ export declare function delegateGrant(context: ClientContext, options: GrantOptions): Promise<IDelegatedZcap>;
21
+ //# sourceMappingURL=grant.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grant.d.ts","sourceRoot":"","sources":["../../src/internal/grant.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;GAKG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAE/D;;;;;;;GAOG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE,YAAY,GACpB,OAAO,CAAC,cAAc,CAAC,CASzB"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Delegates a capability per `GrantOptions`, returning the signed zcap to hand
3
+ * off out-of-band.
4
+ *
5
+ * @param context {ClientContext}
6
+ * @param options {GrantOptions}
7
+ * @returns {Promise<IDelegatedZcap>}
8
+ */
9
+ export async function delegateGrant(context, options) {
10
+ const { to, actions, expires, target, capability } = options;
11
+ return context.zcapClient.delegate({
12
+ controller: to,
13
+ invocationTarget: target,
14
+ allowedActions: actions.map(action => action.toUpperCase()),
15
+ expires,
16
+ capability
17
+ });
18
+ }
19
+ //# sourceMappingURL=grant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grant.js","sourceRoot":"","sources":["../../src/internal/grant.ts"],"names":[],"mappings":"AAYA;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,OAAsB,EACtB,OAAqB;IAErB,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAA;IAC5D,OAAO,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC;QACjC,UAAU,EAAE,EAAE;QACd,gBAAgB,EAAE,MAAM;QACxB,cAAc,EAAE,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;QAC3D,OAAO;QACP,UAAU;KACX,CAAC,CAAA;AACJ,CAAC"}