Skip to content

Commit b01cc28

Browse files
docs(web-demo): add consumer config matrix for retail and UI
Document planned CONSUMER_PROFILE setups and map demo routes to production patterns from bitgo-retail and bitgo-ui. WEB-000
1 parent ef0927d commit b01cc28

3 files changed

Lines changed: 97 additions & 11 deletions

File tree

modules/web-demo/README.md

Lines changed: 55 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,63 @@
11
# web-demo
22

3-
This module serves as an example on how you can integrate the BitGo SDK into your own UI.
3+
Reference UI for integrating the BitGo SDK in the browser. Routes mirror problems solved in production apps (**bitgo-retail**, **bitgo-ui**) using SDK packages directly — no private `@bitgo-private/*` dependencies.
44

5-
## Usage
5+
## Quick start
66

7-
In order to start the server, run the following command after having already run `yarn install` in the root of the repo.
7+
From the BitGoJS repo root (after `yarn install`):
88

9-
```
9+
```bash
10+
cd modules/web-demo
1011
yarn dev
1112
```
1213

13-
This will spin up a server serving the UI at [localhost:8080](localhost:8080).
14+
Opens [localhost:8080](http://localhost:8080).
15+
16+
## Consumer config matrix
17+
18+
Production apps bundle the SDK differently. web-demo will support **consumer profiles** (via `CONSUMER_PROFILE` env) so each profile documents one real-world setup. Profiles are added incrementally; only `classic-webpack` is active today.
19+
20+
| Profile | Status | Mirrors | Bundler | WASM | SDK auth |
21+
| --- | --- | --- | --- | --- | --- |
22+
| `classic-webpack` | **active** (default) | bitgo-ui classic app, default web-demo | Webpack + [`webpack/bitgojs.config.js`](../../webpack/bitgojs.config.js) | Partial ESM aliases in shared config | Access token or `/webcrypto-auth` |
23+
| `retail-browser` | planned | bitgo-retail web (`MOBILE_MODE` off) | Webpack profile | Full `@bitgo/wasm-*` ESM paths, DKLS/cardano browser swaps | `WebCryptoHmacStrategy` + `requestIdPrefix` |
24+
| `retail-mobile-stub` | planned | bitgo-retail mobile webview | Webpack profile | Empty WASM shims (no heavy signing WASM) | Bridge / token (documented only) |
25+
| `direct-sdk` | planned | bitgo-retail mock server, `examples/ts` | Either | Per profile | `BitGoAPI` + `customRootURI`, no Express |
26+
| `express-proxy` | planned | Self-hosted Express users | Either | Per profile | Local Express signing proxy |
27+
28+
**Planned usage** (not wired yet):
29+
30+
```bash
31+
yarn dev # classic-webpack
32+
CONSUMER_PROFILE=retail-browser yarn dev # future
33+
CONSUMER_PROFILE=retail-mobile-stub yarn dev # future
34+
```
35+
36+
### What each production app solved
37+
38+
| Problem | bitgo-retail | bitgo-ui | web-demo route |
39+
| --- | --- | --- | --- |
40+
| Browser WASM loading | Vite ESM aliases for `@bitgo/wasm-utxo`, `wasm-ton`, `wasm-mps` | Webpack aliases (similar) | `/wasm-miniscript` |
41+
| HMAC without raw token in storage | `WebCryptoHmacStrategy` + IndexedDB | Classic token flow | `/webcrypto-auth` |
42+
| Passkey PRF wallet flows | `@bitgo-private/web-client` (retail); SDK: `@bitgo/passkey-crypto` | Partial | `/passkey-demo` |
43+
| Keycard generation | `@bitgo/key-card` in wallet create / migration | Keycard flows | `/keycard` |
44+
| Lazy coin registration | `retail-sdk-client/coinFactory` | `~/utils/coinFactory` | `/coins` |
45+
| Token enable prebuild | React Query + `PrebuildTransactionResult` | `useBuildTokenEnablementMutation` | planned `/token-enable` |
46+
47+
## Demo routes
48+
49+
| Path | Description |
50+
| --- | --- |
51+
| `/` | Home |
52+
| `/bitgo-js` | BitGo SDK object inspect |
53+
| `/bitgo-api` | BitGoAPI usage |
54+
| `/coins` | Coin factory / registration |
55+
| `/keycard` | Keycard download fixtures |
56+
| `/wasm-miniscript` | WASM miniscript smoke |
57+
| `/ecdsachallenge` | ECDSA challenge generation |
58+
| `/webcrypto-auth` | WebCrypto HMAC strategy + IndexedDB session |
59+
| `/passkey-demo` | Passkey register / attach / wallet (uses `@bitgo/passkey-crypto`) |
60+
61+
## Contributing
62+
63+
Owned by **@BitGo/web-experience** (`CODEOWNERS`). Prefer small PRs: one profile, one route, or one README section at a time. See the local BitGoJS side-improvements plan for micro-PR sizing.

scripts/prepare-commit-msg.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,30 @@ const childProcess = require('child_process');
55
const fs = require('fs');
66
const exec = promisify(childProcess.exec);
77

8-
// ex WP-1234 or WEB-000 (case-insensitive)
9-
const branchRegex = /([A-Za-z]+-)(\d+)/i;
8+
// Build regex from commitlint's known issuePrefixes so arbitrary branch segments
9+
// (e.g. "release-2-hotfix") don't produce bogus TICKET footers.
10+
const { issuePrefixes } = require('../commitlint.config.js').parserPreset.parserOpts;
11+
const escapedPrefixes = issuePrefixes
12+
.filter((p) => p !== '#')
13+
.map((p) => p.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'));
14+
// Anchored at branch start; case-insensitive so "web-000-desc" matches "WEB-"
15+
const branchRegex = new RegExp(`^(${escapedPrefixes.join('|')})(\\d+)`, 'i');
1016
// ex TICKET: WP-1234
1117
const commitRegex = /(ticket|issue):\s(\S+)/gim;
1218

19+
function extractTicket(branch) {
20+
const found = branch.match(branchRegex);
21+
return found ? found[0].toUpperCase() : null;
22+
}
23+
1324
async function main() {
1425
const commitMsgFilepath = process.argv[2];
1526
try {
1627
const branch = (await exec(`git branch --show-current`)).stdout.trim();
17-
const found = branch.match(branchRegex);
18-
// Do not append message if branch name does not match regex
19-
if (!found) {
28+
const ticket = extractTicket(branch);
29+
if (!ticket) {
2030
return;
2131
}
22-
const ticket = found[0].toUpperCase();
2332
const data = fs.readFileSync(commitMsgFilepath, 'utf8');
2433
// Exit if ticket is already in commit footer
2534
if (data.match(commitRegex)) {
@@ -29,4 +38,5 @@ async function main() {
2938
} catch (e) {}
3039
}
3140

41+
module.exports = { extractTicket };
3242
main();
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
const assert = require('assert');
2+
const { extractTicket } = require('../prepare-commit-msg');
3+
4+
describe('extractTicket', () => {
5+
it('extracts uppercase ticket from uppercase branch', () => {
6+
assert.strictEqual(extractTicket('WEB-000-my-feature'), 'WEB-000');
7+
});
8+
9+
it('extracts and uppercases ticket from lowercase branch', () => {
10+
assert.strictEqual(extractTicket('web-000-my-feature'), 'WEB-000');
11+
});
12+
13+
it('extracts WP ticket', () => {
14+
assert.strictEqual(extractTicket('WP-1234-some-work'), 'WP-1234');
15+
});
16+
17+
it('returns null for branches without a known prefix', () => {
18+
assert.strictEqual(extractTicket('release-2-hotfix'), null);
19+
assert.strictEqual(extractTicket('main'), null);
20+
assert.strictEqual(extractTicket('feature-no-ticket'), null);
21+
});
22+
23+
it('returns null for empty branch', () => {
24+
assert.strictEqual(extractTicket(''), null);
25+
});
26+
});

0 commit comments

Comments
 (0)