@ccw-api/api 0.4.2 → 0.6.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.
Files changed (119) hide show
  1. package/README.md +591 -367
  2. package/dist/esm/community-web/ccw-mall/ccw/product/fe/query.js +34 -0
  3. package/dist/esm/community-web/ccw-mall/ccw/product/fe/query.test.js +8 -0
  4. package/dist/esm/community-web/comment/page_by_topic.js +1 -1
  5. package/dist/esm/community-web/extensions/creation-like/detail.js +14 -0
  6. package/dist/esm/community-web/extensions/creation-like/detail.test.js +4 -0
  7. package/dist/esm/community-web/extensions/following/status.js +14 -0
  8. package/dist/esm/community-web/extensions/following/status.test.js +4 -0
  9. package/dist/esm/community-web/great_creation/update.js +13 -0
  10. package/dist/esm/community-web/great_creation/update.test.js +4 -0
  11. package/dist/esm/community-web/index.js +22 -0
  12. package/dist/esm/community-web/post/post.test.js +0 -1
  13. package/dist/esm/community-web/smart_contract/account.js +13 -0
  14. package/dist/esm/community-web/smart_contract/account.test.js +4 -0
  15. package/dist/esm/community-web/smart_contract/detail.js +13 -0
  16. package/dist/esm/community-web/smart_contract/detail.test.js +4 -0
  17. package/dist/esm/community-web/smart_contract/execute.js +17 -0
  18. package/dist/esm/community-web/smart_contract/execute.test.js +4 -0
  19. package/dist/esm/community-web/smart_contract/list.js +14 -0
  20. package/dist/esm/community-web/smart_contract/list.test.js +4 -0
  21. package/dist/esm/community-web/study-community/following/follow.js +13 -0
  22. package/dist/esm/community-web/study-community/following/follow.test.js +4 -0
  23. package/dist/esm/community-web/user_package/status.js +14 -0
  24. package/dist/esm/community-web/user_package/status.test.js +4 -0
  25. package/dist/esm/community-web/user_package/user_product.js +29 -0
  26. package/dist/esm/community-web/user_package/user_product.test.js +9 -0
  27. package/dist/esm/community-web-cloud-database/cloud_variable/detail/v2.js +16 -0
  28. package/dist/esm/community-web-cloud-database/cloud_variable/detail/v2.test.js +4 -0
  29. package/dist/esm/community-web-cloud-database/cloud_variable/save.js +29 -0
  30. package/dist/esm/community-web-cloud-database/cloud_variable/save.test.js +13 -0
  31. package/dist/esm/community-web-cloud-database/index.js +7 -0
  32. package/dist/esm/gandi-main/creation/leaderboards/{oid}/records.js +28 -0
  33. package/dist/esm/gandi-main/creation/leaderboards/{oid}/records.test.js +11 -0
  34. package/dist/esm/gandi-main/index.js +3 -0
  35. package/dist/esm/index.js +5 -1
  36. package/dist/esm/op-parent-api/captcha/check.js +15 -0
  37. package/dist/esm/op-parent-api/captcha/check.test.js +12 -0
  38. package/dist/esm/op-parent-api/captcha/create.js +13 -0
  39. package/dist/esm/op-parent-api/captcha/create.test.js +13 -0
  40. package/dist/esm/op-parent-api/index.js +6 -0
  41. package/dist/esm/sso/index.js +4 -0
  42. package/dist/esm/sso/web/auth/assistant/captcha/v2/create.js +17 -0
  43. package/dist/esm/sso/web/auth/assistant/captcha/v2/create.test.js +8 -0
  44. package/dist/esm/sso/web/auth/login-by-password.js +4 -3
  45. package/dist/esm/sso/web/auth/v3/login/by-phone.js +33 -0
  46. package/dist/esm/sso/web/auth/v3/login/by-phone.test.js +7 -0
  47. package/dist/node/community-web/ccw-mall/ccw/product/fe/query.js +38 -0
  48. package/dist/node/community-web/ccw-mall/ccw/product/fe/query.test.js +10 -0
  49. package/dist/node/community-web/comment/page_by_topic.js +1 -1
  50. package/dist/node/community-web/extensions/creation-like/detail.js +18 -0
  51. package/dist/node/community-web/extensions/creation-like/detail.test.js +6 -0
  52. package/dist/node/community-web/extensions/following/status.js +18 -0
  53. package/dist/node/community-web/extensions/following/status.test.js +6 -0
  54. package/dist/node/community-web/great_creation/update.js +17 -0
  55. package/dist/node/community-web/great_creation/update.test.js +6 -0
  56. package/dist/node/community-web/index.js +22 -0
  57. package/dist/node/community-web/post/post.test.js +0 -1
  58. package/dist/node/community-web/smart_contract/account.js +17 -0
  59. package/dist/node/community-web/smart_contract/account.test.js +6 -0
  60. package/dist/node/community-web/smart_contract/detail.js +17 -0
  61. package/dist/node/community-web/smart_contract/detail.test.js +6 -0
  62. package/dist/node/community-web/smart_contract/execute.js +21 -0
  63. package/dist/node/community-web/smart_contract/execute.test.js +6 -0
  64. package/dist/node/community-web/smart_contract/list.js +18 -0
  65. package/dist/node/community-web/smart_contract/list.test.js +6 -0
  66. package/dist/node/community-web/study-community/following/follow.js +17 -0
  67. package/dist/node/community-web/study-community/following/follow.test.js +6 -0
  68. package/dist/node/community-web/user_package/status.js +18 -0
  69. package/dist/node/community-web/user_package/status.test.js +6 -0
  70. package/dist/node/community-web/user_package/user_product.js +33 -0
  71. package/dist/node/community-web/user_package/user_product.test.js +11 -0
  72. package/dist/node/community-web-cloud-database/cloud_variable/detail/v2.js +20 -0
  73. package/dist/node/community-web-cloud-database/cloud_variable/detail/v2.test.js +6 -0
  74. package/dist/node/community-web-cloud-database/cloud_variable/save.js +34 -0
  75. package/dist/node/community-web-cloud-database/cloud_variable/save.test.js +15 -0
  76. package/dist/node/community-web-cloud-database/index.js +10 -0
  77. package/dist/node/gandi-main/creation/leaderboards/{oid}/records.js +33 -0
  78. package/dist/node/gandi-main/creation/leaderboards/{oid}/records.test.js +13 -0
  79. package/dist/node/gandi-main/index.js +3 -0
  80. package/dist/node/index.js +7 -1
  81. package/dist/node/op-parent-api/captcha/check.js +19 -0
  82. package/dist/node/op-parent-api/captcha/check.test.js +14 -0
  83. package/dist/node/op-parent-api/captcha/create.js +17 -0
  84. package/dist/node/op-parent-api/captcha/create.test.js +15 -0
  85. package/dist/node/op-parent-api/index.js +9 -0
  86. package/dist/node/sso/index.js +4 -0
  87. package/dist/node/sso/web/auth/assistant/captcha/v2/create.js +21 -0
  88. package/dist/node/sso/web/auth/assistant/captcha/v2/create.test.js +10 -0
  89. package/dist/node/sso/web/auth/login-by-password.js +4 -3
  90. package/dist/node/sso/web/auth/v3/login/by-phone.js +37 -0
  91. package/dist/node/sso/web/auth/v3/login/by-phone.test.js +9 -0
  92. package/dist/types/community-web/ccw-mall/ccw/product/fe/query.d.ts +54 -0
  93. package/dist/types/community-web/comment/page_by_topic.d.ts +1 -1
  94. package/dist/types/community-web/extensions/creation-like/detail.d.ts +18 -0
  95. package/dist/types/community-web/extensions/following/status.d.ts +19 -0
  96. package/dist/types/community-web/great_creation/update.d.ts +12 -0
  97. package/dist/types/community-web/index.d.ts +22 -0
  98. package/dist/types/community-web/post/detail.d.ts +1 -1
  99. package/dist/types/community-web/smart_contract/account.d.ts +13 -0
  100. package/dist/types/community-web/smart_contract/detail.d.ts +24 -0
  101. package/dist/types/community-web/smart_contract/execute.d.ts +25 -0
  102. package/dist/types/community-web/smart_contract/list.d.ts +49 -0
  103. package/dist/types/community-web/study-community/following/follow.d.ts +12 -0
  104. package/dist/types/community-web/user_package/status.d.ts +13 -0
  105. package/dist/types/community-web/user_package/user_product.d.ts +40 -0
  106. package/dist/types/community-web-cloud-database/cloud_variable/detail/v2.d.ts +17 -0
  107. package/dist/types/community-web-cloud-database/cloud_variable/save.d.ts +26 -0
  108. package/dist/types/community-web-cloud-database/index.d.ts +7 -0
  109. package/dist/types/gandi-main/creation/leaderboards/{oid}/records.d.ts +62 -0
  110. package/dist/types/gandi-main/index.d.ts +3 -0
  111. package/dist/types/index.d.ts +27 -1
  112. package/dist/types/op-parent-api/captcha/check.d.ts +21 -0
  113. package/dist/types/op-parent-api/captcha/create.d.ts +24 -0
  114. package/dist/types/op-parent-api/index.d.ts +6 -0
  115. package/dist/types/sso/index.d.ts +4 -0
  116. package/dist/types/sso/web/auth/assistant/captcha/v2/create.d.ts +34 -0
  117. package/dist/types/sso/web/auth/login-by-password.d.ts +2 -18
  118. package/dist/types/sso/web/auth/v3/login/by-phone.d.ts +38 -0
  119. package/package.json +2 -2
