File tree Expand file tree Collapse file tree
payment-method/ilp/connector/core/middleware Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -203,8 +203,6 @@ export const Config = {
203203 'SEND_TENANT_WEBHOOKS_TO_OPERATOR' ,
204204 false
205205 ) ,
206- // TODO Maybe rename?
207- enableKycAseDecision : envBool ( 'ENABLE_KYC_ASE_DECISION' , false ) ,
208206 kycAseDecisionUrl : process . env . KYC_ASE_DECISION_URL ,
209207 kycDecisionMaxWaitMs : envInt ( 'KYC_DECISION_MAX_WAIT_MS' , 1500 ) ,
210208 kycDecisionSafetyMarginMs : envInt ( 'KYC_DECISION_SAFETY_MARGIN_MS' , 100 )
Original file line number Diff line number Diff line change 1- import { Errors , IlpErrorCode } from 'ilp-packet'
1+ import { Errors } from 'ilp-packet'
22import { ILPContext , ILPMiddleware } from '../rafiki'
33import { StreamState } from './stream-address'
44
@@ -9,22 +9,14 @@ export function createKycDecisionMiddleware(): ILPMiddleware {
99 ) : Promise < void > => {
1010 const { config, logger, redis } = ctx . services
1111
12- // TODO This might not be needed? We should be able to just check the state.hasAdditionalData
13- // if (!config.enableKycAseDecision) {
14- // await next()
15- // return
16- // }
17-
18- logger . info ( 'KYC Decision Middleware, has additional data: ' + ctx . state . hasAdditionalData )
19-
2012 if ( ! ctx . state . streamDestination || ! ctx . state . hasAdditionalData ) {
2113 await next ( )
2214 return
2315 }
2416
2517 const incomingPaymentId = ctx . state . streamDestination
26- // TODO Maybe we should have a more `unique` key? Think of packet/stream id!!!
27- const cacheKey = `kyc_decision:${ incomingPaymentId } `
18+ const connectionId = ctx . state . connectionId ?? 'unknown'
19+ const cacheKey = `kyc_decision:${ incomingPaymentId } : ${ connectionId } `
2820
2921 // Bounded polling: wait for decision up to (packet expiry - safetyMs) or maxWaitMs
3022 const safetyMs = Number . isFinite ( config . kycDecisionSafetyMarginMs )
@@ -71,5 +63,3 @@ export function createKycDecisionMiddleware(): ILPMiddleware {
7163 )
7264 }
7365}
74-
75-
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ export interface StreamState {
77 streamDestination ?: string
88 streamServer ?: StreamServer
99 hasAdditionalData ?: boolean
10+ connectionId ?: string
1011}
1112
1213export function createStreamAddressMiddleware ( ) : ILPMiddleware {
@@ -47,7 +48,7 @@ export function createStreamAddressMiddleware(): ILPMiddleware {
4748 const payload = frames ?. length
4849 ? frames . find ( ( f ) => f . streamId === 1 ) ?. data ?? frames [ 0 ] . data
4950 : undefined
50-
51+
5152 if ( payload && payload . length > 0 ) {
5253 ctx . services . logger . info (
5354 { payload : payload . toString ( 'utf8' ) } ,
@@ -56,6 +57,9 @@ export function createStreamAddressMiddleware(): ILPMiddleware {
5657 }
5758
5859 ctx . state . hasAdditionalData = ! ! payload ?. length
60+ if ( typeof ( replyOrMoney as any ) . connectionId === 'string' ) {
61+ ctx . state . connectionId = ( replyOrMoney as any ) . connectionId
62+ }
5963 //TODO Here we should store STREAM data payload i.e. db call in webhook events table
6064 }
6165 } finally {
You can’t perform that action at this time.
0 commit comments