authorization hook, and spec changes

This commit is contained in:
boufni95 2024-09-18 18:49:29 +00:00
parent 6df5752d46
commit 49b8dd693c
19 changed files with 2655 additions and 216 deletions

View file

@ -435,7 +435,7 @@ service LightningPub {
option (http_route) = "/api/user/lnurl_channel/url";
option (nostr) = true;
}
rpc GetAuthorizedDebits(structs.Empty) returns (structs.AuthorizedDebits){
rpc GetDebitAuthorizations(structs.Empty) returns (structs.DebitAuthorizations){
option (auth_type) = "User";
option (http_method) = "get";
option (http_route) = "/api/user/debit/get";
@ -447,12 +447,18 @@ service LightningPub {
option (http_route) = "/api/user/debit/remove";
option (nostr) = true;
}
rpc AuthorizeDebit(structs.DebitAuthorization) returns (structs.AuthorizedDebit){
rpc AuthorizeDebit(structs.DebitAuthorizationRequest) returns (structs.DebitAuthorization){
option (auth_type) = "User";
option (http_method) = "post";
option (http_route) = "/api/user/debit/authorize";
option (nostr) = true;
}
rpc GetLiveDebitRequests(structs.Empty) returns (stream structs.LiveDebitRequest){
option (auth_type) = "User";
option (http_method) = "post";
option (http_route) = "/api/user/debit/sub";
option (nostr) = true;
}
rpc GetLiveUserOperations(structs.Empty) returns (stream structs.LiveUserOperation){
option (auth_type) = "User";
option (http_method) = "post";

View file

@ -480,25 +480,53 @@ message GetInviteTokenStateResponse {
message DebitAuthorizationRequest {
string authorize_npub = 1;
repeated DebitRule rules = 2;
}
message DebitAuthorization {
optional string authorize_npub =1;
}
enum AuthorizedDebitType {
NPUB = 0;
KEY = 1;
}
message AuthorizedDebit {
string debit_id = 1;
AuthorizedDebitType debit_type = 2;
string key = 3;
bool authorized = 2;
string npub = 3;
repeated DebitRule rules = 4;
}
message AuthorizedDebits {
repeated AuthorizedDebit debits = 1;
message DebitAuthorizations {
repeated DebitAuthorization debits = 1;
}
message RemoveAuthorizedDebitRequest {
string debit_id = 1;
string npub = 1;
}
message DebitExpirationRule {
int64 expires_at_unix = 1;
}
enum IntervalType {
DAY = 0;
WEEK = 1;
MONTH = 2;
}
message FrequencyRule {
int64 number_of_intervals = 1;
IntervalType interval = 2;
}
message DebitRule {
oneof rule {
DebitExpirationRule expiration_rule = 1;
FrequencyRule frequency_rule = 2;
}
}
message LiveDebitRequest {
string npub = 1;
int64 amount = 2;
oneof debit {
string invoice = 3;
FrequencyRule frequency = 4;
}
}