@tma.js/init-data-node 1.3.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +9 -9
- package/dist/buf-converters.d.ts +13 -0
- package/dist/entries/node.cjs +87 -10
- package/dist/entries/node.cjs.map +1 -1
- package/dist/entries/node.d.ts +34 -11
- package/dist/entries/node.js +70 -13
- package/dist/entries/node.js.map +1 -1
- package/dist/entries/parsing-Cj_BXCnv.cjs +258 -0
- package/dist/entries/parsing-Cj_BXCnv.cjs.map +1 -0
- package/dist/entries/parsing-eczkSd-W.js +241 -0
- package/dist/entries/parsing-eczkSd-W.js.map +1 -0
- package/dist/entries/shared.d.ts +6 -4
- package/dist/entries/web.cjs +125 -24
- package/dist/entries/web.cjs.map +1 -1
- package/dist/entries/web.d.ts +39 -11
- package/dist/entries/web.js +106 -26
- package/dist/entries/web.js.map +1 -1
- package/dist/errors.d.ts +21 -0
- package/dist/hashToken.d.ts +2 -0
- package/dist/parsing.d.ts +10 -0
- package/dist/signDataFp.d.ts +13 -0
- package/dist/signFp.d.ts +35 -0
- package/dist/types.d.ts +6 -9
- package/dist/validation.d.ts +67 -0
- package/package.json +14 -8
- package/dist/entries/index-Brzmngqx.js +0 -369
- package/dist/entries/index-Brzmngqx.js.map +0 -1
- package/dist/entries/index-CDcPFeVC.cjs +0 -368
- package/dist/entries/index-CDcPFeVC.cjs.map +0 -1
- package/dist/initDataToSearchParams.d.ts +0 -3
- package/dist/sign.d.ts +0 -20
- package/dist/signData.d.ts +0 -17
- package/dist/validate.d.ts +0 -39
package/dist/signData.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
/**
|
|
3
|
-
* Signs specified data with the passed token.
|
|
4
|
-
* @param data - data to sign.
|
|
5
|
-
* @param key - private key.
|
|
6
|
-
* @param createHmac - function to create HMAC-SHA256.
|
|
7
|
-
* @returns Data sign.
|
|
8
|
-
*/
|
|
9
|
-
export declare function signData(data: string, key: string, createHmac: (data: string, key: string | Buffer) => Buffer): string;
|
|
10
|
-
/**
|
|
11
|
-
* Signs specified data with the passed token.
|
|
12
|
-
* @param data - data to sign.
|
|
13
|
-
* @param key - private key.
|
|
14
|
-
* @param createHmac - function to create HMAC-SHA256.
|
|
15
|
-
* @returns Data sign.
|
|
16
|
-
*/
|
|
17
|
-
export declare function signData(data: string, key: string, createHmac: (data: string, key: string | Buffer) => Promise<Buffer>): Promise<string>;
|
package/dist/validate.d.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { InitData, InitDataParsed } from '@tma.js/sdk';
|
|
2
|
-
import { SignDataAsyncFn, SignDataSyncFn } from './types.js';
|
|
3
|
-
|
|
4
|
-
export interface ValidateOptions {
|
|
5
|
-
/**
|
|
6
|
-
* Time in seconds which states, how long from creation time init data is considered valid.
|
|
7
|
-
*
|
|
8
|
-
* In other words, in case when authDate + expiresIn is before current time, init data is
|
|
9
|
-
* recognized as expired.
|
|
10
|
-
*
|
|
11
|
-
* In case this value is equal to 0, the function does not check init data expiration.
|
|
12
|
-
* @default 86400 (1 day)
|
|
13
|
-
*/
|
|
14
|
-
expiresIn?: number;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Validates passed init data.
|
|
18
|
-
* @param value - value to check.
|
|
19
|
-
* @param token - bot secret token.
|
|
20
|
-
* @param signData - function signing data.
|
|
21
|
-
* @param options - additional validation options.
|
|
22
|
-
* @throws {TypeError} "auth_date" should present integer
|
|
23
|
-
* @throws {Error} "hash" is empty or not found
|
|
24
|
-
* @throws {Error} "auth_date" is empty or not found
|
|
25
|
-
* @throws {Error} Init data expired
|
|
26
|
-
*/
|
|
27
|
-
export declare function validate(value: InitData | InitDataParsed | string | URLSearchParams, token: string, signData: SignDataSyncFn, options?: ValidateOptions): void | never;
|
|
28
|
-
/**
|
|
29
|
-
* Validates passed init data.
|
|
30
|
-
* @param value - value to check.
|
|
31
|
-
* @param token - bot secret token.
|
|
32
|
-
* @param signData - function signing data.
|
|
33
|
-
* @param options - additional validation options.
|
|
34
|
-
* @throws {TypeError} "auth_date" should present integer
|
|
35
|
-
* @throws {Error} "hash" is empty or not found
|
|
36
|
-
* @throws {Error} "auth_date" is empty or not found
|
|
37
|
-
* @throws {Error} Init data expired
|
|
38
|
-
*/
|
|
39
|
-
export declare function validate(value: InitData | InitDataParsed | string | URLSearchParams, token: string, signData: SignDataAsyncFn, options?: ValidateOptions): Promise<void>;
|