@reclaimprotocol/client 0.1.6 → 0.1.9

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/lib/client.js CHANGED
@@ -1,3 +1,15 @@
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _ReclaimClient_token, _ReclaimClient_fetch, _ReclaimClient_headers;
1
13
  import { notFound } from '@hapi/boom';
2
14
  import assert from 'node:assert';
3
15
  import { DEFAULT_BASE_URL, USER_AGENT } from "./consts.js";
@@ -16,25 +28,24 @@ import { ROUTES } from "./routes.gen.js";
16
28
  * to {@link ProblemError}.
17
29
  */
18
30
  export class ReclaimClient {
19
- baseUrl;
20
- #token;
21
- #fetch;
22
- #headers;
23
31
  constructor(opts = {}) {
32
+ _ReclaimClient_token.set(this, void 0);
33
+ _ReclaimClient_fetch.set(this, void 0);
34
+ _ReclaimClient_headers.set(this, void 0);
24
35
  this.baseUrl = (opts.baseUrl || DEFAULT_BASE_URL).replace(/\/$/, '');
25
- this.#token = opts.token;
26
- this.#fetch = opts.fetch || fetch;
27
- this.#headers = {
36
+ __classPrivateFieldSet(this, _ReclaimClient_token, opts.token, "f");
37
+ __classPrivateFieldSet(this, _ReclaimClient_fetch, opts.fetch || fetch, "f");
38
+ __classPrivateFieldSet(this, _ReclaimClient_headers, {
28
39
  'User-Agent': USER_AGENT,
29
40
  Accept: 'application/json',
30
41
  ...opts.headers,
31
- };
42
+ }, "f");
32
43
  }
33
44
  setToken(token) {
34
- this.#token = token;
45
+ __classPrivateFieldSet(this, _ReclaimClient_token, token, "f");
35
46
  }
36
47
  getToken() {
37
- return this.#token;
48
+ return __classPrivateFieldGet(this, _ReclaimClient_token, "f");
38
49
  }
39
50
  async call(operationId, ...argsRest) {
40
51
  const args = argsRest[0] ?? {};
@@ -64,11 +75,11 @@ export class ReclaimClient {
64
75
  url += `?${search.toString()}`;
65
76
  }
66
77
  const headers = {
67
- ...this.#headers,
78
+ ...__classPrivateFieldGet(this, _ReclaimClient_headers, "f"),
68
79
  Accept: 'application/json',
69
80
  };
70
- if (this.#token) {
71
- headers['Authorization'] = `Bearer ${this.#token}`;
81
+ if (__classPrivateFieldGet(this, _ReclaimClient_token, "f")) {
82
+ headers['Authorization'] = `Bearer ${__classPrivateFieldGet(this, _ReclaimClient_token, "f")}`;
72
83
  }
73
84
  // Per-request header parameters (e.g. `If-Match` for optimistic
74
85
  // concurrency). Applied last so spec-declared headers win over the
@@ -94,7 +105,7 @@ export class ReclaimClient {
94
105
  init.body = JSON.stringify(args.body ?? {});
95
106
  headers['Content-Type'] = 'application/json';
96
107
  }
97
- const res = await this.#fetch(url, init);
108
+ const res = await __classPrivateFieldGet(this, _ReclaimClient_fetch, "f").call(this, url, init);
98
109
  if (!res.ok) {
99
110
  await throwProblemError(res);
100
111
  }
@@ -105,3 +116,4 @@ export class ReclaimClient {
105
116
  return { data, response: res };
106
117
  }
107
118
  }
119
+ _ReclaimClient_token = new WeakMap(), _ReclaimClient_fetch = new WeakMap(), _ReclaimClient_headers = new WeakMap();
package/lib/result.js CHANGED
@@ -156,12 +156,6 @@ function contentHash(params) {
156
156
  * }
157
157
  */
158
158
  export class ResultVerificationError extends Error {
159
- /** Machine-readable failure reason — `'bad-signature'`, `'expired'`,
160
- * `'reclaimSessionId-mismatch'`, `'aud-mismatch'`, `'invalid-proof'`, … */
161
- reason;
162
- /** The full (invalid) outcome: `payload`, `reclaimSessionId`, and per-proof
163
- * detail (`proofs`) when verification got that far. */
164
- outcome;
165
159
  constructor(outcome) {
166
160
  super(`result verification failed: ${outcome.reason ?? 'invalid'}`);
167
161
  this.name = 'ResultVerificationError';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@reclaimprotocol/client",
3
3
  "title": "Reclaim Client",
4
- "version": "0.1.6",
4
+ "version": "0.1.9",
5
5
  "description": "Typed SDK client for @reclaimprotocol/app. Used by @reclaimprotocol/agent and any other consumer that needs programmatic API access without the full agent.",
6
6
  "type": "module",
7
7
  "sideEffects": false,