Skip to content

Commit 238c827

Browse files
committed
Initial commit
Signed-off-by: Kamal Tufekcic <kamal@lo.sh>
0 parents  commit 238c827

File tree

143 files changed

+47322
-0
lines changed

Some content is hidden

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

143 files changed

+47322
-0
lines changed

.github/workflows/ci.yml

Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
tags: ['v*']
7+
pull_request:
8+
branches: [main]
9+
10+
permissions:
11+
contents: read
12+
pages: write
13+
id-token: write
14+
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.ref }}
17+
cancel-in-progress: true
18+
19+
jobs:
20+
build:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0
27+
28+
- name: Get LibOQS commit hash
29+
id: liboqs-hash
30+
run: |
31+
LIBOQS_HASH=$(git ls-remote https://github.com/open-quantum-safe/liboqs.git refs/heads/main | cut -f1)
32+
echo "hash=$LIBOQS_HASH" >> $GITHUB_OUTPUT
33+
echo "LibOQS commit: $LIBOQS_HASH"
34+
35+
- name: Cache WASM modules
36+
id: cache-wasm
37+
uses: actions/cache@v4
38+
with:
39+
path: dist/
40+
key: wasm-${{ steps.liboqs-hash.outputs.hash }}-${{ hashFiles('build.sh', 'algorithms.json') }}
41+
restore-keys: |
42+
wasm-${{ steps.liboqs-hash.outputs.hash }}-
43+
wasm-
44+
45+
- name: Setup Emscripten
46+
if: steps.cache-wasm.outputs.cache-hit != 'true'
47+
uses: mymindstorm/setup-emsdk@v14
48+
49+
- name: Build WASM modules
50+
if: steps.cache-wasm.outputs.cache-hit != 'true'
51+
run: ./build.sh
52+
53+
- name: Verify WASM modules
54+
run: |
55+
set -euo pipefail
56+
expected=$(jq '[.kem, .sig, ."sig-stateful" | .. | .slug? | select(. != null)] | length' algorithms.json)
57+
node_count=$(find dist/ -name "*.min.js" -type f | wc -l)
58+
deno_count=$(find dist/ -name "*.deno.js" -type f | wc -l)
59+
60+
echo "Expected: $expected modules per runtime"
61+
echo "Node.js modules: $node_count"
62+
echo "Deno modules: $deno_count"
63+
64+
if [ "$node_count" -ne "$expected" ]; then
65+
echo "::error::Node.js module count mismatch. Expected $expected, got $node_count"
66+
exit 1
67+
fi
68+
69+
if [ "$deno_count" -ne "$expected" ]; then
70+
echo "::error::Deno module count mismatch. Expected $expected, got $deno_count"
71+
exit 1
72+
fi
73+
74+
echo "All $expected Node.js and Deno modules verified"
75+
76+
- name: Upload dist artifact
77+
uses: actions/upload-artifact@v4
78+
with:
79+
name: dist
80+
path: dist/
81+
retention-days: 7
82+
83+
test:
84+
needs: build
85+
runs-on: ubuntu-latest
86+
steps:
87+
- name: Checkout repository
88+
uses: actions/checkout@v4
89+
90+
- name: Download dist artifact
91+
uses: actions/download-artifact@v4
92+
with:
93+
name: dist
94+
path: dist/
95+
96+
- name: Setup Bun
97+
uses: oven-sh/setup-bun@v2
98+
99+
- name: Install dependencies
100+
run: bun install
101+
102+
- name: Install Playwright
103+
run: bunx playwright install --with-deps chromium
104+
105+
- name: Run Node.js tests
106+
run: bun run test
107+
108+
test-deno:
109+
needs: build
110+
runs-on: ubuntu-latest
111+
steps:
112+
- name: Checkout repository
113+
uses: actions/checkout@v4
114+
115+
- name: Download dist artifact
116+
uses: actions/download-artifact@v4
117+
with:
118+
name: dist
119+
path: dist/
120+
121+
- name: Setup Deno
122+
uses: denoland/setup-deno@v2
123+
124+
- name: Run Deno tests
125+
run: deno test --allow-read --allow-write --allow-run --allow-env --no-check tests/deno/
126+
127+
docs:
128+
needs: build
129+
runs-on: ubuntu-latest
130+
if: github.event_name == 'push'
131+
environment:
132+
name: github-pages
133+
url: ${{ steps.deploy.outputs.page_url }}
134+
steps:
135+
- name: Checkout repository
136+
uses: actions/checkout@v4
137+
138+
- name: Download dist artifact
139+
uses: actions/download-artifact@v4
140+
with:
141+
name: dist
142+
path: dist/
143+
144+
- name: Setup Bun
145+
uses: oven-sh/setup-bun@v2
146+
147+
- name: Install dependencies
148+
run: bun install
149+
150+
- name: Build documentation
151+
run: bunx typedoc
152+
153+
- name: Upload pages artifact
154+
uses: actions/upload-pages-artifact@v3
155+
with:
156+
path: docs/
157+
158+
- name: Deploy to GitHub Pages
159+
id: deploy
160+
uses: actions/deploy-pages@v4
161+
162+
publish:
163+
needs: [test, test-deno]
164+
runs-on: ubuntu-latest
165+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
166+
permissions:
167+
contents: read
168+
id-token: write
169+
steps:
170+
- name: Checkout repository
171+
uses: actions/checkout@v4
172+
173+
- name: Download dist artifact
174+
uses: actions/download-artifact@v4
175+
with:
176+
name: dist
177+
path: dist/
178+
179+
- name: Setup Node.js
180+
uses: actions/setup-node@v4
181+
with:
182+
node-version: 24
183+
registry-url: https://registry.npmjs.org
184+
185+
- name: Check if version already published
186+
id: check
187+
run: |
188+
PACKAGE_VERSION=$(node -p "require('./package.json').version")
189+
if npm view @oqs/liboqs-js@$PACKAGE_VERSION version &>/dev/null; then
190+
echo "Version $PACKAGE_VERSION already published"
191+
echo "skip=true" >> $GITHUB_OUTPUT
192+
else
193+
echo "Version $PACKAGE_VERSION not yet published"
194+
echo "skip=false" >> $GITHUB_OUTPUT
195+
fi
196+
197+
- name: Publish to npm
198+
if: steps.check.outputs.skip == 'false'
199+
run: npm publish --provenance --access public
200+
env:
201+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.gitignore

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
lerna-debug.log*
8+
9+
# Diagnostic reports (https://nodejs.org/api/report.html)
10+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
11+
12+
# Runtime data
13+
pids
14+
*.pid
15+
*.seed
16+
*.pid.lock
17+
18+
# Directory for instrumented libs generated by jscoverage/JSCover
19+
lib-cov
20+
21+
# Coverage directory used by tools like istanbul
22+
coverage
23+
*.lcov
24+
25+
# nyc test coverage
26+
.nyc_output
27+
28+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
29+
.grunt
30+
31+
# Bower dependency directory (https://bower.io/)
32+
bower_components
33+
34+
# node-waf configuration
35+
.lock-wscript
36+
37+
# Compiled binary addons (https://nodejs.org/api/addons.html)
38+
build/Release
39+
40+
# Dependency directories
41+
node_modules/
42+
jspm_packages/
43+
44+
# Package manager lockfiles (keep bun.lockb, ignore others for flexibility)
45+
package-lock.json
46+
yarn.lock
47+
pnpm-lock.yaml
48+
# bun.lock
49+
50+
# Snowpack dependency directory (https://snowpack.dev/)
51+
web_modules/
52+
53+
# TypeScript cache
54+
*.tsbuildinfo
55+
56+
# Optional npm cache directory
57+
.npm
58+
59+
# Optional eslint cache
60+
.eslintcache
61+
62+
# Optional stylelint cache
63+
.stylelintcache
64+
65+
# Optional REPL history
66+
.node_repl_history
67+
68+
# Output of 'npm pack'
69+
*.tgz
70+
71+
# Yarn Integrity file
72+
.yarn-integrity
73+
74+
# dotenv environment variable files
75+
.env
76+
.env.*
77+
!.env.example
78+
79+
# parcel-bundler cache (https://parceljs.org/)
80+
.cache
81+
.parcel-cache
82+
83+
# Next.js build output
84+
.next
85+
out
86+
87+
# Nuxt.js build / generate output
88+
.nuxt
89+
.output
90+
91+
# Gatsby files
92+
.cache/
93+
# Comment in the public line in if your project uses Gatsby and not Next.js
94+
# https://nextjs.org/blog/next-9-1#public-directory-support
95+
# public
96+
97+
# vuepress build output
98+
.vuepress/dist
99+
100+
# vuepress v2.x temp and cache directory
101+
.temp
102+
.cache
103+
104+
# Sveltekit cache directory
105+
.svelte-kit/
106+
107+
# vitepress build output
108+
**/.vitepress/dist
109+
110+
# vitepress cache directory
111+
**/.vitepress/cache
112+
113+
# Docusaurus cache and generated files
114+
.docusaurus
115+
116+
# Serverless directories
117+
.serverless/
118+
119+
# FuseBox cache
120+
.fusebox/
121+
122+
# DynamoDB Local files
123+
.dynamodb/
124+
125+
# Firebase cache directory
126+
.firebase/
127+
128+
# TernJS port file
129+
.tern-port
130+
131+
# Stores VSCode versions used for testing VSCode extensions
132+
.vscode-test
133+
134+
# yarn v3
135+
.pnp.*
136+
.yarn/*
137+
!.yarn/patches
138+
!.yarn/plugins
139+
!.yarn/releases
140+
!.yarn/sdks
141+
!.yarn/versions
142+
143+
# Vite files
144+
vite.config.js.timestamp-*
145+
vite.config.ts.timestamp-*
146+
.vite/
147+
148+
docs/
149+
dist/
150+
builds-wasm/
151+
liboqs/

.npmignore

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
tests/
2+
*.test.js
3+
*.test.ts
4+
vitest.config.js
5+
tsconfig.json
6+
typedoc.json
7+
8+
builds-wasm/
9+
liboqs/
10+
node_modules/
11+
12+
.github/
13+
14+
.vscode/
15+
.idea/
16+
17+
.git/
18+
.gitignore
19+
.gitattributes
20+
21+
*.log
22+
23+
package-lock.json
24+
yarn.lock
25+
pnpm-lock.yaml
26+
bun.lock

.npmrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
engine-strict=false
2+
prefer-offline=true

0 commit comments

Comments
 (0)