@qingfu/core-env 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/database.js +0 -1
- package/lib/jwtoken.js +1 -1
- package/lib/server.js +1 -1
- package/lib/utils.js +8 -0
- package/package.json +3 -3
package/lib/database.js
CHANGED
|
@@ -10,7 +10,6 @@ if ( process.env.DATABASE_URI ) {
|
|
|
10
10
|
|
|
11
11
|
mongoose.set( 'debug', process.env.DATABASE_DEBUG !== 'false' );
|
|
12
12
|
mongoose.set( 'autoIndex', process.env.DATABASE_INDEX !== 'false' );
|
|
13
|
-
mongoose.set( 'strictQuery', false );
|
|
14
13
|
mongoose.plugin( leanVirtuals );
|
|
15
14
|
mongoose.plugin( leanDefaults );
|
|
16
15
|
mongoose.plugin( leanGetters );
|
package/lib/jwtoken.js
CHANGED
|
@@ -44,7 +44,7 @@ if ( process.env.HTTP_SECRET ) {
|
|
|
44
44
|
jwtoken.fromQuery( ctx );
|
|
45
45
|
let raw = { ip: ctx.ip, agent: ctx.get( 'User-Agent' )};
|
|
46
46
|
if ( data && !data.model ) return ctx.throw( 501 );
|
|
47
|
-
if ( data ) Object.assign( data, _.
|
|
47
|
+
if ( data ) Object.assign( data, _.pickBy( raw ));
|
|
48
48
|
if ( data ) ctx.state[ data.model.toLowerCase() ] = data;
|
|
49
49
|
if ( ctx.path === '/' || ignore || data ) return await next();
|
|
50
50
|
else return ctx.throw( 401 );
|
package/lib/server.js
CHANGED
|
@@ -8,7 +8,7 @@ if ( process.env.HTTP_PORT ) {
|
|
|
8
8
|
global.app = new Koa();
|
|
9
9
|
global.server = http.createServer( app.callback() );
|
|
10
10
|
app.use( require( '@koa/cors' )({ credentials: true, maxAge: 86400 }));
|
|
11
|
-
app.use( require( 'koa-helmet' )({ frameguard: false, contentSecurityPolicy: false }));
|
|
11
|
+
app.use( require( 'koa-helmet' )({ frameguard: false, contentSecurityPolicy: false, crossOriginResourcePolicy: false }));
|
|
12
12
|
app.use( require( 'koa-methodoverride' )() );
|
|
13
13
|
app.use( require( 'koa-logger' )() );
|
|
14
14
|
app.use( dontparse );
|
package/lib/utils.js
CHANGED
|
@@ -124,6 +124,14 @@ utils.publicDecrypt = ( string, cert, encoding = 'base64' ) => {
|
|
|
124
124
|
return crypto.publicDecrypt( cert, Buffer.from( string, encoding )).toString( 'utf8' );
|
|
125
125
|
};
|
|
126
126
|
|
|
127
|
+
utils.generateKeyPair = ( length = 2048 ) => {
|
|
128
|
+
return crypto.generateKeyPairSync( 'rsa', {
|
|
129
|
+
modulusLength: length,
|
|
130
|
+
publicKeyEncoding: { type: 'spki', format: 'pem' },
|
|
131
|
+
privateKeyEncoding: { type: 'pkcs8', format: 'pem' }
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
|
|
127
135
|
utils.generatePinyin = string => {
|
|
128
136
|
let options = { style: pinyin.STYLE_NORMAL };
|
|
129
137
|
return _.flatten( pinyin( string, options )).join( ' ' ).toUpperCase();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qingfu/core-env",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"readmeFilename": "README.md",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@koa/cors": "4.0.0",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"glob": "8.1.0",
|
|
13
13
|
"ioredis": "4.28.5",
|
|
14
14
|
"jsonwebtoken": "9.0.0",
|
|
15
|
-
"koa": "2.14.
|
|
15
|
+
"koa": "2.14.2",
|
|
16
16
|
"koa-bodyparser": "4.4.0",
|
|
17
17
|
"koa-favicon": "2.1.0",
|
|
18
18
|
"koa-helmet": "7.0.2",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"koa-qs": "3.0.0",
|
|
22
22
|
"lodash": "4.17.21",
|
|
23
23
|
"moleculer": "0.14.29",
|
|
24
|
-
"mongoose": "7.0.
|
|
24
|
+
"mongoose": "7.0.4",
|
|
25
25
|
"mongoose-cast-aggregation": "0.3.1",
|
|
26
26
|
"mongoose-geojson-schema": "2.2.4",
|
|
27
27
|
"mongoose-lean-defaults": "2.2.1",
|