diff --git a/bfx-report-ui b/bfx-report-ui index 8dfdab80..078a7037 160000 --- a/bfx-report-ui +++ b/bfx-report-ui @@ -1 +1 @@ -Subproject commit 8dfdab804b0b78740ec304d60820a2d6c69bd3b8 +Subproject commit 078a70373b3d31d8d637e1713f0f8d141d4739ca diff --git a/package-lock.json b/package-lock.json index aae41fc2..3a7b30bf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@bitfinex/bfx-reports-framework", - "version": "5.2.1", + "version": "5.3.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@bitfinex/bfx-reports-framework", - "version": "5.2.1", + "version": "5.3.0", "license": "Apache-2.0", "dependencies": { "@bitfinex/bfx-facs-db-better-sqlite": "git+https://github.com/bitfinexcom/bfx-facs-db-better-sqlite.git", @@ -234,8 +234,8 @@ } }, "node_modules/@bitfinex/bfx-report": { - "version": "5.2.1", - "resolved": "git+ssh://git@github.com/bitfinexcom/bfx-report.git#c07b646d9493660c18a554448f2831cb4718d5bf", + "version": "5.2.2", + "resolved": "git+ssh://git@github.com/bitfinexcom/bfx-report.git#83ab7eed8a44361a94205a8e7895d03b3e61cc07", "license": "Apache-2.0", "dependencies": { "@bitfinex/bfx-facs-deflate": "git+https://github.com/bitfinexcom/bfx-facs-deflate.git", diff --git a/package.json b/package.json index 934a4406..4cd039f6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bitfinex/bfx-reports-framework", - "version": "5.2.1", + "version": "5.3.0", "description": "Bitfinex reports framework", "main": "worker.js", "engines": { diff --git a/test/helpers/helpers.mock-rest-v2.js b/test/helpers/helpers.mock-rest-v2.js index 8b892fee..6a3857fa 100644 --- a/test/helpers/helpers.mock-rest-v2.js +++ b/test/helpers/helpers.mock-rest-v2.js @@ -50,13 +50,17 @@ const getMockDataOpts = () => ({ delete_token: null, login: null, login_verify: null, + captcha_providers: null, + captcha_required: null, platform_status: null }) const getExtraMockMethods = () => (new Map([ ['post', { '/v2/login': 'login', - '/v2/login/verify': 'login_verify' + '/v2/login/verify': 'login_verify', + '/v2/int/captcha/providers': 'captcha_providers', + '/v2/int/captcha/required': 'captcha_required' }] ])) diff --git a/test/helpers/mock-data.js b/test/helpers/mock-data.js index 66de8e8f..44313c85 100644 --- a/test/helpers/mock-data.js +++ b/test/helpers/mock-data.js @@ -25,6 +25,14 @@ module.exports = new Map([ '2023-03-21T12:00:00.000Z' ] ], + [ + 'captcha_providers', + ['hcaptcha'] + ], + [ + 'captcha_required', + true + ], [ 'generate_token', ['pub:api:88888888-4444-4444-4444-121212121212-caps:s:o:f:w:wd:a-write'] diff --git a/test/test-cases/api-sync-mode-sqlite-test-cases.js b/test/test-cases/api-sync-mode-sqlite-test-cases.js index b83f3c38..d41baded 100644 --- a/test/test-cases/api-sync-mode-sqlite-test-cases.js +++ b/test/test-cases/api-sync-mode-sqlite-test-cases.js @@ -175,6 +175,48 @@ module.exports = ( assert.isString(res.body.result[1]) }) + it('it should be successfully performed by the getCaptchaProviders method', async function () { + this.timeout(5000) + + const res = await agent + .post(`${basePath}/json-rpc`) + .type('json') + .send({ + method: 'getCaptchaProviders', + id: 5 + }) + .expect('Content-Type', /json/) + .expect(200) + + assert.isObject(res.body) + assert.propertyVal(res.body, 'id', 5) + assert.isArray(res.body.result) + assert.isString(res.body.result[0]) + assert.strictEqual(res.body.result[0], 'hcaptcha') + }) + + it('it should be successfully performed by the isCaptchaRequired method', async function () { + this.timeout(5000) + + const res = await agent + .post(`${basePath}/json-rpc`) + .type('json') + .send({ + method: 'isCaptchaRequired', + params: { + method: 'login' + }, + id: 5 + }) + .expect('Content-Type', /json/) + .expect(200) + + assert.isObject(res.body) + assert.propertyVal(res.body, 'id', 5) + assert.isBoolean(res.body.result) + assert.isOk(res.body.result) + }) + it('it should be successfully performed by the signIn method', async function () { this.timeout(5000) diff --git a/workers/api.framework.report.wrk.js b/workers/api.framework.report.wrk.js index 1fe06a69..e21646ca 100644 --- a/workers/api.framework.report.wrk.js +++ b/workers/api.framework.report.wrk.js @@ -39,6 +39,9 @@ const { PDFBufferUnderElectronCreationError, PDFBufferUnderFrameworkCreationError } = require('@bitfinex/bfx-report/workers/loc.api/errors') +const QUEUE_EVENT_NAMES = require( + '@bitfinex/bfx-report/workers/loc.api/queue/queue.event.names' +) const appDeps = require('./loc.api/di/app.deps') const TYPES = require('./loc.api/di/types') @@ -208,7 +211,7 @@ class WrkReportFrameWorkApi extends WrkReportServiceApi { await wsTransport.start() - processorQueue.on('error:base', (err, job) => { + processorQueue.on(QUEUE_EVENT_NAMES.ERROR_BASE, (err, job) => { if ( !(err instanceof PDFBufferUnderElectronCreationError) && !(err instanceof PDFBufferUnderFrameworkCreationError) @@ -223,7 +226,7 @@ class WrkReportFrameWorkApi extends WrkReportServiceApi { this.logger.error(`WS_EVENT_EMITTER:REPORT_FILE_FAILED: ${err.stack || err}`) }) }) - aggregatorQueue.on('completed', (res) => { + aggregatorQueue.on(QUEUE_EVENT_NAMES.COMPLETED, (res) => { const { reportFilesMetadata, csvFilesMetadata, // For compatibility with old implementation diff --git a/workers/loc.api/generate-report-file/csv-writer/full-snapshot-report-csv-writer.js b/workers/loc.api/generate-report-file/csv-writer/full-snapshot-report-csv-writer.js index c306d6c8..89a66fa6 100644 --- a/workers/loc.api/generate-report-file/csv-writer/full-snapshot-report-csv-writer.js +++ b/workers/loc.api/generate-report-file/csv-writer/full-snapshot-report-csv-writer.js @@ -9,6 +9,9 @@ const { const { omitExtraParamFieldsForReportExport } = require('@bitfinex/bfx-report/workers/loc.api/generate-report-file/helpers') +const QUEUE_EVENT_NAMES = require( + '@bitfinex/bfx-report/workers/loc.api/queue/queue.event.names' +) module.exports = ( rService, @@ -29,7 +32,7 @@ module.exports = ( ...args?.params } - queue.emit('progress', 0) + queue.emit(QUEUE_EVENT_NAMES.PROGRESS, 0) if (typeof jobData === 'string') { await streamWriter( @@ -40,7 +43,7 @@ module.exports = ( }] ) - queue.emit('progress', 100) + queue.emit(QUEUE_EVENT_NAMES.PROGRESS, 100) return } @@ -173,5 +176,5 @@ module.exports = ( ] ) - queue.emit('progress', 100) + queue.emit(QUEUE_EVENT_NAMES.PROGRESS, 100) } diff --git a/workers/loc.api/generate-report-file/csv-writer/full-tax-report-csv-writer.js b/workers/loc.api/generate-report-file/csv-writer/full-tax-report-csv-writer.js index 862adf8e..58f568ff 100644 --- a/workers/loc.api/generate-report-file/csv-writer/full-tax-report-csv-writer.js +++ b/workers/loc.api/generate-report-file/csv-writer/full-tax-report-csv-writer.js @@ -9,6 +9,9 @@ const { const { omitExtraParamFieldsForReportExport } = require('@bitfinex/bfx-report/workers/loc.api/generate-report-file/helpers') +const QUEUE_EVENT_NAMES = require( + '@bitfinex/bfx-report/workers/loc.api/queue/queue.event.names' +) module.exports = ( rService, @@ -30,7 +33,7 @@ module.exports = ( ...args?.params } - queue.emit('progress', 0) + queue.emit(QUEUE_EVENT_NAMES.PROGRESS, 0) if (typeof jobData === 'string') { await streamWriter( @@ -41,7 +44,7 @@ module.exports = ( }] ) - queue.emit('progress', 100) + queue.emit(QUEUE_EVENT_NAMES.PROGRESS, 100) return } @@ -206,5 +209,5 @@ module.exports = ( ] ) - queue.emit('progress', 100) + queue.emit(QUEUE_EVENT_NAMES.PROGRESS, 100) } diff --git a/workers/loc.api/generate-report-file/csv-writer/transaction-tax-report-csv-writer.js b/workers/loc.api/generate-report-file/csv-writer/transaction-tax-report-csv-writer.js index 40f55e18..9b6bfa13 100644 --- a/workers/loc.api/generate-report-file/csv-writer/transaction-tax-report-csv-writer.js +++ b/workers/loc.api/generate-report-file/csv-writer/transaction-tax-report-csv-writer.js @@ -12,6 +12,9 @@ const TRANSLATION_NAMESPACES = require( const { omitExtraParamFieldsForReportExport } = require('@bitfinex/bfx-report/workers/loc.api/generate-report-file/helpers') +const QUEUE_EVENT_NAMES = require( + '@bitfinex/bfx-report/workers/loc.api/queue/queue.event.names' +) module.exports = ( rService, @@ -35,7 +38,7 @@ module.exports = ( } const { language } = params ?? - queue.emit('progress', 0) + queue.emit(QUEUE_EVENT_NAMES.PROGRESS, 0) if (typeof jobData === 'string') { await streamWriter( @@ -46,7 +49,7 @@ module.exports = ( }] ) - queue.emit('progress', 100) + queue.emit(QUEUE_EVENT_NAMES.PROGRESS, 100) return } @@ -108,5 +111,5 @@ ${i18next.t('template.delistedCcyMessageEnd', transOpts)}\ csvStreamDataMap ) - queue.emit('progress', 100) + queue.emit(QUEUE_EVENT_NAMES.PROGRESS, 100) } diff --git a/workers/loc.api/http.request/index.js b/workers/loc.api/http.request/index.js index 50b65363..15a20535 100644 --- a/workers/loc.api/http.request/index.js +++ b/workers/loc.api/http.request/index.js @@ -56,6 +56,16 @@ class ExpandedRESTv2 extends RESTv2 { return makeRequestToBFX(() => this ._makePublicPostRequest('/login/verify', body)) } + + async getCaptchaProviders (body) { + return makeRequestToBFX(() => this + ._makePublicPostRequest('/int/captcha/providers', body)) + } + + async isCaptchaRequired (body) { + return makeRequestToBFX(() => this + ._makePublicPostRequest('/int/captcha/required', body)) + } } decorateInjectable(HTTPRequest, depsTypes) diff --git a/workers/loc.api/service.report.framework.js b/workers/loc.api/service.report.framework.js index feb95f69..77fecdcd 100644 --- a/workers/loc.api/service.report.framework.js +++ b/workers/loc.api/service.report.framework.js @@ -99,6 +99,20 @@ class FrameworkReportService extends ReportService { }, 'verifyOnBFX', args, cb) } + getCaptchaProviders (space, args, cb) { + return this._responder(() => { + return this._httpRequest.getRequest() + .getCaptchaProviders(args?.params) + }, 'getCaptchaProviders', args, cb) + } + + isCaptchaRequired (space, args, cb) { + return this._responder(() => { + return this._httpRequest.getRequest() + .isCaptchaRequired(args?.params) + }, 'isCaptchaRequired', args, cb) + } + isStagingBfxApi (space, args, cb) { return this._responder(() => { return this._authenticator.isStagingBfxApi()