forked from jeffthibault/python-nostr
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
893 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
venv/ | ||
nostr/__pycache__/ | ||
__pycache__/ | ||
nostr.egg-info/ | ||
dist/ | ||
nostr/_version.py | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import time | ||
from dataclasses import dataclass | ||
|
||
|
||
@dataclass | ||
class Delegation: | ||
delegator_pubkey: str | ||
delegatee_pubkey: str | ||
event_kind: int | ||
duration_secs: int = 30*24*60 # default to 30 days | ||
signature: str = None # set in PrivateKey.sign_delegation | ||
|
||
@property | ||
def expires(self) -> int: | ||
return int(time.time()) + self.duration_secs | ||
|
||
@property | ||
def conditions(self) -> str: | ||
return f"kind={self.event_kind}&created_at<{self.expires}" | ||
|
||
@property | ||
def delegation_token(self) -> str: | ||
return f"nostr:delegation:{self.delegatee_pubkey}:{self.conditions}" | ||
|
||
def get_tag(self) -> list[str]: | ||
""" Called by Event """ | ||
return [ | ||
"delegation", | ||
self.delegator_pubkey, | ||
self.conditions, | ||
self.signature, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.