@keri-ts/wallet 0.0.0-stage → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +134 -2
- package/esm/package.json +3 -0
- package/esm/wallet/npm/src/mod.js +6 -0
- package/esm/wallet/npm/src/src/authoring.js +219 -0
- package/esm/wallet/npm/src/src/custody.js +137 -0
- package/esm/wallet/npm/src/src/disclosing.js +528 -0
- package/esm/wallet/npm/src/src/storing.js +60 -0
- package/esm/wallet/npm/src/src/wallet.js +251 -0
- package/package.json +42 -4
- package/types/mod.d.ts +7 -0
- package/types/mod.d.ts.map +1 -0
- package/types/src/authoring.d.ts +51 -0
- package/types/src/authoring.d.ts.map +1 -0
- package/types/src/custody.d.ts +53 -0
- package/types/src/custody.d.ts.map +1 -0
- package/types/src/disclosing.d.ts +109 -0
- package/types/src/disclosing.d.ts.map +1 -0
- package/types/src/storing.d.ts +56 -0
- package/types/src/storing.d.ts.map +1 -0
- package/types/src/wallet.d.ts +77 -0
- package/types/src/wallet.d.ts.map +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,135 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ACDC wallet inventory
|
|
2
2
|
|
|
3
|
-
This
|
|
3
|
+
This application package retains issued credential bytes and explicit consent to
|
|
4
|
+
one accepted Grant/Admit pair. Supply the actual Habery, ACDC v2 RegistryStore,
|
|
5
|
+
Exchanger and an opened WalletBaser. Callers own and close those stores.
|
|
6
|
+
|
|
7
|
+
`recordIssued` verifies accepted local issuance and accepts an explicit blinded
|
|
8
|
+
opening. `recordAdmission(..., {consent: true})` requires current authenticated
|
|
9
|
+
root truth, the intended local holder and the actual accepted response.
|
|
10
|
+
Neither protocol intake nor reading a Grant creates consent automatically.
|
|
11
|
+
|
|
12
|
+
`prepareAdmit(grant, holder, {consent: true})` checks the exact accepted Grant,
|
|
13
|
+
intended local holder and current authenticated root `true` before signing a
|
|
14
|
+
ACDC v2 response. This Effection operation returns `{admit, wire, support}` without
|
|
15
|
+
recording inventory. For a negotiated anchored response, supply the actual
|
|
16
|
+
`receiptor`; it gathers the exact source anchor's witness receipts before returning.
|
|
17
|
+
The caller admits that wire through ordinary ingress, then calls `recordAdmission`
|
|
18
|
+
with the actual accepted pair. False/unknown graphs and missing consent never
|
|
19
|
+
produce a signature. For a group holder, `prepareAdmitBody` applies the same
|
|
20
|
+
consent, prior and root checks without signing. Pass that frozen body through
|
|
21
|
+
`prepareAcdcV2GroupIpex` and explicit member approval, then record only the
|
|
22
|
+
accepted pair. ACDC v2 attachment genus defaults to 2.0.
|
|
23
|
+
|
|
24
|
+
`inventory`, `admissions`, `issuedCredential` and asynchronous `heldCredential`
|
|
25
|
+
read retained history. Held proofs come from that Grant's original nested rows;
|
|
26
|
+
a later fuller disclosure, registry update or policy decision does not replace
|
|
27
|
+
those bytes. History retrieval authenticates the retained outer exchanges through
|
|
28
|
+
Exchanger replay without asserting current issuer standing or graph validity.
|
|
29
|
+
|
|
30
|
+
## ACDC v2 disclosure
|
|
31
|
+
|
|
32
|
+
`WalletDiscloser(wallet, receiptor, custody?)` borrows those actual owners. Its
|
|
33
|
+
Effection operations `prepareApply`, `prepareOffer`, `prepareReply` and
|
|
34
|
+
`prepareGrant` return `{exn, wire, support}`; callers own ordinary ingress and
|
|
35
|
+
delivery. Negotiated source anchoring freezes the exchange body before gathering
|
|
36
|
+
witness receipts. Grant creation requires current authenticated complete-root
|
|
37
|
+
truth before signing and again after receipt collection.
|
|
38
|
+
|
|
39
|
+
Select `{said}` from issued inventory or `{fromGrant}` from an exact admitted
|
|
40
|
+
Grant. `disclose` can reduce that view; `refresh` can replace proof evidence
|
|
41
|
+
without expanding credential material. Event-specific `openings` are explicit;
|
|
42
|
+
`derive: true` additionally requires provisioned custody. `registryProof` returns
|
|
43
|
+
verified accepted event evidence. `unblind` recovers a candidate from an explicitly
|
|
44
|
+
possessed UUID and candidate states; it grants neither standing nor consent.
|
|
45
|
+
|
|
46
|
+
For a separately authorized presenter, select `{transferred: exactWire, presenterAuthorized: true}`, or authorize an already accepted transferred
|
|
47
|
+
`fromGrant` explicitly. These paths preserve transferred credential/proof bytes
|
|
48
|
+
and create no issued/admitted inventory row. Presenter authorization remains
|
|
49
|
+
separate from holder admission consent and possession of a derivation salt.
|
|
50
|
+
A local `presentation` registry must match the selected Issuee declaration; its
|
|
51
|
+
accepted BUP commits the frozen Grant body.
|
|
52
|
+
|
|
53
|
+
For group sender-threshold collection, `prepareGrantFileBody` freezes that same selected
|
|
54
|
+
view while permitting retryable missing current openings only when the supplied
|
|
55
|
+
historical graph verifies as issued. Ordinary `prepareGrantBody` stays strict.
|
|
56
|
+
`inspectGrantFile` checks every supplied authentication factor and reports
|
|
57
|
+
complete and partial signers without dropping invalid signatures. Group members
|
|
58
|
+
combine only their current establishment's signatures. A non-issuer discloser
|
|
59
|
+
still needs the registry issuer's authorization on the exact Grant under the core
|
|
60
|
+
presentation rule; no wallet API produces it. File preparation, signature contributions and roots create
|
|
61
|
+
no Admit; callers retain the original Grant deadline and require complete
|
|
62
|
+
presentation scope before delivery or Unblind.
|
|
63
|
+
|
|
64
|
+
Configure `Receiptor(hby, protocol, http, clock, {gvrsn})` for the actual witness attachment genus,
|
|
65
|
+
independently of ACDC v2 IPEX genus. Its default remains 1.0; the known v2
|
|
66
|
+
witness profile explicitly selects 2.0. For a group, `prepareGrantBody` freezes
|
|
67
|
+
the same selected disclosure without signing. Complete any presentation BUP
|
|
68
|
+
against that body before the first member approval; `attachPresentationProof`
|
|
69
|
+
extends its proof without changing signed bodies. `prepareAcdcV2GroupIpex`
|
|
70
|
+
checks the exact selected graph before each new member signature. Recheck
|
|
71
|
+
current graph use after threshold completion and before delivery or consent;
|
|
72
|
+
protocol completion alone grants no use authority. Approved wrapper retries
|
|
73
|
+
preserve their original nests.
|
|
74
|
+
|
|
75
|
+
## ACDC v2 authoring
|
|
76
|
+
|
|
77
|
+
`WalletAuthor(wallet, acdcV2Regery, receiptor, custody?)` borrows the same public
|
|
78
|
+
registry environment and actual receipt collector. `incept` returns an exact
|
|
79
|
+
accepted RIP; `create` uses the existing ACDC builder; `issue`, `update` and
|
|
80
|
+
`revoke` stage BUPs and return only after the exact KEL seal has authenticated
|
|
81
|
+
historical witness quorum. `update` is a state advance, never historical `upd`.
|
|
82
|
+
For a group, `registry`, `create` and `stage` prepare the same events without
|
|
83
|
+
signing. Use `approveAcdcV2Registry` and `publishAcdcV2Registry` for exact member
|
|
84
|
+
approval; wait for ordinary accepted KEL/TEL and witness evidence before
|
|
85
|
+
recording issuance. Individual signing methods continue to refuse groups.
|
|
86
|
+
|
|
87
|
+
Public authoring explicitly retains and publishes its event opening. Derived
|
|
88
|
+
authoring requires provisioned custody and retains exact nonsecret coordinates
|
|
89
|
+
before processing, including a matching pending retry. A supplied `boundEvent`
|
|
90
|
+
must be an accepted witnessed Issuee event; a new bound BUP requires the known
|
|
91
|
+
current event. Retries reuse stored BUP bytes and an already signed current-branch
|
|
92
|
+
KEL seal, even when receipts were missing. They do not author another anchor just
|
|
93
|
+
to poll. Issuance inventory follows accepted TEL evidence and preserves the
|
|
94
|
+
original issuance reference after later state advances or revocation.
|
|
95
|
+
|
|
96
|
+
`WalletDiscloser.prepareIssuanceGrantBody(sender, credential, options)` prepares a
|
|
97
|
+
different operation: one exact new credential at its issuer's accepted anchored
|
|
98
|
+
RIP, before DH and before an issued inventory row exists. `recipient` is explicit
|
|
99
|
+
and must equal its issuee. The method returns the same unsigned `PreparedGrantBody`
|
|
100
|
+
shape without creating custody, signing, approving DH or admitting a credential.
|
|
101
|
+
Ordinary `prepareGrantBody` retains its issued/held disclosure authorization.
|
|
102
|
+
|
|
103
|
+
Supply every referenced far node through `artifacts`, including its exact issuer
|
|
104
|
+
proof; no prior exchange or credential cache fills missing nodes. Far nodes must
|
|
105
|
+
already authenticate, so this finite issuer publishes only one fresh origin.
|
|
106
|
+
A multinode standalone Grant needs an explicit `plan`; `priorSaid` may select an
|
|
107
|
+
accepted unanchored Apply or Agree. Normal IPEX intake still verifies graph,
|
|
108
|
+
disclosure and DI2I policy before DH can approve the pending Grant. Python's
|
|
109
|
+
selected issuance CLI carries only one origin, while its underlying IPEX supports
|
|
110
|
+
explicit graph artifacts; the one-fresh-origin caller scope is not a protocol limit.
|
|
111
|
+
|
|
112
|
+
After DH provisions the encrypted root, use `RegistryCustody` without calling
|
|
113
|
+
`createCustody`, then `WalletAuthor.issue`. Publish accepted BUP/KEL evidence and
|
|
114
|
+
finish the original Grant through DH. Recipient Admit remains separate explicit
|
|
115
|
+
consent, and only verified Admit may enter held inventory.
|
|
116
|
+
|
|
117
|
+
## Optional local encrypted custody
|
|
118
|
+
|
|
119
|
+
`RegistryCustody({hby, hab, registry, db})` binds the actual local habitat,
|
|
120
|
+
Keeper and wallet owners. `createCustody(registry)` reuses that habitat's
|
|
121
|
+
Keeper root, or provisions a new Salt128 root for its accepted issuer inception.
|
|
122
|
+
It refuses regeneration behind undisclosed blinded history. Ordinary inventory
|
|
123
|
+
needs no private capability.
|
|
124
|
+
|
|
125
|
+
Roots are immutable encrypted `rroots.` values keyed by canonical local AID and
|
|
126
|
+
registry SAID. Keeper AEID replacement atomically rewraps them; encryption cannot
|
|
127
|
+
be disabled while roots remain. Root possession confers no presentation authority.
|
|
128
|
+
DHKE, `RegistryRoot` member replication and network Unblind remain separate owners.
|
|
129
|
+
|
|
130
|
+
`derive` returns an event-opening candidate. `retainDerivedUpdate(event, opening)`
|
|
131
|
+
records only exact event SAID, target, state and optional bound KEL coordinates in
|
|
132
|
+
the wallet before processing/anchoring. `derivedOpening(event)` authenticates the
|
|
133
|
+
exact accepted event and reconstructed commitment after reopen. Losing the wallet
|
|
134
|
+
does not lose the Keeper root, but missing coordinates still refuse derivation;
|
|
135
|
+
no coordinate guessing or legacy wallet-secret reader exists.
|
package/esm/package.json
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Wallet application entrypoint; public protocol owners remain borrowed from keri-ts. */
|
|
2
|
+
export { WalletAuthor } from "./src/authoring.js";
|
|
3
|
+
export { RegistryCustody } from "./src/custody.js";
|
|
4
|
+
export { exchangeWire, WalletDiscloser, } from "./src/disclosing.js";
|
|
5
|
+
export { createWalletBaser, WalletBaser } from "./src/storing.js";
|
|
6
|
+
export { Wallet } from "./src/wallet.js";
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
/** Finite ACDC v2 registry authoring; existing engines own acceptance and receipt authentication. */
|
|
2
|
+
import { bytesEqual, makeBlindState } from "cesr-ts";
|
|
3
|
+
import { acdcmap, blindate, isLocalGroupHab, matchesRegistrySeal, validateAcdcSchema, ValidationError, } from "keri-ts/runtime";
|
|
4
|
+
/** Borrow the actual wallet, registry environment and receipt collector; acquire no handles or workers. */
|
|
5
|
+
export class WalletAuthor {
|
|
6
|
+
constructor(wallet, rgy, receiptor, custody) {
|
|
7
|
+
Object.defineProperty(this, "wallet", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
configurable: true,
|
|
10
|
+
writable: true,
|
|
11
|
+
value: wallet
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(this, "rgy", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
configurable: true,
|
|
16
|
+
writable: true,
|
|
17
|
+
value: rgy
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(this, "receiptor", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
configurable: true,
|
|
22
|
+
writable: true,
|
|
23
|
+
value: receiptor
|
|
24
|
+
});
|
|
25
|
+
Object.defineProperty(this, "custody", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
configurable: true,
|
|
28
|
+
writable: true,
|
|
29
|
+
value: custody
|
|
30
|
+
});
|
|
31
|
+
if (rgy.hby !== wallet.hby || rgy.baser !== wallet.registry.baser || receiptor.hby !== wallet.hby) {
|
|
32
|
+
throw new ValidationError("Authoring requires the wallet's actual registry and receipt owners.");
|
|
33
|
+
}
|
|
34
|
+
if (custody
|
|
35
|
+
&& (custody.options.hby !== wallet.hby || custody.options.registry !== wallet.registry
|
|
36
|
+
|| custody.options.db !== wallet.db)) {
|
|
37
|
+
throw new ValidationError("Authoring custody must use this wallet's actual owners.");
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/** Resolve the actual local registry; staging supports groups while signing methods enforce their owner. */
|
|
41
|
+
registry(name, controller) {
|
|
42
|
+
const registry = this.rgy.registryByName(name);
|
|
43
|
+
if (!registry || registry.hab.pre !== controller) {
|
|
44
|
+
throw new ValidationError("Unknown registry or different controller.");
|
|
45
|
+
}
|
|
46
|
+
return registry;
|
|
47
|
+
}
|
|
48
|
+
/** Signing belongs either to this individual owner or to explicit group approval, never a staging flag. */
|
|
49
|
+
individual(reg) {
|
|
50
|
+
if (isLocalGroupHab(this.wallet.hby, reg.hab)) {
|
|
51
|
+
throw new ValidationError("ACDC v2 group authoring requires member approval.");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/** Idempotently stage an alias, then return only its exact accepted inception. */
|
|
55
|
+
*incept(name, controller, auths) {
|
|
56
|
+
const hab = this.wallet.hby.habs.get(controller);
|
|
57
|
+
if (!hab || isLocalGroupHab(this.wallet.hby, hab)) {
|
|
58
|
+
throw new ValidationError("ACDC v2 inception requires a local individual controller.");
|
|
59
|
+
}
|
|
60
|
+
const reg = this.rgy.registryByName(name) ?? this.rgy.makeRegistry(name, controller);
|
|
61
|
+
this.registry(name, controller);
|
|
62
|
+
const event = reg.store.event(reg.regk);
|
|
63
|
+
yield* this.anchor(reg, event, auths);
|
|
64
|
+
return event;
|
|
65
|
+
}
|
|
66
|
+
/** Construct the issuer's credential using the existing ACDC v2 finite builder. */
|
|
67
|
+
create(reg, options) {
|
|
68
|
+
this.registry(reg.name, reg.hab.pre);
|
|
69
|
+
return acdcmap(reg.hab.pre, { ...options, regid: reg.regk });
|
|
70
|
+
}
|
|
71
|
+
/** Stage one BUP state advance, preserving an exact pending retry and its opening. Never author historical upd. */
|
|
72
|
+
stage(reg, acdc, state, options = {}) {
|
|
73
|
+
return this.stageState(reg, acdc, state, options);
|
|
74
|
+
}
|
|
75
|
+
/** Ensure revocation of retained local issuance; an identical accepted revocation remains an idempotent retry. */
|
|
76
|
+
stageRevocation(reg, said, options = {}) {
|
|
77
|
+
const record = this.wallet.db.issued.get([said]);
|
|
78
|
+
if (!record || record.registry !== reg.regk) {
|
|
79
|
+
throw new ValidationError("Credential is not in this registry's issued inventory.");
|
|
80
|
+
}
|
|
81
|
+
return this.stageState(reg, this.wallet.issuedCredential(said), "revoked", options, true);
|
|
82
|
+
}
|
|
83
|
+
/** Share validation and exact pending-next reuse; only the concrete revocation ensure operation can reuse an accepted head. */
|
|
84
|
+
stageState(reg, acdc, state, options, ensureRevoked = false) {
|
|
85
|
+
this.registry(reg.name, acdc.issuer);
|
|
86
|
+
if (!acdc.verify() || acdc.regid !== reg.regk) {
|
|
87
|
+
throw new ValidationError("Credential does not match this registry.");
|
|
88
|
+
}
|
|
89
|
+
const schema = validateAcdcSchema(acdc, this.wallet.hby.db);
|
|
90
|
+
if (schema.kind !== "valid") {
|
|
91
|
+
throw new ValidationError(schema.kind === "missing" ? `Missing ACDC schema: ${schema.said}` : schema.reason);
|
|
92
|
+
}
|
|
93
|
+
const head = reg.store.headEvent(reg.regk);
|
|
94
|
+
if (!head || head.ilk === "upd")
|
|
95
|
+
throw new ValidationError("An accepted ACDC v2 registry head is required.");
|
|
96
|
+
if (options.public && options.boundEvent) {
|
|
97
|
+
throw new ValidationError("Public opening cannot use private bound coordinates.");
|
|
98
|
+
}
|
|
99
|
+
if (!options.public && !this.custody) {
|
|
100
|
+
throw new ValidationError("Derived authoring requires provisioned registry custody.");
|
|
101
|
+
}
|
|
102
|
+
if (!options.public && this.custody.options.hab !== reg.hab) {
|
|
103
|
+
throw new ValidationError("Derived authoring requires the registry habitat's custody.");
|
|
104
|
+
}
|
|
105
|
+
const sn = Number(BigInt(`0x${head.sad.n}`));
|
|
106
|
+
if (!Number.isSafeInteger(sn + 1))
|
|
107
|
+
throw new ValidationError("Registry ordinal is not representable.");
|
|
108
|
+
let bound;
|
|
109
|
+
if (options.boundEvent) {
|
|
110
|
+
const issuee = acdc.issuee, db = this.wallet.hby.db;
|
|
111
|
+
const event = issuee ? db.getEvtSerder(issuee, options.boundEvent) : null;
|
|
112
|
+
if (!event || event.sn === null || !Number.isSafeInteger(event.sn)
|
|
113
|
+
|| db.kels.getLast(issuee, event.sn) !== event.said || !db.fullyWitnessed(event)) {
|
|
114
|
+
throw new ValidationError("Bound update requires an exact accepted witnessed Issuee event.");
|
|
115
|
+
}
|
|
116
|
+
bound = { bsn: event.sn, bd: event.said };
|
|
117
|
+
}
|
|
118
|
+
const derive = (ordinal) => options.public
|
|
119
|
+
? makeBlindState({ sn: ordinal, acdc: acdc.said, state })
|
|
120
|
+
: this.custody.derive(reg.regk, ordinal, acdc.said, state, bound ? { bound: true, ...bound } : {});
|
|
121
|
+
const matches = (event, opening) => event.ilk === "bup" && event.sad.b === opening.d.nonce && opening.td.nonce === acdc.said
|
|
122
|
+
&& opening.ts.label === state;
|
|
123
|
+
const pending = [...reg.store.baser.evts.getTopItemIter()].map(([, event]) => event).filter((event) => event.regid === reg.regk && event.sad.n === (sn + 1).toString(16));
|
|
124
|
+
if (pending.length) {
|
|
125
|
+
const event = pending[0], opening = options.public ? reg.store.publicOpening(event.said) : derive(sn + 1);
|
|
126
|
+
if (pending.length !== 1 || !opening || !matches(event, opening) || event.sad.p !== head.said) {
|
|
127
|
+
throw new ValidationError("Registry has a different pending update.");
|
|
128
|
+
}
|
|
129
|
+
if (!options.public)
|
|
130
|
+
this.custody.retainDerivedUpdate(event, opening);
|
|
131
|
+
return { event, opening };
|
|
132
|
+
}
|
|
133
|
+
if (ensureRevoked && sn && head.ilk === "bup") {
|
|
134
|
+
const published = reg.store.publicOpening(head.said);
|
|
135
|
+
const opening = options.public ? published : derive(sn);
|
|
136
|
+
if (opening && matches(head, opening) && (!options.public || published)) {
|
|
137
|
+
if (!options.public)
|
|
138
|
+
this.custody.retainDerivedUpdate(head, opening);
|
|
139
|
+
return { event: head, opening };
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (bound && this.wallet.hby.db.getKever(acdc.issuee)?.serder.said !== bound.bd) {
|
|
143
|
+
throw new ValidationError("New bound update must reference the known current Issuee event.");
|
|
144
|
+
}
|
|
145
|
+
const opening = derive(sn + 1), event = blindate(reg.regk, head.said, opening.d.nonce, { sn: sn + 1, stamp: options.stamp });
|
|
146
|
+
if (!options.public)
|
|
147
|
+
this.custody.retainDerivedUpdate(event, opening);
|
|
148
|
+
reg.store.baser.env.transactionSync(() => {
|
|
149
|
+
reg.store.putEvent(event);
|
|
150
|
+
if (options.public)
|
|
151
|
+
reg.store.retainOpening(event, opening);
|
|
152
|
+
const decision = reg.processEvent(event);
|
|
153
|
+
if (decision.kind === "reject")
|
|
154
|
+
throw new ValidationError(`Registry update rejected: ${decision.reason}`);
|
|
155
|
+
});
|
|
156
|
+
return { event, opening };
|
|
157
|
+
}
|
|
158
|
+
/** Advance one explicit state through real anchoring; staging is never reported as accepted. */
|
|
159
|
+
*update(reg, acdc, state, options = {}) {
|
|
160
|
+
this.individual(reg);
|
|
161
|
+
const { event } = this.stage(reg, acdc, state, options);
|
|
162
|
+
yield* this.anchor(reg, event, options.auths);
|
|
163
|
+
return event;
|
|
164
|
+
}
|
|
165
|
+
/** Preserve original issued history on retry; inventory follows exact witnessed TEL acceptance. */
|
|
166
|
+
*issue(reg, acdc, options = {}) {
|
|
167
|
+
this.individual(reg);
|
|
168
|
+
this.registry(reg.name, acdc.issuer);
|
|
169
|
+
if (acdc.regid !== reg.regk)
|
|
170
|
+
throw new ValidationError("Credential does not match this registry.");
|
|
171
|
+
const old = this.wallet.db.issued.get([acdc.said]);
|
|
172
|
+
if (old)
|
|
173
|
+
return this.wallet.recordIssued(acdc, old.update);
|
|
174
|
+
const { event, opening } = this.stage(reg, acdc, "issued", options);
|
|
175
|
+
yield* this.anchor(reg, event, options.auths);
|
|
176
|
+
return this.wallet.recordIssued(acdc, event.said, { blinder: opening });
|
|
177
|
+
}
|
|
178
|
+
/** Revoke only locally retained issuance, not an unrelated arbitrary target digest. */
|
|
179
|
+
*revoke(reg, said, options = {}) {
|
|
180
|
+
this.individual(reg);
|
|
181
|
+
const { event } = this.stageRevocation(reg, said, options);
|
|
182
|
+
yield* this.anchor(reg, event, options.auths);
|
|
183
|
+
return event;
|
|
184
|
+
}
|
|
185
|
+
/** Reuse the current branch's already signed seal even before receipts; no extra anchor merely to poll. */
|
|
186
|
+
*anchor(reg, event, auths) {
|
|
187
|
+
this.registry(reg.name, reg.hab.pre);
|
|
188
|
+
this.individual(reg);
|
|
189
|
+
const ordinal = Number(BigInt(`0x${event.sad.n}`));
|
|
190
|
+
const accepted = reg.store.seqEvent(reg.regk, ordinal);
|
|
191
|
+
if (accepted && bytesEqual(accepted.raw, event.raw))
|
|
192
|
+
return;
|
|
193
|
+
const hab = reg.hab;
|
|
194
|
+
let current = hab.kever.serder, anchor = null;
|
|
195
|
+
while (current) {
|
|
196
|
+
if (current.seals.some((seal) => matchesRegistrySeal(seal, event)))
|
|
197
|
+
anchor = current;
|
|
198
|
+
const prior = current.prior ? hab.db.getEvtSerder(hab.pre, current.prior) : null;
|
|
199
|
+
if (!prior || prior.sn !== current.sn - 1)
|
|
200
|
+
break;
|
|
201
|
+
current = prior;
|
|
202
|
+
}
|
|
203
|
+
if (!anchor) {
|
|
204
|
+
const data = [{ i: reg.regk, s: event.sad.n, d: event.said }];
|
|
205
|
+
if (hab.kever.estOnly)
|
|
206
|
+
hab.rotate({ data });
|
|
207
|
+
else
|
|
208
|
+
hab.interact({ data });
|
|
209
|
+
anchor = hab.kever.serder;
|
|
210
|
+
}
|
|
211
|
+
yield* this.receiptor.receipt(hab.pre, { sn: anchor.sn, allowTcp: true, auths });
|
|
212
|
+
this.wallet.hby.kevery.processEscrows();
|
|
213
|
+
reg.processEscrows();
|
|
214
|
+
const exact = reg.store.seqEvent(reg.regk, ordinal);
|
|
215
|
+
if (!exact || !bytesEqual(exact.raw, event.raw)) {
|
|
216
|
+
throw new ValidationError("ACDC v2 registry event remains pending authenticated anchor receipts.");
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|