@@ -310,6 +310,25 @@ export class Sessions implements SessionsInterface {
310
310
return this . prepareSessionUpdate ( walletAddress , newTopology , origin )
311
311
}
312
312
313
+ async modifyExplicitSession (
314
+ walletAddress : Address . Address ,
315
+ sessionAddress : Address . Address ,
316
+ permissions : CoreSigners . Session . ExplicitParams ,
317
+ origin ?: string ,
318
+ ) : Promise < string > {
319
+ // This will add the session manager if it's missing
320
+ const topology = await this . getTopology ( walletAddress , true )
321
+ const intermediateTopology = SessionConfig . removeExplicitSession ( topology , sessionAddress )
322
+ if ( ! intermediateTopology ) {
323
+ throw new Error ( 'Incomplete session topology' )
324
+ }
325
+ const newTopology = SessionConfig . addExplicitSession ( intermediateTopology , {
326
+ ...permissions ,
327
+ signer : sessionAddress ,
328
+ } )
329
+ return this . prepareSessionUpdate ( walletAddress , newTopology , origin )
330
+ }
331
+
313
332
async removeExplicitSession (
314
333
walletAddress : Address . Address ,
315
334
sessionAddress : Address . Address ,
@@ -318,7 +337,7 @@ export class Sessions implements SessionsInterface {
318
337
const topology = await this . getTopology ( walletAddress )
319
338
const newTopology = SessionConfig . removeExplicitSession ( topology , sessionAddress )
320
339
if ( ! newTopology ) {
321
- throw new Error ( 'Session not found ' )
340
+ throw new Error ( 'Incomplete session topology ' )
322
341
}
323
342
return this . prepareSessionUpdate ( walletAddress , newTopology , origin )
324
343
}
0 commit comments