@333eco/heartbank-api 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ @333eco/heartbank-api is offered under your choice of two licenses (SPDX: CC0-1.0 OR Apache-2.0):
2
+
3
+ - CC0 1.0 Universal (public domain dedication): see LICENSE-CC0
4
+ - Apache License 2.0: see LICENSE-APACHE
5
+
6
+ Pick whichever suits you; you need follow only the one you pick. Neither grants any right in the HeartBank® or other
7
+ trademarks, which are not licensed here.
package/LICENSE-APACHE ADDED
@@ -0,0 +1,73 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
10
+
11
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
12
+
13
+ "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
14
+
15
+ "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
16
+
17
+ "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
18
+
19
+ "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
20
+
21
+ "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
22
+
23
+ "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
24
+
25
+ "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
26
+
27
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
28
+
29
+ 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
30
+
31
+ 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
32
+
33
+ 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
34
+
35
+ (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
36
+
37
+ (b) You must cause any modified files to carry prominent notices stating that You changed the files; and
38
+
39
+ (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
40
+
41
+ (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
42
+
43
+ You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
44
+
45
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
46
+
47
+ 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
48
+
49
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
50
+
51
+ 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
52
+
53
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
54
+
55
+ END OF TERMS AND CONDITIONS
56
+
57
+ APPENDIX: How to apply the Apache License to your work.
58
+
59
+ To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
60
+
61
+ Copyright [yyyy] [name of copyright owner]
62
+
63
+ Licensed under the Apache License, Version 2.0 (the "License");
64
+ you may not use this file except in compliance with the License.
65
+ You may obtain a copy of the License at
66
+
67
+ http://www.apache.org/licenses/LICENSE-2.0
68
+
69
+ Unless required by applicable law or agreed to in writing, software
70
+ distributed under the License is distributed on an "AS IS" BASIS,
71
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
72
+ See the License for the specific language governing permissions and
73
+ limitations under the License.
package/LICENSE-CC0 ADDED
@@ -0,0 +1,121 @@
1
+ Creative Commons Legal Code
2
+
3
+ CC0 1.0 Universal
4
+
5
+ CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
6
+ LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
7
+ ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
8
+ INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
9
+ REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
10
+ PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
11
+ THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
12
+ HEREUNDER.
13
+
14
+ Statement of Purpose
15
+
16
+ The laws of most jurisdictions throughout the world automatically confer
17
+ exclusive Copyright and Related Rights (defined below) upon the creator
18
+ and subsequent owner(s) (each and all, an "owner") of an original work of
19
+ authorship and/or a database (each, a "Work").
20
+
21
+ Certain owners wish to permanently relinquish those rights to a Work for
22
+ the purpose of contributing to a commons of creative, cultural and
23
+ scientific works ("Commons") that the public can reliably and without fear
24
+ of later claims of infringement build upon, modify, incorporate in other
25
+ works, reuse and redistribute as freely as possible in any form whatsoever
26
+ and for any purposes, including without limitation commercial purposes.
27
+ These owners may contribute to the Commons to promote the ideal of a free
28
+ culture and the further production of creative, cultural and scientific
29
+ works, or to gain reputation or greater distribution for their Work in
30
+ part through the use and efforts of others.
31
+
32
+ For these and/or other purposes and motivations, and without any
33
+ expectation of additional consideration or compensation, the person
34
+ associating CC0 with a Work (the "Affirmer"), to the extent that he or she
35
+ is an owner of Copyright and Related Rights in the Work, voluntarily
36
+ elects to apply CC0 to the Work and publicly distribute the Work under its
37
+ terms, with knowledge of his or her Copyright and Related Rights in the
38
+ Work and the meaning and intended legal effect of CC0 on those rights.
39
+
40
+ 1. Copyright and Related Rights. A Work made available under CC0 may be
41
+ protected by copyright and related or neighboring rights ("Copyright and
42
+ Related Rights"). Copyright and Related Rights include, but are not
43
+ limited to, the following:
44
+
45
+ i. the right to reproduce, adapt, distribute, perform, display,
46
+ communicate, and translate a Work;
47
+ ii. moral rights retained by the original author(s) and/or performer(s);
48
+ iii. publicity and privacy rights pertaining to a person's image or
49
+ likeness depicted in a Work;
50
+ iv. rights protecting against unfair competition in regards to a Work,
51
+ subject to the limitations in paragraph 4(a), below;
52
+ v. rights protecting the extraction, dissemination, use and reuse of data
53
+ in a Work;
54
+ vi. database rights (such as those arising under Directive 96/9/EC of the
55
+ European Parliament and of the Council of 11 March 1996 on the legal
56
+ protection of databases, and under any national implementation
57
+ thereof, including any amended or successor version of such
58
+ directive); and
59
+ vii. other similar, equivalent or corresponding rights throughout the
60
+ world based on applicable law or treaty, and any national
61
+ implementations thereof.
62
+
63
+ 2. Waiver. To the greatest extent permitted by, but not in contravention
64
+ of, applicable law, Affirmer hereby overtly, fully, permanently,
65
+ irrevocably and unconditionally waives, abandons, and surrenders all of
66
+ Affirmer's Copyright and Related Rights and associated claims and causes
67
+ of action, whether now known or unknown (including existing as well as
68
+ future claims and causes of action), in the Work (i) in all territories
69
+ worldwide, (ii) for the maximum duration provided by applicable law or
70
+ treaty (including future time extensions), (iii) in any current or future
71
+ medium and for any number of copies, and (iv) for any purpose whatsoever,
72
+ including without limitation commercial, advertising or promotional
73
+ purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
74
+ member of the public at large and to the detriment of Affirmer's heirs and
75
+ successors, fully intending that such Waiver shall not be subject to
76
+ revocation, rescission, cancellation, termination, or any other legal or
77
+ equitable action to disrupt the quiet enjoyment of the Work by the public
78
+ as contemplated by Affirmer's express Statement of Purpose.
79
+
80
+ 3. Public License Fallback. Should any part of the Waiver for any reason
81
+ be judged legally invalid or ineffective under applicable law, then the
82
+ Waiver shall be preserved to the maximum extent permitted taking into
83
+ account Affirmer's express Statement of Purpose. In addition, to the
84
+ extent the Waiver is so judged Affirmer hereby grants to each affected
85
+ person a royalty-free, non transferable, non sublicensable, non exclusive,
86
+ irrevocable and unconditional license to exercise Affirmer's Copyright and
87
+ Related Rights in the Work (i) in all territories worldwide, (ii) for the
88
+ maximum duration provided by applicable law or treaty (including future
89
+ time extensions), (iii) in any current or future medium and for any number
90
+ of copies, and (iv) for any purpose whatsoever, including without
91
+ limitation commercial, advertising or promotional purposes (the
92
+ "License"). The License shall be deemed effective as of the date CC0 was
93
+ applied by Affirmer to the Work. Should any part of the License for any
94
+ reason be judged legally invalid or ineffective under applicable law, such
95
+ partial invalidity or ineffectiveness shall not invalidate the remainder
96
+ of the License, and in such case Affirmer hereby affirms that he or she
97
+ will not (i) exercise any of his or her remaining Copyright and Related
98
+ Rights in the Work or (ii) assert any associated claims and causes of
99
+ action with respect to the Work, in either case contrary to Affirmer's
100
+ express Statement of Purpose.
101
+
102
+ 4. Limitations and Disclaimers.
103
+
104
+ a. No trademark or patent rights held by Affirmer are waived, abandoned,
105
+ surrendered, licensed or otherwise affected by this document.
106
+ b. Affirmer offers the Work as-is and makes no representations or
107
+ warranties of any kind concerning the Work, express, implied,
108
+ statutory or otherwise, including without limitation warranties of
109
+ title, merchantability, fitness for a particular purpose, non
110
+ infringement, or the absence of latent or other defects, accuracy, or
111
+ the present or absence of errors, whether or not discoverable, all to
112
+ the greatest extent permissible under applicable law.
113
+ c. Affirmer disclaims responsibility for clearing rights of other persons
114
+ that may apply to the Work or any use thereof, including without
115
+ limitation any person's Copyright and Related Rights in the Work.
116
+ Further, Affirmer disclaims responsibility for obtaining any necessary
117
+ consents, permissions or other rights required for any use of the
118
+ Work.
119
+ d. Affirmer understands and acknowledges that Creative Commons is not a
120
+ party to this document and has no duty or obligation with respect to
121
+ this CC0 or use of the Work.
package/README.md CHANGED
@@ -1,3 +1,53 @@
1
- # Temporary Holding Version
1
+ # @333eco/heartbank-api
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The typed client for every HeartBank® API: **Log in with HeartBank®**, **Sign with HeartBank®**, **Thank with HeartBank®**, **Lookup** and **Verify**. Generated from the APIs' own OpenAPI descriptions, so it cannot drift from them.
4
+
5
+ ```sh
6
+ npm install @333eco/heartbank-api
7
+ ```
8
+
9
+ **It is for your server, and it never holds a key.** Your server signs; the client asks it to. A key inside an app is not a secret, so never ship one there.
10
+
11
+ ## Read the public logs (free, no account)
12
+
13
+ ```js
14
+ import { VerifyClient, LookupClient } from "@333eco/heartbank-api";
15
+
16
+ const verify = new VerifyClient();
17
+ const checkpoint = await verify.checkpoint({ log: "ledger" }); // the signed checkpoint, as text
18
+ const proof = await verify.zeroSumProof({ from: 0, to: 512 }); // the zero-sum proof for those entries
19
+
20
+ const name = await new LookupClient().byName({ name: "@thon" }); // what that person's public page shows
21
+ ```
22
+
23
+ A name nobody holds, a name held with no page, and a name let go all answer the same `404 not_found`. Lookup never returns an identity, never the other way round, and never a list.
24
+
25
+ ## Calls that need your app's key
26
+
27
+ Pass functions, never keys:
28
+
29
+ ```js
30
+ import { ThankClient, LoginClient, ApiError } from "@333eco/heartbank-api";
31
+
32
+ const thank = new ThankClient({
33
+ assertion: async (aud) => signClientAssertion(aud), // a fresh ES256 JWT: iss = sub = your client id, aud as given, one-use jti
34
+ });
35
+ const ticket = await thank.prepare({ body: { ref, pidToken, sub, ledger: "kiitos", to } });
36
+ if ("ticket" in ticket) {
37
+ // send the person to https://sign.333.eco/press with the ticket; they press their own passkey
38
+ }
39
+ ```
40
+
41
+ - **An agent can do everything except the press.** Every thank and every signature needs the person's own passkey.
42
+ - **A refusal from Thank says nothing**: `{ written: false }`, with no reason and no count. It protects the people involved; it is not a bug.
43
+ - Log in authenticates; Sign attests. A log-in session can never sign.
44
+ - The browser steps are links the client builds, never calls: `LoginClient#authorizeUrl`, `LoginClient#logOutUrl`, `SignClient#signPageUrl`.
45
+ - Any answer outside 2xx throws an `ApiError` with the service's own `error` and `why`.
46
+
47
+ ## Docs
48
+
49
+ The full docs open at developers.333.eco. Until then, this README and the types are the docs; every method links the page it will live on.
50
+
51
+ ## License
52
+
53
+ Your choice of **CC0-1.0** or **Apache-2.0** (see `LICENSE`). Neither grants any right in the HeartBank® or other trademarks.
@@ -0,0 +1,11 @@
1
+ export { ApiError, type ClientOptions } from "./runtime.js";
2
+ export { LoginClient } from "./login.js";
3
+ export * as login from "./login.js";
4
+ export { SignClient } from "./sign.js";
5
+ export * as sign from "./sign.js";
6
+ export { ThankClient } from "./thank.js";
7
+ export * as thank from "./thank.js";
8
+ export { LookupClient } from "./lookup.js";
9
+ export * as lookup from "./lookup.js";
10
+ export { VerifyClient } from "./verify.js";
11
+ export * as verify from "./verify.js";
package/dist/index.js ADDED
@@ -0,0 +1,12 @@
1
+ // Generated by scripts/gen-client.mjs. ⛔ Do not edit.
2
+ export { ApiError } from "./runtime.js";
3
+ export { LoginClient } from "./login.js";
4
+ export * as login from "./login.js";
5
+ export { SignClient } from "./sign.js";
6
+ export * as sign from "./sign.js";
7
+ export { ThankClient } from "./thank.js";
8
+ export * as thank from "./thank.js";
9
+ export { LookupClient } from "./lookup.js";
10
+ export * as lookup from "./lookup.js";
11
+ export { VerifyClient } from "./verify.js";
12
+ export * as verify from "./verify.js";
@@ -0,0 +1,113 @@
1
+ import { type ClientOptions } from "./runtime.js";
2
+ export type ErrorBody = {
3
+ error: string;
4
+ error_description?: string;
5
+ };
6
+ export type Claims = {
7
+ /** Pairwise: this person's ID in YOUR app only. */ sub?: string;
8
+ /** How they logged in, for example a passkey with the user verified. */ amr?: Array<string>;
9
+ locale?: "en" | "km";
10
+ /** Scope `poh`: the verified-human layers this person has, when they choose to show them. */ poh?: Array<string>;
11
+ poh_updated_at?: number;
12
+ /** Scope `ledger`: the person's token for Thank with HeartBank®, opaque to your app. */ pid_token?: string;
13
+ };
14
+ /** Log in with HeartBank®: Prove who someone is, with a passkey. OpenID Connect on the FAPI 2.0 profile. */
15
+ export declare class LoginClient {
16
+ private readonly o;
17
+ constructor(o?: ClientOptions);
18
+ /** The discovery document: every endpoint, scope and algorithm. @see https://developers.333.eco/log-in#discovery */
19
+ discovery(): Promise<Record<string, unknown>>;
20
+ /** The keys login signs ID tokens with. @see https://developers.333.eco/log-in#jwks */
21
+ jwks(): Promise<Record<string, unknown>>;
22
+ /** Push the log-in request (PAR, required). @see https://developers.333.eco/log-in#pushauthorizationrequest */
23
+ pushAuthorizationRequest(input: {
24
+ body: Omit<{
25
+ client_id: string;
26
+ client_assertion_type: string;
27
+ client_assertion: string;
28
+ response_type: "code";
29
+ /** `openid`, plus `poh` or `ledger` if your app was approved for them. */ scope: string;
30
+ redirect_uri: string;
31
+ state: string;
32
+ nonce: string;
33
+ code_challenge: string;
34
+ code_challenge_method: "S256";
35
+ max_age?: number;
36
+ ui_locales?: "en" | "km";
37
+ }, "client_assertion_type" | "client_assertion">;
38
+ }): Promise<{
39
+ request_uri: string;
40
+ expires_in: number;
41
+ }>;
42
+ /** Send the browser here (one tap from where the person is). @see https://developers.333.eco/log-in#authorize */
43
+ authorizeUrl(input: {
44
+ client_id: string;
45
+ request_uri: string;
46
+ }): string;
47
+ /** Exchange the code. @see https://developers.333.eco/log-in#token */
48
+ token(input: {
49
+ body: Omit<{
50
+ grant_type: "authorization_code";
51
+ code: string;
52
+ redirect_uri: string;
53
+ code_verifier: string;
54
+ client_assertion_type: string;
55
+ client_assertion: string;
56
+ }, "client_assertion_type" | "client_assertion">;
57
+ }): Promise<{
58
+ access_token: string;
59
+ token_type: "DPoP";
60
+ /** ES256; check `iss`, `aud`, `nonce`, `auth_time` (for a fresh log-in, on your server). */ id_token: string;
61
+ expires_in?: number;
62
+ }>;
63
+ /** The person's claims. @see https://developers.333.eco/log-in#userinfo */
64
+ userinfo(input: {
65
+ /** The access token from token(). */ accessToken: string;
66
+ }): Promise<Claims>;
67
+ /** Revoke a token. @see https://developers.333.eco/log-in#revoke */
68
+ revoke(input: {
69
+ body: {
70
+ token: string;
71
+ };
72
+ }): Promise<void>;
73
+ /** Log out of HeartBank® too. @see https://developers.333.eco/log-in#logout */
74
+ logOutUrl(input: {
75
+ client_id: string;
76
+ post_logout_redirect_uri: string;
77
+ }): string;
78
+ /** Is this browser logged in at HeartBank®? (display only). @see https://developers.333.eco/log-in#sessionstate */
79
+ sessionState(): Promise<{
80
+ loggedIn: boolean;
81
+ }>;
82
+ /** Announce a security change before making it. @see https://developers.333.eco/log-in#notice */
83
+ notice(input: {
84
+ body: Omit<{
85
+ client_assertion_type: string;
86
+ client_assertion: string;
87
+ sub: string;
88
+ /** `rails`: the person's ways to receive money changed. */ kind: "rails";
89
+ lang?: "en" | "km";
90
+ }, "client_assertion_type" | "client_assertion">;
91
+ }): Promise<{
92
+ ok?: true;
93
+ }>;
94
+ /** Read a person's verified-human layers again. @see https://developers.333.eco/log-in#verifiedhuman */
95
+ verifiedHuman(input: {
96
+ body: Omit<{
97
+ client_assertion_type: string;
98
+ client_assertion: string;
99
+ sub: string;
100
+ }, "client_assertion_type" | "client_assertion">;
101
+ }): Promise<{
102
+ poh?: Array<string>;
103
+ poh_updated_at: number;
104
+ }>;
105
+ /** Thank with HeartBank®: exchange a press for a pressToken. @see https://developers.333.eco/log-in#wrappress */
106
+ wrapPress(input: {
107
+ body: {
108
+ result: string;
109
+ };
110
+ }): Promise<{
111
+ pressToken: string;
112
+ }>;
113
+ }
package/dist/login.js ADDED
@@ -0,0 +1,165 @@
1
+ // Generated by scripts/gen-client.mjs from openapi/login.json. ⛔ Do not edit: change the description and run npm run client.
2
+ import { send, urlOf } from "./runtime.js";
3
+ /** Log in with HeartBank®: Prove who someone is, with a passkey. OpenID Connect on the FAPI 2.0 profile. */
4
+ export class LoginClient {
5
+ o;
6
+ constructor(o = {}) {
7
+ this.o = o;
8
+ }
9
+ /** The discovery document: every endpoint, scope and algorithm. @see https://developers.333.eco/log-in#discovery */
10
+ discovery() {
11
+ return send(this.o, {
12
+ method: "GET",
13
+ base: "https://login.333.eco",
14
+ path: "/.well-known/openid-configuration",
15
+ pathParams: undefined,
16
+ query: undefined,
17
+ headers: undefined,
18
+ security: "none",
19
+ accept: "json",
20
+ });
21
+ }
22
+ /** The keys login signs ID tokens with. @see https://developers.333.eco/log-in#jwks */
23
+ jwks() {
24
+ return send(this.o, {
25
+ method: "GET",
26
+ base: "https://login.333.eco",
27
+ path: "/.well-known/jwks.json",
28
+ pathParams: undefined,
29
+ query: undefined,
30
+ headers: undefined,
31
+ security: "none",
32
+ accept: "json",
33
+ });
34
+ }
35
+ /** Push the log-in request (PAR, required). @see https://developers.333.eco/log-in#pushauthorizationrequest */
36
+ pushAuthorizationRequest(input) {
37
+ return send(this.o, {
38
+ method: "POST",
39
+ base: "https://login.333.eco",
40
+ path: "/request",
41
+ pathParams: undefined,
42
+ query: undefined,
43
+ headers: undefined,
44
+ body: input.body,
45
+ contentType: "application/x-www-form-urlencoded",
46
+ security: "privateKeyJwt",
47
+ audience: "endpoint",
48
+ accept: "json",
49
+ });
50
+ }
51
+ /** Send the browser here (one tap from where the person is). @see https://developers.333.eco/log-in#authorize */
52
+ authorizeUrl(input) {
53
+ return urlOf(this.o.baseUrl ?? "https://login.333.eco", "/auth", undefined, { client_id: input.client_id, request_uri: input.request_uri });
54
+ }
55
+ /** Exchange the code. @see https://developers.333.eco/log-in#token */
56
+ token(input) {
57
+ return send(this.o, {
58
+ method: "POST",
59
+ base: "https://login.333.eco",
60
+ path: "/token",
61
+ pathParams: undefined,
62
+ query: undefined,
63
+ headers: undefined,
64
+ body: input.body,
65
+ contentType: "application/x-www-form-urlencoded",
66
+ security: "privateKeyJwt+dpop",
67
+ audience: "endpoint",
68
+ accept: "json",
69
+ });
70
+ }
71
+ /** The person's claims. @see https://developers.333.eco/log-in#userinfo */
72
+ userinfo(input) {
73
+ return send(this.o, {
74
+ method: "GET",
75
+ base: "https://login.333.eco",
76
+ path: "/me",
77
+ pathParams: undefined,
78
+ query: undefined,
79
+ headers: undefined,
80
+ security: "dpop",
81
+ accessToken: input.accessToken,
82
+ accept: "json",
83
+ });
84
+ }
85
+ /** Revoke a token. @see https://developers.333.eco/log-in#revoke */
86
+ revoke(input) {
87
+ return send(this.o, {
88
+ method: "POST",
89
+ base: "https://login.333.eco",
90
+ path: "/token/revocation",
91
+ pathParams: undefined,
92
+ query: undefined,
93
+ headers: undefined,
94
+ body: input.body,
95
+ contentType: "application/x-www-form-urlencoded",
96
+ security: "privateKeyJwt",
97
+ audience: "endpoint",
98
+ accept: "none",
99
+ });
100
+ }
101
+ /** Log out of HeartBank® too. @see https://developers.333.eco/log-in#logout */
102
+ logOutUrl(input) {
103
+ return urlOf(this.o.baseUrl ?? "https://login.333.eco", "/session/end", undefined, { client_id: input.client_id, post_logout_redirect_uri: input.post_logout_redirect_uri });
104
+ }
105
+ /** Is this browser logged in at HeartBank®? (display only). @see https://developers.333.eco/log-in#sessionstate */
106
+ sessionState() {
107
+ return send(this.o, {
108
+ method: "GET",
109
+ base: "https://login.333.eco",
110
+ path: "/session/state",
111
+ pathParams: undefined,
112
+ query: undefined,
113
+ headers: undefined,
114
+ security: "none",
115
+ accept: "json",
116
+ });
117
+ }
118
+ /** Announce a security change before making it. @see https://developers.333.eco/log-in#notice */
119
+ notice(input) {
120
+ return send(this.o, {
121
+ method: "POST",
122
+ base: "https://login.333.eco",
123
+ path: "/notice",
124
+ pathParams: undefined,
125
+ query: undefined,
126
+ headers: undefined,
127
+ body: input.body,
128
+ contentType: "application/x-www-form-urlencoded",
129
+ security: "privateKeyJwt",
130
+ audience: "endpoint",
131
+ accept: "json",
132
+ });
133
+ }
134
+ /** Read a person's verified-human layers again. @see https://developers.333.eco/log-in#verifiedhuman */
135
+ verifiedHuman(input) {
136
+ return send(this.o, {
137
+ method: "POST",
138
+ base: "https://login.333.eco",
139
+ path: "/poh",
140
+ pathParams: undefined,
141
+ query: undefined,
142
+ headers: undefined,
143
+ body: input.body,
144
+ contentType: "application/x-www-form-urlencoded",
145
+ security: "privateKeyJwt",
146
+ audience: "endpoint",
147
+ accept: "json",
148
+ });
149
+ }
150
+ /** Thank with HeartBank®: exchange a press for a pressToken. @see https://developers.333.eco/log-in#wrappress */
151
+ wrapPress(input) {
152
+ return send(this.o, {
153
+ method: "POST",
154
+ base: "https://login.333.eco",
155
+ path: "/press/wrap",
156
+ pathParams: undefined,
157
+ query: undefined,
158
+ headers: undefined,
159
+ body: input.body,
160
+ contentType: "application/x-www-form-urlencoded",
161
+ security: "none",
162
+ accept: "json",
163
+ });
164
+ }
165
+ }
@@ -0,0 +1,23 @@
1
+ import { type ClientOptions } from "./runtime.js";
2
+ export type Name = {
3
+ /** The name in the form its holder chose, with @ (for example @sokha.keo). */ name: string;
4
+ /** Their page. */ page: string;
5
+ /** What they are called, as they wrote it (any script). */ said: string;
6
+ /** Their one line, or empty. */ line: string;
7
+ /** Up to three https links they chose. */ links: Array<string>;
8
+ /** Their photo's address, or null. */ photo: string | null;
9
+ /** Their own recording of their name, or null. */ voice: string | null;
10
+ /** Whether they let search engines list their page. */ searchable: boolean;
11
+ };
12
+ export type ErrorBody = {
13
+ error: string;
14
+ };
15
+ /** Lookup: One exact name on B-Registry℠, and what that person's public page shows. Free, with no key. */
16
+ export declare class LookupClient {
17
+ private readonly o;
18
+ constructor(o?: ClientOptions);
19
+ /** Look up one exact name. @see https://developers.333.eco/lookup#byname */
20
+ byName(input: {
21
+ /** The name, with or without @; the registry folds case and punctuation, so sokha.keo, SOKHA-KEO and sokhakeo are one name. */ name: string;
22
+ }): Promise<Name>;
23
+ }
package/dist/lookup.js ADDED
@@ -0,0 +1,22 @@
1
+ // Generated by scripts/gen-client.mjs from openapi/lookup.json. ⛔ Do not edit: change the description and run npm run client.
2
+ import { send } from "./runtime.js";
3
+ /** Lookup: One exact name on B-Registry℠, and what that person's public page shows. Free, with no key. */
4
+ export class LookupClient {
5
+ o;
6
+ constructor(o = {}) {
7
+ this.o = o;
8
+ }
9
+ /** Look up one exact name. @see https://developers.333.eco/lookup#byname */
10
+ byName(input) {
11
+ return send(this.o, {
12
+ method: "GET",
13
+ base: "https://333.eco",
14
+ path: "/api/v1/names/{name}",
15
+ pathParams: { name: input.name },
16
+ query: undefined,
17
+ headers: undefined,
18
+ security: "none",
19
+ accept: "json",
20
+ });
21
+ }
22
+ }
@@ -0,0 +1,46 @@
1
+ /**
2
+ * The runtime the generated clients share. It knows HOW to send a request and names no endpoint: every endpoint, field
3
+ * and type comes from openapi/ through scripts/gen-client.mjs (SPEC §7: no hand-written second copy).
4
+ *
5
+ * ⛔ The client never holds a key. Your server signs: `assertion(aud)` returns a fresh ES256 client assertion (one use,
6
+ * at most five minutes old) and `dpop(method, url, accessToken?)` a DPoP proof. A key inside an app is not a secret, so
7
+ * this client is for your SERVER; the browser steps (log in, log out, the signing page) are links it builds for you.
8
+ */
9
+ export interface ClientOptions {
10
+ /** Replaces the server named in the description (for a test double; the sandbox when it exists). */
11
+ baseUrl?: string;
12
+ fetch?: typeof globalThis.fetch;
13
+ /** A fresh client assertion whose `aud` is the given address (private_key_jwt). */
14
+ assertion?: (aud: string) => Promise<string>;
15
+ /** A DPoP proof for this request; `accessToken` is given when the request carries one. */
16
+ dpop?: (method: string, url: string, accessToken?: string) => Promise<string>;
17
+ /** A B-Origin℠ API key (it begins `bo_live_`). ⛔ Keep it on your server. */
18
+ apiKey?: string;
19
+ }
20
+ /** Any answer outside 2xx. `error` and `why` are the service's own words; a refusal from Thank never reaches here (it is `{written: false}`). */
21
+ export declare class ApiError extends Error {
22
+ status: number;
23
+ error: string;
24
+ why?: string | undefined;
25
+ body?: unknown | undefined;
26
+ constructor(status: number, error: string, why?: string | undefined, body?: unknown | undefined);
27
+ }
28
+ export type Security = "none" | "clientAssertion" | "privateKeyJwt" | "dpop" | "privateKeyJwt+dpop" | "apiKey";
29
+ export interface Call {
30
+ method: string;
31
+ base: string;
32
+ path: string;
33
+ pathParams?: Record<string, string | number>;
34
+ query?: Record<string, string | number | undefined>;
35
+ headers?: Record<string, string | undefined>;
36
+ body?: unknown;
37
+ contentType?: string;
38
+ security: Security;
39
+ accessToken?: string;
40
+ /** The client assertion's `aud`: the server's address, or this endpoint's (each security scheme's `x-aud` says which). */
41
+ audience?: "server" | "endpoint";
42
+ /** What the success answer is: parsed JSON, text, or bytes. */
43
+ accept: "json" | "text" | "bytes" | "none";
44
+ }
45
+ export declare function urlOf(base: string, path: string, pathParams?: Record<string, string | number>, query?: Record<string, string | number | undefined>): string;
46
+ export declare function send<T>(o: ClientOptions, c: Call): Promise<T>;
@@ -0,0 +1,98 @@
1
+ /** Any answer outside 2xx. `error` and `why` are the service's own words; a refusal from Thank never reaches here (it is `{written: false}`). */
2
+ export class ApiError extends Error {
3
+ status;
4
+ error;
5
+ why;
6
+ body;
7
+ constructor(status, error, why, body) {
8
+ super(`${status} ${error}${why ? `: ${why}` : ""}`);
9
+ this.status = status;
10
+ this.error = error;
11
+ this.why = why;
12
+ this.body = body;
13
+ this.name = "ApiError";
14
+ }
15
+ }
16
+ const ASSERTION_TYPE = "urn:ietf:params:oauth:client-assertion-type:jwt-bearer";
17
+ export function urlOf(base, path, pathParams = {}, query = {}) {
18
+ const filled = path.replace(/\{(\w+)\}/g, (_, k) => {
19
+ if (pathParams[k] === undefined)
20
+ throw new TypeError(`missing path parameter ${k}`);
21
+ return encodeURIComponent(String(pathParams[k]));
22
+ });
23
+ const u = new URL(base.replace(/\/$/, "") + filled);
24
+ for (const [k, v] of Object.entries(query))
25
+ if (v !== undefined)
26
+ u.searchParams.set(k, String(v));
27
+ return u.toString();
28
+ }
29
+ export async function send(o, c) {
30
+ const f = o.fetch ?? globalThis.fetch;
31
+ const url = urlOf(o.baseUrl ?? c.base, c.path, c.pathParams, c.query);
32
+ // The address the service checks, never the test double's.
33
+ const aud = c.audience === "server" ? c.base.replace(/\/$/, "") : urlOf(c.base, c.path, c.pathParams);
34
+ const headers = {};
35
+ for (const [k, v] of Object.entries(c.headers ?? {}))
36
+ if (v !== undefined)
37
+ headers[k] = v;
38
+ let body;
39
+ let form;
40
+ if (c.contentType === "application/x-www-form-urlencoded")
41
+ form = { ...c.body };
42
+ if (c.security === "clientAssertion") {
43
+ if (!o.assertion)
44
+ throw new TypeError("this call needs options.assertion");
45
+ headers["x-client-assertion"] = await o.assertion(aud);
46
+ }
47
+ if (c.security === "privateKeyJwt" || c.security === "privateKeyJwt+dpop") {
48
+ if (!o.assertion)
49
+ throw new TypeError("this call needs options.assertion");
50
+ form = { ...form, client_assertion_type: ASSERTION_TYPE, client_assertion: await o.assertion(aud) };
51
+ }
52
+ if (c.security === "dpop" || c.security === "privateKeyJwt+dpop") {
53
+ if (!o.dpop)
54
+ throw new TypeError("this call needs options.dpop");
55
+ headers["DPoP"] = await o.dpop(c.method, aud, c.accessToken);
56
+ if (c.accessToken)
57
+ headers["Authorization"] = `DPoP ${c.accessToken}`;
58
+ }
59
+ if (c.security === "apiKey") {
60
+ if (!o.apiKey)
61
+ throw new TypeError("this call needs options.apiKey");
62
+ headers["Authorization"] = `Bearer ${o.apiKey}`;
63
+ }
64
+ if (form) {
65
+ const p = new URLSearchParams();
66
+ for (const [k, v] of Object.entries(form))
67
+ if (v !== undefined)
68
+ p.set(k, String(v));
69
+ body = p;
70
+ headers["Content-Type"] = "application/x-www-form-urlencoded";
71
+ }
72
+ else if (c.body !== undefined) {
73
+ if (c.contentType === "application/json") {
74
+ body = JSON.stringify(c.body);
75
+ headers["Content-Type"] = "application/json";
76
+ }
77
+ else {
78
+ body = c.body;
79
+ headers["Content-Type"] = c.contentType ?? "application/octet-stream";
80
+ }
81
+ }
82
+ const r = await f(url, { method: c.method, headers, body, redirect: "manual" });
83
+ if (r.status < 200 || r.status > 299) {
84
+ let j = null;
85
+ try {
86
+ j = await r.json();
87
+ }
88
+ catch { /* not JSON */ }
89
+ throw new ApiError(r.status, j?.error ?? (r.statusText || "error"), j?.why ?? j?.error_description, j);
90
+ }
91
+ if (c.accept === "none")
92
+ return undefined;
93
+ if (c.accept === "bytes")
94
+ return new Uint8Array(await r.arrayBuffer());
95
+ if (c.accept === "text")
96
+ return (await r.text());
97
+ return (await r.json());
98
+ }
package/dist/sign.d.ts ADDED
@@ -0,0 +1,68 @@
1
+ import { type ClientOptions } from "./runtime.js";
2
+ export type ErrorBody = {
3
+ error: string;
4
+ why?: string;
5
+ };
6
+ /** Built by `claimFor()` in the package; send it as built. It names the file by its fingerprints only. */
7
+ export type Claim = {
8
+ v: 2;
9
+ sha256: string;
10
+ pixels?: string;
11
+ phash?: string;
12
+ mime: string;
13
+ bytes: number;
14
+ /** An IPTC digital source type, for example `digitalCreation`. From the package, `sourceFromHistory({imports, mostly: 0.8})` works it out from what went into the work. */ source: string;
15
+ /** Your app's registered name. ⚠️ It goes into every record your app signs, permanently, so keep it short and plain. */ tool: string;
16
+ declared: boolean;
17
+ /** Optional, for example `CC0-1.0`. */ rights?: string;
18
+ imports?: Array<Record<string, unknown>>;
19
+ createdAtDeclared?: string;
20
+ };
21
+ export type RecordEntry = {
22
+ /** The record's number in the public log. */ index: number;
23
+ /** `similar` is a hint that two pictures look alike, nothing more. */ how: "exact" | "same pixels" | "similar";
24
+ distance?: number;
25
+ signedWith: "passkey";
26
+ at: string;
27
+ source: string;
28
+ declared: boolean;
29
+ rights?: string;
30
+ /** Present when the signer withdrew it: it stays in the log, marked as withdrawn by them. */ withdrawnAt?: string;
31
+ };
32
+ export type Trace = {
33
+ /** The file's SHA-256. */ fingerprint: string;
34
+ records: Array<RecordEntry>;
35
+ /** The file's C2PA manifest when present; `check.state` is `trusted` (signer on the C2PA trust list; it still says only what the signer declared), `valid` (signer not on the list, so anyone could have made it) or `invalid` (`failures` says why). */ c2pa?: Record<string, unknown>;
36
+ iptc?: Record<string, unknown>;
37
+ generators: Array<string>;
38
+ watermarks: Array<{
39
+ kind?: string;
40
+ model?: string;
41
+ agreement?: number;
42
+ }>;
43
+ /** B-Signal℠: the AI markers found in the file, recomputable from this same answer. ⛔ Never a measure of how human a work is, and never shown as a grade of someone's work (you agree to this when you make a key). */ signal: number;
44
+ /** What this answer did not look for, on every answer (SynthID has no public check). */ notChecked: Array<string>;
45
+ };
46
+ /** Sign with HeartBank®: Let the people who use your app sign what they made, and let anyone check it. B-Origin℠. */
47
+ export declare class SignClient {
48
+ private readonly o;
49
+ constructor(o?: ClientOptions);
50
+ /** Look up what a file carries (B-Trace℠, metered). @see https://developers.333.eco/sign#trace */
51
+ trace(input: {
52
+ body: Uint8Array | ArrayBuffer | Blob;
53
+ }): Promise<Trace>;
54
+ /** Ask a person to sign a file (from your web page). @see https://developers.333.eco/sign#requestsign */
55
+ requestSign(input: {
56
+ body: {
57
+ claim: Claim;
58
+ state?: string;
59
+ };
60
+ }): Promise<{
61
+ request_uri: string;
62
+ expires_in: number;
63
+ }>;
64
+ /** The page where the person signs. @see https://developers.333.eco/sign#signpage */
65
+ signPageUrl(input: {
66
+ request_uri: string;
67
+ }): string;
68
+ }
package/dist/sign.js ADDED
@@ -0,0 +1,43 @@
1
+ // Generated by scripts/gen-client.mjs from openapi/sign.json. ⛔ Do not edit: change the description and run npm run client.
2
+ import { send, urlOf } from "./runtime.js";
3
+ /** Sign with HeartBank®: Let the people who use your app sign what they made, and let anyone check it. B-Origin℠. */
4
+ export class SignClient {
5
+ o;
6
+ constructor(o = {}) {
7
+ this.o = o;
8
+ }
9
+ /** Look up what a file carries (B-Trace℠, metered). @see https://developers.333.eco/sign#trace */
10
+ trace(input) {
11
+ return send(this.o, {
12
+ method: "POST",
13
+ base: "https://origin.333.eco",
14
+ path: "/api/v1/trace",
15
+ pathParams: undefined,
16
+ query: undefined,
17
+ headers: undefined,
18
+ body: input.body,
19
+ contentType: "application/octet-stream",
20
+ security: "apiKey",
21
+ accept: "json",
22
+ });
23
+ }
24
+ /** Ask a person to sign a file (from your web page). @see https://developers.333.eco/sign#requestsign */
25
+ requestSign(input) {
26
+ return send(this.o, {
27
+ method: "POST",
28
+ base: "https://sign.333.eco",
29
+ path: "/sign/par",
30
+ pathParams: undefined,
31
+ query: undefined,
32
+ headers: undefined,
33
+ body: input.body,
34
+ contentType: "application/json",
35
+ security: "none",
36
+ accept: "json",
37
+ });
38
+ }
39
+ /** The page where the person signs. @see https://developers.333.eco/sign#signpage */
40
+ signPageUrl(input) {
41
+ return urlOf(this.o.baseUrl ?? "https://sign.333.eco", "/sign", undefined, { request_uri: input.request_uri });
42
+ }
43
+ }
@@ -0,0 +1,89 @@
1
+ import { type ClientOptions } from "./runtime.js";
2
+ /** The ledger declined, or there is no season open. ⛔ No reason and no count, by design. */
3
+ export type NotWritten = {
4
+ written: false;
5
+ };
6
+ export type Prepared = {
7
+ /** Send back unchanged at commit. */ pending: string;
8
+ /** Signed by the ledger with the challenge and a description of what is being signed (ledger, units, season, to, and for Kiitti the direction and kind); sign.333.eco shows the person that description before they press. */ ticket: string;
9
+ };
10
+ export type Written = {
11
+ written: true;
12
+ /** ⛔ Only the entry's id reaches your app (threat T16: an index or a signature would count other apps' thanks). The full receipt goes to the two people, in their own records. */ receipt: {
13
+ id: string;
14
+ };
15
+ /** One-use tokens, one per side, to place that side on the public map later with /v1/place. A token knows neither the person nor the entry. */ place?: {
16
+ from?: string;
17
+ to?: string;
18
+ };
19
+ };
20
+ /** ⏳ Outside apps will name the receiver by registry handle instead, never another person's token (A591 (3)). */
21
+ export type Person = {
22
+ /** From the person's log-in at login.333.eco (scope `ledger`). */ pidToken: string;
23
+ sub: string;
24
+ };
25
+ export type PrepareKiitos = {
26
+ /** Your id for this thank. The same ref returns the same answer and writes once. */ ref: string;
27
+ pidToken: string;
28
+ sub: string;
29
+ ledger: "kiitos";
30
+ to: Person;
31
+ /** Optional: exactly 32 bytes of your own, committed with a salt (never stored as sent); it reaches the two people in their records. */ cargo?: string;
32
+ };
33
+ /** First-party only (B-Twin, thank.333.eco): care for a thing, plant or animal, decided by the ledger's public rule on witnessed evidence. ⛔ Never an outside app: from season 2 an outside app's Kiitti is only a person's thanks to all of life, a call with no direction, twin or evidence field (directive #94). */
34
+ export type PrepareKiitti = {
35
+ ref: string;
36
+ pidToken: string;
37
+ sub: string;
38
+ ledger: "kiitti";
39
+ dir: "kind" | "thankful";
40
+ evidence: {
41
+ kind: "thing" | "plant" | "animal";
42
+ twinId: string;
43
+ attested: boolean;
44
+ match?: number;
45
+ };
46
+ };
47
+ export type ErrorBody = {
48
+ error: string;
49
+ };
50
+ export type Ring = {
51
+ /** The ring's color. */ color: string;
52
+ /** The ring's width, drawn as a ring: ⛔ never shown as a number to chase. */ ring: number;
53
+ };
54
+ /** Thank with HeartBank®: Record a thank on the gratitude ledger. Your app prepares it, the person presses their own passkey, your app commits it. */
55
+ export declare class ThankClient {
56
+ private readonly o;
57
+ constructor(o?: ClientOptions);
58
+ /** Step 1: prepare a thank. @see https://developers.333.eco/thank#prepare */
59
+ prepare(input: {
60
+ body: PrepareKiitos | PrepareKiitti;
61
+ }): Promise<Prepared | NotWritten>;
62
+ /** Step 3: commit the pressed thank. @see https://developers.333.eco/thank#commit */
63
+ commit(input: {
64
+ body: {
65
+ ref: string;
66
+ pending: string;
67
+ /** From POST https://login.333.eco/press/wrap. */ pressToken: string;
68
+ };
69
+ }): Promise<Written | NotWritten>;
70
+ /** Place one side of a written thank on the public map. @see https://developers.333.eco/thank#place */
71
+ place(input: {
72
+ body: {
73
+ token: string;
74
+ /** An area about 100 km across (0.9° bands), from the ledger's open cell function. */ cell: number;
75
+ };
76
+ }): Promise<{
77
+ placed: boolean;
78
+ }>;
79
+ /** Read a person's ring. @see https://developers.333.eco/thank#ring */
80
+ ring(input: {
81
+ sub: string;
82
+ "x-pid-token": string;
83
+ }): Promise<{
84
+ kiitos?: Ring;
85
+ kiitti?: Ring;
86
+ }>;
87
+ /** Retired: a thank without a press (retired). @see https://developers.333.eco/thank#submit */
88
+ submit(): Promise<void>;
89
+ }
package/dist/thank.js ADDED
@@ -0,0 +1,85 @@
1
+ // Generated by scripts/gen-client.mjs from openapi/thank.json. ⛔ Do not edit: change the description and run npm run client.
2
+ import { send } from "./runtime.js";
3
+ /** Thank with HeartBank®: Record a thank on the gratitude ledger. Your app prepares it, the person presses their own passkey, your app commits it. */
4
+ export class ThankClient {
5
+ o;
6
+ constructor(o = {}) {
7
+ this.o = o;
8
+ }
9
+ /** Step 1: prepare a thank. @see https://developers.333.eco/thank#prepare */
10
+ prepare(input) {
11
+ return send(this.o, {
12
+ method: "POST",
13
+ base: "https://ledger.heartbank.net",
14
+ path: "/v1/prepare",
15
+ pathParams: undefined,
16
+ query: undefined,
17
+ headers: undefined,
18
+ body: input.body,
19
+ contentType: "application/json",
20
+ security: "clientAssertion",
21
+ audience: "server",
22
+ accept: "json",
23
+ });
24
+ }
25
+ /** Step 3: commit the pressed thank. @see https://developers.333.eco/thank#commit */
26
+ commit(input) {
27
+ return send(this.o, {
28
+ method: "POST",
29
+ base: "https://ledger.heartbank.net",
30
+ path: "/v1/commit",
31
+ pathParams: undefined,
32
+ query: undefined,
33
+ headers: undefined,
34
+ body: input.body,
35
+ contentType: "application/json",
36
+ security: "clientAssertion",
37
+ audience: "server",
38
+ accept: "json",
39
+ });
40
+ }
41
+ /** Place one side of a written thank on the public map. @see https://developers.333.eco/thank#place */
42
+ place(input) {
43
+ return send(this.o, {
44
+ method: "POST",
45
+ base: "https://ledger.heartbank.net",
46
+ path: "/v1/place",
47
+ pathParams: undefined,
48
+ query: undefined,
49
+ headers: undefined,
50
+ body: input.body,
51
+ contentType: "application/json",
52
+ security: "clientAssertion",
53
+ audience: "server",
54
+ accept: "json",
55
+ });
56
+ }
57
+ /** Read a person's ring. @see https://developers.333.eco/thank#ring */
58
+ ring(input) {
59
+ return send(this.o, {
60
+ method: "GET",
61
+ base: "https://ledger.heartbank.net",
62
+ path: "/v1/aura",
63
+ pathParams: undefined,
64
+ query: { sub: input.sub },
65
+ headers: { "x-pid-token": input["x-pid-token"] },
66
+ security: "clientAssertion",
67
+ audience: "server",
68
+ accept: "json",
69
+ });
70
+ }
71
+ /** Retired: a thank without a press (retired). @see https://developers.333.eco/thank#submit */
72
+ submit() {
73
+ return send(this.o, {
74
+ method: "POST",
75
+ base: "https://ledger.heartbank.net",
76
+ path: "/v1/submit",
77
+ pathParams: undefined,
78
+ query: undefined,
79
+ headers: undefined,
80
+ security: "clientAssertion",
81
+ audience: "server",
82
+ accept: "none",
83
+ });
84
+ }
85
+ }
@@ -0,0 +1,58 @@
1
+ import { type ClientOptions } from "./runtime.js";
2
+ /** Verify: Check anything we say, from the public logs, free forever, with no account and no key. */
3
+ export declare class VerifyClient {
4
+ private readonly o;
5
+ constructor(o?: ClientOptions);
6
+ /** The latest signed checkpoint: the log's size and root. @see https://developers.333.eco/verify#checkpoint */
7
+ checkpoint(input?: {
8
+ log?: "origin" | "ledger";
9
+ }): Promise<string>;
10
+ /** Every earlier checkpoint, locked (written once, never replaced). @see https://developers.333.eco/verify#checkpointat */
11
+ checkpointAt(input: {
12
+ log?: "origin" | "ledger";
13
+ size: number;
14
+ }): Promise<string>;
15
+ /** A tile of the Merkle tree. @see https://developers.333.eco/verify#tile */
16
+ tile(input: {
17
+ log?: "origin" | "ledger";
18
+ level: number;
19
+ index: string;
20
+ }): Promise<Uint8Array>;
21
+ /** A bundle of the log's entries. @see https://developers.333.eco/verify#entries */
22
+ entries(input: {
23
+ log?: "origin" | "ledger";
24
+ index: string;
25
+ }): Promise<Uint8Array>;
26
+ /** Which checkpoints carry which clock. @see https://developers.333.eco/verify#stampsindex */
27
+ stampsIndex(input?: {
28
+ log?: "origin" | "ledger";
29
+ }): Promise<{
30
+ tsa: Array<number>;
31
+ ots: Array<number>;
32
+ }>;
33
+ /** A timestamp authority's token (RFC 3161) over a checkpoint. @see https://developers.333.eco/verify#timestamptoken */
34
+ timestampToken(input: {
35
+ log?: "origin" | "ledger";
36
+ size: number;
37
+ authority: "aped-gr" | "accv-es" | "freetsa-de";
38
+ }): Promise<Uint8Array>;
39
+ /** An OpenTimestamps proof over a checkpoint, reaching Bitcoin. @see https://developers.333.eco/verify#bitcoinproof */
40
+ bitcoinProof(input: {
41
+ log?: "origin" | "ledger";
42
+ size: number;
43
+ }): Promise<Uint8Array>;
44
+ /** The ledger only: the zero-sum proof over entries from…to. @see https://developers.333.eco/verify#zerosumproof */
45
+ zeroSumProof(input: {
46
+ from: number;
47
+ to: number;
48
+ }): Promise<{
49
+ v: number;
50
+ from: number;
51
+ to: number;
52
+ genesis: string;
53
+ origin?: string;
54
+ circuit: string;
55
+ K: number;
56
+ windows: Array<Record<string, unknown>>;
57
+ }>;
58
+ }
package/dist/verify.js ADDED
@@ -0,0 +1,113 @@
1
+ // Generated by scripts/gen-client.mjs from openapi/verify.json. ⛔ Do not edit: change the description and run npm run client.
2
+ import { send } from "./runtime.js";
3
+ /** Verify: Check anything we say, from the public logs, free forever, with no account and no key. */
4
+ export class VerifyClient {
5
+ o;
6
+ constructor(o = {}) {
7
+ this.o = o;
8
+ }
9
+ /** The latest signed checkpoint: the log's size and root. @see https://developers.333.eco/verify#checkpoint */
10
+ checkpoint(input) {
11
+ return send(this.o, {
12
+ method: "GET",
13
+ base: "https://log.333.eco/{log}".replace(/\{(\w+)\}/g, (_, k) => String({ log: input?.log ?? "origin" }[k])),
14
+ path: "/checkpoint",
15
+ pathParams: undefined,
16
+ query: undefined,
17
+ headers: undefined,
18
+ security: "none",
19
+ accept: "text",
20
+ });
21
+ }
22
+ /** Every earlier checkpoint, locked (written once, never replaced). @see https://developers.333.eco/verify#checkpointat */
23
+ checkpointAt(input) {
24
+ return send(this.o, {
25
+ method: "GET",
26
+ base: "https://log.333.eco/{log}".replace(/\{(\w+)\}/g, (_, k) => String({ log: input?.log ?? "origin" }[k])),
27
+ path: "/checkpoints/{size}",
28
+ pathParams: { size: input.size },
29
+ query: undefined,
30
+ headers: undefined,
31
+ security: "none",
32
+ accept: "text",
33
+ });
34
+ }
35
+ /** A tile of the Merkle tree. @see https://developers.333.eco/verify#tile */
36
+ tile(input) {
37
+ return send(this.o, {
38
+ method: "GET",
39
+ base: "https://log.333.eco/{log}".replace(/\{(\w+)\}/g, (_, k) => String({ log: input?.log ?? "origin" }[k])),
40
+ path: "/tile/{level}/{index}",
41
+ pathParams: { level: input.level, index: input.index },
42
+ query: undefined,
43
+ headers: undefined,
44
+ security: "none",
45
+ accept: "bytes",
46
+ });
47
+ }
48
+ /** A bundle of the log's entries. @see https://developers.333.eco/verify#entries */
49
+ entries(input) {
50
+ return send(this.o, {
51
+ method: "GET",
52
+ base: "https://log.333.eco/{log}".replace(/\{(\w+)\}/g, (_, k) => String({ log: input?.log ?? "origin" }[k])),
53
+ path: "/tile/entries/{index}",
54
+ pathParams: { index: input.index },
55
+ query: undefined,
56
+ headers: undefined,
57
+ security: "none",
58
+ accept: "bytes",
59
+ });
60
+ }
61
+ /** Which checkpoints carry which clock. @see https://developers.333.eco/verify#stampsindex */
62
+ stampsIndex(input) {
63
+ return send(this.o, {
64
+ method: "GET",
65
+ base: "https://log.333.eco/{log}".replace(/\{(\w+)\}/g, (_, k) => String({ log: input?.log ?? "origin" }[k])),
66
+ path: "/stamps/index.json",
67
+ pathParams: undefined,
68
+ query: undefined,
69
+ headers: undefined,
70
+ security: "none",
71
+ accept: "json",
72
+ });
73
+ }
74
+ /** A timestamp authority's token (RFC 3161) over a checkpoint. @see https://developers.333.eco/verify#timestamptoken */
75
+ timestampToken(input) {
76
+ return send(this.o, {
77
+ method: "GET",
78
+ base: "https://log.333.eco/{log}".replace(/\{(\w+)\}/g, (_, k) => String({ log: input?.log ?? "origin" }[k])),
79
+ path: "/stamps/{size}.{authority}.tsr",
80
+ pathParams: { size: input.size, authority: input.authority },
81
+ query: undefined,
82
+ headers: undefined,
83
+ security: "none",
84
+ accept: "bytes",
85
+ });
86
+ }
87
+ /** An OpenTimestamps proof over a checkpoint, reaching Bitcoin. @see https://developers.333.eco/verify#bitcoinproof */
88
+ bitcoinProof(input) {
89
+ return send(this.o, {
90
+ method: "GET",
91
+ base: "https://log.333.eco/{log}".replace(/\{(\w+)\}/g, (_, k) => String({ log: input?.log ?? "origin" }[k])),
92
+ path: "/stamps/{size}.ots",
93
+ pathParams: { size: input.size },
94
+ query: undefined,
95
+ headers: undefined,
96
+ security: "none",
97
+ accept: "bytes",
98
+ });
99
+ }
100
+ /** The ledger only: the zero-sum proof over entries from…to. @see https://developers.333.eco/verify#zerosumproof */
101
+ zeroSumProof(input) {
102
+ return send(this.o, {
103
+ method: "GET",
104
+ base: "https://log.333.eco/ledger",
105
+ path: "/proof/{from}-{to}.json",
106
+ pathParams: { from: input.from, to: input.to },
107
+ query: undefined,
108
+ headers: undefined,
109
+ security: "none",
110
+ accept: "json",
111
+ });
112
+ }
113
+ }
package/package.json CHANGED
@@ -1,6 +1,28 @@
1
1
  {
2
2
  "name": "@333eco/heartbank-api",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "The typed client for every HeartBank® API (Log in, Sign and Thank with HeartBank®, and Verify), generated from developers.333.eco's OpenAPI descriptions. For your server: it never holds a key.",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "files": [
9
+ "dist",
10
+ "README.md",
11
+ "LICENSE",
12
+ "LICENSE-CC0",
13
+ "LICENSE-APACHE"
14
+ ],
15
+ "x-publishing": "Name and license approved by the founder 2026-11-11 (\"CC0-1.0 OR Apache-2.0\": each user picks one). The first publish: approved the same day.",
16
+ "license": "CC0-1.0 OR Apache-2.0",
17
+ "engines": {
18
+ "node": ">=18"
19
+ },
20
+ "homepage": "https://developers.333.eco",
21
+ "keywords": [
22
+ "heartbank",
23
+ "passkey",
24
+ "openid-connect",
25
+ "provenance",
26
+ "gratitude"
27
+ ]
28
+ }