@bsv/create-dpp-app 0.0.0-stage → 0.1.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +203 -0
- package/README.md +73 -2
- package/dist/index.js +97 -0
- package/package.json +53 -4
- package/template/Dockerfile +35 -0
- package/template/README.md +134 -0
- package/template/_dockerignore +6 -0
- package/template/_env.example +53 -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 +49 -0
- package/template/apps/api/package.json +34 -0
- package/template/apps/api/src/auth.ts +55 -0
- package/template/apps/api/src/claims.ts +85 -0
- package/template/apps/api/src/cli.ts +42 -0
- package/template/apps/api/src/config.ts +66 -0
- package/template/apps/api/src/custody.ts +186 -0
- package/template/apps/api/src/dev-index.ts +71 -0
- package/template/apps/api/src/env.ts +14 -0
- package/template/apps/api/src/identifiers.ts +57 -0
- package/template/apps/api/src/index-client.ts +136 -0
- package/template/apps/api/src/main.ts +50 -0
- package/template/apps/api/src/parties.ts +68 -0
- package/template/apps/api/src/platform.ts +121 -0
- package/template/apps/api/src/profiles.ts +100 -0
- package/template/apps/api/src/reader.ts +96 -0
- package/template/apps/api/src/server.ts +420 -0
- package/template/apps/api/src/store.ts +249 -0
- package/template/apps/api/src/wallet.ts +346 -0
- package/template/apps/api/src/worker.ts +106 -0
- package/template/apps/api/src/writer.ts +351 -0
- package/template/apps/api/test/config.test.ts +15 -0
- package/template/apps/api/test/external-index.test.ts +31 -0
- package/template/apps/api/test/lifecycle.test.ts +136 -0
- package/template/apps/api/tsconfig.json +9 -0
- package/template/apps/api/vitest.config.ts +9 -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 +51 -0
- package/template/apps/web/src/components/bits.tsx +188 -0
- package/template/apps/web/src/components/layout.tsx +118 -0
- package/template/apps/web/src/components/passport-form.tsx +244 -0
- package/template/apps/web/src/components/read-passport.tsx +48 -0
- package/template/apps/web/src/components/reading.tsx +157 -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 +286 -0
- package/template/apps/web/src/lib/auth.ts +10 -0
- package/template/apps/web/src/lib/format.ts +64 -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 +108 -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/home.tsx +51 -0
- package/template/apps/web/src/pages/new-passport.tsx +114 -0
- package/template/apps/web/src/pages/operations.tsx +150 -0
- package/template/apps/web/src/pages/passport.tsx +568 -0
- package/template/apps/web/src/pages/public-passport.tsx +24 -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 +15 -0
- package/template/deploy/compose.yml +26 -0
- package/template/package.json +42 -0
- package/template/tsconfig.base.json +13 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
Copyright © BSV Association
|
|
2
|
+
|
|
3
|
+
Apache License
|
|
4
|
+
Version 2.0, January 2004
|
|
5
|
+
http://www.apache.org/licenses/
|
|
6
|
+
|
|
7
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
8
|
+
|
|
9
|
+
1. Definitions.
|
|
10
|
+
|
|
11
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
12
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
13
|
+
|
|
14
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
15
|
+
the copyright owner that is granting the License.
|
|
16
|
+
|
|
17
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
18
|
+
other entities that control, are controlled by, or are under common
|
|
19
|
+
control with that entity. For the purposes of this definition,
|
|
20
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
21
|
+
direction or management of such entity, whether by contract or
|
|
22
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
23
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
24
|
+
|
|
25
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
26
|
+
exercising permissions granted by this License.
|
|
27
|
+
|
|
28
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
29
|
+
including but not limited to software source code, documentation
|
|
30
|
+
source, and configuration files.
|
|
31
|
+
|
|
32
|
+
"Object" form shall mean any form resulting from mechanical
|
|
33
|
+
transformation or translation of a Source form, including but
|
|
34
|
+
not limited to compiled object code, generated documentation,
|
|
35
|
+
and conversions to other media types.
|
|
36
|
+
|
|
37
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
38
|
+
Object form, made available under the License, as indicated by a
|
|
39
|
+
copyright notice that is included in or attached to the work
|
|
40
|
+
(an example is provided in the Appendix below).
|
|
41
|
+
|
|
42
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
43
|
+
form, that is based on (or derived from) the Work and for which the
|
|
44
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
45
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
46
|
+
of this License, Derivative Works shall not include works that remain
|
|
47
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
48
|
+
the Work and Derivative Works thereof.
|
|
49
|
+
|
|
50
|
+
"Contribution" shall mean any work of authorship, including
|
|
51
|
+
the original version of the Work and any modifications or additions
|
|
52
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
53
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
54
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
55
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
56
|
+
means any form of electronic, verbal, or written communication sent
|
|
57
|
+
to the Licensor or its representatives, including but not limited to
|
|
58
|
+
communication on electronic mailing lists, source code control systems,
|
|
59
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
60
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
61
|
+
excluding communication that is conspicuously marked or otherwise
|
|
62
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
63
|
+
|
|
64
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
65
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
66
|
+
subsequently incorporated within the Work.
|
|
67
|
+
|
|
68
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
69
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
70
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
71
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
72
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
73
|
+
Work and such Derivative Works in Source or Object form.
|
|
74
|
+
|
|
75
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
76
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
77
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
78
|
+
(except as stated in this section) patent license to make, have made,
|
|
79
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
80
|
+
where such license applies only to those patent claims licensable
|
|
81
|
+
by such Contributor that are necessarily infringed by their
|
|
82
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
83
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
84
|
+
institute patent litigation against any entity (including a
|
|
85
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
86
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
87
|
+
or contributory patent infringement, then any patent licenses
|
|
88
|
+
granted to You under this License for that Work shall terminate
|
|
89
|
+
as of the date such litigation is filed.
|
|
90
|
+
|
|
91
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
92
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
93
|
+
modifications, and in Source or Object form, provided that You
|
|
94
|
+
meet the following conditions:
|
|
95
|
+
|
|
96
|
+
(a) You must give any other recipients of the Work or
|
|
97
|
+
Derivative Works a copy of this License; and
|
|
98
|
+
|
|
99
|
+
(b) You must cause any modified files to carry prominent notices
|
|
100
|
+
stating that You changed the files; and
|
|
101
|
+
|
|
102
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
103
|
+
that You distribute, all copyright, patent, trademark, and
|
|
104
|
+
attribution notices from the Source form of the Work,
|
|
105
|
+
excluding those notices that do not pertain to any part of
|
|
106
|
+
the Derivative Works; and
|
|
107
|
+
|
|
108
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
109
|
+
distribution, then any Derivative Works that You distribute must
|
|
110
|
+
include a readable copy of the attribution notices contained
|
|
111
|
+
within such NOTICE file, excluding those notices that do not
|
|
112
|
+
pertain to any part of the Derivative Works, in at least one
|
|
113
|
+
of the following places: within a NOTICE text file distributed
|
|
114
|
+
as part of the Derivative Works; within the Source form or
|
|
115
|
+
documentation, if provided along with the Derivative Works; or,
|
|
116
|
+
within a display generated by the Derivative Works, if and
|
|
117
|
+
wherever such third-party notices normally appear. The contents
|
|
118
|
+
of the NOTICE file are for informational purposes only and
|
|
119
|
+
do not modify the License. You may add Your own attribution
|
|
120
|
+
notices within Derivative Works that You distribute, alongside
|
|
121
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
122
|
+
that such additional attribution notices cannot be construed
|
|
123
|
+
as modifying the License.
|
|
124
|
+
|
|
125
|
+
You may add Your own copyright statement to Your modifications and
|
|
126
|
+
may provide additional or different license terms and conditions
|
|
127
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
128
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
129
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
130
|
+
the conditions stated in this License.
|
|
131
|
+
|
|
132
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
133
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
134
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
135
|
+
this License, without any additional terms or conditions.
|
|
136
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
137
|
+
the terms of any separate license agreement you may have executed
|
|
138
|
+
with Licensor regarding such Contributions.
|
|
139
|
+
|
|
140
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
141
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
142
|
+
except as required for reasonable and customary use in describing the
|
|
143
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
144
|
+
|
|
145
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
146
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
147
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
148
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
149
|
+
implied, including, without limitation, any warranties or conditions
|
|
150
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
151
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
152
|
+
appropriateness of using or redistributing the Work and assume any
|
|
153
|
+
risks associated with Your exercise of permissions under this License.
|
|
154
|
+
|
|
155
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
156
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
157
|
+
unless required by applicable law (such as deliberate and grossly
|
|
158
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
159
|
+
liable to You for damages, including any direct, indirect, special,
|
|
160
|
+
incidental, or consequential damages of any character arising as a
|
|
161
|
+
result of this License or out of the use or inability to use the
|
|
162
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
163
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
164
|
+
other commercial damages or losses), even if such Contributor
|
|
165
|
+
has been advised of the possibility of such damages.
|
|
166
|
+
|
|
167
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
168
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
169
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
170
|
+
or other liability obligations and/or rights consistent with this
|
|
171
|
+
License. However, in accepting such obligations, You may act only
|
|
172
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
173
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
174
|
+
defend, and hold each Contributor harmless for any liability
|
|
175
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
176
|
+
of your accepting any such warranty or additional liability.
|
|
177
|
+
|
|
178
|
+
END OF TERMS AND CONDITIONS
|
|
179
|
+
|
|
180
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
181
|
+
|
|
182
|
+
To apply the Apache License to your work, attach the following
|
|
183
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
184
|
+
replaced with your own identifying information. (Don't include
|
|
185
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
186
|
+
comment syntax for the file format. We also recommend that a
|
|
187
|
+
file or class name and description of purpose be included on the
|
|
188
|
+
same "printed page" as the copyright notice for easier
|
|
189
|
+
identification within third-party archives.
|
|
190
|
+
|
|
191
|
+
Copyright [yyyy] [name of copyright owner]
|
|
192
|
+
|
|
193
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
194
|
+
you may not use this file except in compliance with the License.
|
|
195
|
+
You may obtain a copy of the License at
|
|
196
|
+
|
|
197
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
198
|
+
|
|
199
|
+
Unless required by applicable law or agreed to in writing, software
|
|
200
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
201
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
202
|
+
See the License for the specific language governing permissions and
|
|
203
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,74 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @bsv/create-dpp-app
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Scaffold a Digital Product Passport application on BSV in one command.
|
|
4
|
+
|
|
5
|
+
This starter and its renamed protocol dependency are source candidates pending publication. The npm command below applies after both are published; use the development commands below to test them from this checkout.
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm create @bsv/dpp-app@0.1.0-beta.1 my-app
|
|
9
|
+
cd my-app
|
|
10
|
+
npm test
|
|
11
|
+
npm run dev
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
You get a working application: a React web app with a brand dashboard, passport pages, hand-on acceptance and public verification; an Express API that owns a platform wallet, writes and reads passports with the `@bsv/dpp` packages, keeps a journal and runs the unattended duties; and a Compose service for the application database. The first run is an offline test of a whole passport lifecycle, with no wallet, funds, Docker or network. The template's README explains the rest, including the route to writing real passports.
|
|
15
|
+
|
|
16
|
+
## Choose the index connection
|
|
17
|
+
|
|
18
|
+
| You want to | What to use |
|
|
19
|
+
| --- | --- |
|
|
20
|
+
| Build the application | `@bsv/create-dpp-app`, this starter |
|
|
21
|
+
| Connect to an existing compatible index | Its URL, network and scoped access settings; no index starter required |
|
|
22
|
+
| Operate your own index | A separate project created by `@bsv/create-dpp-index`, which includes its runtime |
|
|
23
|
+
|
|
24
|
+
The app's Compose file starts only its database, so connecting a separately operated index cannot start another index accidentally. The app includes overlay library components for its offline exercises; those components do not deploy a persistent index. Do not manually install another overlay package as part of app setup. See the generated README's **Connect an index** section and [service choices](../../docs/start/choose-components-and-services.md).
|
|
25
|
+
|
|
26
|
+
## What it decides for you
|
|
27
|
+
|
|
28
|
+
- TypeScript throughout, Node 22 or later, npm workspaces.
|
|
29
|
+
- Web: React, Vite, React Router, Tailwind CSS, shadcn/ui, built to static files the API serves.
|
|
30
|
+
- API: Express 5; MongoDB for records, journal and sign-in; Better Auth for sign-in with organisations as brands; a journal-driven worker loop for proofs and re-announcements.
|
|
31
|
+
- Wallet: `@bsv/wallet-toolbox` as a library, service-owned, keys in a SQLite file.
|
|
32
|
+
- Custody: managed, the platform signs for signed-in users; the party interface keeps self-custody open.
|
|
33
|
+
- Identifiers: GS1 Digital Links under the demonstration prefix 952 until you set a licensed one.
|
|
34
|
+
|
|
35
|
+
Every opinion is a file you can change. The standard itself prefers none of them.
|
|
36
|
+
|
|
37
|
+
## Versions
|
|
38
|
+
|
|
39
|
+
Each release of this package scaffolds one DPP release set, named under `dpp` in `package.json`, with the exact package versions it pins. This source candidate uses `dpp-release-2026-10-10`: protocol and profiles `0.3.0-beta.9`, overlay `0.4.0-beta.12` and SDK `2.8.10`, matching the index starter. The generated app imports `@bsv/dpp-protocol` directly. Once published, a new release set requires a new starter version.
|
|
40
|
+
|
|
41
|
+
## Development
|
|
42
|
+
|
|
43
|
+
This package is a workspace of the DPP standard's repository, published separately from its four runtime packages. Publish the pinned runtime set before the starter. From the repository root, test the source candidate:
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
npm ci
|
|
47
|
+
npm run build
|
|
48
|
+
npm test -w @bsv/create-dpp-app
|
|
49
|
+
npm run starter:check
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
The check installs the packed generator outside the repository, creates an app and uses local archives for the pinned DPP runtime. It then installs dependencies, builds, typechecks and runs the generated app's tests, including a check that `@bsv/dpp-core` is absent. The template keeps exact npm versions; archive paths are written only into the local test project.
|
|
53
|
+
|
|
54
|
+
To retain an editable app at a new directory, use:
|
|
55
|
+
|
|
56
|
+
```sh
|
|
57
|
+
npm run starter:check -- --directory ../my-app
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Before publication, run the separate registry prerequisite check after the runtime packages are available:
|
|
61
|
+
|
|
62
|
+
```sh
|
|
63
|
+
npm run starter:check -- --registry-dependencies
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
This mode uses a fresh npm cache, installs the template's exact versions from public npm, and refuses missing dependencies without substituting local archives. The starter publication workflow requires it. Candidate checks establish neither registry availability nor blockchain inclusion.
|
|
67
|
+
|
|
68
|
+
For the CI image check, `--prepare-only --directory /tmp/my-app` creates the app and candidate archives without installing or testing. Its `.candidate.Dockerfile` adds the archive copy before the template's existing dependency installation; the bundled Dockerfile is unchanged. The image check builds that file and checks the API health endpoint.
|
|
69
|
+
|
|
70
|
+
The template lives in `template/`; files that tooling treats specially ship with a leading underscore (`_gitignore`, `_env.example`) and are renamed when scaffolded. Make template changes there, then regenerate and check a fresh app.
|
|
71
|
+
|
|
72
|
+
## Licence
|
|
73
|
+
|
|
74
|
+
Apache 2.0.
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* create-dpp-app: copy the bundled template into a new directory and name it.
|
|
4
|
+
*
|
|
5
|
+
* npm create @bsv/dpp-app@0.1.0-beta.1 my-app
|
|
6
|
+
* npx @bsv/create-dpp-app my-app [--no-install] [--yes]
|
|
7
|
+
*
|
|
8
|
+
* The template ships inside this package, so scaffolding needs no network;
|
|
9
|
+
* installing the dependencies does. Every version the template pins comes
|
|
10
|
+
* from one DPP release set, named in this package's manifest under "dpp".
|
|
11
|
+
*/
|
|
12
|
+
import { spawnSync } from 'node:child_process';
|
|
13
|
+
import { cpSync, existsSync, mkdirSync, readFileSync, readdirSync, renameSync, statSync, writeFileSync } from 'node:fs';
|
|
14
|
+
import { basename, dirname, join, resolve } from 'node:path';
|
|
15
|
+
import { fileURLToPath } from 'node:url';
|
|
16
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
17
|
+
const packageRoot = join(here, '..');
|
|
18
|
+
const manifest = JSON.parse(readFileSync(join(packageRoot, 'package.json'), 'utf8'));
|
|
19
|
+
const args = process.argv.slice(2);
|
|
20
|
+
const flags = new Set(args.filter((a) => a.startsWith('--')));
|
|
21
|
+
const positional = args.filter((a) => !a.startsWith('--'));
|
|
22
|
+
if (flags.has('--help') || flags.has('-h')) {
|
|
23
|
+
console.log(`create-dpp-app ${manifest.version}: scaffold a Digital Product Passport application on BSV.
|
|
24
|
+
|
|
25
|
+
usage: npm create @bsv/dpp-app@0.1.0-beta.1 <directory> [--no-install] [--yes]
|
|
26
|
+
|
|
27
|
+
<directory> where to create the application; must be empty or hold only .git
|
|
28
|
+
--no-install do not run npm install afterwards
|
|
29
|
+
--yes create without the confirmation line (for scripts)
|
|
30
|
+
|
|
31
|
+
The template pins the DPP packages of ${manifest.dpp.releaseSet}:
|
|
32
|
+
${Object.entries(manifest.dpp.packages)
|
|
33
|
+
.map(([name, version]) => ` ${name}@${version}`)
|
|
34
|
+
.join('\n')}`);
|
|
35
|
+
process.exit(0);
|
|
36
|
+
}
|
|
37
|
+
if (flags.has('--version') || flags.has('-v')) {
|
|
38
|
+
console.log(manifest.version);
|
|
39
|
+
process.exit(0);
|
|
40
|
+
}
|
|
41
|
+
const target = resolve(positional[0] ?? 'my-dpp');
|
|
42
|
+
const projectName = basename(target)
|
|
43
|
+
.toLowerCase()
|
|
44
|
+
.replace(/[^a-z0-9-]+/g, '-')
|
|
45
|
+
.replace(/^-+|-+$/g, '') || 'my-dpp';
|
|
46
|
+
if (existsSync(target)) {
|
|
47
|
+
const entries = readdirSync(target).filter((name) => name !== '.git');
|
|
48
|
+
if (entries.length > 0) {
|
|
49
|
+
console.error(`${target} is not empty (${entries.slice(0, 5).join(', ')}${entries.length > 5 ? ', ...' : ''}). Choose an empty directory.`);
|
|
50
|
+
process.exit(2);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
console.log(`Creating ${projectName} in ${target} from the ${manifest.dpp.releaseSet} template.`);
|
|
54
|
+
mkdirSync(target, { recursive: true });
|
|
55
|
+
// Development artefacts never travel: a template checkout may hold them.
|
|
56
|
+
const skipped = new Set(['node_modules', 'dist', 'local', '.env', 'package-lock.json', '.DS_Store']);
|
|
57
|
+
cpSync(join(packageRoot, 'template'), target, {
|
|
58
|
+
recursive: true,
|
|
59
|
+
errorOnExist: false,
|
|
60
|
+
filter: (source) => !skipped.has(basename(source)),
|
|
61
|
+
});
|
|
62
|
+
// Files that npm strips or that tooling treats specially are shipped with a
|
|
63
|
+
// leading underscore and renamed here: _gitignore -> .gitignore and so on.
|
|
64
|
+
function restoreDotfiles(dir) {
|
|
65
|
+
for (const name of readdirSync(dir)) {
|
|
66
|
+
const path = join(dir, name);
|
|
67
|
+
if (statSync(path).isDirectory())
|
|
68
|
+
restoreDotfiles(path);
|
|
69
|
+
if (/^_[a-z]/i.test(name))
|
|
70
|
+
renameSync(path, join(dir, `.${name.slice(1)}`));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
restoreDotfiles(target);
|
|
74
|
+
const rootManifestPath = join(target, 'package.json');
|
|
75
|
+
const rootManifest = JSON.parse(readFileSync(rootManifestPath, 'utf8'));
|
|
76
|
+
rootManifest.name = projectName;
|
|
77
|
+
writeFileSync(rootManifestPath, `${JSON.stringify(rootManifest, null, 2)}\n`);
|
|
78
|
+
const install = !flags.has('--no-install');
|
|
79
|
+
if (install) {
|
|
80
|
+
console.log('Installing dependencies with npm. The wallet toolbox brings a native SQLite driver; npm 11 may ask you to approve its install script.');
|
|
81
|
+
const result = spawnSync('npm', ['install'], { cwd: target, stdio: 'inherit' });
|
|
82
|
+
if (result.status !== 0) {
|
|
83
|
+
console.error('npm install did not finish. Run it again inside the directory; if npm reports a held install script, run: npm install-scripts approve better-sqlite3');
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
console.log(`
|
|
87
|
+
Done. Next:
|
|
88
|
+
|
|
89
|
+
cd ${positional[0] ?? 'my-dpp'}${install ? '' : '\n npm install'}
|
|
90
|
+
npm test # the offline dry run: issue, update, hand on, retire, claim; no wallet, funds or Docker
|
|
91
|
+
cp .env.example .env
|
|
92
|
+
npm run dev # web on http://localhost:5173, API on http://localhost:3000, a local index in-process
|
|
93
|
+
|
|
94
|
+
For deployment you need an index: the service your app announces passports to and readers look them up in.
|
|
95
|
+
Connect to one that exists, or create your own with @bsv/create-dpp-index (README, Connect an index).
|
|
96
|
+
The app's Compose file starts only its database. No separate overlay installation is needed.
|
|
97
|
+
Read README.md for the live route: a funded wallet, index access, and the identifier you will write under.`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,55 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bsv/create-dpp-app",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0-beta.1",
|
|
4
|
+
"description": "Scaffold a Digital Product Passport application on BSV: a web app, an API that writes and reads passports with the @bsv/dpp packages, and an offline dry run as its first test",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"create-dpp-app": "dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"template",
|
|
13
|
+
"README.md",
|
|
14
|
+
"LICENSE"
|
|
15
|
+
],
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=22"
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsc -p tsconfig.json",
|
|
21
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
22
|
+
"test": "node --test test/*.test.mjs",
|
|
23
|
+
"scaffold:check": "node scripts/scaffold-check.mjs"
|
|
24
|
+
},
|
|
25
|
+
"dpp": {
|
|
26
|
+
"releaseSet": "dpp-release-2026-10-10",
|
|
27
|
+
"packages": {
|
|
28
|
+
"@bsv/dpp-protocol": "0.3.0-beta.9",
|
|
29
|
+
"@bsv/dpp-profiles": "0.3.0-beta.9",
|
|
30
|
+
"@bsv/dpp-overlay": "0.4.0-beta.12",
|
|
31
|
+
"@bsv/sdk": "2.8.10"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@types/node": "^22.20.3",
|
|
36
|
+
"typescript": "^7.0.2"
|
|
37
|
+
},
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "git+https://github.com/bsv-blockchain/dpp.git",
|
|
41
|
+
"directory": "packages/create-dpp-app"
|
|
42
|
+
},
|
|
43
|
+
"publishConfig": {
|
|
44
|
+
"access": "public",
|
|
45
|
+
"registry": "https://registry.npmjs.org/",
|
|
46
|
+
"tag": "latest"
|
|
47
|
+
},
|
|
48
|
+
"keywords": [
|
|
49
|
+
"bsv",
|
|
50
|
+
"digital-product-passport",
|
|
51
|
+
"dpp",
|
|
52
|
+
"scaffold",
|
|
53
|
+
"create"
|
|
54
|
+
]
|
|
55
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# One image: the API serving the built web app. The wallet's SQLite driver is
|
|
2
|
+
# a native module; it ships prebuilt binaries for common platforms, and the
|
|
3
|
+
# build stage carries the tools to compile it where it does not.
|
|
4
|
+
#
|
|
5
|
+
# The base image is a build argument so a build can take the same Docker
|
|
6
|
+
# Official Image from a mirror, for example
|
|
7
|
+
# --build-arg BASE_IMAGE=public.ecr.aws/docker/library/node:22-bookworm-slim
|
|
8
|
+
# where Docker Hub rate limits apply. The default is Docker Hub's.
|
|
9
|
+
ARG BASE_IMAGE=node:22-bookworm-slim
|
|
10
|
+
|
|
11
|
+
FROM ${BASE_IMAGE} AS build
|
|
12
|
+
RUN apt-get update && apt-get install -y --no-install-recommends python3 make g++ && rm -rf /var/lib/apt/lists/*
|
|
13
|
+
WORKDIR /app
|
|
14
|
+
COPY package.json package-lock.json* ./
|
|
15
|
+
COPY apps/api/package.json apps/api/
|
|
16
|
+
COPY apps/web/package.json apps/web/
|
|
17
|
+
# npm ci with the committed lockfile; a fresh scaffold without one installs instead.
|
|
18
|
+
RUN if [ -f package-lock.json ]; then npm ci --no-audit --no-fund; else npm install --no-audit --no-fund; fi
|
|
19
|
+
COPY . .
|
|
20
|
+
RUN npm run build && npm prune --omit=dev
|
|
21
|
+
|
|
22
|
+
FROM ${BASE_IMAGE}
|
|
23
|
+
ENV NODE_ENV=production
|
|
24
|
+
WORKDIR /app
|
|
25
|
+
COPY --from=build /app/node_modules ./node_modules
|
|
26
|
+
COPY --from=build /app/package.json ./
|
|
27
|
+
COPY --from=build /app/apps/api/package.json ./apps/api/
|
|
28
|
+
COPY --from=build /app/apps/api/dist ./apps/api/dist
|
|
29
|
+
COPY --from=build /app/apps/web/dist ./apps/web/dist
|
|
30
|
+
# The wallet file and anything else the application keeps on disk.
|
|
31
|
+
RUN mkdir -p /app/local && chown -R node:node /app
|
|
32
|
+
USER node
|
|
33
|
+
VOLUME ["/app/local"]
|
|
34
|
+
EXPOSE 3000
|
|
35
|
+
CMD ["node", "apps/api/dist/main.js"]
|
|
@@ -0,0 +1,134 @@
|
|
|
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 same `dpp-release-2026-10-10` runtime set as the index starter. 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, keeps the journal and runs the unattended duties |
|
|
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, connect to an existing compatible index or create a separate operator project with `@bsv/create-dpp-index`. The app's Compose file starts only its database. Overlay library components are included for offline exercises; you do not install them separately or use the in-process development index as persistent service storage.
|
|
18
|
+
|
|
19
|
+
## First run
|
|
20
|
+
|
|
21
|
+
No wallet, funds, Docker or network:
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
npm test
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
This runs a whole passport lifecycle against an index in-process and a test wallet with made-up funding: issue, update, hand on with a claim code, retire, and a lifecycle claim, with the reader's report at the end. Then:
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
cp .env.example .env
|
|
31
|
+
npm run dev
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
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. Nothing reaches the chain: the wallet is a test wallet, and the index runs in-process with its header checks off.
|
|
35
|
+
|
|
36
|
+
## How a write works
|
|
37
|
+
|
|
38
|
+
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:
|
|
39
|
+
|
|
40
|
+
1. Build the state's transaction unsent, signed by the acting party and countersigned by the platform wallet.
|
|
41
|
+
2. Check it with the reader's own rules.
|
|
42
|
+
3. Announce it to the index. Send only if the index admits it; abort if it refuses. An unreachable index is not a refusal.
|
|
43
|
+
4. Send it, and report only the network's answer.
|
|
44
|
+
5. Push the merkle proof to the index once the wallet has it.
|
|
45
|
+
6. Keep the transaction, its BEEF and its proof for the passport's life.
|
|
46
|
+
|
|
47
|
+
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`.
|
|
48
|
+
|
|
49
|
+
## Custody: who signs
|
|
50
|
+
|
|
51
|
+
This application runs managed custody: the platform wallet publishes every state and holds the lock on every passport, and every brand, recipient and member signs with a key the platform derives for them. 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.
|
|
52
|
+
|
|
53
|
+
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.
|
|
54
|
+
|
|
55
|
+
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.
|
|
56
|
+
|
|
57
|
+
## Identifiers
|
|
58
|
+
|
|
59
|
+
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.
|
|
60
|
+
|
|
61
|
+
## Going live
|
|
62
|
+
|
|
63
|
+
Every npm script reads `.env` from the project root at start, so a setting changed there applies on the next run without exporting anything. Docker gets the same file with `--env-file`.
|
|
64
|
+
|
|
65
|
+
Writing a real passport spends real satoshis on BSV mainnet and is permanent. Before `LIVE_PUBLISHING=true`:
|
|
66
|
+
|
|
67
|
+
1. **MongoDB.** `docker compose -f deploy/compose.yml --env-file .env up -d mongo`, or a hosted MongoDB. Set `MONGO_URL`. Sign-in and persistence need it.
|
|
68
|
+
2. **A root key.** `openssl rand -hex 32` into `WALLET_ROOT_KEY`. Back it 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.
|
|
69
|
+
3. **Secrets.** `AUTH_SECRET`, `BRAND_ROOT_SECRET` and `MANAGED_IDENTITY_SECRET`, each `openssl rand -hex 32`. Changing an identity secret changes every key derived from it, so decide them once.
|
|
70
|
+
4. **A header source.** A WhatsOnChain API key in `WOC_API_KEY`, for the wallet's monitor and the reader.
|
|
71
|
+
5. **An index that admits your publisher key.** An index is the service this app announces each passport state to before sending it, and the service readers look passports up in. In development the API runs one in-process; live passports need one that persists, and the API refuses to start with `LIVE_PUBLISHING=true` until `INDEX_URL` is set. `npm run wallet` prints the publisher key. Follow [Connect an index](#connect-an-index) to arrange an existing provider or run a separate index project. Match the wallet's network and managed custody profile.
|
|
72
|
+
6. **Funds.** `npm run wallet` prints a funding address. Pay it from any wallet, then take the payment in with the `wallet fund` command it prints, or from the Wallet page. A state costs a little over a hundred satoshis and leaves one satoshi in the passport output.
|
|
73
|
+
7. **Your identifier host and prefix.** `PASSPORT_HOST` must be a host you control and serve this application from, so a label's QR code opens the passport page.
|
|
74
|
+
|
|
75
|
+
Then set `LIVE_PUBLISHING=true`. Until then, a write is built, checked and admitted as a draft, and aborted before the send, which is the dry run you can rehearse with.
|
|
76
|
+
|
|
77
|
+
`SPEND_CAP_SATOSHIS` refuses writes once the platform has spent that much in a day.
|
|
78
|
+
|
|
79
|
+
## Connect an index
|
|
80
|
+
|
|
81
|
+
An index is where your passports become findable: the app announces every state to it before sending, and readers, including other platforms, look states and their evidence up there. It admits only states countersigned by a publisher key it names, and it follows this app's custody model. Choose one route. This app's Compose file starts only the application database.
|
|
82
|
+
|
|
83
|
+
**Use an existing index.** Arrange admission of your publisher public key, managed custody support, and submit and proof-delivery access with its operator. Public lookup access alone is insufficient. Get its URL and network, then set the four app settings below. You need no index starter or additional overlay installation.
|
|
84
|
+
|
|
85
|
+
**Operate your own index.** Use `@bsv/create-dpp-index` in a separate directory. It includes the persistent runtime, MongoDB configuration, tokens and deployment files. This starter is a source candidate pending publication; after its release, from the directory containing your app project:
|
|
86
|
+
|
|
87
|
+
```sh
|
|
88
|
+
npm create @bsv/dpp-index@0.1.0-beta.1 my-index
|
|
89
|
+
cd my-index
|
|
90
|
+
npm test
|
|
91
|
+
npm run up
|
|
92
|
+
npm run doctor -- --online
|
|
93
|
+
npm run connection
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Supply the publisher key printed by this app's `npm run wallet` and select the same network; custody follows this app. The key is public, and the index does not need the wallet's private key. Follow the index project's README for its own startup, hosting and recovery. Before publication, use the index starter's candidate checks in the DPP repository; do not substitute another runtime version to force installation.
|
|
97
|
+
|
|
98
|
+
Copy these settings from the generated index's `.app.env`, or from the existing operator, into the app's server-side `.env`:
|
|
99
|
+
|
|
100
|
+
| App setting | Meaning |
|
|
101
|
+
| --- | --- |
|
|
102
|
+
| `INDEX_URL` | Index address reachable from the API |
|
|
103
|
+
| `INDEX_SUBMIT_TOKEN` | Submission and retraction access |
|
|
104
|
+
| `INDEX_CALLBACK_TOKEN` | Proof-delivery access |
|
|
105
|
+
| `NETWORK` | The same network as the wallet and index |
|
|
106
|
+
|
|
107
|
+
Restart the app after changing its settings. Keep these 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 index project's `npm run connection -- --url https://index.example.org` writes connection settings for a chosen address.
|
|
108
|
+
|
|
109
|
+
Check that the index's `/capabilities` names your publisher key and managed custody profile before enabling live writes. The app uses `INDEX_URL` directly and starts no in-process index when it is set. A connection failure does not cause another index to start.
|
|
110
|
+
|
|
111
|
+
## Deploy
|
|
112
|
+
|
|
113
|
+
If `.candidate.Dockerfile` is present, build with `docker build -f .candidate.Dockerfile -t my-dpp .` to include the local dependency archives. For projects generated by the published starter, build and run with the normal Dockerfile:
|
|
114
|
+
|
|
115
|
+
```sh
|
|
116
|
+
docker build -t my-dpp .
|
|
117
|
+
docker run -p 3000:3000 --env-file .env -v dpp-local:/app/local my-dpp
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
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.
|
|
121
|
+
|
|
122
|
+
## Next steps
|
|
123
|
+
|
|
124
|
+
Things this starter leaves to you, each a known path:
|
|
125
|
+
|
|
126
|
+
- **A registry of your own.** Claims are sent to `REGISTRY_URL`; the hosted reference validates without credentials and stores with permission. Running your own is the registry role of the standard.
|
|
127
|
+
- **Server-rendered passport pages.** The public page renders in the browser. If crawlers or no-JavaScript readers matter, serve a plain HTML view at the identifier route from the API.
|
|
128
|
+
- **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.
|
|
129
|
+
- **Credentials, EPCIS, federation.** The `@bsv/dpp-credentials` package, the interoperability profiles and a second index that synchronises with yours are all documented in the standard.
|
|
130
|
+
- **A wallet storage server.** For several API instances, replace the SQLite file with the toolbox client against a wallet storage server.
|
|
131
|
+
|
|
132
|
+
## Versions
|
|
133
|
+
|
|
134
|
+
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.
|