11import { Config } from 'sst/node/config'
2- import { API , error , ok } from '@ucanto/core'
2+ import { API } from '@ucanto/core'
33import * as Delegation from '@ucanto/core/delegation'
44import { CAR , Legacy , Codec } from '@ucanto/transport'
5- import { DIDResolutionError , Schema } from '@ucanto/validator'
5+ import { Schema } from '@ucanto/validator'
66import * as Link from 'multiformats/link'
77import { base64 } from 'multiformats/bases/base64'
88import * as Sentry from '@sentry/serverless'
@@ -12,6 +12,7 @@ import * as Proof from '@storacha/client/proof'
1212import { Client as IndexingServiceClient } from '@storacha/indexing-service-client'
1313import * as UploadAPI from '@storacha/upload-api'
1414import * as UCANCaps from '@storacha/capabilities/ucan'
15+ import { HTTPResolver , CacheResolver , MapResolver , TieredResolver } from '@storacha/principal-resolver'
1516import {
1617 composeCarStoresWithOrderedHas ,
1718 createCarStore ,
@@ -514,6 +515,13 @@ export async function ucanInvocationRouter(request) {
514515 }
515516 }
516517
518+ const principalResolver = TieredResolver . create ( [
519+ MapResolver . create ( principalMapping ) ,
520+ CacheResolver . create (
521+ HTTPResolver . create ( [ / ^ d i d : w e b : .* \. s t o r a c h a \. n e t w o r k $ / ] )
522+ ) ,
523+ ] )
524+
517525 const server = createUcantoServer ( serviceSigner , {
518526 codec,
519527 // @ts -expect-error needs update of upload-api
@@ -523,10 +531,7 @@ export async function ucanInvocationRouter(request) {
523531 registry : allocationBlobRegistry ,
524532 blobsStorage,
525533 blobRetriever,
526- resolveDIDKey : ( did ) =>
527- Schema . did ( { method : 'web' } ) . is ( did ) && principalMapping [ did ]
528- ? ok ( [ principalMapping [ did ] ] )
529- : error ( new DIDResolutionError ( did ) ) ,
534+ ...principalResolver ,
530535 getServiceConnection : ( ) => connection ,
531536 // TODO: to be deprecated with `store/*` protocol
532537 storeTable : createStoreTable ( AWS_REGION , storeTableName , {
0 commit comments