notification types and topic id
This commit is contained in:
parent
6aa90d63ba
commit
c146d46c59
12 changed files with 211 additions and 9 deletions
|
|
@ -62,6 +62,10 @@ import { TrackedProviderHeight1766504040000 } from './build/src/services/storage
|
||||||
import { SwapsServiceUrl1768413055036 } from './build/src/services/storage/migrations/1768413055036-swaps_service_url.js'
|
import { SwapsServiceUrl1768413055036 } from './build/src/services/storage/migrations/1768413055036-swaps_service_url.js'
|
||||||
import { InvoiceSwaps1769529793283 } from './build/src/services/storage/migrations/1769529793283-invoice_swaps.js'
|
import { InvoiceSwaps1769529793283 } from './build/src/services/storage/migrations/1769529793283-invoice_swaps.js'
|
||||||
import { InvoiceSwapsFixes1769805357459 } from './build/src/services/storage/migrations/1769805357459-invoice_swaps_fixes.js'
|
import { InvoiceSwapsFixes1769805357459 } from './build/src/services/storage/migrations/1769805357459-invoice_swaps_fixes.js'
|
||||||
|
import { ApplicationUserTopicId1770038768784 } from './build/src/services/storage/migrations/1770038768784-application_user_topic_id.js'
|
||||||
|
import { SwapTimestamps1771347307798 } from './build/src/services/storage/migrations/1771347307798-swap_timestamps.js'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export default new DataSource({
|
export default new DataSource({
|
||||||
type: "better-sqlite3",
|
type: "better-sqlite3",
|
||||||
|
|
@ -71,7 +75,9 @@ export default new DataSource({
|
||||||
PaymentIndex1721760297610, DebitAccess1726496225078, DebitAccessFixes1726685229264, DebitToPub1727105758354, UserCbUrl1727112281043,
|
PaymentIndex1721760297610, DebitAccess1726496225078, DebitAccessFixes1726685229264, DebitToPub1727105758354, UserCbUrl1727112281043,
|
||||||
UserOffer1733502626042, ManagementGrant1751307732346, InvoiceCallbackUrls1752425992291, OldSomethingLeftover1753106599604, UserReceivingInvoiceIdx1753109184611,
|
UserOffer1733502626042, ManagementGrant1751307732346, InvoiceCallbackUrls1752425992291, OldSomethingLeftover1753106599604, UserReceivingInvoiceIdx1753109184611,
|
||||||
AppUserDevice1753285173175, UserAccess1759426050669, AddBlindToUserOffer1760000000000, ApplicationAvatarUrl1761000001000, AdminSettings1761683639419, TxSwap1762890527098,
|
AppUserDevice1753285173175, UserAccess1759426050669, AddBlindToUserOffer1760000000000, ApplicationAvatarUrl1761000001000, AdminSettings1761683639419, TxSwap1762890527098,
|
||||||
TxSwapAddress1764779178945, ClinkRequester1765497600000, TrackedProviderHeight1766504040000, SwapsServiceUrl1768413055036, InvoiceSwaps1769529793283, InvoiceSwapsFixes1769805357459],
|
TxSwapAddress1764779178945, ClinkRequester1765497600000, TrackedProviderHeight1766504040000, SwapsServiceUrl1768413055036, InvoiceSwaps1769529793283, InvoiceSwapsFixes1769805357459,
|
||||||
|
ApplicationUserTopicId1770038768784, SwapTimestamps1771347307798],
|
||||||
|
|
||||||
|
|
||||||
entities: [User, UserReceivingInvoice, UserReceivingAddress, AddressReceivingTransaction, UserInvoicePayment, UserTransactionPayment,
|
entities: [User, UserReceivingInvoice, UserReceivingAddress, AddressReceivingTransaction, UserInvoicePayment, UserTransactionPayment,
|
||||||
UserBasicAuth, UserEphemeralKey, Product, UserToUserPayment, Application, ApplicationUser, UserToUserPayment, LspOrder, LndNodeInfo,
|
UserBasicAuth, UserEphemeralKey, Product, UserToUserPayment, Application, ApplicationUser, UserToUserPayment, LspOrder, LndNodeInfo,
|
||||||
|
|
|
||||||
|
|
@ -1670,6 +1670,14 @@ The nostr server will send back a message response, and inside the body there wi
|
||||||
### ProvidersDisruption
|
### ProvidersDisruption
|
||||||
- __disruptions__: ARRAY of: _[ProviderDisruption](#ProviderDisruption)_
|
- __disruptions__: ARRAY of: _[ProviderDisruption](#ProviderDisruption)_
|
||||||
|
|
||||||
|
### PushNotificationEnvelope
|
||||||
|
- __app_npub_hex__: _string_
|
||||||
|
- __encrypted_payload__: _string_
|
||||||
|
- __topic_id__: _string_
|
||||||
|
|
||||||
|
### PushNotificationPayload
|
||||||
|
- __data__: _[PushNotificationPayload_data](#PushNotificationPayload_data)_
|
||||||
|
|
||||||
### RefundAdminInvoiceSwapRequest
|
### RefundAdminInvoiceSwapRequest
|
||||||
- __sat_per_v_byte__: _number_
|
- __sat_per_v_byte__: _number_
|
||||||
- __swap_operation_id__: _string_
|
- __swap_operation_id__: _string_
|
||||||
|
|
@ -1797,6 +1805,7 @@ The nostr server will send back a message response, and inside the body there wi
|
||||||
- __nmanage__: _string_
|
- __nmanage__: _string_
|
||||||
- __noffer__: _string_
|
- __noffer__: _string_
|
||||||
- __service_fee_bps__: _number_
|
- __service_fee_bps__: _number_
|
||||||
|
- __topic_id__: _string_
|
||||||
- __userId__: _string_
|
- __userId__: _string_
|
||||||
- __user_identifier__: _string_
|
- __user_identifier__: _string_
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -647,6 +647,14 @@ type ProviderDisruption struct {
|
||||||
type ProvidersDisruption struct {
|
type ProvidersDisruption struct {
|
||||||
Disruptions []ProviderDisruption `json:"disruptions"`
|
Disruptions []ProviderDisruption `json:"disruptions"`
|
||||||
}
|
}
|
||||||
|
type PushNotificationEnvelope struct {
|
||||||
|
App_npub_hex string `json:"app_npub_hex"`
|
||||||
|
Encrypted_payload string `json:"encrypted_payload"`
|
||||||
|
Topic_id string `json:"topic_id"`
|
||||||
|
}
|
||||||
|
type PushNotificationPayload struct {
|
||||||
|
Data *PushNotificationPayload_data `json:"data"`
|
||||||
|
}
|
||||||
type RefundAdminInvoiceSwapRequest struct {
|
type RefundAdminInvoiceSwapRequest struct {
|
||||||
Sat_per_v_byte int64 `json:"sat_per_v_byte"`
|
Sat_per_v_byte int64 `json:"sat_per_v_byte"`
|
||||||
Swap_operation_id string `json:"swap_operation_id"`
|
Swap_operation_id string `json:"swap_operation_id"`
|
||||||
|
|
@ -774,6 +782,7 @@ type UserInfo struct {
|
||||||
Nmanage string `json:"nmanage"`
|
Nmanage string `json:"nmanage"`
|
||||||
Noffer string `json:"noffer"`
|
Noffer string `json:"noffer"`
|
||||||
Service_fee_bps int64 `json:"service_fee_bps"`
|
Service_fee_bps int64 `json:"service_fee_bps"`
|
||||||
|
Topic_id string `json:"topic_id"`
|
||||||
Userid string `json:"userId"`
|
Userid string `json:"userId"`
|
||||||
User_identifier string `json:"user_identifier"`
|
User_identifier string `json:"user_identifier"`
|
||||||
}
|
}
|
||||||
|
|
@ -872,6 +881,18 @@ type NPubLinking_state struct {
|
||||||
Linking_token *string `json:"linking_token"`
|
Linking_token *string `json:"linking_token"`
|
||||||
Unlinked *Empty `json:"unlinked"`
|
Unlinked *Empty `json:"unlinked"`
|
||||||
}
|
}
|
||||||
|
type PushNotificationPayload_data_type string
|
||||||
|
|
||||||
|
const (
|
||||||
|
RECEIVED_OPERATION PushNotificationPayload_data_type = "received_operation"
|
||||||
|
SENT_OPERATION PushNotificationPayload_data_type = "sent_operation"
|
||||||
|
)
|
||||||
|
|
||||||
|
type PushNotificationPayload_data struct {
|
||||||
|
Type PushNotificationPayload_data_type `json:"type"`
|
||||||
|
Received_operation *UserOperation `json:"received_operation"`
|
||||||
|
Sent_operation *UserOperation `json:"sent_operation"`
|
||||||
|
}
|
||||||
type UpdateChannelPolicyRequest_update_type string
|
type UpdateChannelPolicyRequest_update_type string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
|
||||||
|
|
@ -3843,6 +3843,53 @@ export const ProvidersDisruptionValidate = (o?: ProvidersDisruption, opts: Provi
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type PushNotificationEnvelope = {
|
||||||
|
app_npub_hex: string
|
||||||
|
encrypted_payload: string
|
||||||
|
topic_id: string
|
||||||
|
}
|
||||||
|
export const PushNotificationEnvelopeOptionalFields: [] = []
|
||||||
|
export type PushNotificationEnvelopeOptions = OptionsBaseMessage & {
|
||||||
|
checkOptionalsAreSet?: []
|
||||||
|
app_npub_hex_CustomCheck?: (v: string) => boolean
|
||||||
|
encrypted_payload_CustomCheck?: (v: string) => boolean
|
||||||
|
topic_id_CustomCheck?: (v: string) => boolean
|
||||||
|
}
|
||||||
|
export const PushNotificationEnvelopeValidate = (o?: PushNotificationEnvelope, opts: PushNotificationEnvelopeOptions = {}, path: string = 'PushNotificationEnvelope::root.'): Error | null => {
|
||||||
|
if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message')
|
||||||
|
if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null')
|
||||||
|
|
||||||
|
if (typeof o.app_npub_hex !== 'string') return new Error(`${path}.app_npub_hex: is not a string`)
|
||||||
|
if (opts.app_npub_hex_CustomCheck && !opts.app_npub_hex_CustomCheck(o.app_npub_hex)) return new Error(`${path}.app_npub_hex: custom check failed`)
|
||||||
|
|
||||||
|
if (typeof o.encrypted_payload !== 'string') return new Error(`${path}.encrypted_payload: is not a string`)
|
||||||
|
if (opts.encrypted_payload_CustomCheck && !opts.encrypted_payload_CustomCheck(o.encrypted_payload)) return new Error(`${path}.encrypted_payload: custom check failed`)
|
||||||
|
|
||||||
|
if (typeof o.topic_id !== 'string') return new Error(`${path}.topic_id: is not a string`)
|
||||||
|
if (opts.topic_id_CustomCheck && !opts.topic_id_CustomCheck(o.topic_id)) return new Error(`${path}.topic_id: custom check failed`)
|
||||||
|
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
export type PushNotificationPayload = {
|
||||||
|
data: PushNotificationPayload_data
|
||||||
|
}
|
||||||
|
export const PushNotificationPayloadOptionalFields: [] = []
|
||||||
|
export type PushNotificationPayloadOptions = OptionsBaseMessage & {
|
||||||
|
checkOptionalsAreSet?: []
|
||||||
|
data_Options?: PushNotificationPayload_dataOptions
|
||||||
|
}
|
||||||
|
export const PushNotificationPayloadValidate = (o?: PushNotificationPayload, opts: PushNotificationPayloadOptions = {}, path: string = 'PushNotificationPayload::root.'): Error | null => {
|
||||||
|
if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message')
|
||||||
|
if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null')
|
||||||
|
|
||||||
|
const dataErr = PushNotificationPayload_dataValidate(o.data, opts.data_Options, `${path}.data`)
|
||||||
|
if (dataErr !== null) return dataErr
|
||||||
|
|
||||||
|
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
export type RefundAdminInvoiceSwapRequest = {
|
export type RefundAdminInvoiceSwapRequest = {
|
||||||
sat_per_v_byte: number
|
sat_per_v_byte: number
|
||||||
swap_operation_id: string
|
swap_operation_id: string
|
||||||
|
|
@ -4539,6 +4586,7 @@ export type UserInfo = {
|
||||||
nmanage: string
|
nmanage: string
|
||||||
noffer: string
|
noffer: string
|
||||||
service_fee_bps: number
|
service_fee_bps: number
|
||||||
|
topic_id: string
|
||||||
userId: string
|
userId: string
|
||||||
user_identifier: string
|
user_identifier: string
|
||||||
}
|
}
|
||||||
|
|
@ -4555,6 +4603,7 @@ export type UserInfoOptions = OptionsBaseMessage & {
|
||||||
nmanage_CustomCheck?: (v: string) => boolean
|
nmanage_CustomCheck?: (v: string) => boolean
|
||||||
noffer_CustomCheck?: (v: string) => boolean
|
noffer_CustomCheck?: (v: string) => boolean
|
||||||
service_fee_bps_CustomCheck?: (v: number) => boolean
|
service_fee_bps_CustomCheck?: (v: number) => boolean
|
||||||
|
topic_id_CustomCheck?: (v: string) => boolean
|
||||||
userId_CustomCheck?: (v: string) => boolean
|
userId_CustomCheck?: (v: string) => boolean
|
||||||
user_identifier_CustomCheck?: (v: string) => boolean
|
user_identifier_CustomCheck?: (v: string) => boolean
|
||||||
}
|
}
|
||||||
|
|
@ -4592,6 +4641,9 @@ export const UserInfoValidate = (o?: UserInfo, opts: UserInfoOptions = {}, path:
|
||||||
if (typeof o.service_fee_bps !== 'number') return new Error(`${path}.service_fee_bps: is not a number`)
|
if (typeof o.service_fee_bps !== 'number') return new Error(`${path}.service_fee_bps: is not a number`)
|
||||||
if (opts.service_fee_bps_CustomCheck && !opts.service_fee_bps_CustomCheck(o.service_fee_bps)) return new Error(`${path}.service_fee_bps: custom check failed`)
|
if (opts.service_fee_bps_CustomCheck && !opts.service_fee_bps_CustomCheck(o.service_fee_bps)) return new Error(`${path}.service_fee_bps: custom check failed`)
|
||||||
|
|
||||||
|
if (typeof o.topic_id !== 'string') return new Error(`${path}.topic_id: is not a string`)
|
||||||
|
if (opts.topic_id_CustomCheck && !opts.topic_id_CustomCheck(o.topic_id)) return new Error(`${path}.topic_id: custom check failed`)
|
||||||
|
|
||||||
if (typeof o.userId !== 'string') return new Error(`${path}.userId: is not a string`)
|
if (typeof o.userId !== 'string') return new Error(`${path}.userId: is not a string`)
|
||||||
if (opts.userId_CustomCheck && !opts.userId_CustomCheck(o.userId)) return new Error(`${path}.userId: custom check failed`)
|
if (opts.userId_CustomCheck && !opts.userId_CustomCheck(o.userId)) return new Error(`${path}.userId: custom check failed`)
|
||||||
|
|
||||||
|
|
@ -5009,6 +5061,43 @@ export const NPubLinking_stateValidate = (o?: NPubLinking_state, opts:NPubLinkin
|
||||||
if (unlinkedErr !== null) return unlinkedErr
|
if (unlinkedErr !== null) return unlinkedErr
|
||||||
|
|
||||||
|
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
return new Error(path + ': unknown type '+ stringType)
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
export enum PushNotificationPayload_data_type {
|
||||||
|
RECEIVED_OPERATION = 'received_operation',
|
||||||
|
SENT_OPERATION = 'sent_operation',
|
||||||
|
}
|
||||||
|
export const enumCheckPushNotificationPayload_data_type = (e?: PushNotificationPayload_data_type): boolean => {
|
||||||
|
for (const v in PushNotificationPayload_data_type) if (e === v) return true
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
export type PushNotificationPayload_data =
|
||||||
|
{type:PushNotificationPayload_data_type.RECEIVED_OPERATION, received_operation:UserOperation}|
|
||||||
|
{type:PushNotificationPayload_data_type.SENT_OPERATION, sent_operation:UserOperation}
|
||||||
|
|
||||||
|
export type PushNotificationPayload_dataOptions = {
|
||||||
|
received_operation_Options?: UserOperationOptions
|
||||||
|
sent_operation_Options?: UserOperationOptions
|
||||||
|
}
|
||||||
|
export const PushNotificationPayload_dataValidate = (o?: PushNotificationPayload_data, opts:PushNotificationPayload_dataOptions = {}, path: string = 'PushNotificationPayload_data::root.'): Error | null => {
|
||||||
|
if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null')
|
||||||
|
const stringType: string = o.type
|
||||||
|
switch (o.type) {
|
||||||
|
case PushNotificationPayload_data_type.RECEIVED_OPERATION:
|
||||||
|
const received_operationErr = UserOperationValidate(o.received_operation, opts.received_operation_Options, `${path}.received_operation`)
|
||||||
|
if (received_operationErr !== null) return received_operationErr
|
||||||
|
|
||||||
|
|
||||||
|
break
|
||||||
|
case PushNotificationPayload_data_type.SENT_OPERATION:
|
||||||
|
const sent_operationErr = UserOperationValidate(o.sent_operation, opts.sent_operation_Options, `${path}.sent_operation`)
|
||||||
|
if (sent_operationErr !== null) return sent_operationErr
|
||||||
|
|
||||||
|
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
return new Error(path + ': unknown type '+ stringType)
|
return new Error(path + ': unknown type '+ stringType)
|
||||||
|
|
|
||||||
|
|
@ -541,6 +541,7 @@ message UserInfo{
|
||||||
string callback_url = 10;
|
string callback_url = 10;
|
||||||
string bridge_url = 11;
|
string bridge_url = 11;
|
||||||
string nmanage = 12;
|
string nmanage = 12;
|
||||||
|
string topic_id = 13;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -936,3 +937,18 @@ message BeaconData {
|
||||||
optional string nextRelay = 4;
|
optional string nextRelay = 4;
|
||||||
optional CumulativeFees fees = 5;
|
optional CumulativeFees fees = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
message PushNotificationEnvelope {
|
||||||
|
string topic_id = 1;
|
||||||
|
string app_npub_hex = 2;
|
||||||
|
string encrypted_payload = 3; // encrypted PushNotificationPayload
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
message PushNotificationPayload {
|
||||||
|
oneof data {
|
||||||
|
UserOperation received_operation = 1;
|
||||||
|
UserOperation sent_operation = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -82,7 +82,8 @@ export default class {
|
||||||
ndebit: ndebitEncode({ pubkey: app.nostr_public_key!, pointer: appUser.identifier, relay: nostrSettings.relays[0] }),
|
ndebit: ndebitEncode({ pubkey: app.nostr_public_key!, pointer: appUser.identifier, relay: nostrSettings.relays[0] }),
|
||||||
nmanage: nmanageEncode({ pubkey: app.nostr_public_key!, pointer: appUser.identifier, relay: nostrSettings.relays[0] }),
|
nmanage: nmanageEncode({ pubkey: app.nostr_public_key!, pointer: appUser.identifier, relay: nostrSettings.relays[0] }),
|
||||||
callback_url: appUser.callback_url,
|
callback_url: appUser.callback_url,
|
||||||
bridge_url: this.settings.getSettings().serviceSettings.bridgeUrl
|
bridge_url: this.settings.getSettings().serviceSettings.bridgeUrl,
|
||||||
|
topic_id: appUser.topic_id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -169,7 +169,8 @@ export default class {
|
||||||
ndebit: ndebitEncode({ pubkey: app.nostr_public_key!, pointer: u.identifier, relay: nostrSettings.relays[0] }),
|
ndebit: ndebitEncode({ pubkey: app.nostr_public_key!, pointer: u.identifier, relay: nostrSettings.relays[0] }),
|
||||||
nmanage: nmanageEncode({ pubkey: app.nostr_public_key!, pointer: u.identifier, relay: nostrSettings.relays[0] }),
|
nmanage: nmanageEncode({ pubkey: app.nostr_public_key!, pointer: u.identifier, relay: nostrSettings.relays[0] }),
|
||||||
callback_url: u.callback_url,
|
callback_url: u.callback_url,
|
||||||
bridge_url: this.settings.getSettings().serviceSettings.bridgeUrl
|
bridge_url: this.settings.getSettings().serviceSettings.bridgeUrl,
|
||||||
|
topic_id: u.topic_id
|
||||||
|
|
||||||
},
|
},
|
||||||
max_withdrawable: max
|
max_withdrawable: max
|
||||||
|
|
@ -227,7 +228,8 @@ export default class {
|
||||||
ndebit: ndebitEncode({ pubkey: app.nostr_public_key!, pointer: user.identifier, relay: nostrSettings.relays[0] }),
|
ndebit: ndebitEncode({ pubkey: app.nostr_public_key!, pointer: user.identifier, relay: nostrSettings.relays[0] }),
|
||||||
nmanage: nmanageEncode({ pubkey: app.nostr_public_key!, pointer: user.identifier, relay: nostrSettings.relays[0] }),
|
nmanage: nmanageEncode({ pubkey: app.nostr_public_key!, pointer: user.identifier, relay: nostrSettings.relays[0] }),
|
||||||
callback_url: user.callback_url,
|
callback_url: user.callback_url,
|
||||||
bridge_url: this.settings.getSettings().serviceSettings.bridgeUrl
|
bridge_url: this.settings.getSettings().serviceSettings.bridgeUrl,
|
||||||
|
topic_id: user.topic_id
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -424,13 +424,36 @@ export default class {
|
||||||
if (devices.length === 0 || !app.nostr_public_key || !app.nostr_private_key || !appUser.nostr_public_key) {
|
if (devices.length === 0 || !app.nostr_public_key || !app.nostr_private_key || !appUser.nostr_public_key) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const tokens = devices.map(d => d.firebase_messaging_token)
|
const tokens = devices.map(d => d.firebase_messaging_token)
|
||||||
const ck = nip44.getConversationKey(Buffer.from(app.nostr_private_key, 'hex'), appUser.nostr_public_key)
|
const ck = nip44.getConversationKey(Buffer.from(app.nostr_private_key, 'hex'), appUser.nostr_public_key)
|
||||||
const j = JSON.stringify(op)
|
|
||||||
|
let payloadToEncrypt: Types.PushNotificationPayload;
|
||||||
|
if (op.inbound) {
|
||||||
|
payloadToEncrypt = {
|
||||||
|
data: {
|
||||||
|
type: Types.PushNotificationPayload_data_type.RECEIVED_OPERATION,
|
||||||
|
received_operation: op
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
payloadToEncrypt = {
|
||||||
|
data: {
|
||||||
|
type: Types.PushNotificationPayload_data_type.SENT_OPERATION,
|
||||||
|
sent_operation: op
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const j = JSON.stringify(payloadToEncrypt)
|
||||||
const encrypted = nip44.encrypt(j, ck)
|
const encrypted = nip44.encrypt(j, ck)
|
||||||
const encryptedData: { encrypted: string, app_npub_hex: string } = { encrypted, app_npub_hex: app.nostr_public_key }
|
|
||||||
|
const envelope: Types.PushNotificationEnvelope = {
|
||||||
|
topic_id: appUser.topic_id,
|
||||||
|
app_npub_hex: app.nostr_public_key,
|
||||||
|
encrypted_payload: encrypted
|
||||||
|
}
|
||||||
const notification: ShockPushNotification = {
|
const notification: ShockPushNotification = {
|
||||||
message: JSON.stringify(encryptedData),
|
message: JSON.stringify(envelope),
|
||||||
body,
|
body,
|
||||||
title
|
title
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,8 @@ export default class {
|
||||||
user: user,
|
user: user,
|
||||||
application,
|
application,
|
||||||
identifier: userIdentifier,
|
identifier: userIdentifier,
|
||||||
nostr_public_key: nostrPub
|
nostr_public_key: nostrPub,
|
||||||
|
topic_id: crypto.randomBytes(32).toString('hex')
|
||||||
}, txId)
|
}, txId)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,9 @@ export class ApplicationUser {
|
||||||
@Column({ default: "" })
|
@Column({ default: "" })
|
||||||
callback_url: string
|
callback_url: string
|
||||||
|
|
||||||
|
@Column({ unique: true })
|
||||||
|
topic_id: string;
|
||||||
|
|
||||||
@CreateDateColumn()
|
@CreateDateColumn()
|
||||||
created_at: Date
|
created_at: Date
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class ApplicationUserTopicId1770038768784 implements MigrationInterface {
|
||||||
|
name = 'ApplicationUserTopicId1770038768784'
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`DROP INDEX "IDX_0a0dbb25a73306b037dec82251"`);
|
||||||
|
await queryRunner.query(`CREATE TABLE "temporary_application_user" ("serial_id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "identifier" varchar NOT NULL, "nostr_public_key" varchar, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "updated_at" datetime NOT NULL DEFAULT (datetime('now')), "userSerialId" integer, "applicationSerialId" integer, "callback_url" varchar NOT NULL DEFAULT (''), "topic_id" varchar NOT NULL, CONSTRAINT "UQ_3175dc397c8285d1e532554dea5" UNIQUE ("nostr_public_key"), CONSTRAINT "REL_0796a381bcc624f52e9a155712" UNIQUE ("userSerialId"), CONSTRAINT "UQ_bd1a42f39fd7b4218bed5cc63d9" UNIQUE ("topic_id"), CONSTRAINT "FK_0796a381bcc624f52e9a155712b" FOREIGN KEY ("userSerialId") REFERENCES "user" ("serial_id") ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT "FK_1b3bdb6f660cd99533a1e673ef1" FOREIGN KEY ("applicationSerialId") REFERENCES "application" ("serial_id") ON DELETE NO ACTION ON UPDATE NO ACTION)`);
|
||||||
|
await queryRunner.query(`INSERT INTO "temporary_application_user"("serial_id", "identifier", "nostr_public_key", "created_at", "updated_at", "userSerialId", "applicationSerialId", "callback_url", "topic_id") SELECT "serial_id", "identifier", "nostr_public_key", "created_at", "updated_at", "userSerialId", "applicationSerialId", "callback_url", lower(hex(randomblob(32))) FROM "application_user"`);
|
||||||
|
await queryRunner.query(`DROP TABLE "application_user"`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "temporary_application_user" RENAME TO "application_user"`);
|
||||||
|
await queryRunner.query(`CREATE UNIQUE INDEX "IDX_0a0dbb25a73306b037dec82251" ON "application_user" ("identifier") `);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`DROP INDEX "IDX_0a0dbb25a73306b037dec82251"`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "application_user" RENAME TO "temporary_application_user"`);
|
||||||
|
await queryRunner.query(`CREATE TABLE "application_user" ("serial_id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "identifier" varchar NOT NULL, "nostr_public_key" varchar, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "updated_at" datetime NOT NULL DEFAULT (datetime('now')), "userSerialId" integer, "applicationSerialId" integer, "callback_url" varchar NOT NULL DEFAULT (''), CONSTRAINT "UQ_3175dc397c8285d1e532554dea5" UNIQUE ("nostr_public_key"), CONSTRAINT "REL_0796a381bcc624f52e9a155712" UNIQUE ("userSerialId"), CONSTRAINT "FK_0796a381bcc624f52e9a155712b" FOREIGN KEY ("userSerialId") REFERENCES "user" ("serial_id") ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT "FK_1b3bdb6f660cd99533a1e673ef1" FOREIGN KEY ("applicationSerialId") REFERENCES "application" ("serial_id") ON DELETE NO ACTION ON UPDATE NO ACTION)`);
|
||||||
|
await queryRunner.query(`INSERT INTO "application_user"("serial_id", "identifier", "nostr_public_key", "created_at", "updated_at", "userSerialId", "applicationSerialId", "callback_url") SELECT "serial_id", "identifier", "nostr_public_key", "created_at", "updated_at", "userSerialId", "applicationSerialId", "callback_url" FROM "temporary_application_user"`);
|
||||||
|
await queryRunner.query(`DROP TABLE "temporary_application_user"`);
|
||||||
|
await queryRunner.query(`CREATE UNIQUE INDEX "IDX_0a0dbb25a73306b037dec82251" ON "application_user" ("identifier") `);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -32,17 +32,24 @@ import { TxSwapAddress1764779178945 } from './1764779178945-tx_swap_address.js'
|
||||||
import { ClinkRequester1765497600000 } from './1765497600000-clink_requester.js'
|
import { ClinkRequester1765497600000 } from './1765497600000-clink_requester.js'
|
||||||
import { TrackedProviderHeight1766504040000 } from './1766504040000-tracked_provider_height.js'
|
import { TrackedProviderHeight1766504040000 } from './1766504040000-tracked_provider_height.js'
|
||||||
import { SwapsServiceUrl1768413055036 } from './1768413055036-swaps_service_url.js'
|
import { SwapsServiceUrl1768413055036 } from './1768413055036-swaps_service_url.js'
|
||||||
|
|
||||||
import { InvoiceSwaps1769529793283 } from './1769529793283-invoice_swaps.js'
|
import { InvoiceSwaps1769529793283 } from './1769529793283-invoice_swaps.js'
|
||||||
import { InvoiceSwapsFixes1769805357459 } from './1769805357459-invoice_swaps_fixes.js'
|
import { InvoiceSwapsFixes1769805357459 } from './1769805357459-invoice_swaps_fixes.js'
|
||||||
|
import { ApplicationUserTopicId1770038768784 } from './1770038768784-application_user_topic_id.js'
|
||||||
import { SwapTimestamps1771347307798 } from './1771347307798-swap_timestamps.js'
|
import { SwapTimestamps1771347307798 } from './1771347307798-swap_timestamps.js'
|
||||||
import { RootOpPending1771524665409 } from './1771524665409-root_op_pending.js'
|
import { RootOpPending1771524665409 } from './1771524665409-root_op_pending.js'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export const allMigrations = [Initial1703170309875, LspOrder1718387847693, LiquidityProvider1719335699480, LndNodeInfo1720187506189,
|
export const allMigrations = [Initial1703170309875, LspOrder1718387847693, LiquidityProvider1719335699480, LndNodeInfo1720187506189,
|
||||||
TrackedProvider1720814323679, CreateInviteTokenTable1721751414878, PaymentIndex1721760297610, DebitAccess1726496225078, DebitAccessFixes1726685229264,
|
TrackedProvider1720814323679, CreateInviteTokenTable1721751414878, PaymentIndex1721760297610, DebitAccess1726496225078, DebitAccessFixes1726685229264,
|
||||||
DebitToPub1727105758354, UserCbUrl1727112281043, UserOffer1733502626042, ManagementGrant1751307732346, ManagementGrantBanned1751989251513,
|
DebitToPub1727105758354, UserCbUrl1727112281043, UserOffer1733502626042, ManagementGrant1751307732346, ManagementGrantBanned1751989251513,
|
||||||
InvoiceCallbackUrls1752425992291, OldSomethingLeftover1753106599604, UserReceivingInvoiceIdx1753109184611, AppUserDevice1753285173175,
|
InvoiceCallbackUrls1752425992291, OldSomethingLeftover1753106599604, UserReceivingInvoiceIdx1753109184611, AppUserDevice1753285173175,
|
||||||
UserAccess1759426050669, AddBlindToUserOffer1760000000000, ApplicationAvatarUrl1761000001000, AdminSettings1761683639419, TxSwap1762890527098,
|
UserAccess1759426050669, AddBlindToUserOffer1760000000000, ApplicationAvatarUrl1761000001000, AdminSettings1761683639419, TxSwap1762890527098,
|
||||||
TxSwapAddress1764779178945, ClinkRequester1765497600000, TrackedProviderHeight1766504040000, SwapsServiceUrl1768413055036,
|
TxSwapAddress1764779178945, ClinkRequester1765497600000, TrackedProviderHeight1766504040000, SwapsServiceUrl1768413055036,
|
||||||
InvoiceSwaps1769529793283, InvoiceSwapsFixes1769805357459, SwapTimestamps1771347307798]
|
InvoiceSwaps1769529793283, InvoiceSwapsFixes1769805357459, ApplicationUserTopicId1770038768784, SwapTimestamps1771347307798]
|
||||||
|
|
||||||
|
|
||||||
export const allMetricsMigrations = [LndMetrics1703170330183, ChannelRouting1709316653538, HtlcCount1724266887195, BalanceEvents1724860966825,
|
export const allMetricsMigrations = [LndMetrics1703170330183, ChannelRouting1709316653538, HtlcCount1724266887195, BalanceEvents1724860966825,
|
||||||
RootOps1732566440447, RootOpsTime1745428134124, ChannelEvents1750777346411, RootOpPending1771524665409]
|
RootOps1732566440447, RootOpsTime1745428134124, ChannelEvents1750777346411, RootOpPending1771524665409]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue