Util
Class to provide static utility functions.
Static Method Summary
Static Public Methods | ||
public static |
bufferKey(key: string): Uint8Array Converts a key from a string to buffer. |
|
public static |
Helper method to handle promise exceptions. |
|
public static |
Helper method similar to the one above, but without promises |
|
public static |
countDecimals(value: Number): Number Count the number of decimal points in a number |
|
public static |
disableIframePassthrough(suffix: string) If we're on a token page, this disables passthrough |
|
public static |
enableIframePassthrough(suffix: string, url: string) If we're on a token page, sets up an iframe to avoid CORS preflights. All requests in this window will be routed through the iframe. |
|
public static |
Generates a random nonce |
|
public static |
Gets the specified byte of the 4 byte word, according to index. |
|
public static |
getSigningKey(keys: Array, signature: Object): Object Gets the signing key from a list of keys corresponding to the signature. |
|
public static |
hashAndSerializeAlias(alias: Object): String Support alias hashing |
|
public static |
hashString(value: string): string Hash a string value. |
|
public static |
isEdge(): * |
|
public static |
isFirefox(): * |
|
public static |
isIE11(): * |
|
public static |
parseParamsFromUrl(url: *): * |
|
public static |
Generates a random alias. |
|
public static |
setUpCustomResponseInterceptor(instance: *, cri: *) |
|
public static |
setUpHttpErrorLogging(instance: *) |
|
public static |
strKey(key: Uint8Array): string Converts a key to string. |
|
public static |
stringEndsWith(str: string, suffix: string): boolean Tests if a string ends with a suffix, |
|
public static |
tokenAlias(): Object Returns the token alias. |
|
public static |
wrapBuffer(buffer: string | Buffer): Uint8Array Wraps buffer as an Uint8Array object. |
Static Public Methods
public static bufferKey(key: string): Uint8Array source
Converts a key from a string to buffer.
Params:
Name | Type | Attribute | Description |
key | string | base64url encoded key |
public static async callAsync(method: function, fn: function): Promise source
Helper method to handle promise exceptions. The function will be executed, and if anything fails, a rejected promise is returned, with the method name that failed, included in the rejection.
public static callSync(method: function, fn: function): Object source
Helper method similar to the one above, but without promises
public static countDecimals(value: Number): Number source
Count the number of decimal points in a number
Params:
Name | Type | Attribute | Description |
value | Number | number |
public static disableIframePassthrough(suffix: string) source
If we're on a token page, this disables passthrough
Params:
Name | Type | Attribute | Description |
suffix | string | domain suffix for Iframe passthrough |
public static enableIframePassthrough(suffix: string, url: string) source
If we're on a token page, sets up an iframe to avoid CORS preflights. All requests in this window will be routed through the iframe.
public static getByte(word: number, index: number): number source
Gets the specified byte of the 4 byte word, according to index. Assumes 2s complement representation of the word
public static getSigningKey(keys: Array, signature: Object): Object source
Gets the signing key from a list of keys corresponding to the signature.
public static hashAndSerializeAlias(alias: Object): String source
Support alias hashing
Params:
Name | Type | Attribute | Description |
alias | Object | alias to be hashed |
public static hashString(value: string): string source
Hash a string value.
Params:
Name | Type | Attribute | Description |
value | string | value to be hahsed |
public static parseParamsFromUrl(url: *): * source
Params:
Name | Type | Attribute | Description |
url | * |
Return:
* |
public static setUpCustomResponseInterceptor(instance: *, cri: *) source
Params:
Name | Type | Attribute | Description |
instance | * | ||
cri | * |
public static setUpHttpErrorLogging(instance: *) source
Params:
Name | Type | Attribute | Description |
instance | * |
public static strKey(key: Uint8Array): string source
Converts a key to string.
Params:
Name | Type | Attribute | Description |
key | Uint8Array | key to encode |
public static stringEndsWith(str: string, suffix: string): boolean source
Tests if a string ends with a suffix,
public static wrapBuffer(buffer: string | Buffer): Uint8Array source
Wraps buffer as an Uint8Array object.
Params:
Name | Type | Attribute | Description |
buffer | string | Buffer | data |