From 91ee740dbafd605b66e1176db986db1ed7c6b90a Mon Sep 17 00:00:00 2001 From: dzdidi Date: Mon, 12 Feb 2024 15:49:09 +0000 Subject: [PATCH] fix native auth Signed-off-by: dzdidi --- src/auth/nip98.js | 1 + src/git-remote-pear.js | 2 +- src/list-remote.js | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/auth/nip98.js b/src/auth/nip98.js index 42e2751..2f00b31 100644 --- a/src/auth/nip98.js +++ b/src/auth/nip98.js @@ -1,6 +1,7 @@ const { nip98, nip19, finalizeEvent } = require('nostr-tools') async function getToken({ url, method, data }) { + if (!process.env.GIT_PEAR_AUTH_NSEC) throw new Error('Missing NSEC') const { data: sK } = nip19.decode(process.env.GIT_PEAR_AUTH_NSEC) return nip98.getToken( url, diff --git a/src/git-remote-pear.js b/src/git-remote-pear.js index 6aac563..68e7852 100755 --- a/src/git-remote-pear.js +++ b/src/git-remote-pear.js @@ -29,7 +29,7 @@ const repoName = matches[2] const store = new Corestore(RAM) const swarmOpts = {} -if (process.env.GIT_PEAR_AUTH && process.env.GIT_PEAR_AUTH !== 'native') { +if (process.env.GIT_PEAR_AUTH === 'native') { swarmOpts.keyPair = home.getKeyPair() } const swarm = new Hyperswarm(swarmOpts) diff --git a/src/list-remote.js b/src/list-remote.js index 576fadb..a3fbe0b 100644 --- a/src/list-remote.js +++ b/src/list-remote.js @@ -18,7 +18,7 @@ module.exports = async function listRemote (url) { console.log('Connecting to:', targetKey) const swarmOpts = {} - if (process.env.GIT_PEAR_AUTH && process.env.GIT_PEAR_AUTH !== 'native') { + if (process.env.GIT_PEAR_AUTH === 'native') { swarmOpts.keyPair = home.getKeyPair() } const swarm = new Hyperswarm(swarmOpts)