@certen.io/sdk 0.4.0 → 0.7.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 (105) hide show
  1. package/CHANGELOG.md +874 -185
  2. package/README.md +133 -119
  3. package/dist/client.d.ts +99 -6
  4. package/dist/client.d.ts.map +1 -1
  5. package/dist/client.js +269 -20
  6. package/dist/client.js.map +1 -1
  7. package/dist/doctor.d.ts +53 -0
  8. package/dist/doctor.d.ts.map +1 -0
  9. package/dist/doctor.js +451 -0
  10. package/dist/doctor.js.map +1 -0
  11. package/dist/error-codes.d.ts +14 -0
  12. package/dist/error-codes.d.ts.map +1 -0
  13. package/dist/error-codes.js +55 -0
  14. package/dist/error-codes.js.map +1 -0
  15. package/dist/errors.d.ts +91 -1
  16. package/dist/errors.d.ts.map +1 -1
  17. package/dist/errors.js +130 -1
  18. package/dist/errors.js.map +1 -1
  19. package/dist/funding.d.ts +43 -0
  20. package/dist/funding.d.ts.map +1 -0
  21. package/dist/funding.js +116 -0
  22. package/dist/funding.js.map +1 -0
  23. package/dist/index.d.ts +10 -1
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +18 -1
  26. package/dist/index.js.map +1 -1
  27. package/dist/oauth.d.ts +56 -0
  28. package/dist/oauth.d.ts.map +1 -0
  29. package/dist/oauth.js +68 -0
  30. package/dist/oauth.js.map +1 -0
  31. package/dist/registration.d.ts +33 -0
  32. package/dist/registration.d.ts.map +1 -0
  33. package/dist/registration.js +49 -0
  34. package/dist/registration.js.map +1 -0
  35. package/dist/resources/admin.d.ts +52 -1
  36. package/dist/resources/admin.d.ts.map +1 -1
  37. package/dist/resources/admin.js +55 -0
  38. package/dist/resources/admin.js.map +1 -1
  39. package/dist/resources/billing.d.ts +242 -0
  40. package/dist/resources/billing.d.ts.map +1 -0
  41. package/dist/resources/billing.js +376 -0
  42. package/dist/resources/billing.js.map +1 -0
  43. package/dist/resources/chains.d.ts +38 -0
  44. package/dist/resources/chains.d.ts.map +1 -0
  45. package/dist/resources/chains.js +46 -0
  46. package/dist/resources/chains.js.map +1 -0
  47. package/dist/resources/device.d.ts +43 -0
  48. package/dist/resources/device.d.ts.map +1 -0
  49. package/dist/resources/device.js +49 -0
  50. package/dist/resources/device.js.map +1 -0
  51. package/dist/resources/execute.d.ts +39 -1
  52. package/dist/resources/execute.d.ts.map +1 -1
  53. package/dist/resources/execute.js +41 -1
  54. package/dist/resources/execute.js.map +1 -1
  55. package/dist/resources/health.d.ts +34 -0
  56. package/dist/resources/health.d.ts.map +1 -0
  57. package/dist/resources/health.js +43 -0
  58. package/dist/resources/health.js.map +1 -0
  59. package/dist/resources/identity.d.ts +83 -2
  60. package/dist/resources/identity.d.ts.map +1 -1
  61. package/dist/resources/identity.js +154 -2
  62. package/dist/resources/identity.js.map +1 -1
  63. package/dist/resources/oauth-clients.d.ts +71 -0
  64. package/dist/resources/oauth-clients.d.ts.map +1 -0
  65. package/dist/resources/oauth-clients.js +75 -0
  66. package/dist/resources/oauth-clients.js.map +1 -0
  67. package/dist/resources/pending.d.ts +13 -1
  68. package/dist/resources/pending.d.ts.map +1 -1
  69. package/dist/resources/pending.js +15 -0
  70. package/dist/resources/pending.js.map +1 -1
  71. package/dist/resources/proof.d.ts +75 -0
  72. package/dist/resources/proof.d.ts.map +1 -0
  73. package/dist/resources/proof.js +103 -0
  74. package/dist/resources/proof.js.map +1 -0
  75. package/dist/resources/registration-tokens.d.ts +51 -0
  76. package/dist/resources/registration-tokens.d.ts.map +1 -0
  77. package/dist/resources/registration-tokens.js +54 -0
  78. package/dist/resources/registration-tokens.js.map +1 -0
  79. package/dist/resources/transaction.d.ts +20 -0
  80. package/dist/resources/transaction.d.ts.map +1 -1
  81. package/dist/resources/transaction.js +28 -0
  82. package/dist/resources/transaction.js.map +1 -1
  83. package/dist/resources/transparency.d.ts +68 -0
  84. package/dist/resources/transparency.d.ts.map +1 -0
  85. package/dist/resources/transparency.js +83 -0
  86. package/dist/resources/transparency.js.map +1 -0
  87. package/dist/resources/webhooks.d.ts +97 -0
  88. package/dist/resources/webhooks.d.ts.map +1 -0
  89. package/dist/resources/webhooks.js +112 -0
  90. package/dist/resources/webhooks.js.map +1 -0
  91. package/dist/self-signup.d.ts +66 -0
  92. package/dist/self-signup.d.ts.map +1 -0
  93. package/dist/self-signup.js +76 -0
  94. package/dist/self-signup.js.map +1 -0
  95. package/dist/shared-proof.d.ts +34 -0
  96. package/dist/shared-proof.d.ts.map +1 -0
  97. package/dist/shared-proof.js +78 -0
  98. package/dist/shared-proof.js.map +1 -0
  99. package/dist/types.d.ts +901 -24
  100. package/dist/types.d.ts.map +1 -1
  101. package/dist/verify-receipt.d.ts +32 -0
  102. package/dist/verify-receipt.d.ts.map +1 -0
  103. package/dist/verify-receipt.js +176 -0
  104. package/dist/verify-receipt.js.map +1 -0
  105. package/package.json +6 -5