@@ -0,0 +1,17 @@
1
+ export declare const url = "https://community-web-cloud-database.ccw.site/cloud_variable/detail/v2";
2
+ export type Req = {
3
+ accessKey: string;
4
+ primaryKey: string;
5
+ secondaryKey: string;
6
+ filterKeys: string[];
7
+ };
8
+ export type Res = {};
9
+ /**
10
+ * 查询云变量详情 V2
11
+ * @param {string} accessKey 访问密钥(如作品 OID)
12
+ * @param {string} primaryKey 主键(如 `${projectId}-u`)
13
+ * @param {string} secondaryKey 次级键
14
+ * @param {string[]} filterKeys 过滤的变量名列表
15
+ * @returns {Promise<Res>} 云变量详情
16
+ */
17
+ export declare function getCloudVariableDetailV2(accessKey: string, primaryKey: string, secondaryKey: string, filterKeys: string[]): Promise<Res>;
@@ -0,0 +1,26 @@
1
+ import { MongoDBId } from "src/types/api";
2
+ export declare const url = "https://community-web-cloud-database.ccw.site/cloud_variable/save";
3
+ export type SaveCloudVariableReq<T extends Record<string, unknown>> = {
4
+ primaryKey: string;
5
+ secondaryKey: string;
6
+ value: T;
7
+ };
8
+ export type SaveCloudVariableRes<T extends Record<string, unknown>> = T;
9
+ /**
10
+ * 保存作品云变量到云数据库
11
+ * @param {MongoDBId} projectId 作品id
12
+ * @param {string} secondaryKey 次级键 - 变量名或标识
13
+ * @param {T} value 要保存数据
14
+ * @returns {Promise<SaveCloudVariableRes<T>>} 保存后的值对象
15
+ */
16
+ export declare function saveProjectCloudVariable<T extends string>(projectId: MongoDBId, secondaryKey: string, value: T): Promise<SaveCloudVariableRes<{
17
+ v: T;
18
+ }>>;
19
+ /**
20
+ * 保存数据到用户云数据库
21
+ * @param {MongoDBId} projectId 作品id
22
+ * @param {number} studentNum 次级键 - 用户id
23
+ * @param {T} value 要保存的键值对
24
+ * @returns {Promise<SaveCloudVariableRes<T>>} 保存后的值对象
25
+ */
26
+ export declare function saveUserCloudVariable<T extends Record<string, string>>(projectId: MongoDBId, studentNum: number, value: T): Promise<SaveCloudVariableRes<T>>;
@@ -0,0 +1,7 @@
1
+ import { saveProjectCloudVariable, saveUserCloudVariable } from "./cloud_variable/save";
2
+ import { getCloudVariableDetailV2 } from "./cloud_variable/detail/v2";
3
+ export declare const communityWebCloudDatabase: {
4
+ saveProjectCloudVariable: typeof saveProjectCloudVariable;
5
+ saveUserCloudVariable: typeof saveUserCloudVariable;
6
+ getCloudVariableDetailV2: typeof getCloudVariableDetailV2;
7
+ };
@@ -0,0 +1,62 @@
1
+ import { CNameOssUrl, MongoDBId } from "src/types/api";
2
+ import { SortType } from "src/types/pages";
3
+ export declare const url = "https://gandi-main.ccw.site/creation/leaderboards";
4
+ export type SubmitReq = {
5
+ ext: string;
6
+ oid: MongoDBId;
7
+ score: number;
8
+ };
9
+ export type SubmitRes = boolean;
10
+ export type LeaderboardUser = {
11
+ avatar: null | CNameOssUrl;
12
+ id: MongoDBId;
13
+ locked: null | boolean;
14
+ nickname: null | string;
15
+ };
16
+ export type LeaderboardRecord = {
17
+ createdAt: number;
18
+ ext: string;
19
+ leaderboardOid: MongoDBId;
20
+ oid: MongoDBId;
21
+ ranking: number;
22
+ score: number;
23
+ updatedAt: number;
24
+ user: LeaderboardUser;
25
+ userId: MongoDBId;
26
+ };
27
+ export type ScoreFormat = "DECIMAL_WITH_SEPARATOR" | string;
28
+ export type ScoreStorageRule = "BEST" | string;
29
+ export type StatsCycle = "ALL_DAYS" | string;
30
+ export type LeaderboardRecordsRes = {
31
+ coverLink: null | CNameOssUrl;
32
+ createdAt: number;
33
+ creationId: MongoDBId;
34
+ curUserLeaderboardRecord: null | LeaderboardRecord;
35
+ displayLines: number;
36
+ leaderboardRecordTotalNum: number;
37
+ leaderboardRecords: LeaderboardRecord[];
38
+ oid: MongoDBId;
39
+ scoreFormat: ScoreFormat;
40
+ scoreStorageRule: ScoreStorageRule;
41
+ scoreUnit: string;
42
+ showPersonalRanking: boolean;
43
+ sortType: SortType;
44
+ statsCycle: StatsCycle;
45
+ title: string;
46
+ updatedAt: number;
47
+ };
48
+ /**
49
+ * 向作品排行榜提交一条分数记录
50
+ * @param {MongoDBId} leaderboardOid 排行榜id
51
+ * @param {number} score 分数
52
+ * @param {MongoDBId} userOid 用户id
53
+ * @param {string} ext 扩展信息(可选)
54
+ * @returns {Promise<SubmitRes>} 是否提交成功
55
+ */
56
+ export declare function submitLeaderboardRecord(leaderboardOid: MongoDBId, score: number, userOid: MongoDBId, ext?: string): Promise<SubmitRes>;
57
+ /**
58
+ * 获取作品排行榜记录列表
59
+ * @param {MongoDBId} leaderboardOid 排行榜id
60
+ * @returns {Promise<LeaderboardRecordsRes>} 排行榜记录列表
61
+ */
62
+ export declare function getLeaderboardRecords(leaderboardOid: MongoDBId): Promise<LeaderboardRecordsRes>;
@@ -1,8 +1,11 @@
1
1
  import { getCurrentTimestamp } from "./timestamp/current";
