@@ -31,6 +31,7 @@ import { PkpIdentifierRaw } from '../../rawContractApis/permissions/utils/resolv
3131// Import all handler functions
3232import { addPermittedActionByIdentifier } from './handlers/addPermittedActionByIdentifier' ;
3333import { addPermittedAddressByIdentifier } from './handlers/addPermittedAddressByIdentifier' ;
34+ import { addPermittedAuthMethodByIdentifier } from './handlers/addPermittedAuthMethodByIdentifier' ;
3435import { addPermittedAuthMethodScopeByIdentifier } from './handlers/addPermittedAuthMethodScopeByIdentifier' ;
3536import {
3637 getPermissionsContext ,
@@ -50,6 +51,7 @@ import { isPermittedAddressByIdentifier } from './handlers/isPermittedAddressByI
5051import { removePermittedActionByIdentifier } from './handlers/removePermittedActionByIdentifier' ;
5152import { removePermittedAddressByIdentifier } from './handlers/removePermittedAddressByIdentifier' ;
5253import { removePermittedAuthMethodByIdentifier } from './handlers/removePermittedAuthMethodByIdentifier' ;
54+ import { removePermittedAuthMethodScopeByIdentifier } from './handlers/removePermittedAuthMethodScopeByIdentifier' ;
5355
5456import type { PKPStorageProvider } from '../../../../../../storage/types' ;
5557import { logger } from '../../../../../shared/logger' ;
@@ -137,6 +139,31 @@ export class PKPPermissionsManager {
137139 ) ;
138140 }
139141
142+ /**
143+ * Adds a permitted authentication method to the PKP
144+ *
145+ * @param params - Parameters containing authMethodType, authMethodId, userPubkey, and scopes
146+ * @returns Promise resolving to transaction details
147+ */
148+ async addPermittedAuthMethod ( params : {
149+ authMethodType : string | number | bigint ;
150+ authMethodId : string ;
151+ userPubkey : string ;
152+ scopes : ScopeString [ ] ;
153+ } ) : Promise < LitTxVoid > {
154+ return addPermittedAuthMethodByIdentifier (
155+ {
156+ authMethodType : params . authMethodType ,
157+ authMethodId : params . authMethodId ,
158+ userPubkey : params . userPubkey ,
159+ scopes : params . scopes ,
160+ ...this . getIdentifierParams ( ) ,
161+ } ,
162+ this . networkContext ,
163+ this . accountOrWalletClient
164+ ) ;
165+ }
166+
140167 /**
141168 * Adds a permitted authentication method scope to the PKP
142169 *
@@ -217,6 +244,29 @@ export class PKPPermissionsManager {
217244 ) ;
218245 }
219246
247+ /**
248+ * Removes a specific scope from a permitted authentication method for the PKP
249+ *
250+ * @param params - Parameters containing authMethodType, authMethodId, and scopeId
251+ * @returns Promise resolving to transaction details
252+ */
253+ async removePermittedAuthMethodScope ( params : {
254+ authMethodType : string | number | bigint ;
255+ authMethodId : string ;
256+ scopeId : string | number | bigint ;
257+ } ) : Promise < LitTxVoid > {
258+ return removePermittedAuthMethodScopeByIdentifier (
259+ {
260+ authMethodType : params . authMethodType ,
261+ authMethodId : params . authMethodId ,
262+ scopeId : params . scopeId ,
263+ ...this . getIdentifierParams ( ) ,
264+ } ,
265+ this . networkContext ,
266+ this . accountOrWalletClient
267+ ) ;
268+ }
269+
220270 /**
221271 * Checks if a LitAction is permitted for the PKP
222272 *
@@ -387,18 +437,31 @@ export class PKPPermissionsManager {
387437 | { type : 'addAction' ; ipfsId : string ; scopes : ScopeString [ ] }
388438 | { type : 'addAddress' ; address : string ; scopes : ScopeString [ ] }
389439 | {
390- type : 'addAuthMethodScope' ;
391- authMethodType : string | number | bigint ;
392- authMethodId : string ;
393- scopeId : string | number | bigint ;
394- }
440+ type : 'addAuthMethod' ;
441+ authMethodType : string | number | bigint ;
442+ authMethodId : string ;
443+ userPubkey : string ;
444+ scopes : ScopeString [ ] ;
445+ }
446+ | {
447+ type : 'addAuthMethodScope' ;
448+ authMethodType : string | number | bigint ;
449+ authMethodId : string ;
450+ scopeId : string | number | bigint ;
451+ }
395452 | { type : 'removeAction' ; ipfsId : string }
396453 | { type : 'removeAddress' ; address : string }
397454 | {
398- type : 'removeAuthMethod' ;
399- authMethodType : string | number | bigint ;
400- authMethodId : string ;
401- }
455+ type : 'removeAuthMethod' ;
456+ authMethodType : string | number | bigint ;
457+ authMethodId : string ;
458+ }
459+ | {
460+ type : 'removeAuthMethodScope' ;
461+ authMethodType : string | number | bigint ;
462+ authMethodId : string ;
463+ scopeId : string | number | bigint ;
464+ }
402465 >
403466 ) : Promise < void > {
404467 // Process operations sequentially to avoid transaction conflicts
@@ -416,6 +479,14 @@ export class PKPPermissionsManager {
416479 scopes : op . scopes ,
417480 } ) ;
418481 break ;
482+ case 'addAuthMethod' :
483+ await this . addPermittedAuthMethod ( {
484+ authMethodType : op . authMethodType ,
485+ authMethodId : op . authMethodId ,
486+ userPubkey : op . userPubkey ,
487+ scopes : op . scopes ,
488+ } ) ;
489+ break ;
419490 case 'addAuthMethodScope' :
420491 await this . addPermittedAuthMethodScope ( {
421492 authMethodType : op . authMethodType ,
@@ -439,6 +510,13 @@ export class PKPPermissionsManager {
439510 authMethodId : op . authMethodId ,
440511 } ) ;
441512 break ;
513+ case 'removeAuthMethodScope' :
514+ await this . removePermittedAuthMethodScope ( {
515+ authMethodType : op . authMethodType ,
516+ authMethodId : op . authMethodId ,
517+ scopeId : op . scopeId ,
518+ } ) ;
519+ break ;
442520 }
443521 }
444522 }
0 commit comments