Skip to main content

NvmApiKey

@nevermined-io/sdk - v3.0.40 / NvmApiKey

Class: NvmApiKey

Implements

  • JWTPayload

Indexable

[propName: string]: any

Additional attributes

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new NvmApiKey(): NvmApiKey

Returns

NvmApiKey

Defined in

src/models/NvmApiKey.ts:59

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

src/models/NvmApiKey.ts:18


exp

Optional exp: number

JWT Expiration Time

See

RFC7519#section-4.1.4

Implementation of

JWTPayload.exp

Defined in

src/models/NvmApiKey.ts:45


iat

Optional iat: number

JWT Issued At

See

RFC7519#section-4.1.6

Implementation of

JWTPayload.iat

Defined in

src/models/NvmApiKey.ts:52


iss

iss: string

The public address of the account issuing the key.

Implementation of

JWTPayload.iss

Defined in

src/models/NvmApiKey.ts:13


nvt

Optional nvt: string

The Marketplace auth token

Defined in

src/models/NvmApiKey.ts:38


sub

sub: string

The public address of the account the key is issued for.

Implementation of

JWTPayload.sub

Defined in

src/models/NvmApiKey.ts:23


ver

ver: string = 'v2'

The version of the key

Defined in

src/models/NvmApiKey.ts:28


zsk

Optional zsk: string

The ZeroDev session key

Defined in

src/models/NvmApiKey.ts:33

Methods

hash

hash(): string

It generates the hash of the NvmApiKey

Returns

string

a string representing the hash of the NvmApiKey

Defined in

src/models/NvmApiKey.ts:280


hashJWT

hashJWT(signatureUtils, issuerAccount): Promise\<string>

It generates the hash in JWT format of the NvmApiKey

Parameters

NameTypeDescription
signatureUtilsSignatureUtilsthe SignatureUtils instance
issuerAccountNvmAccountthe account issuing the key

Returns

Promise\<string>

a JWT string representing the hash of the NvmApiKey

Defined in

src/models/NvmApiKey.ts:201


isValid

isValid(chainId?): boolean

It checks if the NVM API Key attributes are valid

Parameters

NameTypeDefault valueDescription
chainIdnumber0The chain id of the network the key is valid for

Returns

boolean

true if the key is valid, false otherwise

Defined in

src/models/NvmApiKey.ts:165


serialize

serialize(): string

It serializes the NVM Api Key into a string

Returns

string

a string representing the NVM API Key

Defined in

src/models/NvmApiKey.ts:255


toJWT

toJWT(signatureUtils, issuerAccount): Promise\<string>

It generates a signed JWT from the NvmApiKey

Parameters

NameTypeDescription
signatureUtilsSignatureUtilsThe SignatureUtils instance
issuerAccountNvmAccountThe account issuing the key

Returns

Promise\<string>

the string in JWT format represeting the NvmApiKey

Defined in

src/models/NvmApiKey.ts:182


toString

toString(): string

It serializes the NVM Api Key into a string

Returns

string

a string representing the NVM API Key

Defined in

src/models/NvmApiKey.ts:263


decodeJWT

decodeJWT(str): JWTPayload

It decodes a string JWT into a JWTPayload

Parameters

NameTypeDescription
strstringjwt string

Returns

JWTPayload

the JWTPayload

Defined in

src/models/NvmApiKey.ts:272


decryptAndDecode

decryptAndDecode(encryptedJwt, privateKey): Promise\<NvmApiKey>

Givena an encrypted JWT and a private key, it decrypts and decodes the JWT into a NvmApiKey

Parameters

NameTypeDescription
encryptedJwtstringThe encrypted JWT
privateKeystringThe private key representing the account

Returns

Promise\<NvmApiKey>

The

See

NvmApiKey

Defined in

src/models/NvmApiKey.ts:140


deserialize

deserialize(str): NvmApiKey

It regenerates the NvmApiKey from a string

Parameters

NameTypeDescription
strstringthe string represeting the NvmApiKey

Returns

NvmApiKey

the

See

NvmApiKey

Defined in

src/models/NvmApiKey.ts:247


fromJSON

fromJSON(jwt): NvmApiKey

It regenerates the NvmApiKey from a JSON object

Parameters

NameTypeDescription
jwtJWTPayloadJWTPayload in JSON format

Returns

NvmApiKey

the

See

NvmApiKey

Defined in

src/models/NvmApiKey.ts:220


fromJWT

fromJWT(jwtString): NvmApiKey

It regenerates the NvmApiKey from a JWT

Parameters

NameTypeDescription
jwtStringstringthe string in JWT format represeting the NvmApiKey

Returns

NvmApiKey

the

See

NvmApiKey

Defined in

src/models/NvmApiKey.ts:237


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

NameTypeDefault valueDescription
signatureUtilsSignatureUtilsundefinedThe SignatureUtils instance
issuerAccountNvmAccountundefinedThe account issuing the key
zeroDevSessionKeyundefined | stringundefinedThe ZeroDev session key
marketplaceAuthTokenstringundefinedThe Marketplace Auth Token
receiverAddressstringundefinedThe address of the account the key is issued for
receiverPublicKeystringundefinedThe public key of the account the key is issued for
expirationTimestring | number'1y'-
additionalParamsObject{}Addintional params to be added to the Key generated

Returns

Promise\<string>

The encrypted string representing the

See

NvmApiKey

Defined in

src/models/NvmApiKey.ts:74


generateWithoutSessionKey

generateWithoutSessionKey(signatureUtils, issuerAccount, marketplaceAuthToken, receiverAddress, receiverPublicKey, additionalParams?): Promise\<string>

Parameters

NameType
signatureUtilsSignatureUtils
issuerAccountNvmAccount
marketplaceAuthTokenstring
receiverAddressstring
receiverPublicKeystring
additionalParamsObject

Returns

Promise\<string>

Defined in

src/models/NvmApiKey.ts:112


getSignerAddress

getSignerAddress(jwtString): Promise\<string>

Given a signed JWT, it recovers the signer address

Parameters

NameTypeDescription
jwtStringstringThe signed JWT

Returns

Promise\<string>

The signer address

Defined in

src/models/NvmApiKey.ts:150


hash

hash(serialized): string

Given a serialized string, it generates the hash

Parameters

NameTypeDescription
serializedstringthe serialized string

Returns

string

the hash

Defined in

src/models/NvmApiKey.ts:289