2
2
  import { getBulletinsPage } from "./bulletins/page";
3
3
  import { getBulletinDetail } from "./bulletins/detail";
4
+ import { getLeaderboardRecords, submitLeaderboardRecord } from "./creation/leaderboards/{oid}/records";
4
5
  export declare const gandiMain: {
5
6
  getCurrentTimestamp: typeof getCurrentTimestamp;
6
7
  getBulletinsPage: typeof getBulletinsPage;
7
8
  getBulletinDetail: typeof getBulletinDetail;
9
+ submitLeaderboardRecord: typeof submitLeaderboardRecord;
10
+ getLeaderboardRecords: typeof getLeaderboardRecords;
8
11
  };
@@ -2,18 +2,23 @@ import { sso } from "./sso/index";
2
2
  import { communityWeb } from "./community-web";
3
3
  import { gandiMain } from "./gandi-main";
4
4
  import { bfsWeb } from "./bfs-web";
5
- export { sso, communityWeb, gandiMain, bfsWeb };
5
+ import { communityWebCloudDatabase } from "./community-web-cloud-database";
6
+ import { opParentApi } from "./op-parent-api";
7
+ export { sso, communityWeb, gandiMain, bfsWeb, communityWebCloudDatabase, opParentApi, };
6
8
  export { setToken } from "@ccw-api/axios";
