@certen.io/sdk 0.5.0 → 0.7.1

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 (112) hide show
  1. package/CHANGELOG.md +599 -0
  2. package/README.md +133 -119
  3. package/dist/client.d.ts +96 -6
  4. package/dist/client.d.ts.map +1 -1
  5. package/dist/client.js +258 -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 +13 -1
  16. package/dist/errors.d.ts.map +1 -1
  17. package/dist/errors.js +18 -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 -0
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +19 -0
  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 +198 -19
  40. package/dist/resources/billing.d.ts.map +1 -1
  41. package/dist/resources/billing.js +297 -7
  42. package/dist/resources/billing.js.map +1 -1
  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 +10 -0
  52. package/dist/resources/execute.d.ts.map +1 -1
  53. package/dist/resources/execute.js +28 -6
  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 +82 -0
  72. package/dist/resources/proof.d.ts.map +1 -0
  73. package/dist/resources/proof.js +112 -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/sign.d.ts.map +1 -1
  80. package/dist/resources/sign.js +12 -7
  81. package/dist/resources/sign.js.map +1 -1
  82. package/dist/resources/transaction.d.ts +20 -0
  83. package/dist/resources/transaction.d.ts.map +1 -1
  84. package/dist/resources/transaction.js +28 -0
  85. package/dist/resources/transaction.js.map +1 -1
  86. package/dist/resources/transparency.d.ts +68 -0
  87. package/dist/resources/transparency.d.ts.map +1 -0
  88. package/dist/resources/transparency.js +83 -0
  89. package/dist/resources/transparency.js.map +1 -0
  90. package/dist/resources/webhooks.d.ts +97 -0
  91. package/dist/resources/webhooks.d.ts.map +1 -0
  92. package/dist/resources/webhooks.js +112 -0
  93. package/dist/resources/webhooks.js.map +1 -0
  94. package/dist/self-signup.d.ts +66 -0
  95. package/dist/self-signup.d.ts.map +1 -0
  96. package/dist/self-signup.js +76 -0
  97. package/dist/self-signup.js.map +1 -0
  98. package/dist/shared-proof.d.ts +34 -0
  99. package/dist/shared-proof.d.ts.map +1 -0
  100. package/dist/shared-proof.js +78 -0
  101. package/dist/shared-proof.js.map +1 -0
  102. package/dist/sign-target.d.ts +34 -0
  103. package/dist/sign-target.d.ts.map +1 -0
  104. package/dist/sign-target.js +41 -0
  105. package/dist/sign-target.js.map +1 -0
  106. package/dist/types.d.ts +831 -22
  107. package/dist/types.d.ts.map +1 -1
  108. package/dist/verify-receipt.d.ts +32 -0
  109. package/dist/verify-receipt.d.ts.map +1 -0
  110. package/dist/verify-receipt.js +176 -0
  111. package/dist/verify-receipt.js.map +1 -0
  112. package/package.json +4 -3
