@ccw-api/api 0.0.2 → 0.3.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/AGENT.md +271 -0
- package/coverage/clover.xml +605 -0
- package/coverage/coverage-final.json +49 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +671 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +210 -0
- package/coverage/lcov.info +977 -0
- package/dist/esm/community-web/api/v1/short_code/encode.js +25 -0
- package/dist/esm/community-web/api/v1/short_code/shortcode.test.js +5 -0
- package/dist/esm/community-web/approval/approval.test.js +5 -0
- package/dist/esm/community-web/approval/list.js +16 -0
- package/dist/esm/community-web/base/dateTime.js +10 -0
- package/dist/esm/community-web/base/dateTime.test.js +6 -0
- package/dist/esm/community-web/campaign_resource/detail.js +12 -0
- package/dist/esm/community-web/campaign_resource/detail.test.js +10 -0
- package/dist/esm/community-web/check_in_record/check_in_record.test.js +8 -0
- package/dist/esm/community-web/check_in_record/detail.js +8 -0
- package/dist/esm/community-web/check_in_record/insert.js +12 -0
- package/dist/esm/community-web/cloud_asset/search.js +25 -0
- package/dist/esm/community-web/cloud_asset/search.test.js +6 -0
- package/dist/esm/community-web/cloud_asset/user/privacy.js +11 -0
- package/dist/esm/community-web/cloud_asset/user/privacy.test.js +4 -0
- package/dist/esm/community-web/comment/page.js +26 -0
- package/dist/esm/community-web/comment/page.test.js +15 -0
- package/dist/esm/community-web/comment/page_by_topic.js +26 -0
- package/dist/esm/community-web/comment/page_by_topic.test.js +13 -0
- package/dist/esm/community-web/config/detail.js +13 -0
- package/dist/esm/community-web/creation/creation.test.js +118 -0
- package/dist/esm/community-web/creation/detail.js +14 -0
- package/dist/esm/community-web/creation/excellent/list.js +13 -0
- package/dist/esm/community-web/creation/introduction/detail.js +13 -0
- package/dist/esm/community-web/creation/like/detail.js +13 -0
- package/dist/esm/community-web/creation/loading/tips.js +11 -0
- package/dist/esm/community-web/creation/page.js +24 -0
- package/dist/esm/community-web/creation/page_by_student.js +24 -0
- package/dist/esm/community-web/creation/potential/list.js +13 -0
- package/dist/esm/community-web/creation/recommend.js +23 -0
- package/dist/esm/community-web/creation/search/page.js +24 -0
- package/dist/esm/community-web/creation/student/detail.js +13 -0
- package/dist/esm/community-web/creation/tag/list.js +12 -0
- package/dist/esm/community-web/index.js +50 -0
- package/dist/esm/community-web/short_url/create.js +15 -0
- package/dist/esm/community-web/short_url/shortUrl.test.js +4 -0
- package/dist/esm/index.js +5 -2
- package/dist/esm/queryPages.js +22 -0
- package/dist/esm/sso/index.js +5 -3
- package/dist/esm/sso/web/auth/auth.test.js +13 -61
- package/dist/esm/sso/web/auth/login-by-password.js +25 -82
- package/dist/esm/sso/web/auth/logout.js +9 -48
- package/dist/esm/sso/web/auth/logout_by_session.js +12 -0
- package/dist/node/community-web/api/v1/short_code/encode.js +29 -0
- package/dist/node/community-web/api/v1/short_code/shortcode.test.js +7 -0
- package/dist/node/community-web/approval/approval.test.js +7 -0
- package/dist/node/community-web/approval/list.js +23 -0
- package/dist/node/community-web/base/dateTime.js +17 -0
- package/dist/node/community-web/base/dateTime.test.js +8 -0
- package/dist/node/community-web/campaign_resource/detail.js +16 -0
- package/dist/node/community-web/campaign_resource/detail.test.js +12 -0
- package/dist/node/community-web/check_in_record/check_in_record.test.js +10 -0
- package/dist/node/community-web/check_in_record/detail.js +12 -0
- package/dist/node/community-web/check_in_record/insert.js +16 -0
- package/dist/node/community-web/cloud_asset/search.js +29 -0
- package/dist/node/community-web/cloud_asset/search.test.js +8 -0
- package/dist/node/community-web/cloud_asset/user/privacy.js +15 -0
- package/dist/node/community-web/cloud_asset/user/privacy.test.js +6 -0
- package/dist/node/community-web/comment/page.js +30 -0
- package/dist/node/community-web/comment/page.test.js +17 -0
- package/dist/node/community-web/comment/page_by_topic.js +30 -0
- package/dist/node/community-web/comment/page_by_topic.test.js +15 -0
- package/dist/node/community-web/config/detail.js +17 -0
- package/dist/node/community-web/creation/creation.test.js +120 -0
- package/dist/node/community-web/creation/detail.js +18 -0
- package/dist/node/community-web/creation/excellent/list.js +17 -0
- package/dist/node/community-web/creation/introduction/detail.js +17 -0
- package/dist/node/community-web/creation/like/detail.js +17 -0
- package/dist/node/community-web/creation/loading/tips.js +15 -0
- package/dist/node/community-web/creation/page.js +28 -0
- package/dist/node/community-web/creation/page_by_student.js +28 -0
- package/dist/node/community-web/creation/potential/list.js +17 -0
- package/dist/node/community-web/creation/recommend.js +27 -0
- package/dist/node/community-web/creation/search/page.js +28 -0
- package/dist/node/community-web/creation/student/detail.js +17 -0
- package/dist/node/community-web/creation/tag/list.js +16 -0
- package/dist/node/community-web/index.js +53 -0
- package/dist/node/community-web/short_url/create.js +19 -0
- package/dist/node/community-web/short_url/shortUrl.test.js +6 -0
- package/dist/node/index.js +6 -2
- package/dist/node/queryPages.js +26 -0
- package/dist/node/sso/index.js +4 -2
- package/dist/node/sso/web/auth/auth.test.js +15 -63
- package/dist/node/sso/web/auth/login-by-password.js +25 -82
- package/dist/node/sso/web/auth/logout.js +9 -48
- package/dist/node/sso/web/auth/logout_by_session.js +16 -0
- package/package.json +7 -2
- package/tsconfig.esm.json +2 -1
- package/tsconfig.json +5 -3
- package/tsconfig.node.json +2 -1
- package/tsconfig.types.json +1 -1
- package/dist/esm/index.d.ts +0 -10
- package/dist/esm/sso/index.d.ts +0 -6
- package/dist/esm/sso/web/auth/auth.test.d.ts +0 -1
- package/dist/esm/sso/web/auth/login-by-password.d.ts +0 -38
- package/dist/esm/sso/web/auth/logout.d.ts +0 -3
- package/dist/esm/types.d.ts +0 -17
- package/dist/esm/types.js +0 -1
- package/dist/index.d.ts +0 -10
- package/dist/node/index.d.ts +0 -10
- package/dist/node/sso/index.d.ts +0 -6
- package/dist/node/sso/web/auth/auth.test.d.ts +0 -1
- package/dist/node/sso/web/auth/login-by-password.d.ts +0 -38
- package/dist/node/sso/web/auth/logout.d.ts +0 -3
- package/dist/node/types.d.ts +0 -17
- package/dist/node/types.js +0 -2
- package/dist/sso/index.d.ts +0 -6
- package/dist/sso/web/auth/login-by-password.d.ts +0 -38
- package/dist/sso/web/auth/logout.d.ts +0 -3
- package/dist/types.d.ts +0 -17
- package/jest.config.ts +0 -13
- package/src/index.ts +0 -8
- package/src/sso/index.ts +0 -7
- package/src/sso/web/auth/auth.test.ts +0 -16
- package/src/sso/web/auth/login-by-password.ts +0 -58
- package/src/sso/web/auth/logout.ts +0 -9
- package/src/types.ts +0 -18
package/src/sso/index.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { loginByPassword } from "./login-by-password";
|
|
2
|
-
import { logout } from "./logout";
|
|
3
|
-
test("expect password to be error", async () => {
|
|
4
|
-
await expect(() =>
|
|
5
|
-
loginByPassword("abc", "foo", {
|
|
6
|
-
device: "test",
|
|
7
|
-
browser: "test",
|
|
8
|
-
}),
|
|
9
|
-
).rejects.toThrow("ccw axios Request failed: 账号或密码错误(4001092401)");
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
test("expect logout to be error when no token", async () => {
|
|
13
|
-
await expect(logout).rejects.toThrow(
|
|
14
|
-
"ccw axios Request failed: token不能为空(4001092X01)",
|
|
15
|
-
);
|
|
16
|
-
});
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { ccwAxios } from "@ccw-api/axios";
|
|
2
|
-
import { ApiResponse, MongoDBId } from "../../../types";
|
|
3
|
-
export const url = "https://sso.ccw.site/web/auth/login-by-password";
|
|
4
|
-
|
|
5
|
-
export type Req = {
|
|
6
|
-
loginKey: string;
|
|
7
|
-
clientCode: "STUDY_COMMUNITY";
|
|
8
|
-
password: string;
|
|
9
|
-
extra: string;
|
|
10
|
-
};
|
|
11
|
-
export type Res<Extra = string> = ApiResponse<{
|
|
12
|
-
accountId: -1;
|
|
13
|
-
accountObjectId: MongoDBId;
|
|
14
|
-
accountType: "STUDENT";
|
|
15
|
-
clientCode: "STUDY_COMMUNITY";
|
|
16
|
-
createdAt: number;
|
|
17
|
-
email: null;
|
|
18
|
-
expireTime: number;
|
|
19
|
-
extra: Extra;
|
|
20
|
-
id: number;
|
|
21
|
-
lastAccessTime: number;
|
|
22
|
-
orgId: "";
|
|
23
|
-
scene: null;
|
|
24
|
-
status: "ENABLED";
|
|
25
|
-
token: string;
|
|
26
|
-
urlEncodedFullName: null;
|
|
27
|
-
}>;
|
|
28
|
-
|
|
29
|
-
type Extra = {
|
|
30
|
-
loginType: "BY_PASSWORD";
|
|
31
|
-
browser: string;
|
|
32
|
-
ip: string;
|
|
33
|
-
loginParentOid: MongoDBId;
|
|
34
|
-
device: string;
|
|
35
|
-
orgId: "";
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export async function loginByPassword(
|
|
39
|
-
loginKey: string,
|
|
40
|
-
password: string,
|
|
41
|
-
reqExtra: { device: string; browser: string } = {
|
|
42
|
-
device: "Node",
|
|
43
|
-
browser: "Node.js",
|
|
44
|
-
},
|
|
45
|
-
): Promise<Res<Extra>["body"]> {
|
|
46
|
-
const { extra: _extra, ...rest } = await ccwAxios
|
|
47
|
-
.post<Res>(url, {
|
|
48
|
-
loginKey,
|
|
49
|
-
password,
|
|
50
|
-
clientCode: "STUDY_COMMUNITY",
|
|
51
|
-
extra: JSON.stringify({ ...reqExtra, scene: null }),
|
|
52
|
-
} satisfies Req)
|
|
53
|
-
.then((res) => res.data.body);
|
|
54
|
-
return {
|
|
55
|
-
...rest,
|
|
56
|
-
extra: JSON.parse(_extra),
|
|
57
|
-
};
|
|
58
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ccwAxios } from "@ccw-api/axios";
|
|
2
|
-
import { ApiResponse } from "../../../types";
|
|
3
|
-
export const url = "https://sso.ccw.site/web/auth/logout";
|
|
4
|
-
|
|
5
|
-
export async function logout() {
|
|
6
|
-
return await ccwAxios
|
|
7
|
-
.post<ApiResponse<null>>(url, {})
|
|
8
|
-
.then((res) => res.data);
|
|
9
|
-
}
|
package/src/types.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 十六进制秒级时间戳
|
|
3
|
-
* @example const date = new Date(Number.parseInt(t, 16) * 1000);
|
|
4
|
-
*/
|
|
5
|
-
export type HexSecTimeStamp = string;
|
|
6
|
-
/**
|
|
7
|
-
* @example
|
|
8
|
-
* const t = id.subString(0,8);
|
|
9
|
-
* const date = new Date(Number.parseInt(t, 16) * 1000);
|
|
10
|
-
*/
|
|
11
|
-
export type MongoDBId = `${HexSecTimeStamp}${string}`;
|
|
12
|
-
|
|
13
|
-
export type ApiResponse<T> = {
|
|
14
|
-
body: T;
|
|
15
|
-
code: string;
|
|
16
|
-
msg: string;
|
|
17
|
-
status: number;
|
|
18
|
-
};
|