Skip to content

Commit

Permalink
experiment: get sign-up-in connected to localhost access-api
Browse files Browse the repository at this point in the history
this includes a hasty workaround for storacha/w3up#344
  • Loading branch information
natevw committed Jan 14, 2023
1 parent c802e99 commit b25ca73
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
4 changes: 3 additions & 1 deletion examples/react/sign-up-in/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import { KeyringProvider } from '@w3ui/react-keyring'
import ContentPage from './ContentPage'
import logo from './logo.png'

import { accessServicePrincipal, accessServiceConnection } from './staging-service.js'

function App () {
return (
<KeyringProvider>
<KeyringProvider servicePrincipal={accessServicePrincipal} connection={accessServiceConnection}>
<div className='vh-100 flex flex-column justify-center items-center sans-serif light-silver'>
<header>
<img src={logo} width='250' alt='logo' />
Expand Down
34 changes: 34 additions & 0 deletions examples/react/sign-up-in/src/staging-service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// via https://filecoinproject.slack.com/archives/C02BZPRS9HP/p1669658502951759?thread_ts=1669658366.189139&cid=C02BZPRS9HP

import { connect } from '@ucanto/client'
import { CAR, CBOR, HTTP } from '@ucanto/transport'
import * as DID from '@ipld/dag-ucan/did'

// export const accessServiceURL = new URL('https://w3access-staging.protocol-labs.workers.dev')
// export const accessServicePrincipal = DID.parse('did:key:z6MkwTYX2JHHd8bmaEuDdS1LJjrpFspirjDcQ4DvAiDP49Gm')
export const accessServiceURL = new URL('http://localhost:8787')
export const accessServicePrincipal = DID.parse('did:web:local.web3.storage')


export const accessServiceConnection = connect({
id: accessServicePrincipal,
encoder: CAR,
decoder: CBOR,
channel: HTTP.open({
url: accessServiceURL,
method: 'POST'
})
})

export const uploadServiceURL = new URL('https://staging.up.web3.storage')
export const uploadServicePrincipal = DID.parse('did:key:z6MkhcbEpJpEvNVDd3n5RurquVdqs5dPU16JDU5VZTDtFgnn')

export const uploadServiceConnection = connect({
id: uploadServicePrincipal,
encoder: CAR,
decoder: CBOR,
channel: HTTP.open({
url: uploadServiceURL,
method: 'POST'
})
})
5 changes: 4 additions & 1 deletion packages/react-keyring/src/providers/Keyring.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ export function KeyringProvider ({ children, servicePrincipal, connection }: Key

const getAgent = async (): Promise<Agent> => {
if (agent == null) {
const a = await createAgent({ servicePrincipal, connection })
const a = await createAgent({
servicePrincipal, connection,
url: connection.channel.url // WORKAROUND: https://github.com/web3-storage/w3protocol/issues/344
})
setAgent(a)
setIssuer(a.issuer)
setSpace(getCurrentSpace(a))
Expand Down

0 comments on commit b25ca73

Please sign in to comment.