Browse Source

Update dependencies

pull/91/head
AlphaX-Projects 2 years ago
parent
commit
8edd13a083
  1. 2
      package.json
  2. 17
      qortal-ui-core/package.json
  3. 14
      qortal-ui-core/src/components/login-view/create-account-section.js
  4. 160
      qortal-ui-core/src/functional-components/random-sentence-generator.js
  5. 36
      qortal-ui-core/src/functional-components/verb-past-tense.js
  6. 27
      qortal-ui-core/src/functional-components/wordlists.js
  7. 16
      qortal-ui-plugins/package.json

2
package.json

@ -37,7 +37,7 @@
"os-locale": "3.0.0"
},
"devDependencies": {
"electron": "22.0.0",
"electron": "22.0.2",
"electron-builder": "23.6.0",
"electron-packager": "17.1.1",
"@electron/notarize": "1.2.3",

17
qortal-ui-core/package.json

@ -58,23 +58,22 @@
"@rollup/plugin-commonjs": "24.0.0",
"@rollup/plugin-node-resolve": "15.0.1",
"@rollup/plugin-replace": "5.0.2",
"@rollup/plugin-terser": "0.2.1",
"@vaadin/button": "23.3.2",
"@vaadin/grid": "23.3.2",
"@vaadin/icons": "23.3.2",
"@vaadin/password-field": "23.3.2",
"@vaadin/tooltip": "23.3.2",
"@rollup/plugin-terser": "0.3.0",
"@vaadin/button": "23.3.3",
"@vaadin/grid": "23.3.3",
"@vaadin/icons": "23.3.3",
"@vaadin/password-field": "23.3.3",
"@vaadin/tooltip": "23.3.3",
"asmcrypto.js": "2.3.2",
"bcryptjs": "2.4.3",
"epml": "0.3.3",
"file-saver": "2.0.5",
"lit": "2.5.0",
"lit": "2.6.1",
"lit-translate": "2.0.1",
"pwa-helpers": "0.9.1",
"random-sentence-generator": "0.0.8",
"redux": "4.2.0",
"redux-thunk": "2.4.2",
"rollup": "3.9.1",
"rollup": "3.10.0",
"rollup-plugin-node-globals": "1.4.0",
"rollup-plugin-progress": "1.1.2",
"rollup-plugin-scss": "3.0.0"

14
qortal-ui-core/src/components/login-view/create-account-section.js

@ -4,11 +4,13 @@ import { store } from '../../store.js'
import { use, get, translate, translateUnsafeHTML, registerTranslateConfig } from 'lit-translate'
import { createWallet } from '../../../../qortal-ui-crypto/api/createWallet.js'
import FileSaver from 'file-saver'
import { doLogin, doLogout, doSelectAddress } from '../../redux/app/app-actions.js'
import { doStoreWallet } from '../../redux/user/user-actions.js'
import { checkApiKey } from '../../apiKeyUtils.js'
import FileSaver from 'file-saver'
import ripple from '../../functional-components/loading-ripple.js'
import snackbar from '../../functional-components/snackbar.js'
import '../../functional-components/random-sentence-generator.js'
import '@material/mwc-button'
import '@material/mwc-checkbox'
import '@material/mwc-textfield'
@ -22,8 +24,6 @@ import '@polymer/paper-input/paper-input.js'
import '@polymer/paper-tooltip/paper-tooltip.js'
import '@vaadin/text-field/vaadin-text-field.js'
import '@vaadin/password-field/vaadin-password-field.js'
import 'random-sentence-generator'
import ripple from '../../functional-components/loading-ripple.js'
let lastPassword = ''
@ -393,17 +393,17 @@ class CreateAccountSection extends connect(store)(LitElement) {
</random-sentence-generator>
</div>
<!--
--- --- --- --- --- --- --- --- --- --- --- -
--- --- --- --- --- --- --- --- --- --- --- --- --- -
Calculations
--- --- --- --- --- --- --- --- --- --- --- -
--- --- --- --- --- --- --- --- --- --- --- --- --- -
403 adjectives
60 interjections
243 adverbs
2353 nouns
3387 verbs
--- --- --- --- --- --- --- --- --- --- --- -
--- --- --- --- --- --- --- --- --- --- --- --- --- -
sooo 243*3387*403*2353*3387*403*2353*403*2353 ~ 2^92
--- --- --- --- --- --- --- --- --- --- --- -
--- --- --- --- --- --- --- --- --- --- --- --- --- -
-->
</div><br>
<div class="horizontal-center">

160
qortal-ui-core/src/functional-components/random-sentence-generator.js

@ -0,0 +1,160 @@
// Author: irontiga <[email protected]>
'use strict'
import { LitElement, html, css } from 'lit'
import * as WORDLISTS from './wordlists.js'
class RandomSentenceGenerator extends LitElement {
static get properties() {
return {
template: {
type: String,
attribute: 'template'
},
parsedString: {
type: String
},
fetchedWordlistCount: {
type: Number,
value: 0
},
capitalize: {
type: Boolean
},
partsOfSpeechMap: {
type: Object
},
templateEntropy: {
type: Number,
reflect: true,
attribute: 'template-entropy'
},
maxWordLength: {
type: Number,
attribute: 'max-word-length'
}
}
}
constructor() {
super()
this.template = 'adjective noun verb adverb.'
this.maxWordLength = 0
this.parsedString = ''
this.fetchedWordlistCount = 0
this.capitalize = true
this.partsOfSpeechMap = {
'noun': 'nouns',
'adverb': 'adverbs',
'adv': 'adverbs',
'verb': 'verbs',
'interjection': 'interjections',
'adjective': 'adjectives',
'adj': 'adjectives',
'verbed': 'verbed'
}
this.partsOfSpeech = Object.keys(this.partsOfSpeechMap)
this._wordlists = WORDLISTS
}
updated(changedProperties) {
let regen = false
if (changedProperties.has('template')) {
regen = true
}
if (changedProperties.has('maxWordLength')) {
console.dir(this.maxWordLength)
if (this.maxWordLength) {
const wl = { ...this._wordlists }
for (const partOfSpeech in this._wordlists) {
console.log(this._wordlists[partOfSpeech])
if (Array.isArray(this._wordlists[partOfSpeech])) {
wl[partOfSpeech] = this._wordlists[partOfSpeech].filter(word => word.length <= this.maxWordLength)
}
}
this._wordlists = wl
}
regen = true
}
if (regen) this.generate()
}
_RNG(entropy) {
if (entropy > 1074) {
throw new Error('Javascript can not handle that much entropy!')
}
let randNum = 0
const crypto = window.crypto || window.msCrypto
if (crypto) {
const entropy256 = Math.ceil(entropy / 8)
let buffer = new Uint8Array(entropy256)
crypto.getRandomValues(buffer)
randNum = buffer.reduce((num, value) => {
return num * value
}, 1) / Math.pow(256, entropy256)
} else {
console.warn('Secure RNG not found. Using Math.random')
randNum = Math.random()
}
return randNum
}
setRNG(fn) {
this._RNG = fn
}
_captitalize(str) {
return str.charAt(0).toUpperCase() + str.slice(1)
}
getWord(partOfSpeech) {
const words = this._wordlists[this.partsOfSpeechMap[partOfSpeech]]
const requiredEntropy = Math.log(words.length) / Math.log(2)
const index = this._RNG(requiredEntropy) * words.length
return {
word: words[Math.round(index)],
entropy: words.length
}
}
generate() {
this.parsedString = this.parse(this.template)
}
parse(template) {
const split = template.split(/[\s]/g)
let entropy = 1
const final = split.map(word => {
const lower = word.toLowerCase()
this.partsOfSpeech.some(partOfSpeech => {
const partOfSpeechIndex = lower.indexOf(partOfSpeech) // Check it exists
const nextChar = word.charAt(partOfSpeech.length)
if (partOfSpeechIndex === 0 && !(nextChar && (nextChar.match(/[a-zA-Z]/g) != null))) {
const replacement = this.getWord(partOfSpeech)
word = replacement.word + word.slice(partOfSpeech.length) // Append the rest of the "word" (punctuation)
entropy = entropy * replacement.entropy
return true
}
})
return word
})
this.templateEntropy = Math.floor(Math.log(entropy) / Math.log(8))
return final.join(' ')
}
render() {
return html`
${this.parsedString}
`
}
}
customElements.define('random-sentence-generator', RandomSentenceGenerator)
export default RandomSentenceGenerator

36
qortal-ui-core/src/functional-components/verb-past-tense.js

@ -0,0 +1,36 @@
// Sourced from https://gist.github.com/letsgetrandy/1e05a68ea74ba6736eb5
export const EXCEPTIONS = {
'are': 'were',
'eat': 'ate',
'go': 'went',
'have': 'had',
'inherit': 'inherited',
'is': 'was',
'run': 'ran',
'sit': 'sat',
'visit': 'visited'
}
export const getPastTense = (verb, exceptions = EXCEPTIONS) => {
if (exceptions[verb]) {
return exceptions[verb]
}
if ((/e$/i).test(verb)) {
return verb + 'd'
}
if ((/[aeiou]c$/i).test(verb)) {
return verb + 'ked'
}
// for american english only
if ((/el$/i).test(verb)) {
return verb + 'ed'
}
if ((/[aeio][aeiou][dlmnprst]$/).test(verb)) {
return verb + 'ed'
}
if ((/[aeiou][bdglmnprst]$/i).test(verb)) {
return verb.replace(/(.+[aeiou])([bdglmnprst])/, '$1$2$2ed')
}
return verb + 'ed'
}

27
qortal-ui-core/src/functional-components/wordlists.js

File diff suppressed because one or more lines are too long

16
qortal-ui-plugins/package.json

@ -46,19 +46,19 @@
"@rollup/plugin-commonjs": "24.0.0",
"@rollup/plugin-node-resolve": "15.0.1",
"@rollup/plugin-replace": "5.0.2",
"@rollup/plugin-terser": "0.2.1",
"@vaadin/avatar": "23.3.2",
"@vaadin/button": "23.3.2",
"@vaadin/grid": "23.3.2",
"@vaadin/icons": "23.3.2",
"@vaadin/tooltip": "23.3.2",
"@rollup/plugin-terser": "0.3.0",
"@vaadin/avatar": "23.3.3",
"@vaadin/button": "23.3.3",
"@vaadin/grid": "23.3.3",
"@vaadin/icons": "23.3.3",
"@vaadin/tooltip": "23.3.3",
"epml": "0.3.3",
"file-saver": "2.0.5",
"highcharts": "10.3.2",
"html-escaper": "3.0.3",
"lit": "2.5.0",
"lit": "2.6.1",
"lit-translate": "2.0.1",
"rollup": "3.9.1",
"rollup": "3.10.0",
"rollup-plugin-node-globals": "1.4.0",
"rollup-plugin-progress": "1.1.2"
},

Loading…
Cancel
Save