-
Notifications
You must be signed in to change notification settings - Fork 37
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
DIDComm alignment: expires_time & created_time #288
Conversation
src/iden3comm/handlers/payment.ts
Outdated
@@ -310,6 +312,12 @@ export class PaymentHandler | |||
paymentRequest: PaymentRequestMessage, | |||
ctx: PaymentRequestMessageHandlerOptions | |||
): Promise<BasicMessage | null> { | |||
if ( |
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.
A lot of code duplication. Can we do something like that:
package common
mustNotExpired = (obj: {expires_time?: number})) => {
if paymentRequest?.expires_time && paymentRequest.expires_time < Math.floor(Date.now() / 1000)
throw new Error
}
Usage:
common.MustNotExpired(offer)
or
common.MustNotExpired(proposal)
...
My idea is have a utility function that consumes interface with optional field expires_time and does some logic
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.
done
src/iden3comm/handlers/auth.ts
Outdated
@@ -315,6 +316,7 @@ export class AuthHandler | |||
ctx: AuthRespOptions | |||
): Promise<BasicMessage | null> { | |||
const request = ctx.request; | |||
verifyExpiresTime(response); |
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.
we need to add option to the handler - allowExpiredMessages.
source:
However, protocols can nuance this in their formal spec. For example, an online auction protocol might specify that timed out bids must be ignored instead of triggering a cancellation of the whole auction
/** | ||
* Basic message with all possible fields required | ||
*/ | ||
export type RequiredBasicMessage = Omit<Required<BasicMessage>, 'created_time' | 'expires_time'> & { |
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.
what is that?
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.
Required makes all optional fields required, and we need all required except created_time
and expires_time
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.
body is also can be optional. Why do we need this at all
No description provided.