diff --git a/package-lock.json b/package-lock.json index 0e19e7fe..1a683144 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "@protobuf-ts/grpc-transport": "^2.9.4", "@protobuf-ts/plugin": "^2.5.0", "@protobuf-ts/runtime": "^2.5.0", - "@shocknet/clink-sdk": "^1.1.7", + "@shocknet/clink-sdk": "^1.3.1", "@stablelib/xchacha20": "^1.0.1", "@types/express": "^4.17.21", "@types/node": "^17.0.31", diff --git a/package.json b/package.json index f78f79e0..2f7b12c2 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "@protobuf-ts/grpc-transport": "^2.9.4", "@protobuf-ts/plugin": "^2.5.0", "@protobuf-ts/runtime": "^2.5.0", - "@shocknet/clink-sdk": "^1.1.7", + "@shocknet/clink-sdk": "^1.3.1", "@stablelib/xchacha20": "^1.0.1", "@types/express": "^4.17.21", "@types/node": "^17.0.31", diff --git a/src/services/main/debitManager.ts b/src/services/main/debitManager.ts index 951b35d6..45ef8457 100644 --- a/src/services/main/debitManager.ts +++ b/src/services/main/debitManager.ts @@ -8,7 +8,7 @@ import { Application } from '../storage/entity/Application.js'; import { ApplicationUser } from '../storage/entity/ApplicationUser.js'; import { NostrEvent, NostrSend, SendData, SendInitiator } from '../nostr/handler.js'; import { UnsignedEvent } from 'nostr-tools'; -import { NdebitData, NdebitFailure, NdebitSuccess, NdebitSuccessPayment, RecurringDebitTimeUnit } from "@shocknet/clink-sdk"; +import { NdebitData, NdebitFailure, NdebitSuccess, RecurringDebitTimeUnit } from "@shocknet/clink-sdk"; export const expirationRuleName = 'expiration' export const frequencyRuleName = 'frequency' @@ -100,7 +100,7 @@ const nip68errs = { 6: "Invalid Request", } type HandleNdebitRes = { status: 'fail', debitRes: NdebitFailure } - | { status: 'invoicePaid', op: Types.UserOperation, app: Application, appUser: ApplicationUser, debitRes: NdebitSuccessPayment } + | { status: 'invoicePaid', op: Types.UserOperation, app: Application, appUser: ApplicationUser, debitRes: NdebitSuccess } | { status: 'authRequired', liveDebitReq: Types.LiveDebitRequest, app: Application, appUser: ApplicationUser } | { status: 'authOk', debitRes: NdebitSuccess } export class DebitManager { @@ -181,7 +181,7 @@ export class DebitManager { const app = await this.storage.applicationStorage.GetApplication(ctx.app_id) const appUser = await this.storage.applicationStorage.GetApplicationUser(app, ctx.app_user_id) const { op, payment } = await this.sendDebitPayment(ctx.app_id, ctx.app_user_id, req.npub, req.response.invoice) - const debitRes: NdebitSuccessPayment = { res: 'ok', preimage: payment.preimage } + const debitRes: NdebitSuccess = { res: 'ok', preimage: payment.preimage } this.notifyPaymentSuccess(appUser, debitRes, op, { appId: ctx.app_id, pub: req.npub, id: req.request_id }) return default: @@ -211,7 +211,7 @@ export class DebitManager { this.notifyPaymentSuccess(appUser, debitRes, op, event) } - notifyPaymentSuccess = (appUser: ApplicationUser, debitRes: NdebitSuccessPayment, op: Types.UserOperation, event: { pub: string, id: string, appId: string }) => { + notifyPaymentSuccess = (appUser: ApplicationUser, debitRes: NdebitSuccess, op: Types.UserOperation, event: { pub: string, id: string, appId: string }) => { const message: Types.LiveUserOperation & { requestId: string, status: 'OK' } = { operation: op, requestId: "GetLiveUserOperations", status: 'OK' } if (appUser.nostr_public_key) { // TODO - fix before support for http streams this.nostrSend({ type: 'app', appId: event.appId }, { type: 'content', content: JSON.stringify(message), pub: appUser.nostr_public_key }) @@ -219,7 +219,7 @@ export class DebitManager { this.sendDebitResponse(debitRes, event) } - sendDebitResponse = (debitRes: NdebitFailure | NdebitSuccess | NdebitSuccessPayment, event: { pub: string, id: string, appId: string }) => { + sendDebitResponse = (debitRes: NdebitFailure | NdebitSuccess, event: { pub: string, id: string, appId: string }) => { const e = newNdebitResponse(JSON.stringify(debitRes), event) this.nostrSend({ type: 'app', appId: event.appId }, { type: 'event', event: e, encrypt: { toPub: event.pub } }) } diff --git a/src/services/main/offerManager.ts b/src/services/main/offerManager.ts index 7de2470b..2601ebf0 100644 --- a/src/services/main/offerManager.ts +++ b/src/services/main/offerManager.ts @@ -165,7 +165,7 @@ export class OfferManager { } async HandleDefaultUserOffer(offerReq: NofferData, appId: string, remote: number): Promise<{ success: true, invoice: string } | { success: false, code: number, max: number }> { - const { amount, offer } = offerReq + const { amount_sats: amount, offer } = offerReq if (!amount || isNaN(amount) || amount < 10 || amount > remote) { return { success: false, code: 5, max: remote } } @@ -178,7 +178,7 @@ export class OfferManager { } async HandleUserOffer(offerReq: NofferData, appId: string, remote: number): Promise<{ success: true, invoice: string } | { success: false, code: number, max: number }> { - const { amount, offer } = offerReq + const { amount_sats: amount, offer } = offerReq const userOffer = await this.storage.offerStorage.GetOffer(offer) if (!userOffer) { return this.HandleDefaultUserOffer(offerReq, appId, remote)