7
9
  declare const _default: {
8
10
  sso: {
9
11
  loginByPassword: typeof import("./sso/web/auth/login-by-password").loginByPassword;
10
12
  logout: typeof import("./sso/web/auth/logout").logout;
11
13
  logoutBySession: typeof import("./sso/web/auth/logout_by_session").logoutBySession;
14
+ createSmsCaptcha: typeof import("./sso/web/auth/assistant/captcha/v2/create").createSmsCaptcha;
15
+ loginByPhone: typeof import("./sso/web/auth/v3/login/by-phone").loginByPhone;
12
16
  };
13
17
  communityWeb: {
14
18
  acceptAward: typeof import("./community-web/task/award").acceptAward;
15
19
  donateTrade: typeof import("./community-web/study-trade/trade/donate").donateTrade;
16
20
  encodeShortCode: typeof import("./community-web/api/v1/short_code/encode").encodeShortCode;
21
+ executeSmartContract: typeof import("./community-web/smart_contract/execute").executeSmartContract;
17
22
  createCloudVariable: typeof import("./community-web/study-community/cloud_variable/create").createCloudVariable;
18
23
  createComment: typeof import("./community-web/comment/create").createComment;
19
24
  createShortUrl: typeof import("./community-web/short_url/create").createShortUrl;
@@ -21,6 +26,7 @@ declare const _default: {
21
26
  decompressShortUrl: typeof import("./community-web/short_url/decompress").decompressShortUrl;
22
27
  deleteComment: typeof import("./community-web/study-community/comment/delete").deleteComment;
23
28
  foldComment: typeof import("./community-web/study-community/comment/fold").foldComment;
29
+ followCreator: typeof import("./community-web/study-community/following/follow").followCreator;
24
30
  getApprovalTags: typeof import("./community-web/approval/list").getApprovalTags;
25
31
  getCampaignResources: typeof import("./community-web/campaign_resource/detail").getCampaignResources;
26
32
  getCcwMainStatus: typeof import("./community-web/ccw-main/status").getCCWMainStatus;
@@ -34,6 +40,7 @@ declare const _default: {
34
40
  getCreationDetail: typeof import("./community-web/creation/detail").getCreationDetail;
35
41
  getCreationFavoriteDetail: typeof import("./community-web/creation_favorite/detail").getCreationFavoriteDetail;
36
42
  getCreationIntroduction: typeof import("./community-web/creation/introduction/detail").getCreationIntroduction;
43
+ getConnectCommunityCreationLikeStatus: typeof import("./community-web/extensions/creation-like/detail").getConnectCommunityCreationLikeStatus;
37
44
  getCreationRecommendPositionList: typeof import("./community-web/creation_recommend_position/list").getCreationRecommendPositionList;
38
45
  getCreationReleasePage: typeof import("./community-web/creation_release/page").getCreationReleasePage;
39
46
  getCreationScreenshotPage: typeof import("./community-web/creation_screenshot/page").getCreationScreenshotPage;
@@ -42,6 +49,7 @@ declare const _default: {
42
49
  getCreatorScore: typeof import("./community-web/students/creator_score").getCreatorScore;
43
50
  getDonatedRecordRanking: typeof import("./community-web/creation_donated_record/ranking_list").getDonatedRecordRanking;
44
51
  getExcellentCreations: typeof import("./community-web/creation/excellent/list").getExcellentCreations;
52
+ getConnectCommunityFollowingStatus: typeof import("./community-web/extensions/following/status").getConnectCommunityFollowingStatus;
45
53
  getEmojiCategoryList: typeof import("./community-web/emoji/category/list").getEmojiCategoryList;
46
54
  getEmojiPage: typeof import("./community-web/emoji/page").getEmojiPage;
47
55
  getAllEmojis: typeof import("./community-web/emoji/all").getAllEmojis;
@@ -70,6 +78,9 @@ declare const _default: {
70
78
  getRemixedCreationPage: typeof import("./community-web/creation/page").getRemixedCreationPage;
71
79
  getReputationScoreLogPage: typeof import("./community-web/students/reputation_score_log/page").getReputationScoreLog;
72
80
  getSearchHotWords: typeof import("./community-web/search/hot_words").getSearchHotWords;
81
+ getSmartContractAccount: typeof import("./community-web/smart_contract/account").getSmartContractAccount;
82
+ getSmartContractDetail: typeof import("./community-web/smart_contract/detail").getSmartContractDetail;
83
+ getSmartContractList: typeof import("./community-web/smart_contract/list").getSmartContractList;
73
84
  getSplitRuleDetail: typeof import("./community-web/creation/smart_contract/split_rule/detail").getSplitRuleDetail;
74
85
  getSpreadFeedUnreadCount: typeof import("./community-web/study-community/spread_feed/unread/count").getSpreadFeedUnreadCount;
75
86
  getStudentBlockRecordDetail: typeof import("./community-web/student/block_record/detail").getStudentBlockRecordDetail;
@@ -93,6 +104,8 @@ declare const _default: {
93
104
  getUserAssetStorageSize: typeof import("./community-web/cloud_asset/user/privacy").getUserAssetStorageSize;
94
105
  getUserCardDetail: typeof import("./community-web/user-card/detail").getUserCardDetail;
95
106
  getUserLabelList: typeof import("./community-web/user_label/list").getUserLabelList;
107
+ getUserProductsPage: typeof import("./community-web/user_package/user_product").getUserProductsPage;
108
+ queryMallProducts: typeof import("./community-web/ccw-mall/ccw/product/fe/query").queryMallProducts;
96
109
  getCreationsByStudent: typeof import("./community-web/creation/page_by_student").getCreationsByStudent;
97
110
  insertCheckInRecord: typeof import("./community-web/check_in_record/insert").insertCheckInRecord;
98
111
  likeComment: typeof import("./community-web/comment/like_record/create").likeComment;
@@ -101,9 +114,11 @@ declare const _default: {
101
114
  searchCloudAssets: typeof import("./community-web/cloud_asset/search").searchCloudAssets;
102
115
  searchCreationsByTag: typeof import("./community-web/creation/search/page").searchCreationsByTag;
103
116
  sendEvent: typeof import("./community-web/event").sendEvent;
117
+ setUserProductStatus: typeof import("./community-web/user_package/status").setUserProductStatus;
104
118
  submitCreation: typeof import("./community-web/creation/submit").submitCreation;
105
119
  topComment: typeof import("./community-web/study-community/comment/top").topComment;
106
120
  updateCreation: typeof import("./community-web/creation/update").updateCreation;
121
+ updateGreatCreation: typeof import("./community-web/great_creation/update").updateGreatCreation;
107
122
  updateStudent: typeof import("./community-web/students/update").updateStudent;
108
123
  viewCreationStats: typeof import("./community-web/creation_stats/view").viewCreationStats;
109
124
  };
@@ -111,11 +126,22 @@ declare const _default: {
111
126
  getCurrentTimestamp: typeof import("./gandi-main/timestamp/current").getCurrentTimestamp;
112
127
  getBulletinsPage: typeof import("./gandi-main/bulletins/page").getBulletinsPage;
113
128
  getBulletinDetail: typeof import("./gandi-main/bulletins/detail").getBulletinDetail;
129
+ submitLeaderboardRecord: typeof import("./gandi-main/creation/leaderboards/{oid}/records").submitLeaderboardRecord;
130
+ getLeaderboardRecords: typeof import("./gandi-main/creation/leaderboards/{oid}/records").getLeaderboardRecords;
114
131
  };
115
132
  bfsWeb: {
116
133
  donateExtension: typeof import("./bfs-web/extensions/{eid}/donate").donateExtension;
117
134
  getUserExtensions: typeof import("./bfs-web/users/{oid}/extensions").getUserExtensions;
118
135
  };
136
+ communityWebCloudDatabase: {
137
+ saveProjectCloudVariable: typeof import("./community-web-cloud-database/cloud_variable/save").saveProjectCloudVariable;
138
+ saveUserCloudVariable: typeof import("./community-web-cloud-database/cloud_variable/save").saveUserCloudVariable;
139
+ getCloudVariableDetailV2: typeof import("./community-web-cloud-database/cloud_variable/detail/v2").getCloudVariableDetailV2;
140
+ };
141
+ opParentApi: {
142
+ createCaptcha: typeof import("./op-parent-api/captcha/create").createCaptcha;
143
+ checkCaptcha: typeof import("./op-parent-api/captcha/check").checkCaptcha;
144
+ };
119
145
  };
120
146
  export default _default;
121
147
  export type * from "./types";
@@ -0,0 +1,21 @@
1
+ export declare const url = "https://op-parent-api.xiguacity.cn/captcha/check";
2
+ export type Req = {
3
+ data: {
4
+ x: number;
5
+ y: number;
6
+ };
7
+ token: string;
8
+ };
9
+ export type Res = {
10
+ captchaExpired: boolean;
11
+ errorMsg: string | null;
12
+ success: boolean;
13
+ };
14
+ /**
15
+ * 校验图形验证码(拼图滑块坐标)
16
+ * @param {string} token createCaptcha 返回的 token
17
+ * @param {number} x 拼图滑块目标位置的 x 坐标
18
+ * @param {number} y 拼图滑块目标位置的 y 坐标
19
+ * @returns {Promise<Res>} 校验结果
20
+ */
21
+ export declare function checkCaptcha(token: string, x: number, y?: number): Promise<Res>;
@@ -0,0 +1,24 @@
1
+ export declare const url = "https://op-parent-api.xiguacity.cn/captcha/create";
2
+ export type CaptchaType = "BLOCK_PUZZLE";
3
+ export type Req = {
4
+ type: CaptchaType;
5
+ };
6
+ export type Res = {
7
+ data: {
8
+ /**
9
+ * data url
10
+ */
11
+ bgImg: string;
12
+ /**
13
+ * data url
14
+ */
15
+ jigsawImg: string;
16
+ };
17
+ token: string;
18
+ };
19
+ /**
20
+ * 创建图形验证码(拼图滑块)
21
+ * @param {CaptchaType} type 验证码类型,默认 BLOCK_PUZZLE(滑块拼图)
22
+ * @returns {Promise<Res>} 验证码信息:bgImg为背景图base64 data url,jigsawImg为拼图块base64 data url,token用于后续校验
23
+ */
24
+ export declare function createCaptcha(type?: CaptchaType): Promise<Res>;
@@ -0,0 +1,6 @@
1
+ import { createCaptcha } from "./captcha/create";
2
+ import { checkCaptcha } from "./captcha/check";
3
+ export declare const opParentApi: {
4
+ createCaptcha: typeof createCaptcha;
5
+ checkCaptcha: typeof checkCaptcha;
6
+ };
@@ -1,8 +1,12 @@
1
1
  import { loginByPassword } from "./web/auth/login-by-password";
2
2
  import { logout } from "./web/auth/logout";
3
3
  import { logoutBySession } from "./web/auth/logout_by_session";
4
+ import { createSmsCaptcha } from "./web/auth/assistant/captcha/v2/create";
5
+ import { loginByPhone } from "./web/auth/v3/login/by-phone";
4
6
  export declare const sso: {
5
7
  loginByPassword: typeof loginByPassword;
6
8
  logout: typeof logout;
7
9
  logoutBySession: typeof logoutBySession;
10
+ createSmsCaptcha: typeof createSmsCaptcha;
11
+ loginByPhone: typeof loginByPhone;
8
12
  };
@@ -0,0 +1,34 @@
1
+ export declare const url = "https://sso.ccw.site/web/auth/assistant/captcha/v2/create";
2
+ export type SmsScene = "loginbyPhone";
3
+ export type SmsRuleCode = "ccw_sms";
4
+ export type CaptchaPayload = {
5
+ data: {
6
+ x: number;
7
+ y: number;
8
+ };
9
+ token: string;
10
+ };
11
+ export type Req = {
12
+ captcha?: CaptchaPayload;
13
+ countryCode: string;
14
+ recipient: string;
15
+ ruleCode: SmsRuleCode;
16
+ scene: SmsScene;
17
+ };
18
+ export type Res = {
19
+ batchId: string | null;
20
+ /**
21
+ * sendResult=1 表示成功
22
+ */
23
+ sendResult: 1 | 2;
24
+ };
25
+ /**
26
+ * 发送短信验证码
27
+ * @param {string} recipient 接收手机号,如 "10011451919"
28
+ * @param {SmsScene} scene 场景,默认 loginbyPhone
29
+ * @param {string} countryCode 国家代码,默认 "86"
30
+ * @param {SmsRuleCode} ruleCode 短信规则编码,默认 "ccw_sms"
31
+ * @param {CaptchaPayload} captcha 图形验证码校验结果(滑块拼图的坐标与token),可选(部分场景未强制要求时可省略,但失败时sendResult!=1)
32
+ * @returns {Promise<Res>} 发送结果:batchId 为短信批次ID,sendResult=1 表示成功
33
+ */
34
+ export declare function createSmsCaptcha(recipient: string, scene?: SmsScene, countryCode?: string, ruleCode?: SmsRuleCode, captcha?: CaptchaPayload): Promise<Res>;
@@ -1,5 +1,5 @@
1
- import { AccountTypes } from "src/types/account";
2
1
  import { MongoDBId } from "src/types/api";
2
+ import { LoginSession } from "src/types/session";
3
3
  export declare const url = "https://sso.ccw.site/web/auth/login-by-password";
4
4
  export type Req = {
5
5
  clientCode: "STUDY_COMMUNITY";
@@ -7,23 +7,7 @@ export type Req = {
7
7
  loginKey: string;
8
8
  password: string;
9
9
  };
10
- export type Res<Extra = string> = {
11
- accountId: -1;
12
- accountObjectId: MongoDBId;
13
- accountType: AccountTypes;
14
- clientCode: "STUDY_COMMUNITY";
15
- createdAt: number;
16
- email: null;
17
- expireTime: number;
18
- extra: Extra;
19
- id: number;
20
- lastAccessTime: number;
21
- orgId: "";
22
- scene: null;
23
- status: "ENABLED";
24
- token: string;
25
- urlEncodedFullName: null;
26
- };
10
+ export type Res<Extra> = LoginSession<Extra>;
27
11
  export type Extra = {
28
12
  browser: string;
29
13
  device: string;
@@ -0,0 +1,38 @@
1
+ import { MongoDBId } from "src/types/api";
2
+ import { LoginSession } from "src/types/session";
3
+ export declare const url = "https://sso.ccw.site/web/auth/v3/login/by_phone";
4
+ export type LoginClientCode = "STUDY_COMMUNITY";
5
+ export type LoginScene = "loginbyPhone";
6
+ export type LoginRuleCode = "ccw_sms";
7
+ export type Req = {
8
+ clientCode: LoginClientCode;
9
+ code: string;
10
+ countryCode: string;
11
+ extra: string;
12
+ phone: string;
13
+ ruleCode: LoginRuleCode;
14
+ scene: LoginScene;
15
+ };
16
+ export type Res<Extra> = LoginSession<Extra>;
17
+ export type Extra = {
18
+ browser: string;
19
+ device: string;
20
+ ip: string;
21
+ loginParentOid: MongoDBId;
22
+ loginType: "BY_PHONE_LOGIN_OR_REGISTER";
23
+ };
24
+ export interface ReqExtra {
25
+ browser: string;
26
+ device: string;
27
+ }
28
+ /**
29
+ * 通过手机号+短信验证码登录(V3)
30
+ * @param {string} phone 手机号,如 "12345671145"
31
+ * @param {string} code 收到的短信验证码
32
+ * @param {ReqExtra} reqExtra 设备和浏览器信息
33
+ * @param {string} countryCode 国家代码,默认 "86"
34
+ * @param {LoginRuleCode} ruleCode 短信规则编码,默认 "ccw_sms"
35
+ * @param {LoginScene} scene 登录场景,默认 "loginbyPhone"
36
+ * @returns {Promise<Res<Extra>>} session 信息
37
+ */
38
+ export declare function loginByPhone(phone: string, code: string, reqExtra?: ReqExtra, countryCode?: string, ruleCode?: LoginRuleCode, scene?: LoginScene): Promise<Res<Extra>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ccw-api/api",
3
- "version": "0.4.2",
3
+ "version": "0.6.0",
4
4
  "description": "ccw api collections",
5
5
  "license": "MIT",
6
6
  "author": "Meng Fuzi",
@@ -29,7 +29,7 @@
29
29
  "build": "tsc --project tsconfig.node.json && tsc --project tsconfig.esm.json && tsc --project tsconfig.types.json"
30
30
  },
31
31
  "dependencies": {
32
- "@ccw-api/axios": "^2.1.0"
32
+ "@ccw-api/axios": "^3.0.0"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@types/jest": "^30.0.0",