This commit is contained in:
parent
d6a40871c4
commit
c5bc0855d7
12
README.md
12
README.md
@ -116,6 +116,18 @@ const export = keystore.export_verification_data();
|
||||
keystore.import_verification_data(export);
|
||||
```
|
||||
|
||||
### Exporting and importing blacklist entries across server instances
|
||||
|
||||
```js
|
||||
const {blacklist} = require('@sapphirecode/auth-server-helper');
|
||||
|
||||
const export = blacklist.export_blacklist();
|
||||
|
||||
// second instance
|
||||
|
||||
blacklist.import_blacklist(export);
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT © Timo Hocker <timo@scode.ovh>
|
||||
|
@ -43,6 +43,14 @@ class Blacklist {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public export_blacklist (): Signature[] {
|
||||
return this._signatures;
|
||||
}
|
||||
|
||||
public import_blacklist (data: Signature[]): void {
|
||||
this._signatures.push (...data);
|
||||
}
|
||||
}
|
||||
|
||||
const bl = (new Blacklist);
|
||||
|
@ -5,7 +5,7 @@
|
||||
* Created by Timo Hocker <timo@scode.ovh>, December 2020
|
||||
*/
|
||||
|
||||
import blacklist from '../../lib/Blacklist';
|
||||
import blacklist, { Blacklist } from '../../lib/Blacklist';
|
||||
import { clock_finalize, clock_setup } from '../Helper';
|
||||
|
||||
// eslint-disable-next-line max-lines-per-function
|
||||
@ -60,4 +60,16 @@ describe ('blacklist', () => {
|
||||
expect (blacklist.is_valid ('baz'))
|
||||
.toBeFalse ();
|
||||
});
|
||||
|
||||
it ('should export and import data', () => {
|
||||
const exp = blacklist.export_blacklist ();
|
||||
// eslint-disable-next-line dot-notation
|
||||
expect (blacklist['_signatures'])
|
||||
.toEqual (exp);
|
||||
const bl2 = (new Blacklist);
|
||||
bl2.import_blacklist (exp);
|
||||
// eslint-disable-next-line dot-notation
|
||||
expect (bl2['_signatures'])
|
||||
.toEqual (exp);
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user