@333eco/heartbank-api 0.0.0-stage → 0.2.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 +7 -0
- package/LICENSE-APACHE +73 -0
- package/LICENSE-CC0 +121 -0
- package/README.md +72 -2
- package/dist/confirm.d.ts +43 -0
- package/dist/confirm.js +45 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +14 -0
- package/dist/login.d.ts +113 -0
- package/dist/login.js +165 -0
- package/dist/lookup.d.ts +23 -0
- package/dist/lookup.js +22 -0
- package/dist/runtime.d.ts +46 -0
- package/dist/runtime.js +98 -0
- package/dist/sign.d.ts +68 -0
- package/dist/sign.js +43 -0
- package/dist/thank.d.ts +89 -0
- package/dist/thank.js +85 -0
- package/dist/verify.d.ts +58 -0
- package/dist/verify.js +113 -0
- package/package.json +26 -4
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,73 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @333eco/heartbank-api
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The typed client for every HeartBank® API: **Log in with HeartBank®**, **Sign with HeartBank®**, **Confirm 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
|
+
## A human in the loop: Confirm with HeartBank®
|
|
48
|
+
|
|
49
|
+
A person's own passkey press for one action your app names, so you know a person, not a script, did it. They must have logged in to your app with Log in with HeartBank®; `sub` is your app's own ID for them.
|
|
50
|
+
|
|
51
|
+
```js
|
|
52
|
+
import { ConfirmClient } from "@333eco/heartbank-api";
|
|
53
|
+
|
|
54
|
+
const confirm = new ConfirmClient({ assertion: async (aud) => signClientAssertion(aud) });
|
|
55
|
+
|
|
56
|
+
// 1. On upload: your server asks. `hash` is the file's SHA-256, `return_to` one of your registered redirect URLs.
|
|
57
|
+
const { ticket, url } = await confirm.request({ body: { sub, kind: "upload", hash, return_to: "https://yourapp.example/cb" } });
|
|
58
|
+
// 2. Send the person's browser there, with the ticket in the FRAGMENT:
|
|
59
|
+
const go = `${url}#${new URLSearchParams({ ticket, state })}`;
|
|
60
|
+
// 3. They come back with #confirm=<result>&state=… (or #declined=1&state=…). Your server redeems it, once:
|
|
61
|
+
const done = await confirm.redeem({ body: { result } });
|
|
62
|
+
if (done.sub !== sub || done.hash !== hash) throw new Error("not this person, or not this file");
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
It proves presence, not personhood: never call a confirmed person "verified". For a file someone puts their name to, in public and for good, use Sign with HeartBank®.
|
|
66
|
+
|
|
67
|
+
## Docs
|
|
68
|
+
|
|
69
|
+
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.
|
|
70
|
+
|
|
71
|
+
## License
|
|
72
|
+
|
|
73
|
+
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,43 @@
|
|
|
1
|
+
import { type ClientOptions } from "./runtime.js";
|
|
2
|
+
export type ErrorBody = {
|
|
3
|
+
error: string;
|
|
4
|
+
why?: string;
|
|
5
|
+
};
|
|
6
|
+
export type Ticket = {
|
|
7
|
+
/** Opaque to your app; put it in the page's address fragment, never a query. */ ticket: string;
|
|
8
|
+
/** https://sign.333.eco/confirm */ url: string;
|
|
9
|
+
/** Seconds the ticket lasts (600). */ expires_in: number;
|
|
10
|
+
};
|
|
11
|
+
export type Confirmed = {
|
|
12
|
+
confirmed: true;
|
|
13
|
+
/** Your app's own sub for the person who pressed: check it is the person you asked about. */ sub: string;
|
|
14
|
+
kind: "upload";
|
|
15
|
+
/** The SHA-256 you asked about: check it is the file you hold. */ hash?: string;
|
|
16
|
+
/** When they pressed (seconds since 1970). */ at: number;
|
|
17
|
+
};
|
|
18
|
+
/** Confirm with HeartBank®: A person's own passkey press for one action your app names: a human in the loop, so you know a person, not a script, did it. */
|
|
19
|
+
export declare class ConfirmClient {
|
|
20
|
+
private readonly o;
|
|
21
|
+
constructor(o?: ClientOptions);
|
|
22
|
+
/** Step 1: ask a person to confirm one action. @see https://developers.333.eco/confirm#request */
|
|
23
|
+
request(input: {
|
|
24
|
+
body: Omit<{
|
|
25
|
+
client_assertion_type: string;
|
|
26
|
+
client_assertion: string;
|
|
27
|
+
/** Your app's own sub for the person, from their Log in with HeartBank® ID token. */ sub: string;
|
|
28
|
+
/** What they are confirming, from a closed list: the page says it in its own words. */ kind: "upload";
|
|
29
|
+
/** Optional: the SHA-256 of the thing (a file being uploaded), 64 lowercase hex. The page shows its first eight. */ hash?: string;
|
|
30
|
+
/** One of your app's registered redirect URLs. */ return_to: string;
|
|
31
|
+
}, "client_assertion_type" | "client_assertion">;
|
|
32
|
+
}): Promise<Ticket>;
|
|
33
|
+
/** Step 2: the page where the person presses. @see https://developers.333.eco/confirm#page */
|
|
34
|
+
pageUrl(): string;
|
|
35
|
+
/** Step 3: redeem the result, once. @see https://developers.333.eco/confirm#redeem */
|
|
36
|
+
redeem(input: {
|
|
37
|
+
body: Omit<{
|
|
38
|
+
client_assertion_type: string;
|
|
39
|
+
client_assertion: string;
|
|
40
|
+
/** The `confirm` value the browser brought back. */ result: string;
|
|
41
|
+
}, "client_assertion_type" | "client_assertion">;
|
|
42
|
+
}): Promise<Confirmed>;
|
|
43
|
+
}
|
package/dist/confirm.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// Generated by scripts/gen-client.mjs from openapi/confirm.json. ⛔ Do not edit: change the description and run npm run client.
|
|
2
|
+
import { send, urlOf } from "./runtime.js";
|
|
3
|
+
/** Confirm with HeartBank®: A person's own passkey press for one action your app names: a human in the loop, so you know a person, not a script, did it. */
|
|
4
|
+
export class ConfirmClient {
|
|
5
|
+
o;
|
|
6
|
+
constructor(o = {}) {
|
|
7
|
+
this.o = o;
|
|
8
|
+
}
|
|
9
|
+
/** Step 1: ask a person to confirm one action. @see https://developers.333.eco/confirm#request */
|
|
10
|
+
request(input) {
|
|
11
|
+
return send(this.o, {
|
|
12
|
+
method: "POST",
|
|
13
|
+
base: "https://login.333.eco",
|
|
14
|
+
path: "/confirm/request",
|
|
15
|
+
pathParams: undefined,
|
|
16
|
+
query: undefined,
|
|
17
|
+
headers: undefined,
|
|
18
|
+
body: input.body,
|
|
19
|
+
contentType: "application/x-www-form-urlencoded",
|
|
20
|
+
security: "privateKeyJwt",
|
|
21
|
+
audience: "endpoint",
|
|
22
|
+
accept: "json",
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
/** Step 2: the page where the person presses. @see https://developers.333.eco/confirm#page */
|
|
26
|
+
pageUrl() {
|
|
27
|
+
return urlOf(this.o.baseUrl ?? "https://sign.333.eco", "/confirm", undefined, undefined);
|
|
28
|
+
}
|
|
29
|
+
/** Step 3: redeem the result, once. @see https://developers.333.eco/confirm#redeem */
|
|
30
|
+
redeem(input) {
|
|
31
|
+
return send(this.o, {
|
|
32
|
+
method: "POST",
|
|
33
|
+
base: "https://login.333.eco",
|
|
34
|
+
path: "/confirm/redeem",
|
|
35
|
+
pathParams: undefined,
|
|
36
|
+
query: undefined,
|
|
37
|
+
headers: undefined,
|
|
38
|
+
body: input.body,
|
|
39
|
+
contentType: "application/x-www-form-urlencoded",
|
|
40
|
+
security: "privateKeyJwt",
|
|
41
|
+
audience: "endpoint",
|
|
42
|
+
accept: "json",
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
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 { ConfirmClient } from "./confirm.js";
|
|
7
|
+
export * as confirm from "./confirm.js";
|
|
8
|
+
export { ThankClient } from "./thank.js";
|
|
9
|
+
export * as thank from "./thank.js";
|
|
10
|
+
export { LookupClient } from "./lookup.js";
|
|
11
|
+
export * as lookup from "./lookup.js";
|
|
12
|
+
export { VerifyClient } from "./verify.js";
|
|
13
|
+
export * as verify from "./verify.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
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 { ConfirmClient } from "./confirm.js";
|
|
8
|
+
export * as confirm from "./confirm.js";
|
|
9
|
+
export { ThankClient } from "./thank.js";
|
|
10
|
+
export * as thank from "./thank.js";
|
|
11
|
+
export { LookupClient } from "./lookup.js";
|
|
12
|
+
export * as lookup from "./lookup.js";
|
|
13
|
+
export { VerifyClient } from "./verify.js";
|
|
14
|
+
export * as verify from "./verify.js";
|
package/dist/login.d.ts
ADDED
|
@@ -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
|
+
}
|