@@ -0,0 +1,43 @@
1
+ import { AxiosInstance } from 'axios';
2
+ import { CertenError } from './errors.js';
3
+ /**
4
+ * The unfunded abstract account guard.
5
+ *
6
+ * This is the most expensive silent failure the platform can produce, and it is invisible at every
7
+ * point where someone might notice it. A fresh identity gets a deterministic abstract account on
8
+ * each linked chain, with a zero balance. An intent that moves value from it is accepted, signed
9
+ * and submitted — every call returns success — and then parks at `anchoring` forever, because the
10
+ * execution leg cannot run on chain. No response says so. The intent simply never reaches a
11
+ * terminal state, and the failure is usually blamed on the gateway.
12
+ *
13
+ * So the SDK refuses before submitting, and says why.
14
+ *
15
+ * **The check is one-directional by design.** It refuses ONLY on a positively observed zero
16
+ * balance. If the balance cannot be read — the chain is absent from the portfolio, the account is
17
+ * not deployed, the lookup fails — the intent proceeds. A guard that blocked on missing data would
18
+ * break legitimate work every time the portfolio view lagged, which is a worse failure than the one
19
+ * it prevents. It is a courtesy, not a gate the product depends on.
20
+ */
21
+ /** Thrown instead of submitting an intent that could never execute. */
22
+ export declare class CertenUnfundedAccountError extends CertenError {
23
+ readonly address: string;
24
+ readonly chain: string;
25
+ constructor(address: string, chain: string);
26
+ /** Never. Funding is a human act; retrying changes nothing. */
27
+ get isRetryable(): boolean;
28
+ }
29
+ export declare function normalizeChainId(value: string | number | null | undefined): string;
30
+ /** Does this amount move value? A zero or absent amount needs no funded account. */
31
+ export declare function movesValue(amount: unknown): boolean;
32
+ /**
33
+ * Refuse a value-moving intent from an abstract account positively known to be empty.
34
+ *
35
+ * Reads the portfolio directly rather than taking a client, so this stays usable from inside
36
+ * `ExecuteResource`, which holds only an axios instance.
37
+ */
38
+ export declare function assertFundedForValue(http: AxiosInstance, params: {
39
+ identityId: string;
40
+ chain: string | undefined;
41
+ amount: unknown;
42
+ }): Promise<void>;
43
+ //# sourceMappingURL=funding.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"funding.d.ts","sourceRoot":"","sources":["../src/funding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C;;;;;;;;;;;;;;;;;GAiBG;AAEH,uEAAuE;AACvE,qBAAa,0BAA2B,SAAQ,WAAW;IACzD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;gBAEX,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAe1C,+DAA+D;IAC/D,IAAI,WAAW,IAAI,OAAO,CAEzB;CACF;AAuBD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAIlF;AAED,oFAAoF;AACpF,wBAAgB,UAAU,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAOnD;AAED;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,aAAa,EACnB,MAAM,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,GACzE,OAAO,CAAC,IAAI,CAAC,CAiCf"}
@@ -0,0 +1,116 @@
1
+ import { CertenError } from './errors.js';
2
+ /**
3
+ * The unfunded abstract account guard.
4
+ *
5
+ * This is the most expensive silent failure the platform can produce, and it is invisible at every
6
+ * point where someone might notice it. A fresh identity gets a deterministic abstract account on
7
+ * each linked chain, with a zero balance. An intent that moves value from it is accepted, signed
8
+ * and submitted — every call returns success — and then parks at `anchoring` forever, because the
9
+ * execution leg cannot run on chain. No response says so. The intent simply never reaches a
10
+ * terminal state, and the failure is usually blamed on the gateway.
11
+ *
12
+ * So the SDK refuses before submitting, and says why.
13
+ *
14
+ * **The check is one-directional by design.** It refuses ONLY on a positively observed zero
15
+ * balance. If the balance cannot be read — the chain is absent from the portfolio, the account is
16
+ * not deployed, the lookup fails — the intent proceeds. A guard that blocked on missing data would
17
+ * break legitimate work every time the portfolio view lagged, which is a worse failure than the one
18
+ * it prevents. It is a courtesy, not a gate the product depends on.
19
+ */
20
+ /** Thrown instead of submitting an intent that could never execute. */
21
+ export class CertenUnfundedAccountError extends CertenError {
22
+ address;
23
+ chain;
24
+ constructor(address, chain) {
25
+ super(`The abstract account ${address} on ${chain} holds no gas. This intent would be accepted, `
26
+ + 'signed and submitted, and would then park at "anchoring" forever, because the execution leg '
27
+ + 'cannot run on chain. Fund it first, or pass skipFundingCheck: true to submit anyway.',
28
+ // 0 is the SDK's "this never reached the gateway" status, which is exactly true here: the
29
+ // guard runs before the request, and nothing was submitted.
30
+ 0, 'ABSTRACT_ACCOUNT_UNFUNDED');
31
+ this.name = 'CertenUnfundedAccountError';
32
+ this.address = address;
33
+ this.chain = chain;
34
+ }
35
+ /** Never. Funding is a human act; retrying changes nothing. */
36
+ get isRetryable() {
37
+ return false;
38
+ }
39
+ }
40
+ /**
41
+ * Numeric EVM chain id → registry slug.
42
+ *
43
+ * `GET /v1/portfolio` used to return `chain_id` as a slug on some chain accounts and as a numeric
44
+ * EVM id on others, in the same response, because the gateway stored whatever the caller sent.
45
+ * Comparing raw strings matched the slug entries and silently skipped the numeric ones — so this
46
+ * guard did nothing on exactly the accounts it was written to protect.
47
+ *
48
+ * The gateway now canonicalizes on write and has backfilled the old rows, so a current gateway
49
+ * returns slugs only. This stays anyway, and not out of superstition: the SDK is versioned
50
+ * independently and is routinely pointed at a gateway older than itself. A guard that silently
51
+ * stops guarding against an older peer is worse than no guard, because nothing signals the gap.
52
+ */
53
+ const NUMERIC_CHAIN_IDS = {
54
+ 11155111: 'ethereum-sepolia',
55
+ 84532: 'base-sepolia',
56
+ 421614: 'arbitrum-sepolia',
57
+ 11155420: 'optimism-sepolia',
58
+ 80002: 'polygon-amoy',
59
+ };
60
+ export function normalizeChainId(value) {
61
+ if (value === null || value === undefined)
62
+ return '';
63
+ const raw = String(value).trim();
64
+ return NUMERIC_CHAIN_IDS[raw] ?? raw;
65
+ }
66
+ /** Does this amount move value? A zero or absent amount needs no funded account. */
67
+ export function movesValue(amount) {
68
+ if (amount === undefined || amount === null || amount === '')
69
+ return false;
70
+ const n = Number(String(amount));
71
+ // A non-numeric amount is not evidence of zero. Assume it moves value and let the gateway judge
72
+ // the shape — the opposite default would skip the guard on exactly the malformed input that most
73
+ // warrants a second look.
74
+ return Number.isFinite(n) ? n > 0 : true;
75
+ }
76
+ /**
77
+ * Refuse a value-moving intent from an abstract account positively known to be empty.
78
+ *
79
+ * Reads the portfolio directly rather than taking a client, so this stays usable from inside
80
+ * `ExecuteResource`, which holds only an axios instance.
81
+ */
82
+ export async function assertFundedForValue(http, params) {
83
+ if (!params.chain || !movesValue(params.amount))
84
+ return;
85
+ let address;
86
+ let balance;
87
+ try {
88
+ const { data } = await http.get('/v1/portfolio', { params: { identity: params.identityId } });
89
+ const want = normalizeChainId(params.chain);
90
+ const identities = data.identities ?? [];
91
+ for (const identity of identities) {
92
+ for (const chain of identity.chains ?? []) {
93
+ if (normalizeChainId(chain.chain_id) !== want)
94
+ continue;
95
+ // The NATIVE balance is what pays for execution. A token balance on the same account does
96
+ // not make the execution leg runnable.
97
+ const native = (chain.balances ?? [])
98
+ .find((b) => !b.token || b.token === 'ETH' || b.token === 'native');
99
+ if (!native)
100
+ return;
101
+ address = chain.address;
102
+ balance = native.balance;
103
+ }
104
+ }
105
+ }
106
+ catch {
107
+ // An unavailable portfolio must never block a transaction.
108
+ return;
109
+ }
110
+ if (address === undefined || balance === undefined)
111
+ return;
112
+ if (Number(balance) > 0)
113
+ return;
114
+ throw new CertenUnfundedAccountError(address, normalizeChainId(params.chain));
115
+ }
116
+ //# sourceMappingURL=funding.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"funding.js","sourceRoot":"","sources":["../src/funding.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C;;;;;;;;;;;;;;;;;GAiBG;AAEH,uEAAuE;AACvE,MAAM,OAAO,0BAA2B,SAAQ,WAAW;IAChD,OAAO,CAAS;IAChB,KAAK,CAAS;IAEvB,YAAY,OAAe,EAAE,KAAa;QACxC,KAAK,CACH,wBAAwB,OAAO,OAAO,KAAK,gDAAgD;cACzF,8FAA8F;cAC9F,sFAAsF;QACxF,0FAA0F;QAC1F,4DAA4D;QAC5D,CAAC,EACD,2BAA2B,CAC5B,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,4BAA4B,CAAC;QACzC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,+DAA+D;IAC/D,IAAI,WAAW;QACb,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAED;;;;;;;;;;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,CAAC;QAC9F,MAAM,IAAI,GAAG,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC5C,MAAM,UAAU,GAAI,IAElB,CAAC,UAAU,IAAI,EAAE,CAAC;QAEpB,KAAK,MAAM,QAAQ,IAAI,UAAU,EAAE,CAAC;YAClC,KAAK,MAAM,KAAK,IAAI,QAAQ,CAAC,MAAM,IAAI,EAAE,EAAE,CAAC;gBAC1C,IAAI,gBAAgB,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,IAAI;oBAAE,SAAS;gBACxD,0FAA0F;gBAC1F,uCAAuC;gBACvC,MAAM,MAAM,GAAG,CAAC,KAAK,CAAC,QAAQ,IAAI,EAAE,CAAC;qBAClC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,KAAK,KAAK,KAAK,IAAI,CAAC,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC;gBACtE,IAAI,CAAC,MAAM;oBAAE,OAAO;gBACpB,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;gBACxB,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;YAC3B,CAAC;QACH,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,2DAA2D;QAC3D,OAAO;IACT,CAAC;IAED,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,SAAS;QAAE,OAAO;IAC3D,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC;QAAE,OAAO;IAEhC,MAAM,IAAI,0BAA0B,CAAC,OAAO,EAAE,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AAChF,CAAC"}
package/dist/index.d.ts CHANGED
@@ -3,4 +3,14 @@ export * from './types.js';
3
3
  export type { SignFn, ProofGatedCallParams, TransferParams, OpenedIntent } from './resources/execute.js';
