Skip to content

Instantly share code, notes, and snippets.

@radio-alice
Last active August 26, 2019 19:47
Show Gist options
  • Save radio-alice/b80c42a0ae0e518207d72e5b7966d8ea to your computer and use it in GitHub Desktop.
Save radio-alice/b80c42a0ae0e518207d72e5b7966d8ea to your computer and use it in GitHub Desktop.
import ipfsClient from 'ipfs-http-client'
const username = 'zach'
const password = '[ the password ]'
const temporalAuthUrl = `https://api.temporal.cloud/v2/auth/login`
// this is working now!
const init = async () => {
const auth = await fetch(temporalAuthUrl, {
method: 'POST',
headers: {
'Content-Type': 'text/plain'
},
body: JSON.stringify({
username: username,
password: password
})
})
const { token } = await auth.json()
console.log(token)
return ipfsClient({
host: 'api.ipfs.temporal.cloud',
port: '443',
'api-path': '/api/v0/',
protocol: 'https',
headers: {
Authorization: 'Bearer ' + token
}
})
}
// this has always hit 403 errors
const run = async () => {
let ipfs = await init()
console.log(ipfs)
const obj = { simple: 'object' }
ipfs.dag.put(obj, { format: 'dag-cbor', hashAlg: 'sha3-512' }, (err, cid) => {
console.log(cid.toBaseEncodedString())
})
// ipfs.dag.get(cid).then(console.log)
}
run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment