Home Reference Source Test
public class | source

Encryption

The Hyperwallet Encryption processor

Test:

Static Method Summary

Static Public Methods
public static

base64Decode(encryptedBody: string): *

Convert encrypted string to array of Buffer

public static

base64Encode(decodedBody: string): *

Convert array of Buffer to encrypted string

public static

checkUrlIsValid(url: string, callback: string)

Checks if an input string is a valid URL

public static

Get current time in seconds

public static

readKeySet(keySetPath: string): *

Reads JWK set in JSON format either from given URL or path to local file

Constructor Summary

Public Constructor
public

constructor(clientPrivateKeySetLocation: string, hyperwalletKeySetLocation: string, encryptionAlgorithm: string, signAlgorithm: string, encryptionMethod: string, jwsExpirationMinutes: string)

Create a instance of the Encryption service

Member Summary

Protected Members
protected

Client KeyStore object

protected

String that can be a URL or path to file with client JWK set

protected

JWE encryption algorithm, by default value = RSA-OAEP-256

protected

JWE encryption method, by default value = A256CBC-HS512

protected

Hyperwallet KeyStore object

protected

String that can be a URL or path to file with hyperwallet JWK set

protected

Minutes when JWS signature is valid, by default value = 5

protected

JWS signature algorithm, by default value = RS256

Method Summary

Public Methods
public

Verify if response body has a valid signature

public

Creates 2 JWK key stores : 1) for client keys 2) for hyperwallet keys

public

createKeyStoreFromJwkSet(jwkSetPath: string, jwkSet: string): *

Converts JWK set in JSON format to JOSE key store format

public

decrypt(body: string): *

Decrypts encrypted response : 1) decrypts the request body; 2) verifies the payload signature

public

decryptBody(body: string): *

Decrypts the response body

public

encrypt(body: string): *

Makes an encrypted request : 1) signs the request body; 2) encrypts payload after signature

public

encryptBody(body: string): *

Encrypts the request body

public

Calculates signature expiration time in seconds ( by default expiration time = 5 minutes )

public

signBody(body: string): *

Makes signature for request body

Static Public Methods

public static base64Decode(encryptedBody: string): * source

Convert encrypted string to array of Buffer

Params:

NameTypeAttributeDescription
encryptedBody string

Encrypted body to be decoded

Return:

*

public static base64Encode(decodedBody: string): * source

Convert array of Buffer to encrypted string

Params:

NameTypeAttributeDescription
decodedBody string

Array of Buffer to be decoded to encrypted string

Return:

*

public static checkUrlIsValid(url: string, callback: string) source

Checks if an input string is a valid URL

Params:

NameTypeAttributeDescription
url string

The URL string to be verified

callback string

The callback method to process the verification result of input url

public static getCurrentTime(): * source

Get current time in seconds

Return:

*

public static readKeySet(keySetPath: string): * source

Reads JWK set in JSON format either from given URL or path to local file

Params:

NameTypeAttributeDescription
keySetPath string

The location of JWK set (can be URL string or path to file)

Return:

*

Public Constructors

public constructor(clientPrivateKeySetLocation: string, hyperwalletKeySetLocation: string, encryptionAlgorithm: string, signAlgorithm: string, encryptionMethod: string, jwsExpirationMinutes: string) source

Create a instance of the Encryption service

Params:

NameTypeAttributeDescription
clientPrivateKeySetLocation string

String that can be a URL or path to file with client JWK set

hyperwalletKeySetLocation string

String that can be a URL or path to file with hyperwallet JWK set

encryptionAlgorithm string

JWE encryption algorithm, by default value = RSA-OAEP-256

signAlgorithm string

JWS signature algorithm, by default value = RS256

encryptionMethod string

JWE encryption method, by default value = A256CBC-HS512

jwsExpirationMinutes string

Minutes when JWS signature is valid

Test:

Protected Members

protected clientKeyStore: string source

Client KeyStore object

protected clientPrivateKeySetLocation: string source

String that can be a URL or path to file with client JWK set

protected encryptionAlgorithm: string source

JWE encryption algorithm, by default value = RSA-OAEP-256

protected encryptionMethod: string source

JWE encryption method, by default value = A256CBC-HS512

protected hwKeyStore: string source

Hyperwallet KeyStore object

protected hyperwalletKeySetLocation: string source

String that can be a URL or path to file with hyperwallet JWK set

protected jwsExpirationMinutes: number source

Minutes when JWS signature is valid, by default value = 5

protected signAlgorithm: string source

JWS signature algorithm, by default value = RS256

Public Methods

public checkSignature(body: string): * source

Verify if response body has a valid signature

Params:

NameTypeAttributeDescription
body string

The response body to be verified

Return:

*

public createKeyStore(): * source

Creates 2 JWK key stores : 1) for client keys 2) for hyperwallet keys

Return:

*

public createKeyStoreFromJwkSet(jwkSetPath: string, jwkSet: string): * source

Converts JWK set in JSON format to JOSE key store format

Params:

NameTypeAttributeDescription
jwkSetPath string

The location of JWK set (can be URL string or path to file)

jwkSet string

The JSON representation of JWK set, to be converted to keystore

Return:

*

public decryptBody(body: string): * source

Decrypts the response body

Params:

NameTypeAttributeDescription
body string

The response body to be decrypted

Return:

*

public encryptBody(body: string): * source

Encrypts the request body

Params:

NameTypeAttributeDescription
body string

The request body to be encrypted

Return:

*

public getSignatureExpirationTime(): * source

Calculates signature expiration time in seconds ( by default expiration time = 5 minutes )

Return:

*

public signBody(body: string): * source

Makes signature for request body

Params:

NameTypeAttributeDescription
body string

The request body to be signed

Return:

*