@@ -0,0 +1,75 @@
1
+ /**
2
+ * The OAuth2 clients your organization owns.
3
+ *
4
+ * `fetchOAuthToken` and `revokeOAuthToken` let a service obtain and give back tokens — but the
5
+ * client those tokens come from could only be created by a human opening the portal. So an
6
+ * integration could authenticate itself and could not provision itself, and every automated
7
+ * deployment stopped to wait on someone clicking through a browser.
8
+ *
9
+ * These sat at `/v1/admin/oauth-clients` behind `admin:write`, which was the same misfiling
10
+ * webhooks had: the rows are org-scoped and the create route explicitly refuses to cross orgs
11
+ * without admin scope, so this was always a customer capability wearing an operator's path. Moved
12
+ * to `/v1/oauth-clients` with `oauth:read` and `oauth:write`.
13
+ *
14
+ * **A secret appears exactly twice in its life** — once from `create()`, once from
15
+ * `rotateSecret()` — and never again from any read. Store it before doing anything else.
16
+ */
17
+ export class OAuthClientsResource {
18
+ http;
19
+ constructor(http) {
20
+ this.http = http;
21
+ }
22
+ /** Clients this organization owns. Never includes secrets. Requires `oauth:read`. */
23
+ async list() {
24
+ const { data } = await this.http.get('/v1/oauth-clients');
25
+ return data;
26
+ }
27
+ /**
28
+ * Create a client and receive its credentials once.
29
+ *
30
+ * `scopes` is what tokens issued to this client may do — grant it the narrowest set that works,
31
+ * because a token is only as constrained as the client that minted it. Omitting it creates a
32
+ * client whose tokens can do nothing, which is rarely what anyone wants.
33
+ *
34
+ * `orgId` is for operators placing a client in another organization and requires `admin:write`;
35
+ * leave it unset and the client lands in your own org.
36
+ *
37
+ * NOT retry-safe — a repeat creates a second client. Requires `oauth:write`.
38
+ */
39
+ async create(params) {
40
+ const { data } = await this.http.post('/v1/oauth-clients', {
41
+ scopes: params.scopes,
42
+ ...(params.orgId ? { org_id: params.orgId } : {}),
43
+ });
44
+ return data;
45
+ }
46
+ /**
47
+ * Deactivate a client and revoke every token it ever issued.
48
+ *
49
+ * Immediate and cascading: anything currently authenticating as this client stops working on the
50
+ * next request, including tokens that had hours left. That is the correct behaviour for a leaked
51
+ * client secret and a severe one for a live integration — reach for `rotateSecret` with a grace
52
+ * window when the goal is to change the credential rather than to stop the client.
53
+ *
54
+ * Idempotent: deactivation is a state, so a retry is safe. Requires `oauth:write`.
55
+ */
56
+ async remove(id) {
57
+ await this.http.delete(`/v1/oauth-clients/${encodeURIComponent(id)}`);
58
+ }
59
+ /**
60
+ * Issue a new client secret, optionally keeping the old one alive while you deploy.
61
+ *
62
+ * `graceSeconds` is the whole point of this method over delete-and-recreate: the previous secret
63
+ * keeps working for that long, so a fleet can pick up the new one at its own pace instead of
64
+ * failing all at once. Defaults to 300 seconds, and the gateway caps it at seven days. Pass `0`
65
+ * for an immediate cutover — correct when the old secret has leaked, and a small outage otherwise.
66
+ *
67
+ * NOT retry-safe. Each call invalidates the secret the previous one issued, so calling twice
68
+ * strands whatever was mid-deployment with the first new secret. Requires `oauth:write`.
69
+ */
70
+ async rotateSecret(id, params = {}) {
71
+ const { data } = await this.http.post(`/v1/oauth-clients/${encodeURIComponent(id)}/rotate-secret`, params.graceSeconds === undefined ? {} : { grace_seconds: params.graceSeconds });
72
+ return data;
73
+ }
74
+ }
75
+ //# sourceMappingURL=oauth-clients.js.map
@@ -0,0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AE,CAChF,CAAC;QACF,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
@@ -1,8 +1,20 @@
1
1
  import { AxiosInstance } from 'axios';
