@heybox/hb-sdk-protocol 0.8.0-alpha → 0.8.0-alpha.12
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 +3 -6
- package/dist/index.cjs.js +512 -37
- package/dist/index.esm.js +482 -38
- package/package.json +4 -1
- package/src/bridge.ts +21 -3
- package/src/capabilities.ts +294 -28
- package/src/constants.ts +1 -0
- package/src/guards.ts +161 -7
- package/src/index.ts +1 -0
- package/src/payloads.ts +174 -1
- package/src/permission-catalog.ts +168 -0
- package/src/permissions.ts +28 -10
- package/types/bridge.d.ts +19 -3
- package/types/capabilities.d.ts +291 -30
- package/types/constants.d.ts +1 -0
- package/types/guards.d.ts +11 -0
- package/types/index.d.ts +1 -0
- package/types/payloads.d.ts +144 -1
- package/types/permission-catalog.d.ts +108 -0
- package/types/permissions.d.ts +4 -3
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { MiniProgramBridgeMethod, MiniProgramCapabilityRisk } from './capabilities';
|
|
2
|
+
export declare const MINI_PROGRAM_PERMISSION_KEYS: readonly ["userInfo", "steamLibrary", "share", "storage", "filesystem", "clipboard", "leaderboard", "network"];
|
|
3
|
+
export type MiniProgramPermissionKey = (typeof MINI_PROGRAM_PERMISSION_KEYS)[number];
|
|
4
|
+
export type MiniProgramPermissionRequirement = {
|
|
5
|
+
readonly kind: 'none';
|
|
6
|
+
} | {
|
|
7
|
+
readonly kind: 'all';
|
|
8
|
+
readonly permissions: readonly MiniProgramPermissionKey[];
|
|
9
|
+
};
|
|
10
|
+
export type MiniProgramPermissionAccess = 'declaration' | 'platform-approval';
|
|
11
|
+
export interface MiniProgramPermissionConfigFieldDefinition {
|
|
12
|
+
readonly type: 'boolean';
|
|
13
|
+
readonly required: boolean;
|
|
14
|
+
readonly default: boolean;
|
|
15
|
+
readonly description: string;
|
|
16
|
+
}
|
|
17
|
+
export interface MiniProgramPermissionDefinition {
|
|
18
|
+
readonly key: MiniProgramPermissionKey;
|
|
19
|
+
readonly name: string;
|
|
20
|
+
readonly description: string;
|
|
21
|
+
readonly access: MiniProgramPermissionAccess;
|
|
22
|
+
readonly risk: MiniProgramCapabilityRisk;
|
|
23
|
+
readonly config: Readonly<Record<string, MiniProgramPermissionConfigFieldDefinition>>;
|
|
24
|
+
readonly methods: readonly MiniProgramBridgeMethod[];
|
|
25
|
+
readonly conditions: readonly string[];
|
|
26
|
+
}
|
|
27
|
+
export declare const MINI_PROGRAM_PERMISSION_CATALOG: readonly [{
|
|
28
|
+
readonly key: "userInfo";
|
|
29
|
+
readonly name: "用户信息";
|
|
30
|
+
readonly description: "登录小程序并读取当前用户的授权信息。";
|
|
31
|
+
readonly access: "declaration";
|
|
32
|
+
readonly risk: "medium";
|
|
33
|
+
readonly config: {};
|
|
34
|
+
readonly methods: readonly ["auth.login", "user.getInfo"];
|
|
35
|
+
readonly conditions: readonly ["继续执行黑盒登录、用户授权和可信手势规则。"];
|
|
36
|
+
}, {
|
|
37
|
+
readonly key: "steamLibrary";
|
|
38
|
+
readonly name: "Steam 游戏库";
|
|
39
|
+
readonly description: "读取当前用户授权的 Steam 游戏库。";
|
|
40
|
+
readonly access: "declaration";
|
|
41
|
+
readonly risk: "high";
|
|
42
|
+
readonly config: {};
|
|
43
|
+
readonly methods: readonly ["user.getSteamGameList"];
|
|
44
|
+
readonly conditions: readonly ["继续执行账号绑定和数据可用性规则。"];
|
|
45
|
+
}, {
|
|
46
|
+
readonly key: "share";
|
|
47
|
+
readonly name: "分享";
|
|
48
|
+
readonly description: "使用小程序分享、分享菜单和截图能力。";
|
|
49
|
+
readonly access: "declaration";
|
|
50
|
+
readonly risk: "medium";
|
|
51
|
+
readonly config: {};
|
|
52
|
+
readonly methods: readonly ["share.copyLink", "share.showShareMenu", "share.screenshot"];
|
|
53
|
+
readonly conditions: readonly ["继续执行分享参数校验和 Host 支持检查。"];
|
|
54
|
+
}, {
|
|
55
|
+
readonly key: "storage";
|
|
56
|
+
readonly name: "键值存储";
|
|
57
|
+
readonly description: "读写按小程序隔离的简单键值数据。";
|
|
58
|
+
readonly access: "declaration";
|
|
59
|
+
readonly risk: "medium";
|
|
60
|
+
readonly config: {};
|
|
61
|
+
readonly methods: readonly ["storage.getStorage", "storage.setStorage"];
|
|
62
|
+
readonly conditions: readonly ["仅用于简单键值存储,不包含文件系统。"];
|
|
63
|
+
}, {
|
|
64
|
+
readonly key: "filesystem";
|
|
65
|
+
readonly name: "文件系统";
|
|
66
|
+
readonly description: "访问小程序沙盒文件和用户选择的外部文件。";
|
|
67
|
+
readonly access: "declaration";
|
|
68
|
+
readonly risk: "high";
|
|
69
|
+
readonly config: {};
|
|
70
|
+
readonly methods: readonly ["network.download", "files.pickFiles", "files.pickDirectory", "files.saveFile", "file.create", "file.remove", "file.exists", "file.readText", "file.writeText", "file.readBytes", "file.writeBytes", "file.stat", "directory.create", "directory.remove", "directory.exists", "directory.list"];
|
|
71
|
+
readonly conditions: readonly ["外部文件继续要求有效的用户选择、会话句柄和匹配的读写模式。"];
|
|
72
|
+
}, {
|
|
73
|
+
readonly key: "clipboard";
|
|
74
|
+
readonly name: "剪贴板";
|
|
75
|
+
readonly description: "向系统剪贴板写入文本。";
|
|
76
|
+
readonly access: "declaration";
|
|
77
|
+
readonly risk: "medium";
|
|
78
|
+
readonly config: {};
|
|
79
|
+
readonly methods: readonly ["device.setClipboard"];
|
|
80
|
+
readonly conditions: readonly ["继续执行文本长度和 Host 支持限制。"];
|
|
81
|
+
}, {
|
|
82
|
+
readonly key: "leaderboard";
|
|
83
|
+
readonly name: "排行榜";
|
|
84
|
+
readonly description: "读写小程序云排行榜。";
|
|
85
|
+
readonly access: "declaration";
|
|
86
|
+
readonly risk: "medium";
|
|
87
|
+
readonly config: {};
|
|
88
|
+
readonly methods: readonly ["cloud.leaderboard.submit", "cloud.leaderboard.getList", "cloud.leaderboard.getCurrentUserEntry", "cloud.leaderboard.deleteCurrentUserEntry", "cloud.leaderboard.getInfo"];
|
|
89
|
+
readonly conditions: readonly ["排行榜必须已创建,用户和资源规则保持不变。"];
|
|
90
|
+
}, {
|
|
91
|
+
readonly key: "network";
|
|
92
|
+
readonly name: "网络";
|
|
93
|
+
readonly description: "通过 network 模块请求或下载外部资源。";
|
|
94
|
+
readonly access: "platform-approval";
|
|
95
|
+
readonly risk: "high";
|
|
96
|
+
readonly config: {
|
|
97
|
+
readonly useOfficialDomain: {
|
|
98
|
+
readonly type: "boolean";
|
|
99
|
+
readonly required: false;
|
|
100
|
+
readonly default: false;
|
|
101
|
+
readonly description: "是否申请访问小黑盒官方域名。";
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
readonly methods: readonly ["network.request", "network.download"];
|
|
105
|
+
readonly conditions: readonly ["声明后仍需平台批准,并继续执行网络安全策略。"];
|
|
106
|
+
}];
|
|
107
|
+
export declare const MINI_PROGRAM_NO_DECLARATION_METHODS: readonly ["user.revokeAuthorization", "ui.showToast", "ui.showLoading", "ui.hideLoading", "viewport.getWindowInfo", "viewport.setNavigationBarStyle", "device.vibrate", "navigation.close", "navigation.reload", "navigation.openAppPage"];
|
|
108
|
+
export declare function isMiniProgramPermissionKey(key: string): key is MiniProgramPermissionKey;
|
package/types/permissions.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import { type MiniProgramPermissionKey } from './permission-catalog';
|
|
2
|
+
export declare function isManagedMiniProgramRuntimePermissionKey(key: string): key is MiniProgramPermissionKey;
|
|
2
3
|
export type MiniProgramRuntimePermissionStatus = 'enabled' | 'disabled';
|
|
3
4
|
export interface MiniProgramRuntimePermissionEntry {
|
|
4
|
-
key:
|
|
5
|
+
key: MiniProgramPermissionKey;
|
|
5
6
|
status: MiniProgramRuntimePermissionStatus;
|
|
6
7
|
config: Record<string, unknown>;
|
|
7
8
|
}
|
|
@@ -12,6 +13,6 @@ export interface MiniProgramRuntimePermissionsSnapshot {
|
|
|
12
13
|
}
|
|
13
14
|
export interface ParsedMiniProgramRuntimePermissions {
|
|
14
15
|
valid: boolean;
|
|
15
|
-
permissions: Record<
|
|
16
|
+
permissions: Partial<Record<MiniProgramPermissionKey, MiniProgramRuntimePermissionEntry>>;
|
|
16
17
|
}
|
|
17
18
|
export declare function parseMiniProgramRuntimePermissions(snapshot: unknown): ParsedMiniProgramRuntimePermissions;
|