Skip to content

Commit 1e94c27

Browse files
authored
0.6.11 release (#248)
* initial commit * update deps * update deps add postgres docker compose * update docs * update deps * update deps * update deps * update deps * updzte deps * update deps * update deps * update deps * update deps and docs * update markdowns * update deps * update deps * update deps * update deps * updated deps * config refactor * update deps * update deps * update deps * remove nestjs and reactjs * fix bugs * fix bugs * update deps * update libs * update deps * update deps * fix jest tests * update test fixes * update knex version * update jest * update deps * update deps * update deps * update deps * update deps * replace cypress with playwright * update readme * 0.6.11 release * 0.6.11 release update
1 parent 68bdc6e commit 1e94c27

File tree

269 files changed

+20861
-64193
lines changed

Some content is hidden

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

269 files changed

+20861
-64193
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @ais-one
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<!--
2+
ATTENTION! WE WILL HAVE TO CLOSE THIS ISSUE if you don't provide the needed information.
3+
Please read https://github.com/ais-one/cookbook/blob/master/.github/CONTRIBUTING.md before opening an issue.
4+
-->
5+
6+
## Description
7+
8+
**Environment:**
9+
<!-- Describe your environment in detail. e.g. OS, application (e.g. chrome) type and version, library versions -->
10+
11+
**Current behavior:**
12+
<!-- Describe how the bug manifests. -->
13+
14+
**Expected behavior:**
15+
<!-- Describe what the behavior would be without the bug. -->
16+
17+
**Steps to reproduce:**
18+
<!-- Please explain the steps required to duplicate the issue, especially if you are able to provide a sample application -->
19+
20+
**Related code:**
21+
<!--
22+
If you are able to illustrate the bug or feature request with an example, please provide a sample application via one of the following means:
23+
24+
A sample application via GitHub
25+
26+
StackBlitz (https://stackblitz.com)
27+
28+
Plunker (http://plnkr.co/edit/cpeRJs?p=preview)
29+
30+
Codesandbox (https://codesandbox.io/)
31+
-->
32+
33+
```
34+
insert short code snippets here
35+
```
36+
37+
## Other information
38+
39+
**npm, node, OS, Browser**
40+
```
41+
<!--
42+
Node, npm: `node --version` and `npm --version`
43+
OS: Windows (7/8/10). Linux (incl. distribution). macOS (El Capitan? Sierra?)
44+
Browser: Chrome/Safari/Firefox/etc?
45+
-->
46+
```
47+
48+
**Angular, Nebular**
49+
```
50+
<!--
51+
Check your `package-lock.json` or locate a `package.json` in the `node_modules` folder.
52+
-->
53+
```
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
name: Feature Request
3+
about: Suggest new idea
4+
labels: feature
5+
---
6+
7+
## Summary
8+
9+
Brief explanation of the feature
10+
11+
### Basic example
12+
13+
Include specs, document, code examples, screenshots, etc.
14+
15+
### Motivation
16+
17+
- Why is this needed?
18+
- What use cases does it support?
19+
- What is the expected outcome?
File renamed without changes.

@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.13",
3+
"version": "0.0.14",
44
"author": "Aaron Gong",
55
"license": "MIT",
66
"repository": {

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

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,35 @@ const jwt = require('jsonwebtoken')
66

77
//NOSONAR const uuid = require('uuid/v4')
88
//NOSONAR const qrcode = require('qrcode')
9-
let COOKIE_HTTPONLY, COOKIE_SAMESITE, COOKIE_SECURE, COOKIE_MAXAGE, COOKIE_DOMAIN,
10-
USE_OTP, OTP_EXPIRY, CORS_OPTIONS,
11-
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,
12-
JWT_ALG, JWT_SECRET, JWT_REFRESH_SECRET, JWT_EXPIRY, JWT_REFRESH_EXPIRY, JWT_CERTS, JWT_REFRESH_CERTS,
13-
JWT_REFRESH_STORE, AUTH_USER_STORE, AUTH_USER_STORE_NAME, JWT_REFRESH_STORE_NAME,
14-
setRefreshToken, getRefreshToken, revokeRefreshToken, setRefreshTokenStoreName, setTokenService, setUserService,
9+
10+
//TOREMOVE let COOKIE_HTTPONLY, COOKIE_SAMESITE, COOKIE_SECURE, COOKIE_MAXAGE, COOKIE_DOMAIN,
11+
// 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,
12+
// JWT_REFRESH_STORE, AUTH_USER_STORE, AUTH_USER_STORE_NAME, JWT_REFRESH_STORE_NAME,
13+
14+
let setRefreshToken, getRefreshToken, revokeRefreshToken, setRefreshTokenStoreName, setTokenService, setUserService,
1515
findUser, updateUser,
1616
setAuthUserStoreName
1717

18+
const {
19+
COOKIE_HTTPONLY, COOKIE_SAMESITE, COOKIE_SECURE, COOKIE_MAXAGE, COOKIE_DOMAIN,
20+
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 = '',
21+
JWT_REFRESH_STORE='keyv',
22+
AUTH_USER_STORE,
23+
AUTH_USER_STORE_NAME,
24+
JWT_REFRESH_STORE_NAME,
25+
26+
USE_OTP,
27+
JWT_ALG, JWT_EXPIRY, JWT_REFRESH_EXPIRY,
28+
JWT_PRIVATE_KEY, JWT_CERTIFICATE, JWT_REFRESH_PRIVATE_KEY, JWT_REFRESH_CERTIFICATE, JWT_SECRET, JWT_REFRESH_SECRET
29+
} = process.env
30+
1831
const userOps = {
1932
findUser: null,
2033
updateUser: null
2134
}
2235

23-
const setupAuth = (tokenService, userService, options = global.CONFIG) => {
24-
({
25-
COOKIE_HTTPONLY, COOKIE_SAMESITE, COOKIE_SECURE, COOKIE_MAXAGE, COOKIE_DOMAIN,
26-
USE_OTP, OTP_EXPIRY, CORS_OPTIONS,
27-
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 = '',
28-
JWT_ALG, JWT_SECRET, JWT_REFRESH_SECRET, JWT_EXPIRY, JWT_REFRESH_EXPIRY, JWT_CERTS, JWT_REFRESH_CERTS,
29-
30-
JWT_REFRESH_STORE ='keyv', AUTH_USER_STORE,
31-
AUTH_USER_STORE_NAME, JWT_REFRESH_STORE_NAME
32-
} = options || {});
33-
36+
const setupAuth = (tokenService, userService) => {
37+
//NOSONAR ({ } = process.env);
3438
({ setRefreshToken, getRefreshToken, revokeRefreshToken, setRefreshTokenStoreName, setTokenService } = require('./' + JWT_REFRESH_STORE)); // keyv, redis, mongo, knex
3539
({ findUser, updateUser, setAuthUserStoreName, setUserService } = require('./' + AUTH_USER_STORE)); // mongo, knex
3640
userOps.findUser = findUser
@@ -62,9 +66,9 @@ const httpOnlyCookie = () => `HttpOnly;SameSite=${COOKIE_SAMESITE};`
6266
const getSecret = (mode, type) => {
6367
if (JWT_ALG.substring(0,2) === 'RS') {
6468
if (mode === 'sign') {
65-
return type === 'refresh' ? JWT_REFRESH_CERTS.key : JWT_CERTS.key
69+
return type === 'refresh' ? JWT_REFRESH_PRIVATE_KEY : JWT_PRIVATE_KEY
6670
} else {
67-
return type === 'refresh' ? JWT_REFRESH_CERTS.cert : JWT_CERTS.cert
71+
return type === 'refresh' ? JWT_REFRESH_CERTIFICATE : JWT_CERTIFICATE
6872
}
6973
}
7074
return type === 'refresh' ? JWT_REFRESH_SECRET : JWT_SECRET
@@ -100,13 +104,12 @@ const createToken = async (user) => { // Create a tokens & data from user
100104

101105
options.expiresIn = JWT_REFRESH_EXPIRY
102106
const refresh_token = jwt.sign({ id }, getSecret('sign', 'refresh'), options) // store only ID in refresh token?
103-
104107
await setRefreshToken(id, refresh_token) // store in DB or Cache
105108
return {
106109
access_token,
107110
refresh_token,
108111
user_meta
109-
}
112+
}
110113
}
111114

112115
const setTokensToHeader = (res, {access_token, refresh_token}) => {

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

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
11
'use strict'
22

33
const axios = require('axios')
4-
let key
5-
let sender
4+
const { SENDGRID_KEY, SENDGRID_SENDER } = process.env
65

7-
function setupSendGrid(options = global.CONFIG) {
8-
const { SENDGRID_KEY, SENDGRID_SENDER } = options || {}
9-
key = SENDGRID_KEY
10-
sender = SENDGRID_SENDER
11-
}
12-
13-
async function sendSendGrid(to, from, subject, text, html) {
6+
exports.send = async (to, from, subject, text, html) => {
147
try {
15-
if (!key) return
16-
if (!from) from = sender
8+
if (!SENDGRID_KEY) return
9+
if (!from) from = SENDGRID_SENDER
1710
const body = {
1811
personalizations: [
1912
{ to: [{ email: to }] }
@@ -22,16 +15,11 @@ async function sendSendGrid(to, from, subject, text, html) {
2215
subject,
2316
content: [{"type": "text/plain", "value": text}]
2417
}
25-
await axios.post('https://api.sendgrid.com/v3/mail/send', body, { headers: { Authorization: 'Bearer ' + key } })
18+
await axios.post('https://api.sendgrid.com/v3/mail/send', body, { headers: { Authorization: 'Bearer ' + SENDGRID_KEY } })
2619
console.log('sendMail ok', to, from, subject, text)
2720
} catch (e) {
28-
console.log('sendMail err', e.toString(), key)
21+
console.log('sendMail err', e.toString(), SENDGRID_KEY)
2922
}
3023
}
3124

32-
// sendSendGrid('aaronjxz@gmail.com', 'eslabs.com@gmail.com', 'Subj', 'Test Message').then(a => console.log('ok', a)).catch(e => console.log('fail', e))
33-
34-
module.exports = {
35-
setupSendGrid,
36-
sendSendGrid
37-
}
25+
// send('aaronjxz@gmail.com', 'eslabs.com@gmail.com', 'Subj', 'Test Message').then(a => console.log('ok', a)).catch(e => console.log('fail', e))

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
'use strict'
22

33
const axios = require('axios')
4-
let key
5-
6-
exports.setup = (options = global.CONFIG) => {
7-
const { FCM_SERVER_KEY } = options || {}
8-
key = FCM_SERVER_KEY
9-
}
104

115
exports.send = async (to, title, body) => { // send firebase push notification
126
// console.log('FCM TEST @es-labs/node/fcm.js', to, body, title, key)
@@ -22,7 +16,7 @@ exports.send = async (to, title, body) => { // send firebase push notification
2216
}
2317
},{
2418
headers: {
25-
Authorization: 'key=' + key,
19+
Authorization: 'key=' + process.env.FCM_SERVER_KEY,
2620
'Content-Type': 'application/json'
2721
}
2822
})

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

Lines changed: 32 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,46 @@
11
'use strict'
22

33
const axios = require('axios')
4-
let key
5-
let api_secret
6-
let sender
74

85
//NOSONAR
96
// nexmo.isms('6596935500', 'Blah ' + new Date())
107
// nexmo.ismsSend('6596935500', 'Blah ' + new Date())
8+
const { NEXMO_KEY, NEXMO_SECRET, NEXMO_SENDER = 'SMSnotice' } = process.env
119

12-
const nexmo = {
13-
setup: function(options=global.CONFIG) {
14-
const { NEXMO_KEY, NEXMO_SECRET, NEXMO_SENDER = 'SMSnotice' } = options || {}
15-
key = NEXMO_KEY
16-
api_secret = NEXMO_SECRET
17-
sender = NEXMO_SENDER
18-
},
19-
// sms = 6511112222
20-
// one at a time...
21-
send: async function (sms, message, from) {
22-
try {
23-
if (!from) from = sender
24-
if (sms && message) {
25-
return await axios.get(`https://rest.nexmo.com/sms/json?api_key=${key}&api_secret=${api_secret}&to=${sms}&from=${from}&text=${message}`)
26-
}
27-
} catch (e) {
28-
console.log('send', e.toString())
10+
// sms = 6511112222
11+
// one at a time...
12+
exports.send = async (sms, message, from) => {
13+
try {
14+
if (!from) from = NEXMO_SENDER
15+
if (sms && message) {
16+
return await axios.get(`https://rest.nexmo.com/sms/json?api_key=${NEXMO_KEY}&api_secret=${NEXMO_SECRET}&to=${sms}&from=${from}&text=${message}`)
2917
}
30-
return null
31-
},
32-
// sms = 6511112222
33-
// one at a time...
34-
ismsSend: async function (sms, message, from) {
35-
const url = 'https://sms.era.sg/isms_mt.php?'
36-
try {
37-
if (sms && message) {
38-
const options = {
39-
params: {
40-
uid: key,
41-
pwd: require('crypto').createHash('md5').update( api_secret ).digest('hex'),
42-
dnr: sms,
43-
snr: from || sender,
44-
msg: message,
45-
split: 5
46-
}
18+
} catch (e) {
19+
console.log('send', e.toString())
20+
}
21+
return null
22+
}
23+
24+
// sms = 6511112222
25+
// one at a time...
26+
exports.ismsSend = async (sms, message, from) => {
27+
const url = 'https://sms.era.sg/isms_mt.php?'
28+
try {
29+
if (sms && message) {
30+
const options = {
31+
params: {
32+
uid: NEXMO_KEY,
33+
pwd: require('crypto').createHash('md5').update( NEXMO_SECRET ).digest('hex'),
34+
dnr: sms,
35+
snr: from || NEXMO_SENDER,
36+
msg: message,
37+
split: 5
4738
}
48-
return await axios.get(url, options)
4939
}
50-
} catch (e) {
51-
console.log('ismsSend', e.toString())
40+
return await axios.get(url, options)
5241
}
53-
return null
42+
} catch (e) {
43+
console.log('ismsSend', e.toString())
5444
}
45+
return null
5546
}
56-
57-
module.exports = nexmo

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

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
11
'use strict'
22

33
const axios = require('axios')
4-
let apiKey
5-
let channelId
6-
7-
function setup(options = global.CONFIG) {
8-
const { TELEGRAM_API_KEY, TELEGRAM_CHANNEL_ID } = options || {}
9-
// console.log('TELEGRAM_API_KEY, TELEGRAM_CHANNEL_ID', TELEGRAM_API_KEY, TELEGRAM_CHANNEL_ID)
10-
apiKey = TELEGRAM_API_KEY
11-
channelId = TELEGRAM_CHANNEL_ID
12-
}
4+
const { TELEGRAM_API_KEY, TELEGRAM_CHANNEL_ID } = process.env
135

146
async function sendChannelMsg(text) {
157
try {
16-
return await axios.get('https://api.telegram.org/bot' + apiKey + '/sendMessage?chat_id=' + channelId + '&text=' + text) //NOSONAR { id, date, pts, seq }
8+
return await axios.get('https://api.telegram.org/bot' + TELEGRAM_API_KEY + '/sendMessage?chat_id=' + TELEGRAM_CHANNEL_ID + '&text=' + text) //NOSONAR { id, date, pts, seq }
179
} catch (e) {
1810
return { err: e.toString() }
1911
}
@@ -22,7 +14,7 @@ async function sendChannelMsg(text) {
2214
async function sendChatMsg(chatId, text) {
2315
try {
2416
// console.log('chatId, text', chatId, text)
25-
return await axios.get('https://api.telegram.org/bot' + apiKey + '/sendMessage?chat_id=' + chatId + '&text=' + text) //NOSONAR { id, date, pts, seq }
17+
return await axios.get('https://api.telegram.org/bot' + TELEGRAM_API_KEY + '/sendMessage?chat_id=' + chatId + '&text=' + text) //NOSONAR { id, date, pts, seq }
2618
} catch (e) {
2719
return { err: e.toString() }
2820
}

0 commit comments

Comments
 (0)