@ichinese/open-sdk 1.0.0-rc.4 → 1.0.0-rc.5
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/README.md +13 -1
- package/dist/gen/meta.d.ts +4 -2
- package/dist/gen/schema.d.ts +18 -2
- package/dist/index.cjs +9 -1
- package/dist/index.js +7 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# iChinese Open Platform SDK for Node.js
|
|
2
2
|
|
|
3
|
-
> **Prerelease 1.0.0-rc.
|
|
3
|
+
> **Prerelease 1.0.0-rc.5.** 这是预发布版,开放平台还没有正式开放,SDK 的默认地址可能连不上。This is a prerelease: the open platform is not open to the public yet, so the SDK's default address may not answer.
|
|
4
4
|
|
|
5
5
|
爱中文开放平台的 Node.js 服务端 SDK:开放接口(`/open-apis/v1`)的每个接口都是一个方法,并处理令牌、重试、分页和事件推送。
|
|
6
6
|
|
|
@@ -113,6 +113,18 @@ Guides and the API reference: <https://open.ichinese.cn>
|
|
|
113
113
|
This repository is generated from the platform's monorepo at each release, so a change made here would be
|
|
114
114
|
overwritten; please open an issue instead.
|
|
115
115
|
|
|
116
|
+
## Phone number and email scopes
|
|
117
|
+
|
|
118
|
+
Declare `phone` and/or `email` in the developer console and release the app configuration.
|
|
119
|
+
Each user decides on each scope separately. The backend's `getUserInfo` (Python: `get_user_info`,
|
|
120
|
+
Go: `GetUserInfo`) returns `phone_number` (E.164) and/or `email` only for scopes both declared
|
|
121
|
+
and granted, and only for currently verified, bound identifiers. Otherwise the field is absent,
|
|
122
|
+
including after revocation. Neither scope requires `profile`.
|
|
123
|
+
|
|
124
|
+
For the web JS SDK's browser fallback, include the declared scopes in `config({ appId, scopes: ['phone', 'email'] })`.
|
|
125
|
+
In a container the consent sheet uses the app's declared scopes. Exchange the code and call the user-info
|
|
126
|
+
API on your backend; keep the user token there.
|
|
127
|
+
|
|
116
128
|
## License
|
|
117
129
|
|
|
118
130
|
MIT
|
package/dist/gen/meta.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/** The SDK's version (it follows the open API's). */
|
|
2
|
-
export declare const VERSION = "1.0.0-rc.
|
|
2
|
+
export declare const VERSION = "1.0.0-rc.5";
|
|
3
3
|
/** The open API's address from the release configuration (sdks/release.json); `baseUrl` overrides it. */
|
|
4
4
|
export declare const DEFAULT_BASE_URL = "https://open.ichinese.cn";
|
|
5
5
|
export declare const API_PREFIX = "/open-apis/v1";
|
|
6
6
|
/** Every scope (permission code) of the open API. */
|
|
7
|
-
export declare const SCOPES: readonly ["openid", "profile", "org:member:readonly", "org:member", "class:readonly", "class:member", "schedule:readonly", "schedule", "attendance:readonly", "coursework", "grade:readonly", "course", "learning:progress:readonly", "im:message:send_as_bot", "im:chat:readonly", "notify:send", "live:recording:readonly", "event", "event:registration:readonly", "job", "job:candidate:readonly", "trial", "trade:order:readonly", "trade:booking:readonly", "venue:readonly", "venue", "opening:readonly", "review", "profile:interest:readonly", "profile:interest", "profile:learning:readonly", "report:create", "community:post", "me:schedule:readonly", "me:learning:readonly", "me:words:readonly", "me:words", "insights:readonly"];
|
|
7
|
+
export declare const SCOPES: readonly ["openid", "profile", "phone", "email", "org:member:readonly", "org:member", "class:readonly", "class:member", "schedule:readonly", "schedule", "attendance:readonly", "coursework", "grade:readonly", "course", "learning:progress:readonly", "im:message:send_as_bot", "im:chat:readonly", "notify:send", "live:recording:readonly", "event", "event:registration:readonly", "job", "job:candidate:readonly", "trial", "trade:order:readonly", "trade:booking:readonly", "venue:readonly", "venue", "opening:readonly", "review", "profile:interest:readonly", "profile:interest", "profile:learning:readonly", "report:create", "community:post", "me:schedule:readonly", "me:learning:readonly", "me:words:readonly", "me:words", "insights:readonly"];
|
|
8
8
|
export type Scope = (typeof SCOPES)[number];
|
|
9
9
|
/** The events an app can subscribe to. */
|
|
10
10
|
export declare const EVENT_TYPES: readonly ["app.installed", "app.uninstalled", "app.scopes_changed", "coursework.submitted", "grade.published", "schedule.session_changed", "event.registered", "job.candidate_applied", "trade.order_paid", "review.created", "trial.booked", "im.message_received", "class.member_changed", "course.completed", "exam.results_released", "event.checked_in", "live.recording_ready", "trade.order_refunded", "trial.confirmed", "trial.cancelled", "community.post_reviewed", "community.video_ready", "booking.changed"];
|
|
@@ -16,6 +16,8 @@ export type ErrorReason = (typeof ERROR_REASONS)[number];
|
|
|
16
16
|
export declare const OPERATION_TOKENS: Record<string, readonly ('app' | 'tenant' | 'user')[]>;
|
|
17
17
|
export declare const SCOPE_OPENID = "openid";
|
|
18
18
|
export declare const SCOPE_PROFILE = "profile";
|
|
19
|
+
export declare const SCOPE_PHONE = "phone";
|
|
20
|
+
export declare const SCOPE_EMAIL = "email";
|
|
19
21
|
export declare const SCOPE_ORG_MEMBER_READONLY = "org:member:readonly";
|
|
20
22
|
export declare const SCOPE_ORG_MEMBER = "org:member";
|
|
21
23
|
export declare const SCOPE_CLASS_READONLY = "class:readonly";
|
package/dist/gen/schema.d.ts
CHANGED
|
@@ -114,7 +114,7 @@ export interface paths {
|
|
|
114
114
|
};
|
|
115
115
|
/**
|
|
116
116
|
* 当前用户(用户令牌)
|
|
117
|
-
* @description 总有 `open_id`;`name`、`avatar_url`、`locale` 要用户批了 `profile`。
|
|
117
|
+
* @description 总有 `open_id`;`name`、`avatar_url`、`locale` 要用户批了 `profile`。应用声明且用户同意 `phone` / `email` 后,分别返回当前已验证绑定的 `phone_number` / `email`;未声明、未同意、已撤回或未绑定时省略对应字段。两项权限互不依赖,也不依赖 `profile`。
|
|
118
118
|
*/
|
|
119
119
|
get: operations["getUserInfo"];
|
|
120
120
|
put?: never;
|
|
@@ -1416,7 +1416,7 @@ export interface components {
|
|
|
1416
1416
|
/** @description 权限码(目录见 `ScopeCode`;平台的 `GET /api/v1/open/scopes` 返回带说明的目录) */
|
|
1417
1417
|
Scope: string;
|
|
1418
1418
|
/** @enum {string} */
|
|
1419
|
-
ScopeCode: "openid" | "profile" | "org:member:readonly" | "org:member" | "class:readonly" | "class:member" | "schedule:readonly" | "schedule" | "attendance:readonly" | "coursework" | "grade:readonly" | "course" | "learning:progress:readonly" | "im:message:send_as_bot" | "im:chat:readonly" | "notify:send" | "live:recording:readonly" | "event" | "event:registration:readonly" | "job" | "job:candidate:readonly" | "trial" | "trade:order:readonly" | "trade:booking:readonly" | "venue:readonly" | "venue" | "opening:readonly" | "review" | "profile:interest:readonly" | "profile:interest" | "profile:learning:readonly" | "report:create" | "community:post" | "me:schedule:readonly" | "me:learning:readonly" | "me:words:readonly" | "me:words" | "insights:readonly";
|
|
1419
|
+
ScopeCode: "openid" | "profile" | "phone" | "email" | "org:member:readonly" | "org:member" | "class:readonly" | "class:member" | "schedule:readonly" | "schedule" | "attendance:readonly" | "coursework" | "grade:readonly" | "course" | "learning:progress:readonly" | "im:message:send_as_bot" | "im:chat:readonly" | "notify:send" | "live:recording:readonly" | "event" | "event:registration:readonly" | "job" | "job:candidate:readonly" | "trial" | "trade:order:readonly" | "trade:booking:readonly" | "venue:readonly" | "venue" | "opening:readonly" | "review" | "profile:interest:readonly" | "profile:interest" | "profile:learning:readonly" | "report:create" | "community:post" | "me:schedule:readonly" | "me:learning:readonly" | "me:words:readonly" | "me:words" | "insights:readonly";
|
|
1420
1420
|
/** @enum {string} */
|
|
1421
1421
|
OrgRole: "owner" | "admin" | "academic" | "editor" | "content_reviewer" | "teacher" | "community" | "recruiter" | "member";
|
|
1422
1422
|
AppCredentials: {
|
|
@@ -1455,6 +1455,13 @@ export interface components {
|
|
|
1455
1455
|
name?: string;
|
|
1456
1456
|
avatar_url?: string | null;
|
|
1457
1457
|
locale?: string;
|
|
1458
|
+
/** @description 应用声明且用户同意 phone 时返回当前已验证绑定的手机号(E.164);否则省略 */
|
|
1459
|
+
phone_number?: string;
|
|
1460
|
+
/**
|
|
1461
|
+
* Format: email
|
|
1462
|
+
* @description 应用声明且用户同意 email 时返回当前已验证绑定的邮箱;否则省略
|
|
1463
|
+
*/
|
|
1464
|
+
email?: string;
|
|
1458
1465
|
};
|
|
1459
1466
|
Tenant: {
|
|
1460
1467
|
tenant_key: components["schemas"]["TenantKey"];
|
|
@@ -2672,6 +2679,15 @@ export interface operations {
|
|
|
2672
2679
|
};
|
|
2673
2680
|
401: components["responses"]["Unauthenticated"];
|
|
2674
2681
|
429: components["responses"]["RateLimited"];
|
|
2682
|
+
/** @description SERVICE_UNAVAILABLE,归属区身份服务暂时不可用 */
|
|
2683
|
+
503: {
|
|
2684
|
+
headers: {
|
|
2685
|
+
[name: string]: unknown;
|
|
2686
|
+
};
|
|
2687
|
+
content: {
|
|
2688
|
+
"application/json": components["schemas"]["ErrorResponse"];
|
|
2689
|
+
};
|
|
2690
|
+
};
|
|
2675
2691
|
};
|
|
2676
2692
|
};
|
|
2677
2693
|
getTenant: {
|
package/dist/index.cjs
CHANGED
|
@@ -34,6 +34,7 @@ __export(index_exports, {
|
|
|
34
34
|
SCOPE_COMMUNITY_POST: () => SCOPE_COMMUNITY_POST,
|
|
35
35
|
SCOPE_COURSE: () => SCOPE_COURSE,
|
|
36
36
|
SCOPE_COURSEWORK: () => SCOPE_COURSEWORK,
|
|
37
|
+
SCOPE_EMAIL: () => SCOPE_EMAIL,
|
|
37
38
|
SCOPE_EVENT: () => SCOPE_EVENT,
|
|
38
39
|
SCOPE_EVENT_REGISTRATION_READONLY: () => SCOPE_EVENT_REGISTRATION_READONLY,
|
|
39
40
|
SCOPE_GRADE_READONLY: () => SCOPE_GRADE_READONLY,
|
|
@@ -53,6 +54,7 @@ __export(index_exports, {
|
|
|
53
54
|
SCOPE_OPENING_READONLY: () => SCOPE_OPENING_READONLY,
|
|
54
55
|
SCOPE_ORG_MEMBER: () => SCOPE_ORG_MEMBER,
|
|
55
56
|
SCOPE_ORG_MEMBER_READONLY: () => SCOPE_ORG_MEMBER_READONLY,
|
|
57
|
+
SCOPE_PHONE: () => SCOPE_PHONE,
|
|
56
58
|
SCOPE_PROFILE: () => SCOPE_PROFILE,
|
|
57
59
|
SCOPE_PROFILE_INTEREST: () => SCOPE_PROFILE_INTEREST,
|
|
58
60
|
SCOPE_PROFILE_INTEREST_READONLY: () => SCOPE_PROFILE_INTEREST_READONLY,
|
|
@@ -123,12 +125,14 @@ var OpenApiError = class extends Error {
|
|
|
123
125
|
var isOpenApiError = (e) => e instanceof OpenApiError;
|
|
124
126
|
|
|
125
127
|
// src/gen/meta.ts
|
|
126
|
-
var VERSION = "1.0.0-rc.
|
|
128
|
+
var VERSION = "1.0.0-rc.5";
|
|
127
129
|
var DEFAULT_BASE_URL = "https://open.ichinese.cn";
|
|
128
130
|
var API_PREFIX = "/open-apis/v1";
|
|
129
131
|
var SCOPES = [
|
|
130
132
|
"openid",
|
|
131
133
|
"profile",
|
|
134
|
+
"phone",
|
|
135
|
+
"email",
|
|
132
136
|
"org:member:readonly",
|
|
133
137
|
"org:member",
|
|
134
138
|
"class:readonly",
|
|
@@ -312,6 +316,8 @@ var OPERATION_TOKENS = {
|
|
|
312
316
|
};
|
|
313
317
|
var SCOPE_OPENID = "openid";
|
|
314
318
|
var SCOPE_PROFILE = "profile";
|
|
319
|
+
var SCOPE_PHONE = "phone";
|
|
320
|
+
var SCOPE_EMAIL = "email";
|
|
315
321
|
var SCOPE_ORG_MEMBER_READONLY = "org:member:readonly";
|
|
316
322
|
var SCOPE_ORG_MEMBER = "org:member";
|
|
317
323
|
var SCOPE_CLASS_READONLY = "class:readonly";
|
|
@@ -1243,6 +1249,7 @@ var challengeResponse = (v) => ({ challenge: v.challenge });
|
|
|
1243
1249
|
SCOPE_COMMUNITY_POST,
|
|
1244
1250
|
SCOPE_COURSE,
|
|
1245
1251
|
SCOPE_COURSEWORK,
|
|
1252
|
+
SCOPE_EMAIL,
|
|
1246
1253
|
SCOPE_EVENT,
|
|
1247
1254
|
SCOPE_EVENT_REGISTRATION_READONLY,
|
|
1248
1255
|
SCOPE_GRADE_READONLY,
|
|
@@ -1262,6 +1269,7 @@ var challengeResponse = (v) => ({ challenge: v.challenge });
|
|
|
1262
1269
|
SCOPE_OPENING_READONLY,
|
|
1263
1270
|
SCOPE_ORG_MEMBER,
|
|
1264
1271
|
SCOPE_ORG_MEMBER_READONLY,
|
|
1272
|
+
SCOPE_PHONE,
|
|
1265
1273
|
SCOPE_PROFILE,
|
|
1266
1274
|
SCOPE_PROFILE_INTEREST,
|
|
1267
1275
|
SCOPE_PROFILE_INTEREST_READONLY,
|
package/dist/index.js
CHANGED
|
@@ -43,12 +43,14 @@ var OpenApiError = class extends Error {
|
|
|
43
43
|
var isOpenApiError = (e) => e instanceof OpenApiError;
|
|
44
44
|
|
|
45
45
|
// src/gen/meta.ts
|
|
46
|
-
var VERSION = "1.0.0-rc.
|
|
46
|
+
var VERSION = "1.0.0-rc.5";
|
|
47
47
|
var DEFAULT_BASE_URL = "https://open.ichinese.cn";
|
|
48
48
|
var API_PREFIX = "/open-apis/v1";
|
|
49
49
|
var SCOPES = [
|
|
50
50
|
"openid",
|
|
51
51
|
"profile",
|
|
52
|
+
"phone",
|
|
53
|
+
"email",
|
|
52
54
|
"org:member:readonly",
|
|
53
55
|
"org:member",
|
|
54
56
|
"class:readonly",
|
|
@@ -232,6 +234,8 @@ var OPERATION_TOKENS = {
|
|
|
232
234
|
};
|
|
233
235
|
var SCOPE_OPENID = "openid";
|
|
234
236
|
var SCOPE_PROFILE = "profile";
|
|
237
|
+
var SCOPE_PHONE = "phone";
|
|
238
|
+
var SCOPE_EMAIL = "email";
|
|
235
239
|
var SCOPE_ORG_MEMBER_READONLY = "org:member:readonly";
|
|
236
240
|
var SCOPE_ORG_MEMBER = "org:member";
|
|
237
241
|
var SCOPE_CLASS_READONLY = "class:readonly";
|
|
@@ -1162,6 +1166,7 @@ export {
|
|
|
1162
1166
|
SCOPE_COMMUNITY_POST,
|
|
1163
1167
|
SCOPE_COURSE,
|
|
1164
1168
|
SCOPE_COURSEWORK,
|
|
1169
|
+
SCOPE_EMAIL,
|
|
1165
1170
|
SCOPE_EVENT,
|
|
1166
1171
|
SCOPE_EVENT_REGISTRATION_READONLY,
|
|
1167
1172
|
SCOPE_GRADE_READONLY,
|
|
@@ -1181,6 +1186,7 @@ export {
|
|
|
1181
1186
|
SCOPE_OPENING_READONLY,
|
|
1182
1187
|
SCOPE_ORG_MEMBER,
|
|
1183
1188
|
SCOPE_ORG_MEMBER_READONLY,
|
|
1189
|
+
SCOPE_PHONE,
|
|
1184
1190
|
SCOPE_PROFILE,
|
|
1185
1191
|
SCOPE_PROFILE_INTEREST,
|
|
1186
1192
|
SCOPE_PROFILE_INTEREST_READONLY,
|
package/package.json
CHANGED