Skip to content

Passing a %JOSE.JWK{} to Signer.create() #294

@acco

Description

@acco

Hey team,

I work with JOSE.JWK in their native struct in my codebase. Eg:

jwk = %JOSE.JWK{
  fields: %{},
  keys: :undefined,
  kty: {:jose_jwk_kty_okp_ed25519,
   <<22, 265, 220, 103, 320, 163, 18, 80, 12, 255, 235, 31, ...>>}
}

I want to be able to do something like this:

signer = Joken.Signer.create("Ed25519", jwk)

But this raises this error:

    The following arguments were given to JOSE.JWK.from_record/1:

        # 1
        {:error, {:missing_required_keys, ["keys", "kty"]}}

    Attempted function clauses (showing 2 out of 2):

        def from_record({:jose_jwk, keys, kty, fields})
        def from_record(list) when is_list(list)

So, my workaround is the following - which is fine, just not ideal:

signer = Joken.Signer.create("Ed25519", %{"pem" => JOSE.JWK.to_pem(pub_key) |> elem(1)}),

Any reason not to support passing in JWK's directly?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions