@certen.io/sdk 0.5.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.
- package/CHANGELOG.md +576 -0
- package/README.md +133 -119
- package/dist/client.d.ts +96 -6
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +258 -20
- package/dist/client.js.map +1 -1
- package/dist/doctor.d.ts +53 -0
- package/dist/doctor.d.ts.map +1 -0
- package/dist/doctor.js +451 -0
- package/dist/doctor.js.map +1 -0
- package/dist/error-codes.d.ts +14 -0
- package/dist/error-codes.d.ts.map +1 -0
- package/dist/error-codes.js +55 -0
- package/dist/error-codes.js.map +1 -0
- package/dist/errors.d.ts +13 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +18 -1
- package/dist/errors.js.map +1 -1
- package/dist/funding.d.ts +43 -0
- package/dist/funding.d.ts.map +1 -0
- package/dist/funding.js +116 -0
- package/dist/funding.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -1
- package/dist/oauth.d.ts +56 -0
- package/dist/oauth.d.ts.map +1 -0
- package/dist/oauth.js +68 -0
- package/dist/oauth.js.map +1 -0
- package/dist/registration.d.ts +33 -0
- package/dist/registration.d.ts.map +1 -0
- package/dist/registration.js +49 -0
- package/dist/registration.js.map +1 -0
- package/dist/resources/admin.d.ts +52 -1
- package/dist/resources/admin.d.ts.map +1 -1
- package/dist/resources/admin.js +55 -0
- package/dist/resources/admin.js.map +1 -1
- package/dist/resources/billing.d.ts +198 -19
- package/dist/resources/billing.d.ts.map +1 -1
- package/dist/resources/billing.js +297 -7
- package/dist/resources/billing.js.map +1 -1
- package/dist/resources/chains.d.ts +38 -0
- package/dist/resources/chains.d.ts.map +1 -0
- package/dist/resources/chains.js +46 -0
- package/dist/resources/chains.js.map +1 -0
- package/dist/resources/device.d.ts +43 -0
- package/dist/resources/device.d.ts.map +1 -0
- package/dist/resources/device.js +49 -0
- package/dist/resources/device.js.map +1 -0
- package/dist/resources/execute.d.ts +10 -0
- package/dist/resources/execute.d.ts.map +1 -1
- package/dist/resources/execute.js +18 -0
- package/dist/resources/execute.js.map +1 -1
- package/dist/resources/health.d.ts +34 -0
- package/dist/resources/health.d.ts.map +1 -0
- package/dist/resources/health.js +43 -0
- package/dist/resources/health.js.map +1 -0
- package/dist/resources/identity.d.ts +83 -2
- package/dist/resources/identity.d.ts.map +1 -1
- package/dist/resources/identity.js +154 -2
- package/dist/resources/identity.js.map +1 -1
- package/dist/resources/oauth-clients.d.ts +71 -0
- package/dist/resources/oauth-clients.d.ts.map +1 -0
- package/dist/resources/oauth-clients.js +75 -0
- package/dist/resources/oauth-clients.js.map +1 -0
- package/dist/resources/pending.d.ts +13 -1
- package/dist/resources/pending.d.ts.map +1 -1
- package/dist/resources/pending.js +15 -0
- package/dist/resources/pending.js.map +1 -1
- package/dist/resources/proof.d.ts +75 -0
- package/dist/resources/proof.d.ts.map +1 -0
- package/dist/resources/proof.js +103 -0
- package/dist/resources/proof.js.map +1 -0
- package/dist/resources/registration-tokens.d.ts +51 -0
- package/dist/resources/registration-tokens.d.ts.map +1 -0
- package/dist/resources/registration-tokens.js +54 -0
- package/dist/resources/registration-tokens.js.map +1 -0
- package/dist/resources/transaction.d.ts +20 -0
- package/dist/resources/transaction.d.ts.map +1 -1
- package/dist/resources/transaction.js +28 -0
- package/dist/resources/transaction.js.map +1 -1
- package/dist/resources/transparency.d.ts +68 -0
- package/dist/resources/transparency.d.ts.map +1 -0
- package/dist/resources/transparency.js +83 -0
- package/dist/resources/transparency.js.map +1 -0
- package/dist/resources/webhooks.d.ts +97 -0
- package/dist/resources/webhooks.d.ts.map +1 -0
- package/dist/resources/webhooks.js +112 -0
- package/dist/resources/webhooks.js.map +1 -0
- package/dist/self-signup.d.ts +66 -0
- package/dist/self-signup.d.ts.map +1 -0
- package/dist/self-signup.js +76 -0
- package/dist/self-signup.js.map +1 -0
- package/dist/shared-proof.d.ts +34 -0
- package/dist/shared-proof.d.ts.map +1 -0
- package/dist/shared-proof.js +78 -0
- package/dist/shared-proof.js.map +1 -0
- package/dist/types.d.ts +790 -19
- package/dist/types.d.ts.map +1 -1
- package/dist/verify-receipt.d.ts +32 -0
- package/dist/verify-receipt.d.ts.map +1 -0
- package/dist/verify-receipt.js +176 -0
- package/dist/verify-receipt.js.map +1 -0
- package/package.json +6 -5
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../src/resources/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAGtC,OAAO,KAAK,EACV,uBAAuB,EACvB,yBAAyB,EACzB,mBAAmB,EACnB,wBAAwB,EACxB,qBAAqB,EACrB,uBAAuB,EACvB,sBAAsB,EACvB,MAAM,aAAa,CAAC;AAErB,qBAAa,mBAAmB;IAClB,OAAO,CAAC,IAAI;gBAAJ,IAAI,EAAE,aAAa;IAEvC;;;;;;;OAOG;IACG,MAAM,CAAC,MAAM,EAAE,uBAAuB,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAoB3E,eAAe,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAQ5F,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAO7C,IAAI,CAAC,MAAM,CAAC,EAAE,sBAAsB,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAU9E;;;;;;;;;;;;;;;;;;OAkBG;IACH,OAAO,CAAC,QAAQ,SAAM,GAAG,qBAAqB,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;
|
|
1
|
+
{"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../src/resources/transaction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAWxC,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,EAAE,CAAC;YAC1B,OAAO,CAAC,iBAAiB,CAAC,GAAG,MAAM,CAAC,cAAc,CAAC;QACrD,CAAC;QACD,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CACnC,iBAAiB,EACjB,aAAa,CAAC;YACZ,WAAW,EAAE,MAAM,CAAC,UAAU;YAC9B,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,kBAAkB,EAAE,MAAM,CAAC,iBAAiB;YAC5C,WAAW,EAAE,MAAM,CAAC,UAAU;YAC9B,eAAe,EAAE,MAAM,CAAC,aAAa;YACrC,iBAAiB,EAAE,MAAM,CAAC,e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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"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The public transparency log.
|
|
3
|
+
*
|
|
4
|
+
* This is what turns a receipt from an assertion into evidence. A receipt's signature says CERTEN
|
|
5
|
+
* issued it; the log says CERTEN did not later hide or edit it, because every receipt is a leaf of
|
|
6
|
+
* an append-only Merkle tree whose roots are signed and written to Accumulate.
|
|
7
|
+
*
|
|
8
|
+
* The receipt's own verification instructions name these endpoints — "check root_hash against the
|
|
9
|
+
* signed head at this tree size" — and none of them had a client surface, so the instruction could
|
|
10
|
+
* not be followed without hand-rolling HTTP. A verification procedure nobody can run is not a
|
|
11
|
+
* verification procedure.
|
|
12
|
+
*
|
|
13
|
+
* **These reads need no API key.** That is deliberate on the gateway's side and worth preserving in
|
|
14
|
+
* your integration: evidence obtainable only by asking CERTEN nicely could not settle a dispute
|
|
15
|
+
* with CERTEN. The client sends its key anyway because it sends one to everything; the endpoints do
|
|
16
|
+
* not require it.
|
|
17
|
+
*/
|
|
18
|
+
export class TransparencyResource {
|
|
19
|
+
http;
|
|
20
|
+
constructor(http) {
|
|
21
|
+
this.http = http;
|
|
22
|
+
}
|
|
23
|
+
/** What the log is, how big it is, and where its roots are anchored. */
|
|
24
|
+
async log() {
|
|
25
|
+
const { data } = await this.http.get('/v1/transparency');
|
|
26
|
+
return data;
|
|
27
|
+
}
|
|
28
|
+
/** Signed tree heads, newest first. */
|
|
29
|
+
async heads(params = {}) {
|
|
30
|
+
const { data } = await this.http.get('/v1/transparency/heads', {
|
|
31
|
+
params: { limit: params.limit ?? 50, offset: params.offset ?? 0 },
|
|
32
|
+
});
|
|
33
|
+
return data;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The signed head at one tree size.
|
|
37
|
+
*
|
|
38
|
+
* Step three of verifying a receipt: fold its audit path to a root, then check that root against
|
|
39
|
+
* the head fetched HERE rather than against the `root_hash` the proof itself carried. Comparing a
|
|
40
|
+
* proof to a root supplied in the same response proves nothing — it is the independent fetch, and
|
|
41
|
+
* the signature on it, that makes the check mean something.
|
|
42
|
+
*/
|
|
43
|
+
async head(treeSize) {
|
|
44
|
+
const { data } = await this.http.get(`/v1/transparency/heads/${treeSize}`);
|
|
45
|
+
return data;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Proof that the log at `second` extends the log at `first` without rewriting it.
|
|
49
|
+
*
|
|
50
|
+
* Needed whenever a receipt's own head is not the one that got anchored. The anchored head is
|
|
51
|
+
* later and larger, and this is what shows the anchored root still commits to everything the
|
|
52
|
+
* earlier root did — that the log was appended to, not rebuilt.
|
|
53
|
+
*/
|
|
54
|
+
async consistency(first, second) {
|
|
55
|
+
const { data } = await this.http.get('/v1/transparency/consistency', {
|
|
56
|
+
params: { first, second },
|
|
57
|
+
});
|
|
58
|
+
return data;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Every published price book, with its hash and the window it was in force.
|
|
62
|
+
*
|
|
63
|
+
* A receipt carries `price_book_hash`. This is where that hash resolves to actual prices — which
|
|
64
|
+
* is what lets someone check that a charge matched the prices published at the time, rather than
|
|
65
|
+
* prices chosen afterwards.
|
|
66
|
+
*/
|
|
67
|
+
async priceBooks() {
|
|
68
|
+
const { data } = await this.http.get('/v1/transparency/price-books');
|
|
69
|
+
return data;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* A signed FX observation.
|
|
73
|
+
*
|
|
74
|
+
* A gas-priced charge converts native currency to USD at a rate observed at a moment. The receipt
|
|
75
|
+
* names the observation; this returns it, signed, so the conversion can be rechecked rather than
|
|
76
|
+
* taken on trust.
|
|
77
|
+
*/
|
|
78
|
+
async fx(id) {
|
|
79
|
+
const { data } = await this.http.get(`/v1/transparency/fx/${encodeURIComponent(id)}`);
|
|
80
|
+
return data;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=transparency.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transparency.js","sourceRoot":"","sources":["../../src/resources/transparency.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,oBAAoB;IACX;IAApB,YAAoB,IAAmB;QAAnB,SAAI,GAAJ,IAAI,CAAe;IAAG,CAAC;IAE3C,wEAAwE;IACxE,KAAK,CAAC,GAAG;QACP,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;QACzD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,uCAAuC;IACvC,KAAK,CAAC,KAAK,CAAC,SAA8C,EAAE;QAC1D,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,wBAAwB,EAAE;YAC7D,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,CAAC,EAAE;SAClE,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,IAAI,CAAC,QAAgB;QACzB,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,0BAA0B,QAAQ,EAAE,CAAC,CAAC;QAC3E,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,WAAW,CAAC,KAAa,EAAE,MAAc;QAC7C,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,8BAA8B,EAAE;YACnE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE;SAC1B,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,UAAU;QACd,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC;QACrE,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,CAAC,EAAU;QACjB,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,uBAAuB,kBAAkB,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QACtF,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import type { WebhookEndpoint, WebhookDelivery, Pagination } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Webhook endpoints, and what happened to each delivery.
|
|
5
|
+
*
|
|
6
|
+
* The gateway has had a delivery queue, a retry policy, an event registry and a customer-facing
|
|
7
|
+
* signature-verification guide since early on. None of it had a client surface — so the only push
|
|
8
|
+
* mechanism CERTEN offers could be configured nowhere, and a failed delivery could be neither seen
|
|
9
|
+
* nor retried. A webhook a customer cannot inspect is worse than no webhook: it fails silently and
|
|
10
|
+
* looks like the event never happened.
|
|
11
|
+
*
|
|
12
|
+
* These lived under `/v1/admin/webhooks/*` and required `admin:write` — a scope that also grants
|
|
13
|
+
* revoking every API key in the organization, attributing payments and publishing price books.
|
|
14
|
+
* The data was always org-scoped, so the path and the scope both overstated what this is. Moved to
|
|
15
|
+
* `/v1/webhooks/*` with `webhook:read` and `webhook:write`, which cover exactly this and nothing
|
|
16
|
+
* else.
|
|
17
|
+
*/
|
|
18
|
+
export declare class WebhooksResource {
|
|
19
|
+
private http;
|
|
20
|
+
constructor(http: AxiosInstance);
|
|
21
|
+
/** Endpoints registered for this organization. Requires `webhook:read`. */
|
|
22
|
+
list(): Promise<{
|
|
23
|
+
endpoints: WebhookEndpoint[];
|
|
24
|
+
}>;
|
|
25
|
+
/**
|
|
26
|
+
* Register an endpoint.
|
|
27
|
+
*
|
|
28
|
+
* **The signing secret is returned once and never again.** Store it before doing anything else —
|
|
29
|
+
* without it you cannot verify that a delivery came from CERTEN, and the only recovery is
|
|
30
|
+
* `rotateSecret`, which invalidates whatever the previous secret was signing.
|
|
31
|
+
*
|
|
32
|
+
* Supply your own `secret` to keep the value out of a response body entirely. Omit `eventTypes`
|
|
33
|
+
* to receive everything.
|
|
34
|
+
*/
|
|
35
|
+
register(params: {
|
|
36
|
+
url: string;
|
|
37
|
+
secret?: string;
|
|
38
|
+
eventTypes?: string[];
|
|
39
|
+
description?: string;
|
|
40
|
+
/** Skip the verification ping. The endpoint is registered unverified. */
|
|
41
|
+
skipVerification?: boolean;
|
|
42
|
+
}): Promise<WebhookEndpoint & {
|
|
43
|
+
secret?: string;
|
|
44
|
+
warning?: string;
|
|
45
|
+
}>;
|
|
46
|
+
/** Change an endpoint's URL, events, description, or active state. Requires `webhook:write`. */
|
|
47
|
+
update(id: string, params: {
|
|
48
|
+
url?: string;
|
|
49
|
+
eventTypes?: string[];
|
|
50
|
+
description?: string;
|
|
51
|
+
isActive?: boolean;
|
|
52
|
+
}): Promise<WebhookEndpoint>;
|
|
53
|
+
/** Stop delivering to an endpoint. Requires `webhook:write`. */
|
|
54
|
+
remove(id: string): Promise<{
|
|
55
|
+
deleted?: boolean;
|
|
56
|
+
[k: string]: unknown;
|
|
57
|
+
}>;
|
|
58
|
+
/**
|
|
59
|
+
* Issue a new signing secret.
|
|
60
|
+
*
|
|
61
|
+
* NOT retry-safe: each call invalidates the secret the previous one issued, so a retry can strand
|
|
62
|
+
* a receiver that was verifying correctly seconds earlier. Returns the new secret once.
|
|
63
|
+
*/
|
|
64
|
+
rotateSecret(id: string): Promise<{
|
|
65
|
+
secret: string;
|
|
66
|
+
[k: string]: unknown;
|
|
67
|
+
}>;
|
|
68
|
+
/** Re-run the verification ping against an endpoint. Requires `webhook:write`. */
|
|
69
|
+
verify(id: string): Promise<WebhookEndpoint>;
|
|
70
|
+
/**
|
|
71
|
+
* Delivery attempts, newest first. Requires `webhook:read`.
|
|
72
|
+
*
|
|
73
|
+
* This is the half that makes webhooks debuggable: a delivery that failed is otherwise invisible
|
|
74
|
+
* to the person waiting for the event.
|
|
75
|
+
*/
|
|
76
|
+
deliveries(params?: {
|
|
77
|
+
limit?: number;
|
|
78
|
+
offset?: number;
|
|
79
|
+
}): Promise<{
|
|
80
|
+
deliveries: WebhookDelivery[];
|
|
81
|
+
pagination?: Pagination;
|
|
82
|
+
}>;
|
|
83
|
+
/** Every delivery, paging automatically on `has_more`. */
|
|
84
|
+
deliveriesAll(pageSize?: number): AsyncIterableIterator<WebhookDelivery>;
|
|
85
|
+
/** One delivery, including the response body the endpoint returned. Requires `webhook:read`. */
|
|
86
|
+
delivery(id: string): Promise<WebhookDelivery>;
|
|
87
|
+
/**
|
|
88
|
+
* Send a delivery again.
|
|
89
|
+
*
|
|
90
|
+
* Deliberately NOT retry-safe: delivering again is the entire point, so calling this twice
|
|
91
|
+
* delivers twice. Make sure the receiver is idempotent before leaning on it.
|
|
92
|
+
*/
|
|
93
|
+
redeliver(id: string): Promise<{
|
|
94
|
+
[k: string]: unknown;
|
|
95
|
+
}>;
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=webhooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhooks.d.ts","sourceRoot":"","sources":["../../src/resources/webhooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEhF;;;;;;;;;;;;;;GAcG;AACH,qBAAa,gBAAgB;IACf,OAAO,CAAC,IAAI;gBAAJ,IAAI,EAAE,aAAa;IAEvC,2EAA2E;IACrE,IAAI,IAAI,OAAO,CAAC;QAAE,SAAS,EAAE,eAAe,EAAE,CAAA;KAAE,CAAC;IAKvD;;;;;;;;;OASG;IACG,QAAQ,CAAC,MAAM,EAAE;QACrB,GAAG,EAAE,MAAM,CAAC;QACZ,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;QACtB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,yEAAyE;QACzE,gBAAgB,CAAC,EAAE,OAAO,CAAC;KAC5B,GAAG,OAAO,CAAC,eAAe,GAAG;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAWpE,gGAAgG;IAC1F,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE;QAC/B,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;QACtB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;KACpB,GAAG,OAAO,CAAC,eAAe,CAAC;IAU5B,gEAAgE;IAC1D,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,CAAC,EAAE,OAAO,CAAC;QAAC,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;IAK9E;;;;;OAKG;IACG,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;IAOjF,kFAAkF;IAC5E,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAOlD;;;;;OAKG;IACG,UAAU,CACd,MAAM,GAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAO,GAC/C,OAAO,CAAC;QAAE,UAAU,EAAE,eAAe,EAAE,CAAC;QAAC,UAAU,CAAC,EAAE,UAAU,CAAA;KAAE,CAAC;IAOtE,0DAA0D;IAC1D,aAAa,CAAC,QAAQ,SAAM,GAAG,qBAAqB,CAAC,eAAe,CAAC;IAUrE,gGAAgG;IAC1F,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAKpD;;;;;OAKG;IACG,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;CAM/D"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { paginate } from '../client.js';
|
|
2
|
+
/**
|
|
3
|
+
* Webhook endpoints, and what happened to each delivery.
|
|
4
|
+
*
|
|
5
|
+
* The gateway has had a delivery queue, a retry policy, an event registry and a customer-facing
|
|
6
|
+
* signature-verification guide since early on. None of it had a client surface — so the only push
|
|
7
|
+
* mechanism CERTEN offers could be configured nowhere, and a failed delivery could be neither seen
|
|
8
|
+
* nor retried. A webhook a customer cannot inspect is worse than no webhook: it fails silently and
|
|
9
|
+
* looks like the event never happened.
|
|
10
|
+
*
|
|
11
|
+
* These lived under `/v1/admin/webhooks/*` and required `admin:write` — a scope that also grants
|
|
12
|
+
* revoking every API key in the organization, attributing payments and publishing price books.
|
|
13
|
+
* The data was always org-scoped, so the path and the scope both overstated what this is. Moved to
|
|
14
|
+
* `/v1/webhooks/*` with `webhook:read` and `webhook:write`, which cover exactly this and nothing
|
|
15
|
+
* else.
|
|
16
|
+
*/
|
|
17
|
+
export class WebhooksResource {
|
|
18
|
+
http;
|
|
19
|
+
constructor(http) {
|
|
20
|
+
this.http = http;
|
|
21
|
+
}
|
|
22
|
+
/** Endpoints registered for this organization. Requires `webhook:read`. */
|
|
23
|
+
async list() {
|
|
24
|
+
const { data } = await this.http.get('/v1/webhooks/endpoints');
|
|
25
|
+
return data;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Register an endpoint.
|
|
29
|
+
*
|
|
30
|
+
* **The signing secret is returned once and never again.** Store it before doing anything else —
|
|
31
|
+
* without it you cannot verify that a delivery came from CERTEN, and the only recovery is
|
|
32
|
+
* `rotateSecret`, which invalidates whatever the previous secret was signing.
|
|
33
|
+
*
|
|
34
|
+
* Supply your own `secret` to keep the value out of a response body entirely. Omit `eventTypes`
|
|
35
|
+
* to receive everything.
|
|
36
|
+
*/
|
|
37
|
+
async register(params) {
|
|
38
|
+
const { data } = await this.http.post('/v1/webhooks/endpoints', {
|
|
39
|
+
url: params.url,
|
|
40
|
+
...(params.secret ? { secret: params.secret } : {}),
|
|
41
|
+
...(params.eventTypes ? { event_types: params.eventTypes } : {}),
|
|
42
|
+
...(params.description ? { description: params.description } : {}),
|
|
43
|
+
...(params.skipVerification ? { skip_verification: true } : {}),
|
|
44
|
+
});
|
|
45
|
+
return data;
|
|
46
|
+
}
|
|
47
|
+
/** Change an endpoint's URL, events, description, or active state. Requires `webhook:write`. */
|
|
48
|
+
async update(id, params) {
|
|
49
|
+
const { data } = await this.http.patch(`/v1/webhooks/endpoints/${encodeURIComponent(id)}`, {
|
|
50
|
+
...(params.url ? { url: params.url } : {}),
|
|
51
|
+
...(params.eventTypes ? { event_types: params.eventTypes } : {}),
|
|
52
|
+
...(params.description !== undefined ? { description: params.description } : {}),
|
|
53
|
+
...(params.isActive !== undefined ? { is_active: params.isActive } : {}),
|
|
54
|
+
});
|
|
55
|
+
return data;
|
|
56
|
+
}
|
|
57
|
+
/** Stop delivering to an endpoint. Requires `webhook:write`. */
|
|
58
|
+
async remove(id) {
|
|
59
|
+
const { data } = await this.http.delete(`/v1/webhooks/endpoints/${encodeURIComponent(id)}`);
|
|
60
|
+
return data;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Issue a new signing secret.
|
|
64
|
+
*
|
|
65
|
+
* NOT retry-safe: each call invalidates the secret the previous one issued, so a retry can strand
|
|
66
|
+
* a receiver that was verifying correctly seconds earlier. Returns the new secret once.
|
|
67
|
+
*/
|
|
68
|
+
async rotateSecret(id) {
|
|
69
|
+
const { data } = await this.http.post(`/v1/webhooks/endpoints/${encodeURIComponent(id)}/rotate-secret`);
|
|
70
|
+
return data;
|
|
71
|
+
}
|
|
72
|
+
/** Re-run the verification ping against an endpoint. Requires `webhook:write`. */
|
|
73
|
+
async verify(id) {
|
|
74
|
+
const { data } = await this.http.post(`/v1/webhooks/endpoints/${encodeURIComponent(id)}/verify`);
|
|
75
|
+
return data;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Delivery attempts, newest first. Requires `webhook:read`.
|
|
79
|
+
*
|
|
80
|
+
* This is the half that makes webhooks debuggable: a delivery that failed is otherwise invisible
|
|
81
|
+
* to the person waiting for the event.
|
|
82
|
+
*/
|
|
83
|
+
async deliveries(params = {}) {
|
|
84
|
+
const { data } = await this.http.get('/v1/webhooks/deliveries', {
|
|
85
|
+
params: { limit: params.limit ?? 50, offset: params.offset ?? 0 },
|
|
86
|
+
});
|
|
87
|
+
return data;
|
|
88
|
+
}
|
|
89
|
+
/** Every delivery, paging automatically on `has_more`. */
|
|
90
|
+
deliveriesAll(pageSize = 100) {
|
|
91
|
+
return paginate(async (limit, offset) => {
|
|
92
|
+
const page = await this.deliveries({ limit, offset });
|
|
93
|
+
return { items: page.deliveries ?? [], hasMore: page.pagination?.has_more };
|
|
94
|
+
}, pageSize);
|
|
95
|
+
}
|
|
96
|
+
/** One delivery, including the response body the endpoint returned. Requires `webhook:read`. */
|
|
97
|
+
async delivery(id) {
|
|
98
|
+
const { data } = await this.http.get(`/v1/webhooks/deliveries/${encodeURIComponent(id)}`);
|
|
99
|
+
return data;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Send a delivery again.
|
|
103
|
+
*
|
|
104
|
+
* Deliberately NOT retry-safe: delivering again is the entire point, so calling this twice
|
|
105
|
+
* delivers twice. Make sure the receiver is idempotent before leaning on it.
|
|
106
|
+
*/
|
|
107
|
+
async redeliver(id) {
|
|
108
|
+
const { data } = await this.http.post(`/v1/webhooks/deliveries/${encodeURIComponent(id)}/redeliver`);
|
|
109
|
+
return data;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=webhooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhooks.js","sourceRoot":"","sources":["../../src/resources/webhooks.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAGxC;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,gBAAgB;IACP;IAApB,YAAoB,IAAmB;QAAnB,SAAI,GAAJ,IAAI,CAAe;IAAG,CAAC;IAE3C,2EAA2E;IAC3E,KAAK,CAAC,IAAI;QACR,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAA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AM,IAAI,CAAC,EAAE;SAClE,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;IAED,0DAA0D;IAC1D,aAAa,CAAC,QAAQ,GAAG,GAAG;QAC1B,OAAO,QAAQ,CACb,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;YACtB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;YACtD,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,UAAU,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE,QAAQ,EAAE,CAAC;QAC9E,CAAC,EACD,QAAQ,CACT,CAAC;IACJ,CAAC;IAED,gGAAgG;IAChG,KAAK,CAAC,QAAQ,CAAC,EAAU;QACvB,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,2BAA2B,kBAAkB,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QAC1F,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,SAAS,CAAC,EAAU;QACxB,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CACnC,2BAA2B,kBAAkB,CAAC,EAAE,CAAC,YAAY,CAC9D,CAAC;QACF,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { SignupChallenge, RedeemedRegistration } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Provisioning an organization by proving you hold a key — no browser, no email, nobody at CERTEN.
|
|
4
|
+
*
|
|
5
|
+
* CERTEN is non-custodial: we never hold a customer's keys. A signup that required a human — ours
|
|
6
|
+
* in an approvals queue, theirs in a browser, or an existing customer handing over a registration
|
|
7
|
+
* token — contradicted that, and made CERTEN a friction point in the one flow where it should be
|
|
8
|
+
* invisible.
|
|
9
|
+
*
|
|
10
|
+
* The anchor is an Ed25519 keypair, which is free to create, impossible for us to hold, needs no
|
|
11
|
+
* inbox, and is a credential the caller needs anyway: every CERTEN identity is an Ed25519 key. One
|
|
12
|
+
* step does two jobs.
|
|
13
|
+
*
|
|
14
|
+
* Standalone rather than client methods, for the reason that recurs across this SDK: the caller
|
|
15
|
+
* holds no credential, and obtaining the first one is the entire purpose.
|
|
16
|
+
*/
|
|
17
|
+
interface Endpoint {
|
|
18
|
+
/** Defaults to the SDK's configured gateway. */
|
|
19
|
+
baseUrl?: string;
|
|
20
|
+
timeoutMs?: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Ask for a nonce to sign.
|
|
24
|
+
*
|
|
25
|
+
* Pass `publicKey` — it binds the challenge to your key, so nobody who observes the nonce in flight
|
|
26
|
+
* can answer it with their own.
|
|
27
|
+
*/
|
|
28
|
+
export declare function requestSignupChallenge(publicKey?: string, options?: Endpoint): Promise<SignupChallenge>;
|
|
29
|
+
/**
|
|
30
|
+
* Answer a challenge and receive a new organization with its first API key.
|
|
31
|
+
*
|
|
32
|
+
* `signature` is a DETACHED Ed25519 signature over the raw bytes of the nonce — decode the hex
|
|
33
|
+
* first. Signing the hex text instead is the one mistake worth calling out, and the gateway says so
|
|
34
|
+
* explicitly when it happens.
|
|
35
|
+
*
|
|
36
|
+
* **The API key is returned once.** The nonce is spent by this call whether or not it succeeded, so
|
|
37
|
+
* a retry needs a fresh challenge.
|
|
38
|
+
*/
|
|
39
|
+
export declare function completeSignup(params: {
|
|
40
|
+
publicKey: string;
|
|
41
|
+
nonce: string;
|
|
42
|
+
signature: string;
|
|
43
|
+
orgName?: string;
|
|
44
|
+
}, options?: Endpoint): Promise<RedeemedRegistration>;
|
|
45
|
+
/**
|
|
46
|
+
* Both steps, for a caller that can sign.
|
|
47
|
+
*
|
|
48
|
+
* ```ts
|
|
49
|
+
* const { org, api_key } = await selfSignup({
|
|
50
|
+
* publicKey: myPublicKeyHex,
|
|
51
|
+
* sign: (nonceHex) => signWithMyKey(nonceHex), // detached ed25519 over the nonce BYTES
|
|
52
|
+
* orgName: 'my-agent',
|
|
53
|
+
* });
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* `sign` receives the nonce as hex and must return the signature as hex. That signature is made
|
|
57
|
+
* with a private key this SDK never sees — which is the point, and why signing is a callback rather
|
|
58
|
+
* than a key parameter.
|
|
59
|
+
*/
|
|
60
|
+
export declare function selfSignup(params: {
|
|
61
|
+
publicKey: string;
|
|
62
|
+
sign: (nonceHex: string) => string | Promise<string>;
|
|
63
|
+
orgName?: string;
|
|
64
|
+
}, options?: Endpoint): Promise<RedeemedRegistration>;
|
|
65
|
+
export {};
|
|
66
|
+
//# sourceMappingURL=self-signup.d.ts.map
|