Signed-off-by: dzdidi <deniszalessky@gmail.com>
This commit is contained in:
dzdidi
2024-01-28 17:01:13 +00:00
parent e2cc611bc8
commit a0b2d1fc24
2 changed files with 3 additions and 24 deletions

View File

@@ -26,24 +26,3 @@ module.exports = {
getId,
getToken
}
// ;(async () => {
// const repo = 'gitpear'
// const url = `pear://d1672d338b8e24223cd0dc6c6b5e04ebabf091fc2b470204abdb98fa5fc59072/${repo}`
// const commit = '1837a4bae8497f71fb8f01305c3ace1e3dedcdba'
// const method = 'push'
// const branch = 'test'
// const data = `${branch}#${commit}`
//
// let payload
// let npub
//
// payload = await getToken({ url, method, data })
// npub = await getId({ payload, url, method, data })
//
// payload = await getToken({url, method: 'get-repos'})
// npub = await getId({ payload, url, method: 'get-repos' })
//
// payload = await getToken({url, method: 'get-refs', data: { repo }})
// npub = await getId({ payload, url, method: 'get-refs', data: { repo }})
// })()

View File

@@ -157,9 +157,9 @@ module.exports = class RPC {
return parsed
}
async authenticate (publicKey, req) {
if (!process.env.GIT_PEAR_AUTH) return publicKey
if (process.env.GIT_PEAR_AUTH === 'naitive') return publicKey
async authenticate (publicKey, request) {
if (!process.env.GIT_PEAR_AUTH) return publicKey.toString('hex')
if (process.env.GIT_PEAR_AUTH === 'naitive') return publicKey.toString('hex')
if (process.env.GIT_PEAR_AUTH !== 'naitive' && !request.header) {
throw new Error('You are not allowed to access this repo')
}