@heybox/hb-sdk 0.9.6-alpha.7 → 0.9.6-alpha.9

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 (32) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +1 -1
  3. package/dist/cli-chunks/{artifact-Cd8ycOAg.cjs → artifact-BPntCpxe.cjs} +3 -3
  4. package/dist/cli-chunks/{build-BrgWPvOc.cjs → build-C-u_43nO.cjs} +5 -5
  5. package/dist/cli-chunks/{create-DazrJqTq.cjs → create-HUynjFAz.cjs} +1 -1
  6. package/dist/cli-chunks/{dev-Bh_tcjTh.cjs → dev-Dpg4MIoV.cjs} +45 -15
  7. package/dist/cli-chunks/{dev-context-S51_iwMg.cjs → dev-context-BBInsRLS.cjs} +4 -6
  8. package/dist/cli-chunks/{doctor-CcXOLXts.cjs → doctor-qjPdtMIj.cjs} +1 -1
  9. package/dist/cli-chunks/{games-32NDNB8b.cjs → games-B7ckiLkr.cjs} +1 -1
  10. package/dist/cli-chunks/{index-DMnPneAL.cjs → index-D0fPJhtR.cjs} +17 -17
  11. package/dist/cli-chunks/{index-DYsLBhFf.cjs → index-SB2iukXP.cjs} +1 -1
  12. package/dist/cli-chunks/{index.esm-DKeO7cxb.cjs → index.esm-jOc0zgE7.cjs} +6 -6
  13. package/dist/cli-chunks/{login-B6MxifMG.cjs → login-DDKJA4pj.cjs} +1 -1
  14. package/dist/cli-chunks/{project-vite-BCnIF2rk.cjs → project-vite-B_yd6m3R.cjs} +1 -1
  15. package/dist/cli-chunks/{remote-Bb8GZSc-.cjs → remote-CSmfJpqd.cjs} +10 -7
  16. package/dist/cli-chunks/{runtime-permission-env-o7tIqjej.cjs → runtime-permission-env-Bbc5KS3u.cjs} +61 -12
  17. package/dist/cli-chunks/{skill-Day4Rrl6.cjs → skill-BTKQpM8e.cjs} +2 -2
  18. package/dist/cli-chunks/{version-AWKcsAry.cjs → version-Blqp4J3r.cjs} +1 -1
  19. package/dist/cli.cjs +1 -1
  20. package/dist/devtools/browser-dev-host/assets/browser-dev-host-sU7AkNvZ.js +100 -0
  21. package/dist/devtools/browser-dev-host/assets/{desktop-app-launch-B8q4rMrU.js → desktop-app-launch-CRHmhFwH.js} +1 -1
  22. package/dist/devtools/browser-dev-host/assets/{index-__3F9lBl.js → index-yw_35zwq.js} +3 -3
  23. package/dist/devtools/browser-dev-host/index.html +2 -2
  24. package/dist/index.cjs.js +1 -1
  25. package/dist/index.esm.js +1 -1
  26. package/dist/miniapp-publish.cjs.js +1 -1
  27. package/dist/miniapp-publish.esm.js +1 -1
  28. package/dist/vite.cjs.js +107 -19
  29. package/dist/vite.esm.js +107 -19
  30. package/package.json +4 -4
  31. package/skill/skill.json +4 -4
  32. package/dist/devtools/browser-dev-host/assets/browser-dev-host-sGVpeJfu.js +0 -100
@@ -2,9 +2,9 @@
2
2
 
3
3
  var fs = require('node:fs');
4
4
  var path = require('node:path');
5
- var version$1 = require('./version-AWKcsAry.cjs');
5
+ var version$1 = require('./version-Blqp4J3r.cjs');
6
6
  require('node:crypto');
7
- var index = require('./index-DMnPneAL.cjs');
7
+ var index = require('./index-D0fPJhtR.cjs');
8
8
  var node_async_hooks = require('node:async_hooks');
9
9
 
10
10
  /**
@@ -39,7 +39,7 @@ const MINI_PROGRAM_PERMISSION_CATALOG = [
39
39
  risk: 'high',
40
40
  config: {},
41
41
  methods: ['gameSaves.list', 'gameSaves.sync', 'gameSaves.getFile', 'gameSaves.readParsedData'],
42
- conditions: ['需要用户明确授权、有效 Steam 登录和支持文件读取的宿主;可按需读取受支持游戏的已有解析概览,不触发解析。'],
42
+ conditions: ['需声明权限并校验当前 Steam 账号,无需额外授权弹窗;可读取受支持游戏已有的完整结构化数据,不触发解析。同步需有效 Steam 登录,文件下载另需宿主支持文件读取。'],
43
43
  },
44
44
  {
45
45
  key: 'userInfo',
@@ -16623,24 +16623,63 @@ const LIST_USER_MINIPROGRAM_PERMISSION_APPLICATION_API_PATH = '/mall/developer/u
16623
16623
  /** 提交不绑定版本的平台权限申请。 */
16624
16624
  const SUBMIT_USER_MINIPROGRAM_PERMISSION_APPLICATION_API_PATH = '/mall/developer/user_miniprogram/runtime_permission/application_submit';
