NvmApiKey
@nevermined-io/sdk - v3.0.44 / NvmApiKey
Class: NvmApiKey
Implements
JWTPayload
Indexable
▪ [propName: string
]: any
Additional attributes
Table of contents
Constructors
Properties
Methods
- hash
- hashJWT
- isValid
- serialize
- toJWT
- toString
- decodeJWT
- decryptAndDecode
- deserialize
- fromJSON
- fromJWT
- generate
- generateWithoutSessionKey
- getSignerAddress
- hash
Constructors
constructor
• new NvmApiKey(): NvmApiKey
Returns
Defined in
Properties
aud
• aud: string
The chain id of the network the key is valid for. If zero the key is not having any network limitation
Implementation of
JWTPayload.aud
Defined in
exp
• Optional
exp: number
JWT Expiration Time
See
Implementation of
JWTPayload.exp
Defined in
iat
• Optional
iat: number
JWT Issued At
See
Implementation of
JWTPayload.iat
Defined in
iss
• iss: string
The public address of the account issuing the key.
Implementation of
JWTPayload.iss
Defined in
nvt
• Optional
nvt: string
The Marketplace auth token
Defined in
sub
• sub: string
The public address of the account the key is issued for.
Implementation of
JWTPayload.sub
Defined in
ver
• ver: string
= 'v2'
The version of the key
Defined in
zsk
• Optional
zsk: string
The ZeroDev session key
Defined in
Methods
hash
▸ hash(): string
It generates the hash of the NvmApiKey
Returns
string
a string representing the hash of the NvmApiKey
Defined in
hashJWT
▸ hashJWT(signatureUtils
, issuerAccount
): Promise
\<string
>
It generates the hash in JWT format of the NvmApiKey
Parameters
Name | Type | Description |
---|---|---|
signatureUtils | SignatureUtils | the SignatureUtils instance |
issuerAccount | NvmAccount | the account issuing the key |
Returns
Promise
\<string
>
a JWT string representing the hash of the NvmApiKey
Defined in
isValid
▸ isValid(chainId?
): boolean
It checks if the NVM API Key attributes are valid
Parameters
Name | Type | Default value | Description |
---|---|---|---|
chainId | number | 0 | The chain id of the network the key is valid for |
Returns
boolean
true if the key is valid, false otherwise
Defined in
serialize
▸ serialize(): string
It serializes the NVM Api Key into a string
Returns
string
a string representing the NVM API Key
Defined in
toJWT
▸ toJWT(signatureUtils
, issuerAccount
): Promise
\<string
>
It generates a signed JWT from the NvmApiKey
Parameters
Name | Type | Description |
---|---|---|
signatureUtils | SignatureUtils | The SignatureUtils instance |
issuerAccount | NvmAccount | The account issuing the key |
Returns
Promise
\<string
>
the string in JWT format represeting the NvmApiKey
Defined in
toString
▸ toString(): string
It serializes the NVM Api Key into a string
Returns
string
a string representing the NVM API Key
Defined in
decodeJWT
▸ decodeJWT(str
): JWTPayload
It decodes a string JWT into a JWTPayload
Parameters
Name | Type | Description |
---|---|---|
str | string | jwt string |
Returns
JWTPayload
the JWTPayload
Defined in
decryptAndDecode
▸ decryptAndDecode(encryptedJwt
, privateKey
): Promise
\<NvmApiKey
>
Givena an encrypted JWT and a private key, it decrypts and decodes the JWT into a NvmApiKey
Parameters
Name | Type | Description |
---|---|---|
encryptedJwt | string | The encrypted JWT |
privateKey | string | The private key representing the account |
Returns
Promise
\<NvmApiKey
>
The
See
Defined in
deserialize
▸ deserialize(str
): NvmApiKey
It regenerates the NvmApiKey from a string
Parameters
Name | Type | Description |
---|---|---|
str | string | the string represeting the NvmApiKey |
Returns
the
See
Defined in
fromJSON
▸ fromJSON(jwt
): NvmApiKey
It regenerates the NvmApiKey from a JSON object
Parameters
Name | Type | Description |
---|---|---|
jwt | JWTPayload | JWTPayload in JSON format |
Returns
the
See
Defined in
fromJWT
▸ fromJWT(jwtString
): NvmApiKey
It regenerates the NvmApiKey from a JWT
Parameters
Name | Type | Description |
---|---|---|
jwtString | string | the string in JWT format represeting the NvmApiKey |
Returns
the
See
Defined in
generate
▸ 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.
Parameters
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 |
Returns
Promise
\<string
>
The encrypted string representing the
See
Defined in
generateWithoutSessionKey
▸ generateWithoutSessionKey(signatureUtils
, issuerAccount
, marketplaceAuthToken
, receiverAddress
, receiverPublicKey
, additionalParams?
): Promise
\<string
>
Parameters
Name | Type |
---|---|
signatureUtils | SignatureUtils |
issuerAccount | NvmAccount |
marketplaceAuthToken | string |
receiverAddress | string |
receiverPublicKey | string |
additionalParams | Object |
Returns
Promise
\<string
>
Defined in
getSignerAddress
▸ getSignerAddress(jwtString
): Promise
\<string
>
Given a signed JWT, it recovers the signer address
Parameters
Name | Type | Description |
---|---|---|
jwtString | string | The signed JWT |
Returns
Promise
\<string
>
The signer address
Defined in
hash
▸ hash(serialized
): string
Given a serialized string, it generates the hash
Parameters
Name | Type | Description |
---|---|---|
serialized | string | the serialized string |
Returns
string
the hash