dna-api 0.4.12 → 0.5.1

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.
@@ -1,9 +1,21 @@
1
1
  import { TimeBasicResponse } from "../TimeBasicResponse";
2
2
  import { type HeadersPayload, type RequestOptions } from "./utils";
3
+ export interface DNABaseAPIConfig {
4
+ server?: "cn" | "global";
5
+ dev_code?: string;
6
+ token?: string;
7
+ kf_token?: string;
8
+ fetchFn?: typeof fetch;
9
+ is_h5?: boolean;
10
+ rsa_public_key?: string;
11
+ mode?: "android" | "ios";
12
+ debug?: boolean;
13
+ }
3
14
  export declare class DNABaseAPI {
4
15
  fetchFn?: typeof fetch;
5
16
  RSA_PUBLIC_KEY: string;
6
17
  BASE_URL: string;
18
+ BASE_WEB_SOCKET_URL: string;
7
19
  KF_BASE_URL: string;
8
20
  uploadKey: string;
9
21
  sign_api_urls: Set<string>;
@@ -13,15 +25,8 @@ export declare class DNABaseAPI {
13
25
  kf_token: string;
14
26
  debug: boolean;
15
27
  cookieToken: string;
16
- constructor(options?: {
17
- dev_code?: string;
18
- token?: string;
19
- kf_token?: string;
20
- fetchFn?: typeof fetch;
21
- rsa_public_key?: string;
22
- mode?: "ios" | "android";
23
- debug?: boolean;
24
- });
28
+ server: string;
29
+ constructor(options?: DNABaseAPIConfig);
25
30
  fileUpload(url: string, data: FormData): Promise<TimeBasicResponse<string[]>>;
26
31
  getRsaPublicKey(): Promise<string>;
27
32
  getHeaders(options?: {
@@ -0,0 +1,39 @@
1
+ export declare const GAME_ID_OC = "159";
2
+ export declare const PROJECT_ID = "10456";
3
+ export declare const FB_APP_ID = "1969162350523490";
4
+ export declare const FB_CLIENT_TOKEN = "e1efe6e74f2ae46f87231bb519d3a304";
5
+ export declare const TWITTER_KEY = "HJgwHbASKFT9P9WeGVZhaHi5V";
6
+ export declare const TWITTER_SECRET = "VmqVoGcCRsUggpXrEQpbttkTLftuIJveD3okOVWpcOEc5vDc13";
7
+ export declare const PRODUCT_CODE = "459";
8
+ export declare const PRODUCT_KEY = "la3nh98r46032fn90tzl";
9
+ /**
10
+ * email 密码加密
11
+ * @param password 原始密码
12
+ * @returns 加密后的密码
13
+ */
14
+ export declare function hashPassword(password: string): string;
15
+ /**
16
+ * 生成 UltraSDK 签名
17
+ * @param productKey 产品密钥
18
+ * @param params 参数数组,格式为 [key1, value1, key2, value2, ...]
19
+ * @returns MD5 签名字符串
20
+ */
21
+ export declare function markSign(...params: string[]): string;
22
+ /**
23
+ * 生成 sendVerifyCode API 的 data 参数
24
+ * @param params 参数对象
25
+ * @returns 编码后的 data 字符串
26
+ */
27
+ export declare function generateDataParam(params: Record<string, any>): string;
28
+ /**
29
+ * 解析 sendVerifyCode API 的 data 参数
30
+ * @param encodedData 编码后的 data 字符串
31
+ * @returns 解析后的参数对象
32
+ */
33
+ export declare function parseDataParam(encodedData: string): Record<string, any> | null;
34
+ /**
35
+ * 生成 emailVerify 接口的请求参数
36
+ * @param customParams 自定义参数对象
37
+ * @returns URL 查询字符串
38
+ */
39
+ export declare function generateEmailVerifyParams(customParams: Record<string, any>): string;
@@ -1,5 +1,17 @@
1
1
  import type { DNABlockBean, DNACanEditNickNameBean, DNACommonConfigEntity, DNAConfigSwitchBean, DNAEmojiConfigBean, DNAFollowGameIdBean, DNAGameConfigResponse, DNAGameNewHeadBean, DNAHaveOfficialRoleBean, DNAIsRedPointBean, DNAModeratorPermission, DNARecommendConfig, DNAScreenResponse, DNASplashResponse, DNATokenBean, DNAUserDataBean, DNAUserHeadResponse, DNAWikiVoEntity } from "../type-generated";
2
2
  import { DNASubModule } from "./base";
3
+ export declare enum LoginType {
4
+ EMAIL = 1,
5
+ FACEBOOK = 1,
6
+ FACEBOOK_TYPE = 11,
7
+ GOOGLE = 2,
8
+ X = 5
9
+ }
10
+ export declare enum EmailWithPwd {
11
+ CODE = "0",
12
+ PWD = "1",
13
+ EMAIL_TOKEN = "2"
14
+ }
3
15
  export declare class UserAPI extends DNASubModule {
4
16
  loginLog(): Promise<import("..").TimeBasicResponse<any>>;
5
17
  blockList(): Promise<import("..").TimeBasicResponse<DNABlockBean>>;
@@ -21,6 +33,15 @@ export declare class UserAPI extends DNASubModule {
21
33
  haveOfficialRole(): Promise<import("..").TimeBasicResponse<DNAHaveOfficialRoleBean>>;
22
34
  isRedPoint(): Promise<import("..").TimeBasicResponse<DNAIsRedPointBean>>;
23
35
  login(mobile: string, code: string): Promise<import("..").TimeBasicResponse<DNAUserDataBean>>;
36
+ sendEmailVerifyCode(email: string): Promise<Response>;
37
+ loginEmail(email: string, pwd: string, accessToken: string): Promise<import("..").TimeBasicResponse<DNAUserDataBean>>;
38
+ /**
39
+ * 邮箱验证码登录,返回 accessToken
40
+ * @param email 邮箱地址
41
+ * @param code 验证码
42
+ * @returns accessToken
43
+ */
44
+ emailVerify(email: string, code: string): Promise<string>;
24
45
  oneTapLoginRestriction(): Promise<import("..").TimeBasicResponse<any>>;
25
46
  recommendConfig(): Promise<import("..").TimeBasicResponse<DNARecommendConfig>>;
26
47
  refreshToken(refreshToken: string): Promise<import("..").TimeBasicResponse<DNATokenBean>>;
@@ -36,4 +57,53 @@ export declare class UserAPI extends DNASubModule {
36
57
  getEmoji(): Promise<import("..").TimeBasicResponse<DNAEmojiConfigBean[]>>;
37
58
  getGameConfig(): Promise<import("..").TimeBasicResponse<DNAGameConfigResponse[]>>;
38
59
  getGameHeadCode(): Promise<import("..").TimeBasicResponse<DNAGameNewHeadBean[]>>;
60
+ /**
61
+ * Facebook OAuth 登录
62
+ * @param accessToken Facebook 访问令牌
63
+ * @returns 登录结果
64
+ */
65
+ facebookLogin(accessToken: string): Promise<import("..").TimeBasicResponse<DNAUserDataBean>>;
66
+ /**
67
+ * Twitter OAuth 登录
68
+ * @param accessToken Twitter 访问令牌
69
+ * @param accessTokenSecret Twitter 访问令牌密钥
70
+ * @returns 登录结果
71
+ */
72
+ twitterLogin(accessToken: string, accessTokenSecret: string): Promise<import("..").TimeBasicResponse<DNAUserDataBean>>;
73
+ /**
74
+ * 获取 Facebook OAuth 访问令牌
75
+ * @param code Facebook 授权码
76
+ * @param redirectUri 重定向 URI
77
+ * @returns Facebook 访问令牌
78
+ */
79
+ getFacebookAccessToken(code: string, redirectUri: string): Promise<any>;
80
+ /**
81
+ * 获取 Twitter OAuth 访问令牌
82
+ * @param oauthToken Twitter 请求令牌
83
+ * @param oauthVerifier Twitter 验证码
84
+ * @returns Twitter 访问令牌和密钥
85
+ */
86
+ getTwitterAccessToken(oauthToken: string, oauthVerifier: string): Promise<{
87
+ accessToken: string;
88
+ accessTokenSecret: string;
89
+ userId: string;
90
+ screenName: string;
91
+ }>;
92
+ /**
93
+ * 获取 Twitter 请求令牌
94
+ * @param callbackUrl 回调 URL
95
+ * @returns Twitter 请求令牌和密钥
96
+ */
97
+ getTwitterRequestToken(callbackUrl: string): Promise<{
98
+ oauthToken: string;
99
+ oauthTokenSecret: string;
100
+ oauthCallbackConfirmed: boolean;
101
+ }>;
102
+ /**
103
+ * 生成 HMAC-SHA1 签名
104
+ * @param key 签名密钥
105
+ * @param data 待签名数据
106
+ * @returns Base64 编码的签名
107
+ */
108
+ private generateHmacSha1Signature;
39
109
  }
@@ -16,6 +16,7 @@ export interface HeadersPayload {
16
16
  }
17
17
  export declare function rsa_encrypt(text: string, public_key_b64: string): string;
18
18
  export declare function rand_str(length?: number): string;
19
+ export declare function rand_str2(length?: number): string;
19
20
  export declare function md5_upper(text: string): string;
20
21
  /**
21
22
  * MD5 结果位置混淆: 1↔13, 5↔17, 7↔23
@@ -35,10 +36,12 @@ export declare function build_sign_string(params: Record<string, any>, app_key:
35
36
  */
36
37
  export declare function sign_shuffled(params: Record<string, any>, app_key: string): string;
37
38
  export declare function xor_encode(text: string, key: string): string;
38
- export declare function build_signature(pk: string, payload: Record<string, any>, token?: string): Record<string, any>;
39
+ export declare function build_signature120(pk: string, payload: Record<string, any>, token?: string): Record<string, any>;
39
40
  export declare function build_upload_signature(public_key: string): {
40
41
  signature: string;
41
42
  key: string;
42
43
  };
43
44
  export declare function swapForUploadImgApp(text: string): string;
44
45
  export declare function aesDecryptImageUrl(encryptedUrl: string, key: string): string;
46
+ /** 1.1.1版本加密 */
47
+ export declare function build_signature111(data: Record<string, any>, token?: string): Record<string, any>;
@@ -531,6 +531,7 @@ export interface DNAUserDataBean {
531
531
  userName: string;
532
532
  isComplete: number;
533
533
  isOfficial: number;
534
+ registerLang?: string;
534
535
  }
535
536
  export interface DNARecommendConfig {
536
537
  exposureCacheNum: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dna-api",
3
- "version": "0.4.12",
3
+ "version": "0.5.1",
4
4
  "description": "dna bbs api",
5
5
  "author": {
6
6
  "name": "pa001024",