-
Notifications
You must be signed in to change notification settings - Fork 7
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
Support Erlang 24 by using mac/3 #9
Merged
edgurgel
merged 2 commits into
edgurgel:master
from
blake-education:support-erlang-24-hmac-mac
Aug 4, 2021
Merged
Support Erlang 24 by using mac/3 #9
edgurgel
merged 2 commits into
edgurgel:master
from
blake-education:support-erlang-24-hmac-mac
Aug 4, 2021
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In Erlang 24, the `hmac/4` function has been removed. `mac/3` replaces it, but `mac/3` is only available in Erlang >= 22. Support both depending on what the `:crypto` module exports. Also fix a `meck`-related compile error by updating to the latest version: ``` $ mix deps.compile ==> meck (compile) src/meck_code_gen.erl:182:42: erlang:get_stacktrace/0 is removed; use the new try/catch syntax for retrieving the stack backtrace Compiling src/meck_code_gen.erl failed: ERROR: compile failed while processing signaturex/deps/meck: rebar_abort ** (Mix) Could not compile dependency :meck, "elixir/1.12.2/.mix/rebar compile skip_deps=true deps_dir="signaturex/_build/test/lib"" command failed. You can recompile this dependency with "mix deps.compile meck", update it with "mix deps.update meck" or clean it with "mix deps.clean meck" ``` Also fix a compile warning about the application setup and `crypto` by adding `extra_applications` to the `mix.exs` file: ``` warning: :crypto.hash/2 defined in application :crypto is used by the current application but the current application does not depend on :crypto. To fix this, you must do one of: 1. If :crypto is part of Erlang/Elixir, you must include it under :extra_applications inside "def application" in your mix.exs 2. If :crypto is a dependency, make sure it is listed under "def deps" in your mix.exs 3. In case you don't want to add a requirement to :crypto, you may optionally skip this warning by adding [xref: [exclude: [:crypto]]] to your "def project" in mix.exs lib/signaturex/crypto_helper.ex:37: Signaturex.CryptoHelper.md5/1 ``` Fixes #8.
@edgurgel before I bother making a new version in our private hex org, any chance you still monitor this package, are happy with this PR, and are interested in publishing a new official version? |
@lucas-nelson yes happy to update and publish a new version! |
Thanks!! Will check it out later today! |
1.4.0 should be good to go! Thanks for the update! One day I will sort out CI again 🤣 |
lucas-nelson
added a commit
to blake-education/pusher
that referenced
this pull request
Aug 4, 2021
Related to edgurgel/signaturex#9 This change avoids errors in Erlang 24 like: ``` ** (UndefinedFunctionError) function :crypto.hmac/3 is undefined or private (crypto 5.0.2) :crypto.hmac(:sha256, "secret", "POST\n/apps/app_id/events\nauth_key=app_key&auth_timestamp=1628030250&auth_version=1.0&body_md5=271e594983d1c002b6a158cc5f9c7d5a") (signaturex 1.3.0) lib/signaturex/crypto_helper.ex:7: Signaturex.CryptoHelper.hmac256_to_string/2 (signaturex 1.3.0) lib/signaturex.ex:88: Signaturex.sign/5 (pusher 2.2.0) lib/pusher/request_signer.ex:17: Pusher.RequestSigner.sign/5 (pusher 2.2.0) lib/pusher/http_client.ex:21: Pusher.HttpClient.request/5 (pusher 2.2.0) lib/pusher.ex:16: Pusher.trigger/5 ``` The `crypto` library changed and removed the `hmac` function. The `1.4.0` version of signaturex contains the workaround. The existing semver in mix.exs (`1.3.0`) prevents the upgrade (well, you can manually `override: true` but that's not ideal).
edgurgel
pushed a commit
to edgurgel/pusher
that referenced
this pull request
Aug 6, 2021
Related to edgurgel/signaturex#9 This change avoids errors in Erlang 24 like: ``` ** (UndefinedFunctionError) function :crypto.hmac/3 is undefined or private (crypto 5.0.2) :crypto.hmac(:sha256, "secret", "POST\n/apps/app_id/events\nauth_key=app_key&auth_timestamp=1628030250&auth_version=1.0&body_md5=271e594983d1c002b6a158cc5f9c7d5a") (signaturex 1.3.0) lib/signaturex/crypto_helper.ex:7: Signaturex.CryptoHelper.hmac256_to_string/2 (signaturex 1.3.0) lib/signaturex.ex:88: Signaturex.sign/5 (pusher 2.2.0) lib/pusher/request_signer.ex:17: Pusher.RequestSigner.sign/5 (pusher 2.2.0) lib/pusher/http_client.ex:21: Pusher.HttpClient.request/5 (pusher 2.2.0) lib/pusher.ex:16: Pusher.trigger/5 ``` The `crypto` library changed and removed the `hmac` function. The `1.4.0` version of signaturex contains the workaround. The existing semver in mix.exs (`1.3.0`) prevents the upgrade (well, you can manually `override: true` but that's not ideal).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In Erlang 24, the
hmac/4
function has been removed.mac/3
replacesit, but
mac/3
is only available in Erlang >= 22. Support bothdepending on what the
:crypto
module exports.Also fix a
meck
-related compile error by updating to the latestversion:
Also fix a compile warning about the application setup and
crypto
byadding
extra_applications
to themix.exs
file:Fixes #8.