@@ -68,13 +68,14 @@ class TodoApp extends Component {
6868 return
6969 }
7070
71- const typeIndexUrl = `https://nosdav.net/${ pubkey } /settings/publicTypeIndex.json`
72- console . log ( `Checking for publicTypeIndex at: ${ typeIndexUrl } ` )
71+ // Use StorageConfig for DID-aware URL building instead of hardcoded nosdav.net
72+ const typeIndexUrl = await StorageConfig . buildUrl ( 'settings/publicTypeIndex.json' )
73+ console . log ( `π Checking for publicTypeIndex at DID-discovered location: ${ typeIndexUrl } ` )
7374
7475 const response = await fetch ( typeIndexUrl )
7576
7677 if ( response . status === 404 ) {
77- console . log ( 'No publicTypeIndex.json found' )
78+ console . log ( 'π No publicTypeIndex.json found - DID discovery will be used for storage ' )
7879 return
7980 }
8081
@@ -96,10 +97,11 @@ class TodoApp extends Component {
9697 )
9798
9899 if ( trackerRegistrations . length > 0 ) {
99- console . log ( 'Found Tracker registrations:' , trackerRegistrations )
100+ console . log ( 'β
Found Tracker registrations:' , trackerRegistrations )
101+ console . log ( 'π TypeRegistrations will override DID discovery for storage' )
100102
101- // Convert instance paths to full URLs
102- const trackerUris = trackerRegistrations . map ( reg => {
103+ // Convert instance paths to full URLs using DID-discovered storage root
104+ const trackerUris = await Promise . all ( trackerRegistrations . map ( async reg => {
103105 let instancePath = reg . instance
104106
105107 // Handle relative paths that start with ../
@@ -128,25 +130,29 @@ class TodoApp extends Component {
128130 return `${ baseUrl . origin } ${ newPath } `
129131 }
130132
131- // Original code for absolute paths
132- // Make sure the instance path starts with a slash
133- instancePath = instancePath . startsWith ( '/' )
134- ? instancePath
135- : `/ ${ instancePath } `
133+ // For absolute paths, use StorageConfig instead of hardcoded nosdav.net
134+ // Remove leading slash if present since buildUrl adds path properly
135+ const cleanPath = instancePath . startsWith ( '/' )
136+ ? instancePath . substring ( 1 )
137+ : instancePath
136138
137- return `https://nosdav.net/ ${ pubkey } ${ instancePath } `
138- } )
139+ return await StorageConfig . buildUrl ( cleanPath )
140+ } ) )
139141
140- console . log ( 'Tracker URIs:' , trackerUris )
142+ console . log ( 'π― DID-based Tracker URIs:' , trackerUris )
143+ console . log ( 'β
All TypeRegistration paths now use DID-discovered storage root' )
141144
142145 // Update state with these URIs
143146 this . setState ( {
144147 availableUris : trackerUris ,
145148 typeRegistrations : trackerRegistrations
146149 } )
150+ } else {
151+ console . log ( 'π No Tracker TypeRegistrations found - DID discovery will be used for storage' )
147152 }
148153 } catch ( error ) {
149- console . error ( 'Error checking publicTypeIndex.json:' , error )
154+ console . error ( 'β Error checking publicTypeIndex.json:' , error )
155+ console . log ( 'π Falling back to DID discovery for storage' )
150156 }
151157 }
152158
@@ -187,7 +193,14 @@ class TodoApp extends Component {
187193 availableUris [ this . state . currentUriIndex ] || null
188194
189195 // Enhanced storage provider with DID document discovery
190- console . log ( 'Using enhanced storage provider with DID discovery' )
196+ console . log ( '=== STORAGE PROVIDER DEBUG ===' )
197+ console . log ( 'Available URIs from TypeRegistrations:' , this . state . availableUris )
198+ console . log ( 'Available URIs from query/state:' , availableUris )
199+ console . log ( 'Current URI index:' , this . state . currentUriIndex )
200+ console . log ( 'Custom todos URL:' , customTodosUrl )
201+ console . log ( 'Will use DID discovery:' , ! customTodosUrl )
202+ console . log ( 'StorageConfig cache status:' , StorageConfig . getCachedStorageRoot ( ) )
203+ console . log ( '================================' )
191204 return {
192205 type : 'nosdav' ,
193206 isPrimary : true ,
@@ -199,9 +212,12 @@ class TodoApp extends Component {
199212 if ( customTodosUrl ) {
200213 // Use custom URL from TypeRegistrations/query params
201214 url = customTodosUrl
215+ console . log ( 'π SAVE: Using custom URL from TypeRegistrations/query params:' , url )
202216 } else {
203217 // Use enhanced StorageConfig for intelligent URL building
218+ console . log ( 'π SAVE: Using DID discovery via StorageConfig...' )
204219 url = await StorageConfig . buildUrl ( 'public/todo/todo.json' )
220+ console . log ( 'π― SAVE: DID-discovered URL:' , url )
205221 }
206222
207223 const response = await fetch ( url , {
@@ -279,11 +295,12 @@ class TodoApp extends Component {
279295 if ( customTodosUrl ) {
280296 // Use custom URL from TypeRegistrations/query params
281297 url = customTodosUrl
282- console . log ( ` Using custom URI: ${ url } ` )
298+ console . log ( 'π LOAD: Using custom URI from TypeRegistrations/query params:' , url )
283299 } else {
284300 // Use enhanced StorageConfig for intelligent URL building
301+ console . log ( 'π LOAD: Using DID discovery via StorageConfig...' )
285302 url = await StorageConfig . buildUrl ( 'public/todo/todo.json' )
286- console . log ( `Using DID-discovered storage: ${ url } ` )
303+ console . log ( 'π― LOAD: DID-discovered URL:' , url )
287304 }
288305
289306 const response = await fetch ( url )
0 commit comments