Skip to content

Commit

Permalink
feat: make Storacha service information configurable (#13)
Browse files Browse the repository at this point in the history
This lets us use staging Storacha for the staging environment, and
allows us to send folks through the Storacha auth rather than
web3.storage auth.

---------

Co-authored-by: Crostons <shubh1608003@gmail.com>
  • Loading branch information
travis and Crosstons authored Mar 1, 2025
1 parent 131cd56 commit 4f5bd9b
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 4 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
"@headlessui/react": "^2.2.0",
"@heroicons/react": "^2.2.0",
"@tailwindcss/postcss": "^4.0.9",
"@ipld/dag-ucan": "^3.4.5",
"@tanstack/react-query": "^5.66.0",
"@ucanto/client": "^9.0.1",
"@ucanto/transport": "^9.1.1",
"@w3ui/react": "^2.5.5",
"@web3-storage/w3up-client": "^17.1.2",
"dexie": "^4.0.11",
Expand Down
9 changes: 9 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/components/StorachaAuthenticator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ export default function StorachaAuthenticator () {
<Identity />
</AuthenticationEnsurer>
</Authenticator>
)
)
}
11 changes: 8 additions & 3 deletions src/components/W3UIProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import type { ReactNode } from 'react'
import { Provider } from '@w3ui/react'
import { serviceConnection, servicePrincipal } from './services'

export default function W3UIProvider({ children }: { children: React.ReactNode }) {
export default function W3UIProvider ({ children }: { children: ReactNode }) {
return (
<Provider>
{children}
<Provider
connection={serviceConnection}
servicePrincipal={servicePrincipal}
>
<>{children}</>
</Provider>
)
}
21 changes: 21 additions & 0 deletions src/components/services.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import type { Service } from '@w3ui/react'
import { connect } from '@ucanto/client'
import { CAR, HTTP } from '@ucanto/transport'
import * as DID from '@ipld/dag-ucan/did'

export const serviceURL = new URL(
process.env.NEXT_PUBLIC_STORACHA_SERVICE_URL ?? 'https://up.storacha.network'
)

export const servicePrincipal = DID.parse(
process.env.NEXT_PUBLIC_STORACHA_SERVICE_DID ?? 'did:web:web3.storage'
)

export const serviceConnection = connect<Service>({
id: servicePrincipal,
codec: CAR.outbound,
channel: HTTP.open({
url: serviceURL,
method: 'POST',
}),
})

0 comments on commit 4f5bd9b

Please # to comment.