UNPKG

ubiq-security

Version:

Ubiq Client Node.js Implementation

388 lines (288 loc) 13.9 kB
./node_modules/.bin/mocha -g Test_factory ./node_modules/.bin/mocha -g Test_builder git stash show .vscode/settings.json | 2 +- example/package.json | 4 +- example/ubiq_sample.js | 4 +- index.js | 4 +- lib/billingEventsProcessor.js | 7 +- lib/encryption.js | 4 +- package-lock.json | 3211 +++++++++++++++++++----------- package.json | 3 +- tests/FF1.test.js | 6 +- tests/UbiqSecurityEncryptDecrypt.test.js | 23 +- git checkout stash@{0} -- <file> git diff stash@{0} -- lib/encryption.js example/package.json - Local reference to library "commander": "^9.3.0", - "ubiq-security": "^1.0.9", + "ubiq-security": "file:..", "yargs": "^15.4.1" tput reset && npm test --path 'tests/UbiqSecurityStucturedEncryptDecrypt.test.js' tput reset && npm test -- -t 'addUserDefinedMetdata' tput reset && npm test -- -t "GetCopyOfUsage*" tput reset && npm test -- -t 'Structured_GetCopyOfUsage_Minutes' tput reset && npm test -- -t 'LoadTest' tput reset && npm test --path tests/UbiqSecurityLoadTest.test.js npm test ubiq-node unit test API key export UBIQ_ACCESS_KEY_ID=KsV3HSoPG77oAXUy3tuoxwwL export UBIQ_SECRET_SIGNING_KEY=C81UfvEilsJIIzyFycQk3h/aA6j2IXCCy7v2fXq1F6iX export UBIQ_SECRET_CRYPTO_ACCESS_KEY=NiVqAikgUJmiTmfETz4Qn6BzqEvvKKEfICr5hPE5YJj0 export UBIQ_SERVER=https://api.ubiqsecurity.com export UBIQ_TEST_DATA_FILE=/home/gary/ubiq-node/tests/DATA/100.json export UBIQ_MAX_AVG_ENCRYPT=5000 export UBIQ_MAX_TOTAL_DECRYPT=500000 export UBIQ_IDP_USERNAME=gary+scrum@ubiqsecurity.com export UBIQ_IDP_PASSWORD=Josie123$ [Library Structured Unit Tests - ubiq-node] ACCESS_KEY_ID = KsV3HSoPG77oAXUy3tuoxwwL SECRET_SIGNING_KEY = C81UfvEilsJIIzyFycQk3h/aA6j2IXCCy7v2fXq1F6iX SECRET_CRYPTO_ACCESS_KEY = NiVqAikgUJmiTmfETz4Qn6BzqEvvKKEfICr5hPE5YJj0 SERVER = https://api.ubiqsecurity.com node ./ubiq_sample_fpe.js -c ./credentials -P default -s -n SSN_passthrough -e 123-456-7890-123456678 export UBIQ_ACCESS_KEY_ID=jEK27hE8W1HmcFB2zr4H32ax export UBIQ_SECRET_SIGNING_KEY=ToahxnhHg/u4QrjlpQehOht9WJEDwvhvuRsKG7A/KPLK export UBIQ_SECRET_CRYPTO_ACCESS_KEY=749XOUXBY8Y2hQ/fpnAIC1NwhENKjrjCBXkkYIiIMITZ export UBIQ_SERVER=https://api-dev.ubiqsecurity.com export UBIQ_TEST_DATA_FILE=/home/gary/ubiq-java-samples-community/test_generator/100-dev.json root@debian:/home/gary/ubiq-node# npm outdated Package Current Wanted Latest Location Depended by commander 9.5.0 9.5.0 12.1.0 node_modules/commander ubiq-node dotenv 16.0.3 16.4.5 16.4.5 node_modules/dotenv ubiq-node eslint 7.32.0 7.32.0 9.8.0 node_modules/eslint ubiq-node eslint-plugin-import 2.26.0 2.29.1 2.29.1 node_modules/eslint-plugin-import ubiq-node jest 28.1.3 28.1.3 29.7.0 node_modules/jest ubiq-node node-fetch 2.6.7 2.7.0 3.3.2 node_modules/node-fetch ubiq-node uuid 8.3.2 8.3.2 10.0.0 node_modules/uuid ubiq-node root@debian:/tmp/Z/new# npm outdated Package Current Wanted Latest Location Depended by commander 9.5.0 9.5.0 12.1.0 node_modules/commander new eslint 7.32.0 7.32.0 9.8.0 node_modules/eslint new as-is dotenv - passed npm install uuid@10.0.0 npm audi fix commander 9.5.0 9.5.0 12.1.0 node_modules/commander ubiq-node eslint 7.32.0 7.32.0 9.8.0 node_modules/eslint ubiq-node eslint-plugin-import 2.26.0 2.29.1 2.29.1 node_modules/eslint-plugin-import ubiq-node jest 28.1.3 28.1.3 29.7.0 node_modules/jest ubiq-node node-fetch 2.6.7 2.7.0 3.3.2 node_modules/node-fetch ubiq-node npm install eslint-plugin-import@2.29.1 node ubiq_sample.js -c ../credentials -P dev-local -s -e -i README.md -o /tmp/README-s.enc node ubiq_sample.js -c ../credentials -P dev-local -p -e -i README.md -o /tmp/README-p.enc node ubiq_sample.js -c ../credentials -P dev-local -s -d -i /tmp/README-s.enc -o /tmp/README-s-s.dec node ubiq_sample.js -c ../credentials -P dev-local -s -d -i /tmp/README-p.enc -o /tmp/README-p-s.dec node ubiq_sample.js -c ../credentials -P dev-local -p -d -i /tmp/README-s.enc -o /tmp/README-s-p.dec node ubiq_sample.js -c ../credentials -P dev-local -p -d -i /tmp/README-p.enc -o /tmp/README-p-p.dec md5sum README.md /tmp/README-s-s.dec /tmp/README-p-s.dec /tmp/README-s-p.dec /tmp/README-p-p.dec node ubiq_sample.js -c ../credentials -P dev-local -s -d /tmp/README.enc -o /tmp/README.dec 14 node ubiq_sample.js -c ../credentials -P dev-local -p -d -i /tmp/README.enc -o /tmp/README.dec 18 node ubiq_sample.js -c ../credentials -P dev-local -s -d -i /tmp/README.enc -o /tmp/README.dec // Update configuration file for SSO tput reset && npm test -- -t "idp_sso" node ./ubiq_sample_structured.js -c ../credentials -P idp-local -n ALPHANUM_SSN -e 123-45-6789 -g ../configuration node ./ubiq_sample_structured.js -c ../credentials -P idp-local -n ALPHANUM_SSN -d 500-0q-S2yD -g ../configuration node ubiq_sample.js -g ../configuration -c ../credentials -P idp-local -s -e -i README.md -o /tmp/README.enc node ubiq_sample.js -g ../configuration -c ../credentials -P idp-local -s -d -i /tmp/README.enc -o /tmp/README.dec tput reset && node ./ubiq_sample_structured.js -c ../credentials -P prod_java_unit_test -n ALPHANUM_SSN -e 123-45-6789 node ./ubiq_sample_structured.js -c ../credentials -P prod -n SSN -e 123-45-6789 -g ./configuration cat configuration > log1.txt && node ./ubiq_sample_structured.js -c ../credentials -P prod -n SSN -e 123-45-6789 -g ./configuration >> log1.txt cat configuration > log2.txt && node ./ubiq_sample_structured.js -c ../credentials -P prod -n SSN -e 123-45-6789 -g ./configuration >> log2.txt cat configuration > log3.txt && node ./ubiq_sample_structured.js -c ../credentials -P prod -n SSN -e 123-45-6789 -g ./configuration >> log3.txt cat configuration > log4.txt && node ./ubiq_sample_structured.js -c ../credentials -P prod -n SSN -e 123-45-6789 -g ./configuration >> log4.txt node ./ubiq_sample.js -c ../credentials -P prod -g ./configuration -s -e -i README.md -o /tmp/readme.enc node ./ubiq_sample.js -c ../credentials -P prod -g ./configuration -s -e -i README.md -o /tmp/README-s.enc node ./ubiq_sample.js -c ../credentials -P prod -g ./configuration -p -d -i /tmp/readme.enc -o /tmp/README.dec const fetch = require('node-fetch'); const auth = require('./auth'); const { UrlHelper } = require('./urlHelper'); let options = { method: 'POST', body: new URLSearchParams({ client_id: '0oakpjijng7IHLqNQ5d7', client_secret: 'aGhK63MZX2S_Cr0xVGGme-BTBNXCwmopR-JiI11SPvn1HcOsOQ0d9UX964enO6Ql', username: 'gary+okta1@ubiqsecurity.com', password: 'Stella123$', grant_type: 'password', scope: 'openid offline_access okta.users.read okta.groups.read' }).toString(), headers: { Accept: 'application/json', 'Cache-control': 'no-cache', 'Content-type': 'application/x-www-form-urlencoded', }} let response = await fetch("https://dev-68866100.okta.com/oauth2/v1/token", options); https://api.ubiqsecurity.com/e1993087-070d-439e-9d4c-8eba88cdec54/api/v3/scim npm test -- --loglevel=silly --verbose node 16 npm install npm test PASS tests/UbiqSecurityLoadTest.test.js (5.646 s) ✓ LoadTest (4256 ms) PASS tests/UbiqSecurityEncryptDecrypt.test.js (18.262 s) ✓ Test_small (2836 ms) ✓ Test_block_size (2379 ms) ✓ Test_block_size_2xm1 (3320 ms) ✓ Test_block_size_2x (2302 ms) ✓ Test_block_size_2xp1 (2382 ms) ✓ Unstructured_GetCopyOfUsage (1194 ms) ✓ Unstructured_GetCopyOfUsage_Missing (1225 ms) ✓ Unstructured_GetCopyOfUsage_Minutes (1260 ms) ✓ Configuration_default (1 ms) ✓ Configuration_file (1 ms) ✓ Credentials ✓ Credentials_env (1 ms) ✓ Credentials_no_idp (1 ms) PASS tests/UbiqSecurityStucturedEncryptDecrypt.test.js (66.18 s) ✓ ALPHANUM_SSN_Success (8653 ms) ✓ BIRTH_DATE_Success (7511 ms) ✓ SSN_Success (8848 ms) ✓ UTF8_STRING_COMPLEX_Success (10894 ms) ✓ UTF8_STRING_COMPLEX_2_Success (9829 ms) ✓ BULK_INVALID_ffs (412 ms) ✓ SIMPLE_INVALID_ffs (188 ms) ✓ BULK_INVALID_pt_ct (1040 ms) ✓ SIMPLE_INVALID_pt_ct (724 ms) ✓ BULK_INVALID_len (956 ms) ✓ SIMPLE_INVALID_len (1672 ms) ✓ BULK_INVALID_keynum (1023 ms) ✓ SIMPLE_INVALID_keynum (1564 ms) ✓ BULK_cached (899 ms) ✓ BULK_cached_2 (931 ms) ✓ MIXED_forward (2055 ms) ✓ MIXED_backward (2256 ms) ✓ CREDS_invalid_papi (532 ms) ✓ CREDS_invalid_sapi (233 ms) ✓ CREDS_invalid_rsa (1159 ms) ✓ CREDS_invalid_host (66 ms) ✓ BULK_INVALID_creds (32 ms) ✓ addUserDefinedMetdata_InvalidJson (2 ms) ✓ addUserDefinedMetdata_EmptyString (2 ms) ✓ addUserDefinedMetdata_MissingJson (1 ms) ✓ addUserDefinedMetdata_RandomJson (1 ms) ✓ addUserDefinedMetdata_LongJson (2 ms) ✓ addUserDefinedMetdata_EmptyJson (1 ms) ✓ addUserDefinedMetdata_ValidJson (1 ms) ✓ Structured_GetCopyOfUsage_Minutes (1243 ms) ✓ Structured_GetCopyOfUsage_DAYS (1024 ms) ✓ Structured_GetCopyOfUsage_Missing (1022 ms) Test Suites: 5 passed, 5 total Tests: 73 passed, 73 total Snapshots: 0 total Time: 66.359 s node 20 npm install npm audit fix - 3 still npm test PASS tests/UbiqSecurityLoadTest.test.js ✓ LoadTest (3933 ms) PASS tests/UbiqSecurityEncryptDecrypt.test.js (13.331 s) ✓ Test_small (2604 ms) ✓ Test_block_size (1812 ms) ✓ Test_block_size_2xm1 (2053 ms) ✓ Test_block_size_2x (1802 ms) ✓ Test_block_size_2xp1 (1822 ms) ✓ Unstructured_GetCopyOfUsage (940 ms) ✓ Unstructured_GetCopyOfUsage_Missing (913 ms) ✓ Unstructured_GetCopyOfUsage_Minutes (898 ms) ✓ Configuration_default ✓ Configuration_file (1 ms) ✓ Credentials (1 ms) ✓ Credentials_env ✓ Credentials_no_idp PASS tests/UbiqSecurityStucturedEncryptDecrypt.test.js (43.276 s) ✓ ALPHANUM_SSN_Success (6513 ms) ✓ BIRTH_DATE_Success (5722 ms) ✓ SSN_Success (5949 ms) ✓ UTF8_STRING_COMPLEX_Success (7067 ms) ✓ UTF8_STRING_COMPLEX_2_Success (6425 ms) ✓ BULK_INVALID_ffs (157 ms) ✓ SIMPLE_INVALID_ffs (203 ms) ✓ BULK_INVALID_pt_ct (645 ms) ✓ SIMPLE_INVALID_pt_ct (584 ms) ✓ BULK_INVALID_len (515 ms) ✓ SIMPLE_INVALID_len (1010 ms) ✓ BULK_INVALID_keynum (697 ms) ✓ SIMPLE_INVALID_keynum (1228 ms) ✓ BULK_cached (566 ms) ✓ BULK_cached_2 (514 ms) ✓ MIXED_forward (1142 ms) ✓ MIXED_backward (1131 ms) ✓ CREDS_invalid_papi (362 ms) ✓ CREDS_invalid_sapi (104 ms) ✓ CREDS_invalid_rsa (654 ms) ✓ CREDS_invalid_host (63 ms) ✓ BULK_INVALID_creds (36 ms) ✓ addUserDefinedMetdata_InvalidJson (2 ms) ✓ addUserDefinedMetdata_EmptyString (1 ms) ✓ addUserDefinedMetdata_MissingJson (1 ms) ✓ addUserDefinedMetdata_RandomJson (1 ms) ✓ addUserDefinedMetdata_LongJson ✓ addUserDefinedMetdata_EmptyJson ✓ addUserDefinedMetdata_ValidJson (1 ms) ✓ Structured_GetCopyOfUsage_Minutes (489 ms) ✓ Structured_GetCopyOfUsage_DAYS (480 ms) ✓ Structured_GetCopyOfUsage_Missing (504 ms) Test Suites: 5 passed, 5 total Tests: 73 passed, 73 total Snapshots: 0 total Time: 43.437 s node 22 PASS tests/UbiqSecurityLoadTest.test.js (44.298 s) ✓ LoadTest (43825 ms) PASS tests/UbiqSecurityEncryptDecrypt.test.js (279.832 s) ✓ Test_small (44113 ms) ✓ Test_block_size (42708 ms) ✓ Test_block_size_2xm1 (41822 ms) ✓ Test_block_size_2x (41800 ms) ✓ Test_block_size_2xp1 (46694 ms) ✓ Unstructured_GetCopyOfUsage (21070 ms) ✓ Unstructured_GetCopyOfUsage_Missing (20521 ms) ✓ Unstructured_GetCopyOfUsage_Minutes (20642 ms) ✓ Configuration_default ✓ Configuration_file (1 ms) ✓ Credentials (1 ms) ✓ Credentials_env ✓ Credentials_no_idp PASS tests/UbiqSecurityStucturedEncryptDecrypt.test.js (817.66 s) ✓ ALPHANUM_SSN_Success (126269 ms) ✓ BIRTH_DATE_Success (127535 ms) ✓ SSN_Success (114407 ms) ✓ UTF8_STRING_COMPLEX_Success (140284 ms) ✓ UTF8_STRING_COMPLEX_2_Success (138834 ms) ✓ BULK_INVALID_ffs (269 ms) ✓ SIMPLE_INVALID_ffs (206 ms) ✓ BULK_INVALID_pt_ct (10920 ms) ✓ SIMPLE_INVALID_pt_ct (9895 ms) ✓ BULK_INVALID_len (10050 ms) ✓ SIMPLE_INVALID_len (21976 ms) ✓ BULK_INVALID_keynum (10483 ms) ✓ SIMPLE_INVALID_keynum (18934 ms) ✓ BULK_cached (9337 ms) ✓ BULK_cached_2 (9450 ms) ✓ MIXED_forward (19778 ms) ✓ MIXED_backward (18961 ms) ✓ CREDS_invalid_papi (170 ms) ✓ CREDS_invalid_sapi (109 ms) ✓ CREDS_invalid_rsa (501 ms) ✓ CREDS_invalid_host (73 ms) ✓ BULK_INVALID_creds (34 ms) ✓ addUserDefinedMetdata_InvalidJson (2 ms) ✓ addUserDefinedMetdata_EmptyString (1 ms) ✓ addUserDefinedMetdata_MissingJson (1 ms) ✓ addUserDefinedMetdata_RandomJson (1 ms) ✓ addUserDefinedMetdata_LongJson (2 ms) ✓ addUserDefinedMetdata_EmptyJson (1 ms) ✓ addUserDefinedMetdata_ValidJson (1 ms) ✓ Structured_GetCopyOfUsage_Minutes (9643 ms) ✓ Structured_GetCopyOfUsage_DAYS (9667 ms) ✓ Structured_GetCopyOfUsage_Missing (9396 ms) Test Suites: 5 passed, 5 total Tests: 73 passed, 73 total Snapshots: 0 total Time: 817.863 s node 24 npm test npm test -- -t "Test_small" --loglevel=silly --verbose -- -t 'addUserDefinedMetdata'