@thirtified/eudi-dev 0.0.0-stage → 0.1.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.
Files changed (47) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +223 -2
  3. package/dist/binary.d.ts +42 -0
  4. package/dist/binary.js +76 -0
  5. package/dist/binary.js.map +1 -0
  6. package/dist/commands/credentials.d.ts +151 -0
  7. package/dist/commands/credentials.js +234 -0
  8. package/dist/commands/credentials.js.map +1 -0
  9. package/dist/commands/registrar.d.ts +116 -0
  10. package/dist/commands/registrar.js +150 -0
  11. package/dist/commands/registrar.js.map +1 -0
  12. package/dist/commands/trust.d.ts +58 -0
  13. package/dist/commands/trust.js +90 -0
  14. package/dist/commands/trust.js.map +1 -0
  15. package/dist/errors.d.ts +47 -0
  16. package/dist/errors.js +41 -0
  17. package/dist/errors.js.map +1 -0
  18. package/dist/eudi.d.ts +66 -0
  19. package/dist/eudi.js +113 -0
  20. package/dist/eudi.js.map +1 -0
  21. package/dist/index.d.ts +10 -0
  22. package/dist/index.js +8 -0
  23. package/dist/index.js.map +1 -0
  24. package/dist/input.d.ts +32 -0
  25. package/dist/input.js +7 -0
  26. package/dist/input.js.map +1 -0
  27. package/dist/runner.d.ts +86 -0
  28. package/dist/runner.js +246 -0
  29. package/dist/runner.js.map +1 -0
  30. package/dist/types.d.ts +345 -0
  31. package/dist/types.js +11 -0
  32. package/dist/types.js.map +1 -0
  33. package/dist/version.d.ts +24 -0
  34. package/dist/version.js +35 -0
  35. package/dist/version.js.map +1 -0
  36. package/package.json +71 -4
  37. package/src/binary.ts +114 -0
  38. package/src/commands/credentials.ts +384 -0
  39. package/src/commands/registrar.ts +243 -0
  40. package/src/commands/trust.ts +123 -0
  41. package/src/errors.ts +66 -0
  42. package/src/eudi.ts +159 -0
  43. package/src/index.ts +44 -0
  44. package/src/input.ts +27 -0
  45. package/src/runner.ts +310 -0
  46. package/src/types.ts +396 -0
  47. package/src/version.ts +36 -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 2026 Julian Dreissig
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,224 @@
1
- # Temporary Holding Version
1
+ # @thirtified/eudi-dev
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![CI](https://github.com/thirtified/eudi-dev-node/actions/workflows/ci.yml/badge.svg)](https://github.com/thirtified/eudi-dev-node/actions/workflows/ci.yml)
4
+ [![npm](https://img.shields.io/npm/v/@thirtified/eudi-dev)](https://www.npmjs.com/package/@thirtified/eudi-dev)
5
+ [![License: Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-blue)](LICENSE)
6
+
7
+ Typed Node.js wrapper for the [eudi-dev](https://github.com/eudi-dev/eudi-dev) CLI (Apache-2.0). It is built for integration tests that need to issue, decode and validate EUDI credentials (SD-JWT VC, JWT VC, mdoc) and work with the wallet's trusted lists and registrar.
8
+
9
+ The package does not bind to the Go code. It runs the CLI with `--json`, which upstream treats as a stable interface (ADR 0020): exactly one JSON document on stdout, messages on stderr, and within a major version fields are only added, never removed.
10
+
11
+ **Scope:** CLI commands only. It does not start `wallet serve` and has no HTTP client for the wallet API.
12
+
13
+ Targets eudi-dev **v3.10.1**. Any v3.x binary is accepted. No runtime dependencies besides the platform package with the binary.
14
+
15
+ ## Install
16
+
17
+ ```bash
18
+ pnpm add -D @thirtified/eudi-dev
19
+ # or: npm install --save-dev @thirtified/eudi-dev
20
+ ```
21
+
22
+ The eudi-dev binary comes in one npm package per platform, listed as `optionalDependencies` with exact versions. The package manager installs only the one that matches your OS and CPU. Nothing is downloaded at install time or at runtime, and there is no install script.
23
+
24
+ | Platform | Package | Upstream asset |
25
+ |---|---|---|
26
+ | macOS arm64 | `@thirtified/eudi-dev-darwin-arm64` | `eudi-v3.10.1-darwin-arm64` |
27
+ | macOS x64 | `@thirtified/eudi-dev-darwin-x64` | `eudi-v3.10.1-darwin-amd64` |
28
+ | Linux x64 | `@thirtified/eudi-dev-linux-x64` | `eudi-v3.10.1-linux-amd64` |
29
+ | Linux arm64 | `@thirtified/eudi-dev-linux-arm64` | `eudi-v3.10.1-linux-arm64` |
30
+
31
+ Windows isn't supported yet. Upstream publishes `eudi-v3.10.1-windows-amd64.exe`, and you can point `EUDI_DEV_BIN` at it, but the wrapper is untested on Windows.
32
+
33
+ Each package contains the upstream release binary unchanged, checked against the release's `checksums.txt` (SHA-256) when it was built, plus upstream's Apache-2.0 `LICENSE`. Its README and the `eudiDev` field in its `package.json` record the release and the hash.
34
+
35
+ The binary is found in this order:
36
+
37
+ 1. the `bin` option of `EudiDev.create()`
38
+ 2. the `EUDI_DEV_BIN` environment variable, for example a binary from `go build` or Homebrew
39
+ 3. the platform package
40
+
41
+ ### If the platform package is missing
42
+
43
+ `EudiDev.create()` throws an `EudiDevBinaryError` that names the package. The usual causes:
44
+
45
+ - Optional dependencies were left out (npm `--omit=optional`, pnpm `--no-optional`, or `omit=optional` in `.npmrc`). Install without leaving them out.
46
+ - `package-lock.json` was created on another OS and has no entry for your platform's package ([npm/cli#4828](https://github.com/npm/cli/issues/4828)). Delete `node_modules` and `package-lock.json` and run `npm install` again. pnpm's lockfile lists every platform, so this doesn't happen with pnpm.
47
+ - `node_modules` was installed on another platform than the one it runs on, for example on a Mac and then mounted into a Linux container. With pnpm, list both platforms under `supportedArchitectures` in `pnpm-workspace.yaml`. With npm, install inside the container.
48
+ - Your platform isn't one of the four above. Set `EUDI_DEV_BIN`.
49
+
50
+ With Yarn PnP the packages are unplugged (`preferUnplugged`), so the binary is a real file on disk.
51
+
52
+ The macOS binaries are ad-hoc signed by the Go linker, not notarised. Files installed by npm or pnpm carry no quarantine attribute, so they run.
53
+
54
+ ## Usage
55
+
56
+ ```ts
57
+ import { EudiDev } from '@thirtified/eudi-dev';
58
+
59
+ await using eudi = await EudiDev.create(); // own temp EUDI_DEV_HOME, removed on dispose
60
+
61
+ // Issue with an ephemeral key, then decode and validate
62
+ const { credential, publicJwk } = await eudi.issue.sdjwt({ pid: true, omit: ['sex'] });
63
+ const decoded = await eudi.decode(credential);
64
+ const result = await eudi.validate(credential, { key: publicJwk, haip: true });
65
+ result.valid; // false when a type/expiry/integrity/signature/status check fails
66
+ result.error; // "signature: ..." for the first failing check
67
+ result.report.checks; // every check, typed
68
+ result.report.haipFindings; // informational
69
+
70
+ // DCQL query for every claim of a credential
71
+ const query = await eudi.dcql(credential);
72
+
73
+ // mdoc and plain JWT VC
74
+ await eudi.issue.mdoc({ pid: true, docType: 'eu.europa.ec.eudi.pid.1' });
75
+ await eudi.issue.jwt({ claims: { name: 'Test', age: 30 } });
76
+ ```
77
+
78
+ A failing `validate` does **not** throw. It returns `valid: false` along with the report. Everything else throws `EudiDevError` when the command fails.
79
+
80
+ ### Inputs
81
+
82
+ Commands that read a credential take an `Input`:
83
+
84
+ - `string | Uint8Array`: the content itself, sent on stdin, so there is no argv length limit
85
+ - `{ path }`: a file. It must exist, because upstream would read a missing path as raw input.
86
+ - `{ url }`: an http(s) URL that eudi-dev fetches
87
+
88
+ File-valued options (`key`, `trustedList`, `cert`, `csr`, `dcql`, `claims`, `ca`) take the content, `{ path }`, or `{ url }` where upstream accepts one. Content is written to a private temp file for the duration of the call. JSON options (`claims`, a JWK `key`, a DCQL `dcql`) also accept plain objects.
89
+
90
+ ### Wallet, trust and registrar (local state)
91
+
92
+ These commands work on the wallet in the instance's `EUDI_DEV_HOME`, which is created on first use. Pass `home` to keep state between instances.
93
+
94
+ ```ts
95
+ const issued = await eudi.issue.sdjwt({ pid: true, wallet: true }); // issued.id
96
+ const trustedList = await eudi.trust.show({ vct: 'urn:eudi:pid:1' }); // signed JWT
97
+ await eudi.validate(issued.credential, { trustedList, statusList: false });
98
+
99
+ const caPem = await eudi.trust.caCert();
100
+ const caJwks = await eudi.trust.caJwks();
101
+
102
+ const rp = await eudi.registrar.verifiers.add({ name: 'Shop', purpose: 'Age check', dcql: query });
103
+ const id = rp.identifier[0]!.identifier;
104
+ const { registrationCertificate, verifierInfo } = await eudi.registrar.registrationCert({ identifier: id });
105
+ await eudi.registrar.revoke({ identifier: id });
106
+ await eudi.registrar.issuers.add({ name: 'Diplomas Inc', attestations: ['dc+sd-jwt:urn:example:diploma:1'] });
107
+ await eudi.registrar.accessCert({ identifier: id, csr: { path: 'verifier.csr' } });
108
+ await eudi.registrar.enrol({ relyingParty: { tradeName: 'X' }, access: { csr: csrPem } });
109
+ ```
110
+
111
+ A wallet-issued credential points to the wallet's own status list, which only `wallet serve` serves. Without a running server, validate it with `statusList: false`.
112
+
113
+ ### Escape hatches
114
+
115
+ - Every wrapper takes `extraArgs` for flags it doesn't model, plus `timeoutMs` and `signal`.
116
+ - `eudi.run<T>(['templates', 'list'])` runs any command with `--json` and returns `{ document, stdout, stderr }`.
117
+ - `new Runner({ bin, home })` gives the bare runner without the version check.
118
+ - `resolveBinary()` returns the binary path the lookup above finds, and `platformPackage()` the package for a platform.
119
+
120
+ ### Isolation
121
+
122
+ Each call runs with:
123
+
124
+ - `EUDI_DEV_HOME` set to the instance's home
125
+ - `NO_COLOR=1` and `--no-color`
126
+ - every inherited `EUDI_DEV_*` variable removed, so a developer's `EUDI_DEV_STORAGE` or `EUDI_DEV_SEED` cannot change results. Opt out with `inheritEudiEnv: true`. Add variables with `env`.
127
+
128
+ `EudiDev.create()` runs `eudi version` and refuses a major version other than 3 unless you pass `allowAnyVersion: true`. `dev` builds are accepted.
129
+
130
+ ### Errors
131
+
132
+ `EudiDevError` has `message` (the last stderr line, which is the error cobra printed), `stderr`, `stdout`, `exitCode` (eudi-dev uses only 0 and 1), `signal`, `timedOut`, `args`, and `document` (the JSON document, if one was printed before the failure). `EudiDevBinaryError` covers a missing or non-executable binary and an unsupported major version.
133
+
134
+ ## Types
135
+
136
+ The `--json` document types (`ValidateReport`, `DecodedSdJwt`, `DecodedMdoc`, `Check`, `StatusResult`, `RelyingParty`, `TrustOverview`, …) are written by hand from the Go structs at v3.10.1. Upstream publishes no schema for them. Every object type also accepts unknown keys, so fields added in later v3 releases still type-check. `decode` of OpenID4VCI offers, OpenID4VP requests and trusted lists returns a plain `JsonObject`.
137
+
138
+ ## Development
139
+
140
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for setup and pull requests. In short:
141
+
142
+ ```bash
143
+ pnpm install
144
+ pnpm run typecheck
145
+ pnpm test # unit tests against a fake binary (node:test, Node 22+)
146
+ pnpm run test:integration # real binary: EUDI_DEV_BIN or the platform package
147
+ pnpm run lint # Biome (lint:fix to fix); lint:package runs publint and attw
148
+ pnpm run build
149
+ ```
150
+
151
+ The pnpm version is pinned in `packageManager` (enable it with `corepack enable`, or install that version). `pnpm-workspace.yaml` denies esbuild's install script (`allowBuilds`). tsx doesn't need it, and pnpm otherwise stops the install to ask.
152
+
153
+ Before the platform packages are on npm, or to test a new upstream release, build your own platform's package into `node_modules`. If a later `pnpm install` prunes it, run it again:
154
+
155
+ ```bash
156
+ node scripts/build-platform-packages.mjs --only current --out node_modules/@thirtified
157
+ ```
158
+
159
+ ## Platform packages
160
+
161
+ `scripts/build-platform-packages.mjs` builds them (Node only, no dependencies):
162
+
163
+ ```bash
164
+ node scripts/build-platform-packages.mjs # all four into npm/, upstream tag from src/version.ts
165
+ node scripts/build-platform-packages.mjs --help # all options
166
+ ```
167
+
168
+ It downloads the release's `checksums.txt` and the four assets, fails on any SHA-256 mismatch without writing anything, and writes `npm/eudi-dev-<os>-<cpu>/` with `bin/eudi` (mode 0755), `package.json`, `LICENSE` (from the upstream tag) and `README.md`. `--base-url` points it at a mirror (`file:` URLs work). Node's `fetch` ignores `HTTPS_PROXY`; behind a proxy run it with `NODE_USE_ENV_PROXY=1` (Node 22.21+ / 24).
169
+
170
+ ### Versions
171
+
172
+ - A platform package has the upstream version without the `v`: `3.10.1` for `v3.10.1`.
173
+ - To fix the packaging of the same upstream release, add `-<n>`: `3.10.1-1`, `3.10.1-2`. npm can't republish a version, and it ignores `+build` metadata. Being a semver prerelease, `3.10.1-1` sorts below `3.10.1`, which doesn't matter because the main package pins exact versions.
174
+ - The main package has its own version and pins the platform packages exactly in `optionalDependencies`. `--sync-main` writes those pins.
175
+
176
+ ### Releasing
177
+
178
+ `.github/workflows/release.yml` runs on a tag `v<package.json version>` or by hand:
179
+
180
+ 1. It builds the platform packages at the version pinned in `optionalDependencies`, and checks that all four pins agree (`--verify-main`).
181
+ 2. It stages each one with `npm stage publish --provenance`, skipping versions already published or staged.
182
+ 3. Then it tests, builds and stages `@thirtified/eudi-dev`.
183
+ 4. You approve the staged versions with 2FA, on npmjs.com or with `npm stage list <pkg>` and `npm stage approve <id>`. The job summary lists them. **Approve the four platform packages first, then the main package.** npm skips a missing optional dependency silently, so a live main package without its platform packages installs without a binary.
184
+
185
+ Nothing goes live without that 2FA approval. Both jobs run in the `npm` GitHub environment, which holds `NPM_TOKEN`: a granular token limited to staging. You can later replace it with npm trusted publishing, allowing only staging: `npm trust github <pkg> --repo thirtified/eudi-dev-node --file release.yml --env npm --allow-stage-publish`. `package.json` needs a `repository` field that matches the GitHub repo, for provenance. The platform packages take theirs from it, falling back to `$GITHUB_REPOSITORY`.
186
+
187
+ The repo uses pnpm (the version is pinned in `packageManager`) for installing, building and testing. Publishing uses the npm CLI (`npm stage publish`), because provenance, staging and trusted publishing are defined for it. pnpm skips an optional dependency it can't fetch, so `pnpm install --frozen-lockfile` passes even while a platform package isn't on npm yet. After the platform packages are published, run `pnpm update '@thirtified/eudi-dev-*'` and commit the updated `pnpm-lock.yaml`. A plain `pnpm install` isn't enough: it treats the skipped packages as resolved and leaves them out. `minimumReleaseAgeExclude` in `pnpm-workspace.yaml` exempts these packages from the one-day wait, so this works right after a release.
188
+
189
+ The unit tests use `test/fixtures/fake-eudi.mjs`, which follows the same JSON contract and logs each call, so the tests can check argument building, temp files, stdin and the environment. The fake binary is a shebang script, so the tests need macOS or Linux.
190
+
191
+ ### First release
192
+
193
+ npm can stage versions only of packages that already exist, so publish the first version of all five packages from your machine, with 2FA:
194
+
195
+ ```bash
196
+ pnpm install && pnpm run lint && pnpm test
197
+ node scripts/build-platform-packages.mjs --verify-main # all four into npm/, checksum-verified
198
+ for dir in npm/*/; do npm publish "$dir" --access public --provenance=false; done
199
+ npm publish --provenance=false # the main package, last
200
+ ```
201
+
202
+ `--provenance=false` is needed because provenance can only be generated in CI, and `publishConfig` turns it on. These first versions therefore carry no provenance. Every later release goes through the workflow and has it.
203
+
204
+ ## Updating upstream
205
+
206
+ The [upstream watch](.github/workflows/upstream-watch.yml) workflow opens an issue with these steps when eudi-dev publishes a new release.
207
+
208
+ 1. Bump `EUDI_DEV_VERSION` in `src/version.ts`.
209
+ 2. Run `node scripts/build-platform-packages.mjs --only current --out node_modules/@thirtified --sync-main`. This pins the new version in `optionalDependencies` and installs your platform's package locally.
210
+ 3. Check `CHANGELOG.md` upstream for new flags and fields, and add them to the option and result types.
211
+ 4. Run `pnpm run test:integration`.
212
+ 5. Bump the main package version and update `CHANGELOG.md`, then tag and push to release. Afterwards run `pnpm update '@thirtified/eudi-dev-*'` and commit the lockfile.
213
+
214
+ ## Security
215
+
216
+ See [SECURITY.md](SECURITY.md). Report vulnerabilities privately, not as public issues.
217
+
218
+ ## License
219
+
220
+ [Apache-2.0](LICENSE) © Julian Dreissig.
221
+
222
+ The platform packages contain the unmodified [eudi-dev](https://github.com/eudi-dev/eudi-dev) release binaries, © Dominik Schlosser, also under Apache-2.0. Each package carries upstream's `LICENSE`.
223
+
224
+ This project isn't affiliated with or endorsed by the eudi-dev project or the European Commission. "EUDI" refers to the EU Digital Identity Wallet framework.
@@ -0,0 +1,42 @@
1
+ /**
2
+ * One per-platform npm package that ships the upstream release binary.
3
+ * `scripts/build-platform-packages.mjs` builds them from the same table.
4
+ */
5
+ export interface PlatformPackage {
6
+ /** npm package name, e.g. `@thirtified/eudi-dev-linux-x64`. */
7
+ name: string;
8
+ /** Node `process.platform` value (`os` in package.json). */
9
+ os: 'darwin' | 'linux';
10
+ /** Node `process.arch` value (`cpu` in package.json). */
11
+ cpu: 'arm64' | 'x64';
12
+ /** Path of the binary inside the package. */
13
+ binPath: 'bin/eudi';
14
+ }
15
+ /** The platform packages listed in `optionalDependencies`. */
16
+ export declare const PLATFORM_PACKAGES: readonly PlatformPackage[];
17
+ export interface ResolveBinaryOptions {
18
+ /** Use this binary and skip the lookup. Takes precedence over `EUDI_DEV_BIN`. */
19
+ bin?: string | undefined;
20
+ /** Override the detected platform (mainly for tests). Default `process.platform`. */
21
+ platform?: NodeJS.Platform | undefined;
22
+ /** Override the detected architecture (mainly for tests). Default `process.arch`. */
23
+ arch?: string | undefined;
24
+ /**
25
+ * Resolves a module specifier to a file path (mainly for tests). Default
26
+ * `createRequire(import.meta.url).resolve`.
27
+ */
28
+ resolve?: ((specifier: string) => string) | undefined;
29
+ }
30
+ /**
31
+ * The platform package for a Node platform and architecture. There is none
32
+ * for Windows yet; `EUDI_DEV_BIN` can point to upstream's `eudi.exe`, untested.
33
+ */
34
+ export declare function platformPackage(platform?: NodeJS.Platform, arch?: string): PlatformPackage;
35
+ /**
36
+ * Finds the eudi-dev binary.
37
+ *
38
+ * Order: `options.bin`, `EUDI_DEV_BIN`, then the binary in the platform
39
+ * package (for example `@thirtified/eudi-dev-linux-x64`) that npm installed
40
+ * as an optional dependency.
41
+ */
42
+ export declare function resolveBinary(options?: ResolveBinaryOptions): Promise<string>;
package/dist/binary.js ADDED
@@ -0,0 +1,76 @@
1
+ import { access, constants, stat } from 'node:fs/promises';
2
+ import { createRequire } from 'node:module';
3
+ import { EudiDevBinaryError } from './errors.js';
4
+ /** The platform packages listed in `optionalDependencies`. */
5
+ export const PLATFORM_PACKAGES = [
6
+ { name: '@thirtified/eudi-dev-darwin-arm64', os: 'darwin', cpu: 'arm64', binPath: 'bin/eudi' },
7
+ { name: '@thirtified/eudi-dev-darwin-x64', os: 'darwin', cpu: 'x64', binPath: 'bin/eudi' },
8
+ { name: '@thirtified/eudi-dev-linux-x64', os: 'linux', cpu: 'x64', binPath: 'bin/eudi' },
9
+ { name: '@thirtified/eudi-dev-linux-arm64', os: 'linux', cpu: 'arm64', binPath: 'bin/eudi' },
10
+ ];
11
+ /**
12
+ * The platform package for a Node platform and architecture. There is none
13
+ * for Windows yet; `EUDI_DEV_BIN` can point to upstream's `eudi.exe`, untested.
14
+ */
15
+ export function platformPackage(platform = process.platform, arch = process.arch) {
16
+ const pkg = PLATFORM_PACKAGES.find((p) => p.os === platform && p.cpu === arch);
17
+ if (!pkg) {
18
+ throw new EudiDevBinaryError(`eudi-dev publishes no binary for ${platform}/${arch}. Set EUDI_DEV_BIN to an eudi binary you built with "go build".`);
19
+ }
20
+ return pkg;
21
+ }
22
+ async function isExecutableFile(path) {
23
+ try {
24
+ const s = await stat(path);
25
+ if (!s.isFile())
26
+ return false;
27
+ if (process.platform !== 'win32')
28
+ await access(path, constants.X_OK);
29
+ return true;
30
+ }
31
+ catch {
32
+ return false;
33
+ }
34
+ }
35
+ /**
36
+ * Finds the eudi-dev binary.
37
+ *
38
+ * Order: `options.bin`, `EUDI_DEV_BIN`, then the binary in the platform
39
+ * package (for example `@thirtified/eudi-dev-linux-x64`) that npm installed
40
+ * as an optional dependency.
41
+ */
42
+ export async function resolveBinary(options = {}) {
43
+ const explicit = options.bin ?? process.env.EUDI_DEV_BIN;
44
+ if (explicit) {
45
+ if (!(await isExecutableFile(explicit))) {
46
+ const source = options.bin ? 'bin option' : 'EUDI_DEV_BIN';
47
+ throw new EudiDevBinaryError(`${source} points to ${explicit}, which is not an executable file`);
48
+ }
49
+ return explicit;
50
+ }
51
+ const platform = options.platform ?? process.platform;
52
+ const arch = options.arch ?? process.arch;
53
+ const pkg = platformPackage(platform, arch);
54
+ const specifier = `${pkg.name}/${pkg.binPath}`;
55
+ const resolve = options.resolve ?? createRequire(import.meta.url).resolve;
56
+ let path;
57
+ try {
58
+ path = resolve(specifier);
59
+ }
60
+ catch (err) {
61
+ throw new EudiDevBinaryError([
62
+ `The eudi-dev binary package ${pkg.name} is not installed.`,
63
+ `It is an optional dependency of @thirtified/eudi-dev, and npm skips it when:`,
64
+ ` - optional dependencies are left out (--omit=optional, --no-optional, or omit=optional in .npmrc or NPM_CONFIG_OMIT)`,
65
+ ` - package-lock.json was created on another OS or CPU and has no entry for it (npm/cli#4828).`,
66
+ ` Delete node_modules and package-lock.json, then run "npm install" again.`,
67
+ ` - this platform (${platform}/${arch}) is not supported`,
68
+ `Set EUDI_DEV_BIN to an eudi binary to skip the lookup.`,
69
+ ].join('\n'), { cause: err });
70
+ }
71
+ if (!(await isExecutableFile(path))) {
72
+ throw new EudiDevBinaryError(`${path} from ${pkg.name} is not an executable file. Reinstall the package, or set EUDI_DEV_BIN to an eudi binary.`);
73
+ }
74
+ return path;
75
+ }
76
+ //# sourceMappingURL=binary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"binary.js","sourceRoot":"","sources":["../src/binary.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAiBjD,8DAA8D;AAC9D,MAAM,CAAC,MAAM,iBAAiB,GAA+B;IAC3D,EAAE,IAAI,EAAE,mCAAmC,EAAE,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE;IAC9F,EAAE,IAAI,EAAE,iCAAiC,EAAE,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE;IAC1F,EAAE,IAAI,EAAE,gCAAgC,EAAE,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE;IACxF,EAAE,IAAI,EAAE,kCAAkC,EAAE,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO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