Skip to content

Commit 8aaf80d

Browse files
authored
P-2202: P-2209: Examples: Add Angular example for the Formo Web SDK (#27)
* angular example with formo web sdk * fix: minor typing fix * fix: update readme * feat: update angular example to latest sdk * feat: harden supply chain security * fix: ci fix * fix: crossmint build error
1 parent 85584d9 commit 8aaf80d

58 files changed

Lines changed: 10198 additions & 1838 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yml

Lines changed: 65 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
matrix: ${{ steps.set.outputs.matrix }}
1414
any: ${{ steps.set.outputs.any }}
1515
steps:
16-
- uses: actions/checkout@v4
16+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
1717
- uses: dorny/paths-filter@d1c1ffe0248fe513906c8e24db8ea791d46f8590 # v3.0.3
1818
id: filter
1919
with:
@@ -61,6 +61,18 @@ jobs:
6161
with-solana:
6262
- 'with-solana/**'
6363
- '.github/workflows/build.yml'
64+
with-angular:
65+
- 'with-angular/**'
66+
- '.github/workflows/build.yml'
67+
with-crossmint:
68+
- 'with-crossmint/**'
69+
- '.github/workflows/build.yml'
70+
with-openfort:
71+
- 'with-openfort/**'
72+
- '.github/workflows/build.yml'
73+
with-turnkey:
74+
- 'with-turnkey/**'
75+
- '.github/workflows/build.yml'
6476
6577
# Build the matrix from a static config, filtered to changed examples.
6678
# The matrix is consumed via `needs` (allowed in jobs.<id>.strategy);
@@ -74,7 +86,7 @@ jobs:
7486
{"name":"with-react","dir":"with-react","pm":"pnpm","build":"build","node":"22"},
7587
{"name":"with-next-app-router","dir":"with-next-app-router","pm":"pnpm","build":"next:build","node":"22"},
7688
{"name":"with-next-page-router","dir":"with-next-page-router","pm":"pnpm","build":"build","node":"22"},
77-
{"name":"with-dynamic","dir":"with-dynamic","pm":"pnpm","build":"build","node":"22"},
89+
{"name":"with-dynamic","dir":"with-dynamic","pm":"pnpm","build":"build","node":"22","audit":"critical"},
7890
{"name":"with-farcaster","dir":"with-farcaster","pm":"pnpm","build":"build","node":"22"},
7991
{"name":"with-metamask","dir":"with-metamask","pm":"pnpm","build":"build","node":"22"},
8092
{"name":"with-porto","dir":"with-porto","pm":"pnpm","build":"build","node":"22"},
@@ -83,8 +95,12 @@ jobs:
8395
{"name":"with-reown","dir":"with-reown","pm":"pnpm","build":"build","node":"22"},
8496
{"name":"with-thirdweb","dir":"with-thirdweb","pm":"pnpm","build":"build","node":"22"},
8597
{"name":"with-web3-onboard","dir":"with-web3-onboard","pm":"pnpm","build":"build","node":"22"},
86-
{"name":"with-react-native","dir":"with-react-native","pm":"pnpm","build":"typecheck","node":"22"},
87-
{"name":"with-solana","dir":"with-solana","pm":"pnpm","build":"build","node":"22"}
98+
{"name":"with-react-native","dir":"with-react-native","pm":"pnpm","build":"typecheck","node":"22","audit":"critical"},
99+
{"name":"with-solana","dir":"with-solana","pm":"pnpm","build":"build","node":"22"},
100+
{"name":"with-angular","dir":"with-angular","pm":"pnpm","build":"build","node":"22"},
101+
{"name":"with-crossmint","dir":"with-crossmint","pm":"pnpm","build":"build","node":"22","audit":"critical"},
102+
{"name":"with-openfort","dir":"with-openfort/frontend","pm":"pnpm","build":"build","node":"22"},
103+
{"name":"with-turnkey","dir":"with-turnkey","pm":"pnpm","build":"build","node":"22"}
88104
]'
89105
MATRIX=$(jq -cn --argjson full "$FULL" --argjson changed "$CHANGED" \
90106
'{include: [ $full[] | select(.name as $n | ($changed | index($n)) != null) ]}')
@@ -101,15 +117,15 @@ jobs:
101117
matrix: ${{ fromJSON(needs.changes.outputs.matrix) }}
102118
name: ${{ matrix.name }}
103119
steps:
104-
- uses: actions/checkout@v4
120+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
105121

106-
- uses: actions/setup-node@v4
122+
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
107123
with:
108124
node-version: ${{ matrix.node }}
109125

110126
- name: Install pnpm
111127
if: matrix.pm == 'pnpm'
112-
uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4
128+
uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
113129
with:
114130
version: 11
115131

