mirror of
https://github.com/aljazceru/gitpear.git
synced 2025-12-17 22:24:22 +01:00
@@ -1,5 +1,5 @@
|
|||||||
const list-remote = require('./list-remote')
|
const listRemote = require('./list-remote')
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
list-remote,
|
listRemote,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ const ProtomuxRPC = require('protomux-rpc')
|
|||||||
const Hyperswarm = require('hyperswarm')
|
const Hyperswarm = require('hyperswarm')
|
||||||
const crypto = require('hypercore-crypto')
|
const crypto = require('hypercore-crypto')
|
||||||
|
|
||||||
const home = require('./home')
|
const home = require('../home')
|
||||||
const auth = require('./auth')
|
const auth = require('../auth')
|
||||||
|
|
||||||
module.exports = async function listRemote (url) {
|
module.exports = async function listRemote (url) {
|
||||||
const matches = url.match(/pear:\/\/([a-f0-9]{64})/)
|
const matches = url.match(/pear:\/\/([a-f0-9]{64})/)
|
||||||
@@ -29,13 +29,14 @@ module.exports = async function listRemote (url) {
|
|||||||
const rpc = new ProtomuxRPC(socket)
|
const rpc = new ProtomuxRPC(socket)
|
||||||
|
|
||||||
let payload = { body: { url, method: 'get-repos' } }
|
let payload = { body: { url, method: 'get-repos' } }
|
||||||
|
if (!process.env.GIT_PEAR_AUTH) {
|
||||||
|
console.debug('Retreiving data using un-authenticated access')
|
||||||
|
} else {
|
||||||
|
console.debug('Retreiving data using authenticated access')
|
||||||
|
}
|
||||||
if (process.env.GIT_PEAR_AUTH && process.env.GIT_PEAR_AUTH !== 'native') {
|
if (process.env.GIT_PEAR_AUTH && process.env.GIT_PEAR_AUTH !== 'native') {
|
||||||
payload.header = await auth.getToken(payload.body)
|
payload.header = await auth.getToken(payload.body)
|
||||||
console.debug('Retreiving data using authenticated access')
|
|
||||||
} else {
|
|
||||||
console.debug('Retreiving data using un-authenticated access')
|
|
||||||
}
|
}
|
||||||
console.log()
|
|
||||||
|
|
||||||
const reposRes = await rpc.request('get-repos', Buffer.from(JSON.stringify(payload)))
|
const reposRes = await rpc.request('get-repos', Buffer.from(JSON.stringify(payload)))
|
||||||
const repositories = JSON.parse(reposRes.toString())
|
const repositories = JSON.parse(reposRes.toString())
|
||||||
|
|||||||
Reference in New Issue
Block a user