2
- import type { PendingActionsResponse, ListPendingParams } from '../types.js';
2
+ import type { PendingActionsResponse, ListPendingParams, PendingAction } from '../types.js';
3
3
  export declare class PendingResource {
4
4
  private http;
5
5
  constructor(http: AxiosInstance);
6
6
  list(params?: ListPendingParams): Promise<PendingActionsResponse>;
7
+ /**
8
+ * Every pending action, fetched a page at a time.
9
+ *
10
+ * ```ts
11
+ * for await (const action of certen.pending.listAll({ identity })) { … }
12
+ * ```
13
+ *
14
+ * Filters are passed through, so this narrows the same way `list()` does. `stats` is not carried:
15
+ * it describes a page's context, and an iterator that spans pages has no single one to report —
16
+ * call `list()` when you want the counts.
17
+ */
18
+ listAll(params?: Omit<ListPendingParams, 'limit' | 'offset'>, pageSize?: number): AsyncIterableIterator<PendingAction>;
7
19
  }
8
20
  //# sourceMappingURL=pending.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pending.d.ts","sourceRoot":"","sources":["../../src/resources/pending.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,KAAK,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAE7E,qBAAa,eAAe;IACd,OAAO,CAAC,IAAI;gBAAJ,IAAI,EAAE,aAAa;IAEjC,IAAI,CAAC,MAAM,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,sBAAsB,CAAC;CAYxE"}
1
+ {"version":3,"file":"pending.d.ts","sourceRoot":"","sources":["../../src/resources/pending.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,OAAO,KAAK,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5F,qBAAa,eAAe;IACd,OAAO,CAAC,IAAI;gBAAJ,IAAI,EAAE,aAAa;IAEjC,IAAI,CAAC,MAAM,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAavE;;;;;;;;;;OAUG;IACH,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,iBAAiB,EAAE,OAAO,GAAG,QAAQ,CAAC,EAAE,QAAQ,SAAM,GAAG,qBAAqB,CAAC,aAAa,CAAC;CAMpH"}
@@ -1,3 +1,4 @@
1
+ import { paginate } from '../client.js';
1
2
  export class PendingResource {
2
3
  http;
3
4
  constructor(http) {
@@ -15,5 +16,19 @@ export class PendingResource {
15
16
  });
16
17
  return data;
17
18
  }
19
+ /**
20
+ * Every pending action, fetched a page at a time.
21
+ *
22
+ * ```ts
23
+ * for await (const action of certen.pending.listAll({ identity })) { … }
24
+ * ```
25
+ *
26
+ * Filters are passed through, so this narrows the same way `list()` does. `stats` is not carried:
27
+ * it describes a page's context, and an iterator that spans pages has no single one to report —
28
+ * call `list()` when you want the counts.
29
+ */
30
+ listAll(params, pageSize = 100) {
31
+ return paginate(async (limit, offset) => ({ items: (await this.list({ ...params, limit, offset })).actions ?? [] }), pageSize);
32
+ }
18
33
  }
19
34
  //# sourceMappingURL=pending.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pending.js","sourceRoot":"","sources":["../../src/resources/pending.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,eAAe;IACN;IAApB,YAAoB,IAAmB;QAAnB,SAAI,GAAJ,IAAI,CAAe;IAAG,CAAC;IAE3C,KAAK,CAAC,IAAI,CAAC,MAA0B;QACnC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE;YAClD,MAAM,EAAE;gBACN,QAAQ,EAAE,MAAM,EAAE,QAAQ;gBAC1B,MAAM,EAAE,MAAM,EAAE,MAAM;gBACtB,QAAQ,EAAE,MAAM,EAAE,QAAQ;gBAC1B,KAAK,EAAE,MAAM,EAAE,KAAK;gBACpB,MAAM,EAAE,MAAM,EAAE,MAAM;aACvB;SACF,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