4
4
  export { CertenError, CertenAuthError, CertenRateLimitError, CertenBadRequestError, CertenServerError, CertenPaymentRequiredError, } from './errors.js';
5
5
  export type { PaymentResolution } from './errors.js';
6
+ export { runDoctor, CREDENTIALLED_CHECKS } from './doctor.js';
7
+ export { fetchSharedProof, parseShareTarget } from './shared-proof.js';
8
+ export { fetchOAuthToken, refreshOAuthToken, revokeOAuthToken } from './oauth.js';
9
+ export { parseMnemonicTarget } from './resources/identity.js';
10
+ export { redeemRegistrationToken } from './registration.js';
11
+ export { selfSignup, requestSignupChallenge, completeSignup } from './self-signup.js';
12
+ export { CertenUnfundedAccountError, movesValue, normalizeChainId } from './funding.js';
13
+ export { resolveSignTarget } from './sign-target.js';
14
+ export type { SignTarget } from './sign-target.js';
15
+ export type { DoctorReport, DoctorCheck, CheckStatus } from './doctor.js';
6
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC1F,cAAc,YAAY,CAAC;AAC3B,YAAY,EAAE,MAAM,EAAE,oBAAoB,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACzG,OAAO,EACL,WAAW,EACX,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,EACjB,0BAA0B,GAC3B,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC1F,cAAc,YAAY,CAAC;AAC3B,YAAY,EAAE,MAAM,EAAE,oBAAoB,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACzG,OAAO,EACL,WAAW,EACX,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,EACjB,0BAA0B,GAC3B,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAG9D,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAGvE,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAGlF,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAG9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAG5D,OAAO,EAAE,UAAU,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACtF,OAAO,EAAE,0BAA0B,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAExF,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,YAAY,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC"}
package/dist/index.js CHANGED
@@ -1,4 +1,23 @@
1
1
  export { CertenClient, paginate, paginateWithTotal, DEFAULT_BASE_URL } from './client.js';
