Skip to content

Commit 0119940

Browse files
committed
Vendor Oslo dependencies
1 parent 60be8c9 commit 0119940

27 files changed

Lines changed: 6848 additions & 71 deletions

eslint.config.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ export default defineConfig([
1515
".context/**",
1616
".pnpm-store/**",
1717
"packages/argon2id-wasm/rust/pkg/**",
18+
// Generated wasm-bindgen output.
19+
"packages/argon2id/src/argon2-wasm/pkg/**",
1820
// Generated output in the docs package (Next.js build + Fumadocs MDX).
1921
"packages/docs/.next/**",
2022
"packages/docs/.source/**",

packages/core/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@
5353
},
5454
"dependencies": {
5555
"@convex-dev/rate-limiter": "^0.3.2",
56-
"@oslojs/crypto": "^1.0.1",
57-
"@oslojs/webauthn": "^1.0.0",
5856
"argon2id-wasm": "0.0.0-alpha.1",
5957
"commander": "^14.0.2",
6058
"cookie": "1.1.1",

packages/core/src/components/passkey/authentication.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ import {
55
createAssertionSignatureMessage,
66
parseAuthenticatorData,
77
parseClientDataJSON,
8-
} from "@oslojs/webauthn";
8+
} from "../../vendor/oslo/webauthn";
99
import {
1010
decodePKIXECDSASignature,
1111
decodeSEC1PublicKey,
1212
p256,
1313
verifyECDSASignature,
14-
} from "@oslojs/crypto/ecdsa";
14+
} from "../../vendor/oslo/crypto/ecdsa";
1515
import {
1616
decodePKCS1RSAPublicKey,
1717
sha256ObjectIdentifier,
1818
verifyRSASSAPKCS1v15Signature,
19-
} from "@oslojs/crypto/rsa";
20-
import { sha256 } from "@oslojs/crypto/sha2";
19+
} from "../../vendor/oslo/crypto/rsa";
20+
import { sha256 } from "../../vendor/oslo/crypto/sha2";
2121
import { finishAuthenticationUserError } from "./validation";
2222
import { consumeChallenge, randomChallenge } from "./helpers";
2323

packages/core/src/components/passkey/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { MutationCtx } from "./_generated/server";
2-
import { constantTimeEqual } from "@oslojs/crypto/subtle";
2+
import { constantTimeEqual } from "../../vendor/oslo/crypto/subtle";
33

44
// The time for which a stored challenge stays valid. A WebAuthn ceremony
55
// completes in seconds. An older challenge shows a stale tab or a replay

packages/core/src/components/passkey/registration.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import {
77
coseEllipticCurveP256,
88
parseAttestationObject,
99
parseClientDataJSON,
10-
} from "@oslojs/webauthn";
11-
import { ECDSAPublicKey, p256 } from "@oslojs/crypto/ecdsa";
12-
import { RSAPublicKey } from "@oslojs/crypto/rsa";
10+
} from "../../vendor/oslo/webauthn";
11+
import { ECDSAPublicKey, p256 } from "../../vendor/oslo/crypto/ecdsa";
12+
import { RSAPublicKey } from "../../vendor/oslo/crypto/rsa";
1313
import {
1414
finishRegistrationUserError,
1515
deletePasskeyUserError,
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 pilcrowOnPaper
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Vendored Oslo libraries
2+
3+
This directory contains code vendored from the [Oslo
4+
project](https://oslojs.dev) by pilcrowOnPaper. The Oslo project is being
5+
deprecated, so the parts that the passkey component relies on live here
6+
instead of coming in as npm dependencies.
7+
8+
All of the code is MIT-licensed, Copyright (c) 2024 pilcrowOnPaper (see the
9+
`LICENSE` file in this directory).
10+
11+
## Sources
12+
13+
Each directory mirrors one Oslo package, and the file layout follows the
14+
package's public import specifiers (for example `@oslojs/crypto/ecdsa`
15+
becomes `crypto/ecdsa.ts`).
16+
17+
| Directory | Source package | Version | Commit | Repository |
18+
| ----------- | ------------------ | ------- | --------- | ---------------------------------------- |
19+
| `webauthn/` | `@oslojs/webauthn` | 1.0.0 | `c18f664` | https://github.com/oslo-project/webauthn |
20+
| `crypto/` | `@oslojs/crypto` | 1.0.1 | `8b3910f` | https://github.com/oslo-project/crypto |
21+
| `asn1/` | `@oslojs/asn1` | 1.0.0 | `65a9bbd` | https://github.com/oslo-project/asn1 |
22+
| `binary/` | `@oslojs/binary` | 1.0.0 | `9186bf7` | https://github.com/oslo-project/binary |
23+
| `cbor/` | `@oslojs/cbor` | 1.0.0 | `0ec853c` | https://github.com/oslo-project/cbor |
24+
| `encoding/` | `@oslojs/encoding` | 1.1.0 | `5b8b873` | https://github.com/oslo-project/encoding |
25+
26+
## Modifications
27+
28+
- Each package module is merged into a single file, and the pieces the
29+
passkey component does not use are removed (for example other hash
30+
functions, other elliptic curves, RSA-PSS, CBOR encoding, ASN.1 types that
31+
never appear in WebAuthn payloads, and the COSE key types the component
32+
rejects).
33+
- The tests are ported into `*.test.ts` files next to the sources so they run
34+
with the repository's Vitest setup. Tests that used `node:crypto` were
35+
rewritten against the WebCrypto API (the tests run in an edge-like runtime,
36+
like Convex functions). The NIST signature- and hash-verification vectors
37+
from the `@oslojs/crypto` repository are ported for the algorithms kept here
38+
(SHA-256, ECDSA P-256, RSASSA-PKCS1-v1.5) in `crypto/nist-vectors.test.ts`.
39+
40+
When changing this code, keep the changes minimal and covered by the tests.

0 commit comments

Comments
 (0)