1
+ {"version":3,"file":"pending.js","sourceRoot":"","sources":["../../src/resources/pending.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAGxC,MAAM,OAAO,eAAe;IACN;IAApB,YAAoB,IAAmB;QAAnB,SAAI,GAAJ,IAAI,CAAe;IAAG,CAAC;IAE3C,KAAK,CAAC,IAAI,CAAC,MAA0B;QACnC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE;YAClD,MAAM,EAAE;gBACN,QAAQ,EAAE,MAAM,EAAE,QAAQ;gBAC1B,MAAM,EAAE,MAAM,EAAE,MAAM;gBACtB,QAAQ,EAAE,MAAM,EAAE,QAAQ;gBAC1B,KAAK,EAAE,MAAM,EAAE,KAAK;gBACpB,MAAM,EAAE,MAAM,EAAE,MAAM;aACvB;SACF,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;;;OAUG;IACH,OAAO,CAAC,MAAoD,EAAE,QAAQ,GAAG,GAAG;QAC1E,OAAO,QAAQ,CACb,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,OAAO,IAAI,EAAE,EAAE,CAAC,EACnG,QAAQ,CACT,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,75 @@
1
+ import { AxiosInstance } from 'axios';
2
+ import type { ProofArtifact, ProofCustody, ChainReceipt, ProofShare, ProofSharesResponse, SharedProof } from '../types.js';
3
+ /**
4
+ * Reading and sharing proofs.
5
+ *
6
+ * A transaction hash is a claim; a proof is evidence. These are the reads a counterparty performs
7
+ * instead of trusting you — and the reads you perform to hand them something to check.
8
+ *
9
+ * **Two independent sources sit behind these methods, and they fail independently.**
10
+ *
11
+ * `proof/{id}`, `/bundle` and `/custody` are served by the proof-service. `proof/tx/{hash}/receipt`
12
+ * is read live from Accumulate. When the proof-service is unavailable the first three return 5xx
13
+ * — with a plain-text body, not JSON — while the receipt keeps working, because it never touched
14
+ * the proof-service at all. Code that treats "the proof endpoint failed" as "there is no proof"
15
+ * gets this exactly backwards, and the receipt is usually still there to be had.
16
+ *
17
+ * The receipt is also the only route that works for governance and key-page authorizations, which
18
+ * the proof-service does not index and which therefore carry no `proof_id`.
19
+ */
20
+ export declare class ProofResource {
21
+ private http;
22
+ constructor(http: AxiosInstance);
23
+ /** The proof artifact for a proof id. Shape is defined by the proof-service, not by this SDK. */
24
+ get(proofId: string): Promise<ProofArtifact>;
25
+ /** The proof artifact for a transaction hash, where the proof-service indexed one. */
26
+ byTxHash(txHash: string): Promise<ProofArtifact>;
27
+ /**
28
+ * The Accumulate merkle inclusion receipt for a transaction, read from the network.
29
+ *
30
+ * This is the read that works everywhere: any delivered transaction has one, including the
31
+ * governance and key-page authorizations the proof-service does not index. When a `proof_id`
32
+ * lookup comes back empty for something you know executed, this is what you want.
33
+ */
34
+ receipt(txHash: string): Promise<ChainReceipt>;
35
+ /**
36
+ * The full bundle.
37
+ *
38
+ * Returned as a Buffer because the gateway streams `application/octet-stream` when the
39
+ * downstream produces binary and JSON otherwise. Deciding between them here would mean
40
+ * guessing; the caller writes it to a file, and `contentType` says which it got.
41
+ */
42
+ bundle(proofId: string): Promise<{
43
+ data: Buffer;
44
+ contentType: string;
45
+ }>;
46
+ /** The custody chain for a proof. */
47
+ custody(proofId: string): Promise<ProofCustody>;
48
+ /**
49
+ * Mint a shareable link, so a counterparty can fetch the bundle without an API key of yours.
50
+ *
51
+ * The token is returned once. `expiresIn` is seconds.
52
+ */
53
+ /**
54
+ * Read a proof someone shared with you.
55
+ *
56
+ * Convenience for a caller who already has a client. The endpoint takes NO API key — the person
57
+ * a share link is for has no CERTEN relationship — so a counterparty should import the standalone
58
+ * `fetchSharedProof(url)` instead and construct nothing.
59
+ *
60
+ * Accepts the share URL as handed over, or the bare token.
61
+ */
62
+ shared(tokenOrUrl: string): Promise<SharedProof>;
63
+ share(proofId: string, params?: {
64
+ label?: string;
65
+ expiresIn?: number;
66
+ }): Promise<ProofShare>;
67
+ /** Every share link this organization has created, including revoked and expired ones. */
68
+ shares(): Promise<ProofSharesResponse>;
69
+ /** Revoke a share link. The token stops resolving; the proof itself is untouched. */
70
+ revokeShare(shareId: string): Promise<{
71
+ revoked?: boolean;
72
+ [key: string]: unknown;
73
+ }>;
74
+ }
75
+ //# sourceMappingURL=proof.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proof.d.ts","sourceRoot":"","sources":["../../src/resources/proof.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,OAAO,KAAK,EACV,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,mBAAmB,EAC1E,WAAW,EACZ,MAAM,aAAa,CAAC;AAErB;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,aAAa;IACZ,OAAO,CAAC,IAAI;gBAAJ,IAAI,EAAE,aAAa;IAEvC,iGAAiG;IAC3F,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAKlD,sFAAsF;IAChF,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAKtD;;;;;;OAMG;IACG,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAKpD;;;;;;OAMG;IACG,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC;IAU7E,qCAAqC;IAC/B,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAKrD;;;;OAIG;IACH;;;;;;;;OAQG;IACG,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAMhD,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,GAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,OAAO,CAAC,UAAU,CAAC;IAQtG,0FAA0F;IACpF,MAAM,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAK5C,qFAAqF;IAC/E,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,CAAC,EAAE,OAAO,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;CAI3F"}
@@ -0,0 +1,103 @@
1
+ import { parseShareTarget } from '../shared-proof.js';
2
+ /**
3
+ * Reading and sharing proofs.
4
+ *
5
+ * A transaction hash is a claim; a proof is evidence. These are the reads a counterparty performs
6
+ * instead of trusting you — and the reads you perform to hand them something to check.
7
+ *
8
+ * **Two independent sources sit behind these methods, and they fail independently.**
9
+ *
10
+ * `proof/{id}`, `/bundle` and `/custody` are served by the proof-service. `proof/tx/{hash}/receipt`
11
+ * is read live from Accumulate. When the proof-service is unavailable the first three return 5xx
12
+ * — with a plain-text body, not JSON — while the receipt keeps working, because it never touched
13
+ * the proof-service at all. Code that treats "the proof endpoint failed" as "there is no proof"
14
+ * gets this exactly backwards, and the receipt is usually still there to be had.
15
+ *
16
+ * The receipt is also the only route that works for governance and key-page authorizations, which
17
+ * the proof-service does not index and which therefore carry no `proof_id`.
18
+ */
19
+ export class ProofResource {
20
+ http;
21
+ constructor(http) {
22
+ this.http = http;
23
+ }
24
+ /** The proof artifact for a proof id. Shape is defined by the proof-service, not by this SDK. */
25
+ async get(proofId) {
26
+ const { data } = await this.http.get(`/v1/proof/${proofId}`);
27
+ return data;
28
+ }
29
+ /** The proof artifact for a transaction hash, where the proof-service indexed one. */
30
+ async byTxHash(txHash) {
31
+ const { data } = await this.http.get(`/v1/proof/tx/${txHash}`);
32
+ return data;
33
+ }
34
+ /**
35
+ * The Accumulate merkle inclusion receipt for a transaction, read from the network.
36
+ *
37
+ * This is the read that works everywhere: any delivered transaction has one, including the
38
+ * governance and key-page authorizations the proof-service does not index. When a `proof_id`
39
+ * lookup comes back empty for something you know executed, this is what you want.
40
+ */
41
+ async receipt(txHash) {
42
+ const { data } = await this.http.get(`/v1/proof/tx/${txHash}/receipt`);
43
+ return data;
44
+ }
45
+ /**
46
+ * The full bundle.
47
+ *
48
+ * Returned as a Buffer because the gateway streams `application/octet-stream` when the
49
+ * downstream produces binary and JSON otherwise. Deciding between them here would mean
50
+ * guessing; the caller writes it to a file, and `contentType` says which it got.
51
+ */
52
+ async bundle(proofId) {
53
+ const response = await this.http.get(`/v1/proof/${proofId}/bundle`, {
54
+ responseType: 'arraybuffer',
55
+ });
56
+ return {
57
+ data: Buffer.from(response.data),
58
+ contentType: String(response.headers['content-type'] ?? 'application/octet-stream'),
59
+ };
60
+ }
61
+ /** The custody chain for a proof. */
62
+ async custody(proofId) {
63
+ const { data } = await this.http.get(`/v1/proof/${proofId}/custody`);
64
+ return data;
65
+ }
66
+ /**
67
+ * Mint a shareable link, so a counterparty can fetch the bundle without an API key of yours.
68
+ *
69
+ * The token is returned once. `expiresIn` is seconds.
70
+ */
71
+ /**
72
+ * Read a proof someone shared with you.
73
+ *
74
+ * Convenience for a caller who already has a client. The endpoint takes NO API key — the person
75
+ * a share link is for has no CERTEN relationship — so a counterparty should import the standalone
76
+ * `fetchSharedProof(url)` instead and construct nothing.
77
+ *
78
+ * Accepts the share URL as handed over, or the bare token.
79
+ */
80
+ async shared(tokenOrUrl) {
81
+ const { token } = parseShareTarget(tokenOrUrl, 'http://placeholder');
82
+ const { data } = await this.http.get(`/v1/proof/shared/${encodeURIComponent(token)}`);
83
+ return data;
84
+ }
85
+ async share(proofId, params = {}) {
86
+ const { data } = await this.http.post(`/v1/proof/${proofId}/share`, {
87
+ label: params.label,
88
+ expires_in: params.expiresIn,
89
+ });
90
+ return data;
91
+ }
92
+ /** Every share link this organization has created, including revoked and expired ones. */
93
+ async shares() {
94
+ const { data } = await this.http.get('/v1/proof/shares');
95
+ return data;
96
+ }
97
+ /** Revoke a share link. The token stops resolving; the proof itself is untouched. */
98
+ async revokeShare(shareId) {
99
+ const { data } = await this.http.delete(`/v1/proof/shares/${shareId}`);
100
+ return data;
101
+ }
102
+ }
103
+ //# sourceMappingURL=proof.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proof.js","sourceRoot":"","sources":["../../src/resources/proof.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAMtD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,aAAa;IACJ;IAApB,YAAoB,IAAmB;QAAnB,SAAI,GAAJ,IAAI,CAAe;IAAG,CAAC;IAE3C,iGAAiG;IACjG,KAAK,CAAC,GAAG,CAAC,OAAe;QACvB,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,aAAa,OAAO,EAAE,CAAC,CAAC;QAC7D,OAAO,IAAI,CAAC;IACd,CAAC;IAED,sFAAsF;IACtF,KAAK,CAAC,QAAQ,CAAC,MAAc;QAC3B,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,gBAAgB,MAAM,EAAE,CAAC,CAAC;QAC/D,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,OAAO,CAAC,MAAc;QAC1B,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,gBAAgB,MAAM,UAA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FAA0F;IAC1F,KAAK,CAAC,MAAM;QACV,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;QACzD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,qFAAqF;IACrF,KAAK,CAAC,WAAW,CAAC,OAAe;QAC/B,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,oBAAoB,OAAO,EAAE,CAAC,CAAC;QACvE,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
@@ -0,0 +1,51 @@
1
+ import { AxiosInstance } from 'axios';
2
+ import type { RegistrationToken, MintedRegistrationToken } from '../types.js';
3
+ /**
4
+ * Registration tokens — letting an organization be created without a browser.
5
+ *
6
+ * Minting is the half that needs a credential and the `org:invite` scope. Redeeming is deliberately
7
+ * NOT here: the redeemer holds nothing yet, so it is the standalone `redeemRegistrationToken`.
8
+ *
9
+ * What the new organization will be is fixed at mint time by the minter — its plan, and what its
10
+ * first key may do. A redeemer able to choose those would be choosing what someone else is billed
11
+ * for, and how much reach an unattended credential has.
12
+ */
13
+ export declare class RegistrationTokensResource {
14
+ private http;
15
+ constructor(http: AxiosInstance);
16
+ /**
17
+ * Mint a token. **The token is returned once and never again.**
18
+ *
19
+ * `permissions` are the scopes the redeemed organization's first key receives. Operator and
20
+ * wildcard scopes are refused, as is `org:invite` itself — one human decision must not become an
21
+ * unbounded tree of organizations.
22
+ *
23
+ * NOT retry-safe: each call mints a DIFFERENT token, so a retry leaves a second live token that
24
+ * can create a second organization. Revoke anything you did not mean to issue.
25
+ */
26
+ mint(params?: {
27
+ /** Name for the organization this creates. The redeemer may override it. */
28
+ orgName?: string;
29
+ plan?: 'starter' | 'pro' | 'enterprise';
30
+ /** Scopes for the redeemed org's first key. Defaults to a working read/write set. */
31
+ permissions?: string[];
32
+ /** Seconds until it expires. Default 86400, clamped to the gateway's ceiling. */
33
+ expiresIn?: number;
34
+ /** For your own records — who this was issued to. */
35
+ note?: string;
36
+ }): Promise<MintedRegistrationToken>;
37
+ /** Tokens this organization minted, newest first. Never includes a token. Requires `org:invite`. */
38
+ list(): Promise<{
39
+ tokens: RegistrationToken[];
40
+ }>;
41
+ /**
42
+ * Stop a token being redeemed.
43
+ *
44
+ * Idempotent — revoking twice succeeds, because the intent is already satisfied. A token that has
45
+ * ALREADY been redeemed cannot be revoked: the organization exists and cannot be un-created, so
46
+ * this throws a 409 rather than implying you have contained something you have not. Revoke that
47
+ * organization's API keys instead.
48
+ */
49
+ revoke(id: string): Promise<RegistrationToken>;
50
+ }
51
+ //# sourceMappingURL=registration-tokens.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registration-tokens.d.ts","sourceRoot":"","sources":["../../src/resources/registration-tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,KAAK,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAE9E;;;;;;;;;GASG;AACH,qBAAa,0BAA0B;IACzB,OAAO,CAAC,IAAI;gBAAJ,IAAI,EAAE,aAAa;IAEvC;;;;;;;;;OASG;IACG,IAAI,CAAC,MAAM,GAAE;QACjB,4EAA4E;QAC5E,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,IAAI,CAAC,EAAE,SAAS,GAAG,KAAK,GAAG,YAAY,CAAC;QACxC,qFAAqF;QACrF,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;QACvB,iFAAiF;QACjF,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,qDAAqD;QACrD,IAAI,CAAC,EAAE,MAAM,CAAC;KACV,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAWzC,oGAAoG;IAC9F,IAAI,IAAI,OAAO,CAAC;QAAE,MAAM,EAAE,iBAAiB,EAAE,CAAA;KAAE,CAAC;IAKtD;;;;;;;OAOG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAIrD"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Registration tokens — letting an organization be created without a browser.
3
+ *
4
+ * Minting is the half that needs a credential and the `org:invite` scope. Redeeming is deliberately
5
+ * NOT here: the redeemer holds nothing yet, so it is the standalone `redeemRegistrationToken`.
6
+ *
7
+ * What the new organization will be is fixed at mint time by the minter — its plan, and what its
8
+ * first key may do. A redeemer able to choose those would be choosing what someone else is billed
9
+ * for, and how much reach an unattended credential has.
10
+ */
11
+ export class RegistrationTokensResource {
12
+ http;
13
+ constructor(http) {
14
+ this.http = http;
15
+ }
16
+ /**
17
+ * Mint a token. **The token is returned once and never again.**
18
+ *
19
+ * `permissions` are the scopes the redeemed organization's first key receives. Operator and
20
+ * wildcard scopes are refused, as is `org:invite` itself — one human decision must not become an
21
+ * unbounded tree of organizations.
22
+ *
23
+ * NOT retry-safe: each call mints a DIFFERENT token, so a retry leaves a second live token that
24
+ * can create a second organization. Revoke anything you did not mean to issue.
25
+ */
26
+ async mint(params = {}) {
27
+ const { data } = await this.http.post('/v1/registration-tokens', {
28
+ ...(params.orgName ? { org_name: params.orgName } : {}),
29
+ ...(params.plan ? { plan: params.plan } : {}),
30
+ ...(params.permissions ? { permissions: params.permissions } : {}),
31
+ ...(params.expiresIn !== undefined ? { expires_in: params.expiresIn } : {}),
32
+ ...(params.note ? { note: params.note } : {}),
33
+ });
34
+ return data;
35
+ }
36
+ /** Tokens this organization minted, newest first. Never includes a token. Requires `org:invite`. */
37
+ async list() {
38
+ const { data } = await this.http.get('/v1/registration-tokens');
39
+ return data;
40
+ }
41
+ /**
42
+ * Stop a token being redeemed.
43
+ *
44
+ * Idempotent — revoking twice succeeds, because the intent is already satisfied. A token that has
45
+ * ALREADY been redeemed cannot be revoked: the organization exists and cannot be un-created, so
46
+ * this throws a 409 rather than implying you have contained something you have not. Revoke that
47
+ * organization's API keys instead.
48
+ */
49
+ async revoke(id) {
50
+ const { data } = await this.http.delete(`/v1/registration-tokens/${encodeURIComponent(id)}`);
51
+ return data;
52
+ }
53
+ }
54
+ //# sourceMappingURL=registration-tokens.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registration-tokens.js","sourceRoot":"","sources":["../../src/resources/registration-tokens.ts"],"names":[],"mappings":"AAGA;;;;;;;;;GASG;AACH,MAAM,OAAO,0BAA0B;IACjB;IAApB,YAAoB,IAAmB;QAAnB,SAAI,GAAJ,IAAI,CAAe;IAAG,CAAC;IAE3C;;;;;;;;;OASG;IACH,KAAK,CAAC,IAAI,CAAC,SAUP,EAAE;QACJ,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,yBAAyB,EAAE;YAC/D,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACvD,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC7C,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAClE,GAAG,CAAC,MAAM,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC3E,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC9C,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;IAED,oGAAoG;IACpG,KAAK,CAAC,IAAI;QACR,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;QAChE,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,MAAM,CAAC,EAAU;QACrB,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,2BAA2B,kBAAkB,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QAC7F,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
@@ -15,5 +15,25 @@ export declare class TransactionResource {
15
15
  submitSignature(id: string, params: SubmitSignatureParams): Promise<SubmitSignatureResponse>;
16
16
  get(id: string): Promise<TransactionResponse>;
17
17
  list(params?: ListTransactionsParams): Promise<ListTransactionsResponse>;
18
+ /**
19
+ * Every transaction, fetched a page at a time.
20
+ *
21
+ * ```ts
22
+ * for await (const tx of certen.transaction.listAll()) { … }
23
+ * ```
24
+ *
25
+ * The `paginate` helper has been exported since 0.2.0, but it takes a callback returning
26
+ * `{ items }` and NO method on this SDK returns that shape — `list()` returns `{ transactions }`.
27
+ * So the helper could not be used without first hand-writing the adapter it should have contained:
28
+ *
29
+ * ```ts
30
+ * paginate((limit, offset) =>
31
+ * certen.transaction.list({ limit, offset }).then((r) => ({ items: r.transactions })))
32
+ * ```
33
+ *
34
+ * Exporting a helper that composes with nothing it ships beside is worse than not exporting one:
35
+ * it reads as a solved problem. The adapter lives here now, once, instead of in every caller.
36
+ */
37
+ listAll(pageSize?: number): AsyncIterableIterator<TransactionResponse>;
18
38
  }
19
39
  //# sourceMappingURL=transaction.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../src/resources/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,OAAO,KAAK,EACV,uBAAuB,EACvB,yBAAyB,EACzB,mBAAmB,EACnB,wBAAwB,EACxB,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B,CAAC,mBAAmB,CAAC;CAWpE"}
@@ -1,4 +1,5 @@
1
1
  import { omitUndefined } from '../internal.js';
2
+ import { paginate } from '../client.js';
2
3
  export class TransactionResource {
3
4
  http;
4
5
  constructor(http) {
@@ -49,5 +50,32 @@ export class TransactionResource {
49
50
  });
50
51
  return data;
51
52
  }
53
+ /**
54
+ * Every transaction, fetched a page at a time.
55
+ *
56
+ * ```ts
57
+ * for await (const tx of certen.transaction.listAll()) { … }
58
+ * ```
59
+ *
60
+ * The `paginate` helper has been exported since 0.2.0, but it takes a callback returning
61
+ * `{ items }` and NO method on this SDK returns that shape — `list()` returns `{ transactions }`.
62
+ * So the helper could not be used without first hand-writing the adapter it should have contained:
63
+ *
64
+ * ```ts
65
+ * paginate((limit, offset) =>
66
+ * certen.transaction.list({ limit, offset }).then((r) => ({ items: r.transactions })))
67
+ * ```
68
+ *
69
+ * Exporting a helper that composes with nothing it ships beside is worse than not exporting one:
70
+ * it reads as a solved problem. The adapter lives here now, once, instead of in every caller.
71
+ */
72
+ listAll(pageSize = 100) {
73
+ return paginate(async (limit, offset) => {
74
+ const page = await this.list({ limit, offset });
75
+ // `has_more` when the gateway sends it. Short-page inference otherwise, which ends a walk
76
+ // early whenever the last page happens to be exactly full.
77
+ return { items: page.transactions ?? [], hasMore: page.pagination?.has_more };
78
+ }, pageSize);
79
+ }
52
80
  }
53
81
  //# sourceMappingURL=transaction.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../src/resources/transaction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAW/C,MAAM,OAAO,mBAAmB;IACV;IAApB,YAAoB,IAAmB;QAAnB,SAAI,GAAJ,IAAI,CAAe;IAAG,CAAC;IAE3C;;;;;;;OAOG;IACH,KAAK,CAAC,MAAM,CAAC,MAA+B;QAC1C,MAAM,OAAO,GAA2B,EAAE,CAAC;QAC3C,IAAI,MAAM,CAAC,cAAc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AAC,GAAG,CAAC,EAAU;QAClB,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAAC;QAC9D,OAAO,IAAI,CAAC;IACd,CAAC;IAED,kGAAkG;IAClG,oCAAoC;IACpC,KAAK,CAAC,IAAI,CAAC,MAA+B;QACxC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,kBAAkB,EAAE;YACvD,MAAM,EAAE;gBACN,KAAK,EAAE,MAAM,EAAE,KAAK;gBACpB,MAAM,EAAE,MAAM,EAAE,MAAM;aACvB;SACF,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,OAAO,CAAC,QAAQ,GAAG,GAAG;QACpB,OAAO,QAAQ,CACb,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;YACtB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;YAChD,0FAA0F;YAC1F,2DAA2D;YAC3D,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,YAAY,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE,QAAQ,EAAE,CAAC;QAChF,CAAC,EACD,QAAQ,CACT,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,68 @@
1
+ import { AxiosInstance } from 'axios';
2
+ import type { TransparencyLogInfo, TransparencyHead, ConsistencyProof, PublishedPriceBook, FxObservation } from '../types.js';
3
+ /**
4
+ * The public transparency log.
5
+ *
6
+ * This is what turns a receipt from an assertion into evidence. A receipt's signature says CERTEN
7
+ * issued it; the log says CERTEN did not later hide or edit it, because every receipt is a leaf of
8
+ * an append-only Merkle tree whose roots are signed and written to Accumulate.
9
+ *
10
+ * The receipt's own verification instructions name these endpoints — "check root_hash against the
11
+ * signed head at this tree size" — and none of them had a client surface, so the instruction could
12
+ * not be followed without hand-rolling HTTP. A verification procedure nobody can run is not a
13
+ * verification procedure.
14
+ *
15
+ * **These reads need no API key.** That is deliberate on the gateway's side and worth preserving in
16
+ * your integration: evidence obtainable only by asking CERTEN nicely could not settle a dispute
17
+ * with CERTEN. The client sends its key anyway because it sends one to everything; the endpoints do
18
+ * not require it.
19
+ */
20
+ export declare class TransparencyResource {
21
+ private http;
22
+ constructor(http: AxiosInstance);
23
+ /** What the log is, how big it is, and where its roots are anchored. */
24
+ log(): Promise<TransparencyLogInfo>;
25
+ /** Signed tree heads, newest first. */
26
+ heads(params?: {
27
+ limit?: number;
28
+ offset?: number;
29
+ }): Promise<{
30
+ heads: TransparencyHead[];
31
+ }>;
32
+ /**
33
+ * The signed head at one tree size.
34
+ *
35
+ * Step three of verifying a receipt: fold its audit path to a root, then check that root against
36
+ * the head fetched HERE rather than against the `root_hash` the proof itself carried. Comparing a
37
+ * proof to a root supplied in the same response proves nothing — it is the independent fetch, and
38
+ * the signature on it, that makes the check mean something.
39
+ */
40
+ head(treeSize: number): Promise<TransparencyHead>;
41
+ /**
42
+ * Proof that the log at `second` extends the log at `first` without rewriting it.
43
+ *
44
+ * Needed whenever a receipt's own head is not the one that got anchored. The anchored head is
45
+ * later and larger, and this is what shows the anchored root still commits to everything the
46
+ * earlier root did — that the log was appended to, not rebuilt.
47
+ */
48
+ consistency(first: number, second: number): Promise<ConsistencyProof>;
49
+ /**
50
+ * Every published price book, with its hash and the window it was in force.
51
+ *
52
+ * A receipt carries `price_book_hash`. This is where that hash resolves to actual prices — which
53
+ * is what lets someone check that a charge matched the prices published at the time, rather than
54
+ * prices chosen afterwards.
55
+ */
56
+ priceBooks(): Promise<{
57
+ price_books: PublishedPriceBook[];
58
+ }>;
59
+ /**
60
+ * A signed FX observation.
61
+ *
62
+ * A gas-priced charge converts native currency to USD at a rate observed at a moment. The receipt
63
+ * names the observation; this returns it, signed, so the conversion can be rechecked rather than
64
+ * taken on trust.
65
+ */
66
+ fx(id: string): Promise<FxObservation>;
67
+ }
68
+ //# sourceMappingURL=transparency.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transparency.d.ts","sourceRoot":"","sources":["../../src/resources/transparency.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,KAAK,EACV,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACd,MAAM,aAAa,CAAC;AAErB;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,oBAAoB;IACnB,OAAO,CAAC,IAAI;gBAAJ,IAAI,EAAE,aAAa;IAEvC,wEAAwE;IAClE,GAAG,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAKzC,uCAAuC;IACjC,KAAK,CAAC,MAAM,GAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,gBAAgB,EAAE,CAAA;KAAE,CAAC;IAOrG;;;;;;;OAOG;IACG,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAKvD;;;;;;OAMG;IACG,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAO3E;;;;;;OAMG;IACG,UAAU,IAAI,OAAO,CAAC;QAAE,WAAW,EAAE,kBAAkB,EAAE,CAAA;KAAE,CAAC;IAKlE;;;;;;OAMG;IACG,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;CAI7C"}