@passportsign/core 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 +201 -0
- package/README.md +36 -0
- package/dist/badge.d.ts +37 -0
- package/dist/badge.d.ts.map +1 -0
- package/dist/badge.js +94 -0
- package/dist/badge.js.map +1 -0
- package/dist/bind.d.ts +61 -0
- package/dist/bind.d.ts.map +1 -0
- package/dist/bind.js +79 -0
- package/dist/bind.js.map +1 -0
- package/dist/bundle.d.ts +47 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +95 -0
- package/dist/bundle.js.map +1 -0
- package/dist/canonical.d.ts +19 -0
- package/dist/canonical.d.ts.map +1 -0
- package/dist/canonical.js +30 -0
- package/dist/canonical.js.map +1 -0
- package/dist/dsse.d.ts +55 -0
- package/dist/dsse.d.ts.map +1 -0
- package/dist/dsse.js +64 -0
- package/dist/dsse.js.map +1 -0
- package/dist/errors.d.ts +17 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +33 -0
- package/dist/errors.js.map +1 -0
- package/dist/github.d.ts +28 -0
- package/dist/github.d.ts.map +1 -0
- package/dist/github.js +113 -0
- package/dist/github.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/log/rekor.d.ts +91 -0
- package/dist/log/rekor.d.ts.map +1 -0
- package/dist/log/rekor.js +218 -0
- package/dist/log/rekor.js.map +1 -0
- package/dist/merkle.d.ts +37 -0
- package/dist/merkle.d.ts.map +1 -0
- package/dist/merkle.js +160 -0
- package/dist/merkle.js.map +1 -0
- package/dist/nonce.d.ts +24 -0
- package/dist/nonce.d.ts.map +1 -0
- package/dist/nonce.js +50 -0
- package/dist/nonce.js.map +1 -0
- package/dist/sdk-payload.d.ts +33 -0
- package/dist/sdk-payload.d.ts.map +1 -0
- package/dist/sdk-payload.js +36 -0
- package/dist/sdk-payload.js.map +1 -0
- package/dist/statement.d.ts +67 -0
- package/dist/statement.d.ts.map +1 -0
- package/dist/statement.js +67 -0
- package/dist/statement.js.map +1 -0
- package/dist/storage/sqlite.d.ts +45 -0
- package/dist/storage/sqlite.d.ts.map +1 -0
- package/dist/storage/sqlite.js +132 -0
- package/dist/storage/sqlite.js.map +1 -0
- package/dist/submit.d.ts +26 -0
- package/dist/submit.d.ts.map +1 -0
- package/dist/submit.js +35 -0
- package/dist/submit.js.map +1 -0
- package/dist/verifier.d.ts +74 -0
- package/dist/verifier.d.ts.map +1 -0
- package/dist/verifier.js +197 -0
- package/dist/verifier.js.map +1 -0
- package/package.json +60 -0
- package/src/badge.ts +113 -0
- package/src/bind.ts +137 -0
- package/src/bundle.ts +127 -0
- package/src/canonical.ts +33 -0
- package/src/dsse.ts +91 -0
- package/src/errors.ts +37 -0
- package/src/github.ts +196 -0
- package/src/index.ts +121 -0
- package/src/log/rekor.ts +334 -0
- package/src/merkle.ts +187 -0
- package/src/nonce.ts +53 -0
- package/src/sdk-payload.ts +62 -0
- package/src/statement.ts +119 -0
- package/src/storage/sqlite.ts +185 -0
- package/src/submit.ts +54 -0
- package/src/truestamp-canonify.d.ts +7 -0
- package/src/verifier.ts +317 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
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,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Support. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or support.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 passportsign contributors
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# @passportsign/core
|
|
2
|
+
|
|
3
|
+
Core primitives for [passportsign](https://passportsign.dev) — the
|
|
4
|
+
Sigstore-adjacent personhood-attestation toolkit. Binds a GitHub
|
|
5
|
+
account to a passport-holding human via [zkPassport](https://zkpassport.id)
|
|
6
|
+
and logs the binding to the public [Sigstore Rekor](https://docs.sigstore.dev/logging/overview/)
|
|
7
|
+
transparency log as an [in-toto attestation](https://in-toto.io/Statement/v1).
|
|
8
|
+
|
|
9
|
+
This package contains the protocol primitives. See
|
|
10
|
+
[`@passportsign/cli`](https://www.npmjs.com/package/@passportsign/cli)
|
|
11
|
+
for the user-facing tool.
|
|
12
|
+
|
|
13
|
+
## What's in here
|
|
14
|
+
|
|
15
|
+
- **`canonical`** — RFC 8785 JCS canonical serialization
|
|
16
|
+
- **`statement`** — in-toto Statement v1 builder with our `passportsign.dev/personhood/v1` predicate type
|
|
17
|
+
- **`bundle`** — `binding.passportsign.json` portable format
|
|
18
|
+
- **`github`** — gist control check with full §4 error vocabulary
|
|
19
|
+
- **`log/rekor`** — Rekor client (intoto v0.0.2, log info, consistency proofs)
|
|
20
|
+
- **`merkle`** — RFC 6962 Merkle inclusion + consistency verification
|
|
21
|
+
- **`dsse`** — DSSE envelope builder (ephemeral ECDSA P-256)
|
|
22
|
+
- **`verifier`** — full bundle verifier
|
|
23
|
+
- **`badge`** — self-contained inline SVG badge
|
|
24
|
+
- **`storage/sqlite`** — local cache (separate export to avoid bundling `node:sqlite`)
|
|
25
|
+
|
|
26
|
+
## Spec
|
|
27
|
+
|
|
28
|
+
Full v0.4 spec at
|
|
29
|
+
[`docs/passportsign.md`](https://github.com/debugmcp/passportsign/blob/main/docs/passportsign.md)
|
|
30
|
+
in the source repo. The v0 acceptance evidence — including a live
|
|
31
|
+
real-passport Rekor entry — is at
|
|
32
|
+
[`docs/v0-acceptance.md`](https://github.com/debugmcp/passportsign/blob/main/docs/v0-acceptance.md).
|
|
33
|
+
|
|
34
|
+
## License
|
|
35
|
+
|
|
36
|
+
Apache-2.0
|
package/dist/badge.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Self-contained inline SVG badge generator for passportsign.
|
|
3
|
+
*
|
|
4
|
+
* v0 ships without a hosted badge service. Maintainers commit the
|
|
5
|
+
* generated `passportsign-badge.svg` to a public repo (typically the
|
|
6
|
+
* `username/username` profile repo) and reference it from their
|
|
7
|
+
* README. GitHub's image proxy renders the SVG; the badge wraps a
|
|
8
|
+
* link to the Rekor entry for click-through verification.
|
|
9
|
+
*
|
|
10
|
+
* Visual: shields.io-style pill, two segments, ~190-280px wide
|
|
11
|
+
* depending on text. Renders with the 10x scale + transform=scale(.1)
|
|
12
|
+
* trick used by shields.io for crisper text rendering.
|
|
13
|
+
*/
|
|
14
|
+
export interface BadgeInput {
|
|
15
|
+
github_username: string;
|
|
16
|
+
issuing_country: string | null;
|
|
17
|
+
bound_at: string;
|
|
18
|
+
/** Rekor entry UUID for the `<title>` tooltip. */
|
|
19
|
+
log_entry_hash?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Render the badge SVG. The output is intentionally a string (not a
|
|
23
|
+
* DOM tree or stream) so callers can write it to disk directly with
|
|
24
|
+
* `writeFileSync`.
|
|
25
|
+
*/
|
|
26
|
+
export declare function renderBadgeSvg(input: BadgeInput): string;
|
|
27
|
+
/**
|
|
28
|
+
* Render the Markdown snippet that wraps the badge in a click-through
|
|
29
|
+
* link to the Rekor entry. Suitable for pasting into a README.
|
|
30
|
+
*/
|
|
31
|
+
export declare function renderBadgeMarkdown(input: {
|
|
32
|
+
badge_path: string;
|
|
33
|
+
log_entry_hash: string;
|
|
34
|
+
rekor_base_url?: string;
|
|
35
|
+
alt_text?: string;
|
|
36
|
+
}): string;
|
|
37
|
+
//# sourceMappingURL=badge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"badge.d.ts","sourceRoot":"","sources":["../src/badge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,WAAW,UAAU;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,kDAAkD;IAClD,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AA6BD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CA0CxD;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GAAG,MAAM,CAKT"}
|
package/dist/badge.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Self-contained inline SVG badge generator for passportsign.
|
|
3
|
+
*
|
|
4
|
+
* v0 ships without a hosted badge service. Maintainers commit the
|
|
5
|
+
* generated `passportsign-badge.svg` to a public repo (typically the
|
|
6
|
+
* `username/username` profile repo) and reference it from their
|
|
7
|
+
* README. GitHub's image proxy renders the SVG; the badge wraps a
|
|
8
|
+
* link to the Rekor entry for click-through verification.
|
|
9
|
+
*
|
|
10
|
+
* Visual: shields.io-style pill, two segments, ~190-280px wide
|
|
11
|
+
* depending on text. Renders with the 10x scale + transform=scale(.1)
|
|
12
|
+
* trick used by shields.io for crisper text rendering.
|
|
13
|
+
*/
|
|
14
|
+
const LABEL = 'passportsign';
|
|
15
|
+
const CHAR_WIDTH_PX = 7; // Approx Verdana 11pt character width
|
|
16
|
+
const SIDE_PADDING_PX = 8;
|
|
17
|
+
function escapeXml(s) {
|
|
18
|
+
return s.replace(/[<>&"']/g, (c) => {
|
|
19
|
+
switch (c) {
|
|
20
|
+
case '<': return '<';
|
|
21
|
+
case '>': return '>';
|
|
22
|
+
case '&': return '&';
|
|
23
|
+
case '"': return '"';
|
|
24
|
+
case "'": return ''';
|
|
25
|
+
default: return c;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function dateStringFor(isoTimestamp) {
|
|
30
|
+
// Render as YYYY-MM-DD for the badge.
|
|
31
|
+
const d = new Date(isoTimestamp);
|
|
32
|
+
if (Number.isNaN(d.getTime()))
|
|
33
|
+
return isoTimestamp.slice(0, 10);
|
|
34
|
+
const y = d.getUTCFullYear();
|
|
35
|
+
const m = String(d.getUTCMonth() + 1).padStart(2, '0');
|
|
36
|
+
const day = String(d.getUTCDate()).padStart(2, '0');
|
|
37
|
+
return `${y}-${m}-${day}`;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Render the badge SVG. The output is intentionally a string (not a
|
|
41
|
+
* DOM tree or stream) so callers can write it to disk directly with
|
|
42
|
+
* `writeFileSync`.
|
|
43
|
+
*/
|
|
44
|
+
export function renderBadgeSvg(input) {
|
|
45
|
+
const date = dateStringFor(input.bound_at);
|
|
46
|
+
const valueParts = ['verified human'];
|
|
47
|
+
if (input.issuing_country)
|
|
48
|
+
valueParts.push(input.issuing_country);
|
|
49
|
+
valueParts.push(date);
|
|
50
|
+
const valueText = valueParts.join(' · '); // middle dot ·
|
|
51
|
+
const labelEsc = escapeXml(LABEL);
|
|
52
|
+
const valueEsc = escapeXml(valueText);
|
|
53
|
+
const labelW = LABEL.length * CHAR_WIDTH_PX + 2 * SIDE_PADDING_PX;
|
|
54
|
+
const valueW = valueText.length * CHAR_WIDTH_PX + 2 * SIDE_PADDING_PX;
|
|
55
|
+
const totalW = labelW + valueW;
|
|
56
|
+
const labelCx10 = labelW * 5; // centre of label segment, scaled x10
|
|
57
|
+
const valueCx10 = (labelW + valueW / 2) * 10;
|
|
58
|
+
const ariaLabel = `${labelEsc}: ${valueEsc}`;
|
|
59
|
+
const tooltipExtra = input.log_entry_hash
|
|
60
|
+
? ` (rekor entry ${escapeXml(input.log_entry_hash.slice(0, 16))}…)`
|
|
61
|
+
: '';
|
|
62
|
+
return [
|
|
63
|
+
`<svg xmlns="http://www.w3.org/2000/svg" width="${totalW}" height="20" role="img" aria-label="${ariaLabel}">`,
|
|
64
|
+
`<title>${ariaLabel}${tooltipExtra}</title>`,
|
|
65
|
+
`<linearGradient id="s" x2="0" y2="100%">`,
|
|
66
|
+
`<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>`,
|
|
67
|
+
`<stop offset="1" stop-opacity=".1"/>`,
|
|
68
|
+
`</linearGradient>`,
|
|
69
|
+
`<clipPath id="r"><rect width="${totalW}" height="20" rx="3" fill="#fff"/></clipPath>`,
|
|
70
|
+
`<g clip-path="url(#r)">`,
|
|
71
|
+
`<rect width="${labelW}" height="20" fill="#555"/>`,
|
|
72
|
+
`<rect x="${labelW}" width="${valueW}" height="20" fill="#4c1"/>`,
|
|
73
|
+
`<rect width="${totalW}" height="20" fill="url(#s)"/>`,
|
|
74
|
+
`</g>`,
|
|
75
|
+
`<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110">`,
|
|
76
|
+
`<text x="${labelCx10}" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)">${labelEsc}</text>`,
|
|
77
|
+
`<text x="${labelCx10}" y="140" transform="scale(.1)">${labelEsc}</text>`,
|
|
78
|
+
`<text x="${valueCx10}" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)">${valueEsc}</text>`,
|
|
79
|
+
`<text x="${valueCx10}" y="140" transform="scale(.1)">${valueEsc}</text>`,
|
|
80
|
+
`</g>`,
|
|
81
|
+
`</svg>`,
|
|
82
|
+
].join('');
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Render the Markdown snippet that wraps the badge in a click-through
|
|
86
|
+
* link to the Rekor entry. Suitable for pasting into a README.
|
|
87
|
+
*/
|
|
88
|
+
export function renderBadgeMarkdown(input) {
|
|
89
|
+
const base = input.rekor_base_url ?? 'https://rekor.sigstore.dev';
|
|
90
|
+
const url = `${base}/api/v1/log/entries/${input.log_entry_hash}`;
|
|
91
|
+
const alt = input.alt_text ?? 'passportsign verified';
|
|
92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C,IAAI;QACnE,CAAC,CAAC,EAAE,CAAC;IAEP,OAAO;QACL,kDAAkD,MAAM,wCAAwC,SAAS,IAAI;QAC7G,UAAU,SAAS,GAAG,YAAY,UAAU;QAC5C,0CAA0C;QAC1C,wDAAwD;QACxD,sCAAsC;QACtC,mBAAmB;QACnB,iCAAiC,MAAM,+CAA+C;QACtF,yBAAyB;QACzB,gBAAgB,MAAM,6BAA6B;QACnD,YAAY,MAAM,YAAY,MAAM,6BAA6B;QACjE,gBAAgB,MAAM,gCAAgC;QACtD,MAAM;QACN,8IAA8I;QAC9I,YAAY,SAAS,oEAAoE,QAAQ,SAAS;QAC1G,YAAY,SAAS,mCAAmC,QAAQ,SAAS;QACzE,YAAY,SAAS,oEAAoE,QAAQ,SAAS;QAC1G,YAAY,SAAS,mCAAmC,QAAQ,SAAS;QACzE,MAAM;QACN,QAAQ;KACT,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACb,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAKnC;IACC,MAAM,IAAI,GAAG,KAAK,CAAC,cAAc,IAAI,4BAA4B,CAAC;IAClE,MAAM,GAAG,GAAG,GAAG,IAAI,uBAAuB,KAAK,CAAC,cAAc,EAAE,CAAC;IACjE,MAAM,GAAG,GAAG,KAAK,CAAC,QAAQ,IAAI,uBAAuB,CAAC;IACtD,OAAO,MAAM,GAAG,KAAK,KAAK,CAAC,UAAU,MAAM,GAAG,GAAG,CAAC;AACpD,CAAC"}
|
package/dist/bind.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bind-flow orchestrator (no Rekor yet).
|
|
3
|
+
*
|
|
4
|
+
* Composes the pieces from `github.ts`, `statement.ts`, and `canonical.ts`
|
|
5
|
+
* into a single "given these inputs, produce a ready-to-submit binding"
|
|
6
|
+
* function. Day 5 will chain this with the Rekor submission and bundle
|
|
7
|
+
* write to deliver the full `passportsign bind` CLI command.
|
|
8
|
+
*
|
|
9
|
+
* Deliberately does **not** call the zkPassport SDK directly — the proof
|
|
10
|
+
* blob and SDK-derived metadata come in as plain data. The CLI's bind
|
|
11
|
+
* command is the producer of that data (it drives the SDK + UI),
|
|
12
|
+
* keeping this module pure and unit-testable without the SDK.
|
|
13
|
+
*/
|
|
14
|
+
import { checkGistControl, type GistEvidence } from './github.js';
|
|
15
|
+
import { type PassportsignStatement } from './statement.js';
|
|
16
|
+
export interface PrepareBindingInput {
|
|
17
|
+
github_username: string;
|
|
18
|
+
/** Base64-encoded zkPassport proof blob (the SDK callback's serialized output). */
|
|
19
|
+
proof_blob_b64: string;
|
|
20
|
+
/** From the SDK's `onResult` callback. Deterministic for this passport + scope. */
|
|
21
|
+
unique_identifier: string;
|
|
22
|
+
/** ICAO 3-letter code if disclosed, else null. Pass through as-returned by SDK. */
|
|
23
|
+
issuing_country: string | null;
|
|
24
|
+
/** Per-binding nonce that was placed in the user's gist for the control check. */
|
|
25
|
+
nonce: string;
|
|
26
|
+
/** Full scope string (e.g. "passportsign.dev:nationality-disclose:1"). */
|
|
27
|
+
scope: string;
|
|
28
|
+
/** Version string from the zkPassport SDK that produced the proof. */
|
|
29
|
+
zkpassport_sdk_version: string;
|
|
30
|
+
/** Optional GitHub token for the gist check (rate limits only — no special access). */
|
|
31
|
+
github_token?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface PrepareBindingInit {
|
|
34
|
+
/** Init timestamp — gist `updated_at` must be on or after this. */
|
|
35
|
+
issuedAt: Date;
|
|
36
|
+
/** Filename to look for in the user's gists. Defaults to `passportsign.txt`. */
|
|
37
|
+
gistFilename?: string;
|
|
38
|
+
}
|
|
39
|
+
export interface PrepareBindingDeps {
|
|
40
|
+
/** Inject for tests. Defaults to {@link checkGistControl}. */
|
|
41
|
+
github?: typeof checkGistControl;
|
|
42
|
+
/** Inject a fetch (forwarded to github). */
|
|
43
|
+
fetch?: typeof fetch;
|
|
44
|
+
}
|
|
45
|
+
export interface PreparedBinding {
|
|
46
|
+
statement: PassportsignStatement;
|
|
47
|
+
statement_canonical: Uint8Array;
|
|
48
|
+
statement_sha256_hex: string;
|
|
49
|
+
proof_blob_b64: string;
|
|
50
|
+
proof_blob_sha256_hex: string;
|
|
51
|
+
gist: GistEvidence;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Run the GitHub gist control check, then build the in-toto statement and
|
|
55
|
+
* compute canonical bytes + hashes for the Rekor handoff.
|
|
56
|
+
*
|
|
57
|
+
* Throws {@link PassportsignError} with the matching §4 code on any
|
|
58
|
+
* failure path.
|
|
59
|
+
*/
|
|
60
|
+
export declare function prepareBinding(input: PrepareBindingInput, init: PrepareBindingInit, deps?: PrepareBindingDeps): Promise<PreparedBinding>;
|
|
61
|
+
//# sourceMappingURL=bind.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bind.d.ts","sourceRoot":"","sources":["../src/bind.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAMH,OAAO,EAAE,gBAAgB,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAkB,KAAK,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAE5E,MAAM,WAAW,mBAAmB;IAClC,eAAe,EAAE,MAAM,CAAC;IACxB,mFAAmF;IACnF,cAAc,EAAE,MAAM,CAAC;IACvB,mFAAmF;IACnF,iBAAiB,EAAE,MAAM,CAAC;IAC1B,mFAAmF;IACnF,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,kFAAkF;IAClF,KAAK,EAAE,MAAM,CAAC;IACd,0EAA0E;IAC1E,KAAK,EAAE,MAAM,CAAC;IACd,sEAAsE;IACtE,sBAAsB,EAAE,MAAM,CAAC;IAC/B,uFAAuF;IACvF,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,kBAAkB;IACjC,mEAAmE;IACnE,QAAQ,EAAE,IAAI,CAAC;IACf,gFAAgF;IAChF,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,kBAAkB;IACjC,8DAA8D;IAC9D,MAAM,CAAC,EAAE,OAAO,gBAAgB,CAAC;IACjC,4CAA4C;IAC5C,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CACtB;AAED,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,qBAAqB,CAAC;IACjC,mBAAmB,EAAE,UAAU,CAAC;IAChC,oBAAoB,EAAE,MAAM,CAAC;IAC7B,cAAc,EAAE,MAAM,CAAC;IACvB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,IAAI,EAAE,YAAY,CAAC;CACpB;AAYD;;;;;;GAMG;AACH,wBAAsB,cAAc,CAClC,KAAK,EAAE,mBAAmB,EAC1B,IAAI,EAAE,kBAAkB,EACxB,IAAI,GAAE,kBAAuB,GAC5B,OAAO,CAAC,eAAe,CAAC,CAqD1B"}
|
package/dist/bind.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bind-flow orchestrator (no Rekor yet).
|
|
3
|
+
*
|
|
4
|
+
* Composes the pieces from `github.ts`, `statement.ts`, and `canonical.ts`
|
|
5
|
+
* into a single "given these inputs, produce a ready-to-submit binding"
|
|
6
|
+
* function. Day 5 will chain this with the Rekor submission and bundle
|
|
7
|
+
* write to deliver the full `passportsign bind` CLI command.
|
|
8
|
+
*
|
|
9
|
+
* Deliberately does **not** call the zkPassport SDK directly — the proof
|
|
10
|
+
* blob and SDK-derived metadata come in as plain data. The CLI's bind
|
|
11
|
+
* command is the producer of that data (it drives the SDK + UI),
|
|
12
|
+
* keeping this module pure and unit-testable without the SDK.
|
|
13
|
+
*/
|
|
14
|
+
import { createHash } from 'node:crypto';
|
|
15
|
+
import { canonicalize, canonicalSha256Hex } from './canonical.js';
|
|
16
|
+
import { PassportsignError } from './errors.js';
|
|
17
|
+
import { checkGistControl } from './github.js';
|
|
18
|
+
import { buildStatement } from './statement.js';
|
|
19
|
+
const DEFAULT_GIST_FILENAME = 'passportsign.txt';
|
|
20
|
+
function decodeBase64(b64) {
|
|
21
|
+
return new Uint8Array(Buffer.from(b64, 'base64'));
|
|
22
|
+
}
|
|
23
|
+
function sha256Hex(bytes) {
|
|
24
|
+
return createHash('sha256').update(bytes).digest('hex');
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Run the GitHub gist control check, then build the in-toto statement and
|
|
28
|
+
* compute canonical bytes + hashes for the Rekor handoff.
|
|
29
|
+
*
|
|
30
|
+
* Throws {@link PassportsignError} with the matching §4 code on any
|
|
31
|
+
* failure path.
|
|
32
|
+
*/
|
|
33
|
+
export async function prepareBinding(input, init, deps = {}) {
|
|
34
|
+
const githubImpl = deps.github ?? checkGistControl;
|
|
35
|
+
// 1. GitHub gist control check (throws PassportsignError on any §4 path).
|
|
36
|
+
const gist = await githubImpl({
|
|
37
|
+
username: input.github_username,
|
|
38
|
+
expected_filename: init.gistFilename ?? DEFAULT_GIST_FILENAME,
|
|
39
|
+
expected_content: input.nonce,
|
|
40
|
+
not_before: init.issuedAt,
|
|
41
|
+
...(input.github_token ? { token: input.github_token } : {}),
|
|
42
|
+
...(deps.fetch ? { fetch: deps.fetch } : {}),
|
|
43
|
+
});
|
|
44
|
+
// 2. Derive proof_blob sha256 from the base64 input.
|
|
45
|
+
let proofBytes;
|
|
46
|
+
try {
|
|
47
|
+
proofBytes = decodeBase64(input.proof_blob_b64);
|
|
48
|
+
}
|
|
49
|
+
catch (err) {
|
|
50
|
+
throw new PassportsignError('proof_invalid', `proof_blob_b64 is not valid base64`, err);
|
|
51
|
+
}
|
|
52
|
+
if (proofBytes.length === 0) {
|
|
53
|
+
throw new PassportsignError('proof_invalid', 'proof_blob_b64 decoded to zero bytes');
|
|
54
|
+
}
|
|
55
|
+
const proof_blob_sha256_hex = sha256Hex(proofBytes);
|
|
56
|
+
// 3. Build the in-toto statement (enforces hex / non-empty invariants).
|
|
57
|
+
const statement = buildStatement({
|
|
58
|
+
github_username: input.github_username,
|
|
59
|
+
unique_identifier: input.unique_identifier,
|
|
60
|
+
issuing_country: input.issuing_country,
|
|
61
|
+
proof_blob_sha256: proof_blob_sha256_hex,
|
|
62
|
+
gist_url: gist.url,
|
|
63
|
+
gist_content_sha256: gist.content_sha256,
|
|
64
|
+
scope: input.scope,
|
|
65
|
+
zkpassport_sdk_version: input.zkpassport_sdk_version,
|
|
66
|
+
});
|
|
67
|
+
// 4. Canonical bytes + sha256 for the Rekor entry.
|
|
68
|
+
const statement_canonical = canonicalize(statement);
|
|
69
|
+
const statement_sha256_hex = canonicalSha256Hex(statement);
|
|
70
|
+
return {
|
|
71
|
+
statement,
|
|
72
|
+
statement_canonical,
|
|
73
|
+
statement_sha256_hex,
|
|
74
|
+
proof_blob_b64: input.proof_blob_b64,
|
|
75
|
+
proof_blob_sha256_hex,
|
|
76
|
+
gist,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=bind.js.map
|
package/dist/bind.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bind.js","sourceRoot":"","sources":["../src/bind.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAqB,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,cAAc,EAA8B,MAAM,gBAAgB,CAAC;AA2C5E,MAAM,qBAAqB,GAAG,kBAAkB,CAAC;AAEjD,SAAS,YAAY,CAAC,GAAW;IAC/B,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC;AACpD,CAAC;AAED,SAAS,SAAS,CAAC,KAAiB;IA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E,MAAM,SAAS,GAAG,cAAc,CAAC;QAC/B,eAAe,EAAE,KAAK,CAAC,eAAe;QACtC,iBAAiB,EAAE,KAAK,CAAC,iBAAiB;QAC1C,eAAe,EAAE,KAAK,CAAC,eAAe;QACtC,iBAAiB,EAAE,qBAAqB;QACxC,QAAQ,EAAE,IAAI,CAAC,GAAG;QAClB,mBAAmB,EAAE,IAAI,CAAC,cAAc;QACxC,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,sBAAsB,EAAE,KAAK,CAAC,sBAAsB;KACrD,CAAC,CAAC;IAEH,mDAAmD;IACnD,MAAM,mBAAmB,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;IACpD,MAAM,oBAAoB,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC;IAE3D,OAAO;QACL,SAAS;QACT,mBAAmB;QACnB,oBAAoB;QACpB,cAAc,EAAE,KAAK,CAAC,cAAc;QACpC,qBAAqB;QACrB,IAAI;KACL,CAAC;AACJ,CAAC"}
|
package/dist/bundle.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `binding.passportsign.json` bundle format — the portable unit of
|
|
3
|
+
* verification.
|
|
4
|
+
*
|
|
5
|
+
* Rekor stores hashes, not artifacts. To verify a binding, a third party
|
|
6
|
+
* needs both the Rekor entry (hash + inclusion proof) and the artifacts
|
|
7
|
+
* that were hashed. The bundle carries both: the canonical statement bytes
|
|
8
|
+
* (hex), the proof blob (base64), and the Rekor metadata.
|
|
9
|
+
*
|
|
10
|
+
* Shape follows the Sigstore verification-bundle pattern. The
|
|
11
|
+
* `rekor.inclusion_proof` field is intentionally `unknown` for now — its
|
|
12
|
+
* shape gets pinned in Day 5 after we've smoke-tested the public Sigstore
|
|
13
|
+
* Rekor response format.
|
|
14
|
+
*/
|
|
15
|
+
export declare const BUNDLE_FORMAT_VERSION: 1;
|
|
16
|
+
export interface RekorBundleFields {
|
|
17
|
+
log_entry_hash: string;
|
|
18
|
+
inclusion_proof: unknown;
|
|
19
|
+
log_root_at_submission: string;
|
|
20
|
+
}
|
|
21
|
+
export interface PassportsignBundle {
|
|
22
|
+
bundle_format_version: typeof BUNDLE_FORMAT_VERSION;
|
|
23
|
+
/** Hex-encoded canonical JCS bytes of the in-toto statement. */
|
|
24
|
+
statement: string;
|
|
25
|
+
/** Base64-encoded zkPassport proof blob. */
|
|
26
|
+
proof_blob: string;
|
|
27
|
+
rekor: RekorBundleFields;
|
|
28
|
+
}
|
|
29
|
+
export declare class BundleValidationError extends Error {
|
|
30
|
+
readonly path: string;
|
|
31
|
+
constructor(path: string, message: string);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Type-guard validator for `PassportsignBundle`. Throws
|
|
35
|
+
* `BundleValidationError` with a structured path on the first issue.
|
|
36
|
+
*/
|
|
37
|
+
export declare function validateBundle(value: unknown): asserts value is PassportsignBundle;
|
|
38
|
+
/**
|
|
39
|
+
* Read and validate a `binding.passportsign.json` file. Throws on
|
|
40
|
+
* invalid JSON or schema violations.
|
|
41
|
+
*/
|
|
42
|
+
export declare function readBundle(path: string): PassportsignBundle;
|
|
43
|
+
/**
|
|
44
|
+
* Validate and write a `binding.passportsign.json` file (pretty-printed).
|
|
45
|
+
*/
|
|
46
|
+
export declare function writeBundle(path: string, bundle: PassportsignBundle): void;
|
|
47
|
+
//# sourceMappingURL=bundle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../src/bundle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,eAAO,MAAM,qBAAqB,EAAG,CAAU,CAAC;AAEhD,MAAM,WAAW,iBAAiB;IAChC,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,OAAO,CAAC;IACzB,sBAAsB,EAAE,MAAM,CAAC;CAChC;AAED,MAAM,WAAW,kBAAkB;IACjC,qBAAqB,EAAE,OAAO,qBAAqB,CAAC;IACpD,gEAAgE;IAChE,SAAS,EAAE,MAAM,CAAC;IAClB,4CAA4C;IAC5C,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,iBAAiB,CAAC;CAC1B;AAOD,qBAAa,qBAAsB,SAAQ,KAAK;IAE5C,QAAQ,CAAC,IAAI,EAAE,MAAM;gBAAZ,IAAI,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM;CAKlB;AAUD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,IAAI,kBAAkB,CAsClF;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,CAa3D;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,kBAAkB,GAAG,IAAI,CAG1E"}
|