Add passphrase-generator plugin
This plugins generates passphrases using the [EFF's long wordlist][1]. Implements keeweb/keeweb#210.
The functionality is currently very basic: it adds adds a preset to the password generator view called "passphrase", and lets you choose the number of space-seperated words to generate with the length slider. It ignores all the other options from the generator view.
In the future, I'd like to improve the UX for the plugin by removing extraneous options from the generator view and allowing the user to save custom passphrase presets. I'd also like to add an option the change the word seperator, for example from ' ' to '-'.
Currently, the wordlist is not compressed, since there is no decompression api exposed to plugins. However, even with compression, the wordlist would need to be stored in the plugin.js file, likely in base64, since plugins cannot access external resources. The uncompressed wordlist is 60KiB, while the deflate compressed list, encoded in base64, is 32KiB.
[1]: https://www.eff.org/deeplinks/2016/07/new-wordlists-random-passphrases
2022-03-20 18:06:47 +01:00
|
|
|
/**
|
|
|
|
* KeeWeb plugin: passphrase-generator
|
|
|
|
* @author Grant Moyer
|
|
|
|
* @license MIT
|
|
|
|
*/
|
|
|
|
|
2022-03-29 05:22:33 +02:00
|
|
|
const { GeneratorPresets } = require('comp/app/generator-presets')
|
Add passphrase-generator plugin
This plugins generates passphrases using the [EFF's long wordlist][1]. Implements keeweb/keeweb#210.
The functionality is currently very basic: it adds adds a preset to the password generator view called "passphrase", and lets you choose the number of space-seperated words to generate with the length slider. It ignores all the other options from the generator view.
In the future, I'd like to improve the UX for the plugin by removing extraneous options from the generator view and allowing the user to save custom passphrase presets. I'd also like to add an option the change the word seperator, for example from ' ' to '-'.
Currently, the wordlist is not compressed, since there is no decompression api exposed to plugins. However, even with compression, the wordlist would need to be stored in the plugin.js file, likely in base64, since plugins cannot access external resources. The uncompressed wordlist is 60KiB, while the deflate compressed list, encoded in base64, is 32KiB.
[1]: https://www.eff.org/deeplinks/2016/07/new-wordlists-random-passphrases
2022-03-20 18:06:47 +01:00
|
|
|
const Kdbxweb = require('kdbxweb');
|
|
|
|
const { PasswordGenerator } = require('util/generators/password-generator');
|
|
|
|
|
2022-03-29 05:22:33 +02:00
|
|
|
let generatorPresetsBuiltIn = Object.getOwnPropertyDescriptor(GeneratorPresets, 'builtIn');
|
|
|
|
Object.defineProperty(GeneratorPresets, 'builtInOriginal', generatorPresetsBuiltIn);
|
|
|
|
Object.defineProperty(GeneratorPresets, 'builtIn', {
|
2022-03-29 05:23:04 +02:00
|
|
|
get: function() {
|
|
|
|
const presets = this.builtInOriginal;
|
|
|
|
presets.push({
|
|
|
|
name: 'passphrase',
|
|
|
|
title: 'passphrase',
|
|
|
|
type: 'passphrase',
|
|
|
|
builtIn: true,
|
2022-03-30 01:10:44 +02:00
|
|
|
options: [
|
|
|
|
{
|
|
|
|
name: 'upper',
|
|
|
|
title: 'Uppercase words',
|
|
|
|
sample: 'WORD',
|
|
|
|
label: 'CAP',
|
|
|
|
type: 'checkbox'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'seperator',
|
|
|
|
title: 'Word seperator',
|
|
|
|
type: 'text'
|
|
|
|
}
|
|
|
|
],
|
|
|
|
seperator: ' ',
|
2022-03-29 05:23:04 +02:00
|
|
|
length: 6
|
|
|
|
})
|
|
|
|
return presets;
|
|
|
|
}
|
2022-03-29 05:22:33 +02:00
|
|
|
})
|
Add passphrase-generator plugin
This plugins generates passphrases using the [EFF's long wordlist][1]. Implements keeweb/keeweb#210.
The functionality is currently very basic: it adds adds a preset to the password generator view called "passphrase", and lets you choose the number of space-seperated words to generate with the length slider. It ignores all the other options from the generator view.
In the future, I'd like to improve the UX for the plugin by removing extraneous options from the generator view and allowing the user to save custom passphrase presets. I'd also like to add an option the change the word seperator, for example from ' ' to '-'.
Currently, the wordlist is not compressed, since there is no decompression api exposed to plugins. However, even with compression, the wordlist would need to be stored in the plugin.js file, likely in base64, since plugins cannot access external resources. The uncompressed wordlist is 60KiB, while the deflate compressed list, encoded in base64, is 32KiB.
[1]: https://www.eff.org/deeplinks/2016/07/new-wordlists-random-passphrases
2022-03-20 18:06:47 +01:00
|
|
|
|
2022-03-29 05:22:33 +02:00
|
|
|
let passwordGeneratorGenerate = PasswordGenerator.generate;
|
|
|
|
PasswordGenerator.generate = function(preset) {
|
2022-03-29 05:23:04 +02:00
|
|
|
if (preset.type !== 'passphrase') return passwordGeneratorGenerate(preset);
|
|
|
|
if (typeof preset.length !== 'number' || preset.length < 0) {
|
|
|
|
return '';
|
|
|
|
}
|
2022-03-30 01:10:44 +02:00
|
|
|
let password = Array
|
2022-03-29 05:23:04 +02:00
|
|
|
.from({length: preset.length}, _ => eff_large_wordlist()[get_random_index()])
|
2022-03-30 01:10:44 +02:00
|
|
|
.join(preset.seperator);
|
|
|
|
if (preset.upper) {
|
|
|
|
password = password.toUpperCase();
|
|
|
|
}
|
2022-03-29 05:23:04 +02:00
|
|
|
return password;
|
Add passphrase-generator plugin
This plugins generates passphrases using the [EFF's long wordlist][1]. Implements keeweb/keeweb#210.
The functionality is currently very basic: it adds adds a preset to the password generator view called "passphrase", and lets you choose the number of space-seperated words to generate with the length slider. It ignores all the other options from the generator view.
In the future, I'd like to improve the UX for the plugin by removing extraneous options from the generator view and allowing the user to save custom passphrase presets. I'd also like to add an option the change the word seperator, for example from ' ' to '-'.
Currently, the wordlist is not compressed, since there is no decompression api exposed to plugins. However, even with compression, the wordlist would need to be stored in the plugin.js file, likely in base64, since plugins cannot access external resources. The uncompressed wordlist is 60KiB, while the deflate compressed list, encoded in base64, is 32KiB.
[1]: https://www.eff.org/deeplinks/2016/07/new-wordlists-random-passphrases
2022-03-20 18:06:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports.uninstall = function() {
|
2022-03-29 05:23:04 +02:00
|
|
|
Object.defineProperty(GeneratorPresets, 'builtIn', generatorPresetsBuiltIn);
|
|
|
|
Object.defineProperty(GeneratorPresets, 'builtInOriginal', {});
|
|
|
|
PasswordGenerator.generate = passwordGeneratorGenerate;
|
Add passphrase-generator plugin
This plugins generates passphrases using the [EFF's long wordlist][1]. Implements keeweb/keeweb#210.
The functionality is currently very basic: it adds adds a preset to the password generator view called "passphrase", and lets you choose the number of space-seperated words to generate with the length slider. It ignores all the other options from the generator view.
In the future, I'd like to improve the UX for the plugin by removing extraneous options from the generator view and allowing the user to save custom passphrase presets. I'd also like to add an option the change the word seperator, for example from ' ' to '-'.
Currently, the wordlist is not compressed, since there is no decompression api exposed to plugins. However, even with compression, the wordlist would need to be stored in the plugin.js file, likely in base64, since plugins cannot access external resources. The uncompressed wordlist is 60KiB, while the deflate compressed list, encoded in base64, is 32KiB.
[1]: https://www.eff.org/deeplinks/2016/07/new-wordlists-random-passphrases
2022-03-20 18:06:47 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
function get_random_index() {
|
2022-03-29 05:23:04 +02:00
|
|
|
let rand = 6**5 * 8; // greatest multiple of 6**5 below 2**16
|
|
|
|
while (rand >= 6**5 * 8) {
|
|
|
|
const randBytes = Kdbxweb.CryptoEngine.random(2);
|
|
|
|
rand = (randBytes[1] << 8) + randBytes[0];
|
|
|
|
}
|
|
|
|
rand = rand % 6**5;
|
|
|
|
return rand;
|
Add passphrase-generator plugin
This plugins generates passphrases using the [EFF's long wordlist][1]. Implements keeweb/keeweb#210.
The functionality is currently very basic: it adds adds a preset to the password generator view called "passphrase", and lets you choose the number of space-seperated words to generate with the length slider. It ignores all the other options from the generator view.
In the future, I'd like to improve the UX for the plugin by removing extraneous options from the generator view and allowing the user to save custom passphrase presets. I'd also like to add an option the change the word seperator, for example from ' ' to '-'.
Currently, the wordlist is not compressed, since there is no decompression api exposed to plugins. However, even with compression, the wordlist would need to be stored in the plugin.js file, likely in base64, since plugins cannot access external resources. The uncompressed wordlist is 60KiB, while the deflate compressed list, encoded in base64, is 32KiB.
[1]: https://www.eff.org/deeplinks/2016/07/new-wordlists-random-passphrases
2022-03-20 18:06:47 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
let wordlist;
|
|
|
|
function eff_large_wordlist() {
|
2022-03-29 05:23:04 +02:00
|
|
|
if (wordlist !== undefined) return wordlist;
|
|
|
|
// EFF long word list: https://www.eff.org/deeplinks/2016/07/new-wordlists-random-passphrases
|
|
|
|
wordlist = 'abacus:abdomen:abdominal:abide:abiding:ability:ablaze:able:abnormal:abrasion:abrasive:abreast:abridge:abroad:abruptly:absence:absentee:absently:absinthe:absolute:absolve:abstain:abstract:absurd:accent:acclaim:acclimate:accompany:account:accuracy:accurate:accustom:acetone:achiness:aching:acid:acorn:acquaint:acquire:acre:acrobat:acronym:acting:action:activate:activator:active:activism:activist:activity:actress:acts:acutely:acuteness:aeration:aerobics:aerosol:aerospace:afar:affair:affected:affecting:affection:affidavit:affiliate:affirm:affix:afflicted:affluent:afford:affront:aflame:afloat:aflutter:afoot:afraid:afterglow:afterlife:aftermath:aftermost:afternoon:aged:ageless:agency:agenda:agent:aggregate:aghast:agile:agility:aging:agnostic:agonize:agonizing:agony:agreeable:agreeably:agreed:agreeing:agreement:aground:ahead:ahoy:aide:aids:aim:ajar:alabaster:alarm:albatross:album:alfalfa:algebra:algorithm:alias:alibi:alienable:alienate:aliens:alike:alive:alkaline:alkalize:almanac:almighty:almost:aloe:aloft:aloha:alone:alongside:aloof:alphabet:alright:although:altitude:alto:aluminum:alumni:always:amaretto:amaze:amazingly:amber:ambiance:ambiguity:ambiguous:ambition:ambitious:ambulance:ambush:amendable:amendment:amends:amenity:amiable:amicably:amid:amigo:amino:amiss:ammonia:ammonium:amnesty:amniotic:among:amount:amperage:ample:amplifier:amplify:amply:amuck:amulet:amusable:amused:amusement:amuser:amusing:anaconda:anaerobic:anagram:anatomist:anatomy:anchor:anchovy:ancient:android:anemia:anemic:aneurism:anew:angelfish:angelic:anger:angled:angler:angles:angling:angrily:angriness:anguished:angular:animal:animate:animating:animation:animator:anime:animosity:ankle:annex:annotate:announcer:annoying:annually:annuity:anointer:another:answering:antacid:antarctic:anteater:antelope:antennae:anthem:anthill:anthology:antibody:antics:antidote:antihero:antiquely:antiques:antiquity:antirust:antitoxic:antitrust:antiviral:antivirus:antler:antonym:antsy:anvil:anybody:anyhow:anymore:anyone:anyplace:anything:anytime:anyway:anywhere:aorta:apache:apostle:appealing:appear:appease:appeasing:appendage:appendix:appetite:appetizer:applaud:applause:apple:appliance:applicant:applied:apply:appointee:appraisal:appraiser:apprehend:approach:approval:approve:apricot:april:apron:aptitude:aptly:aqua:aqueduct:arbitrary:arbitrate:ardently:area:arena:arguable:arguably:argue:arise:armadillo:armband:armchair:armed:armful:armhole:arming:armless:armoire:armored:armory:armrest:army:aroma:arose:around:arousal:arrange:array:arrest:arrival:arrive:arrogance:arrogant:arson:art:ascend:ascension:ascent:ascertain:ashamed:ashen:ashes:ashy:aside:askew:asleep:asparagus:aspect:aspirate:aspire:aspirin:astonish:astound:astride:astrology:astronaut:astronomy:astute:atlantic:atlas:atom:atonable:atop:atrium:atrocious:atrophy:attach:attain:attempt:attendant:attendee:attention:attentive:attest:attic:attire:attitude:attractor:attribute:atypical:auction:audacious:audacity:audible:audibly:audience:audio:audition:augmented:august:authentic:author:autism:autistic:autograph:automaker:automated:automatic:autopilot:available:avalanche:avatar:avenge:avenging:avenue:average:aversion:avert:aviation:aviator:avid:avoid:await:awaken:award:aware:awhile:awkward:awning:awoke:awry:axis:babble:babbling:babied:baboon:backache:backboard:backboned:backdrop:backed:backer:backfield:backfire:backhand:backing:backlands:backlash:backless:backlight:backlit:backlog:backpack:backpedal:backrest:backroom:backshift:backside:backslid:backspace:backspin:backstab:backstage:backtalk:backtrack:backup:backward:backwash:backwater:backyard:bacon:bacteria:bacterium:badass:badge:badland:badly:badness:baffle:baffling:bagel:bagful:baggage:bagged:baggie:bagginess:bagging:baggy:bagpipe:baguette:baked:bakery:bakeshop:baking:balance:balancing:balcony:balmy:balsamic:bamboo:banana:banish:banister:banjo:bankable:bankbook:banked:banker:banking:banknote:bankroll:banner:bannister:banshee:banter:barbecue:barbed:barbell:barber:barcode:barge:bargraph:barista:baritone:barley:barmaid:barman:barn:barometer:barrack:barracuda:barrel:barrette:b
|
|
|
|
return wordlist;
|
Add passphrase-generator plugin
This plugins generates passphrases using the [EFF's long wordlist][1]. Implements keeweb/keeweb#210.
The functionality is currently very basic: it adds adds a preset to the password generator view called "passphrase", and lets you choose the number of space-seperated words to generate with the length slider. It ignores all the other options from the generator view.
In the future, I'd like to improve the UX for the plugin by removing extraneous options from the generator view and allowing the user to save custom passphrase presets. I'd also like to add an option the change the word seperator, for example from ' ' to '-'.
Currently, the wordlist is not compressed, since there is no decompression api exposed to plugins. However, even with compression, the wordlist would need to be stored in the plugin.js file, likely in base64, since plugins cannot access external resources. The uncompressed wordlist is 60KiB, while the deflate compressed list, encoded in base64, is 32KiB.
[1]: https://www.eff.org/deeplinks/2016/07/new-wordlists-random-passphrases
2022-03-20 18:06:47 +01:00
|
|
|
}
|