Class: MessageVerifier
Message verifier is similar to the encryption. However, the actual payload is not encrypted and just base64 encoded. This is helpful when you are not concerned about the confidentiality of the data, but just want to make sure that is not tampered after encoding.
Constructors
Constructor
ts
new MessageVerifier(secret: string): MessageVerifier;Parameters
| Parameter | Type |
|---|---|
secret | string |
Returns
MessageVerifier
Methods
encodable()
ts
encodable(value: unknown): boolean;Checks if the value can be encoded
Parameters
| Parameter | Type |
|---|---|
value | unknown |
Returns
boolean
sign()
ts
sign(
payload: any,
expiresIn?: string | number,
purpose?: string): string;Sign a given piece of value using the app secret. A wide range of data types are supported. See @nhtio/serialization for more information on the supported data types.
You can optionally define a purpose for which the value was signed and mentioning a different purpose/no purpose during unsign will fail.
Parameters
| Parameter | Type |
|---|---|
payload | any |
expiresIn? | string | number |
purpose? | string |
Returns
string
unsign()
ts
unsign<T>(payload: string, purpose?: string): null | T;Unsign a previously signed value with an optional purpose
Type Parameters
| Type Parameter |
|---|
T extends any |
Parameters
| Parameter | Type |
|---|---|
payload | string |
purpose? | string |
Returns
null | T
encodable()
ts
static encodable(value: unknown): boolean;Checks if the value can be encoded
Parameters
| Parameter | Type |
|---|---|
value | unknown |
Returns
boolean