Skip to content

Commit

Permalink
refactor(heyauthn): update tests and doc
Browse files Browse the repository at this point in the history
  • Loading branch information
cedoor committed Jan 12, 2024
1 parent 2b05a94 commit c8da0dc
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 15 deletions.
9 changes: 3 additions & 6 deletions packages/heyauthn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,13 @@ import { Group } from "@semaphore-protocol/group"
import { generateProof } from "@semaphore-protocol/proof"
import { utils } from "ethers"

const group = new Group("42")
const group = new Group()

group.addMembers(memberList)

const signal = utils.formatBytes32String("Hey anon!")
const message = utils.formatBytes32String("Hey anon!")

generateProof(identity, group, group.id, "42", {
zkeyFilePath: "./semaphore.zkey",
wasmFilePath: "./semaphore.wasm"
})
generateProof(identity, group, message, group.root)
```

## Authors
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion packages/heyauthn/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Identity } from "@semaphore-protocol/identity"
import { GenerateAuthenticationOptionsOpts, GenerateRegistrationOptionsOpts } from "@simplewebauthn/server"
import HeyAuthn from "./heyAuthn"
import HeyAuthn from "./hey-authn"

export {
HeyAuthn,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
GenerateRegistrationOptionsOpts as RegistrationOptions
} from "@simplewebauthn/server"

import HeyAuthn from "./heyAuthn"
import { HeyAuthn } from "../src"

jest.mock("@simplewebauthn/browser", () => ({
startRegistration: async () => ({
Expand Down Expand Up @@ -52,9 +52,8 @@ describe("HeyAuthn", () => {
const { identity } = await HeyAuthn.fromRegister(options)
const expectedIdentity = new Identity("my-new-credential")

expect(expectedIdentity.trapdoor).toEqual(identity.trapdoor)
expect(expectedIdentity.nullifier).toEqual(identity.nullifier)
expect(expectedIdentity.commitment).toEqual(identity.commitment)
expect(identity.secretScalar).toEqual(expectedIdentity.secretScalar)
expect(identity.commitment).toEqual(expectedIdentity.commitment)
})
})

Expand All @@ -67,9 +66,8 @@ describe("HeyAuthn", () => {
const { identity } = await HeyAuthn.fromAuthenticate(options)
const expectedIdentity = new Identity("my-existing-credential")

expect(expectedIdentity.trapdoor).toEqual(identity.trapdoor)
expect(expectedIdentity.nullifier).toEqual(identity.nullifier)
expect(expectedIdentity.commitment).toEqual(identity.commitment)
expect(identity.secretScalar).toEqual(expectedIdentity.secretScalar)
expect(identity.commitment).toEqual(expectedIdentity.commitment)
})
})
})
2 changes: 1 addition & 1 deletion packages/heyauthn/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"extends": "../../tsconfig.json",
"include": ["src", "rollup.config.ts"]
"include": ["src", "tests", "rollup.config.ts"]
}

0 comments on commit c8da0dc

Please sign in to comment.