nip69 server
This commit is contained in:
parent
8e18e67995
commit
747bce3cf1
9 changed files with 130 additions and 37 deletions
|
|
@ -652,6 +652,7 @@ The nostr server will send back a message response, and inside the body there wi
|
|||
- __identifier__: _string_
|
||||
- __info__: _[UserInfo](#UserInfo)_
|
||||
- __max_withdrawable__: _number_
|
||||
- __noffer__: _string_
|
||||
|
||||
### Application
|
||||
- __balance__: _number_
|
||||
|
|
@ -897,6 +898,7 @@ The nostr server will send back a message response, and inside the body there wi
|
|||
### Product
|
||||
- __id__: _string_
|
||||
- __name__: _string_
|
||||
- __noffer__: _string_
|
||||
- __price_sats__: _number_
|
||||
|
||||
### RelaysMigration
|
||||
|
|
|
|||
|
|
@ -510,6 +510,7 @@ export type AppUser = {
|
|||
identifier: string
|
||||
info: UserInfo
|
||||
max_withdrawable: number
|
||||
noffer: string
|
||||
}
|
||||
export const AppUserOptionalFields: [] = []
|
||||
export type AppUserOptions = OptionsBaseMessage & {
|
||||
|
|
@ -517,6 +518,7 @@ export type AppUserOptions = OptionsBaseMessage & {
|
|||
identifier_CustomCheck?: (v: string) => boolean
|
||||
info_Options?: UserInfoOptions
|
||||
max_withdrawable_CustomCheck?: (v: number) => boolean
|
||||
noffer_CustomCheck?: (v: string) => boolean
|
||||
}
|
||||
export const AppUserValidate = (o?: AppUser, opts: AppUserOptions = {}, path: string = 'AppUser::root.'): Error | null => {
|
||||
if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message')
|
||||
|
|
@ -532,6 +534,9 @@ export const AppUserValidate = (o?: AppUser, opts: AppUserOptions = {}, path: st
|
|||
if (typeof o.max_withdrawable !== 'number') return new Error(`${path}.max_withdrawable: is not a number`)
|
||||
if (opts.max_withdrawable_CustomCheck && !opts.max_withdrawable_CustomCheck(o.max_withdrawable)) return new Error(`${path}.max_withdrawable: custom check failed`)
|
||||
|
||||
if (typeof o.noffer !== 'string') return new Error(`${path}.noffer: is not a string`)
|
||||
if (opts.noffer_CustomCheck && !opts.noffer_CustomCheck(o.noffer)) return new Error(`${path}.noffer: custom check failed`)
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
|
|
@ -1977,6 +1982,7 @@ export const PaymentStateValidate = (o?: PaymentState, opts: PaymentStateOptions
|
|||
export type Product = {
|
||||
id: string
|
||||
name: string
|
||||
noffer: string
|
||||
price_sats: number
|
||||
}
|
||||
export const ProductOptionalFields: [] = []
|
||||
|
|
@ -1984,6 +1990,7 @@ export type ProductOptions = OptionsBaseMessage & {
|
|||
checkOptionalsAreSet?: []
|
||||
id_CustomCheck?: (v: string) => boolean
|
||||
name_CustomCheck?: (v: string) => boolean
|
||||
noffer_CustomCheck?: (v: string) => boolean
|
||||
price_sats_CustomCheck?: (v: number) => boolean
|
||||
}
|
||||
export const ProductValidate = (o?: Product, opts: ProductOptions = {}, path: string = 'Product::root.'): Error | null => {
|
||||
|
|
@ -1996,6 +2003,9 @@ export const ProductValidate = (o?: Product, opts: ProductOptions = {}, path: st
|
|||
if (typeof o.name !== 'string') return new Error(`${path}.name: is not a string`)
|
||||
if (opts.name_CustomCheck && !opts.name_CustomCheck(o.name)) return new Error(`${path}.name: custom check failed`)
|
||||
|
||||
if (typeof o.noffer !== 'string') return new Error(`${path}.noffer: is not a string`)
|
||||
if (opts.noffer_CustomCheck && !opts.noffer_CustomCheck(o.noffer)) return new Error(`${path}.noffer: custom check failed`)
|
||||
|
||||
if (typeof o.price_sats !== 'number') return new Error(`${path}.price_sats: is not a number`)
|
||||
if (opts.price_sats_CustomCheck && !opts.price_sats_CustomCheck(o.price_sats)) return new Error(`${path}.price_sats: custom check failed`)
|
||||
|
||||
|
|
|
|||
|
|
@ -192,6 +192,7 @@ message AppUser {
|
|||
string identifier = 1;
|
||||
UserInfo info = 2;
|
||||
int64 max_withdrawable = 3;
|
||||
string noffer = 4;
|
||||
}
|
||||
|
||||
message AddAppInvoiceRequest {
|
||||
|
|
@ -409,6 +410,7 @@ message Product {
|
|||
string id = 1;
|
||||
string name = 2;
|
||||
int64 price_sats = 3;
|
||||
string noffer = 4;
|
||||
}
|
||||
|
||||
message GetProductBuyLinkResponse {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue