@bsv/create-dpp-app 0.0.0-stage → 0.1.0-beta.2
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 +203 -0
- package/NOTICE +2 -0
- package/PATENTS +12 -0
- package/README.md +93 -2
- package/dist/index.js +125 -0
- package/package.json +57 -4
- package/template/Dockerfile +37 -0
- package/template/README.md +389 -0
- package/template/_dockerignore +6 -0
- package/template/_env.example +122 -0
- package/template/_github/workflows/ci.yml +23 -0
- package/template/_gitignore +8 -0
- package/template/_prettierrc +6 -0
- package/template/apps/api/API.md +119 -0
- package/template/apps/api/package.json +39 -0
- package/template/apps/api/src/auth.ts +55 -0
- package/template/apps/api/src/bound-profiles.ts +590 -0
- package/template/apps/api/src/claims.ts +204 -0
- package/template/apps/api/src/cli.ts +99 -0
- package/template/apps/api/src/config.ts +180 -0
- package/template/apps/api/src/custody.ts +358 -0
- package/template/apps/api/src/dev-index.ts +120 -0
- package/template/apps/api/src/env-file.ts +55 -0
- package/template/apps/api/src/env.ts +14 -0
- package/template/apps/api/src/epcis/exchange.ts +434 -0
- package/template/apps/api/src/epcis/mongo-storage.ts +381 -0
- package/template/apps/api/src/epcis/routes.ts +364 -0
- package/template/apps/api/src/epcis/sources.ts +142 -0
- package/template/apps/api/src/go-live.ts +226 -0
- package/template/apps/api/src/http-error.ts +15 -0
- package/template/apps/api/src/identifiers.ts +57 -0
- package/template/apps/api/src/index-client.ts +261 -0
- package/template/apps/api/src/index-projects.ts +53 -0
- package/template/apps/api/src/lifecycle-authority.ts +49 -0
- package/template/apps/api/src/lifecycle.ts +485 -0
- package/template/apps/api/src/main.ts +58 -0
- package/template/apps/api/src/parties.ts +68 -0
- package/template/apps/api/src/platform.ts +176 -0
- package/template/apps/api/src/portability/commands.ts +224 -0
- package/template/apps/api/src/portability/export.ts +708 -0
- package/template/apps/api/src/portability/package.ts +270 -0
- package/template/apps/api/src/portability/restore.ts +863 -0
- package/template/apps/api/src/profiles.ts +125 -0
- package/template/apps/api/src/reader.ts +265 -0
- package/template/apps/api/src/resolver.ts +159 -0
- package/template/apps/api/src/sector-examples.ts +390 -0
- package/template/apps/api/src/server.ts +613 -0
- package/template/apps/api/src/store.ts +426 -0
- package/template/apps/api/src/validation-engine.ts +172 -0
- package/template/apps/api/src/wallet.ts +359 -0
- package/template/apps/api/src/worker.ts +113 -0
- package/template/apps/api/src/writer.ts +603 -0
- package/template/apps/api/test/bound-http.test.ts +496 -0
- package/template/apps/api/test/bound-profiles.test.ts +547 -0
- package/template/apps/api/test/config.test.ts +160 -0
- package/template/apps/api/test/custody-journal.test.ts +415 -0
- package/template/apps/api/test/custody-recovery-profile.test.ts +224 -0
- package/template/apps/api/test/custom-profile.test.ts +167 -0
- package/template/apps/api/test/env-file.test.ts +53 -0
- package/template/apps/api/test/epcis-fixtures.ts +270 -0
- package/template/apps/api/test/epcis-http.test.ts +1179 -0
- package/template/apps/api/test/epcis-mongo-storage.test.ts +313 -0
- package/template/apps/api/test/epcis-separation.test.ts +253 -0
- package/template/apps/api/test/epcis-web.test.ts +230 -0
- package/template/apps/api/test/exit-exercise.test.ts +1038 -0
- package/template/apps/api/test/external-index.test.ts +32 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/background.ttl +33 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/binding.json +141 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/context.jsonld +36 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/product.schema.json +44 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/shapes.ttl +112 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/conflicting-gtin.json +44 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/conflicting-serial.json +44 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/granularity-mismatch.json +44 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/item-gtin-13.json +43 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/item.json +42 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/missing-required-property.json +43 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/model-as-subject.json +44 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/no-passport-identifier.json +43 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/other-product.json +44 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/part-not-dishwasher-safe.json +45 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/registration/altered-artefact.json +19 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/registration/altered-background.ttl +33 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/registration/conflicting-binding.json +141 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/registration/conflicting-second-registration.json +19 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/registration/untrusted-binding.json +13 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/unlisted-context.json +47 -0
- package/template/apps/api/test/fixtures/custom-profile/example-bottle@1/vectors/wrong-binding-digest.json +44 -0
- package/template/apps/api/test/fixtures/custom-profile/example-notebook@1/binding.json +88 -0
- package/template/apps/api/test/fixtures/custom-profile/example-notebook@1/product.schema.json +25 -0
- package/template/apps/api/test/fixtures/custom-profile/example-notebook@1/vectors/item.json +26 -0
- package/template/apps/api/test/fixtures/custom-profile/example-notebook@1/vectors/missing-required-property.json +27 -0
- package/template/apps/api/test/fixtures/custom-profile/example-notebook@1/vectors/no-passport-identifier.json +27 -0
- package/template/apps/api/test/fixtures/custom-profile/example-notebook@1/vectors/other-product.json +28 -0
- package/template/apps/api/test/go-live.test.ts +179 -0
- package/template/apps/api/test/gs1-global-setup.ts +33 -0
- package/template/apps/api/test/gs1-test-env.ts +5 -0
- package/template/apps/api/test/identifier-host.test.ts +256 -0
- package/template/apps/api/test/index-projects.test.ts +81 -0
- package/template/apps/api/test/lifecycle-claims.test.ts +546 -0
- package/template/apps/api/test/lifecycle-fixtures.ts +167 -0
- package/template/apps/api/test/lifecycle.test.ts +147 -0
- package/template/apps/api/test/manifest-notice.test.ts +36 -0
- package/template/apps/api/test/network-guard.ts +113 -0
- package/template/apps/api/test/portability.test.ts +655 -0
- package/template/apps/api/test/profile-bundle-resolver.test.ts +198 -0
- package/template/apps/api/test/retired-profiles.test.ts +216 -0
- package/template/apps/api/test/sector-cutover.test.ts +95 -0
- package/template/apps/api/test/sector-forms.test.ts +420 -0
- package/template/apps/api/test/unjoined-index.test.ts +62 -0
- package/template/apps/api/test/validation-engine.test.ts +328 -0
- package/template/apps/api/test/wallet-monitor.test.ts +38 -0
- package/template/apps/api/test/writer-journal.test.ts +327 -0
- package/template/apps/api/tsconfig.json +9 -0
- package/template/apps/api/vitest.config.ts +12 -0
- package/template/apps/web/components.json +21 -0
- package/template/apps/web/index.html +12 -0
- package/template/apps/web/package.json +33 -0
- package/template/apps/web/src/app.tsx +55 -0
- package/template/apps/web/src/components/bits.tsx +188 -0
- package/template/apps/web/src/components/bound/bound-passport-form.tsx +368 -0
- package/template/apps/web/src/components/bound/field-view.tsx +237 -0
- package/template/apps/web/src/components/bound/pieces.tsx +169 -0
- package/template/apps/web/src/components/bound/readings.tsx +152 -0
- package/template/apps/web/src/components/bound/structured-value.tsx +114 -0
- package/template/apps/web/src/components/claim-dialog.tsx +344 -0
- package/template/apps/web/src/components/epcis-events.tsx +119 -0
- package/template/apps/web/src/components/layout.tsx +135 -0
- package/template/apps/web/src/components/lifecycle-claims.tsx +199 -0
- package/template/apps/web/src/components/passport-form.tsx +244 -0
- package/template/apps/web/src/components/read-passport.tsx +49 -0
- package/template/apps/web/src/components/reading.tsx +150 -0
- package/template/apps/web/src/components/ui/alert.tsx +65 -0
- package/template/apps/web/src/components/ui/badge.tsx +47 -0
- package/template/apps/web/src/components/ui/button.tsx +63 -0
- package/template/apps/web/src/components/ui/card.tsx +91 -0
- package/template/apps/web/src/components/ui/dialog.tsx +156 -0
- package/template/apps/web/src/components/ui/input.tsx +20 -0
- package/template/apps/web/src/components/ui/label.tsx +21 -0
- package/template/apps/web/src/components/ui/select.tsx +189 -0
- package/template/apps/web/src/components/ui/separator.tsx +25 -0
- package/template/apps/web/src/components/ui/table.tsx +115 -0
- package/template/apps/web/src/components/ui/tabs.tsx +90 -0
- package/template/apps/web/src/components/ui/textarea.tsx +17 -0
- package/template/apps/web/src/index.css +81 -0
- package/template/apps/web/src/lib/api.ts +396 -0
- package/template/apps/web/src/lib/auth.ts +10 -0
- package/template/apps/web/src/lib/bound/battery-form.ts +269 -0
- package/template/apps/web/src/lib/bound/display.ts +122 -0
- package/template/apps/web/src/lib/bound/fields.ts +128 -0
- package/template/apps/web/src/lib/bound/form-model.ts +521 -0
- package/template/apps/web/src/lib/bound/forms.ts +15 -0
- package/template/apps/web/src/lib/bound/identity.ts +48 -0
- package/template/apps/web/src/lib/bound/textile-form.ts +236 -0
- package/template/apps/web/src/lib/bound/units.ts +37 -0
- package/template/apps/web/src/lib/epcis.ts +345 -0
- package/template/apps/web/src/lib/format.ts +87 -0
- package/template/apps/web/src/lib/lifecycle.ts +350 -0
- package/template/apps/web/src/lib/session.tsx +92 -0
- package/template/apps/web/src/lib/use-load.ts +46 -0
- package/template/apps/web/src/main.tsx +18 -0
- package/template/apps/web/src/pages/accept.tsx +113 -0
- package/template/apps/web/src/pages/brand.tsx +94 -0
- package/template/apps/web/src/pages/brands.tsx +104 -0
- package/template/apps/web/src/pages/events.tsx +388 -0
- package/template/apps/web/src/pages/home.tsx +51 -0
- package/template/apps/web/src/pages/new-passport.tsx +137 -0
- package/template/apps/web/src/pages/operations.tsx +169 -0
- package/template/apps/web/src/pages/passport.tsx +632 -0
- package/template/apps/web/src/pages/public-passport.tsx +64 -0
- package/template/apps/web/src/pages/sign-in.tsx +93 -0
- package/template/apps/web/src/pages/verify.tsx +30 -0
- package/template/apps/web/src/pages/wallet.tsx +141 -0
- package/template/apps/web/tsconfig.json +29 -0
- package/template/apps/web/vite.config.ts +23 -0
- package/template/deploy/compose.yml +38 -0
- package/template/package.json +48 -0
- package/template/tsconfig.base.json +13 -0
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
# A Digital Product Passport application on BSV
|
|
2
|
+
|
|
3
|
+
Scaffolded by `@bsv/create-dpp-app`. Brands issue product passports as records on the BSV blockchain, hand them on along the supply chain, and anyone verifies a passport from its label. The records follow the open DPP standard; this application is one way of building what the standard requires, and every opinion it takes is yours to change.
|
|
4
|
+
|
|
5
|
+
The application uses `@bsv/dpp-protocol` directly and pins the `dpp-release-2026-11` runtime set, the set the DPP repository's index image builds. Keep the declared versions together. A project prepared from the repository before npm publication uses local candidate archives; those checks do not establish that a public npm installation is available.
|
|
6
|
+
|
|
7
|
+
## What you have
|
|
8
|
+
|
|
9
|
+
| Part | Where | What it does |
|
|
10
|
+
|---|---|---|
|
|
11
|
+
| Web app | `apps/web` | React single-page app: brand dashboard, passport pages, hand-on acceptance, public verification |
|
|
12
|
+
| API | `apps/api` | Express service that owns the platform wallet, writes and reads passports with the `@bsv/dpp` packages, validates product data against its profile, keeps the journal and runs the unattended duties. It answers each passport identifier as its GS1 resolver. It also imports, pulls and exports EPCIS events, as data kept apart from every passport |
|
|
13
|
+
| Application database | `deploy/compose.yml` | MongoDB for application records, journal and sign-in |
|
|
14
|
+
|
|
15
|
+
The API's routes are in [apps/api/API.md](apps/api/API.md).
|
|
16
|
+
|
|
17
|
+
For deployment, `npm run go-live` registers this app with the default hosted index; `npm run connect-index` takes another provider's or your own. The app's Compose file starts only its database. The index runtime is included for offline exercises; you do not install it separately or use the index in this process as persistent service storage.
|
|
18
|
+
|
|
19
|
+
## First run
|
|
20
|
+
|
|
21
|
+
No wallet, funds or Docker:
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
npm test
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
This runs a whole passport lifecycle against an index in this process and a test wallet with made-up funding: issue, update, hand on with a claim code, retire, and an EPCIS lifecycle claim, with the reader's report at the end. It also writes and reads a battery passport and a textile passport under the two sector profiles, and registers a profile from a folder.
|
|
28
|
+
|
|
29
|
+
The EPCIS tests need two things the project does not carry, and the first run fetches each once and keeps it:
|
|
30
|
+
|
|
31
|
+
| What | From | Kept in |
|
|
32
|
+
|---|---|---|
|
|
33
|
+
| The three EPCIS 2.0.1 files documents are checked against, which GS1 publishes under its own terms | `https://ref.gs1.org` | `node_modules/.cache/dpp-gs1`, or the folder `DPP_GS1_ARTEFACTS_DIR` names |
|
|
34
|
+
| A MongoDB server binary, for the tests of the EPCIS store on one MongoDB node in memory | MongoDB's download site, by `mongodb-memory-server` | That package's own cache |
|
|
35
|
+
|
|
36
|
+
Later runs use no network. A run that cannot obtain a GS1 file fails before any test and says which file. It never skips. Then:
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
npm run dev
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
The web app is on http://localhost:5173 and the API on http://localhost:3000. Without MongoDB the API keeps records in memory and signs you in as a developer with one development brand, so you can issue a passport, open its page, hand it on and accept it with the claim code, all without any service. The scaffold wrote `.env` with fresh secrets and the default testnet index; until `npm run go-live` has registered this app with it, the API runs an index in this process and the web app says so. Nothing reaches the chain: the wallet is a test wallet, and the index runs in-process with its header checks off.
|
|
43
|
+
|
|
44
|
+
## How a write works
|
|
45
|
+
|
|
46
|
+
Every state goes through six steps, in order, and the journal records each before it is acted on, so a retry continues and never builds a second transaction:
|
|
47
|
+
|
|
48
|
+
1. Build the state's transaction unsent, signed by the acting party and countersigned by the platform wallet.
|
|
49
|
+
2. Check it with the reader's own rules.
|
|
50
|
+
3. Announce it to the index. Send only if the index admits it; abort if it refuses. An unreachable index is not a refusal.
|
|
51
|
+
4. Send it, and report only the network's answer.
|
|
52
|
+
5. Push the merkle proof to the index once the wallet has it.
|
|
53
|
+
6. Keep the transaction, its BEEF and its proof for the passport's life.
|
|
54
|
+
|
|
55
|
+
Steps 3 and 5 can come later than the screen that caused them. The worker loop in the API does them from the journal; `npm run operations` shows what is still owed and runs one pass. Inside the container the same commands are `node apps/api/dist/cli.js operations` and `node apps/api/dist/cli.js wallet`.
|
|
56
|
+
|
|
57
|
+
## Custody: who signs
|
|
58
|
+
|
|
59
|
+
This application runs managed custody: the platform wallet funds and publishes each state. Each new passport output is locked to the controller key signed into that state. The platform manages the signing keys for brands, recipients and members. When updating an older passport that still carries the platform wallet’s per-passport lock, the writer spends that original output with the platform wallet and locks its successor to the signed controller. Sign-in decides who may act for which brand; the signature itself is always made with a platform-held key. A recipient of a hand-on needs no wallet: they accept with a claim code, and that code is how they act on the passport from then on.
|
|
60
|
+
|
|
61
|
+
This is a choice, not a rule of the standard. The standard lets any role be filled by a person's own BRC-100 wallet, and `apps/api/src/parties.ts` is the seam: a party that signs from a user's wallet replaces a managed identity without changing the writer. A passport can also leave managed custody by a transfer to a key the recipient's own wallet derived.
|
|
62
|
+
|
|
63
|
+
Under managed custody a compromised platform can forge what it holds. Keep the root key, the two identity secrets and the acceptance records as the secrets they are.
|
|
64
|
+
|
|
65
|
+
## Identifiers
|
|
66
|
+
|
|
67
|
+
Passports are GS1 Digital Links, `https://<PASSPORT_HOST>/01/<GTIN>/21/<serial>`. The default GS1 prefix, 952, is GS1's demonstration prefix, never licensed to anyone; every payload written under it starts with a notice saying nothing real stands behind it. When you hold a licensed GS1 company prefix, set `GS1_PREFIX` and the notice switches off. The API refuses any identifier outside the configured prefix and host, because a state under someone else's GTIN is permanent.
|
|
68
|
+
|
|
69
|
+
**The identifier host.** An identifier is a web address, and the code printed on a product carries the identifier itself, never the address of a page. The API answers every identifier it issued at the identifier's own path, as the standard's GS1 discovery profile asks of the host an identifier is minted under (`spec/gs1-discovery.md` §1): it is a GS1-Conformant Resolver for GTINs, made of the resolver helpers of `@bsv/dpp-profiles` in `apps/api/src/resolver.ts`. The passport page is at a path of its own, one redirect away.
|
|
70
|
+
|
|
71
|
+
| Request | Answer |
|
|
72
|
+
|---|---|
|
|
73
|
+
| `GET /01/<gtin>/21/<serial>` from a browser or a scanner | 307 to the passport page, `/passport/01/<gtin>/21/<serial>`, with the query string passed on |
|
|
74
|
+
| The same with `Accept: application/linkset+json`, or with `?linkType=linkset` | 200 with the linkset: the passport page under `gs1:dpp` as the item's default link, and the product page under `gs1:pip` as the default link of its GTIN |
|
|
75
|
+
| `GET /01/<gtin>`, or a serial nobody issued under a GTIN that has passports | 307 to the product page, `/passport/01/<gtin>`. It holds no passport and says so: it names the product and says where an item's passport is found |
|
|
76
|
+
| A compressed identifier, `/eh...` or `/ex...` | Decompressed, then answered as the identifier it spells |
|
|
77
|
+
| A malformed identifier | 400 `identifier-malformed`, with the reason |
|
|
78
|
+
| A GTIN no passport was issued under | 404 `identifier-unknown` |
|
|
79
|
+
| `GET /.well-known/gs1resolver` | The resolver description file |
|
|
80
|
+
|
|
81
|
+
The links are made from the journal, so an identifier resolves from the moment its passport is issued, and nothing is registered by hand. Only pages this application serves are listed. It lists no evidence package, because it serves none at an address of its own. Every answer allows any origin, and the host answers `GET`, `HEAD` and `OPTIONS`. `npm run dev` answers the same at http://localhost:5173, because Vite passes these paths to the API; only an `OPTIONS` request is answered by Vite itself. `apps/api/test/identifier-host.test.ts` asks each of these over HTTP and walks from an identifier to the verification of its passport.
|
|
82
|
+
|
|
83
|
+
Serve the application over HTTPS at `PASSPORT_HOST`: the identifier is an address under that host, and a scan goes there.
|
|
84
|
+
|
|
85
|
+
## Product documents under a binding
|
|
86
|
+
|
|
87
|
+
Besides the manifest profile `general@2`, the application writes and reads passports under profiles held by a binding: a data model defined outside the DPP packages, as JSON-LD contexts and SHACL shapes or as a JSON Schema, that one immutable `binding.json` pins file by file. The profiles package ships two editions each for the battery and textile data of one serialised item. New sector passports use `eu-battery@2` and `eu-textile@2`. Existing version 1 passports keep the binding named in their signed state. Each name states which data model a product document uses. Neither claims that a passport or a product complies with any law.
|
|
88
|
+
|
|
89
|
+
The original sector bindings replaced the earlier manifest profiles `battery@2`, `battery@3`, `battery@4` and `textile@1` to `textile@4`, which are retired. The application offers none of them and refuses every write under one with `profile-retired`. A passport already in the journal under one is still shown, with its profile reported as retired and not checked, and it gets no further state, hand-on or claim. Nothing converts it: issue a new passport under the replacement.
|
|
90
|
+
|
|
91
|
+
Under such a profile a passport carries one product document, and the binding lists which of its top-level properties are public. The rest are restricted.
|
|
92
|
+
|
|
93
|
+
| Part | Where it goes | Who reads it |
|
|
94
|
+
|---|---|---|
|
|
95
|
+
| Public properties | The state's public payload, on chain | Anyone, for good. It cannot be withdrawn or redacted |
|
|
96
|
+
| Restricted properties | Encrypted to the holder's key and kept in the journal, as every owner tier is. Only the hash of the ciphertext is on chain | The holder |
|
|
97
|
+
|
|
98
|
+
The split is by property, not by value. A restricted value that you repeat inside a public property, such as a name in a description or a link to a private file, is published with that property. The form labels every property Public or Restricted before you submit and asks you to confirm the public list.
|
|
99
|
+
|
|
100
|
+
**Writing.** Choose `eu-battery@2` or `eu-textile@2` when you issue a passport. The form asks for the item reference and serial once, and writes the document's identifier, GTIN and serial from them, so they cannot disagree with the passport identifier. A field left empty is absent from the document: the form makes up no identifier, classification, date, unit or precision, and a number is written with the digits you typed. A measurement is a value with its unit. **Load example** fills the form with invented data under the demonstration prefix, and **Load a document from a file** takes a product document of your own in the profile's data model. A property the form has no field for is kept as JSON under **Other properties** and written unchanged.
|
|
101
|
+
|
|
102
|
+
The API validates the whole document against the passport identifier it is about to sign, splits it, and signs exactly the public payload the profiles package returns. A document that fails, that could not be checked, or whose public part is over 65,535 bytes is refused before anything is signed, and the form shows each finding at the field it concerns.
|
|
103
|
+
|
|
104
|
+
**Reading.** A passport page shows the product data as structure, each property with its tier, and two checks that are kept apart:
|
|
105
|
+
|
|
106
|
+
| Check | Who sees it | What it says |
|
|
107
|
+
|---|---|---|
|
|
108
|
+
| Public view | Anyone | The public payload carries public properties only, keeps every rule it could break, and describes this passport's item. It says nothing about restricted data |
|
|
109
|
+
| Authorised view | The holder | The public payload rejoined with the restricted part satisfies the profile |
|
|
110
|
+
| Owner-tier check | The holder | The stored ciphertext hashes to the state's `payload_owner_hash`. This is the protocol's check, and the only statement about the on-chain commitment |
|
|
111
|
+
|
|
112
|
+
A check that could not run is shown as **Not checked**, never as passed. On a managed transfer the giver checks the restricted bytes against the signed predecessor, encrypts their contents to the recipient and commits the new ciphertext. The recipient can open it immediately. An older transfer that kept the original ciphertext still needs the key used for that ciphertext.
|
|
113
|
+
|
|
114
|
+
**The validation engine.** The engine that checks a product document is a setting, and the application is the same either way (`apps/api/src/validation-engine.ts`).
|
|
115
|
+
|
|
116
|
+
| `VALIDATOR_URL` | Where the JSON-LD and SHACL engines run | What it needs |
|
|
117
|
+
|---|---|---|
|
|
118
|
+
| Unset, the default | In the API's own process | `jsonld`, `n3` and `shacl-engine`, which `apps/api` depends on at the versions `@bsv/dpp-profiles` is tested with |
|
|
119
|
+
| The address of a validator service | In that service, asked through the client of `@bsv/dpp-profiles/validator-client` | The service's address, and `VALIDATOR_TOKEN` when it requires a token |
|
|
120
|
+
|
|
121
|
+
The service is an engine and nothing more. The registry, the binding digests you trust, the split into public and restricted parts and the comparison with the passport identifier all stay in the API. The service is sent the product document and the rule files of its binding, so point `VALIDATOR_URL` only at a service you would show a restricted product document to. The token is sent to that address and nowhere else, and is never logged or returned.
|
|
122
|
+
|
|
123
|
+
Three ways to have a service: the validator of the DPP repository's operator preset, which an index operator runs; `npx dpp-validator` in this project, which starts the same code on `127.0.0.1:8090` and reads `VALIDATOR_HOST`, `VALIDATOR_PORT` and `VALIDATOR_TOKEN`; or any other service that keeps the `dpp-validator/1` contract.
|
|
124
|
+
|
|
125
|
+
Whichever engine is chosen, one rule holds: an engine that cannot be used is never a pass. Libraries that did not load, and a service that is stopped, slow, behind a wrong token or answering something else, all give the same result. A profile held by a binding cannot be written, the form says so with the reason, and every reading says **Not checked**. The API asks a service again whenever the health answer, the form or the Operations page is loaded, so a service that comes back is used without restarting the API. Libraries that did not load need a restart. `apps/api/test/validation-engine.test.ts` runs the same passports through both engines, then stops the service.
|
|
126
|
+
|
|
127
|
+
In both modes every context and rule file is read from the binding, and nothing is fetched.
|
|
128
|
+
|
|
129
|
+
**Where the profiles are read from.** By default all four sector bindings are read from the folder the profiles package ships. With `PROFILE_BUNDLE_DIR` set they are read from a profile bundle in that folder, which is where a [restore](#export-and-restore) installs the profiles a package carries, and the package's own folder is not read. Trust does not change with the source: a sector profile is accepted only under the digest your installed profiles package publishes for it, and any other binding only when its digest is in `TRUSTED_BINDING_DIGESTS`.
|
|
130
|
+
|
|
131
|
+
**Sector editions.** The issue form offers `eu-battery@2` and `eu-textile@2`. Each checks the signed subject's product type, including subclasses declared in its pinned ontology. Asking the API to issue explicitly under `eu-battery@1` or `eu-textile@1` returns HTTP 409 with `profile-superseded` and the current profile in `replacedBy`. A holder can still read, update and hand on an existing version 1 passport under its original binding.
|
|
132
|
+
|
|
133
|
+
To exercise the current editions locally, run `npm run dev` with `LIVE_PUBLISHING=false`, select the version 2 profile by name in the issue form and load its example. The public reading shows its public properties. The holder's authorised reading also opens the sealed restricted properties. An application that reads bindings from `PROFILE_BUNDLE_DIR` needs the current edition there to issue under it, and the historical edition there to read and maintain an existing version 1 passport.
|
|
134
|
+
|
|
135
|
+
**A profile of your own.** Put its `binding.json` and the files it names in a folder ([how to write a binding](https://github.com/bsv-blockchain/dpp/blob/main/docs/packages/dpp-profiles.md#write-a-binding)), then name the folder and trust its binding in `.env`:
|
|
136
|
+
|
|
137
|
+
```sh
|
|
138
|
+
CUSTOM_PROFILE_DIRS=profiles/example-bottle@1
|
|
139
|
+
TRUSTED_BINDING_DIGESTS=<the SHA-256 of that folder's binding.json>
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
`shasum -a 256 profiles/example-bottle@1/binding.json` prints the digest. Trust is that digest: the API registers the folder at start only when its `binding.json` has a listed digest and every file it names matches the length and SHA-256 the binding records. A folder that is not trusted, or that changed since you trusted it, is refused by name in the start-up log and on the Operations page, and the application runs without it. No source file changes. `apps/api/test/fixtures/custom-profile/` holds two example profiles to try this with, and `apps/api/test/custom-profile.test.ts` shows them trusted, untrusted and altered. A profile with no form in the web app is written as a JSON document, with the same labels and the same warning.
|
|
143
|
+
|
|
144
|
+
Restricted values never reach the application's logs, its listings, the index or any public export: `apps/api/test/bound-http.test.ts` issues passports carrying a value that appears nowhere else and searches all of them for it.
|
|
145
|
+
|
|
146
|
+
## Lifecycle claims
|
|
147
|
+
|
|
148
|
+
A lifecycle claim is a signed statement of something that happened to a product, on its own rail: it never spends a passport. This application issues EPCIS lifecycle claims, `dpp-epcis-lifecycle@1`. Each one is one EPCIS 2.0.1 event, of the five types (`ObjectEvent`, `AggregationEvent`, `TransactionEvent`, `TransformationEvent`, `AssociationEvent`), in a signed envelope that binds it to the passports whose products it names and says in which role the signer signs: `observer`, `owner`, `custodian` or `authorised-reporter`. On a passport's page, **Sign a lifecycle claim** takes the event in one of two ways:
|
|
149
|
+
|
|
150
|
+
- **Enter the event.** The form asks for what EPCIS records: the event type, the action where the type has one (a transformation has none), the business step, the disposition, the identifiers in each role (objects, a parent and its contents, inputs and outputs, quantities of a class), the read point and business location, the source and destination parties and places, business transactions, and sensor elements as EPCIS JSON.
|
|
151
|
+
- **A retained event.** An event the EPCIS exchange retained is signed exactly as it was received, with a `source` link to its import and the import's digest. Whoever supplied it observed it, not you, so it is never signed as `observer`.
|
|
152
|
+
|
|
153
|
+
The bindings come from the event's own identifiers, matched to this platform's passports under the identity rules of `@bsv/dpp-profiles`: an item identifier binds that item's passport, written as a GS1 Digital Link or an EPC URN, and a quantity element's class binds every passport of that class at class level only, which never says an item took part. Nothing is made from a passport operation, a metadata edit or a sale: an event that names none of this platform's passports binds nothing and is refused. The pinned EPCIS 2.0.1 schema is applied before anything is signed, from the GS1 files the EPCIS exchange obtained.
|
|
154
|
+
|
|
155
|
+
**Configure signing authority.** The operator records a grant after checking the member's authority for a role and passport. The API requires a matching issuer DID, compressed identity key, passport identifier, role, purpose and event time for every passport the event binds. Its wallet signs only after those checks pass. Keep the grant file in operator-controlled configuration outside the served web directory. Set `LIFECYCLE_AUTHORITY_GRANTS_FILE` to its absolute path and restart the API with that configuration.
|
|
156
|
+
|
|
157
|
+
To prepare one entry from the generated project's root, use the same managed identity configuration as the running API. Set `MEMBER_ID` to the verified member's application user ID and `PASSPORT_ID` to the exact passport identifier. The member's own signed-in `GET /api/me` response identifies their `userId`. This example prints the complete JSON document for one `observer` grant on the sample dates. Review its contents and dates before saving it to the configured file.
|
|
158
|
+
|
|
159
|
+
```sh
|
|
160
|
+
node --import tsx --input-type=module <<'JS'
|
|
161
|
+
import './apps/api/src/env.ts'
|
|
162
|
+
import { loadConfig } from './apps/api/src/config.ts'
|
|
163
|
+
import { managedParties } from './apps/api/src/parties.ts'
|
|
164
|
+
|
|
165
|
+
const { MEMBER_ID, PASSPORT_ID } = process.env
|
|
166
|
+
if (!MEMBER_ID || !PASSPORT_ID) throw new Error('Set MEMBER_ID and PASSPORT_ID.')
|
|
167
|
+
const issuer = managedParties(loadConfig()).member(MEMBER_ID)
|
|
168
|
+
console.log(JSON.stringify({ grants: [{
|
|
169
|
+
issuer: issuer.did, issuerKey: issuer.identityKey, passportId: PASSPORT_ID,
|
|
170
|
+
role: 'observer', purpose: 'claim',
|
|
171
|
+
validFrom: '2026-01-01T00:00:00Z', validUntil: '2027-01-01T00:00:00Z',
|
|
172
|
+
}] }, null, 2))
|
|
173
|
+
JS
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
The interval includes `validFrom` and ends immediately before `validUntil`. It applies to the EPCIS event's `eventTime`. Supported roles are `observer`, `owner`, `custodian` and `authorised-reporter`. Imported events are reported in an allowed non-observer role. An issuer declaring its own event in error still needs its ordinary role grant. To correct another issuer's original, it also needs a matching grant with purpose `error-declaration`. An unreadable or malformed configured file stops the API at startup. Leaving the setting unset allows the API to start, and signing returns `authority-unavailable`. A configured source with no matching grant returns `authority-unconfirmed`. A two-product event requires a grant for each bound passport. A request that supplies only part of that scope returns `authority-scope-incomplete`. The caller cannot add a grant through the claim request.
|
|
177
|
+
|
|
178
|
+
The member's managed wallet signs the claim's RFC 8785 bytes. Sending it to `REGISTRY_URL` is a separate step the member ticks: the registry verifies it, keeps the exact bytes and anchors them once for each bound passport, all in one transaction on the index's `tm_attestation`. Check the configured registry’s advertised representation before requesting submission. Its intake response records whether it accepted the claim.
|
|
179
|
+
|
|
180
|
+
**Reading.** A passport's page, public or not, lists the claims that concern it: those whose anchors name it as their subject, and those this application holds that bind it. Each is verified, and only a verified binding says whether this passport took part, its item or only its class. An anchor that names a passport the claim does not bind is listed as found and not established. Every finding is shown on its own line: event structure, event semantics, product binding, signature, authority, possession, ownership, anchor, inclusion and correction. What was not checked reads unknown. The authority result reports what the configured evidence establishes for the issuer, role and event time within the original signed scope. A historical or external claim can bind two products and declare a role for only one. Each product page lists that scope and states whether it includes the current passport. Signature, possession and ownership remain distinct findings. An anchor proves an anchoring service's commitment to the bytes, not that the event happened, who owns the product or that anything complies with a rule.
|
|
181
|
+
|
|
182
|
+
**Corrections.** **Declare in error** signs a new claim that carries the same event with an EPCIS error declaration. The original signed bytes are retained. The reader reports a verified declaration by the original issuer.
|
|
183
|
+
|
|
184
|
+
**Historical native claims.** Native claims with one of four event types, `dpp-lifecycle-v1`, are no longer issued here. Those this application issued before are kept exactly as they were signed, still verify under their own rules, and are shown apart, labelled as historical native claims. Their category is not read as an EPCIS event. Other producers of native claims, including any deployed application built from an earlier version of this starter, still issue that format until they change, so a reader keeps verifying it.
|
|
185
|
+
|
|
186
|
+
`GET /api/lifecycle-claims/:id` returns a claim's exact bytes, and an export carries every claim this application holds as those bytes, which the restoring deployment verifies before it writes anything.
|
|
187
|
+
|
|
188
|
+
## EPCIS exchange
|
|
189
|
+
|
|
190
|
+
The application imports EPCIS 2.0 documents, pulls events from a source you configure, and gives back exactly what it received. All of it is `@bsv/dpp-credentials/epcis-exchange`: the application supplies the storage, the routes and the pages, and does none of the module's work a second time.
|
|
191
|
+
|
|
192
|
+
**What an event here is.** Data a source supplied. An import or a pull changes no custody, signs nothing, writes nothing on chain and never calls the wallet. A document that is **valid** passed a check of its format. It is not signed, and nothing verifies who observed an event or that it happened. The pages label every event that way, and a passport's page lists the events that name its product in a section of their own, apart from the states and claims that are the passport's own record.
|
|
193
|
+
|
|
194
|
+
| You want to | Where |
|
|
195
|
+
|---|---|
|
|
196
|
+
| Upload a document and see whether it was refused or retained, with its findings | **Events**, then **Upload a document** |
|
|
197
|
+
| Pull events from a configured source | **Events**, then **Pull from a source** |
|
|
198
|
+
| Find the events that name an identifier | **Events**, or the section at the foot of a passport's page |
|
|
199
|
+
| Download a document as it was received | **Download** beside an import or an event |
|
|
200
|
+
| Do the same from a script | The routes under `/api/epcis` in [apps/api/API.md](apps/api/API.md#epcis-exchange) |
|
|
201
|
+
|
|
202
|
+
**The GS1 files.** A document is checked against three files GS1 publishes under its own terms, which this project does not contain. The API obtains them at start, once, from `https://ref.gs1.org` into `DPP_GS1_ARTEFACTS_DIR` (`local/gs1`), checks every byte against a pinned digest, and logs one line saying whether they were present, fetched or unavailable. If they are unavailable the API still starts, and every import and pull is refused with how to provide them: start again with network access, run `npx dpp-gs1-artefacts fetch --dir <folder>`, or place the files in the folder yourself. With `DPP_GS1_ARTEFACTS_OFFLINE=true` the API never fetches.
|
|
203
|
+
|
|
204
|
+
**Uploading.** The page sends the file as the bytes it is, with a request identifier it chose for that file. The API digests and keeps those bytes and never writes them out again from a parsed form, so an export is the original, byte for byte, under the media type it arrived with. Sending the same file again under the same identifier is the same request and keeps one import. The same identifier with other bytes is refused, and the first import stands. A transport that cannot be kept, such as a body that is not JSON, is over the size limit or has the wrong media type, is refused with a status that says why, and nothing of it is kept. A document that parses and fails validation is kept, with its findings, and reads **Invalid format**.
|
|
205
|
+
|
|
206
|
+
**A source to pull from.** A source is configuration on the server. Nothing about it comes from a request. Name it in `.env`, then set its address and, if it needs one, its credential:
|
|
207
|
+
|
|
208
|
+
```sh
|
|
209
|
+
EPCIS_SOURCES=supplier-a
|
|
210
|
+
EPCIS_SOURCE_SUPPLIER_A_URL=https://events.example.org/epcis
|
|
211
|
+
EPCIS_SOURCE_SUPPLIER_A_BEARER_TOKEN=<the token the source gave you>
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
| Setting, after `EPCIS_SOURCE_<NAME>_` | Meaning |
|
|
215
|
+
|---|---|
|
|
216
|
+
| `URL` | The base address of the source's query interface. Events are asked for at `<URL>/events` |
|
|
217
|
+
| `ORIGINS` | Every origin a request may go to, comma-separated. Empty permits the address's own origin only. A redirect or a next page anywhere else is refused before it is requested |
|
|
218
|
+
| `BEARER_TOKEN`, or `BASIC_USER` with `BASIC_PASSWORD`, or `HEADER_NAME` with `HEADER_VALUE` | The credential, when the source needs one. At most one kind |
|
|
219
|
+
| `LOCAL_TEST` | `true` permits plain `http` and private addresses. Off unless you set it, for a source on your own machine only. The API's description of the source and every result of a pull say when it is on |
|
|
220
|
+
| `REPEAT_LISTS` | `true` sends each value of a list as its own parameter, for a source that does not read the pipe-delimited form. Recorded with each pull as a leniency |
|
|
221
|
+
|
|
222
|
+
The credential stays in `.env` and the API's memory. It is sent to the address's own origin and to no other. It is never written to the database, an answer, a log line or the web app: `GET /api/epcis/sources` says that a credential is set and which kind, and `apps/api/test/bound-http.test.ts` pulls with a credential that appears nowhere else and searches everything the application answers, stores, exports and prints for it.
|
|
223
|
+
|
|
224
|
+
**Pulling.** One pull is one bounded run: it reads a limited number of pages and stops. Give the query a name. Running it again under that name continues from where it stopped, also after a restart, and no page is lost or kept twice. The outcome is shown in the module's own words: its outcome, its reason and whether the source's pages were exhausted. A run that ended early says the history is partial, and no run says a source's history is complete.
|
|
225
|
+
|
|
226
|
+
**The store.** With MongoDB the application keeps imports in four collections of the application database, through `apps/api/src/epcis/mongo-storage.ts`. Without MongoDB they are held in memory and are gone when the API stops. The module asks one hard thing of a store: a batch of records is written whole or not at all, also across a crash. One MongoDB node has no multi-document transaction, so the adapter does not use one:
|
|
227
|
+
|
|
228
|
+
1. It checks what the batch expects, then replaces one log document with the whole batch, on the condition that no other batch was committed meanwhile. That one conditional update of one document is the commit, acknowledged from the journal.
|
|
229
|
+
2. It applies the batch record by record and marks the log document idle.
|
|
230
|
+
3. A store that stopped in between finds the committed batch when it is next opened and applies it again. That is safe: each write sets a whole value, and only on a record an earlier batch wrote last. A deleted record leaves a small marker so that an old batch applied late cannot bring it back.
|
|
231
|
+
|
|
232
|
+
A reader takes its answer between two looks at the log document, and takes it again if a batch moved meanwhile, so it never sees part of a batch. `apps/api/test/epcis-mongo-storage.test.ts` runs the module's own adapter suite against one MongoDB node in memory, then stops the adapter at every step it takes in the database.
|
|
233
|
+
|
|
234
|
+
Two things to know about that store. A batch is one MongoDB document until it is applied, so a single record or batch past 15 MiB is refused, with nothing written. The limits in force, 2 MiB a document and 100 events a page, keep an ordinary document far below that. A document made of hundreds of thousands of very short identifiers can pass it, and its import is then refused as `record-too-large`. And the markers deleted records leave are not removed: there is one small one for each finished import.
|
|
235
|
+
|
|
236
|
+
**Another store.** `EPCIS_STORAGE=file` keeps the exchange in a folder, `EPCIS_STORAGE_DIR` (`local/epcis-store`), through the file-system adapter that `@bsv/dpp-credentials/epcis-exchange` ships. It passes the same adapter suite and is handed to the module as the same six methods. It is here to show that the store is a boundary you can replace, and it is what the exit exercise restores into. It is one process on one machine's disk, with no replication: MongoDB is the store this application is built and tested on, and the file adapter is not offered as a second production database. An adapter for another database is yours to write against the same suite.
|
|
237
|
+
|
|
238
|
+
**At start.** Before it accepts a request the API runs the module's recovery, which finishes or discards whatever a stopped process left, and logs what it did. Recovery assumes nothing else is writing to the store. Start one API process at a time, so that one is not importing while another recovers.
|
|
239
|
+
|
|
240
|
+
## Export and restore
|
|
241
|
+
|
|
242
|
+
The whole application can be exported as one signed evidence package and restored into another deployment: another host, another database, another provider. Both are operator commands, run on the host with the API and its worker stopped. There is no route for either. The API has no operator role, and a signed-in member of a brand is not the operator of the deployment, so the authorisation is the one the deployment already rests on: whoever can run a command with its settings.
|
|
243
|
+
|
|
244
|
+
```sh
|
|
245
|
+
npm run export -- --out ../my-dpp-export # everything, for your own recovery or a move
|
|
246
|
+
npm run export -- --out ../my-dpp-public --public # only what anyone may hold
|
|
247
|
+
npm run restore -- --from ../my-dpp-export --exporter-key <publisher key of the deployment that exported>
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
To exercise the proposed custody export profile, add `--custody-profile managed-custody@3` to the public or authorised export command. A public package identifies withheld and missing acceptances by commitment. A recovery package carries completed acceptances held in the journal or in a retained offer. A signed handover awaiting transfer stays with its offer. Add `--require-custody-profile managed-custody@3` to restore when the replacement requires these rules. Earlier packages can still be read under their original edition.
|
|
251
|
+
|
|
252
|
+
An export is one `dpp-evidence-package@1`: a folder of files under a manifest, `manifest.json`, that this application signs with a key derived from its publisher key. Every file is listed once in the manifest, with its length and SHA-256.
|
|
253
|
+
|
|
254
|
+
| In the folder | What it is | Authorised export | Public export |
|
|
255
|
+
|---|---|---|---|
|
|
256
|
+
| `passports/<n>/index/` | The index's own signed evidence for the passport, exactly as the index exported it: transactions, proofs, its publisher policy and its report | Carried | Carried |
|
|
257
|
+
| `passports/<n>/reading.json` | How the passport verified here when it was exported: each check and each finding, no values | Carried | Carried |
|
|
258
|
+
| `passports/<n>/journal.json` | This application's journal: each state's bytes, its sealed owner tier, who holds the passport | Carried | Left out |
|
|
259
|
+
| `passports/<n>/authority/` | Each acceptance record a hand-on commits to | Carried | Left out |
|
|
260
|
+
| `application/brands/`, `offers/`, `claims/` | The brands, hand-on offers and lifecycle claims that belong to those passports | Carried | Left out |
|
|
261
|
+
| `application/lifecycle-claims/` | Each EPCIS lifecycle claim's exact signed bytes, once however many carried passports it binds | Carried | Left out |
|
|
262
|
+
| `profiles/` | The profile bundle of `@bsv/dpp-profiles`: each binding the passports declare, every file it lists, its notices and licence text | Carried | Carried |
|
|
263
|
+
| `epcis/` | The EPCIS exchange, from `@bsv/dpp-credentials/epcis-exchange` | The recovery snapshot of every source scope: originals, import records, observations, conflict decisions and pull state | The public form, and only of the source scopes you name with `--public-source` |
|
|
264
|
+
| `application/application-export.json` | The descriptor: what the export covers, what it names without carrying, and what it leaves out | Carried | Carried |
|
|
265
|
+
|
|
266
|
+
Neither export holds a key, a wallet file, a secret or a credential, and before a folder is written every byte is searched for each secret this deployment was configured with. The files GS1 publishes are named in the manifest by address and digest and are never carried. An authorised export does hold restricted records, sealed as they were: treat the folder as you treat the database. A public export is not a backup, and a restore refuses it.
|
|
267
|
+
|
|
268
|
+
**Restoring.** Configure the new deployment first: its own `MONGO_URL`, its index, and whichever store and profile source it is to use. Then run `restore`. In order, it:
|
|
269
|
+
|
|
270
|
+
1. Verifies the package before it writes anything: the manifest's signature under the exporter key you gave, every file against the manifest, each journal as a lineage that verifies, the index's signature on its evidence, the profile bundle against the digests this deployment trusts, and the EPCIS snapshot by the module's own checks.
|
|
271
|
+
2. Compares the package with what the deployment already holds. An equal record is left alone. A different record under the same identity stops the restore with nothing written: a restore never overwrites.
|
|
272
|
+
3. Restores the exchange into the configured store, installs the profile bundle into `PROFILE_BUNDLE_DIR` when that is set, and writes the journals, brands, offers and claims.
|
|
273
|
+
4. Rebuilds what is derived: the exchange's index of identifiers, and the index's records of each passport, by announcing each state's own bytes to the index this deployment has joined.
|
|
274
|
+
5. Reads every passport again here and compares the result with `reading.json`, check for check.
|
|
275
|
+
|
|
276
|
+
It ends with a report of what it wrote, what it left, what you still have to provide and anything that needs attention. Run twice, it changes nothing the second time.
|
|
277
|
+
|
|
278
|
+
| A package that | Is refused as |
|
|
279
|
+
|---|---|
|
|
280
|
+
| Is signed by another key than the one you gave | `exporter-unexpected` |
|
|
281
|
+
| Lacks a file its manifest lists, or a record its descriptor counts | `package-incomplete`, naming what is missing |
|
|
282
|
+
| Holds a file that is not the bytes the manifest lists, or one the manifest does not list | `file-altered`, `file-unlisted` |
|
|
283
|
+
| Carries another definition under a profile's name, whoever signed it | `profile-refused` (`bundle-binding-substituted` or `bundle-binding-untrusted`) |
|
|
284
|
+
| Carries a pull checkpoint without its imports, a conflict decision without its observations, or an altered original | `epcis-refused`, with the module's own code |
|
|
285
|
+
| Is a public export | `not-a-recovery-package` |
|
|
286
|
+
|
|
287
|
+
**What an export does not carry, and you provide at the new deployment.**
|
|
288
|
+
|
|
289
|
+
| What | How it gets there |
|
|
290
|
+
|---|---|
|
|
291
|
+
| The wallet's root key and file | The wallet's own recovery. Set `WALLET_ROOT_KEY` to the same key, and restore or rebuild the wallet file |
|
|
292
|
+
| `BRAND_ROOT_SECRET` and `MANAGED_IDENTITY_SECRET` | Your own handling of secrets. Brand, recipient and member keys are derived from them, so they must be the same |
|
|
293
|
+
| The index's address and this application's tokens | `npm run connect-index` or `npm run go-live`. The index must admit the same publisher key |
|
|
294
|
+
| Each EPCIS source's credential | The `EPCIS_SOURCE_<NAME>_` settings. The restore's report names each source and says whether its credential is set |
|
|
295
|
+
| The GS1 files | The API obtains them at start, or you place them |
|
|
296
|
+
| Sign-in accounts, sessions and brand memberships | Not carried. See below |
|
|
297
|
+
|
|
298
|
+
Without the keys the new deployment reads every passport and can write none of them. It verifies each as before, except for the issuer's authority, which it reports as `authority-unconfirmed`: it takes the issuer's key from its own `BRAND_ROOT_SECRET`, never from the package. That is the custody rule and no export changes it: continuing to sign needs the authorised keys, and they travel by the wallet's own recovery, never in a package.
|
|
299
|
+
|
|
300
|
+
**After a restore.** An unfinished pull continues once its source's credential is set. A cursor is left out of an export unless you pass `--cursors include`, so the pull asks again from its retained bounds and recognises what it already holds: no page is skipped and no event is kept twice. If the source is now reached at another address, set that address in `.env` and run `npm run epcis-remap -- --source <name>` once, which binds every pull of the source to it and keeps the source's identity. A request a client sends again answers the import it made before, with no new receipt.
|
|
301
|
+
|
|
302
|
+
**What cannot be recovered this way.** A lost key. Sign-in: accounts, sessions and memberships are not exported, and a brand is tied to its sign-in organisation by its identifier, so a deployment that uses sign-in must move the sign-in collections of its database by its own means or attach members to the restored brands again. The index's own state beyond these passports. The daily spend counter. Anything the first deployment never retained.
|
|
303
|
+
|
|
304
|
+
`apps/api/test/exit-exercise.test.ts` is the whole of this as a test: it builds a deployment on MongoDB with a battery and a textile passport and an EPCIS exchange, exports it, switches it off, restores into a deployment that keeps the exchange in the file adapter and reads profiles from the bundle, with every upstream host out of reach, and continues there. It runs `npm run export` and `npm run restore` as you would, and restores the same package into a deployment without the keys, which reads both passports and refuses an `UPDATE` by name.
|
|
305
|
+
|
|
306
|
+
## Going live
|
|
307
|
+
|
|
308
|
+
```sh
|
|
309
|
+
npm run go-live
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
One command checks everything a real write needs and names the fix for each failure; nothing reaches the chain until every check passes. In order:
|
|
313
|
+
|
|
314
|
+
1. **Configuration.** The secrets in `.env` are not placeholders; `INDEX_URL` is set and a hosted index matches `NETWORK` (`https://dpp-overlay-testnet.bsvb.net` is `test`, `https://dpp-overlay-mainnet.bsvb.net` is `main`); on mainnet, `GS1_PREFIX` is a prefix licensed to you and `PASSPORT_HOST` a host you serve.
|
|
315
|
+
2. **Wallet.** The first run generates `WALLET_ROOT_KEY` into `.env` and prints the publisher key. Back the file up: a root key alone is not a full wallet backup, so read the wallet toolbox's recovery guidance and keep the SQLite file in `local/` on a persistent volume.
|
|
316
|
+
3. **Index.** The index answers, serves the same network, and admits under the managed custody profile this app writes.
|
|
317
|
+
4. **Registration.** The app signs a registration request with its wallet and sends it to the index's `POST /register`; the index names the publisher key in its policy and answers with the app's two write tokens, which go into `.env`. An index whose operator approves registrations holds the request; run `go-live` again once approved. An index that does not register publishers says so and names `connect-index`.
|
|
318
|
+
5. **Funds.** The wallet holds enough for a few states. If not, the command prints a funding address and the `wallet fund` command that takes the payment in. A state costs a little over a hundred satoshis and leaves one satoshi in the passport output.
|
|
319
|
+
6. **Admission.** The index now names the key.
|
|
320
|
+
|
|
321
|
+
Then `LIVE_PUBLISHING=true` is written and the next write spends real satoshis. With a funded wallet and live publishing off, the writer checks the draft and aborts it before sending. It requests draft admission only at an index that supports retraction. `SPEND_CAP_SATOSHIS` refuses writes once the platform has spent that much in a day.
|
|
322
|
+
|
|
323
|
+
Mainnet needs MongoDB (`docker compose -f deploy/compose.yml --env-file .env up -d mongo`, or a hosted one, in `MONGO_URL`) for sign-in and persistence, a WhatsOnChain API key in `WOC_API_KEY` for the wallet's monitor and the reader, `NETWORK=main` with `INDEX_URL=https://dpp-overlay-mainnet.bsvb.net`, and your own `PASSPORT_HOST` and `GS1_PREFIX`. Changing an identity secret changes every key derived from it, so decide `BRAND_ROOT_SECRET` and `MANAGED_IDENTITY_SECRET` once.
|
|
324
|
+
|
|
325
|
+
## Connect an index
|
|
326
|
+
|
|
327
|
+
Readers use the index to find passports and their evidence. The starter announces drafts to its in-process index and to the two hosted reference index base URLs before sending them. If the wallet refuses a draft, the starter asks that index to withdraw it. The technology behind it is a BSV overlay service. It admits only states countersigned by a publisher key it names, and it follows this app's custody model. Three routes; this app's Compose file starts only the application database.
|
|
328
|
+
|
|
329
|
+
**The default index.** `.env` names the hosted testnet index, and `npm run go-live` registers this app with it. Mainnet is `INDEX_URL=https://dpp-overlay-mainnet.bsvb.net` with `NETWORK=main`, where the operator approves each registration.
|
|
330
|
+
|
|
331
|
+
**Another provider's index.** `npm run connect-index -- --url https://index.example` writes the address and runs the checks; `go-live` then registers if the index registers publishers. A provider that hands out tokens itself: `npm run connect-index -- --url https://index.example --submit-token <t> --callback-token <t>`. Match the wallet's network and the managed custody profile; public lookup access alone is insufficient.
|
|
332
|
+
|
|
333
|
+
**Your own index.** Run it from the DPP repository's operator preset, `deploy/` in [github.com/bsv-blockchain/dpp](https://github.com/bsv-blockchain/dpp): the index image and a persistent MongoDB on Docker Compose, configured from one env file. Give it this app's publisher key as `SERVICE_IDENTITY_KEY`, and this app's `NETWORK`: `npm run wallet` prints the key, and its first run generates `WALLET_ROOT_KEY` into `.env` (back the file up). Once the index runs, its `dpp-index connection` command writes the connection file; `npm run connect-index -- --from <that file>` here writes the address and both tokens to `.env` and runs the go-live checks, and when every check passes it switches live publishing on. After fixing a failed check, such as funds, run `npm run go-live`. The preset's README covers hosting, backup and recovery.
|
|
334
|
+
|
|
335
|
+
| App setting | Meaning |
|
|
336
|
+
| --- | --- |
|
|
337
|
+
| `INDEX_URL` | Index address reachable from the API |
|
|
338
|
+
| `INDEX_RETRACTION_URL` | For a custom index that supports `POST /retract`, set this to its exact `INDEX_URL` to enable draft admission. |
|
|
339
|
+
| `INDEX_SUBMIT_TOKEN` | Submission and retraction access, from registration or the operator |
|
|
340
|
+
| `INDEX_CALLBACK_TOKEN` | Proof-delivery access, from registration or the operator |
|
|
341
|
+
| `NETWORK` | The same network as the wallet and index |
|
|
342
|
+
|
|
343
|
+
For other indexes the starter sends the transaction first by default. If admission then fails, the journal keeps the completed write and the worker retries the original BEEF in spend order. Confirm custom retraction support with the index operator before setting `INDEX_RETRACTION_URL`. Its value only enables draft admission for that base URL.
|
|
344
|
+
|
|
345
|
+
Before changing index, settle outstanding drafts and deliver pending proofs to the original index. An interrupted draft records which index may hold it. A withdrawal from a different index leaves the draft pending until the original index reconciles it. For journals created by older starter versions, the operator must reconnect the original index. The in-process development index forgets its outputs and changes address at restart. Use a persistent external index for recoverable deployments. The worker offers proofs to its currently configured index.
|
|
346
|
+
|
|
347
|
+
Restart the app after changing its settings. Keep the tokens out of browser code. For an API running in Docker, use an index address reachable from that container; `localhost` refers to the API container itself. The app announces to `INDEX_URL` once it holds both tokens; before that it runs an index in this process, and a connection failure does not cause another index to start.
|
|
348
|
+
|
|
349
|
+
## Deploy
|
|
350
|
+
|
|
351
|
+
Build the published starter with `docker build -t my-dpp .`. If `.candidate.Dockerfile` is present, use `docker build -f .candidate.Dockerfile -t my-dpp .` to include the local dependency archives.
|
|
352
|
+
|
|
353
|
+
To run the image with the supplied MongoDB service, start MongoDB and join its Compose network. Inside the app container, `mongo` resolves to the database service.
|
|
354
|
+
|
|
355
|
+
```sh
|
|
356
|
+
docker compose -f deploy/compose.yml --env-file .env up -d --wait mongo
|
|
357
|
+
docker run -p 3000:3000 --network dpp-platform_default --env-file .env \
|
|
358
|
+
-e MONGO_URL=mongodb://mongo:27017 -v dpp-local:/app/local my-dpp
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
The Compose file names the project `dpp-platform`. If you set a different project name, use its `<project>_default` network. With a hosted database, set `MONGO_URL` in `.env` to its connection string and run the app directly.
|
|
362
|
+
|
|
363
|
+
```sh
|
|
364
|
+
docker run -p 3000:3000 --env-file .env -v dpp-local:/app/local my-dpp
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
One container serves the API and the web app. Run one instance with `WORKER=with-api` (the default), or several API instances with `WORKER=off` and exactly one with `WORKER=only`, so the unattended duties run once. Each API instance runs the EPCIS recovery when it starts, which assumes no other instance is importing at that moment: start them one at a time. The volume at `/app/local` holds the wallet file and the GS1 files, and with `EPCIS_STORAGE=file` or `PROFILE_BUNDLE_DIR` their folders too.
|
|
368
|
+
|
|
369
|
+
`deploy/compose.yml` starts MongoDB for the application, named by tag and digest so that every machine runs the same image. MongoDB Community Server is its publisher's program under the Server Side Public License. It is pulled from its publisher and is not part of this project.
|
|
370
|
+
|
|
371
|
+
## Next steps
|
|
372
|
+
|
|
373
|
+
Things this starter leaves to you, each a known path:
|
|
374
|
+
|
|
375
|
+
- **A registry of your own.** Claims are sent to `REGISTRY_URL`, which anchors each one once per bound passport. Check the configured registry’s advertised EPCIS lifecycle representation and the intake response before recording acceptance. Running your own is the registry role of the standard.
|
|
376
|
+
- **Authority evidence.** Maintain the operator grants described under [Lifecycle claims](#lifecycle-claims). A deployment with its own source of evidence can supply a resolver for the same issuer, passport, role, purpose and event-time questions.
|
|
377
|
+
- **More links at the identifier host.** The resolver lists two links: the passport page of an item, and a plain product page for its GTIN. Your own product page as the GTIN's default, a link at lot level, or an evidence package once you serve one at a stable address, are records to add where `apps/api/src/resolver.ts` makes them, and the checks of `@bsv/dpp-profiles` it applies refuse a set that breaks a rule. It answers a linkset request with JSON whatever the `Accept`, with no page for a person, and it answers only for identifiers under its own `PASSPORT_HOST`.
|
|
378
|
+
- **Server-rendered passport pages.** The public page renders in the browser. If crawlers or no-JavaScript readers matter, serve a plain HTML view of it from the API at the page's own path, not at the identifier's.
|
|
379
|
+
- **Self-custody.** Let a brand or a holder sign from their own BRC-100 wallet: implement a `Party` backed by a wallet connection in the browser, and let a transfer go to a key the holder's wallet derived.
|
|
380
|
+
- **Who sees which events.** Every signed-in user sees every import and may start a pull, as with the wallet and operations pages. Scope them to a brand if your users should not see each other's.
|
|
381
|
+
- **An operator role.** Export and restore are commands on the host because the API has no operator to authorise. If you want them over HTTP, add the role first.
|
|
382
|
+
- **Moving sign-in.** An export carries no account, session or membership. Moving them with a deployment is yours to do.
|
|
383
|
+
- **More of EPCIS.** This starter imports files, pulls from the standard query interface and exports originals. It captures nothing, subscribes to nothing, reads no XML and maps no event to a passport state. A page for recording a decision on two bodies under one event identifier is yours to add: the route is `POST /api/epcis/conflicts/:conflictId/resolutions`.
|
|
384
|
+
- **Credentials and federation.** The rest of `@bsv/dpp-credentials` and a second index that synchronises with yours are documented in the standard.
|
|
385
|
+
- **A wallet storage server.** For several API instances, replace the SQLite file with the toolbox client against a wallet storage server.
|
|
386
|
+
|
|
387
|
+
## Versions
|
|
388
|
+
|
|
389
|
+
The DPP packages are pinned to one release set, named in `package.json` under `dpp`. Move them together, and read the standard's changelog first: they are prereleases.
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# The scaffold wrote .env from this file with fresh secrets and the default testnet index;
|
|
2
|
+
# this copy keeps the placeholders. The npm scripts (dev, start, wallet, operations, go-live) read
|
|
3
|
+
# .env at start, as does Docker with --env-file. A value already set in the environment wins over
|
|
4
|
+
# the file. Values marked (live) are needed only to write real passports; `npm test` and
|
|
5
|
+
# `npm run dev` work without them, and `npm run go-live` fills in what it can.
|
|
6
|
+
|
|
7
|
+
# The chain your wallet and index are on: test for the default testnet index, main for mainnet
|
|
8
|
+
NETWORK=test
|
|
9
|
+
PORT=3000
|
|
10
|
+
# Where the web app is served from in production (the API serves it); in dev Vite proxies to the API
|
|
11
|
+
PUBLIC_URL=http://localhost:3000
|
|
12
|
+
|
|
13
|
+
# MongoDB for the application's records, journal and sign-in
|
|
14
|
+
MONGO_URL=mongodb://127.0.0.1:27017
|
|
15
|
+
MONGO_DB=dpp_app
|
|
16
|
+
|
|
17
|
+
# Sign-in (Better Auth). Generate a secret with: openssl rand -hex 32
|
|
18
|
+
AUTH_SECRET=change-me-to-32-random-bytes-hex
|
|
19
|
+
|
|
20
|
+
# The platform wallet: a BRC-100 wallet the API owns (wallet-toolbox on SQLite).
|
|
21
|
+
# Empty until the first `npm run go-live`, which generates the root key here. Keep it secret and backed up.
|
|
22
|
+
WALLET_ROOT_KEY=
|
|
23
|
+
WALLET_FILE=local/wallet.sqlite
|
|
24
|
+
# WhatsOnChain API key: the header source for the wallet and the reader (live)
|
|
25
|
+
WOC_API_KEY=
|
|
26
|
+
# An ARC-compatible broadcaster URL; empty uses the toolbox's defaults for the network (live)
|
|
27
|
+
ARC_URL=
|
|
28
|
+
|
|
29
|
+
# Secrets the platform derives managed identities from: one per brand, one per recipient. openssl rand -hex 32 each.
|
|
30
|
+
BRAND_ROOT_SECRET=
|
|
31
|
+
MANAGED_IDENTITY_SECRET=
|
|
32
|
+
|
|
33
|
+
# The index this app announces passports to and readers look them up in. The default is the
|
|
34
|
+
# hosted testnet index (mainnet: https://dpp-overlay-mainnet.bsvb.net with NETWORK=main). Until
|
|
35
|
+
# `npm run go-live` has registered the app's publisher key and stored the two tokens below, the
|
|
36
|
+
# API runs an index in this process instead. `npm run connect-index` takes another provider's
|
|
37
|
+
# address and tokens, or with --from the connection file an index operator wrote with
|
|
38
|
+
# `dpp-index connection`, your own index's included.
|
|
39
|
+
INDEX_URL=https://dpp-overlay-testnet.bsvb.net
|
|
40
|
+
# For a custom index whose operator confirms POST /retract, set this to the same base URL
|
|
41
|
+
# as INDEX_URL to announce drafts before sending. Other custom indexes receive sent states.
|
|
42
|
+
INDEX_RETRACTION_URL=
|
|
43
|
+
INDEX_SUBMIT_TOKEN=
|
|
44
|
+
INDEX_CALLBACK_TOKEN=
|
|
45
|
+
# Only for `npm run export`, which carries the index's own signed evidence for each passport. The token is the
|
|
46
|
+
# one the index wants for its complete export, where its operator set one and gave it to you; a passport of up
|
|
47
|
+
# to 500 states needs none. The key is the index's exporter identity key, to hold its packages to. Empty uses
|
|
48
|
+
# the key the index's capability document names.
|
|
49
|
+
INDEX_EXPORT_TOKEN=
|
|
50
|
+
INDEX_EXPORTER_KEY=
|
|
51
|
+
|
|
52
|
+
# The host passports are minted under: https://<PASSPORT_HOST>/01/<gtin>/21/<serial>
|
|
53
|
+
PASSPORT_HOST=localhost:3000
|
|
54
|
+
# The GS1 company prefix passports may be written under. 952 is GS1's demonstration prefix, never licensed to anyone.
|
|
55
|
+
# Replace with your licensed prefix for real products; the demo notice switches off with it.
|
|
56
|
+
GS1_PREFIX=952
|
|
57
|
+
|
|
58
|
+
# Profiles of your own, each held by a binding in a folder: binding.json and the files it names (README,
|
|
59
|
+
# Product documents under a binding). Folders are comma-separated, and a relative one is read from this
|
|
60
|
+
# file's directory. A folder is registered at start only when the SHA-256 of its binding.json is listed in
|
|
61
|
+
# TRUSTED_BINDING_DIGESTS: that is how you say you reviewed that exact file. A folder that is not trusted,
|
|
62
|
+
# or that changed since, is refused by name at start and the app runs without it. The four packaged sector editions need
|
|
63
|
+
# neither setting. New sector passports use eu-battery@2 or eu-textile@2.
|
|
64
|
+
CUSTOM_PROFILE_DIRS=
|
|
65
|
+
TRUSTED_BINDING_DIGESTS=
|
|
66
|
+
# Where the bound profiles are read from. Empty reads the packaged sector editions from the folder the profiles
|
|
67
|
+
# package ships. A folder here is read as a profile bundle instead, and the package's folder is not read:
|
|
68
|
+
# `npm run restore` installs the bundle of the package it restores into it. A relative folder is read from
|
|
69
|
+
# this file's directory. Trust is the same either way (README, Where the profiles are read from).
|
|
70
|
+
PROFILE_BUNDLE_DIR=
|
|
71
|
+
|
|
72
|
+
# The validation engine for profiles held by a binding. Empty runs the JSON-LD and SHACL libraries in the
|
|
73
|
+
# API's own process. An address asks a validator service there instead: the DPP operator preset runs one, and
|
|
74
|
+
# `npx dpp-validator` starts one on 127.0.0.1:8090. The token is the one that service requires, if any. It is
|
|
75
|
+
# sent to that address only and is never logged. A service that does not answer blocks writes under a bound
|
|
76
|
+
# profile and never reads as a pass (README, The validation engine).
|
|
77
|
+
VALIDATOR_URL=
|
|
78
|
+
VALIDATOR_TOKEN=
|
|
79
|
+
|
|
80
|
+
# EPCIS exchange: importing EPCIS 2.0 documents, pulling events from a source and exporting what was received.
|
|
81
|
+
# Documents are checked against three files GS1 publishes under its own terms, which this project does not
|
|
82
|
+
# contain. The API obtains them from https://ref.gs1.org once, at start, into this folder, and checks every
|
|
83
|
+
# byte against a pinned digest. A relative folder is read from this file's directory. With OFFLINE=true the API
|
|
84
|
+
# never fetches: place the files in the folder yourself (`npx dpp-gs1-artefacts verify --dir <folder>` lists them).
|
|
85
|
+
# Without the files the API still starts, and refuses every import and pull by name.
|
|
86
|
+
DPP_GS1_ARTEFACTS_DIR=local/gs1
|
|
87
|
+
DPP_GS1_ARTEFACTS_OFFLINE=false
|
|
88
|
+
# Where the exchange keeps what it retains. mongodb is the application database above, and the store this
|
|
89
|
+
# application is built and tested on. file keeps it in EPCIS_STORAGE_DIR through the file-system adapter the
|
|
90
|
+
# DPP packages ship: one process, one disk, no replication. It shows the store can be replaced and is not
|
|
91
|
+
# offered as a second production database.
|
|
92
|
+
EPCIS_STORAGE=mongodb
|
|
93
|
+
EPCIS_STORAGE_DIR=local/epcis-store
|
|
94
|
+
|
|
95
|
+
# The EPCIS query sources this app may pull from: names, comma-separated, each of lower-case letters, digits
|
|
96
|
+
# and hyphens. Nothing about a source comes from a request. For a source named supplier-a set, with the name in
|
|
97
|
+
# upper case and each hyphen as an underscore:
|
|
98
|
+
# EPCIS_SOURCE_SUPPLIER_A_URL the base address of its query interface; events are asked for at <URL>/events
|
|
99
|
+
# EPCIS_SOURCE_SUPPLIER_A_ORIGINS every origin a request may go to, comma-separated; empty permits the URL's own origin only
|
|
100
|
+
# EPCIS_SOURCE_SUPPLIER_A_BEARER_TOKEN a bearer token, or
|
|
101
|
+
# EPCIS_SOURCE_SUPPLIER_A_BASIC_USER a user name with
|
|
102
|
+
# EPCIS_SOURCE_SUPPLIER_A_BASIC_PASSWORD its password, or
|
|
103
|
+
# EPCIS_SOURCE_SUPPLIER_A_HEADER_NAME the name of a credential header with
|
|
104
|
+
# EPCIS_SOURCE_SUPPLIER_A_HEADER_VALUE its value
|
|
105
|
+
# EPCIS_SOURCE_SUPPLIER_A_LOCAL_TEST true permits plain http and private addresses: for a source on your own machine only
|
|
106
|
+
# EPCIS_SOURCE_SUPPLIER_A_REPEAT_LISTS true sends each value of a list as its own parameter, for a source that needs it
|
|
107
|
+
# The credential stays in this file and the API's memory. It is sent to the URL's own origin only, and is never
|
|
108
|
+
# written to the database, an answer, a log line or the web app.
|
|
109
|
+
EPCIS_SOURCES=
|
|
110
|
+
|
|
111
|
+
# A registry that validates and stores lifecycle claims (POST /validate is open on the hosted reference)
|
|
112
|
+
REGISTRY_URL=https://dpp-resolver.bsvb.net
|
|
113
|
+
REGISTRY_TOKEN=
|
|
114
|
+
|
|
115
|
+
# Absolute path to the operator's role grants for qualified lifecycle signing.
|
|
116
|
+
# See "Configure signing authority" in the generated README.
|
|
117
|
+
# LIFECYCLE_AUTHORITY_GRANTS_FILE=/path/to/lifecycle-authority-grants.json
|
|
118
|
+
|
|
119
|
+
# Writing to the chain spends real satoshis. `npm run go-live` sets this to true once every check passes.
|
|
120
|
+
LIVE_PUBLISHING=false
|
|
121
|
+
# How many satoshis the platform may spend per day before it refuses to write more
|
|
122
|
+
SPEND_CAP_SATOSHIS=20000
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Install, typecheck, build and run the offline lifecycle test on every change.
|
|
2
|
+
name: CI
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
test:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v7
|
|
16
|
+
- uses: actions/setup-node@v7
|
|
17
|
+
with:
|
|
18
|
+
node-version: 22.23.4
|
|
19
|
+
cache: npm
|
|
20
|
+
- run: npm ci
|
|
21
|
+
- run: npm run typecheck
|
|
22
|
+
- run: npm run build
|
|
23
|
+
- run: npm test
|