@motebit/verifier 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,206 @@
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 Additional Liability. 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 additional liability.
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 Motebit, Inc.
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.
202
+
203
+ "Motebit" is a trademark of Motebit, Inc. The Apache License grants rights to
204
+ this software, not to any Motebit trademarks, logos, or branding. You may not
205
+ use Motebit branding in a way that suggests endorsement or affiliation without
206
+ written permission.
package/NOTICE ADDED
@@ -0,0 +1,19 @@
1
+ Motebit
2
+ Copyright 2026 Motebit, Inc.
3
+
4
+ This product includes software developed at Motebit, Inc. (https://motebit.com).
5
+
6
+ The permissive-floor packages (the protocol, SDK, cryptographic primitives,
7
+ platform-attestation verifier leaves, scaffolding CLI, and GitHub Action) are
8
+ licensed under the Apache License, Version 2.0. See LICENSE files in each
9
+ `packages/*/` subdirectory and in `spec/` for the full license text.
10
+
11
+ The remaining packages, apps, and services are licensed under the Business
12
+ Source License 1.1 and convert to the Apache License, Version 2.0 four years
13
+ after each version's first public release. See `LICENSE` at the repository
14
+ root and `LICENSING.md` for the full license boundary.
15
+
16
+ "Motebit" is a trademark of Motebit, Inc. The licenses granted here cover
17
+ this software only, not Motebit trademarks, logos, or branding. Use of
18
+ Motebit branding in a way that suggests endorsement or affiliation requires
19
+ written permission.
package/README.md ADDED
@@ -0,0 +1,82 @@
1
+ # @motebit/verifier
2
+
3
+ Offline third-party verifier for every signed Motebit artifact.
4
+
5
+ ```bash
6
+ npm i -g @motebit/verifier
7
+ motebit-verify motebit.md
8
+ ```
9
+
10
+ Outputs
11
+
12
+ ```
13
+ VALID (identity)
14
+ did: did:motebit:01234567-...
15
+ name: my-agent
16
+ ```
17
+
18
+ Zero relay contact. Zero network. The signer's public key is embedded in the artifact or derivable from it; verification is pure crypto against committed wire formats.
19
+
20
+ ## Why this exists
21
+
22
+ Motebit's moat is the **self-signing body**: every action the agent takes emits a signed receipt that any third party can verify without running the motebit. This package is the smallest public surface of that promise — a CLI and a library that together answer _"is this signed artifact authentic, and what does it claim?"_
23
+
24
+ ## What it verifies
25
+
26
+ The unified `verify()` dispatcher in [`@motebit/crypto`](https://www.npmjs.com/package/@motebit/crypto) auto-detects and verifies:
27
+
28
+ - **identity** — `motebit.md` (YAML frontmatter + content + Ed25519 signature)
29
+ - **receipt** — `ExecutionReceipt` (task ID, tools used, prompt/result hashes, signature)
30
+ - **credential** — W3C-style Verifiable Credentials
31
+ - **presentation** — W3C-style Verifiable Presentations
32
+
33
+ ## Usage
34
+
35
+ ```
36
+ motebit-verify <file> [options]
37
+
38
+ --json Print structured JSON instead of human.
39
+ --expect <type> Pin expected type: identity | receipt | credential | presentation.
40
+ --clock-skew <seconds> Allowance for credential/presentation time bounds.
41
+ -h, --help
42
+ -V, --version
43
+ ```
44
+
45
+ ### Exit codes
46
+
47
+ | Code | Meaning |
48
+ | ---- | --------------------------------------------------- |
49
+ | `0` | Artifact verified |
50
+ | `1` | Artifact invalid (bad signature, expired, mismatch) |
51
+ | `2` | Usage or I/O error |
52
+
53
+ POSIX-friendly — chain into CI gates, `make` targets, `git` hooks.
54
+
55
+ ### Library
56
+
57
+ ```ts
58
+ import { verifyFile } from "@motebit/verifier";
59
+
60
+ const result = await verifyFile("./receipt.json");
61
+ if (result.valid) console.log(`receipt signed by ${result.receipt?.signer}`);
62
+ ```
63
+
64
+ ## Guarantees
65
+
66
+ - **No network.** Verification runs entirely offline. No relay calls, no DID resolution over the wire.
67
+ - **No dependencies beyond `@motebit/crypto`.** Every dependency is a trust attack surface we'd have to re-audit on every upgrade.
68
+ - **Suite-agile.** New signature suites (post-quantum, future) are registry additions, not CLI changes — `@motebit/crypto`'s `verifyBySuite` dispatches for us.
69
+
70
+ ## Related
71
+
72
+ - [`@motebit/crypto`](https://www.npmjs.com/package/@motebit/crypto) — the verification primitives this package wraps (Apache-2.0, zero deps)
73
+ - [`@motebit/protocol`](https://www.npmjs.com/package/@motebit/protocol) — protocol types for the artifacts being verified (Apache-2.0, zero deps)
74
+ - [`@motebit/sdk`](https://www.npmjs.com/package/@motebit/sdk) — developer contract for building Motebit-powered agents
75
+ - [`create-motebit`](https://www.npmjs.com/package/create-motebit) — scaffold a signed agent identity
76
+ - [`motebit`](https://www.npmjs.com/package/motebit) — reference runtime and operator console
77
+
78
+ ## License
79
+
80
+ Apache-2.0 — see [LICENSE](./LICENSE).
81
+
82
+ "Motebit" is a trademark. The Apache License grants rights to this software, not to any Motebit trademarks, logos, or branding. You may not use Motebit branding in a way that suggests endorsement or affiliation without written permission.
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @motebit/verifier — Apache-2.0 permissive-floor library for verifying every
3
+ * signed Motebit artifact.
4
+ *
5
+ * The moat: anything a motebit signs (identity file, execution receipt,
6
+ * credential, presentation) is third-party verifiable with only this
7
+ * package and the signer's public key — no relay contact, no motebit
8
+ * runtime, no network. This module is the smallest public library
9
+ * surface of that promise.
10
+ *
11
+ * Library-only as of v1.0. The `motebit-verify` CLI moved to the BSL
12
+ * `@motebit/verify` package, which layers bundled hardware-attestation
13
+ * adapters (Apple App Attest, TPM 2.0, Google Play Integrity, WebAuthn)
14
+ * on top of this library. The split mirrors long-lived tool lineages
15
+ * like `git` / `libgit2` or `cargo` / `tokio`: permissive-floor library
16
+ * underneath, BSL verb-named CLI on top. Third parties building
17
+ * permissive-floor-only verifiers compose this package and
18
+ * `@motebit/crypto` freely — Apache-2.0 carries an explicit patent grant.
19
+ *
20
+ * Composition:
21
+ *
22
+ * - `verifyFile(path, opts?)` — read an artifact off disk, detect its
23
+ * kind, return the typed `VerifyResult` from `@motebit/crypto`.
24
+ * - `verifyArtifact(content, opts?)` — same, but accept the artifact
25
+ * already-loaded (string for identity, object or JSON string for
26
+ * JSON artifacts).
27
+ * - `formatHuman(result)` — render a `VerifyResult` as the
28
+ * multi-line human-readable output a CLI would print.
29
+ * - `VerifyFileOptions.hardwareAttestation` — optional injection of
30
+ * platform-specific verifiers for `device_check` / `tpm` /
31
+ * `play_integrity` / `webauthn` claims. Permissive-floor consumers can
32
+ * supply their own; `@motebit/verify` wires the canonical bundle.
33
+ */
34
+ export { verifyFile, verifyArtifact, formatHuman } from "./lib.js";
35
+ export type { VerifyFileOptions } from "./lib.js";
36
+ export type { VerifyResult, ArtifactType } from "@motebit/crypto";
37
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACnE,YAAY,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAClD,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,35 @@
1
+ /**
2
+ * @motebit/verifier — Apache-2.0 permissive-floor library for verifying every
3
+ * signed Motebit artifact.
4
+ *
5
+ * The moat: anything a motebit signs (identity file, execution receipt,
6
+ * credential, presentation) is third-party verifiable with only this
7
+ * package and the signer's public key — no relay contact, no motebit
8
+ * runtime, no network. This module is the smallest public library
9
+ * surface of that promise.
10
+ *
11
+ * Library-only as of v1.0. The `motebit-verify` CLI moved to the BSL
12
+ * `@motebit/verify` package, which layers bundled hardware-attestation
13
+ * adapters (Apple App Attest, TPM 2.0, Google Play Integrity, WebAuthn)
14
+ * on top of this library. The split mirrors long-lived tool lineages
15
+ * like `git` / `libgit2` or `cargo` / `tokio`: permissive-floor library
16
+ * underneath, BSL verb-named CLI on top. Third parties building
17
+ * permissive-floor-only verifiers compose this package and
18
+ * `@motebit/crypto` freely — Apache-2.0 carries an explicit patent grant.
19
+ *
20
+ * Composition:
21
+ *
22
+ * - `verifyFile(path, opts?)` — read an artifact off disk, detect its
23
+ * kind, return the typed `VerifyResult` from `@motebit/crypto`.
24
+ * - `verifyArtifact(content, opts?)` — same, but accept the artifact
25
+ * already-loaded (string for identity, object or JSON string for
26
+ * JSON artifacts).
27
+ * - `formatHuman(result)` — render a `VerifyResult` as the
28
+ * multi-line human-readable output a CLI would print.
29
+ * - `VerifyFileOptions.hardwareAttestation` — optional injection of
30
+ * platform-specific verifiers for `device_check` / `tpm` /
31
+ * `play_integrity` / `webauthn` claims. Permissive-floor consumers can
32
+ * supply their own; `@motebit/verify` wires the canonical bundle.
33
+ */
34
+ export { verifyFile, verifyArtifact, formatHuman } from "./lib.js";
35
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC"}
package/dist/lib.d.ts ADDED
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Library core — thin wrapper over `@motebit/crypto`'s unified `verify()`
3
+ * dispatcher with file-reading + human-rendering helpers. No state, no
4
+ * side effects beyond filesystem reads you requested.
5
+ *
6
+ * Supported artifact kinds (auto-detected by `@motebit/crypto`):
7
+ * - `identity` — `motebit.md` identity file with YAML frontmatter
8
+ * - `receipt` — signed `ExecutionReceipt` JSON
9
+ * - `credential` — W3C-style `VerifiableCredential` JSON
10
+ * - `presentation`— `VerifiablePresentation` JSON
11
+ *
12
+ * Error handling: file I/O errors throw (caller decides how to surface).
13
+ * Parse / signature errors are returned as `valid: false` results so the
14
+ * caller can render a structured reason instead of catching exceptions.
15
+ */
16
+ import { type ArtifactType, type HardwareAttestationVerifiers, type VerifyResult } from "@motebit/crypto";
17
+ export interface VerifyFileOptions {
18
+ /**
19
+ * Pin the expected artifact type. When set, detection must match or
20
+ * the result is `valid: false` with an explanatory error. Useful in
21
+ * CI where you want to reject a credential passed into a
22
+ * receipt-verification step.
23
+ */
24
+ readonly expectedType?: ArtifactType;
25
+ /**
26
+ * Clock skew allowance (seconds) for credential / presentation
27
+ * time-bounded fields (`issuanceDate`, `expirationDate`, etc.).
28
+ * Forwarded to `@motebit/crypto`. Defaults to the crypto package's
29
+ * default.
30
+ */
31
+ readonly clockSkewSeconds?: number;
32
+ /**
33
+ * Optional platform-specific hardware-attestation verifiers. Forwarded
34
+ * through to `@motebit/crypto::verify` so credentials carrying a
35
+ * `hardware_attestation` claim for `device_check` / `tpm` /
36
+ * `play_integrity` / `webauthn` can be verified end-to-end. Leaving
37
+ * this unset keeps the permissive-floor path fail-closed —
38
+ * hardware-attested credentials still verify their Ed25519 proof, but the
39
+ * `hardware_attestation` channel reports `adapter not yet shipped`
40
+ * (the expected permissive-floor-only behavior). The BSL companion CLI
41
+ * `@motebit/verify` wires all four leaves automatically.
42
+ */
43
+ readonly hardwareAttestation?: HardwareAttestationVerifiers;
44
+ }
45
+ /**
46
+ * Verify an artifact read from disk. Auto-detects type via content
47
+ * inspection in `@motebit/crypto`.
48
+ */
49
+ export declare function verifyFile(path: string, opts?: VerifyFileOptions): Promise<VerifyResult>;
50
+ /**
51
+ * Verify an already-loaded artifact. Accepts a JSON string, an
52
+ * already-parsed object, or a `motebit.md` identity string.
53
+ */
54
+ export declare function verifyArtifact(content: string | object, opts?: VerifyFileOptions): Promise<VerifyResult>;
55
+ /**
56
+ * Render a `VerifyResult` as the CLI's default human-readable block.
57
+ * `--json` bypasses this and prints the raw result directly.
58
+ *
59
+ * Layout:
60
+ * ```
61
+ * VALID (receipt)
62
+ * signer: did:motebit:...
63
+ * id: rcpt_01JZN...
64
+ * ```
65
+ * or
66
+ * ```
67
+ * INVALID (credential)
68
+ * - credentialSubject.id missing
69
+ * - signature mismatch
70
+ * ```
71
+ */
72
+ export declare function formatHuman(result: VerifyResult): string;
73
+ //# sourceMappingURL=lib.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../src/lib.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,4BAA4B,EACjC,KAAK,YAAY,EAElB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,WAAW,iBAAiB;IAChC;;;;;OAKG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,YAAY,CAAC;IACrC;;;;;OAKG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IACnC;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,mBAAmB,CAAC,EAAE,4BAA4B,CAAC;CAC7D;AAED;;;GAGG;AACH,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,YAAY,CAAC,CAG9F;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,IAAI,CAAC,EAAE,iBAAiB,GACvB,OAAO,CAAC,YAAY,CAAC,CAgBvB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAqBxD"}
package/dist/lib.js ADDED
@@ -0,0 +1,146 @@
1
+ /**
2
+ * Library core — thin wrapper over `@motebit/crypto`'s unified `verify()`
3
+ * dispatcher with file-reading + human-rendering helpers. No state, no
4
+ * side effects beyond filesystem reads you requested.
5
+ *
6
+ * Supported artifact kinds (auto-detected by `@motebit/crypto`):
7
+ * - `identity` — `motebit.md` identity file with YAML frontmatter
8
+ * - `receipt` — signed `ExecutionReceipt` JSON
9
+ * - `credential` — W3C-style `VerifiableCredential` JSON
10
+ * - `presentation`— `VerifiablePresentation` JSON
11
+ *
12
+ * Error handling: file I/O errors throw (caller decides how to surface).
13
+ * Parse / signature errors are returned as `valid: false` results so the
14
+ * caller can render a structured reason instead of catching exceptions.
15
+ */
16
+ import { readFile } from "node:fs/promises";
17
+ import { verify, } from "@motebit/crypto";
18
+ /**
19
+ * Verify an artifact read from disk. Auto-detects type via content
20
+ * inspection in `@motebit/crypto`.
21
+ */
22
+ export async function verifyFile(path, opts) {
23
+ const content = await readFile(path, "utf-8");
24
+ return verifyArtifact(content, opts);
25
+ }
26
+ /**
27
+ * Verify an already-loaded artifact. Accepts a JSON string, an
28
+ * already-parsed object, or a `motebit.md` identity string.
29
+ */
30
+ export function verifyArtifact(content, opts) {
31
+ const cryptoOpts = opts?.expectedType !== undefined ||
32
+ opts?.clockSkewSeconds !== undefined ||
33
+ opts?.hardwareAttestation !== undefined
34
+ ? {
35
+ ...(opts.expectedType !== undefined && { expectedType: opts.expectedType }),
36
+ ...(opts.clockSkewSeconds !== undefined && {
37
+ clockSkewSeconds: opts.clockSkewSeconds,
38
+ }),
39
+ ...(opts.hardwareAttestation !== undefined && {
40
+ hardwareAttestation: opts.hardwareAttestation,
41
+ }),
42
+ }
43
+ : undefined;
44
+ return verify(content, cryptoOpts);
45
+ }
46
+ /**
47
+ * Render a `VerifyResult` as the CLI's default human-readable block.
48
+ * `--json` bypasses this and prints the raw result directly.
49
+ *
50
+ * Layout:
51
+ * ```
52
+ * VALID (receipt)
53
+ * signer: did:motebit:...
54
+ * id: rcpt_01JZN...
55
+ * ```
56
+ * or
57
+ * ```
58
+ * INVALID (credential)
59
+ * - credentialSubject.id missing
60
+ * - signature mismatch
61
+ * ```
62
+ */
63
+ export function formatHuman(result) {
64
+ const header = `${result.valid ? "VALID" : "INVALID"} (${result.type})`;
65
+ const lines = [header];
66
+ if (result.valid) {
67
+ const summary = summarizeValid(result);
68
+ for (const [k, v] of summary) {
69
+ lines.push(` ${k.padEnd(8)} ${v}`);
70
+ }
71
+ }
72
+ else {
73
+ const errs = "errors" in result && result.errors ? result.errors : [];
74
+ if (errs.length === 0) {
75
+ lines.push(" (no detail provided)");
76
+ }
77
+ else {
78
+ for (const e of errs) {
79
+ lines.push(` - ${e.message}`);
80
+ }
81
+ }
82
+ }
83
+ return lines.join("\n");
84
+ }
85
+ function summarizeValid(result) {
86
+ switch (result.type) {
87
+ case "identity": {
88
+ if (!result.identity)
89
+ return [];
90
+ const out = [];
91
+ if (result.did)
92
+ out.push(["did:", result.did]);
93
+ if (result.identity.service_name) {
94
+ out.push(["name:", result.identity.service_name]);
95
+ }
96
+ out.push(["id:", result.identity.motebit_id]);
97
+ return out;
98
+ }
99
+ case "receipt": {
100
+ if (!result.receipt)
101
+ return [];
102
+ const out = [];
103
+ out.push(["task:", result.receipt.task_id]);
104
+ out.push(["motebit:", result.receipt.motebit_id]);
105
+ if (result.signer)
106
+ out.push(["signer:", result.signer]);
107
+ return out;
108
+ }
109
+ case "credential": {
110
+ if (!result.credential)
111
+ return [];
112
+ const out = [];
113
+ if (result.issuer)
114
+ out.push(["issuer:", result.issuer]);
115
+ if (result.subject)
116
+ out.push(["subject:", result.subject]);
117
+ if (result.expired !== undefined) {
118
+ out.push(["expired:", result.expired ? "yes" : "no"]);
119
+ }
120
+ // Hardware-attestation channel — shown only when the credential's
121
+ // subject declared a claim. Absent field = no line (no hardware
122
+ // claim was made, which is different from "fails"). Verifier CLI
123
+ // output is the user's only hook into this until a GUI surface
124
+ // grows one, so the line is terse but unambiguous.
125
+ if (result.hardware_attestation) {
126
+ const ha = result.hardware_attestation;
127
+ const status = ha.valid ? "✓" : "✗";
128
+ const platform = ha.platform ?? "unknown";
129
+ out.push(["hardware:", `${platform} ${status}`]);
130
+ }
131
+ return out;
132
+ }
133
+ case "presentation": {
134
+ if (!result.presentation)
135
+ return [];
136
+ const out = [];
137
+ if (result.holder)
138
+ out.push(["holder:", result.holder]);
139
+ if (result.credentials) {
140
+ out.push(["creds:", String(result.credentials.length)]);
141
+ }
142
+ return out;
143
+ }
144
+ }
145
+ }
146
+ //# sourceMappingURL=lib.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lib.js","sourceRoot":"","sources":["../src/lib.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,E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,+DAA+D;YAC/D,mDAAmD;YACnD,IAAI,MAAM,CAAC,oBAAoB,EAAE,CAAC;gBAChC,MAAM,EAAE,GAAG,MAAM,CAAC,oBAAoB,CAAC;gBACvC,MAAM,MAAM,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;gBACpC,MAAM,QAAQ,GAAG,EAAE,CAAC,QAAQ,IAAI,SAAS,CAAC;gBAC1C,GAAG,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,GAAG,QAAQ,IAAI,MAAM,EAAE,CAAC,CAAC,CAAC;YACnD,CAAC;YACD,OAAO,GAAG,CAAC;QACb,CAAC;QACD,KAAK,cAAc,CAAC,CAAC,CAAC;YACpB,IAAI,CAAC,MAAM,CAAC,YAAY;gBAAE,OAAO,EAAE,CAAC;YACpC,MAAM,GAAG,GAAqC,EAAE,CAAC;YACjD,IAAI,MAAM,CAAC,MAAM;gBAAE,GAAG,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;YACxD,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;gBACvB,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YAC1D,CAAC;YACD,OAAO,GAAG,CAAC;QACb,CAAC;IACH,CAAC;AACH,CAAC"}
package/package.json ADDED
@@ -0,0 +1,77 @@
1
+ {
2
+ "name": "@motebit/verifier",
3
+ "version": "1.0.0",
4
+ "description": "Apache-2.0 library for verifying signed Motebit artifacts (identity files, execution receipts, credentials, presentations) — file-reading and human-formatting helpers on top of @motebit/crypto. The canonical `motebit-verify` CLI now lives at @motebit/verify; this package is the Apache-2.0 library it sits on.",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist/**/*.js",
16
+ "dist/**/*.js.map",
17
+ "dist/**/*.d.ts",
18
+ "dist/**/*.d.ts.map",
19
+ "LICENSE",
20
+ "NOTICE",
21
+ "README.md"
22
+ ],
23
+ "sideEffects": false,
24
+ "license": "Apache-2.0",
25
+ "keywords": [
26
+ "motebit",
27
+ "verify",
28
+ "library",
29
+ "ed25519",
30
+ "signature",
31
+ "receipt",
32
+ "credential",
33
+ "identity",
34
+ "offline",
35
+ "audit"
36
+ ],
37
+ "homepage": "https://github.com/motebit/motebit/tree/main/packages/verifier#readme",
38
+ "bugs": {
39
+ "url": "https://github.com/motebit/motebit/issues"
40
+ },
41
+ "repository": {
42
+ "type": "git",
43
+ "url": "https://github.com/motebit/motebit",
44
+ "directory": "packages/verifier"
45
+ },
46
+ "publishConfig": {
47
+ "access": "public"
48
+ },
49
+ "motebit": {
50
+ "implements": [
51
+ "spec/identity-v1.md",
52
+ "spec/credential-v1.md"
53
+ ]
54
+ },
55
+ "dependencies": {
56
+ "@motebit/crypto": "1.0.0"
57
+ },
58
+ "devDependencies": {
59
+ "@noble/ed25519": "~3.0.1",
60
+ "@noble/hashes": "~1.6.0",
61
+ "@types/node": "^22.0.0",
62
+ "typescript": "^5.6.0",
63
+ "vitest": "^2.1.0"
64
+ },
65
+ "engines": {
66
+ "node": ">=20"
67
+ },
68
+ "scripts": {
69
+ "build": "tsc -b",
70
+ "test": "vitest run",
71
+ "test:coverage": "vitest run --coverage",
72
+ "typecheck": "tsc --noEmit",
73
+ "lint": "eslint --parser-options=project:tsconfig.eslint.json src/",
74
+ "lint:pack": "publint --strict && attw --pack --profile esm-only",
75
+ "clean": "rm -rf dist .turbo *.tsbuildinfo"
76
+ }
77
+ }