-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add RBS for [email protected] #243
Conversation
gems/jwt/2.5/jwt.rbs
Outdated
|
||
def self?.encode: (untyped payload, untyped key, ::String | _Algo algorithm, ?::Hash[::String | ::Symbol, untyped] header_fields) -> ::String | ||
|
||
def self?.decode: (String jwt, ?untyped? key, ?bool verify, ?::Hash[Symbol, untyped] options) ?{ (Hash[::String, untyped] header, ?untyped payload) -> untyped } -> [untyped, Hash[::String, untyped]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def self?.decode: (String jwt, ?untyped? key, ?bool verify, ?::Hash[Symbol, untyped] options) ?{ (Hash[::String, untyped] header, ?untyped payload) -> untyped } -> [untyped, Hash[::String, untyped]] | |
def self?.decode: (String jwt, ?untyped? key, ?boolish verify, ?::Hash[Symbol, untyped] options) ?{ (Hash[::String, untyped] header, ?untyped payload) -> untyped } -> [untyped, Hash[::String, untyped]] |
How about using boolish
instead of bool
?
https://github.com/ruby/rbs/blob/30e800622a2d7217f822beb2693bdff16f528193/docs/syntax.md#bool-or-boolish
decode
method receives anything as verify
, and the argument is used only for if
/unless
conditions. So I think we have no reason to strict it to true
or false
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx, you are right. Also return types of _Algo#valid_alg?
and _Algo#verify
should be boolish
.
gems/jwt/2.5/jwt.rbs
Outdated
def verify: (data: untyped, signature: ::String, verification_key: untyped) -> bool | ||
end | ||
|
||
def self?.encode: (untyped payload, untyped key, ::String | _Algo algorithm, ?::Hash[::String | ::Symbol, untyped] header_fields) -> ::String |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def self?.encode: (untyped payload, untyped key, ::String | _Algo algorithm, ?::Hash[::String | ::Symbol, untyped] header_fields) -> ::String | |
def self?.encode: (untyped payload, untyped key, ?::String | _Algo algorithm, ?::Hash[::String | ::Symbol, untyped] header_fields) -> ::String |
algorithm
argument looks optional.
https://github.com/jwt/ruby-jwt/blob/b1b52504a7d7819240f2bc9a50da1a79ed03df2b/lib/jwt.rb#L21
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I was wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍 Thanks for your PR!
This PR add RBS for [email protected].
Currently this RBS contains definition of
JWT.encode
andJWT.decode
(incomplete)