Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
6 changes: 5 additions & 1 deletion test/helpers/helpers.mock-rest-v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}]
]))

Expand Down
8 changes: 8 additions & 0 deletions test/helpers/mock-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
42 changes: 42 additions & 0 deletions test/test-cases/api-sync-mode-sqlite-test-cases.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
7 changes: 5 additions & 2 deletions workers/api.framework.report.wrk.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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(
Expand All @@ -40,7 +43,7 @@ module.exports = (
}]
)

queue.emit('progress', 100)
queue.emit(QUEUE_EVENT_NAMES.PROGRESS, 100)

return
}
Expand Down Expand Up @@ -173,5 +176,5 @@ module.exports = (
]
)

queue.emit('progress', 100)
queue.emit(QUEUE_EVENT_NAMES.PROGRESS, 100)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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(
Expand All @@ -41,7 +44,7 @@ module.exports = (
}]
)

queue.emit('progress', 100)
queue.emit(QUEUE_EVENT_NAMES.PROGRESS, 100)

return
}
Expand Down Expand Up @@ -206,5 +209,5 @@ module.exports = (
]
)

queue.emit('progress', 100)
queue.emit(QUEUE_EVENT_NAMES.PROGRESS, 100)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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(
Expand All @@ -46,7 +49,7 @@ module.exports = (
}]
)

queue.emit('progress', 100)
queue.emit(QUEUE_EVENT_NAMES.PROGRESS, 100)

return
}
Expand Down Expand Up @@ -108,5 +111,5 @@ ${i18next.t('template.delistedCcyMessageEnd', transOpts)}\
csvStreamDataMap
)

queue.emit('progress', 100)
queue.emit(QUEUE_EVENT_NAMES.PROGRESS, 100)
}
10 changes: 10 additions & 0 deletions workers/loc.api/http.request/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 14 additions & 0 deletions workers/loc.api/service.report.framework.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down