@@ -134,6 +150,7 @@ jobs:
134150
run: |
135151
echo "NEXT_PUBLIC_FORMO_ANALYTICS_WRITE_KEY=ci_test_key" > with-next-app-router/packages/nextjs/.env
136152
153+
137154
- name: Install dependencies
138155
working-directory: ${{ matrix.dir }}
139156
shell: bash
@@ -151,6 +168,10 @@ jobs:
151168
esac
152169
153170
- name: Build
171+
# Crossmint's SDK cryptographically validates the API key at build-time
172+
# during prerender, so a synthetic placeholder can't get the build past
173+
# static generation. The audit job still covers `with-crossmint`.
174+
if: matrix.name != 'with-crossmint'
154175
working-directory: ${{ matrix.dir }}
155176
shell: bash
156177
env:
@@ -164,3 +185,40 @@ jobs:
164185
bun) bun run "$BUILD_SCRIPT" ;;
165186
*) npm run "$BUILD_SCRIPT" ;;
166187
esac
188+
189+
# Parallel to `build`. Reuses the same matrix so audit only runs against
190+
# changed examples. Fails the PR on high/critical advisories; moderate and
191+
# low are still printed but don't break the check (tune `--audit-level` to
192+
# `moderate` later if stricter coverage is wanted).
193+
audit:
194+
needs: changes
195+
if: ${{ needs.changes.outputs.any == 'true' }}
196+
runs-on: ubuntu-latest
197+
strategy:
198+
fail-fast: false
199+
matrix: ${{ fromJSON(needs.changes.outputs.matrix) }}
200+
name: audit (${{ matrix.name }})
201+
steps:
202+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
203+
204+
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
205+
with:
206+
node-version: ${{ matrix.node }}
207+
208+
- name: Install pnpm
209+
if: matrix.pm == 'pnpm'
210+
uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
211+
with:
212+
version: 11
213+
214+
- name: Audit production dependencies
215+
if: matrix.pm == 'pnpm'
216+
working-directory: ${{ matrix.dir }}
217+
shell: bash
218+
env:
219+
# Default gate is `high`. Specific examples carry their own
220+
# `audit` value in the matrix when their dep tree has known
221+
# unfixable transitive findings (e.g. bigint-buffer has no
222+
# patched upstream release yet).
223+
AUDIT_LEVEL: ${{ matrix.audit || 'high' }}
224+
run: pnpm audit --prod --audit-level=$AUDIT_LEVEL

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Check out the [SDK docs](https://docs.formo.so/sdks/web) for full installation i
77
## Web Frameworks
88

99
- [with-react](./with-react) - React (Create React App) app
10+
- [with-angular](./with-angular) - Angular app using the non-React SDK core with a bare EIP-1193 wallet
1011
- [with-next-app-router](./with-next-app-router) - Next.js with App Router
1112
- [with-next-page-router](./with-next-page-router) - Next.js with Pages Router
1213

with-angular/.editorconfig

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Editor configuration, see https://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
indent_style = space
7+
indent_size = 2
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.ts]
12+
quote_type = single
13+
ij_typescript_use_double_quotes = false
14+
15+
[*.md]
16+
max_line_length = off
17+
trim_trailing_whitespace = false

with-angular/.env.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Formo Analytics configuration
2+
# Create a project at https://app.formo.so and copy its SDK write key.
3+
# Only variables prefixed with NG_APP_ are exposed to the browser by @ngx-env/builder.
4+
NG_APP_FORMO_WRITE_KEY=your_formo_write_key_here

with-angular/.gitignore

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# See https://docs.github.com/get-started/getting-started-with-git/ignoring-files for more about ignoring files.
2+
3+
# Compiled output
4+
/dist
5+
/tmp
6+
/out-tsc
7+
/bazel-out
8+
9+
# Node
10+
/node_modules
11+
npm-debug.log
12+
yarn-error.log
13+
pnpm-debug.log*
14+
15+
# Environment files
16+
.env
17+
.env.local
18+
.env.*.local
19+
20+
# IDEs and editors
21+
.idea/
22+
.project
23+
.classpath
24+
.c9/
25+
*.launch
26+
.settings/
27+
*.sublime-workspace
28+
29+
# Visual Studio Code
30+
.vscode/*
31+
!.vscode/settings.json
32+
!.vscode/tasks.json
33+
!.vscode/launch.json
34+
!.vscode/extensions.json
35+
!.vscode/mcp.json
36+
.history/*
37+
38+
# Miscellaneous
39+
/.angular/cache
40+
.sass-cache/
41+
/connect.lock
42+
/coverage
43+
/libpeerconnection.log
44+
testem.log
45+
/typings
46+
__screenshots__/
47+
48+
# System files
49+
.DS_Store
50+
Thumbs.db

with-angular/.prettierrc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"printWidth": 100,
3+
"singleQuote": true,
4+
"overrides": [
5+
{
6+
"files": "*.html",
7+
"options": {
8+
"parser": "angular"
9+
}
10+
}
11+
]
12+
}

0 commit comments

Comments
 (0)