16625
16625
 
16626
+ /** 约束构建产物中的 HTTPS source,禁止通配、IP、端口及 CSP 注入。 */
16627
+ function normalizeMiniappBuildImageDomain(value) {
16628
+ if (typeof value !== 'string' || value !== value.trim() || value.length > 253)
16629
+ return undefined;
16630
+ const domain = value.toLowerCase();
16631
+ if (!domain.includes('.') || /^\d+(?:\.\d+)*$/.test(domain))
16632
+ return undefined;
16633
+ if (!domain.split('.').every((label) => /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/.test(label)))
16634
+ return undefined;
16635
+ if (domain.endsWith('.localhost') || domain.endsWith('.local') || domain.endsWith('.internal'))
16636
+ return undefined;
16637
+ return domain;
16638
+ }
16639
+ /** SDK 构建层独立消费平台资料;Runtime 继续独立校验可信启动策略。 */
16640
+ function parseMiniappBuildImagePolicy(value) {
16641
+ if (value === undefined || value === null)
16642
+ return undefined;
16643
+ if (typeof value !== 'object' || Array.isArray(value))
16644
+ throw new TypeError('图片构建策略格式无效');
16645
+ const record = value;
16646
+ const entries = record.entries === undefined ? [] : record.entries;
16647
+ if (!Number.isSafeInteger(record.revision) || record.revision < 1 ||
16648
+ (record.enforcement !== 'approved_domains' && record.enforcement !== 'restricted') ||
16649
+ !Array.isArray(entries) || entries.length > 20)
16650
+ throw new TypeError('图片构建策略格式无效');
16651
+ const domains = new Set();
16652
+ for (const entry of entries) {
16653
+ const domain = normalizeMiniappBuildImageDomain(entry && typeof entry === 'object' ? entry.domain : undefined);
16654
+ if (!domain)
16655
+ throw new TypeError('图片构建策略包含无效域名');
16656
+ domains.add(domain);
16657
+ }
16658
+ return Object.freeze({ revision: record.revision, enforcement: record.enforcement,
16659
+ entries: Object.freeze([...domains].sort().map((domain) => Object.freeze({ domain }))) });
16660
+ }
16661
+
16626
16662
  const HB_SDK_RUNTIME_USE_OFFICIAL_DOMAIN_ENV = 'HB_SDK_RUNTIME_USE_OFFICIAL_DOMAIN';
16627
16663
  const HB_SDK_RUNTIME_PERMISSION_CONTEXT_ENV = 'HB_SDK_RUNTIME_PERMISSION_CONTEXT';
16628
16664
  const VERIFIED_RUNTIME_PERMISSION_CONTEXT = 'verified';
16665
+ const NETWORK_POLICY_ENV = 'HB_SDK_RUNTIME_NETWORK_POLICY';
16629
16666
  const environmentScopeStorage = new node_async_hooks.AsyncLocalStorage();
16630
16667
  let environmentScopeTail = Promise.resolve();
