Skip to content

Commit 2bb132c

Browse files
authored
0.6.5 (#158)
* 0.6.5 initial commit * update deps * update docs * vue-vite improve layout and scrollbars * wip * wip * scaling websockets * scalable websockets * add lucia & solidjs frontend * update deps * wip * add job path, sonarlint * 0.6.5 * sonar fix
1 parent 4578973 commit 2bb132c

File tree

107 files changed

+1478
-1052
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+1478
-1052
lines changed

@es-labs/esm/apollo.js

Lines changed: 0 additions & 105 deletions
This file was deleted.

@es-labs/esm/bwc-autocomplete.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,7 @@ class AutoComplete extends HTMLElement {
8585
}
8686
}
8787
}
88-
8988
// console.log('setup stuff', this.required, this.disabled, this.inputClass)
90-
9189
el.value = this.value
9290
el.className = this.inputClass || 'input' // default to bulma?
9391

@es-labs/esm/fetch.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,3 @@ class Fetch {
113113
}
114114

115115
export default Fetch
116-
117-
// function greeterFactory(greeting = "Hello") {
118-
// return {
119-
// greet: () => console.log(`${greeting}!`)
120-
// }
121-
// }
122-
123-
// export default greeterFactory

@es-labs/esm/log-filter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// const type = 'error'
1+
//NOSONAR const type = 'error'
22
// const orig = console[type]
33
// console[type] = function logError() {
44
// orig.apply(console, [`[${new Date().toISOString().replace("T", " ").replace(/\..+/, "")}]`, ...arguments])

