1- import { networkContext } from " ../../../_config" ;
2- import { PKPPermissionsManager } from " ./PKPPermissionsManager" ;
1+ import { networkContext } from ' ../../../_config' ;
2+ import { PKPPermissionsManager } from ' ./PKPPermissionsManager' ;
33
44// Configuration constants
55const TEST_TOKEN_ID =
6- " 76136736151863037541847315168980811654782785653773679312890341037699996601290" ;
7- const PKP_TEST_ADDRESS = " 0xef3eE1bD838aF5B36482FAe8a6Fc394C68d5Fa9F" ;
6+ ' 76136736151863037541847315168980811654782785653773679312890341037699996601290' ;
7+ const PKP_TEST_ADDRESS = ' 0xef3eE1bD838aF5B36482FAe8a6Fc394C68d5Fa9F' ;
88
9- const MASTER_ADDRESS = " 0xC434D4B9c307111a1CA6752AC47B77C571FcA500" ;
9+ const MASTER_ADDRESS = ' 0xC434D4B9c307111a1CA6752AC47B77C571FcA500' ;
1010
1111// Using valid IPFS CID format for v0 (Qm... format)
12- const TEST_ACTION_IPFS_ID = " QmPK1s3pNYLi9ERiq3BDxKa4XosgWwFRQUydHUtz4YgpqB" ;
12+ const TEST_ACTION_IPFS_ID = ' QmPK1s3pNYLi9ERiq3BDxKa4XosgWwFRQUydHUtz4YgpqB' ;
1313// Add a hex version of the IPFS ID for comparisons
1414const TEST_ACTION_IPFS_ID_HEX =
15- " 0x12200e7071c59df3b9454d1d18a15270aa36d54f89606a576dc621757afd44ad1d2e" ;
15+ ' 0x12200e7071c59df3b9454d1d18a15270aa36d54f89606a576dc621757afd44ad1d2e' ;
1616
17- describe ( " PKPPermissionsManager" , ( ) => {
17+ describe ( ' PKPPermissionsManager' , ( ) => {
1818 let manager : PKPPermissionsManager ;
1919
2020 // Set up the test environment
@@ -25,42 +25,42 @@ describe("PKPPermissionsManager", () => {
2525 ) ;
2626 } ) ;
2727
28- test ( " should get permissions context initially" , async ( ) => {
28+ test ( ' should get permissions context initially' , async ( ) => {
2929 const context = await manager . getPermissionsContext ( ) ;
3030 expect ( context ) . toBeDefined ( ) ;
3131 } ) ;
3232
33- test ( " should check if an address is permitted" , async ( ) => {
33+ test ( ' should check if an address is permitted' , async ( ) => {
3434 const isPermitted = await manager . isPermittedAddress ( {
3535 address : PKP_TEST_ADDRESS ,
3636 } ) ;
3737 expect ( isPermitted ) . toBeDefined ( ) ;
3838 } ) ;
3939
40- test ( " should check if an action is permitted" , async ( ) => {
40+ test ( ' should check if an action is permitted' , async ( ) => {
4141 const isPermitted = await manager . isPermittedAction ( {
4242 ipfsId : TEST_ACTION_IPFS_ID ,
4343 } ) ;
4444 expect ( isPermitted ) . toBeDefined ( ) ;
4545 } ) ;
4646
47- test ( " should get permitted addresses" , async ( ) => {
47+ test ( ' should get permitted addresses' , async ( ) => {
4848 const addresses = await manager . getPermittedAddresses ( ) ;
4949 expect ( addresses ) . toBeDefined ( ) ;
5050 expect ( Array . isArray ( addresses ) ) . toBe ( true ) ;
5151 } ) ;
5252
53- test ( " should get permitted actions" , async ( ) => {
53+ test ( ' should get permitted actions' , async ( ) => {
5454 const actions = await manager . getPermittedActions ( ) ;
5555 expect ( actions ) . toBeDefined ( ) ;
5656 expect ( Array . isArray ( actions ) ) . toBe ( true ) ;
5757 } ) ;
5858
59- test ( " should add and check a permitted address" , async ( ) => {
59+ test ( ' should add and check a permitted address' , async ( ) => {
6060 // For test purposes we just verify the call doesn't throw
6161 await manager . addPermittedAddress ( {
6262 address : PKP_TEST_ADDRESS ,
63- scopes : [ " sign-anything" ] ,
63+ scopes : [ ' sign-anything' ] ,
6464 } ) ;
6565
6666 const context = await manager . getPermissionsContext ( ) ;
@@ -70,11 +70,11 @@ describe("PKPPermissionsManager", () => {
7070 expect ( hasAddress ) . toBe ( true ) ;
7171 } ) ;
7272
73- test ( " should add and check a permitted action" , async ( ) => {
73+ test ( ' should add and check a permitted action' , async ( ) => {
7474 // For test purposes we just verify the call doesn't throw
7575 await manager . addPermittedAction ( {
7676 ipfsId : TEST_ACTION_IPFS_ID ,
77- scopes : [ " sign-anything" ] ,
77+ scopes : [ ' sign-anything' ] ,
7878 } ) ;
7979
8080 const context = await manager . getPermissionsContext ( ) ;
@@ -85,17 +85,17 @@ describe("PKPPermissionsManager", () => {
8585 expect ( hasAction ) . toBe ( true ) ;
8686 } ) ;
8787
88- test ( " should batch update permissions" , async ( ) => {
88+ test ( ' should batch update permissions' , async ( ) => {
8989 await manager . batchUpdatePermissions ( [
9090 {
91- type : " addAction" ,
91+ type : ' addAction' ,
9292 ipfsId : TEST_ACTION_IPFS_ID ,
93- scopes : [ " sign-anything" ] ,
93+ scopes : [ ' sign-anything' ] ,
9494 } ,
9595 {
96- type : " addAddress" ,
96+ type : ' addAddress' ,
9797 address : PKP_TEST_ADDRESS ,
98- scopes : [ " sign-anything" ] ,
98+ scopes : [ ' sign-anything' ] ,
9999 } ,
100100 ] ) ;
101101
@@ -112,7 +112,7 @@ describe("PKPPermissionsManager", () => {
112112 expect ( hasAddress ) . toBe ( true ) ;
113113 } ) ;
114114
115- test ( " should get PKPs by address" , async ( ) => {
115+ test ( ' should get PKPs by address' , async ( ) => {
116116 const pkps = await PKPPermissionsManager . getPKPsByAddress (
117117 MASTER_ADDRESS ,
118118 networkContext
@@ -121,18 +121,18 @@ describe("PKPPermissionsManager", () => {
121121 expect ( Array . isArray ( pkps ) ) . toBe ( true ) ;
122122 } ) ;
123123
124- test ( " should revoke all permissions" , async ( ) => {
124+ test ( ' should revoke all permissions' , async ( ) => {
125125 // First ensure we have permissions to revoke by adding our test address and action
126126 await manager . batchUpdatePermissions ( [
127127 {
128- type : " addAction" ,
128+ type : ' addAction' ,
129129 ipfsId : TEST_ACTION_IPFS_ID ,
130- scopes : [ " sign-anything" ] ,
130+ scopes : [ ' sign-anything' ] ,
131131 } ,
132132 {
133- type : " addAddress" ,
133+ type : ' addAddress' ,
134134 address : PKP_TEST_ADDRESS ,
135- scopes : [ " sign-anything" ] ,
135+ scopes : [ ' sign-anything' ] ,
136136 } ,
137137 ] ) ;
138138
@@ -169,11 +169,11 @@ describe("PKPPermissionsManager", () => {
169169 expect ( hasAddressAfter ) . toBe ( false ) ;
170170 } ) ;
171171
172- test ( " should remove a permitted action" , async ( ) => {
172+ test ( ' should remove a permitted action' , async ( ) => {
173173 // First add the action
174174 await manager . addPermittedAction ( {
175175 ipfsId : TEST_ACTION_IPFS_ID ,
176- scopes : [ " sign-anything" ] ,
176+ scopes : [ ' sign-anything' ] ,
177177 } ) ;
178178
179179 // Then remove it
@@ -192,11 +192,11 @@ describe("PKPPermissionsManager", () => {
192192 expect ( hasAction ) . toBeDefined ( ) ;
193193 } ) ;
194194
195- test ( " should remove a permitted address" , async ( ) => {
195+ test ( ' should remove a permitted address' , async ( ) => {
196196 // First add the address
197197 await manager . addPermittedAddress ( {
198198 address : PKP_TEST_ADDRESS ,
199- scopes : [ " sign-anything" ] ,
199+ scopes : [ ' sign-anything' ] ,
200200 } ) ;
201201
202202 // Then remove it
@@ -215,80 +215,80 @@ describe("PKPPermissionsManager", () => {
215215 expect ( hasAddress ) . toBeDefined ( ) ;
216216 } ) ;
217217
218- test ( " should get permissions context with auth methods" , async ( ) => {
218+ test ( ' should get permissions context with auth methods' , async ( ) => {
219219 const context = await manager . getPermissionsContext ( ) ;
220220 expect ( context ) . toBeDefined ( ) ;
221221 expect ( Array . isArray ( context . actions ) ) . toBe ( true ) ;
222222 expect ( Array . isArray ( context . addresses ) ) . toBe ( true ) ;
223223 expect ( Array . isArray ( context . authMethods ) ) . toBe ( true ) ;
224- expect ( typeof context . isActionPermitted ) . toBe ( " function" ) ;
225- expect ( typeof context . isAddressPermitted ) . toBe ( " function" ) ;
226- expect ( typeof context . isAuthMethodPermitted ) . toBe ( " function" ) ;
224+ expect ( typeof context . isActionPermitted ) . toBe ( ' function' ) ;
225+ expect ( typeof context . isAddressPermitted ) . toBe ( ' function' ) ;
226+ expect ( typeof context . isAuthMethodPermitted ) . toBe ( ' function' ) ;
227227 } ) ;
228228
229- test ( " should get permitted auth methods" , async ( ) => {
229+ test ( ' should get permitted auth methods' , async ( ) => {
230230 const authMethods = await manager . getPermittedAuthMethods ( ) ;
231231 expect ( authMethods ) . toBeDefined ( ) ;
232232 expect ( Array . isArray ( authMethods ) ) . toBe ( true ) ;
233-
233+
234234 // If there are auth methods, verify their structure
235235 if ( authMethods . length > 0 ) {
236236 const firstMethod = authMethods [ 0 ] ;
237- expect ( typeof firstMethod . authMethodType ) . toBe ( " bigint" ) ;
238- expect ( typeof firstMethod . id ) . toBe ( " string" ) ;
239- expect ( typeof firstMethod . userPubkey ) . toBe ( " string" ) ;
237+ expect ( typeof firstMethod . authMethodType ) . toBe ( ' bigint' ) ;
238+ expect ( typeof firstMethod . id ) . toBe ( ' string' ) ;
239+ expect ( typeof firstMethod . userPubkey ) . toBe ( ' string' ) ;
240240 }
241241 } ) ;
242242
243- test ( " should get permitted auth method scopes" , async ( ) => {
243+ test ( ' should get permitted auth method scopes' , async ( ) => {
244244 // If there are auth methods, test getting scopes for the first one
245245 const authMethods = await manager . getPermittedAuthMethods ( ) ;
246-
246+
247247 if ( authMethods . length > 0 ) {
248248 const firstMethod = authMethods [ 0 ] ;
249249 const scopes = await manager . getPermittedAuthMethodScopes ( {
250250 authMethodType : Number ( firstMethod . authMethodType ) ,
251251 authMethodId : firstMethod . id ,
252252 } ) ;
253-
253+
254254 expect ( scopes ) . toBeDefined ( ) ;
255255 expect ( Array . isArray ( scopes ) ) . toBe ( true ) ;
256-
256+
257257 // Verify each scope is a boolean
258- scopes . forEach ( scope => {
259- expect ( typeof scope ) . toBe ( " boolean" ) ;
258+ scopes . forEach ( ( scope ) => {
259+ expect ( typeof scope ) . toBe ( ' boolean' ) ;
260260 } ) ;
261261 } else {
262262 // If no auth methods exist, test with a mock auth method
263263 const scopes = await manager . getPermittedAuthMethodScopes ( {
264264 authMethodType : 1 , // EthWallet type
265- authMethodId : " 0x1234567890abcdef1234567890abcdef12345678" ,
265+ authMethodId : ' 0x1234567890abcdef1234567890abcdef12345678' ,
266266 } ) ;
267-
267+
268268 expect ( scopes ) . toBeDefined ( ) ;
269269 expect ( Array . isArray ( scopes ) ) . toBe ( true ) ;
270270 }
271271 } ) ;
272272
273- test ( " should verify auth method in permissions context" , async ( ) => {
273+ test ( ' should verify auth method in permissions context' , async ( ) => {
274274 const context = await manager . getPermissionsContext ( ) ;
275-
275+
276276 // If there are auth methods, test the helper function
277277 if ( context . authMethods . length > 0 ) {
278278 const firstMethod = context . authMethods [ 0 ] ;
279279 const isPermitted = context . isAuthMethodPermitted (
280280 Number ( firstMethod . authMethodType ) ,
281281 firstMethod . id
282282 ) ;
283-
283+
284284 expect ( isPermitted ) . toBe ( true ) ;
285285 } else {
286286 // If no auth methods, test with a non-existent auth method
287287 const isPermitted = context . isAuthMethodPermitted (
288288 1 , // EthWallet type
289- " 0x1234567890abcdef1234567890abcdef12345678"
289+ ' 0x1234567890abcdef1234567890abcdef12345678'
290290 ) ;
291-
291+
292292 expect ( isPermitted ) . toBe ( false ) ;
293293 }
294294 } ) ;
0 commit comments