16631
- function shouldSkipMiniappPlatformCspFromEnv(env = process.env) {
16632
- return env[HB_SDK_RUNTIME_PERMISSION_CONTEXT_ENV] === VERIFIED_RUNTIME_PERMISSION_CONTEXT && env[HB_SDK_RUNTIME_USE_OFFICIAL_DOMAIN_ENV] === '1';
16668
+ function shouldSkipMiniappPlatformCspFromEnv(_env = process.env) {
16669
+ return false;
16633
16670
  }
16634
- function createMiniappPlatformCspEnv(env, skipPlatformCsp) {
16671
+ function createMiniappPlatformCspEnv(env, _skipPlatformCsp, networkPolicy) {
16672
+ const policy = parseMiniappBuildImagePolicy(networkPolicy);
16635
16673
  return {
16636
16674
  ...env,
16637
16675
  [HB_SDK_RUNTIME_PERMISSION_CONTEXT_ENV]: VERIFIED_RUNTIME_PERMISSION_CONTEXT,
16638
- [HB_SDK_RUNTIME_USE_OFFICIAL_DOMAIN_ENV]: skipPlatformCsp ? '1' : '0',
16676
+ [HB_SDK_RUNTIME_USE_OFFICIAL_DOMAIN_ENV]: '0',
16677
+ [NETWORK_POLICY_ENV]: policy ? JSON.stringify(policy) : '',
16639
16678
  };
16640
16679
  }
16641
- async function withMiniappPlatformCspEnv(skipPlatformCsp, action, env = process.env) {
16680
+ async function withMiniappPlatformCspEnv(skipPlatformCsp, action, env = process.env, networkPolicy) {
16642
16681
  if (environmentScopeStorage.getStore()?.active) {
16643
- return runMiniappPlatformCspEnvScope(skipPlatformCsp, action, env);
16682
+ return runMiniappPlatformCspEnvScope(skipPlatformCsp, action, env, networkPolicy);
16644
16683
  }
16645
16684
  let releaseScope = () => undefined;
16646
16685
  const previousScope = environmentScopeTail;
@@ -16650,22 +16689,27 @@ async function withMiniappPlatformCspEnv(skipPlatformCsp, action, env = process.
16650
16689
  await previousScope;
16651
16690
  const scope = { active: true };
16652
16691
  try {
16653
- return await environmentScopeStorage.run(scope, () => runMiniappPlatformCspEnvScope(skipPlatformCsp, action, env));
16692
+ return await environmentScopeStorage.run(scope, () => runMiniappPlatformCspEnvScope(skipPlatformCsp, action, env, networkPolicy));
16654
16693
  }
16655
16694
  finally {
16656
16695
  scope.active = false;
16657
16696
  releaseScope();
16658
16697
  }
16659
16698
  }
16660
- async function runMiniappPlatformCspEnvScope(skipPlatformCsp, action, env) {
16699
+ async function runMiniappPlatformCspEnvScope(skipPlatformCsp, action, env, networkPolicy) {
16700
+ const policyValue = networkPolicy === undefined && env[HB_SDK_RUNTIME_PERMISSION_CONTEXT_ENV] === VERIFIED_RUNTIME_PERMISSION_CONTEXT && env[NETWORK_POLICY_ENV]
16701
+ ? JSON.parse(env[NETWORK_POLICY_ENV]) : networkPolicy;
16702
+ const policy = parseMiniappBuildImagePolicy(policyValue);
16661
16703
  const targets = env === process.env ? [env] : [env, process.env];
16662
16704
  const previousValues = targets.map((target) => ({
16663
16705
  context: target[HB_SDK_RUNTIME_PERMISSION_CONTEXT_ENV],
16664
16706
  officialDomain: target[HB_SDK_RUNTIME_USE_OFFICIAL_DOMAIN_ENV],
16707
+ networkPolicy: target[NETWORK_POLICY_ENV],
16665
16708
  }));
16666
16709
  for (const target of targets) {
16667
16710
  target[HB_SDK_RUNTIME_PERMISSION_CONTEXT_ENV] = VERIFIED_RUNTIME_PERMISSION_CONTEXT;
16668
- target[HB_SDK_RUNTIME_USE_OFFICIAL_DOMAIN_ENV] = skipPlatformCsp ? '1' : '0';
16711
+ target[HB_SDK_RUNTIME_USE_OFFICIAL_DOMAIN_ENV] = '0';
16712
+ target[NETWORK_POLICY_ENV] = policy ? JSON.stringify(policy) : '';
16669
16713
  }
16670
16714
  try {
16671
16715
  return await action();
@@ -16673,6 +16717,10 @@ async function runMiniappPlatformCspEnvScope(skipPlatformCsp, action, env) {
16673
16717
  finally {
16674
16718
  targets.forEach((target, index) => {
16675
16719
  const previousValue = previousValues[index];
16720
+ if (previousValue?.networkPolicy === undefined)
16721
+ delete target[NETWORK_POLICY_ENV];
16722
+ else
16723
+ target[NETWORK_POLICY_ENV] = previousValue.networkPolicy;
16676
16724
  if (previousValue?.context === undefined) {
16677
16725
  delete target[HB_SDK_RUNTIME_PERMISSION_CONTEXT_ENV];
16678
16726
  }
@@ -16734,6 +16782,7 @@ exports.normalizeBasicInfoName = normalizeBasicInfoName;
16734
16782
  exports.parseMiniProgramLocalDevGrant = parseMiniProgramLocalDevGrant;
16735
16783
  exports.parseMiniProgramRuntimePermissions = parseMiniProgramRuntimePermissions;
16736
16784
  exports.parseMiniappBasicInfo = parseMiniappBasicInfo;
16785
+ exports.parseMiniappBuildImagePolicy = parseMiniappBuildImagePolicy;
16737
16786
  exports.parseMiniappManifestJson = parseMiniappManifestJson;
16738
16787
  exports.parseMiniappPermissions = parseMiniappPermissions;
16739
16788
  exports.prepareMiniappArtifactFiles = prepareMiniappArtifactFiles;
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var version = require('./version-AWKcsAry.cjs');
3
+ var version = require('./version-Blqp4J3r.cjs');
4
4
  var fs = require('node:fs/promises');
5
5
  var path = require('node:path');
6
6
  var childProcess = require('node:child_process');
7
- var index = require('./index-DMnPneAL.cjs');
7
+ var index = require('./index-D0fPJhtR.cjs');
8
8
  require('node:module');
9
9
  require('readline');
10
10
  require('os');
@@ -3,6 +3,6 @@
3
3
  /** 构建时替换为当前发布包的实际版本。 */
4
4
  const HB_SDK_VERSION = typeof undefined === 'string'
5
5
  ? undefined
6
- : '0.9.6-alpha.7';
6
+ : '0.9.6-alpha.9';
7
7
 
8
8
  exports.HB_SDK_VERSION = HB_SDK_VERSION;
package/dist/cli.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./cli-chunks/index-DMnPneAL.cjs');
3
+ var index = require('./cli-chunks/index-D0fPJhtR.cjs');
4
4
  require('node:module');
5
5
  require('readline');
6
6
  require('os');