-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(backend): add Open Payments client service #595
Conversation
@@ -50,6 +50,7 @@ | |||
nonceRedisKey: envString('NONCE_REDIS_KEY', 'nonceToProject'), | |||
adminKey: envString('ADMIN_KEY', 'qwertyuiop1234567890'), | |||
sessionLength: envInt('SESSION_LENGTH', 30), // in minutes | |||
devAccessToken: envString('DEV_ACCESS_TOKEN', 'dev-access-token'), |
Check failure
Code scanning / CodeQL
Hard-coded credentials
77d48a9
to
06351f0
Compare
Update ilp-packet version to match types.
Replace calls to Pay.setupPayment Downgrade axios to v0.26.1
06351f0
to
5d7c193
Compare
@@ -134,6 +141,13 @@ export class IncomingPayment | |||
return `${this.paymentPointer.url}/incoming-payments/${this.id}` | |||
} | |||
|
|||
public get hasConnection(): boolean { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An alternative to this would be to set connectionId
to null
when the incoming payment transitions to Completed
/Expired
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that would be cleaner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 I'll change it.
My only reservation is if we don't want to lose record of the connectionId
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any admin purpose we can think of where it would be beneficial to get the ilp credentials after the payment is completed
or expired
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not returning the connection with a completed/expired payment is an Open Payments OpenAPI thing.
It would technically still be possible to generate ilp credentials for the incoming payment since the connectionId
use only used for the connection url:
https://github.com/interledger/rafiki/pull/595/files#diff-b9b1a593e29f9fdc18a9826d0da73d506ccca8cca9e777165b4ac86b5a0bfdd5R72
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know it's an OP thing. I just checked the code again and remembered that it is something completely artificial that's not even used to create the STREAM credentials. In that case, set it to null
.
const validateResponse = | ||
deps_.openApi.createResponseValidator<IncomingPaymentJSON>({ | ||
path: '/incoming-payments/{incomingPaymentId}', | ||
method: HttpMethod.GET | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does that have to be overwritten?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
validateResponse
isn't included on deps_
.
Or are you asking why define a response validator that should already exist in a validator middleware?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the latter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔
Nothing is being overwritten.
Both this and the auth middleware (only for the get incoming payment route) will each create the same response validator once.
However, the auth middleware does not create response validators when running in production:
https://github.com/interledger/rafiki/blob/main/packages/openapi/src/middleware.ts#L11-L12
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never mind, I misread.
} | ||
} | ||
|
||
export async function getIncomingPayment( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we check whether the incoming payment is a resource on the same Rafiki instance and if so, we just use the service to get it instead of the axios call + all the validation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I initially tried that but didn't like having two code paths, one dealing with IncomingPayments
model and the other dealing with IncomingPaymentJSON
, the former of which duplicated a lot of functionality in middleware and incoming payments routes.ts
, including the solution for #598
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, we keep it simple then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks up local incoming payments / connections and keeps it simpler by calling the route methods:
@@ -134,6 +141,13 @@ export class IncomingPayment | |||
return `${this.paymentPointer.url}/incoming-payments/${this.id}` | |||
} | |||
|
|||
public get hasConnection(): boolean { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that would be cleaner.
Remove publicHost from OutgoingPaymentService.
Changes proposed in this pull request
Pay.setupPayment
ilpStreamConnection
typeilp-packet
to pre-release version to match types of other interledgerjs dependencies.axios
Context
Checklist
fixes #number