async revokeExpired(attempts = 3) {
    const data = await this.storage.get().catch((error) => { throw error });
    if (data) {
      const closedIDs = await Promise.all(Object.keys(data).map(async id => {
        const permission = data[id].permission;
        if (new Duration(permission.ttl).expired(data[id].timestamp)) {
          switch (permission.provider) {
            case "aws-sg":
              try {
                return await new AwsSecurityGroup(permission.region).revokeIngress(id, data[id].ip, permission) ? id : null;
              } catch (error) {
                console.log(error);
                return null;
              }
            default:
              throw new Error("Unsupported provider");
          }
        }
      })).catch((error) => { throw (error) });
      let newData = data;
      let updated = false;
      closedIDs.forEach((id) => {
        if (typeof id === 'string') {
          delete newData[id];
          updated = true;
        }
      });
      if (updated) {
        try {
          await this.storage.set(newData);
        } catch (error) {
          if ((error instanceof ConflictError) && (attempts > 0)) {
            return await revokeExpired(attempts--).catch((errror) => { throw (error); });
          }
          throw error;
        };
      }
    }
  }
/**
   * Revokes stored authorized permissions which are expired.
   * 
   * @returns nothing
   * @throws Throws error in case of issues.
   */
Revokes stored authorized permissions which are expired.

@returns nothing
@throws Throws error in case of issues.
Revokes stored authorized permissions which are expired . @returns nothing @throws Throws error in case of issues .
async revokeExpired(attempts = 3) {
    const data = await this.storage.get().catch((error) => { throw error });
    if (data) {
      const closedIDs = await Promise.all(Object.keys(data).map(async id => {
        const permission = data[id].permission;
        if (new Duration(permission.ttl).expired(data[id].timestamp)) {
          switch (permission.provider) {
            case "aws-sg":
              try {
                return await new AwsSecurityGroup(permission.region).revokeIngress(id, data[id].ip, permission) ? id : null;
              } catch (error) {
                console.log(error);
                return null;
              }
            default:
              throw new Error("Unsupported provider");
          }
        }
      })).catch((error) => { throw (error) });
      let newData = data;
      let updated = false;
      closedIDs.forEach((id) => {
        if (typeof id === 'string') {
          delete newData[id];
          updated = true;
        }
      });
      if (updated) {
        try {
          await this.storage.set(newData);
        } catch (error) {
          if ((error instanceof ConflictError) && (attempts > 0)) {
            return await revokeExpired(attempts--).catch((errror) => { throw (error); });
          }
          throw error;
        };
      }
    }
  }
async revokeExpired ( attempts = 3 ) { const data = await this . storage . get ( ) . catch ( ( error ) => { throw error } ) ; if ( data ) { const closedIDs = await Promise . all ( Object . keys ( data ) . map ( async id => { const permission = data [ id ] . permission ; if ( new Duration ( permission . ttl ) . expired ( data [ id ] . timestamp ) ) { switch ( permission . provider ) { case "aws-sg" : try { return await new AwsSecurityGroup ( permission . region ) . revokeIngress ( id , data [ id ] . ip , permission ) ? id : null ; } catch ( error ) { console . log ( error ) ; return null ; } default : throw new Error ( "Unsupported provider" ) ; } } } ) ) . catch ( ( error ) => { throw ( error ) } ) ; let newData = data ; let updated = false ; closedIDs . forEach ( ( id ) => { if ( typeof id === 'string' ) { delete newData [ id ] ; updated = true ; } } ) ; if ( updated ) { try { await this . storage . set ( newData ) ; } catch ( error ) { if ( ( error instanceof ConflictError ) && ( attempts > 0 ) ) { return await revokeExpired ( attempts -- ) . catch ( ( errror ) => { throw ( error ) ; } ) ; } throw error ; } ; } } }
Revokes stored authorized permissions which are expired.
Revokes stored authorized permissions which are expired .