Profile
This module holds objects and functions to load a nanopub user profile.
Profile
Source code in nanopub/profile.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | |
__init__(agent_id=None, name=None, private_key=None, public_key=None, introduction_nanopub_uri=None, *, orcid_id=None)
Represents a user profile.
Attributes:
| Name | Type | Description |
|---|---|---|
agent_id |
str
|
URI identifying the signer — an ORCID iD or any other agent URI |
name |
str
|
The user’s name |
private_key |
Optional[Union[Path, str]]
|
Path to the user’s private key, or the key as string |
public_key |
Optional[Union[Path, str]]
|
Path to the user’s public key, or the key as string |
introduction_nanopub_uri |
Optional[str]
|
URI of the user’s profile nanopub |
orcid_id |
str
|
Deprecated alias for |
Source code in nanopub/profile.py
generate_keys()
Generate private/public RSA key pair at the path specified in the profile.yml, to be used to sign nanopubs
Source code in nanopub/profile.py
store(folder=USER_CONFIG_DIR)
Stores the nanopub user profile. By default the profile is stored in HOME_DIR/.nanopub/profile.yaml.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
folder
|
Path
|
The path to the folder to store the user’s profile files. |
USER_CONFIG_DIR
|
Returns:
| Type | Description |
|---|---|
str
|
The path where the profile was stored. |
Source code in nanopub/profile.py
ProfileError
ProfileLoader
Bases: Profile
A class to load a user profile from a local YAML file, only used for YAtiML.
Source code in nanopub/profile.py
__init__(name, private_key, public_key, agent_id=None, orcid_id=None, introduction_nanopub_uri=None)
Create a ProfileLoader.
Both the agent_id key and the legacy orcid_id key are accepted
from profile.yml; agent_id takes precedence when both are present.
Source code in nanopub/profile.py
format_key(key)
Format private and public keys to remove header/footer and all newlines, as this is required by nanopub-java.
.. deprecated::
format_key is deprecated and will be removed in an upcoming major
version. It only strips PEM armor from a PKCS#8/SPKI key via string
replacement and silently mishandles PKCS#1 and CRLF input. Use
:func:normalize_private_key / :func:normalize_public_key instead,
which accept any standard PEM/DER/bare key and return the same canonical
single-line base64 form.
Source code in nanopub/profile.py
generate_keyfiles(path=USER_CONFIG_DIR)
Generate private/public RSA key pair at the path specified in the profile.yml, to be used to sign nanopubs
Source code in nanopub/profile.py
load_profile(profile_path=DEFAULT_PROFILE_PATH)
Retrieve nanopub user profile.
By default the profile is stored in HOME_DIR/.nanopub/profile.yaml.
Returns:
| Type | Description |
|---|---|
Profile
|
A Profile containing the data from the configuration file. |
Raises:
| Type | Description |
|---|---|
RecognitionError
|
If there is an error in the file. |
Source code in nanopub/profile.py
normalize_private_key(key_data)
Normalize any RSA private key to nanopub’s canonical single-line base64.
The canonical form is the base64 of the PKCS#8 DER with no PEM armor and no newlines, as required by nanopub-java and assumed by the signing code.
Source code in nanopub/profile.py
normalize_public_key(key_data)
Normalize any RSA public key to nanopub’s canonical single-line base64.
The canonical form is the base64 of the SubjectPublicKeyInfo DER with no PEM armor and no newlines. A private key may be passed in, in which case the corresponding public key is derived.