@es-labs/esm/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@es-labs/esm",
3-
"version": "0.0.7",
3+
"version": "0.0.8",
44
"author": "Aaron Gong",
55
"license": "MIT",
66
"repository": {

@es-labs/esm/pwa.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ const urlBase64ToUint8Array = (base64String) => {
113113

114114
const handleSwMessage = async (e) => {
115115
console.log('handleSwMessage', e)
116-
// if (e && e.data && e.data.msg === 'pushsubscriptionchange') { }
116+
//NOSONAR if (e && e.data && e.data.msg === 'pushsubscriptionchange') { }
117117
}
118118

119119
export const addSwMessageEvent = (handler = handleSwMessage) => {

@es-labs/esm/saml.js

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,9 @@
11
import Fetch from './fetch.js'
22

3-
const val = () => {
4-
// try catch
5-
// let token = window.location.hash.substring(1) // (new URL(window.location.href)).searchParams.get('token')
6-
// if (!token) this.getFromLocalStorage()
7-
// if (!token) this.login()
8-
// else this.setToken(token)
9-
}
10-
3+
// window.location.hash.substring(1) // (new URL(window.location.href)).searchParams.get('token')
114
export const samlLogin = (samlUrl, callbackUrl) => {
125
const port = window.location.port === '443' || window.location.port === '80' ? '' : ':' + window.location.port
136
const redirect = window.location.protocol + '//' + window.location.hostname + port + callbackUrl
147
const { urlFull } = Fetch.parseUrl(`/api/saml/login?RelayState=${redirect}`, samlUrl)
158
window.location.assign(urlFull)
169
}
17-
18-
// logout - cleartoken - window.location.replace('https://adfc.test.com/adfs/ls/?wa=wsignout1.0&wreply='+ encodeURIComponent(LOGOUT_URL))
19-
// mounted
20-
// import Abc from './asdasd.js'
21-
// let abc = new Abc(conf)
22-
// abc.val()
23-
// if (abc._token) {
24-
// this.payload = abc._payload
25-
// this.token = abc._token }

@es-labs/node/auth/aes.js

Lines changed: 60 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -4,68 +4,84 @@
44

55
const crypto = require('crypto')
66

7-
exports.encryptText = (algor, key, iv, text, encoding) => {
7+
const encryptText = (algor, key, iv, text, encoding) => {
88
const cipher = crypto.createCipheriv(algor, key, iv)
99
encoding = encoding || 'binary'
1010
let result = cipher.update(text, 'utf8', encoding)
1111
result += cipher.final(encoding)
1212
return result
1313
}
1414

15-
exports.decryptText = (algor, key, iv, text, encoding) => {
15+
const decryptText = (algor, key, iv, text, encoding) => {
1616
const decipher = crypto.createDecipheriv(algor, key, iv)
1717
encoding = encoding || 'binary'
1818
let result = decipher.update(text, encoding)
1919
result += decipher.final()
2020
return result
2121
}
2222

23-
/*
24-
const data = 'This is a test'
25-
const password = 'hello'
26-
const algorithm = 'aes256'
27-
const args = process.argv.slice(3)
23+
const genIv = () => new Buffer.alloc(16,crypto.pseudoRandomBytes(16))
2824

29-
data = args[0]
30-
password = args[1]
31-
algorithm = args[2]
32-
33-
console.log('Text: ' + data)
34-
console.log('Password: ' + password)
35-
console.log('Type: ' + algorithm)
25+
const genKey = (algorithm, password) => {
26+
let hash, key
27+
if (algorithm.includes("256")) {
28+
hash = crypto.createHash('sha256') // NOSONAR
29+
hash.update(password)
30+
key = new Buffer.alloc(32,hash.digest('hex'),'hex')
31+
} else if (algorithm.includes("192")) {
32+
hash = crypto.createHash('sha192') // NOSONAR
33+
hash.update(password);
34+
key = new Buffer.alloc(24,hash.digest('hex'),'hex')
35+
} else if (algorithm.includes("128")) {
36+
hash = crypto.createHash('md5') // NOSONAR
37+
hash.update(password)
38+
key = new Buffer.alloc(16,hash.digest('hex'),'hex')
39+
}
40+
return key
41+
}
3642

37-
let hash, key
43+
const test_aes = () => {
44+
const data = 'This is a test'
45+
const password = 'hello' // NOSONAR
46+
const algorithm = 'aes256'
47+
//NOSONAR const args = process.argv.slice(3)
48+
// data = args[0]
49+
// password = args[1]
50+
// algorithm = args[2]
51+
52+
console.log('Text: ' + data)
53+
console.log('Password: ' + password)
54+
console.log('Type: ' + algorithm)
3855

39-
if (algorithm.includes("256")) {
40-
hash = crypto.createHash('sha256')
41-
hash.update(password)
42-
key = new Buffer.alloc(32,hash.digest('hex'),'hex')
43-
} else if (algorithm.includes("192")) {
44-
hash = crypto.createHash('sha192')
45-
hash.update(password);
46-
key = new Buffer.alloc(24,hash.digest('hex'),'hex')
47-
} else if (algorithm.includes("128")) {
48-
hash = crypto.createHash('md5')
49-
hash.update(password)
50-
key = new Buffer.alloc(16,hash.digest('hex'),'hex')
56+
57+
const iv = genIv()
58+
const key = genKey(algorithm, password)
59+
console.log('Key: ' + key.toString('base64'))
60+
console.log('Salt: ' + iv.toString('base64'))
61+
62+
const encText = encryptText(algorithm, key, iv, data, 'base64')
63+
console.log('Encrypted: ' + encText)
64+
65+
const decText = decryptText(algorithm, key, iv, encText, 'base64')
66+
console.log('Decrypted: ' + decText);
5167
}
5268

53-
const iv = new Buffer.alloc(16,crypto.pseudoRandomBytes(16))
54-
console.log('Key: ' + key.toString('base64'))
55-
console.log('Salt: ' + iv.toString('base64'))
56-
57-
const encText = encryptText(algorithm, key, iv, data, 'base64')
58-
console.log('Encrypted: ' + encText)
69+
const test_decrypt = () => {
70+
let ct = crypto.enc.Base64.parse('your-cipher-text')
71+
let iv = crypto.enc.Base64.parse('your-iv')
72+
let key = crypto.enc.Base64.parse('your-key')
73+
const decrypt = crypto.algo.AES.createDecryptor(key, { iv })
74+
const proc = decrypt.process(ct)
75+
const final = decrypt.finalize()
76+
const plain = proc.toString(crypto.enc.Utf8) + final.toString(crypto.enc.Utf8)
77+
console.log(plain)
78+
}
5979

60-
const decText = decryptText(algorithm, key, iv, encText, 'base64')
61-
console.log('Decrypted: ' + decText);
62-
*/
80+
test_aes()
6381

64-
// let ct = crypto.enc.Base64.parse('your-cipher-text')
65-
// let iv = crypto.enc.Base64.parse('your-iv')
66-
// let key = crypto.enc.Base64.parse('your-key')
67-
// const decrypt = crypto.algo.AES.createDecryptor(key, { iv })
68-
// const proc = decrypt.process(ct)
69-
// const final = decrypt.finalize()
70-
// const plain = proc.toString(crypto.enc.Utf8) + final.toString(crypto.enc.Utf8)
71-
// console.log(plain)
82+
module.exports = {
83+
genIv,
84+
genKey,
85+
encryptText,
86+
decryptText
87+
}

@es-labs/node/auth/index.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ const otplib = require('otplib')
44
const bcrypt = require('bcryptjs')
55
const jwt = require('jsonwebtoken')
66

7-
// const uuid = require('uuid/v4')
8-
// const qrcode = require('qrcode')
7+
//NOSONAR const uuid = require('uuid/v4')
8+
//NOSONAR const qrcode = require('qrcode')
99
let COOKIE_HTTPONLY, COOKIE_SAMESITE, COOKIE_SECURE, COOKIE_MAXAGE, COOKIE_DOMAIN,
1010
USE_OTP, OTP_EXPIRY, CORS_OPTIONS,
1111
AUTH_REFRESH_URL, AUTH_USER_FIELD_LOGIN, AUTH_USER_FIELD_PASSWORD, AUTH_USER_FIELD_GAKEY, AUTH_USER_FIELD_ID_FOR_JWT, AUTH_USER_FIELDS_JWT_PAYLOAD,
@@ -41,15 +41,15 @@ const httpOnlyCookie = () => `HttpOnly;SameSite=${COOKIE_SAMESITE};`
4141
+ (COOKIE_MAXAGE ? 'MaxAge='+COOKIE_MAXAGE+';':'')
4242
+ (COOKIE_DOMAIN ? 'domain='+COOKIE_DOMAIN+';':'')
4343

44-
// algorithm
44+
//NOSONAR algorithm
4545
// expiresIn
4646
// issuer = 'Mysoft corp'
4747
// subject = 'some@user.com'
4848
// audience = 'http://mysoftcorp.in'
4949
// ip
50-
5150
// We implement stateful refresh_token not stateless
5251

52+
//NOSONAR
5353
// mode: sign, verify
5454
// type: access, refresh
5555
const getSecret = (mode, type) => {
@@ -208,7 +208,8 @@ const login = async (req, res) => {
208208
const id = user[AUTH_USER_FIELD_ID_FOR_JWT]
209209
if (!id) return res.status(401).json({ message: 'Authorization Format Error' })
210210
if (USE_OTP) {
211-
// if (USE_OTP === 'SMS') {
211+
//NOSONAR
212+
// if (USE_OTP === 'SMS') {
212213
// // Generate PIN
213214
// const pin = (Math.floor(Math.random() * (999999 - 0 + 1)) + 0).toString().padStart(6, "0")
214215
// const ts = new Date() // utc?

@es-labs/node/comms/email.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ let key
55
let sender
66

77
// Sendgrid, Mailgun
8-
98
// using Twilio SendGrid's v3 Node.js Library
109
// https://github.com/sendgrid/sendgrid-nodejs
1110
// let sgMail
@@ -23,10 +22,7 @@ function setupSendGrid(options = global.CONFIG) {
2322
async function sendSendGrid(to, from, subject, text, html) {
2423
try {
2524
// const msg = {
26-
// to,
27-
// from,
28-
// subject,
29-
// text
25+
// to, from, subject, text
3026
// }
3127
// if (html) msg.html = html
3228
// await sgMail.send(msg)

0 commit comments

Comments
 (0)