@@ -2,7 +2,7 @@ import { ChangeEvent, useEffect, useState } from 'react'
2
2
import { SpaceDID , useW3 } from '@w3ui/react'
3
3
import { extract } from '@ucanto/core/delegation'
4
4
import type { PropsWithChildren } from 'react'
5
- import type { Delegation } from '@ucanto/interface'
5
+ import type { Capabilities , Delegation } from '@ucanto/interface'
6
6
import { SpacePreview } from './components/SpaceCreator'
7
7
import { H2 , H3 } from '@/components/Text'
8
8
import CopyButton from './components/CopyButton'
@@ -64,64 +64,16 @@ export function ShareSpace({ spaceDID }: { spaceDID: SpaceDID }): JSX.Element {
64
64
throw new Error ( `Client not found` )
65
65
}
66
66
67
- const currentSpace = client . agent . currentSpace ( )
68
- try {
69
- const space = client . spaces ( ) . find ( s => s . did ( ) === spaceDID )
70
- if ( ! space ) {
71
- throw new Error ( `Could not find space to share` )
72
- }
73
-
74
- const delegatedEmail = DIDMailTo . email ( email )
75
-
76
- // FIXME (fforbeck): enable shareSpace function call after @w3ui/react lib is updated to v2.4.0 and the issue with blobs are solved
77
- // const delegation = await client.shareSpace(delegatedEmail, space.did())
78
-
79
- // Make sure the agent is using the shared space before delegating
80
- await client . agent . setCurrentSpace ( spaceDID )
81
-
82
- // Delegate capabilities to the delegate account to access the **current space**
83
- const delegation = await client . createDelegation (
84
- {
85
- did : ( ) => DIDMailTo . fromEmail ( delegatedEmail ) ,
86
- } ,
87
- [
88
- 'space/*' ,
89
- 'store/*' ,
90
- 'upload/*' ,
91
- 'access/*' ,
92
- 'usage/*' ,
93
- // @ts -expect-error (FIXME: https://github.com/storacha/w3up/issues/1554)
94
- 'filecoin/*' ,
95
- ] , {
96
- expiration : Infinity
97
- }
98
- )
99
-
100
- const sharingResult = await client . capability . access . delegate ( {
101
- space : spaceDID ,
102
- delegations : [ delegation ] ,
103
- } )
104
-
105
- if ( sharingResult . error ) {
106
- throw new Error (
107
- `failed to share space with ${ delegatedEmail } : ${ sharingResult . error . message } ` ,
108
- {
109
- cause : sharingResult . error ,
110
- }
111
- )
112
- }
113
-
114
- const next = { email : delegatedEmail , capabilities : delegation . capabilities . map ( c => c . can ) }
115
- updateSharedEmails ( [ next ] )
116
- setValue ( '' )
117
- } catch ( err ) {
118
- console . error ( err )
119
- } finally {
120
- // Reset to the original space if it was different
121
- if ( currentSpace && currentSpace !== spaceDID ) {
122
- await client . agent . setCurrentSpace ( currentSpace )
123
- }
67
+ const space = client . spaces ( ) . find ( s => s . did ( ) === spaceDID )
68
+ if ( ! space ) {
69
+ throw new Error ( `Could not find space to share` )
124
70
}
71
+
72
+ const delegatedEmail = DIDMailTo . email ( email )
73
+ const delegation : Delegation < Capabilities > = await client . shareSpace ( delegatedEmail , space . did ( ) )
74
+ const next = { email : delegatedEmail , capabilities : delegation . capabilities . map ( c => c . can ) }
75
+ updateSharedEmails ( [ next ] )
76
+ setValue ( '' )
125
77
}
126
78
127
79
async function makeDownloadLink ( did : string ) : Promise < string > {
0 commit comments