Skip to content

Cannot sign with empty string as secret #51

Open

Description

@silverwind

When secret is falsy, no signing is performed and a misleading error is given:

require("jws").sign({header: {alg: "HS256"}, payload: "data", secret: ""});
// TypeError: secret must be a string or buffer

The equivalent with an empty Buffer works:

require("jws").sign({header: {alg: "HS256"}, payload: "data", secret: Buffer("")});
// 'eyJhbGciOiJIUzI1NiJ9.ZGF0YQ.KTmgoUPBPfznrnLx1xjRnlmzfIKWZV4x9cXIi6_RopQ'

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions