diff --git a/packages/constants/README.md b/packages/constants/README.md index a2578ff6c38801da03d4491ef2e3c58de32980f9..f0b3c51a063aed8b458e8b371b28431d62e07250 100755 --- a/packages/constants/README.md +++ b/packages/constants/README.md @@ -105,6 +105,9 @@ non-javascript to develop your tool. You can also use the included `constants.js - JS_WS_NAME - JS_PRIMUS_NAME - GO_WS_COOLPY7_NAME +- SOCKET_TYPE_CLIENT_ALIAS +- SOCKET_TYPE_SERVER_ALIAS +- SOCKET_TYPE_KEY - ON_MESSAGE_PROP_NAME - ON_RESULT_PROP_NAME - ON_ERROR_PROP_NAME @@ -121,6 +124,7 @@ non-javascript to develop your tool. You can also use the included `constants.js - INIT_CLIENT_PROP_KEY - INIT_CONTRACT_PROP_KEY - DEFAULT_WS_WAIT_TIME +- DEFAULT_RETRY_TIME - TIMEOUT_ERR_MSG - NOT_LOGIN_ERR_MSG - BASE64_FORMAT diff --git a/packages/constants/constants.json b/packages/constants/constants.json index fb4686055a56c1fab01d1386352b2b70a1ddae83..7da428cbafae7b07fae3099dc9eaa9ee16c92780 100644 --- a/packages/constants/constants.json +++ b/packages/constants/constants.json @@ -10,7 +10,7 @@ "CHARSET": "charset=utf-8", "DEFAULT_HEADER": { "Accept": "application/vnd.api+json", - "Content-Type": "application/vnd.api+json;charset=utf-8" + "Content-Type": "application/vnd.api+jsoncharset=utf-8" }, "DEFAULT_TYPE": "any", "DEFAULT_CONTRACT_FILE_NAME": "contract.json", @@ -136,6 +136,9 @@ "JS_WS_NAME": "ws", "JS_PRIMUS_NAME": "primus", "GO_WS_COOLPY7_NAME": "coolpy7", + "SOCKET_TYPE_CLIENT_ALIAS": "socketClientType", + "SOCKET_TYPE_SERVER_ALIAS": "socketServerType", + "SOCKET_TYPE_KEY": "serverType", "ON_MESSAGE_PROP_NAME": "onMessage", "ON_RESULT_PROP_NAME": "onResult", "ON_ERROR_PROP_NAME": "onError", @@ -152,6 +155,7 @@ "INIT_CLIENT_PROP_KEY": "nodeClient", "INIT_CONTRACT_PROP_KEY": "initContract", "DEFAULT_WS_WAIT_TIME": 5000, + "DEFAULT_RETRY_TIME": 3000, "TIMEOUT_ERR_MSG": "timeout", "NOT_LOGIN_ERR_MSG": "NOT LOGIN", "BASE64_FORMAT": "base64", diff --git a/packages/constants/main.js b/packages/constants/main.js index 0e7efafeb0d20bd4eaf503c5ffc52a82f72f9b20..02d05847b777432681013bdb4c154fd1616a4793 100644 --- a/packages/constants/main.js +++ b/packages/constants/main.js @@ -10,7 +10,7 @@ module.exports = { "CHARSET": "charset=utf-8", "DEFAULT_HEADER": { "Accept": "application/vnd.api+json", - "Content-Type": "application/vnd.api+json;charset=utf-8" + "Content-Type": "application/vnd.api+jsoncharset=utf-8" }, "DEFAULT_TYPE": "any", "DEFAULT_CONTRACT_FILE_NAME": "contract.json", @@ -136,6 +136,9 @@ module.exports = { "JS_WS_NAME": "ws", "JS_PRIMUS_NAME": "primus", "GO_WS_COOLPY7_NAME": "coolpy7", + "SOCKET_TYPE_CLIENT_ALIAS": "socketClientType", + "SOCKET_TYPE_SERVER_ALIAS": "socketServerType", + "SOCKET_TYPE_KEY": "serverType", "ON_MESSAGE_PROP_NAME": "onMessage", "ON_RESULT_PROP_NAME": "onResult", "ON_ERROR_PROP_NAME": "onError", @@ -152,6 +155,7 @@ module.exports = { "INIT_CLIENT_PROP_KEY": "nodeClient", "INIT_CONTRACT_PROP_KEY": "initContract", "DEFAULT_WS_WAIT_TIME": 5000, + "DEFAULT_RETRY_TIME": 3000, "TIMEOUT_ERR_MSG": "timeout", "NOT_LOGIN_ERR_MSG": "NOT LOGIN", "BASE64_FORMAT": "base64", diff --git a/packages/constants/module.js b/packages/constants/module.js index effcb377c2b91f1939181217c2cd76cb6b2752f9..5c2c4af75c0782a7090af32dab8b7f8372af86f2 100644 --- a/packages/constants/module.js +++ b/packages/constants/module.js @@ -1,201 +1,205 @@ -export const EXT = 'js'; // we might do a ts in the future -export const TS_EXT = 'ts'; +export const EXT = 'js' // we might do a ts in the future +export const TS_EXT = 'ts' -export const HELLO = 'Hello world!'; -export const HELLO_FN = 'helloWorld'; +export const HELLO = 'Hello world!' +export const HELLO_FN = 'helloWorld' // the core stuff to id if it's calling with jsonql -export const DATA_KEY = 'data'; -export const ERROR_KEY = 'error'; +export const DATA_KEY = 'data' +export const ERROR_KEY = 'error' -export const JSONQL_PATH = 'jsonql'; +export const JSONQL_PATH = 'jsonql' // according to the json query spec -export const CONTENT_TYPE = 'application/vnd.api+json'; -export const CHARSET = 'charset=utf-8'; +export const CONTENT_TYPE = 'application/vnd.api+json' +export const CHARSET = 'charset=utf-8' export const DEFAULT_HEADER = { 'Accept': CONTENT_TYPE, - 'Content-Type': [ CONTENT_TYPE, CHARSET ].join(';') + 'Content-Type': [ CONTENT_TYPE, CHARSET ].join('') } -// export const INDEX = 'index'; use INDEX_KEY instead -export const DEFAULT_TYPE = 'any'; +// export const INDEX = 'index' use INDEX_KEY instead +export const DEFAULT_TYPE = 'any' // contract file names -// export const DEFAULT_FILE_NAME = 'contract.json'; // @TODO remove once all changed -// export const PUBLIC_FILE_NAME = 'public-contract.json'; // @TODO remove once all changed -export const DEFAULT_CONTRACT_FILE_NAME = 'contract.json'; -export const PUBLIC_CONTRACT_FILE_NAME = 'public-contract.json'; +// export const DEFAULT_FILE_NAME = 'contract.json' // @TODO remove once all changed +// export const PUBLIC_FILE_NAME = 'public-contract.json' // @TODO remove once all changed +export const DEFAULT_CONTRACT_FILE_NAME = 'contract.json' +export const PUBLIC_CONTRACT_FILE_NAME = 'public-contract.json' // this is for the ES6 module import and export -export const DEFAULT_RESOLVER_LIST_FILE_NAME = 'resolver.js'; -export const DEFAULT_RESOLVER_IMPORT_FILE_NAME = 'import.js'; -export const MODULE_TYPE = 'module'; -export const SCRIPT_TYPE = 'script'; +export const DEFAULT_RESOLVER_LIST_FILE_NAME = 'resolver.js' +export const DEFAULT_RESOLVER_IMPORT_FILE_NAME = 'import.js' +export const MODULE_TYPE = 'module' +export const SCRIPT_TYPE = 'script' // @TODO remove this is not in use -// export const CLIENT_CONFIG_FILE = '.clients.json'; -// export const CONTRACT_CONFIG_FILE = 'jsonql-contract-config.js'; +// export const CLIENT_CONFIG_FILE = '.clients.json' +// export const CONTRACT_CONFIG_FILE = 'jsonql-contract-config.js' // type of resolvers -export const QUERY_NAME = 'query'; -export const MUTATION_NAME = 'mutation'; -export const SOCKET_NAME = 'socket'; -export const CONTRACT_NAME = 'contract'; -export const RESOLVER_TYPES = [QUERY_NAME, MUTATION_NAME, SOCKET_NAME]; +export const QUERY_NAME = 'query' +export const MUTATION_NAME = 'mutation' +export const SOCKET_NAME = 'socket' +export const CONTRACT_NAME = 'contract' +export const RESOLVER_TYPES = [QUERY_NAME, MUTATION_NAME, SOCKET_NAME] // for calling the mutation -export const PAYLOAD_PARAM_NAME = 'payload'; // @TODO shortern them -export const CONDITION_PARAM_NAME = 'condition'; -export const RESOLVER_PARAM_NAME = 'resolverName'; -export const QUERY_ARG_NAME = 'args'; -export const TIMESTAMP_PARAM_NAME = 'TS'; -export const MUTATION_ARGS = [RESOLVER_PARAM_NAME, PAYLOAD_PARAM_NAME, CONDITION_PARAM_NAME]; +export const PAYLOAD_PARAM_NAME = 'payload' // @TODO shortern them +export const CONDITION_PARAM_NAME = 'condition' +export const RESOLVER_PARAM_NAME = 'resolverName' +export const QUERY_ARG_NAME = 'args' +export const TIMESTAMP_PARAM_NAME = 'TS' +export const MUTATION_ARGS = [RESOLVER_PARAM_NAME, PAYLOAD_PARAM_NAME, CONDITION_PARAM_NAME] // new jsonp -export const JSONP_CALLBACK_NAME = 'jsonqlJsonpCallback'; +export const JSONP_CALLBACK_NAME = 'jsonqlJsonpCallback' // methods allow -export const API_REQUEST_METHODS = ['POST', 'PUT']; -export const CONTRACT_REQUEST_METHODS = ['GET', 'HEAD']; +export const API_REQUEST_METHODS = ['POST', 'PUT'] +export const CONTRACT_REQUEST_METHODS = ['GET', 'HEAD'] // for contract-cli -export const KEY_WORD = 'continue'; -export const PUBLIC_KEY = 'public'; -export const PRIVATE_KEY = 'private'; - -export const TYPE_KEY = 'type'; -export const OPTIONAL_KEY = 'optional'; -export const ENUM_KEY = 'enumv'; // need to change this because enum is a reserved word -export const ARGS_KEY = 'args'; -export const CHECKER_KEY = 'checker'; -export const ALIAS_KEY = 'alias'; -export const CHECKED_KEY = '__checked__'; +export const KEY_WORD = 'continue' +export const PUBLIC_KEY = 'public' +export const PRIVATE_KEY = 'private' + +export const TYPE_KEY = 'type' +export const OPTIONAL_KEY = 'optional' +export const ENUM_KEY = 'enumv' // need to change this because enum is a reserved word +export const ARGS_KEY = 'args' +export const CHECKER_KEY = 'checker' +export const ALIAS_KEY = 'alias' +export const CHECKED_KEY = '__checked__' // author -export const AUTH_TYPE = 'auth'; -export const LOGIN_NAME = 'login'; -export const ISSUER_NAME = LOGIN_NAME; // legacy issue need to replace them later -export const LOGOUT_NAME = 'logout'; -export const VALIDATOR_NAME = 'validator'; +export const AUTH_TYPE = 'auth' +export const LOGIN_NAME = 'login' +export const ISSUER_NAME = LOGIN_NAME // legacy issue need to replace them later +export const LOGOUT_NAME = 'logout' +export const VALIDATOR_NAME = 'validator' -export const AUTH_HEADER = 'Authorization'; -export const AUTH_CHECK_HEADER = 'authorization'; // this is for checking so it must be lowercase -export const BEARER = 'Bearer'; +export const AUTH_HEADER = 'Authorization' +export const AUTH_CHECK_HEADER = 'authorization' // this is for checking so it must be lowercase +export const BEARER = 'Bearer' // for client use @TODO need to clean this up some of them are not in use -export const CREDENTIAL_STORAGE_KEY = 'jsonqlcredential'; -export const CLIENT_STORAGE_KEY = 'jsonqlstore'; -export const CLIENT_AUTH_KEY = 'jsonqlauthkey'; +export const CREDENTIAL_STORAGE_KEY = 'jsonqlcredential' +export const CLIENT_STORAGE_KEY = 'jsonqlstore' +export const CLIENT_AUTH_KEY = 'jsonqlauthkey' // for id the multiple storage engine -export const INDEX_KEY = 'index'; +export const INDEX_KEY = 'index' // contract key -export const CONTRACT_KEY_NAME = 'X-JSONQL-CV-KEY'; -export const SHOW_CONTRACT_DESC_PARAM = {desc: 'y'}; +export const CONTRACT_KEY_NAME = 'X-JSONQL-CV-KEY' +export const SHOW_CONTRACT_DESC_PARAM = {desc: 'y'} // directories -export const DEFAULT_RESOLVER_DIR = 'resolvers'; -export const DEFAULT_CONTRACT_DIR = 'contracts'; -export const DEFAULT_KEYS_DIR = 'keys'; +export const DEFAULT_RESOLVER_DIR = 'resolvers' +export const DEFAULT_CONTRACT_DIR = 'contracts' +export const DEFAULT_KEYS_DIR = 'keys' // add in V1.3.4 start supporting socket // for validation -export const CJS_TYPE = 'cjs'; -export const ES_TYPE = 'es'; -export const TS_TYPE = 'ts'; -export const ACCEPTED_JS_TYPES = [CJS_TYPE, ES_TYPE]; // not accept this TS_TYPE at the moment +export const CJS_TYPE = 'cjs' +export const ES_TYPE = 'es' +export const TS_TYPE = 'ts' +export const ACCEPTED_JS_TYPES = [CJS_TYPE, ES_TYPE] // not accept this TS_TYPE at the moment -export const OR_SEPERATOR = '|'; +export const OR_SEPERATOR = '|' -export const STRING_TYPE = 'string'; -export const BOOLEAN_TYPE = 'boolean'; -export const ARRAY_TYPE = 'array'; -export const OBJECT_TYPE = 'object'; -export const ANY_TYPE = 'any'; +export const STRING_TYPE = 'string' +export const BOOLEAN_TYPE = 'boolean' +export const ARRAY_TYPE = 'array' +export const OBJECT_TYPE = 'object' +export const ANY_TYPE = 'any' -export const NUMBER_TYPE = 'number'; -export const NUMBER_TYPES = ['int', 'integer', 'float', 'double', 'decimal']; +export const NUMBER_TYPE = 'number' +export const NUMBER_TYPES = ['int', 'integer', 'float', 'double', 'decimal'] // supported types -export const SUPPORTED_TYPES = [NUMBER_TYPE, STRING_TYPE, BOOLEAN_TYPE, ARRAY_TYPE, OBJECT_TYPE, ANY_TYPE]; +export const SUPPORTED_TYPES = [NUMBER_TYPE, STRING_TYPE, BOOLEAN_TYPE, ARRAY_TYPE, OBJECT_TYPE, ANY_TYPE] -export const ARRAY_TS_TYPE_LFT = 'Array<'; -export const ARRAY_TYPE_LFT = 'array.<'; -export const ARRAY_TYPE_RGT = '>'; +export const ARRAY_TS_TYPE_LFT = 'Array<' +export const ARRAY_TYPE_LFT = 'array.<' +export const ARRAY_TYPE_RGT = '>' // for contract cli -export const RETURN_AS_FILE = 'file'; -export const RETURN_AS_JSON = 'json'; -export const RETURN_AS_ENUM = [RETURN_AS_FILE, RETURN_AS_JSON]; +export const RETURN_AS_FILE = 'file' +export const RETURN_AS_JSON = 'json' +export const RETURN_AS_ENUM = [RETURN_AS_FILE, RETURN_AS_JSON] -export const NO_ERROR_MSG = 'No message'; -export const NO_STATUS_CODE = -1; +export const NO_ERROR_MSG = 'No message' +export const NO_STATUS_CODE = -1 // use throughout the clients -export const SWITCH_USER_EVENT_NAME = '__switch__'; -export const LOGIN_EVENT_NAME = '__login__'; -export const LOGOUT_EVENT_NAME = '__logout__'; +export const SWITCH_USER_EVENT_NAME = '__switch__' +export const LOGIN_EVENT_NAME = '__login__' +export const LOGOUT_EVENT_NAME = '__logout__' // for ws servers -export const WS_REPLY_TYPE = '__reply__'; -export const WS_EVT_NAME = '__event__'; -export const WS_DATA_NAME = '__data__'; -export const WS_IS_REPLY_KEYS = [WS_REPLY_TYPE, WS_EVT_NAME, WS_DATA_NAME]; -export const EMIT_REPLY_TYPE = 'emit'; -export const ACKNOWLEDGE_REPLY_TYPE = 'acknowledge'; -export const ERROR_TYPE = 'error'; +export const WS_REPLY_TYPE = '__reply__' +export const WS_EVT_NAME = '__event__' +export const WS_DATA_NAME = '__data__' +export const WS_IS_REPLY_KEYS = [WS_REPLY_TYPE, WS_EVT_NAME, WS_DATA_NAME] +export const EMIT_REPLY_TYPE = 'emit' +export const ACKNOWLEDGE_REPLY_TYPE = 'acknowledge' +export const ERROR_TYPE = 'error' export const NSP_SET = 'nspSet' export const PUBLIC_NAMESPACE = 'publicNamespace' -export const JS_WS_SOCKET_IO_NAME = 'socket.io'; -export const JS_WS_NAME = 'ws'; +export const JS_WS_SOCKET_IO_NAME = 'socket.io' +export const JS_WS_NAME = 'ws' export const JS_PRIMUS_NAME = 'primus' -export const GO_WS_COOLPY7_NAME = 'coolpy7'; +export const GO_WS_COOLPY7_NAME = 'coolpy7' +export const SOCKET_TYPE_CLIENT_ALIAS = 'socketClientType' // 1.9.0 +export const SOCKET_TYPE_SERVER_ALIAS = 'socketServerType' // 1.9.1 +export const SOCKET_TYPE_KEY = 'serverType' //1.9.1 // for ws client -export const ON_MESSAGE_PROP_NAME = 'onMessage'; -export const ON_RESULT_PROP_NAME = 'onResult'; -export const ON_ERROR_PROP_NAME = 'onError'; -export const ON_READY_PROP_NAME = 'onReady'; -export const ON_LOGIN_PROP_NAME = 'onLogin'; // new @1.8.6 +export const ON_MESSAGE_PROP_NAME = 'onMessage' +export const ON_RESULT_PROP_NAME = 'onResult' +export const ON_ERROR_PROP_NAME = 'onError' +export const ON_READY_PROP_NAME = 'onReady' +export const ON_LOGIN_PROP_NAME = 'onLogin' // new @1.8.6 -export const SEND_MSG_PROP_NAME = 'send'; +export const SEND_MSG_PROP_NAME = 'send' // breaking change from 1.8.8 the above name was the name below // the names are using in the new resolver.on getter interface -export const MESSAGE_PROP_NAME = 'message'; -export const RESULT_PROP_NAME = 'result'; -export const ERROR_PROP_NAME = 'error'; -export const READY_PROP_NAME = 'ready'; -export const LOGIN_PROP_NAME = 'login'; // new @1.8.6 +export const MESSAGE_PROP_NAME = 'message' +export const RESULT_PROP_NAME = 'result' +export const ERROR_PROP_NAME = 'error' +export const READY_PROP_NAME = 'ready' +export const LOGIN_PROP_NAME = 'login' // new @1.8.6 // this one is for nodeClient inject into the resolver -export const CLIENT_PROP_NAME = 'client'; -export const USERDATA_PROP_NAME = 'userdata'; +export const CLIENT_PROP_NAME = 'client' +export const USERDATA_PROP_NAME = 'userdata' // this are property keys used in the configuration options // and re-use elsewhere -export const INIT_CLIENT_PROP_KEY = 'nodeClient'; -export const INIT_CONTRACT_PROP_KEY = 'initContract'; +export const INIT_CLIENT_PROP_KEY = 'nodeClient' +export const INIT_CONTRACT_PROP_KEY = 'initContract' // this is the default time to wait for reply if exceed this then we // trigger an error --> 5 seconds -export const DEFAULT_WS_WAIT_TIME = 5000; -export const TIMEOUT_ERR_MSG = 'timeout'; -export const NOT_LOGIN_ERR_MSG = 'NOT LOGIN'; +export const DEFAULT_WS_WAIT_TIME = 5000 +export const DEFAULT_RETRY_TIME = 3000 // 1.9.0 +export const TIMEOUT_ERR_MSG = 'timeout' +export const NOT_LOGIN_ERR_MSG = 'NOT LOGIN' // for crypto operation -export const BASE64_FORMAT = 'base64'; -export const HEX_FORMAT = 'hex'; -export const UTF8_FORMAT = 'utf8'; -export const RSA_FORMATS = [BASE64_FORMAT, HEX_FORMAT]; -export const RSA_ALGO = 'RS256'; -export const HSA_ALGO = 'HS256'; -export const JWT_SUPPORT_ALGOS = [RSA_ALGO, HSA_ALGO]; -export const RSA_PRIVATE_KEY_HEADER = 'BEGIN RSA PRIVATE KEY'; -export const RSA_MIN_MODULE_LEN = 1024; -export const RSA_MAX_MODULE_LEN = 4096; -export const TOKEN_PARAM_NAME = 'token'; -export const IO_ROUNDTRIP_LOGIN = 'roundtip'; -export const IO_HANDSHAKE_LOGIN = 'handshake'; -export const IO_LOGIN_METHODS = [IO_ROUNDTRIP_LOGIN, IO_HANDSHAKE_LOGIN]; - -export const PEM_EXT = 'pem'; -export const PUBLIC_KEY_NAME = 'publicKey'; -export const PRIVATE_KEY_NAME = 'privateKey'; +export const BASE64_FORMAT = 'base64' +export const HEX_FORMAT = 'hex' +export const UTF8_FORMAT = 'utf8' +export const RSA_FORMATS = [BASE64_FORMAT, HEX_FORMAT] +export const RSA_ALGO = 'RS256' +export const HSA_ALGO = 'HS256' +export const JWT_SUPPORT_ALGOS = [RSA_ALGO, HSA_ALGO] +export const RSA_PRIVATE_KEY_HEADER = 'BEGIN RSA PRIVATE KEY' +export const RSA_MIN_MODULE_LEN = 1024 +export const RSA_MAX_MODULE_LEN = 4096 +export const TOKEN_PARAM_NAME = 'token' +export const IO_ROUNDTRIP_LOGIN = 'roundtip' +export const IO_HANDSHAKE_LOGIN = 'handshake' +export const IO_LOGIN_METHODS = [IO_ROUNDTRIP_LOGIN, IO_HANDSHAKE_LOGIN] + +export const PEM_EXT = 'pem' +export const PUBLIC_KEY_NAME = 'publicKey' +export const PRIVATE_KEY_NAME = 'privateKey' export const DEFAULT_PUBLIC_KEY_FILE = [PUBLIC_KEY_NAME, PEM_EXT].join('.') export const DEFAULT_PRIVATE_KEY_FILE = [PRIVATE_KEY_NAME, PEM_EXT].join('.') // status -export const SUCCESS_STATUS = 200; -export const UNAUTHORIZED_STATUS = 401; -export const FORBIDDEN_STATUS = 403; -export const NOT_FOUND_STATUS = 404; +export const SUCCESS_STATUS = 200 +export const UNAUTHORIZED_STATUS = 401 +export const FORBIDDEN_STATUS = 403 +export const NOT_FOUND_STATUS = 404 // just whatever -export const DEFAULT_PORT_NUM = 6557; +export const DEFAULT_PORT_NUM = 6557 diff --git a/packages/constants/package.json b/packages/constants/package.json index de694a2c5b29d08ef7f3c6e21821d8132603de0c..157e9e0631606b4ac06a25caa560ac347ad05830 100755 --- a/packages/constants/package.json +++ b/packages/constants/package.json @@ -1,6 +1,6 @@ { "name": "jsonql-constants", - "version": "1.8.14", + "version": "1.9.1", "description": "All the share constants for json:ql tools", "main": "main.js", "module": "module.js", diff --git a/packages/jwt/cmd.js b/packages/jwt/cmd.js index 785d2885dbac7c990a7b6a8949c2a91976696181..d98185027f648dc3b105357a2b20ed0f3b725829 100644 --- a/packages/jwt/cmd.js +++ b/packages/jwt/cmd.js @@ -3,8 +3,8 @@ // https://stackoverflow.com/questions/8520973/how-to-create-a-pair-private-public-keys-using-node-js-crypto const { argv } = require('yargs') const colors = require('colors/safe') -const fsx = require('fs-extra') -const debug = require('debug')('jsonql-jwt:cmd') +// const fsx = require('fs-extra') +// const debug = require('debug')('jsonql-jwt:cmd') const { version } = require('./package.json') const { rsaKeys, jwtToken, rsaPemKeys } = require('./main') diff --git a/packages/jwt/dist/jsonql-jwt.js b/packages/jwt/dist/jsonql-jwt.js index 7fb4f7ed2c5c36ed1bd2bfcf77d86effa1603a7a..48e79596e598048310bf589d70e8a9cbcbb4e120 100644 --- a/packages/jwt/dist/jsonql-jwt.js +++ b/packages/jwt/dist/jsonql-jwt.js @@ -1,2 +1,2 @@ -!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((t=t||self).jsonqlJwt={})}(this,(function(t){"use strict";var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function e(t){this.message=t}e.prototype=new Error,e.prototype.name="InvalidCharacterError";var n="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var n=String(t).replace(/=+$/,"");if(n.length%4==1)throw new e("'atob' failed: The string to be decoded is not correctly encoded.");for(var o,u,a=0,i=0,c="";u=n.charAt(i++);~u&&(o=a%4?64*o+u:u,a++%4)?c+=String.fromCharCode(255&o>>(-2*a&6)):0)u=r.indexOf(u);return c};var o=function(t){var r=t.replace(/-/g,"+").replace(/_/g,"/");switch(r.length%4){case 0:break;case 2:r+="==";break;case 3:r+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(n(t).replace(/(.)/g,(function(t,r){var e=r.charCodeAt(0).toString(16).toUpperCase();return e.length<2&&(e="0"+e),"%"+e})))}(r)}catch(t){return n(r)}};function u(t){this.message=t}u.prototype=new Error,u.prototype.name="InvalidTokenError";var a=function(t,r){if("string"!=typeof t)throw new u("Invalid token specified");var e=!0===(r=r||{}).header?0:1;try{return JSON.parse(o(t.split(".")[e]))}catch(t){throw new u("Invalid token specified: "+t.message)}},i=u;a.InvalidTokenError=i;var c="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},f="object"==typeof c&&c&&c.Object===Object&&c,l="object"==typeof self&&self&&self.Object===Object&&self,s=f||l||Function("return this")(),p=s.Symbol;function v(t,r){for(var e=-1,n=null==t?0:t.length,o=Array(n);++e=n?t:function(t,r,e){var n=-1,o=t.length;r<0&&(r=-r>o?0:o+r),(e=e>o?o:e)<0&&(e+=o),o=r>e?0:e-r>>>0,r>>>=0;for(var u=Array(o);++n-1;);return e}(n,o),function(t,r){for(var e=t.length;e--&&I(r,t[e],0)>-1;);return e}(n,o)+1).join("")}var Y="[object String]";function K(t){return"string"==typeof t||!h(t)&&A(t)&&O(t)==Y}var Q=function(t){return""!==H(t)&&K(t)},X="type",Z="optional",tt="enumv",rt="args",et="checker",nt="alias",ot=function(t){function r(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];t.apply(this,e),this.message=e[0],this.detail=e[1],this.className=r.name,t.captureStackTrace&&t.captureStackTrace(this,r)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var e={name:{configurable:!0},statusCode:{configurable:!0}};return e.name.get=function(){return"JsonqlError"},e.statusCode.get=function(){return-1},Object.defineProperties(r,e),r}(Error),ut=function(t){void 0===t&&(t=!1);var r=Date.now();return t?Math.floor(r/1e3):r};var at=function(t){return!!h(t)||null!=t&&""!==H(t)},it="[object Number]";function ct(t){return function(t){return"number"==typeof t||A(t)&&O(t)==it}(t)&&t!=+t}var ft=function(t){return!K(t)&&!ct(parseFloat(t))},lt=function(t){return null!=t&&"boolean"==typeof t},st=function(t,r){return void 0===r&&(r=!0),void 0!==t&&""!==t&&""!==H(t)&&(!1===r||!0===r&&null!==t)},pt=X,vt=Z,ht=tt,dt=rt,yt=et,bt=nt,gt="continue",_t=function(t){switch(t){case"number":return ft;case"string":return Q;case"boolean":return lt;default:return st}},jt=function(t,r){return void 0===r&&(r=""),!!h(t)&&(""===r||""===H(r)||!(t.filter((function(t){return!_t(r)(t)})).length>0))},mt=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var r=t.replace("array.<","").replace(">","");return r.indexOf("|")?r.split("|"):[r]}return!1},wt=function(t,r){var e=t.arg;return r.length>1?!e.filter((function(t){return!(r.length>r.filter((function(r){return!_t(r)(t)})).length)})).length:r.length>r.filter((function(t){return!jt(e,t)})).length};function Ot(t,r){return function(e){return t(r(e))}}var At=Ot(Object.getPrototypeOf,Object),kt="[object Object]",St=Function.prototype,Et=Object.prototype,xt=St.toString,Pt=Et.hasOwnProperty,Tt=xt.call(Object);function zt(t){if(!A(t)||O(t)!=kt)return!1;var r=At(t);if(null===r)return!0;var e=Pt.call(r,"constructor")&&r.constructor;return"function"==typeof e&&e instanceof e&&xt.call(e)==Tt}var Ct,It=function(t,r,e){for(var n=-1,o=Object(t),u=e(t),a=u.length;a--;){var i=u[Ct?a:++n];if(!1===r(o[i],i,o))break}return t};var Mt="[object Arguments]";function Dt(t){return A(t)&&O(t)==Mt}var Ft=Object.prototype,$t=Ft.hasOwnProperty,Bt=Ft.propertyIsEnumerable,Nt=Dt(function(){return arguments}())?Dt:function(t){return A(t)&&$t.call(t,"callee")&&!Bt.call(t,"callee")};var Rt="object"==typeof t&&t&&!t.nodeType&&t,Ut=Rt&&"object"==typeof module&&module&&!module.nodeType&&module,Vt=Ut&&Ut.exports===Rt?s.Buffer:void 0,qt=(Vt?Vt.isBuffer:void 0)||function(){return!1},Jt=9007199254740991,Lt=/^(?:0|[1-9]\d*)$/;function Wt(t,r){var e=typeof t;return!!(r=null==r?Jt:r)&&("number"==e||"symbol"!=e&&Lt.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=Gt}var Yt={};Yt["[object Float32Array]"]=Yt["[object Float64Array]"]=Yt["[object Int8Array]"]=Yt["[object Int16Array]"]=Yt["[object Int32Array]"]=Yt["[object Uint8Array]"]=Yt["[object Uint8ClampedArray]"]=Yt["[object Uint16Array]"]=Yt["[object Uint32Array]"]=!0,Yt["[object Arguments]"]=Yt["[object Array]"]=Yt["[object ArrayBuffer]"]=Yt["[object Boolean]"]=Yt["[object DataView]"]=Yt["[object Date]"]=Yt["[object Error]"]=Yt["[object Function]"]=Yt["[object Map]"]=Yt["[object Number]"]=Yt["[object Object]"]=Yt["[object RegExp]"]=Yt["[object Set]"]=Yt["[object String]"]=Yt["[object WeakMap]"]=!1;var Kt,Qt="object"==typeof t&&t&&!t.nodeType&&t,Xt=Qt&&"object"==typeof module&&module&&!module.nodeType&&module,Zt=Xt&&Xt.exports===Qt&&f.process,tr=function(){try{var t=Xt&&Xt.require&&Xt.require("util").types;return t||Zt&&Zt.binding&&Zt.binding("util")}catch(t){}}(),rr=tr&&tr.isTypedArray,er=rr?(Kt=rr,function(t){return Kt(t)}):function(t){return A(t)&&Ht(t.length)&&!!Yt[O(t)]},nr=Object.prototype.hasOwnProperty;function or(t,r){var e=h(t),n=!e&&Nt(t),o=!e&&!n&&qt(t),u=!e&&!n&&!o&&er(t),a=e||n||o||u,i=a?function(t,r){for(var e=-1,n=Array(t);++e-1},mr.prototype.set=function(t,r){var e=this.__data__,n=_r(e,t);return n<0?(++this.size,e.push([t,r])):e[n][1]=r,this};var wr,Or=s["__core-js_shared__"],Ar=(wr=/[^.]+$/.exec(Or&&Or.keys&&Or.keys.IE_PROTO||""))?"Symbol(src)_1."+wr:"";var kr=Function.prototype.toString;function Sr(t){if(null!=t){try{return kr.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var Er=/^\[object .+?Constructor\]$/,xr=Function.prototype,Pr=Object.prototype,Tr=xr.toString,zr=Pr.hasOwnProperty,Cr=RegExp("^"+Tr.call(zr).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Ir(t){return!(!fr(t)||function(t){return!!Ar&&Ar in t}(t))&&(hr(t)?Cr:Er).test(Sr(t))}function Mr(t,r){var e=function(t,r){return null==t?void 0:t[r]}(t,r);return Ir(e)?e:void 0}var Dr=Mr(s,"Map"),Fr=Mr(Object,"create");var $r="__lodash_hash_undefined__",Br=Object.prototype.hasOwnProperty;var Nr=Object.prototype.hasOwnProperty;var Rr="__lodash_hash_undefined__";function Ur(t){var r=-1,e=null==t?0:t.length;for(this.clear();++ri))return!1;var f=u.get(t);if(f&&u.get(r))return f==r;var l=-1,s=!0,p=e&Kr?new Gr:void 0;for(u.set(t,r),u.set(r,t);++lr.type.filter((function(t){var r;return void 0===e||(!1!==(r=mt(t))?!wt({arg:e},r):!_t(t)(e))})).length)})).length}return!1},bn=function(t){function r(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];t.apply(this,e),this.message=e[0],this.detail=e[1],this.className=r.name,t.captureStackTrace&&t.captureStackTrace(this,r)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var e={name:{configurable:!0}};return e.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(r,e),r}(Error),gn=function(t){function r(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];t.apply(this,e),this.message=e[0],this.detail=e[1],this.className=r.name,t.captureStackTrace&&t.captureStackTrace(this,r)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var e={name:{configurable:!0}};return e.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(r,e),r}(Error),_n=function(t){function r(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];t.apply(this,e),this.message=e[0],this.detail=e[1],this.className=r.name,t.captureStackTrace&&t.captureStackTrace(this,r)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var e={name:{configurable:!0}};return e.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(r,e),r}(Error),jn=function(t,r){var e,n,o,u,a;switch(!0){case"object"===t:return o=(n=r).arg,u=n.param,a=[o],Array.isArray(u.keys)&&u.keys.length&&a.push(u.keys),!Reflect.apply(yn,null,a);case"array"===t:return!jt(r.arg);case!1!==(e=mt(t)):return!wt(r,e);default:return!_t(t)(r.arg)}},mn=function(t,r){return void 0!==t?t:!0===r.optional&&void 0!==r.defaultvalue?r.defaultvalue:null},wn=function(){try{var t=Mr(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function On(t,r,e){"__proto__"==r&&wn?wn(t,r,{configurable:!0,enumerable:!0,value:e,writable:!0}):t[r]=e}function An(t,r,e){(void 0===e||gr(t[r],e))&&(void 0!==e||r in t)||On(t,r,e)}var kn="object"==typeof t&&t&&!t.nodeType&&t,Sn=kn&&"object"==typeof module&&module&&!module.nodeType&&module,En=Sn&&Sn.exports===kn?s.Buffer:void 0,xn=En?En.allocUnsafe:void 0;function Pn(t,r){var e,n,o=r?(e=t.buffer,n=new e.constructor(e.byteLength),new Xr(n).set(new Xr(e)),n):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}var Tn=Object.create,zn=function(){function t(){}return function(r){if(!fr(r))return{};if(Tn)return Tn(r);t.prototype=r;var e=new t;return t.prototype=void 0,e}}();function Cn(t,r){if(("constructor"!==r||"function"!=typeof t[r])&&"__proto__"!=r)return t[r]}var In=Object.prototype.hasOwnProperty;function Mn(t,r,e){var n=t[r];In.call(t,r)&&gr(n,e)&&(void 0!==e||r in t)||On(t,r,e)}var Dn=Object.prototype.hasOwnProperty;function Fn(t){if(!fr(t))return function(t){var r=[];if(null!=t)for(var e in Object(t))r.push(e);return r}(t);var r=ar(t),e=[];for(var n in t)("constructor"!=n||!r&&Dn.call(t,n))&&e.push(n);return e}function $n(t){return dr(t)?or(t,!0):Fn(t)}function Bn(t){return function(t,r,e,n){var o=!e;e||(e={});for(var u=-1,a=r.length;++u0){if(++r>=Jn)return arguments[0]}else r=0;return t.apply(void 0,arguments)}}(qn);function Hn(t,r){return Gn(function(t,r,e){return r=Vn(void 0===r?t.length-1:r,0),function(){for(var n=arguments,o=-1,u=Vn(n.length-r,0),a=Array(u);++o1?r[n-1]:void 0,u=n>2?r[2]:void 0;for(o=Yn.length>3&&"function"==typeof o?(n--,o):void 0,u&&function(t,r,e){if(!fr(e))return!1;var n=typeof r;return!!("number"==n?dr(e)&&Wt(r,e.length):"string"==n&&r in e)&&gr(e[r],t)}(r[0],r[1],u)&&(o=n<3?void 0:o,n=1),t=Object(t);++er.length:var n=r.length,o=["any"];return t.map((function(t,e){var u=e>=n||!!r[e].optional,a=r[e]||{type:o,name:"_"+e};return{arg:u?mn(t,a):t,index:e,param:a,optional:u}}));default:throw new ot("Could not understand your arguments and parameter structure!",{args:t,params:r})}}(t,r),u=o.filter((function(t){return!0===t.optional||!0===t.param.optional?function(t){var r=t.arg,e=t.param;return!!at(r)&&!(e.type.length>e.type.filter((function(r){return jn(r,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(r){return jn(r,t)})).length)}));return e?((n={}).error=u,n.data=o.map((function(t){return t.arg})),n):u})),Eo={algorithm:ko("HS256",["string"]),expiresIn:ko(!1,["boolean","number","string"],(ho={},ho[nt]="exp",ho[Z]=!0,ho)),notBefore:ko(!1,["boolean","number","string"],(yo={},yo[nt]="nbf",yo[Z]=!0,yo)),audience:ko(!1,["boolean","string"],(bo={},bo[nt]="iss",bo[Z]=!0,bo)),subject:ko(!1,["boolean","string"],(go={},go[nt]="sub",go[Z]=!0,go)),issuer:ko(!1,["boolean","string"],(_o={},_o[nt]="iss",_o[Z]=!0,_o)),noTimestamp:ko(!1,["boolean"],(jo={},jo[Z]=!0,jo)),header:ko(!1,["boolean","string"],(mo={},mo[Z]=!0,mo)),keyid:ko(!1,["boolean","string"],(wo={},wo[Z]=!0,wo)),mutatePayload:ko(!1,["boolean"],(Oo={},Oo[Z]=!0,Oo))};t.decodeToken=function(t){if(Q(t))return function(t){var r=t.iat||ut(!0);if(t.exp&&r>=t.exp){var e=new Date(t.exp).toISOString();throw new ot("Token has expired on "+e,t)}return t}(a(t));throw new ot("Token must be a string!")},t.tokenValidator=function(t){if(!Ao(t))return{};var r={},e=So(t,Eo);for(var n in e)e[n]&&(r[n]=e[n]);return r},Object.defineProperty(t,"__esModule",{value:!0})})); +!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((t=t||self).jsonqlJwt={})}(this,(function(t){"use strict";function r(t){this.message=t}r.prototype=new Error,r.prototype.name="InvalidCharacterError";var e="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new r("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,o,u=0,a=0,i="";o=e.charAt(a++);~o&&(n=u%4?64*n+o:o,u++%4)?i+=String.fromCharCode(255&n>>(-2*u&6)):0)o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(o);return i};var n=function(t){var r=t.replace(/-/g,"+").replace(/_/g,"/");switch(r.length%4){case 0:break;case 2:r+="==";break;case 3:r+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(e(t).replace(/(.)/g,(function(t,r){var e=r.charCodeAt(0).toString(16).toUpperCase();return e.length<2&&(e="0"+e),"%"+e})))}(r)}catch(t){return e(r)}};function o(t){this.message=t}o.prototype=new Error,o.prototype.name="InvalidTokenError";var u=function(t,r){if("string"!=typeof t)throw new o("Invalid token specified");var e=!0===(r=r||{}).header?0:1;try{return JSON.parse(n(t.split(".")[e]))}catch(t){throw new o("Invalid token specified: "+t.message)}};u.InvalidTokenError=o;var a="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},i="object"==typeof a&&a&&a.Object===Object&&a,c="object"==typeof self&&self&&self.Object===Object&&self,f=i||c||Function("return this")(),l=f.Symbol;function s(t,r){for(var e=-1,n=null==t?0:t.length,o=Array(n);++e=n?t:function(t,r,e){var n=-1,o=t.length;r<0&&(r=-r>o?0:o+r),(e=e>o?o:e)<0&&(e+=o),o=r>e?0:e-r>>>0,r>>>=0;for(var u=Array(o);++n-1;);return e}(n,o),function(t,r){for(var e=t.length;e--&&E(r,t[e],0)>-1;);return e}(n,o)+1).join("")}function q(t){return"string"==typeof t||!p(t)&&j(t)&&"[object String]"==_(t)}var J=function(t){return""!==V(t)&&q(t)},L=function(t){function r(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];t.apply(this,e),this.message=e[0],this.detail=e[1],this.className=r.name,t.captureStackTrace&&t.captureStackTrace(this,r)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var e={name:{configurable:!0},statusCode:{configurable:!0}};return e.name.get=function(){return"JsonqlError"},e.statusCode.get=function(){return-1},Object.defineProperties(r,e),r}(Error);function W(t){var r=t.iat||function(t){void 0===t&&(t=!1);var r=Date.now();return t?Math.floor(r/1e3):r}(!0);if(t.exp&&r>=t.exp){var e=new Date(t.exp).toISOString();throw new L("Token has expired on "+e,t)}return t}var G=function(t){return!!p(t)||null!=t&&""!==V(t)};function H(t){return function(t){return"number"==typeof t||j(t)&&"[object Number]"==_(t)}(t)&&t!=+t}var Y=function(t){return!q(t)&&!H(parseFloat(t))},K=function(t){return null!=t&&"boolean"==typeof t},Q=function(t,r){return void 0===r&&(r=!0),void 0!==t&&""!==t&&""!==V(t)&&(!1===r||!0===r&&null!==t)},X=function(t){switch(t){case"number":return Y;case"string":return J;case"boolean":return K;default:return Q}},Z=function(t,r){return void 0===r&&(r=""),!!p(t)&&(""===r||""===V(r)||!(t.filter((function(t){return!X(r)(t)})).length>0))},tt=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var r=t.replace("array.<","").replace(">","");return r.indexOf("|")?r.split("|"):[r]}return!1},rt=function(t,r){var e=t.arg;return r.length>1?!e.filter((function(t){return!(r.length>r.filter((function(r){return!X(r)(t)})).length)})).length:r.length>r.filter((function(t){return!Z(e,t)})).length};function et(t,r){return function(e){return t(r(e))}}var nt=et(Object.getPrototypeOf,Object),ot=Function.prototype,ut=Object.prototype,at=ot.toString,it=ut.hasOwnProperty,ct=at.call(Object);function ft(t){if(!j(t)||"[object Object]"!=_(t))return!1;var r=nt(t);if(null===r)return!0;var e=it.call(r,"constructor")&&r.constructor;return"function"==typeof e&&e instanceof e&&at.call(e)==ct}var lt,st=function(t,r,e){for(var n=-1,o=Object(t),u=e(t),a=u.length;a--;){var i=u[lt?a:++n];if(!1===r(o[i],i,o))break}return t};function pt(t){return j(t)&&"[object Arguments]"==_(t)}var vt=Object.prototype,ht=vt.hasOwnProperty,dt=vt.propertyIsEnumerable,yt=pt(function(){return arguments}())?pt:function(t){return j(t)&&ht.call(t,"callee")&&!dt.call(t,"callee")};var bt="object"==typeof t&&t&&!t.nodeType&&t,gt=bt&&"object"==typeof module&&module&&!module.nodeType&&module,_t=gt&>.exports===bt?f.Buffer:void 0,jt=(_t?_t.isBuffer:void 0)||function(){return!1},mt=/^(?:0|[1-9]\d*)$/;function wt(t,r){var e=typeof t;return!!(r=null==r?9007199254740991:r)&&("number"==e||"symbol"!=e&&mt.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=9007199254740991}var kt={};kt["[object Float32Array]"]=kt["[object Float64Array]"]=kt["[object Int8Array]"]=kt["[object Int16Array]"]=kt["[object Int32Array]"]=kt["[object Uint8Array]"]=kt["[object Uint8ClampedArray]"]=kt["[object Uint16Array]"]=kt["[object Uint32Array]"]=!0,kt["[object Arguments]"]=kt["[object Array]"]=kt["[object ArrayBuffer]"]=kt["[object Boolean]"]=kt["[object DataView]"]=kt["[object Date]"]=kt["[object Error]"]=kt["[object Function]"]=kt["[object Map]"]=kt["[object Number]"]=kt["[object Object]"]=kt["[object RegExp]"]=kt["[object Set]"]=kt["[object String]"]=kt["[object WeakMap]"]=!1;var At,St="object"==typeof t&&t&&!t.nodeType&&t,Et=St&&"object"==typeof module&&module&&!module.nodeType&&module,xt=Et&&Et.exports===St&&i.process,Pt=function(){try{var t=Et&&Et.require&&Et.require("util").types;return t||xt&&xt.binding&&xt.binding("util")}catch(t){}}(),Tt=Pt&&Pt.isTypedArray,zt=Tt?(At=Tt,function(t){return At(t)}):function(t){return j(t)&&Ot(t.length)&&!!kt[_(t)]},Ct=Object.prototype.hasOwnProperty;function It(t,r){var e=p(t),n=!e&&yt(t),o=!e&&!n&&jt(t),u=!e&&!n&&!o&&zt(t),a=e||n||o||u,i=a?function(t,r){for(var e=-1,n=Array(t);++e-1},Wt.prototype.set=function(t,r){var e=this.__data__,n=Jt(e,t);return n<0?(++this.size,e.push([t,r])):e[n][1]=r,this};var Gt,Ht=f["__core-js_shared__"],Yt=(Gt=/[^.]+$/.exec(Ht&&Ht.keys&&Ht.keys.IE_PROTO||""))?"Symbol(src)_1."+Gt:"";var Kt=Function.prototype.toString;function Qt(t){if(null!=t){try{return Kt.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var Xt=/^\[object .+?Constructor\]$/,Zt=Function.prototype,tr=Object.prototype,rr=Zt.toString,er=tr.hasOwnProperty,nr=RegExp("^"+rr.call(er).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function or(t){return!(!Bt(t)||function(t){return!!Yt&&Yt in t}(t))&&(Nt(t)?nr:Xt).test(Qt(t))}function ur(t,r){var e=function(t,r){return null==t?void 0:t[r]}(t,r);return or(e)?e:void 0}var ar=ur(f,"Map"),ir=ur(Object,"create");var cr=Object.prototype.hasOwnProperty;var fr=Object.prototype.hasOwnProperty;function lr(t){var r=-1,e=null==t?0:t.length;for(this.clear();++ri))return!1;var f=u.get(t);if(f&&u.get(r))return f==r;var l=-1,s=!0,p=2&e?new hr:void 0;for(u.set(t,r),u.set(r,t);++lr.type.filter((function(t){var r;return void 0===e||(!1!==(r=tt(t))?!rt({arg:e},r):!X(t)(e))})).length)})).length}return!1},le=function(t){function r(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];t.apply(this,e),this.message=e[0],this.detail=e[1],this.className=r.name,t.captureStackTrace&&t.captureStackTrace(this,r)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var e={name:{configurable:!0}};return e.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(r,e),r}(Error),se=function(t){function r(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];t.apply(this,e),this.message=e[0],this.detail=e[1],this.className=r.name,t.captureStackTrace&&t.captureStackTrace(this,r)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var e={name:{configurable:!0}};return e.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(r,e),r}(Error),pe=function(t){function r(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];t.apply(this,e),this.message=e[0],this.detail=e[1],this.className=r.name,t.captureStackTrace&&t.captureStackTrace(this,r)}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var e={name:{configurable:!0}};return e.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(r,e),r}(Error),ve=function(t,r){var e,n,o,u,a;switch(!0){case"object"===t:return o=(n=r).arg,u=n.param,a=[o],Array.isArray(u.keys)&&u.keys.length&&a.push(u.keys),!Reflect.apply(fe,null,a);case"array"===t:return!Z(r.arg);case!1!==(e=tt(t)):return!rt(r,e);default:return!X(t)(r.arg)}},he=function(t,r){return void 0!==t?t:!0===r.optional&&void 0!==r.defaultvalue?r.defaultvalue:null},de=function(){try{var t=ur(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function ye(t,r,e){"__proto__"==r&&de?de(t,r,{configurable:!0,enumerable:!0,value:e,writable:!0}):t[r]=e}function be(t,r,e){(void 0===e||qt(t[r],e))&&(void 0!==e||r in t)||ye(t,r,e)}var ge="object"==typeof t&&t&&!t.nodeType&&t,_e=ge&&"object"==typeof module&&module&&!module.nodeType&&module,je=_e&&_e.exports===ge?f.Buffer:void 0,me=je?je.allocUnsafe:void 0;function we(t,r){var e,n,o=r?(e=t.buffer,n=new e.constructor(e.byteLength),new br(n).set(new br(e)),n):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}var Oe=Object.create,ke=function(){function t(){}return function(r){if(!Bt(r))return{};if(Oe)return Oe(r);t.prototype=r;var e=new t;return t.prototype=void 0,e}}();function Ae(t,r){if(("constructor"!==r||"function"!=typeof t[r])&&"__proto__"!=r)return t[r]}var Se=Object.prototype.hasOwnProperty;function Ee(t,r,e){var n=t[r];Se.call(t,r)&&qt(n,e)&&(void 0!==e||r in t)||ye(t,r,e)}var xe=Object.prototype.hasOwnProperty;function Pe(t){if(!Bt(t))return function(t){var r=[];if(null!=t)for(var e in Object(t))r.push(e);return r}(t);var r=Dt(t),e=[];for(var n in t)("constructor"!=n||!r&&xe.call(t,n))&&e.push(n);return e}function Te(t){return Rt(t)?It(t,!0):Pe(t)}function ze(t){return function(t,r,e,n){var o=!e;e||(e={});for(var u=-1,a=r.length;++u0){if(++r>=800)return arguments[0]}else r=0;return t.apply(void 0,arguments)}}(Fe);function Ne(t,r){return Be(function(t,r,e){return r=De(void 0===r?t.length-1:r,0),function(){for(var n=arguments,o=-1,u=De(n.length-r,0),a=Array(u);++o1?r[n-1]:void 0,u=n>2?r[2]:void 0;for(o=Re.length>3&&"function"==typeof o?(n--,o):void 0,u&&function(t,r,e){if(!Bt(e))return!1;var n=typeof r;return!!("number"==n?Rt(e)&&wt(r,e.length):"string"==n&&r in e)&&qt(e[r],t)}(r[0],r[1],u)&&(o=n<3?void 0:o,n=1),t=Object(t);++er.length:var n=r.length,o=["any"];return t.map((function(t,e){var u=e>=n||!!r[e].optional,a=r[e]||{type:o,name:"_"+e};return{arg:u?he(t,a):t,index:e,param:a,optional:u}}));default:throw new L("Could not understand your arguments and parameter structure!",{args:t,params:r})}}(t,r),u=o.filter((function(t){return!0===t.optional||!0===t.param.optional?function(t){var r=t.arg,e=t.param;return!!G(r)&&!(e.type.length>e.type.filter((function(r){return ve(r,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(r){return ve(r,t)})).length)}));return e?((n={}).error=u,n.data=o.map((function(t){return t.arg})),n):u})),vn={algorithm:sn("HS256",["string"]),expiresIn:sn(!1,["boolean","number","string"],(tn={},tn.alias="exp",tn.optional=!0,tn)),notBefore:sn(!1,["boolean","number","string"],(rn={},rn.alias="nbf",rn.optional=!0,rn)),audience:sn(!1,["boolean","string"],(en={},en.alias="iss",en.optional=!0,en)),subject:sn(!1,["boolean","string"],(nn={},nn.alias="sub",nn.optional=!0,nn)),issuer:sn(!1,["boolean","string"],(on={},on.alias="iss",on.optional=!0,on)),noTimestamp:sn(!1,["boolean"],(un={},un.optional=!0,un)),header:sn(!1,["boolean","string"],(an={},an.optional=!0,an)),keyid:sn(!1,["boolean","string"],(cn={},cn.optional=!0,cn)),mutatePayload:sn(!1,["boolean"],(fn={},fn.optional=!0,fn))};t.decodeToken=function(t){if(J(t))return W(u(t));throw new L("Token must be a string!")},t.tokenValidator=function(t){if(!ln(t))return{};var r={},e=pn(t,vn);for(var n in e)e[n]&&(r[n]=e[n]);return r},Object.defineProperty(t,"__esModule",{value:!0})})); //# sourceMappingURL=jsonql-jwt.js.map diff --git a/packages/jwt/package.json b/packages/jwt/package.json index 1f8c438d13d2bc519468afd1561c4b6dada180a0..4fc155138f0aec7ea918699076a5aa4174193a25 100644 --- a/packages/jwt/package.json +++ b/packages/jwt/package.json @@ -1,13 +1,13 @@ { "name": "jsonql-jwt", - "version": "1.3.8", + "version": "1.3.9", "description": "jwt authentication helpers library for jsonql browser / node", "main": "main.js", "module": "index.js", "browser": "dist/jsonql-jwt.js", "scripts": { "test": "npm run build && npm run test:run", - "test:run": "DEBUG=jsonql-jwt* ava --verbose", + "test:run": "DEBUG=jsonql-jwt* ava", "build": "npm run build:decode && npm run build:main", "build:main": "rollup -c", "build:decode": "rollup -c ./rollup.decode-jwt.config.js", @@ -41,59 +41,56 @@ "fs-extra": "^8.1.0", "jsonql-constants": "^1.8.14", "jsonql-errors": "^1.1.10", - "jsonql-params-validator": "^1.5.1", - "jsonql-utils": "^0.9.2", + "jsonql-params-validator": "^1.5.2", + "jsonql-utils": "^1.0.0", "jsonwebtoken": "^8.5.1", "jwt-decode": "^2.2.0", "socketio-jwt": "^4.5.0", - "yargs": "^15.0.2" + "yargs": "^15.1.0" }, "bin": { "jsonql-jwt": "./cmd.js" }, "devDependencies": { "socket.io-client": "^2.3.0", - "ws": "^7.2.0", - "ava": "^2.4.0", + "ws": "^7.2.1", + "ava": "^3.5.0", "debug": "^4.1.1", "esm": "^3.2.25", "koa": "^2.11.0", - "rollup": "^1.27.9", + "rollup": "^1.32.0", "rollup-plugin-alias": "^2.2.0", "rollup-plugin-async": "^1.2.0", "rollup-plugin-buble": "^0.19.8", "rollup-plugin-bundle-size": "^1.0.3", "rollup-plugin-commonjs": "^10.1.0", - "rollup-plugin-copy": "^3.1.0", + "rollup-plugin-copy": "^3.3.0", "rollup-plugin-json": "^4.0.0", "rollup-plugin-node-builtins": "^2.1.2", "rollup-plugin-node-globals": "^1.4.0", "rollup-plugin-node-resolve": "^5.2.0", "rollup-plugin-replace": "^2.2.0", "rollup-plugin-serve": "^1.0.1", - "rollup-plugin-terser": "^5.1.2", - "server-io-core": "^1.2.0", + "rollup-plugin-terser": "^5.2.0", + "server-io-core": "^1.3.1", "socket.io": "^2.3.0" }, "ava": { "files": [ - "tests/**/*.test.js", - "!tests/fixtures/**/*.*" + "tests/**/*.test.js" ], - "sources": [ - "**/*.{js,jsx}", - "!dist/**/*" + "ignoredByWatcher": [ + "tests/fixtures/**/*.*" + ], + "require": [ + "esm" ], "cache": true, "concurrency": 5, "failFast": true, "failWithoutAssertions": false, "tap": false, - "verbose": true, - "compileEnhancements": false, - "require": [ - "esm" - ] + "verbose": true }, "engine": { "node": ">=8" diff --git a/packages/jwt/src/client/decode-token/decode-token.js b/packages/jwt/src/client/decode-token/decode-token.js index e9ee0409dc581c4273c6c03d5c6da6be40c4dfc3..8a7817d809eed4c59ac134618637b8a7a5123d4b 100644 --- a/packages/jwt/src/client/decode-token/decode-token.js +++ b/packages/jwt/src/client/decode-token/decode-token.js @@ -6,9 +6,14 @@ import jwt_decode from 'jwt-decode' import isString from 'jsonql-params-validator/src/string' import JsonqlError from 'jsonql-errors/src/error' +/** + * Use the jsonql-utils version in the future + * @param {boolean} sec use second + * @return {integer} the timestamp in second or milsecond + */ const timestamp = function (sec = false) { var time = Date.now() - return sec ? Math.floor( time / 1000 ) : time; + return sec ? Math.floor( time / 1000 ) : time } /** @@ -25,7 +30,7 @@ function validate(token) { throw new JsonqlError(`Token has expired on ${expired}`, token) } } - return token; + return token } /** diff --git a/packages/jwt/src/client/decode-token/token-validator.js b/packages/jwt/src/client/decode-token/token-validator.js index 40fe63eb348d52a9be8626b2a5517cdca08bef7c..7c80c50c316e249a7ed15cd5f3a7cf310315f98c 100644 --- a/packages/jwt/src/client/decode-token/token-validator.js +++ b/packages/jwt/src/client/decode-token/token-validator.js @@ -42,17 +42,22 @@ const appProps = { }) } +/** + * validate the token type + * @param {object} config options + * @return {object} tested result + */ export default function tokenValidator(config) { if (!isObject(config)) { - return {}; // we just ignore it all together? + return {} // @TODO we just ignore it all together? } - let result = {}; + let result = {} let opts = checkConfig(config, appProps) // need to remove options that is false for (let key in opts) { if (opts[key]) { - result[key] = opts[key]; + result[key] = opts[key] } } - return result; + return result } diff --git a/packages/jwt/src/crypto/encrypt-decrypt.js b/packages/jwt/src/crypto/encrypt-decrypt.js index 1c4555a36e9611fb21713e3514786045f18fbb4b..22628877fe8b2df5a378b707b7626f87d42db3e2 100644 --- a/packages/jwt/src/crypto/encrypt-decrypt.js +++ b/packages/jwt/src/crypto/encrypt-decrypt.js @@ -4,6 +4,7 @@ const fs = require('fs-extra') const { BASE64_FORMAT, UTF8_FORMAT } = require('jsonql-constants') /** + * Encrypt data with a public key in pem file format * @param {*} toEncrypt data to encypt * @param {string} relativeOrAbsolutePathToPublicKey path to pem public key file */ @@ -16,6 +17,7 @@ function encryptWithPublicPem(toEncrypt, relativeOrAbsolutePathToPublicKey) { } /** + * Decrypt the data with the public key in pem file format * @param {*} toDecrypt data to decrypt * @param {string} relativeOrAbsolutePathtoPrivateKey path to pem private key file */ @@ -39,8 +41,9 @@ module.exports = { } // for reference at the moment +/* function signObject(str) { - var signerObject = crypto.createSign("RSA-SHA256"); + var signerObject = crypto.createSign("RSA-SHA256") signerObject.update(str); var signature = signerObject.sign({ key: privateKey, @@ -49,11 +52,12 @@ function signObject(str) { console.info("signature: %s", signature); //verify String - var verifierObject = crypto.createVerify("RSA-SHA256"); + var verifierObject = crypto.createVerify("RSA-SHA256") verifierObject.update(str); var verified = verifierObject.verify({ key: publicKey, padding: crypto.constants.RSA_PKCS1_PSS_PADDING }, signature, "base64"); - console.info("is signature ok?: %s", verified); + console.info("is signature ok?: %s", verified) } +*/ \ No newline at end of file diff --git a/packages/jwt/src/crypto/rsa-keys.js b/packages/jwt/src/crypto/rsa-keys.js index c591a73f38b1e4c6d39e0e08634bcf8d932a0bea..ed59e77a7a19f5459b47c78d4de4272b387a5ab7 100644 --- a/packages/jwt/src/crypto/rsa-keys.js +++ b/packages/jwt/src/crypto/rsa-keys.js @@ -1,9 +1,9 @@ const crypto = require('crypto') -const { BASE64_FORMAT, HEX_FORMAT, RSA_FORMATS } = require('jsonql-constants') +const { BASE64_FORMAT, RSA_FORMATS } = require('jsonql-constants') const { inArray } = require('jsonql-params-validator') const { JsonqlError } = require('jsonql-errors') - -const PRIME_LENGTH = 60; +// HEX_FORMAT, +const PRIME_LENGTH = 60 /** * create RSA public / private key pair @@ -13,12 +13,12 @@ const PRIME_LENGTH = 60; */ module.exports = function rsaKeys(format = BASE64_FORMAT, len = PRIME_LENGTH) { if (len > 0 && inArray(RSA_FORMATS, format)) { - const diffHell = crypto.createDiffieHellman(len); + const diffHell = crypto.createDiffieHellman(len) diffHell.generateKeys(format); return { publicKey: diffHell.getPublicKey(format), privateKey: diffHell.getPrivateKey(format) - }; + } } - throw new JsonqlError(`Len must be greater than zero and format must be one of these two ${RSA_FORMATS}`); -}; + throw new JsonqlError(`Len(gth) must be greater than zero and format must be one of these two ${RSA_FORMATS}`) +} diff --git a/packages/jwt/src/crypto/rsa-pem-keys.js b/packages/jwt/src/crypto/rsa-pem-keys.js index 0ac647f78231833de41fc3c283fe1d2174a94eac..24bf1c23b8b8c497fee715208100d8a7129dd6a8 100644 --- a/packages/jwt/src/crypto/rsa-pem-keys.js +++ b/packages/jwt/src/crypto/rsa-pem-keys.js @@ -11,13 +11,14 @@ const { DEFAULT_PUBLIC_KEY_FILE } = require('jsonql-constants') const { JsonqlValidationError, JsonqlError } = require('jsonql-errors') + /** * Double check the input len * @param {number} len modulusLength * @return {number} on OK */ const checkLen = len => { - len = parseInt(len, 10); + len = parseInt(len, 10) if (isNaN(len)) { throw new JsonqlValidationError(`modulusLength needs to be an integer!`); } @@ -25,9 +26,9 @@ const checkLen = len => { return len; } if (len > RSA_MIN_MODULE_LEN && len < RSA_MAX_MODULE_LEN) { - let d = len / RSA_MIN_MODULE_LEN; + let d = len / RSA_MIN_MODULE_LEN if (d%2 === 0) { - return len; + return len } } throw new JsonqlValidationError(`modulusLength needs to be squre by 2 and larger or equal to ${RSA_MIN_MODULE_LEN} and less than or equal to ${RSA_MAX_MODULE_LEN}`) @@ -41,14 +42,14 @@ const checkLen = len => { * @return {object} promise resolve to publicKey / privateKey */ const outputToDir = (outputDir, result) => { - const dir = resolve(outputDir); - const { publicKey, privateKey } = result; - const files = [publicKey, privateKey]; + const dir = resolve(outputDir) + const { publicKey, privateKey } = result + const files = [publicKey, privateKey] // @TODO use provide names const names = [ DEFAULT_PUBLIC_KEY_FILE, DEFAULT_PRIVATE_KEY_FILE - ]; + ] // the way this check is wrong ... return Promise.all( files.map((file, i) => { @@ -74,6 +75,7 @@ const outputToDir = (outputDir, result) => { /** * generate a pair of public and private rsa keys in pem format + * @param {integer} len the length of the key * @return {promise} resolve the publicKey privateKey */ function rsaPemKeysAction(len) { diff --git a/packages/jwt/src/jwt/decode-token.js b/packages/jwt/src/jwt/decode-token.js index 7801426be96ed77618796beac4ab3d46f0f113b6..33992cf54a1ca32dc0493353bdda28073bade590 100644 --- a/packages/jwt/src/jwt/decode-token.js +++ b/packages/jwt/src/jwt/decode-token.js @@ -631,11 +631,16 @@ var JsonqlError = /*@__PURE__*/(function (Error) { // when the user is login with the jwt +/** + * Use the jsonql-utils version in the future + * @param {boolean} sec use second + * @return {integer} the timestamp in second or milsecond + */ var timestamp = function (sec) { if ( sec === void 0 ) sec = false; var time = Date.now(); - return sec ? Math.floor( time / 1000 ) : time; + return sec ? Math.floor( time / 1000 ) : time }; /** @@ -652,7 +657,7 @@ function validate(token) { throw new JsonqlError(("Token has expired on " + expired), token) } } - return token; + return token } /** @@ -685,9 +690,14 @@ var appProps = { mutatePayload: jsonqlParamsValidator.createConfig(false, [BOOLEAN_TYPE], ( obj$8 = {}, obj$8[OPTIONAL_KEY] = true, obj$8 )) }; +/** + * validate the token type + * @param {object} config options + * @return {object} tested result + */ function tokenValidator(config) { if (!jsonqlParamsValidator.isObject(config)) { - return {}; // we just ignore it all together? + return {} // @TODO we just ignore it all together? } var result = {}; var opts = jsonqlParamsValidator.checkConfig(config, appProps); @@ -697,7 +707,7 @@ function tokenValidator(config) { result[key] = opts[key]; } } - return result; + return result } exports.decodeToken = jwtDecode; diff --git a/packages/jwt/src/jwt/jwt-token.js b/packages/jwt/src/jwt/jwt-token.js index 3717248288b777a386e6ac3f90f98211212ca483..fbdde76f07ebb22a4b494ae56ef397d5af32394b 100644 --- a/packages/jwt/src/jwt/jwt-token.js +++ b/packages/jwt/src/jwt/jwt-token.js @@ -1,10 +1,10 @@ const jwt = require('jsonwebtoken') -const { HSA_ALGO, RSA_ALGO, BASE64_FORMAT } = require('jsonql-constants') +// HSA_ALGO, , BASE64_FORMAT +const { RSA_ALGO } = require('jsonql-constants') const { buff } = require('jsonql-utils') - const { tokenValidator } = require('./decode-token') -const baseOptions = { algorithm: HSA_ALGO } +// const baseOptions = { algorithm: HSA_ALGO } /* NOTES about the options: diff --git a/packages/jwt/src/server/auth/create-token-validator.js b/packages/jwt/src/server/auth/create-token-validator.js index 4273ba65fd6a16b484ea655211b10e2bfa84b68b..10361243ba3c41010fc38686be92b1ca49aa13f4 100644 --- a/packages/jwt/src/server/auth/create-token-validator.js +++ b/packages/jwt/src/server/auth/create-token-validator.js @@ -1,4 +1,4 @@ -const { join, resolve } = require('path') +// const { join, resolve } = require('path') const { JsonqlValidationError } = require('jsonql-errors') const { isString } = require('jsonql-params-validator') const { RSA_ALGO, HSA_ALGO } = require('jsonql-constants') @@ -10,7 +10,7 @@ const jwtDecode = require('../../jwt/jwt-decode') * @return {function} the token decode function */ module.exports = function createTokenValidator(config) { - const { useJwt, publicKey } = config; + const { useJwt, publicKey } = config // const tokenOpts = tokenValidator(tokenOptions); // debug('config', useJwt, publicKey, tokenOpts) let key, opts; diff --git a/packages/koa/package.json b/packages/koa/package.json index 7e473d07b86d8db5c4d28399164348fddf1077b4..8739163ed02b332c72335abd89110f81f360e829 100644 --- a/packages/koa/package.json +++ b/packages/koa/package.json @@ -78,14 +78,14 @@ "debug": "^4.1.1", "esm": "^3.2.25", "fs-extra": "^8.1.0", - "jsonql-constants": "^1.8.14", + "jsonql-constants": "^1.9.1", "jsonql-contract": "^1.8.7", "jsonql-errors": "^1.1.10", - "jsonql-jwt": "^1.3.8", + "jsonql-jwt": "^1.3.9", "jsonql-node-client": "^1.3.0", "jsonql-params-validator": "^1.5.2", "jsonql-resolver": "^1.1.0", - "jsonql-utils": "^0.9.7", + "jsonql-utils": "^1.0.0", "jsonql-web-console": "^0.4.5", "koa-compose": "^4.1.0", "lodash": "^4.17.15" diff --git a/packages/node-client/index.js b/packages/node-client/index.js index 19c13fe5bff68a18d31dc382154c192ae7a6bdb8..43e51f983e7af3cb34e97e35d00e0de634573b52 100755 --- a/packages/node-client/index.js +++ b/packages/node-client/index.js @@ -3,10 +3,14 @@ const { JsonqlRequestClient, getContract, generator, - checkOptions, - createSocketClient, + checkConfiguration, getDebug } = require('./src') +const { + getSocketClient, + createSocketClient, +} = require('./src/create-socket-client') + const debug = getDebug('main') // finally @@ -14,12 +18,18 @@ const debug = getDebug('main') * The config takes two things * hostname, contractDir * if there is security feature on then the contractKey + * @2020-03-04 We have to completely re-architect how to deal with the socket client * @param {object} config configuration the only require field is hostname * @return {object} promise to resolve the jsonql node client */ module.exports = function jsonqlNodeClient(config) { + const { + socketDefaultOptions, + socketConstProps, + createSocketClientFn + } = getSocketClient(config) // start the generator - return checkOptions(config) + return checkConfiguration(config, socketDefaultOptions, socketConstProps) // @TODO remove once the socket client checked .then(opts => { debug('[jsonql-node-client] init opts', opts) @@ -36,7 +46,7 @@ module.exports = function jsonqlNodeClient(config) { .then( ({jsonqlInstance, opts}) => ( getContract(jsonqlInstance, opts.contract) .then(contract => { - opts.contract = contract; + opts.contract = contract return { opts, contract, @@ -46,8 +56,8 @@ module.exports = function jsonqlNodeClient(config) { ) ) ) - // create the node client if any + // create the node socket client if any .then(({opts, contract, client}) => ( - createSocketClient(client, opts, contract) + createSocketClient(createSocketClientFn, client, opts, contract) )) } diff --git a/packages/node-client/package.json b/packages/node-client/package.json index fbea0dcd49faa6aa33038beabf0f7be06ce3bfc8..38fa2311806b636fb7975afd12f705ad592b647b 100755 --- a/packages/node-client/package.json +++ b/packages/node-client/package.json @@ -1,6 +1,6 @@ { "name": "jsonql-node-client", - "version": "1.3.0", + "version": "1.3.1", "description": "jsonql node.js client with ws clients", "main": "index.js", "scripts": { @@ -46,11 +46,11 @@ "debug": "^4.1.1", "flyio": "^0.6.14", "fs-extra": "^8.1.0", - "jsonql-constants": "^1.8.14", + "jsonql-constants": "^1.9.1", "jsonql-errors": "^1.1.10", - "jsonql-jwt": "^1.3.8", + "jsonql-jwt": "^1.3.9", "jsonql-params-validator": "^1.5.2", - "jsonql-utils": "^0.9.7", + "jsonql-utils": "^1.0.0", "lodash.merge": "^4.6.2", "node-cache": "^5.1.0" }, @@ -60,8 +60,8 @@ "devDependencies": { "ava": "^3.5.0", "jsonql-contract": "^1.8.7", - "jsonql-koa": "^1.5.7", - "jsonql-ws-server": "^1.5.3", + "jsonql-koa": "^1.6.2", + "jsonql-ws-server": "^1.6.0", "nyc": "^15.0.0", "server-io-core": "^1.3.1", "superkoa": "^1.0.3" diff --git a/packages/node-client/src/base/get-remote-contract.js b/packages/node-client/src/base/get-remote-contract.js index 0ec0d9649cca2701c2b348233446d91fc3a7c443..cc7b4474789abae96195ddce9139ddd81349fea3 100755 --- a/packages/node-client/src/base/get-remote-contract.js +++ b/packages/node-client/src/base/get-remote-contract.js @@ -1,52 +1,49 @@ -// fetching the remote contract and save locally -// jsonql-contract --remote=http://hostname/jsonql -const request = require('request') -const { join, resolve } = require('path') +// getting contract from server const fsx = require('fs-extra') -const { - CONTENT_TYPE, - PUBLIC_CONTRACT_FILE_NAME, - KEY_WORD, - DEFAULT_HEADER -} = require('jsonql-constants') +const request = require('@to1source/request/jsonql') +const { join, resolve } = require('path') +const { PUBLIC_CONTRACT_FILE_NAME, KEY_WORD } = require('jsonql-constants') +const { JsonqlError } = require('jsonql-errors') const { getDebug } = require('../utils') + const debug = getDebug('get-remote-contract') /** + * fetching the remote contract and save locally + * jsonql-contract --remote=http://hostname/jsonql * @param {object} args argument options * @param {function} cb callback * @return {promise} */ -module.exports = function getRemoteContract(args, cb) { +function getRemoteContract(args, cb) { return new Promise((resolver, rejecter) => { - // defintely we have the remote or not here + // if we have the remote or not here if (!args.remote) { return resolver(KEY_WORD) // allow the next chain to do stuff } + const url = args.remote // options const options = { - url: args.remote, - headers: Object.assign(DEFAULT_HEADER, args.authHeader) + method: 'GET', + headers: args.authHeader } - debug('calling remote server to get contract with %O', options) - // method - function callback(error, response, body) { - if (!error && response.statusCode == 200) { - const json = JSON.parse(body) + request.jsonql(url, [], options) + .then(({result}) => { // @v1.4.3 the server now standardize the return in the same format - if (!json.data) { - return rejecter(json.error || 'Server return wrong contract format') + if (!result.data) { + return rejecter(result.error || 'Server return wrong contract format') } - const contract = json.data; - const outDir = args.out ? resolve(args.out) : process.cwd() - const outFile = join(outDir, PUBLIC_CONTRACT_FILE_NAME) - debug(`outFile to: ${outFile}`) + const contract = result.data; // v1.1.4 add raw output if (args.raw) { return resolver(contract) } // cache it cb(contract) + // write to file + const outDir = args.out ? resolve(args.out) : process.cwd() + const outFile = join(outDir, PUBLIC_CONTRACT_FILE_NAME) + debug(`outFile to: ${outFile}`) fsx.outputJson(outFile, contract, {spaces: 2}, err => { if (err) { return rejecter(err) @@ -54,9 +51,11 @@ module.exports = function getRemoteContract(args, cb) { const result = args.returnAs && args.returnAs === 'file' ? outFile : contract; resolver(result) }) - } - } - // execute the remote call - request(options, callback) + }) + .catch(err => { + rejecter(new JsonqlError('getRemoteContract', err)) + }) }) } + +module.exports = { getRemoteContract } \ No newline at end of file diff --git a/packages/node-client/src/base/index.js b/packages/node-client/src/base/index.js index f0ffe7a2e5e49db50210a51bef88815af1ec6c82..5ef6234b703f9434687f66d0703c9b6550b8ee5f 100644 --- a/packages/node-client/src/base/index.js +++ b/packages/node-client/src/base/index.js @@ -2,4 +2,4 @@ const JsonqlClientCls = require('./jsonql-auth-cls') -module.exports = JsonqlClientCls; +module.exports = JsonqlClientCls diff --git a/packages/node-client/src/base/jsonql-auth-cls.js b/packages/node-client/src/base/jsonql-auth-cls.js index ed8f0c4423d6bcde53bb42a424f3642eb2950e47..cb335c94bd130b83aeb85a78d841f3ccba083bde 100644 --- a/packages/node-client/src/base/jsonql-auth-cls.js +++ b/packages/node-client/src/base/jsonql-auth-cls.js @@ -1,10 +1,11 @@ // this part is focus on the login / logout / validate metthod only -const nbEventService = require('nb-event-service') +// const nbEventService = require('nb-event-service') const { LOGIN_EVENT_NAME, LOGOUT_EVENT_NAME, AUTH_HEADER , BEARER } = require('jsonql-constants') -const { isFunc } = require('jsonql-utils') +// const { isFunc } = require('jsonql-utils') const { JsonqlNodeClientEventService } = require('./event-service') +const { getDebug } = require('../utils') const JsonqlRequestClient = require('./request-client') -const { display, getDebug, resultHandler } = require('../utils') + const debug = getDebug('jsonql-auth-cls') @@ -57,7 +58,7 @@ class JsonqlAuthClient extends JsonqlRequestClient { // the setter doesn't produce a return! this.setter('token', token) debug('store token --> ', token) - return token; + return token } /** @@ -67,7 +68,7 @@ class JsonqlAuthClient extends JsonqlRequestClient { __getAuthHeader() { let t = this.__getAuthToken() debug(`[getAuthHeader] ${t}`) - return t ? { [AUTH_HEADER]: `${BEARER} ${t}` } : {}; + return t ? { [AUTH_HEADER]: `${BEARER} ${t}` } : {} } /** diff --git a/packages/node-client/src/base/jsonql-base-cls.js b/packages/node-client/src/base/jsonql-base-cls.js index 83fdbc1828f4829b2a12e7924eb75cf8faf9dc37..27b583f3929b117684a76ecbb2566efc02b686cd 100755 --- a/packages/node-client/src/base/jsonql-base-cls.js +++ b/packages/node-client/src/base/jsonql-base-cls.js @@ -3,23 +3,18 @@ * @TODO we should move all the main back here * because the main interface should be a generator based on the contract */ - const { join } = require('path') const fsx = require('fs-extra') - -const { decodeToken } = require('jsonql-jwt') const merge = require('lodash.merge') - -const { AUTH_HEADER , BEARER } = require('jsonql-constants') - +const { decodeToken } = require('jsonql-jwt') // using node-cache from v1.1.0 // it becomes a class since 1.1.7 const JsonqlCacheClass = require('./jsonql-cache-class') -const getRemote = require('./get-remote-contract') +const { getRemoteContract } = require('./get-remote-contract') const { getDebug } = require('../utils') const debug = getDebug('jsonql-base-cls') -class JsonqlClient extends JsonqlCacheClass { +class JsonqlClientClass extends JsonqlCacheClass { constructor(config) { super(config) @@ -46,7 +41,7 @@ class JsonqlClient extends JsonqlCacheClass { * @return {object} for the accepted header */ get baseHeader() { - const { contentType } = this.opts; + const { contentType } = this.opts return { 'Accept': contentType, 'Content-Type': contentType @@ -60,8 +55,8 @@ class JsonqlClient extends JsonqlCacheClass { */ __interceptor(payload, body) { const result = typeof body === 'string' ? JSON.parse(body) : body - const resolverName = Object.keys(payload)[0] - + // const resolverName = Object.keys(payload)[0] + return result } @@ -94,7 +89,7 @@ class JsonqlClient extends JsonqlCacheClass { * @return {boolean} false on OK */ __isContractExpired(contract) { - return false; + return false /* if (contract) { const { expired } = contract; @@ -135,7 +130,6 @@ class JsonqlClient extends JsonqlCacheClass { return Promise.resolve(cacheContract) } } - // check if there is a contract store locally const file = join(this.opts.contractDir, this.opts.contractFileName) if (fsx.existsSync(file)) { @@ -153,7 +147,7 @@ class JsonqlClient extends JsonqlCacheClass { } debug(`contract out: ${this.opts.contractDir}`) // use the remote method to get it - return getRemote(Object.assign({ + return getRemoteContract(Object.assign({ remote: this.__url__, out: this.opts.contractDir }, { authHeader }), contract => { @@ -163,4 +157,4 @@ class JsonqlClient extends JsonqlCacheClass { } // export -module.exports = JsonqlClient +module.exports = JsonqlClientClass diff --git a/packages/node-client/src/create-socket-client.js b/packages/node-client/src/create-socket-client.js index 0d6228971776f72df70aaac24939c05327f6ba6f..735e218857b9c99cde499386890bb6ef69235f14 100644 --- a/packages/node-client/src/create-socket-client.js +++ b/packages/node-client/src/create-socket-client.js @@ -1,67 +1,83 @@ // new method to include the socket client when pass the serverType config -const { JS_WS_NAME, JS_WS_SOCKET_IO_NAME, JS_PRIMUS_NAME, SOCKET_NAME, CHECKED_KEY } = require('jsonql-constants') -const { JsonqlError } = require('jsonql-errors') +const { + JS_WS_NAME, + JS_WS_SOCKET_IO_NAME, + JS_PRIMUS_NAME, + SOCKET_NAME, + SOCKET_TYPE_KEY +} = require('jsonql-constants') const { getDebug } = require('./utils') const debug = getDebug('create-socket-client') /** * get the socket client node version using serverType - * @param {string} serverType the socket server (client) type + * @param {object} config take the raw config and check this first + * config.serverType the socket server (client) type * @return {object} the module */ -function getSocketClient(serverType) { +function getSocketClient(config) { + const serverType = config[SOCKET_TYPE_KEY] + let obj = { + socketDefaultOptions: null, + socketConstProps: null, + createSocketClientFn: null + } try { switch (serverType) { case JS_WS_NAME: - const jsonqlWsClient = require('@jsonql/ws/node') - return jsonqlWsClient - + // @2020-03-04 from now on take only the module version out + const { + jsonqlWsClientAppProps, + jsonqlWsConstProps, + createWsClient + } = require('@jsonql/ws/node') // from now on we will always use the same naming + + obj.socketDefaultOptions = jsonqlWsClientAppProps, + obj.socketConstProps = jsonqlWsConstProps, + obj.createSocketClientFn = createWsClient + + break case JS_WS_SOCKET_IO_NAME: case JS_PRIMUS_NAME: default: - throw new JsonqlError(`getSocketClient`, `Not support ${serverType} at the moment!`) - } + if (serverType) { + console.error(`getSocketClient`, `Not support ${serverType} at the moment!`) + } + } + return obj } catch(e) { console.error(e) - throw new Error(e) + // throw new Error(e) + return obj } } /** * This will hook into the last of the chain during init + * @param {*} createSocketClientFn from the require module if any * @param {object} client the init jsonql-node-client * @param {object} config the checked configuration * @param {object} contract the contract json * @return {object} the modified client object if socketClientType presented */ -function createSocketClient(client, config, contract) { - try { - const { serverType } = config - if (serverType) { - debug('config', config[CHECKED_KEY], config) - debug('serverType', serverType) - let constProp = { - // also need to pass the contract - contract, - // need to pass the eventEmitter here to the config - eventEmitter: client.eventEmitter(), - log: debug - } - - const socketClient = getSocketClient(serverType) - // 1.2.9 get rip of the rawConfig and use the config without checking - // because it's already checked previously - return socketClient(config, constProp) - .then(socketMethods => { - client[SOCKET_NAME] = socketMethods - return client - }) - } - return client - } catch(e) { - debug('createSocketClient', client) - throw new JsonqlError('createSocketClient', e) +function createSocketClient(createSocketClientFn, client, config, contract) { + if (createSocketClientFn) { + const opts = Object.assign(config, { + // also need to pass the contract + contract, + // need to pass the eventEmitter here to the config + eventEmitter: client.eventEmitter(), + log: debug + }) + // @1.3.1 using the require module directly + return createSocketClientFn(opts) + .then(socketClient => { + client[SOCKET_NAME] = socketClient + return client + }) } + // nothing then just pass it onward + return client } -module.exports = { createSocketClient } +module.exports = { createSocketClient, getSocketClient } diff --git a/packages/node-client/src/generator.js b/packages/node-client/src/generator.js index 0121db21fcf604becc56d1b4a31a80513d5eba78..5255ee489f1556db5ea421a15c2a5452d685ac1c 100755 --- a/packages/node-client/src/generator.js +++ b/packages/node-client/src/generator.js @@ -1,7 +1,8 @@ // the main interface generator const { validateAsync } = require('jsonql-params-validator') -const { JsonqlValidationError, finalCatch } = require('jsonql-errors') -const { getDebug, display, injectToFn, chainFns, isContract } = require('./utils') +const { finalCatch } = require('jsonql-errors') +// display, injectToFn, chainFns, +const { getDebug, isContract } = require('./utils') const debug = getDebug('generator') /** diff --git a/packages/node-client/src/index.js b/packages/node-client/src/index.js index 14b1aee421ab795152c21dc1e21d1c2bbffa4263..099f1011ede3a42dd315f776c3631cfb61f0afb7 100644 --- a/packages/node-client/src/index.js +++ b/packages/node-client/src/index.js @@ -1,15 +1,14 @@ // main export interface const JsonqlRequestClient = require('./base') const { getContract, generator } = require('./generator') +const { checkConfiguration, checkSocketClientType } = require('./options') const { getDebug } = require('./utils') -const { createSocketClient} = require('./create-socket-client') -const checkOptions = require('./options') // export module.exports = { JsonqlRequestClient, getContract, generator, - checkOptions, - getDebug, - createSocketClient + checkConfiguration, + checkSocketClientType, + getDebug } diff --git a/packages/node-client/src/options/index.js b/packages/node-client/src/options/index.js index 41f61fad624133b468926c494d24cb417464dd27..e946f68e7a50be05b745d9ee1d99036af6ff050a 100755 --- a/packages/node-client/src/options/index.js +++ b/packages/node-client/src/options/index.js @@ -1,8 +1,9 @@ +// configuration options and check method const { join } = require('path') -const fs = require('fs') const { constructConfig, createConfig, + checkConfig, checkConfigAsync } = require('jsonql-params-validator') const { getDebug, injectToFn } = require('../utils') @@ -15,45 +16,33 @@ const { CONTRACT_KEY_NAME, PUBLIC_CONTRACT_FILE_NAME, DEFAULT_HEADER, - DEFAULT_RESOLVER_DIR, DEFAULT_CONTRACT_DIR, BOOLEAN_TYPE, STRING_TYPE, - NUMBER_TYPE, - ARGS_KEY, - TYPE_KEY, - ENUM_KEY, ALIAS_KEY, - CHECKER_KEY, - ACCEPTED_JS_TYPES, - CJS_TYPE, ISSUER_NAME, LOGOUT_NAME, VALIDATOR_NAME, - // for socket client - JS_WS_NAME, - JS_WS_SOCKET_IO_NAME, - JS_PRIMUS_NAME, - CHECKED_KEY + SOCKET_TYPE_CLIENT_ALIAS, + SOCKET_TYPE_KEY } = require('jsonql-constants') - const BASE_DIR = process.cwd() -// properties +// constants properties const constProps = { contentType: CONTENT_TYPE, contract: {}, useDoc: true, returnAs: 'json' } - -const appProps = { +// node client configuration options +const ncAppProps = { hostname: constructConfig('', STRING_TYPE), // required the hostname jsonqlPath: constructConfig(JSONQL_PATH, STRING_TYPE), // The path on the server // matching the browser client version namespaced: createConfig(false, [BOOLEAN_TYPE]), useJwt: createConfig(true, [BOOLEAN_TYPE]), - + appDir: createConfig('', [STRING_TYPE]), // matching the koa setup loginHandlerName: createConfig(ISSUER_NAME, [STRING_TYPE]), logoutHandlerName: createConfig(LOGOUT_NAME, [STRING_TYPE]), validatorHandlerName: createConfig(VALIDATOR_NAME, [STRING_TYPE]), @@ -72,22 +61,47 @@ const appProps = { // functions storeAuthToken: constructConfig(false, BOOLEAN_TYPE), getAuthToken: constructConfig(false, BOOLEAN_TYPE), - defaultHeader: constructConfig(DEFAULT_HEADER, STRING_TYPE), + defaultHeader: constructConfig(DEFAULT_HEADER, STRING_TYPE) +} +// socket client +const socketAppProps = { // new prop for socket client - serverType: createConfig(null, [STRING_TYPE], { - [ENUM_KEY]: [JS_WS_NAME, JS_WS_SOCKET_IO_NAME, JS_PRIMUS_NAME], - [ALIAS_KEY]: 'socketClientType' - }) + [SOCKET_TYPE_KEY]: createConfig(null, [STRING_TYPE], {[ALIAS_KEY]: SOCKET_TYPE_CLIENT_ALIAS}) + // [ENUM_KEY]: [JS_WS_NAME, JS_WS_SOCKET_IO_NAME, JS_PRIMUS_NAME], +} +// combine the two +const appProps = Object.assign(ncAppProps, socketAppProps) + +/** + * We need this to find the socket server type + * @param {*} config + * @return {string} the name of the socket server if any + */ +function checkSocketClientType(config) { + return checkConfig(config, socketAppProps) } -// debug('appProps', appProps); -// export just one method -module.exports = function(config) { - let { contract } = config; + +/** + * check the node-client config(s) + * Also add the socket server config map and const map if any + * @param {object} config the user supplied configuration + * @param {*} [socketDefaultOptions = null] the socket server default app props + * @param {*} [socketConstProps = null] the socket server const props + * @return {object} the checked configuration + */ +function checkConfiguration(config, socketDefaultOptions = null, socketConstProps = null) { + let { contract } = config debug(`jsonql-node-client raw config`, config) - return checkConfigAsync(config, appProps, constProps) + + const localAppProps = socketDefaultOptions ? Object.assign({}, appProps, socketDefaultOptions) : appProps + const localConstProps = socketConstProps ? Object.assign({}, constProps, socketConstProps) : constProps + + return checkConfigAsync(config, localAppProps, localConstProps) .then(opts => { - opts.contract = contract; - // 1.2.3 add a CHECKED_KEY to the opts so the ws client will know it's part of nodeClient - return injectToFn(opts, CHECKED_KEY, Date.now()) + opts.contract = contract + return opts }) } + +// we should name all of them using the same name checkConfiguration +module.exports = { checkConfiguration, checkSocketClientType } \ No newline at end of file diff --git a/packages/node-client/tests/config.test.js b/packages/node-client/tests/config.test.js index f34aa217b24da8ccf4c2459bad43d49c7e855a41..9394b78a7225c1bc39e5658a76d9df25a74d623b 100644 --- a/packages/node-client/tests/config.test.js +++ b/packages/node-client/tests/config.test.js @@ -1,17 +1,22 @@ // just testing the config const test = require('ava') const { join } = require('path') -const { checkOptions } = require('../src') +const { checkConfiguration, checkSocketClientType } = require('../src') +const { + JS_WS_NAME, + SOCKET_TYPE_CLIENT_ALIAS, + SOCKET_TYPE_KEY +} = require('jsonql-constants') +const debug = require('debug')('jsonql-node-client:test:config') + let contractDir = join(__dirname, 'fixtures', 'contract', 'tmp') -let hostname = 'http://localhost:8899'; -let contractKey = 'what-wrong-with-you-mf'; -const { CHECKED_KEY } = require('jsonql-constants') -const { objHasProp } = require('jsonql-utils') +let hostname = 'http://localhost:8899' +let contractKey = 'what-wrong-with-you-mf' test('It should not throw Error', async t => { - const opts = await checkOptions({ + const opts = await checkConfiguration({ hostname, contractDir, contractKey, @@ -21,5 +26,32 @@ test('It should not throw Error', async t => { t.is(opts.contractKey, contractKey) t.falsy(opts.optionNotInList) - t.truthy(objHasProp, CHECKED_KEY) +}) + +test(`It should able to take the server type or using the alias`, t => { + + const config1 = {[SOCKET_TYPE_KEY]: JS_WS_NAME} + const result1 = checkSocketClientType(config1) + + t.deepEqual(result1, config1) + + const config2 = {[SOCKET_TYPE_CLIENT_ALIAS]: JS_WS_NAME} + const result2 = checkSocketClientType(config2) + + t.deepEqual(result2, config1) + + const config3 = {serverType: null} + + t.throws(() => { + const result3 = checkSocketClientType(config3) + debug(result3) + }, null, `Expect to throw an error because the type was incorrect`) + + + const config4 = {whatever: 'whatever', 'appDir': 'app', 'contractDir': 'some/path/to/contract'} + + const result4 = checkSocketClientType(config4) + + t.is(result4[SOCKET_TYPE_KEY], null) + }) diff --git a/packages/node-client/tests/main.test.js b/packages/node-client/tests/main.test.js index d61d83d81b61e942f11250cd18507444c9616999..ebde034dd5f914ab1a0d57857c28de8d675cb99d 100755 --- a/packages/node-client/tests/main.test.js +++ b/packages/node-client/tests/main.test.js @@ -1,20 +1,24 @@ const test = require('ava') const { join } = require('path') const server = require('./fixtures/server') -const options = require('./fixtures/options') +// const options = require('./fixtures/options') const nodeClient = require('../index') +const { getRemoteContract } = require('../src/base/get-remote-contract') + const debug = require('debug')('jsonql-node-client:test:main') +const hostname = 'http://localhost:8888' +const contractDir = join(__dirname,'fixtures','contract','tmp', 'client') + test.before(async t => { // create server const { stop } = await server() t.context.stop = stop // create client - t.context.client = await nodeClient({ - hostname:'http://localhost:8888', - contractDir: join(__dirname,'fixtures','contract','tmp', 'client') + hostname, + contractDir }) }) @@ -41,3 +45,16 @@ test(`It should able to access the mutation call using the new non-namspaced opt t.truthy(result.timestamp) }) + +test(`Test the getRemoteContract method`, async t => { + + const result = await getRemoteContract({ + remote: [hostname, 'jsonql'].join('/'), + out: join(contractDir, 'remote') + }, (...args) => { + debug('cb', args) + }) + + // debug('getRemoteContractResult', result) + t.truthy(result) +}) diff --git a/packages/node-client/tests/socket.test.js b/packages/node-client/tests/socket.donttest.js similarity index 100% rename from packages/node-client/tests/socket.test.js rename to packages/node-client/tests/socket.donttest.js diff --git a/packages/resolver/package.json b/packages/resolver/package.json index a72a33e92c0694dcce0fdbecf40097ec589c8b61..62cf90a60a750320d37c7735244cec9e18cb2c3d 100644 --- a/packages/resolver/package.json +++ b/packages/resolver/package.json @@ -30,10 +30,10 @@ "debug": "^4.1.1", "jsonql-constants": "^1.8.14", "jsonql-errors": "^1.1.10", - "jsonql-jwt": "^1.3.8", + "jsonql-jwt": "^1.3.9", "jsonql-node-client": "^1.3.0", "jsonql-params-validator": "^1.5.2", - "jsonql-utils": "^0.9.7", + "jsonql-utils": "^1.0.0", "lodash.merge": "^4.6.2" }, "devDependencies": { diff --git a/packages/resolver/tests/fixtures/contract/es/contract.json b/packages/resolver/tests/fixtures/contract/es/contract.json index c56d8ecfdb3543c1fad04b9d2ab380010206cf43..fb69ac031bccd6344a1afd85544bdb76d0d6f21b 100644 --- a/packages/resolver/tests/fixtures/contract/es/contract.json +++ b/packages/resolver/tests/fixtures/contract/es/contract.json @@ -43,6 +43,6 @@ } }, "auth": {}, - "timestamp": 1583287348, + "timestamp": 1583290316, "sourceType": "module" } diff --git a/packages/ws-server-core/package.json b/packages/ws-server-core/package.json index f1e485378fb36d810aa8b4e3afe901737ab38ecd..f69278bed3ec6f14f2d40070fdc1d24213816941 100644 --- a/packages/ws-server-core/package.json +++ b/packages/ws-server-core/package.json @@ -31,7 +31,7 @@ "jsonql-jwt": "^1.3.8", "jsonql-params-validator": "^1.5.2", "jsonql-resolver": "^1.1.0", - "jsonql-utils": "^0.9.7", + "jsonql-utils": "^1.0.0", "lodash": "^4.17.15" }, "devDependencies": {