@nevermined-io/sdk - v3.0.44 / NvmApiKey
JWTPayload
▪ [propName: string
]: any
Additional attributes
• new NvmApiKey(): NvmApiKey
• aud: string
The chain id of the network the key is valid for. If zero the key is not having any network limitation
JWTPayload.aud
• Optional
exp: number
JWT Expiration Time
See
JWTPayload.exp
• Optional
iat: number
JWT Issued At
See
JWTPayload.iat
• iss: string
The public address of the account issuing the key.
JWTPayload.iss
• Optional
nvt: string
The Marketplace auth token
• sub: string
The public address of the account the key is issued for.
JWTPayload.sub
• ver: string
= 'v2'
The version of the key
• Optional
zsk: string
The ZeroDev session key
▸ hash(): string
It generates the hash of the NvmApiKey
string
a string representing the hash of the NvmApiKey
▸ hashJWT(signatureUtils
, issuerAccount
): Promise
<string
>
It generates the hash in JWT format of the NvmApiKey
Name | Type | Description |
---|---|---|
signatureUtils |
SignatureUtils |
the SignatureUtils instance |
issuerAccount |
NvmAccount |
the account issuing the key |
Promise
<string
>
a JWT string representing the hash of the NvmApiKey
▸ isValid(chainId?
): boolean
It checks if the NVM API Key attributes are valid
Name | Type | Default value | Description |
---|---|---|---|
chainId |
number |
0 |
The chain id of the network the key is valid for |
boolean
true if the key is valid, false otherwise
▸ serialize(): string
It serializes the NVM Api Key into a string
string
a string representing the NVM API Key
▸ toJWT(signatureUtils
, issuerAccount
): Promise
<string
>
It generates a signed JWT from the NvmApiKey
Name | Type | Description |
---|---|---|
signatureUtils |
SignatureUtils |
The SignatureUtils instance |
issuerAccount |
NvmAccount |
The account issuing the key |
Promise
<string
>
the string in JWT format represeting the NvmApiKey
▸ toString(): string
It serializes the NVM Api Key into a string
string
a string representing the NVM API Key
▸ decodeJWT(str
): JWTPayload
It decodes a string JWT into a JWTPayload
Name | Type | Description |
---|---|---|
str |
string |
jwt string |
JWTPayload
the JWTPayload
▸ decryptAndDecode(encryptedJwt
, privateKey
): Promise
<NvmApiKey
>
Givena an encrypted JWT and a private key, it decrypts and decodes the JWT into a NvmApiKey
Name | Type | Description |
---|---|---|
encryptedJwt |
string |
The encrypted JWT |
privateKey |
string |
The private key representing the account |
Promise
<NvmApiKey
>
The
See
▸ deserialize(str
): NvmApiKey
It regenerates the NvmApiKey from a string
Name | Type | Description |
---|---|---|
str |
string |
the string represeting the NvmApiKey |
the
See
▸ fromJSON(jwt
): NvmApiKey
It regenerates the NvmApiKey from a JSON object
Name | Type | Description |
---|---|---|
jwt |
JWTPayload |
JWTPayload in JSON format |
the
See
▸ fromJWT(jwtString
): NvmApiKey
It regenerates the NvmApiKey from a JWT
Name | Type | Description |
---|---|---|
jwtString |
string |
the string in JWT format represeting the NvmApiKey |
the
See
▸ generate(signatureUtils
, issuerAccount
, zeroDevSessionKey
, marketplaceAuthToken
, receiverAddress
, receiverPublicKey
, expirationTime?
, additionalParams?
): Promise
<string
>
It generates a new serialized and encrypted NvmApiKey including the ZeroDev session key and the Marketplace auth token. The string representing this key can be used to authenticate against the Nevermined API.
Name | Type | Default value | Description |
---|---|---|---|
signatureUtils |
SignatureUtils |
undefined |
The SignatureUtils instance |
issuerAccount |
NvmAccount |
undefined |
The account issuing the key |
zeroDevSessionKey |
undefined | string |
undefined |
The ZeroDev session key |
marketplaceAuthToken |
string |
undefined |
The Marketplace Auth Token |
receiverAddress |
string |
undefined |
The address of the account the key is issued for |
receiverPublicKey |
string |
undefined |
The public key of the account the key is issued for |
expirationTime |
string | number |
'1y' |
- |
additionalParams |
Object |
{} |
Addintional params to be added to the Key generated |
Promise
<string
>
The encrypted string representing the
See
▸ generateWithoutSessionKey(signatureUtils
, issuerAccount
, marketplaceAuthToken
, receiverAddress
, receiverPublicKey
, additionalParams?
): Promise
<string
>
Name | Type |
---|---|
signatureUtils |
SignatureUtils |
issuerAccount |
NvmAccount |
marketplaceAuthToken |
string |
receiverAddress |
string |
receiverPublicKey |
string |
additionalParams |
Object |
Promise
<string
>
▸ getSignerAddress(jwtString
): Promise
<string
>
Given a signed JWT, it recovers the signer address
Name | Type | Description |
---|---|---|
jwtString |
string |
The signed JWT |
Promise
<string
>
The signer address
▸ hash(serialized
): string
Given a serialized string, it generates the hash
Name | Type | Description |
---|---|---|
serialized |
string |
the serialized string |
string
the hash