diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bb6a11d9..01d0b7b1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -101,3 +101,4 @@ jobs: run: | yarn install --frozen-lockfile yarn test + sync: sshfs diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 10353603..2a5ce34c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -171,6 +171,7 @@ jobs: run: | yarn install --frozen-lockfile yarn node-pre-gyp package + sync: sshfs - name: Upload to Release uses: csexton/release-asset-action@v2 diff --git a/src/argon2_node.cpp b/argon2.cpp similarity index 84% rename from src/argon2_node.cpp rename to argon2.cpp index 1690017c..b951d609 100644 --- a/src/argon2_node.cpp +++ b/argon2.cpp @@ -1,28 +1,21 @@ +#include "argon2/include/argon2.h" + #include #include -#include - #include -#include "../argon2/include/argon2.h" - -#include +#include using namespace Napi; - -#ifndef _MSC_VER -namespace { -#endif - using ustring = std::vector; -ustring from_buffer(const Value& value) +static ustring from_buffer(const Value& value) { const auto& buf = value.As>(); const auto& data = buf.Data(); return {data, data + buf.Length()}; } -Buffer to_buffer(const Env& env, const ustring& str) +static Buffer to_buffer(const Env& env, const ustring& str) { return Buffer::Copy(env, str.data(), str.size()); } @@ -40,7 +33,7 @@ struct Options { argon2_type type; }; -argon2_context make_context(uint8_t* buf, ustring& plain, ustring& salt, Options& opts) +static argon2_context make_context(uint8_t* buf, ustring& plain, ustring& salt, Options& opts) { argon2_context ctx; @@ -106,7 +99,7 @@ class HashWorker final: public AsyncWorker { ustring hash; }; -Options extract_opts(const Object& opts) +static Options extract_opts(const Object& opts) { return { opts.Has("secret") ? from_buffer(opts["secret"]) : ustring{}, @@ -120,13 +113,9 @@ Options extract_opts(const Object& opts) }; } -#ifndef _MSC_VER -} -#endif - -Value Hash(const CallbackInfo& info) +static Value Hash(const CallbackInfo& info) { - assert(info.Length() == 4 and info[0].IsBuffer() and info[1].IsBuffer() and info[2].IsObject() and info[3].IsFunction()); + assert(info.Length() == 4 && info[0].IsBuffer() && info[1].IsBuffer() && info[2].IsObject() && info[3].IsFunction()); auto worker = new HashWorker{ info[3].As(), from_buffer(info[0]), from_buffer(info[1]), extract_opts(info[2].As()) @@ -136,7 +125,7 @@ Value Hash(const CallbackInfo& info) return info.Env().Undefined(); } -Object init(Env env, Object exports) +static Object init(Env env, Object exports) { exports["hash"] = Function::New(env, Hash); return exports; diff --git a/binding.gyp b/binding.gyp index 4de84878..6c81fadf 100644 --- a/binding.gyp +++ b/binding.gyp @@ -42,7 +42,7 @@ ], "type": "static_library" }, { - "target_name": "argon2", + "target_name": "<(module_name)", "xcode_settings": { "GCC_ENABLE_CPP_EXCEPTIONS": "YES", }, @@ -53,7 +53,7 @@ "NAPI_VERSION=<(napi_build_version)", ], "sources": [ - "src/argon2_node.cpp" + "argon2.cpp" ], "cflags_cc!": ["-fno-exceptions"], "include_dirs": ["