-
Notifications
You must be signed in to change notification settings - Fork 305
docs(web-demo): add consumer config matrix for retail and UI #9235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mmcshinsky-bitgo
wants to merge
3
commits into
master
Choose a base branch
from
side/web-demo-profile-readme
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -74,6 +74,7 @@ module.exports = { | |
| 'WAL-', | ||
| 'WCN-', | ||
| 'WCI-', | ||
| 'WEB-', | ||
| 'COIN-', | ||
| 'COINS-', | ||
| 'COINFLP-', | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,63 @@ | ||
| # web-demo | ||
|
|
||
| This module serves as an example on how you can integrate the BitGo SDK into your own UI. | ||
| 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. | ||
|
|
||
| ## Usage | ||
| ## Quick start | ||
|
|
||
| In order to start the server, run the following command after having already run `yarn install` in the root of the repo. | ||
| From the BitGoJS repo root (after `yarn install`): | ||
|
|
||
| ``` | ||
| ```bash | ||
| cd modules/web-demo | ||
| yarn dev | ||
| ``` | ||
|
|
||
| This will spin up a server serving the UI at [localhost:8080](localhost:8080). | ||
| Opens [localhost:8080](http://localhost:8080). | ||
|
|
||
| ## Consumer config matrix | ||
|
|
||
| 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. | ||
|
|
||
| | Profile | Status | Mirrors | Bundler | WASM | SDK auth | | ||
| | --- | --- | --- | --- | --- | --- | | ||
| | `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` | | ||
| | `retail-browser` | planned | bitgo-retail web (`MOBILE_MODE` off) | Webpack profile | Full `@bitgo/wasm-*` ESM paths, DKLS/cardano browser swaps | `WebCryptoHmacStrategy` + `requestIdPrefix` | | ||
| | `retail-mobile-stub` | planned | bitgo-retail mobile webview | Webpack profile | Empty WASM shims (no heavy signing WASM) | Bridge / token (documented only) | | ||
| | `direct-sdk` | planned | bitgo-retail mock server, `examples/ts` | Either | Per profile | `BitGoAPI` + `customRootURI`, no Express | | ||
| | `express-proxy` | planned | Self-hosted Express users | Either | Per profile | Local Express signing proxy | | ||
|
|
||
| **Planned usage** (not wired yet): | ||
|
|
||
| ```bash | ||
| yarn dev # classic-webpack | ||
| CONSUMER_PROFILE=retail-browser yarn dev # future | ||
| CONSUMER_PROFILE=retail-mobile-stub yarn dev # future | ||
| ``` | ||
|
|
||
| ### What each production app solved | ||
|
|
||
| | Problem | bitgo-retail | bitgo-ui | web-demo route | | ||
| | --- | --- | --- | --- | | ||
| | Browser WASM loading | Vite ESM aliases for `@bitgo/wasm-utxo`, `wasm-ton`, `wasm-mps` | Webpack aliases (similar) | `/wasm-miniscript` | | ||
| | HMAC without raw token in storage | `WebCryptoHmacStrategy` + IndexedDB | Classic token flow | `/webcrypto-auth` | | ||
| | Passkey PRF wallet flows | `@bitgo-private/web-client` (retail); SDK: `@bitgo/passkey-crypto` | Partial | `/passkey-demo` | | ||
| | Keycard generation | `@bitgo/key-card` in wallet create / migration | Keycard flows | `/keycard` | | ||
| | Lazy coin registration | `retail-sdk-client/coinFactory` | `~/utils/coinFactory` | `/coins` | | ||
| | Token enable prebuild | React Query + `PrebuildTransactionResult` | `useBuildTokenEnablementMutation` | planned `/token-enable` | | ||
|
|
||
| ## Demo routes | ||
|
|
||
| | Path | Description | | ||
| | --- | --- | | ||
| | `/` | Home | | ||
| | `/bitgo-js` | BitGo SDK object inspect | | ||
| | `/bitgo-api` | BitGoAPI usage | | ||
| | `/coins` | Coin factory / registration | | ||
| | `/keycard` | Keycard download fixtures | | ||
| | `/wasm-miniscript` | WASM miniscript smoke | | ||
| | `/ecdsachallenge` | ECDSA challenge generation | | ||
| | `/webcrypto-auth` | WebCrypto HMAC strategy + IndexedDB session | | ||
| | `/passkey-demo` | Passkey register / attach / wallet (uses `@bitgo/passkey-crypto`) | | ||
|
|
||
| ## Contributing | ||
|
|
||
| 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| const assert = require('assert'); | ||
| const { extractTicket, appendTicketFooter } = require('../prepare-commit-msg'); | ||
|
|
||
| describe('extractTicket', () => { | ||
| it('extracts uppercase ticket from uppercase branch', () => { | ||
| assert.strictEqual(extractTicket('WEB-000-my-feature'), 'WEB-000'); | ||
| }); | ||
|
|
||
| it('extracts and uppercases ticket from lowercase branch', () => { | ||
| assert.strictEqual(extractTicket('web-000-my-feature'), 'WEB-000'); | ||
| }); | ||
|
|
||
| it('extracts WP ticket', () => { | ||
| assert.strictEqual(extractTicket('WP-1234-some-work'), 'WP-1234'); | ||
| }); | ||
|
|
||
| it('returns null for branches without a known prefix', () => { | ||
| assert.strictEqual(extractTicket('release-2-hotfix'), null); | ||
| assert.strictEqual(extractTicket('main'), null); | ||
| assert.strictEqual(extractTicket('feature-no-ticket'), null); | ||
| }); | ||
|
|
||
| it('is anchored at branch start (ignores prefixes mid-name)', () => { | ||
| assert.strictEqual(extractTicket('feature/WEB-000-x'), null); | ||
| }); | ||
|
|
||
| it('returns null for prefix without digits (WEB-foo)', () => { | ||
| assert.strictEqual(extractTicket('WEB-foo'), null); | ||
| }); | ||
|
|
||
| it('returns null for empty branch', () => { | ||
| assert.strictEqual(extractTicket(''), null); | ||
| }); | ||
| }); | ||
|
|
||
| describe('appendTicketFooter', () => { | ||
| it('appends a TICKET footer when none is present', () => { | ||
| assert.strictEqual(appendTicketFooter('feat: add thing', 'WEB-000'), 'feat: add thing\nTICKET: WEB-000\n'); | ||
| }); | ||
|
|
||
| it('returns null when ticket is null (branch had no match)', () => { | ||
| assert.strictEqual(appendTicketFooter('feat: add thing', null), null); | ||
| }); | ||
|
|
||
| it('returns null when a TICKET footer already exists', () => { | ||
| assert.strictEqual(appendTicketFooter('feat: add thing\n\nTICKET: WEB-000', 'WEB-000'), null); | ||
| }); | ||
|
|
||
| it('returns null when an ISSUE footer already exists (any case)', () => { | ||
| assert.strictEqual(appendTicketFooter('feat: add thing\n\nissue: WEB-111', 'WEB-000'), null); | ||
| }); | ||
|
|
||
| it('is not stateful across repeated calls (global-regex lastIndex safe)', () => { | ||
| // Guards against RegExp.lastIndex leaking between .test() invocations. | ||
| assert.strictEqual(appendTicketFooter('feat: a', 'WEB-000'), 'feat: a\nTICKET: WEB-000\n'); | ||
| assert.strictEqual(appendTicketFooter('feat: b', 'WEB-000'), 'feat: b\nTICKET: WEB-000\n'); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ironically, a script that deserves tests!