Skip to content

Commit

Permalink
chore: Fix release tokens and package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
marcbachmann committed Oct 8, 2021
1 parent 3b082cb commit 4ac9859
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
6 changes: 3 additions & 3 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ steps:
image: livingdocs/semantic-release:v1.2.1
environment:
GH_TOKEN:
from_secret: GH_TOKEN
from_secret: gh_token
NPM_TOKEN:
from_secret: NPM_TOKEN
from_secret: npm_token
depends_on:
- test-node-current-alpine
- test-node-16-debian
Expand All @@ -44,6 +44,6 @@ trigger:
event: [push]
---
kind: signature
hmac: 2998e17dc4e7fd0676aff03d5c0132b0f64ccecd73d86f99b46062f9223bc0bd
hmac: 053f9095e742265c30113aeaae26ddd76dfb3aa3ca5422286cd11f78138951bf

...
18 changes: 12 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ const preGyp = require('@mapbox/node-pre-gyp')
const bindings = require(preGyp.find(require.resolve('argon2/package.json')))
const bindingsHash = promisify(bindings.hash)
const generateSalt = promisify(randomBytes)
const textEncoder = new TextEncoder()
const textDecoder = new TextDecoder()

const limits = Object.freeze({
...bindings.limits,
Expand Down Expand Up @@ -55,11 +57,16 @@ function assertBetween (value, {min, max}, key) {

const {serialize, deserialize: _phcDeserialize} = require('@phc/format')
// Removes trailing null bytes from a buffer and deserializes it
function deserialize (hashBuf) {
function deserialize (hash) {
if (typeof hash !== 'string') {
assert(hash instanceof Uint8Array, 'Invalid hash, must be string, Buffer or Uint8Array')
const i = hash.indexOf(0x00)
if (i !== -1) hash = textDecoder.decode(hash.slice(0, i))
else hash = textDecoder.decode(hash)
}

try {
const i = hashBuf.indexOf(0x00)
if (i !== -1) hashBuf = hashBuf.slice(0, i)
return _phcDeserialize(hashBuf.toString())
return _phcDeserialize(hash)
} catch (err) {
return
}
Expand Down Expand Up @@ -121,7 +128,7 @@ function securePassword (opts = {}) {

const salt = await generateSalt(options.saltLength)
const hash = await bindingsHash(passwordBuf, salt, options)
return Buffer.from(serialize({
return textEncoder.encode(serialize({
id: serializeOpts.id,
version: serializeOpts.version,
params: serializeOpts.params,
Expand All @@ -132,7 +139,6 @@ function securePassword (opts = {}) {

async function verify (passwordBuf, hashBuf) {
assert(passwordBuf instanceof Uint8Array, 'Invalid passwordBuf, must be Buffer or Uint8Array')
assert(hashBuf instanceof Uint8Array, 'Invalid hashBuf, must be Buffer or Uint8Array')
assertBetween(passwordBuf.length, limits.passwordLength, 'Invalid passwordBuf')

const deserializedHash = deserialize(hashBuf)
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/livingdocs/secure-password.git"
"url": "git+https://github.com/livingdocsIO/secure-password.git"
},
"keywords": [
"password",
Expand All @@ -27,9 +27,9 @@
"author": "Marc Bachmann <[email protected]>",
"license": "ISC",
"bugs": {
"url": "https://github.com/livingdocs/secure-password/issues"
"url": "https://github.com/livingdocsIO/secure-password/issues"
},
"homepage": "https://github.com/livingdocs/secure-password#readme",
"homepage": "https://github.com/livingdocsIO/secure-password#readme",
"release": {
"extends": "@livingdocs/semantic-release-presets/npm-github"
}
Expand Down

0 comments on commit 4ac9859

Please sign in to comment.