always use the new id

This commit is contained in:
boufni95 2023-10-27 20:05:25 +02:00
parent 960e928cbc
commit c7303ca5dd
6 changed files with 2094 additions and 2096 deletions

View file

@ -95,9 +95,9 @@ The nostr server will send back a message response, and inside the body there wi
- __User__:
- expected context content
- __user_id__: _string_
- __app_id__: _string_
- __app_user_id__: _string_
- __user_id__: _string_
- __Admin__:
- expected context content
@ -372,62 +372,22 @@ The nostr server will send back a message response, and inside the body there wi
## Messages
### The content of requests and response from the methods
### AddAppRequest
- __name__: _string_
- __allow_user_creation__: _boolean_
### GetAppUserLNURLInfoRequest
- __user_identifier__: _string_
- __base_url_override__: _string_
### DecodeInvoiceRequest
- __invoice__: _string_
### DecodeInvoiceResponse
- __amount__: _number_
### LnurlPayInfoResponse
- __tag__: _string_
- __callback__: _string_
- __maxSendable__: _number_
- __minSendable__: _number_
- __metadata__: _string_
### AddProductRequest
- __name__: _string_
- __price_sats__: _number_
### EncryptionExchangeRequest
- __publicKey__: _string_
- __deviceId__: _string_
### LndGetInfoRequest
- __nodeId__: _number_
### OpenChannelResponse
- __channelId__: _string_
### GetUserOperationsResponse
- __latestOutgoingInvoiceOperations__: _[UserOperations](#UserOperations)_
- __latestIncomingInvoiceOperations__: _[UserOperations](#UserOperations)_
- __latestOutgoingTxOperations__: _[UserOperations](#UserOperations)_
- __latestIncomingTxOperations__: _[UserOperations](#UserOperations)_
- __latestOutgoingUserToUserPayemnts__: _[UserOperations](#UserOperations)_
- __latestIncomingUserToUserPayemnts__: _[UserOperations](#UserOperations)_
### Application
- __name__: _string_
- __id__: _string_
- __balance__: _number_
- __npub__: _string_
### GetAppUserRequest
- __user_identifier__: _string_
### PayAppUserInvoiceRequest
- __user_identifier__: _string_
- __invoice__: _string_
- __amount__: _number_
### NewInvoiceResponse
- __invoice__: _string_
### OpenChannelResponse
- __channelId__: _string_
### LnurlLinkResponse
- __lnurl__: _string_
@ -438,40 +398,28 @@ The nostr server will send back a message response, and inside the body there wi
- __balance__: _number_
- __max_withdrawable__: _number_
### SendAppUserToAppUserPaymentRequest
- __from_user_identifier__: _string_
- __to_user_identifier__: _string_
- __amount__: _number_
### SetMockAppBalanceRequest
- __amount__: _number_
### NewAddressResponse
- __address__: _string_
### PayAddressResponse
- __txId__: _string_
### PayInvoiceRequest
- __invoice__: _string_
- __amount__: _number_
### GetUserOperationsRequest
- __latestIncomingInvoice__: _number_
- __latestOutgoingInvoice__: _number_
- __latestIncomingTx__: _number_
- __latestOutgoingTx__: _number_
- __latestIncomingUserToUserPayment__: _number_
- __latestOutgoingUserToUserPayment__: _number_
### LiveUserOperation
- __id__: _string_
- __operation__: _[UserOperation](#UserOperation)_
### PayAppUserInvoiceResponse
- __preimage__: _string_
- __amount_paid__: _number_
### SetMockInvoiceAsPaidRequest
- __invoice__: _string_
- __amount__: _number_
### SetMockAppUserBalanceRequest
- __user_identifier__: _string_
- __amount__: _number_
### AddAppInvoiceRequest
- __payer_identifier__: _string_
- __http_callback_url__: _string_
- __invoice_req__: _[NewInvoiceRequest](#NewInvoiceRequest)_
### NewInvoiceResponse
- __invoice__: _string_
### LnurlWithdrawInfoResponse
- __tag__: _string_
@ -483,15 +431,20 @@ The nostr server will send back a message response, and inside the body there wi
- __balanceCheck__: _string_
- __payLink__: _string_
### PayInvoiceResponse
- __preimage__: _string_
- __amount_paid__: _number_
### GetProductBuyLinkResponse
- __link__: _string_
### OpenChannelRequest
- __destination__: _string_
- __fundingAmount__: _number_
- __pushAmount__: _number_
- __closeAddress__: _string_
### AddAppUserRequest
- __identifier__: _string_
- __fail_if_exists__: _boolean_
- __balance__: _number_
### NewAddressRequest
- __addressType__: _[AddressType](#AddressType)_
### PayInvoiceRequest
- __invoice__: _string_
- __amount__: _number_
### UserOperation
- __paidAtUnix__: _number_
@ -500,6 +453,62 @@ The nostr server will send back a message response, and inside the body there wi
- __amount__: _number_
- __identifier__: _string_
### PayAddressRequest
- __address__: _string_
- __amoutSats__: _number_
- __satsPerVByte__: _number_
### OpenChannelRequest
- __destination__: _string_
- __fundingAmount__: _number_
- __pushAmount__: _number_
- __closeAddress__: _string_
### HandleLnurlPayResponse
- __pr__: _string_
- __routes__: ARRAY of: _[Empty](#Empty)_
### GetAppUserLNURLInfoRequest
- __user_identifier__: _string_
- __base_url_override__: _string_
### SetMockAppBalanceRequest
- __amount__: _number_
### PayInvoiceResponse
- __preimage__: _string_
- __amount_paid__: _number_
### LnurlPayInfoResponse
- __tag__: _string_
- __callback__: _string_
- __maxSendable__: _number_
- __minSendable__: _number_
- __metadata__: _string_
### GetUserOperationsResponse
- __latestOutgoingInvoiceOperations__: _[UserOperations](#UserOperations)_
- __latestIncomingInvoiceOperations__: _[UserOperations](#UserOperations)_
- __latestOutgoingTxOperations__: _[UserOperations](#UserOperations)_
- __latestIncomingTxOperations__: _[UserOperations](#UserOperations)_
- __latestOutgoingUserToUserPayemnts__: _[UserOperations](#UserOperations)_
- __latestIncomingUserToUserPayemnts__: _[UserOperations](#UserOperations)_
### Empty
### AuthApp
- __app__: _[Application](#Application)_
- __auth_token__: _string_
### SendAppUserToAppUserPaymentRequest
- __from_user_identifier__: _string_
- __to_user_identifier__: _string_
- __amount__: _number_
### AddProductRequest
- __name__: _string_
- __price_sats__: _number_
### UserOperations
- __fromIndex__: _number_
- __toIndex__: _number_
@ -510,72 +519,63 @@ The nostr server will send back a message response, and inside the body there wi
- __name__: _string_
- __price_sats__: _number_
### GetProductBuyLinkResponse
- __link__: _string_
### Empty
### NewAddressRequest
- __addressType__: _[AddressType](#AddressType)_
### AuthApp
- __app__: _[Application](#Application)_
- __auth_token__: _string_
### GetAppUserRequest
- __user_identifier__: _string_
### SendAppUserToAppPaymentRequest
- __from_user_identifier__: _string_
- __amount__: _number_
### PayAddressRequest
- __address__: _string_
- __amoutSats__: _number_
- __satsPerVByte__: _number_
### NewInvoiceRequest
- __amountSats__: _number_
- __memo__: _string_
### GetUserOperationsRequest
- __latestIncomingInvoice__: _number_
- __latestOutgoingInvoice__: _number_
- __latestIncomingTx__: _number_
- __latestOutgoingTx__: _number_
- __latestIncomingUserToUserPayment__: _number_
- __latestOutgoingUserToUserPayment__: _number_
### SetMockInvoiceAsPaidRequest
- __invoice__: _string_
- __amount__: _number_
### LndGetInfoResponse
- __alias__: _string_
### EncryptionExchangeRequest
- __publicKey__: _string_
- __deviceId__: _string_
### AppUser
- __identifier__: _string_
- __info__: _[UserInfo](#UserInfo)_
- __max_withdrawable__: _number_
### NewAddressResponse
- __address__: _string_
### AddAppUserInvoiceRequest
- __receiver_identifier__: _string_
- __payer_identifier__: _string_
- __http_callback_url__: _string_
- __invoice_req__: _[NewInvoiceRequest](#NewInvoiceRequest)_
### HandleLnurlPayResponse
- __pr__: _string_
- __routes__: ARRAY of: _[Empty](#Empty)_
### PayAppUserInvoiceResponse
- __preimage__: _string_
- __amount_paid__: _number_
### SendAppUserToAppPaymentRequest
- __from_user_identifier__: _string_
- __amount__: _number_
### PayAddressResponse
- __txId__: _string_
### NewInvoiceRequest
- __amountSats__: _number_
- __memo__: _string_
### LndGetInfoRequest
- __nodeId__: _number_
### AddAppRequest
- __name__: _string_
- __allow_user_creation__: _boolean_
### AuthAppRequest
- __name__: _string_
- __allow_user_creation__: _boolean_ *this field is optional
### AddAppUserRequest
- __identifier__: _string_
- __fail_if_exists__: _boolean_
- __balance__: _number_
### DecodeInvoiceRequest
- __invoice__: _string_
### DecodeInvoiceResponse
- __amount__: _number_
### LndGetInfoResponse
- __alias__: _string_
### AddAppInvoiceRequest
- __payer_identifier__: _string_
- __http_callback_url__: _string_
- __invoice_req__: _[NewInvoiceRequest](#NewInvoiceRequest)_
## Enums
### The enumerators used in the messages

File diff suppressed because it is too large Load diff

View file

@ -208,7 +208,7 @@ export default (params: NostrClientParams, send: (to:string, message: NostrRequ
if (data.status === 'ERROR' && typeof data.reason === 'string') return cb(data)
if (data.status === 'OK') {
const result = data
if(!params.checkResult) return { status: 'OK', ...result }
if(!params.checkResult) return cb({ status: 'OK', ...result })
const error = Types.LiveUserOperationValidate(result)
if (error === null) { return cb({ status: 'OK', ...result }) } else return cb({ status: 'ERROR', reason: error.message })
}

File diff suppressed because it is too large Load diff

Binary file not shown.

View file

@ -133,15 +133,13 @@ export default class {
const sub = this.paymentSubs[ctx.user_id]
const app = await this.storage.applicationStorage.GetApplication(ctx.app_id)
const log = getLogger({ appName: app.name, userId: ctx.user_id })
if (sub) {
log("user already subbed to payment")
return
}
log("subbing user to payment")
await this.storage.applicationStorage.GetApplicationUser(app, ctx.app_user_id)
cb({ id: "10000", operation: { amount: 69, identifier: "tha invoice", inbound: true, paidAtUnix: 10, type: Types.UserOperationType.INCOMING_INVOICE } }, null)
if (sub) {
log("overriding user payment stream")
}
this.paymentSubs[ctx.user_id] = (op) => {
const rand = crypto.randomBytes(32).toString('hex')
const rand = crypto.randomBytes(16).toString('hex')
cb({ id: rand, operation: op }, null)
}
}