2
2
  export * from './types.js';
3
3
  export { CertenError, CertenAuthError, CertenRateLimitError, CertenBadRequestError, CertenServerError, CertenPaymentRequiredError, } from './errors.js';
4
+ export { runDoctor, CREDENTIALLED_CHECKS } from './doctor.js';
5
+ // Standalone on purpose: redeeming a share link needs no API key and therefore no client. See
6
+ // shared-proof.ts.
7
+ export { fetchSharedProof, parseShareTarget } from './shared-proof.js';
8
+ // Standalone for the same reason: these carry their credential in the body and need no API key,
9
+ // so a caller using OAuth is not made to hold one. See oauth.ts.
10
+ export { fetchOAuthToken, refreshOAuthToken, revokeOAuthToken } from './oauth.js';
11
+ // Exported so a caller can split `mnemonic_retrieval.url` the same way the SDK does, rather than
12
+ // writing their own regex against a string whose parts they cannot afford to get wrong.
13
+ export { parseMnemonicTarget } from './resources/identity.js';
14
+ // Standalone for the same reason as the OAuth helpers: the caller has no credential yet, and
15
+ // obtaining its first one is the entire purpose. See registration.ts.
16
+ export { redeemRegistrationToken } from './registration.js';
17
+ // Keypair-proof self-service signup — no browser, no email, nobody at CERTEN. Standalone for the
18
+ // same reason: the caller holds nothing yet. See self-signup.ts.
19
+ export { selfSignup, requestSignupChallenge, completeSignup } from './self-signup.js';
20
+ export { CertenUnfundedAccountError, movesValue, normalizeChainId } from './funding.js';
21
+ // One resolver, shared by the CLI and MCP. Two copies of this would drift — see sign-target.ts.
22
+ export { resolveSignTarget } from './sign-target.js';
4
23
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC1F,cAAc,YAAY,CAAC;AAE3B,OAAO,EACL,WAAW,EACX,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,EACjB,0BAA0B,GAC3B,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC1F,cAAc,YAAY,CAAC;AAE3B,OAAO,EACL,WAAW,EACX,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,EACjB,0BAA0B,GAC3B,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAC9D,8FAA8F;AAC9F,mBAAmB;AACnB,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACvE,gGAAgG;AAChG,iEAAiE;AACjE,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAClF,iGAAiG;AACjG,wFAAwF;AACxF,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,6FAA6F;AAC7F,sEAAsE;AACtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,iGAAiG;AACjG,iEAAiE;AACjE,OAAO,EAAE,UAAU,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACtF,OAAO,EAAE,0BAA0B,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACxF,gGAAgG;AAChG,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,56 @@
1
+ import type { OAuthTokens } from './types.js';
2
+ /**
3
+ * The OAuth2 token lifecycle: obtain, refresh, revoke.
4
+ *
5
+ * None of it was reachable from this SDK — not the token endpoint, not revocation. A machine using
6
+ * client credentials could get a token only by hand-rolling HTTP, and could not give it back at
7
+ * all. That asymmetry is the dangerous half: a leaked token had no revocation path an integration
8
+ * could call, so the response to a suspected compromise was to open a browser.
9
+ *
10
+ * **Standalone functions, deliberately — not methods on `CertenClient`.** Both endpoints take their
11
+ * credential in the BODY and require no API key, which is the whole point: a service using OAuth
12
+ * has a client id and secret, not an API key, so routing these through a constructor that demands
13
+ * `apiKey` would ask for the one credential such a caller does not hold. Same reasoning as
14
+ * `fetchSharedProof`.
15
+ */
16
+ interface Endpoint {
17
+ /** Defaults to the SDK's configured gateway. */
18
+ baseUrl?: string;
19
+ timeoutMs?: number;
20
+ }
21
+ /**
22
+ * Exchange client credentials for an access token.
23
+ *
24
+ * Returns an access token good for an hour and a refresh token good for thirty days.
25
+ */
26
+ export declare function fetchOAuthToken(params: {
27
+ clientId: string;
28
+ clientSecret: string;
29
+ scope?: string;
30
+ }, options?: Endpoint): Promise<OAuthTokens>;
31
+ /**
32
+ * Trade a refresh token for a fresh pair.
33
+ *
34
+ * **The old refresh token is spent the moment this succeeds.** Replaying one that has already been
35
+ * used revokes its entire descendant chain — that is deliberate theft detection, not a bug: if a
36
+ * stolen token is replayed, both the thief's and the victim's tokens die and the compromise
37
+ * surfaces. So store the new pair before doing anything else, and never retry this call blindly
38
+ * with the same token.
39
+ */
40
+ export declare function refreshOAuthToken(refreshToken: string, options?: Endpoint): Promise<OAuthTokens>;
41
+ /**
42
+ * Revoke a token (RFC 7009).
43
+ *
44
+ * Accepts an access token or a refresh token; revoking a REFRESH token kills its whole descendant
45
+ * chain, which is what you want when responding to a leak.
46
+ *
47
+ * Always resolves when the request is understood, even for a token that never existed — the
48
+ * endpoint deliberately does not reveal whether it did, because an endpoint that distinguished them
49
+ * would be an oracle for guessing tokens. So a successful call means "this token is not valid now",
50
+ * not "this token was valid and now is not".
51
+ */
52
+ export declare function revokeOAuthToken(token: string, options?: Endpoint & {
53
+ tokenTypeHint?: 'access_token' | 'refresh_token';
54
+ }): Promise<void>;
55
+ export {};
56
+ //# sourceMappingURL=oauth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../src/oauth.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;;;;;;;;;;;;GAaG;AAEH,UAAU,QAAQ;IAChB,gDAAgD;IAChD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AA0BD;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,EAClE,OAAO,GAAE,QAAa,GACrB,OAAO,CAAC,WAAW,CAAC,CAOtB;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,YAAY,EAAE,MAAM,EACpB,OAAO,GAAE,QAAa,GACrB,OAAO,CAAC,WAAW,CAAC,CAKtB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,QAAQ,GAAG;IAAE,aAAa,CAAC,EAAE,cAAc,GAAG,eAAe,CAAA;CAAO,GAC5E,OAAO,CAAC,IAAI,CAAC,CAKf"}
package/dist/oauth.js ADDED
@@ -0,0 +1,68 @@
1
+ import axios from 'axios';
2
+ import { DEFAULT_BASE_URL } from './client.js';
3
+ import { CertenError } from './errors.js';
4
+ async function post(path, body, options) {
5
+ const base = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, '');
6
+ try {
7
+ const { data } = await axios.post(`${base}${path}`, body, {
8
+ timeout: options.timeoutMs ?? 30_000,
9
+ headers: { 'Content-Type': 'application/json' },
10
+ });
11
+ return data;
12
+ }
13
+ catch (err) {
14
+ const e = err;
15
+ const status = e.response?.status ?? 0;
16
+ const payload = e.response?.data;
17
+ // OAuth errors use `error` / `error_description` (RFC 6749) rather than this API's usual
18
+ // `error` / `code`, so the message is assembled from whichever arrived.
19
+ const message = payload?.error_description ?? payload?.error ?? e.message;
20
+ throw new CertenError(`certen: ${message}`, status, payload?.code ?? payload?.error ?? (status ? 'OAUTH_ERROR' : 'NETWORK_ERROR'), { body: payload });
21
+ }
22
+ }
23
+ /**
24
+ * Exchange client credentials for an access token.
25
+ *
26
+ * Returns an access token good for an hour and a refresh token good for thirty days.
27
+ */
28
+ export function fetchOAuthToken(params, options = {}) {
29
+ return post('/v1/oauth/token', {
30
+ grant_type: 'client_credentials',
31
+ client_id: params.clientId,
32
+ client_secret: params.clientSecret,
33
+ ...(params.scope ? { scope: params.scope } : {}),
34
+ }, options);
35
+ }
36
+ /**
37
+ * Trade a refresh token for a fresh pair.
38
+ *
39
+ * **The old refresh token is spent the moment this succeeds.** Replaying one that has already been
40
+ * used revokes its entire descendant chain — that is deliberate theft detection, not a bug: if a
41
+ * stolen token is replayed, both the thief's and the victim's tokens die and the compromise
42
+ * surfaces. So store the new pair before doing anything else, and never retry this call blindly
43
+ * with the same token.
44
+ */
45
+ export function refreshOAuthToken(refreshToken, options = {}) {
46
+ return post('/v1/oauth/token', {
47
+ grant_type: 'refresh_token',
48
+ refresh_token: refreshToken,
49
+ }, options);
50
+ }
51
+ /**
52
+ * Revoke a token (RFC 7009).
53
+ *
54
+ * Accepts an access token or a refresh token; revoking a REFRESH token kills its whole descendant
55
+ * chain, which is what you want when responding to a leak.
56
+ *
57
+ * Always resolves when the request is understood, even for a token that never existed — the
58
+ * endpoint deliberately does not reveal whether it did, because an endpoint that distinguished them
59
+ * would be an oracle for guessing tokens. So a successful call means "this token is not valid now",
60
+ * not "this token was valid and now is not".
61
+ */
62
+ export async function revokeOAuthToken(token, options = {}) {
63
+ await post('/v1/oauth/revoke', {
64
+ token,
65
+ ...(options.tokenTypeHint ? { token_type_hint: options.tokenTypeHint } : {}),
66
+ }, options);
67
+ }
68
+ //# sourceMappingURL=oauth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth.js","sourceRoot":"","sources":["../src/oauth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAwB1C,KAAK,UAAU,IAAI,CAAI,IAAY,EAAE,IAAa,EAAE,OAAiB;IACnE,MAAM,IAAI,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,gBAAgB,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACvE,IAAI,CAAC;QACH,MAAM,EAAE,IAAI,EAAE,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U,iBAAiB,CAC/B,YAAoB,EACpB,UAAoB,EAAE;IAEtB,OAAO,IAAI,CAAc,iBAAiB,EAAE;QAC1C,UAAU,EAAE,eAAe;QAC3B,aAAa,EAAE,YAAY;KAC5B,EAAE,OAAO,CAAC,CAAC;AACd,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,KAAa,EACb,UAA2E,EAAE;IAE7E,MAAM,IAAI,CAAU,kBAAkB,EAAE;QACtC,KAAK;QACL,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC7E,EAAE,OAAO,CAAC,CAAC;AACd,CAAC"}
@@ -0,0 +1,33 @@
1
+ import type { RedeemedRegistration } from './types.js';
2
+ /**
3
+ * Redeem a registration token for a new organization and its first API key.
4
+ *
5
+ * **Standalone, and necessarily so.** Every other call in this SDK goes through `CertenClient`,
6
+ * which requires a credential — and the entire point of this one is that the caller does not have
7
+ * one yet. Routing it through a constructor that demands `apiKey` would ask for the exact thing it
8
+ * exists to produce. Same reasoning as `fetchSharedProof` and `fetchOAuthToken`.
9
+ *
10
+ * Before this existed, an organization could only be born inside a browser: the Firebase login
11
+ * exchange created one just-in-time when no membership was found. So a platform could not provision
12
+ * its customers, a CI job could not create a scratch org, and an agent could not take its first
13
+ * step — every automated path stopped and waited for a person.
14
+ *
15
+ * A human still decides that an org may exist, by minting the token. What changed is that the
16
+ * decision and the provisioning no longer have to happen at the same keyboard at the same moment.
17
+ *
18
+ * ```ts
19
+ * const { org, api_key } = await redeemRegistrationToken('crt_…');
20
+ * const certen = new CertenClient({ apiKey: api_key });
21
+ * ```
22
+ *
23
+ * **The API key is returned once.** Store it before doing anything else; no endpoint will repeat
24
+ * it. The token is single-use, so a failed store cannot be fixed by redeeming again.
25
+ */
26
+ export declare function redeemRegistrationToken(token: string, options?: {
27
+ /** Overrides the organization name the minter pinned. */
28
+ orgName?: string;
29
+ /** Defaults to the SDK's configured gateway. */
30
+ baseUrl?: string;
31
+ timeoutMs?: number;
32
+ }): Promise<RedeemedRegistration>;
33
+ //# sourceMappingURL=registration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registration.d.ts","sourceRoot":"","sources":["../src/registration.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,uBAAuB,CAC3C,KAAK,EAAE,MAAM,EACb,OAAO,GAAE;IACP,yDAAyD;IACzD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gDAAgD;IAChD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACf,GACL,OAAO,CAAC,oBAAoB,CAAC,CA4B/B"}
@@ -0,0 +1,49 @@
1
+ import axios from 'axios';
2
+ import { DEFAULT_BASE_URL } from './client.js';
3
+ import { CertenError } from './errors.js';
4
+ /**
5
+ * Redeem a registration token for a new organization and its first API key.
6
+ *
7
+ * **Standalone, and necessarily so.** Every other call in this SDK goes through `CertenClient`,
8
+ * which requires a credential — and the entire point of this one is that the caller does not have
9
+ * one yet. Routing it through a constructor that demands `apiKey` would ask for the exact thing it
10
+ * exists to produce. Same reasoning as `fetchSharedProof` and `fetchOAuthToken`.
11
+ *
12
+ * Before this existed, an organization could only be born inside a browser: the Firebase login
13
+ * exchange created one just-in-time when no membership was found. So a platform could not provision
14
+ * its customers, a CI job could not create a scratch org, and an agent could not take its first
15
+ * step — every automated path stopped and waited for a person.
16
+ *
17
+ * A human still decides that an org may exist, by minting the token. What changed is that the
18
+ * decision and the provisioning no longer have to happen at the same keyboard at the same moment.
19
+ *
20
+ * ```ts
21
+ * const { org, api_key } = await redeemRegistrationToken('crt_…');
22
+ * const certen = new CertenClient({ apiKey: api_key });
23
+ * ```
24
+ *
25
+ * **The API key is returned once.** Store it before doing anything else; no endpoint will repeat
26
+ * it. The token is single-use, so a failed store cannot be fixed by redeeming again.
27
+ */
28
+ export async function redeemRegistrationToken(token, options = {}) {
29
+ const base = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, '');
30
+ try {
31
+ const { data } = await axios.post(`${base}/v1/registration-tokens/redeem`, { token, ...(options.orgName ? { org_name: options.orgName } : {}) }, { timeout: options.timeoutMs ?? 30_000, headers: { 'Content-Type': 'application/json' } });
32
+ return data;
33
+ }
34
+ catch (err) {
35
+ const e = err;
36
+ const status = e.response?.status ?? 0;
37
+ const payload = e.response?.data;
38
+ // A 404 here does NOT mean "wrong URL". The gateway deliberately reports unknown, expired,
39
+ // revoked and already-redeemed tokens identically, so that an endpoint needing no credential
40
+ // cannot be used to probe which guesses were close. Say that plainly, or the caller will go
41
+ // looking for a typo in the base URL.
42
+ const message = status === 404
43
+ ? 'certen: this registration token cannot be redeemed — it is unknown, expired, revoked, or '
44
+ + 'already used. These are reported identically on purpose. Ask for a new token.'
45
+ : payload?.error ?? e.message;
46
+ throw new CertenError(status === 404 ? message : `certen: ${message}`, status, payload?.code ?? (status ? 'REGISTRATION_FAILED' : 'NETWORK_ERROR'), { body: payload });
47
+ }
48
+ }
49
+ //# sourceMappingURL=registration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registration.js","sourceRoot":"","sources":["../src/registration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG1C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,KAAa,EACb,UAMI,EAAE;IAEN,MAAM,IAAI,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,gBAAgB,CAAC,CAAC,OAAO,CAAC,M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eyParams, ApiKeyResponse, ApiKeyListItem, AuditLogResponse, UsageSummaryResponse } from '../types.js';
2
+ import type { CreateOrgParams, OrgResponse, CreateApiKeyParams, ApiKeyResponse, ApiKeyListItem, AuditLogResponse, AuditLogEntry, UsageSummaryResponse, ScopeInfo, ErrorCodeInfo } from '../types.js';
3
3
  export declare class AdminResource {
4
4
  private http;
5
5
  constructor(http: AxiosInstance);
6
+ /**
7
+ * Every permission a key can be granted, and what each one covers.
8
+ *
9
+ * Read this before minting a key. The vocabulary was published nowhere, so the choice was made by
10
+ * guessing — and guessing wrong is asymmetric: under-grant and you get 403s, which are visible;
11
+ * over-grant, and the obvious answer to uncertainty is `*`, which hands a key that only needed to
12
+ * read a balance the ability to retire identities and publish price books.
13
+ *
14
+ * Needs no API key: choosing permissions should not require already holding one.
15
+ */
16
+ scopes(): Promise<{
17
+ scopes: ScopeInfo[];
18
+ }>;
19
+ /**
20
+ * Every error code this API can return, and what to do about each.
21
+ *
22
+ * Reads the catalogue from the LIVE gateway, which is the point: the SDK ships a vendored copy in
23
+ * `spec/errors.json`, but that copy is only as current as the release, and a gateway ahead of the
24
+ * SDK raises codes the vendored file has never heard of. Asking the deployment you are actually
25
+ * talking to is the only way to see those.
26
+ *
27
+ * `retryable` answers "will repeating this exact request eventually work?" — not "whose fault is
28
+ * it". A 503 from an unavailable rate oracle is retryable; a 402 is not, because retrying without
29
+ * paying changes nothing.
30
+ *
31
+ * Needs no API key: error handling should be buildable before you hold a credential.
32
+ */
33
+ errors(): Promise<{
34
+ errors: ErrorCodeInfo[];
35
+ }>;
6
36
  createOrg(params: CreateOrgParams): Promise<OrgResponse>;
7
37
  createApiKey(params: CreateApiKeyParams): Promise<ApiKeyResponse>;
8
38
  listApiKeys(): Promise<{
@@ -26,6 +56,27 @@ export declare class AdminResource {
26
56
  limit?: number;
27
57
  offset?: number;
28
58
  }): Promise<AuditLogResponse>;
59
+ /**
60
+ * Every audit-log entry matching the filters, a page at a time.
61
+ *
62
+ * ```ts
63
+ * for await (const { item, index, total } of certen.admin.auditLogAll({ from })) {
64
+ * process.stdout.write(`
65
+ ${index + 1} of ${total}`);
66
+ * }
67
+ * ```
68
+ *
69
+ * Yields `{ item, index, total }` rather than bare entries — unlike the other `listAll`s, because
70
+ * this endpoint DOES return a total and an audit export is the case where a caller genuinely
71
+ * needs it: these run long enough to want a progress line, and long enough that a silent early
72
+ * stop matters. Reading the full log by hand meant tracking the offset against
73
+ * `pagination.total`, which is the arithmetic this exists to stop people writing.
74
+ */
75
+ auditLogAll(params?: Omit<Parameters<AdminResource['getAuditLog']>[0], 'limit' | 'offset'>, pageSize?: number): AsyncIterableIterator<{
76
+ item: AuditLogEntry;
77
+ index: number;
78
+ total: number | undefined;
79
+ }>;
29
80
  getUsage(params?: {
30
81
  from?: string;
31
82
  to?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../../src/resources/admin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,KAAK,EACV,eAAe,EACf,WAAW,EACX,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACrB,MAAM,aAAa,CAAC;AAErB,qBAAa,aAAa;IACZ,OAAO,CAAC,IAAI;gBAAJ,IAAI,EAAE,aAAa;IAEjC,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;IASxD,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,cAAc,CAAC;IAWjE,WAAW,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,cAAc,EAAE,CAAA;KAAE,CAAC;IAKrD,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAK9E;;;;OAIG;IACG,YAAY,CAAC,EAAE,EAAE,MAAM,GA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;KAAE,CAAC;IAKrD,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAK9E;;;;OAIG;IACG,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAKjD,WAAW,CAAC,MAAM,CAAC,EAAE;QACzB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,EAAE,CAAC,EAAE,MAAM,CAAC;QACZ,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAc7B;;;;;;;;;;;;;;;OAeG;IACH,WAAW,CACT,MAAM,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC,EAC9E,QAAQ,SAAM,GACb,qBAAqB,CAAC;QAAE,IAAI,EAAE,aAAa,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE,CAAC;IAUrF,QAAQ,CAAC,MAAM,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC;CASvF"}
@@ -1,8 +1,41 @@
1
+ import { paginateWithTotal } from '../client.js';
1
2
  export class AdminResource {
2
3
  http;
3
4
  constructor(http) {
4
5
  this.http = http;
5
6
  }
7
+ /**
8
+ * Every permission a key can be granted, and what each one covers.
9
+ *
10
+ * Read this before minting a key. The vocabulary was published nowhere, so the choice was made by
11
+ * guessing — and guessing wrong is asymmetric: under-grant and you get 403s, which are visible;
12
+ * over-grant, and the obvious answer to uncertainty is `*`, which hands a key that only needed to
13
+ * read a balance the ability to retire identities and publish price books.
14
+ *
15
+ * Needs no API key: choosing permissions should not require already holding one.
16
+ */
17
+ async scopes() {
18
+ const { data } = await this.http.get('/v1/scopes');
19
+ return data;
20
+ }
21
+ /**
22
+ * Every error code this API can return, and what to do about each.
23
+ *
24
+ * Reads the catalogue from the LIVE gateway, which is the point: the SDK ships a vendored copy in
25
+ * `spec/errors.json`, but that copy is only as current as the release, and a gateway ahead of the
26
+ * SDK raises codes the vendored file has never heard of. Asking the deployment you are actually
27
+ * talking to is the only way to see those.
28
+ *
29
+ * `retryable` answers "will repeating this exact request eventually work?" — not "whose fault is
30
+ * it". A 503 from an unavailable rate oracle is retryable; a 402 is not, because retrying without
31
+ * paying changes nothing.
32
+ *
33
+ * Needs no API key: error handling should be buildable before you hold a credential.
34
+ */
35
+ async errors() {
36
+ const { data } = await this.http.get('/v1/errors');
37
+ return data;
38
+ }
6
39
  async createOrg(params) {
7
40
  const { data } = await this.http.post('/v1/admin/org', {
8
41
  name: params.name,
@@ -51,6 +84,28 @@ export class AdminResource {
51
84
  });
52
85
  return data;
53
86
  }
87
+ /**
88
+ * Every audit-log entry matching the filters, a page at a time.
89
+ *
90
+ * ```ts
91
+ * for await (const { item, index, total } of certen.admin.auditLogAll({ from })) {
92
+ * process.stdout.write(`
93
+ ${index + 1} of ${total}`);
94
+ * }
95
+ * ```
96
+ *
97
+ * Yields `{ item, index, total }` rather than bare entries — unlike the other `listAll`s, because
98
+ * this endpoint DOES return a total and an audit export is the case where a caller genuinely
99
+ * needs it: these run long enough to want a progress line, and long enough that a silent early
100
+ * stop matters. Reading the full log by hand meant tracking the offset against
101
+ * `pagination.total`, which is the arithmetic this exists to stop people writing.
102
+ */
103
+ auditLogAll(params, pageSize = 100) {
104
+ return paginateWithTotal(async (limit, offset) => {
105
+ const page = await this.getAuditLog({ ...params, limit, offset });
106
+ return { items: page.entries ?? [], total: page.pagination?.total };
107
+ }, pageSize);
108
+ }
54
109
  async getUsage(params) {
55
110
  const { data } = await this.http.get('/v1/admin/usage', {
56
111
  params: {
@@ -1 +1 @@
1
- {"version":3,"file":"admin.js","sourceRoot":"","sources":["../../src/resources/admin.ts"],"names":[],"mappings":"AAWA,MAAM,OAAO,aAAa;IACJ;IAApB,YAAoB,IAAmB;QAAnB,SAAI,GAAJ,IAAI,CAAe;IAAG,CAAC;IAE3C,KAAK,CAAC,SAAS,CAAC,MAAuB;QACrC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE;YACrD,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,WAAW,EAAE,MAAM,CAAC,UAAU;SAC/B,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,MAA0B;QAC3C,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE;YAC1D,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,MAAM,EAAE,MAAM,CAAC,KAAK;YACpB,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,cAAc,EAAE,MAAM,CAAC,YAAY;YACnC,UAAU,EAAE,MAAM,CAAC,SAAS;SAC7B,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,WAAW;QACf,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;QAC3D,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,EAAU;QAC3B,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,sBAAsB,EAAE,EAAE,CAAC,CAAC;QACpE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