@heybox/hb-sdk 0.9.8-alpha.1 → 0.9.8-alpha.3
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/CHANGELOG.md +10 -0
- package/README.md +2 -0
- package/dist/cli-chunks/{artifact-DjBgoh5t.cjs → artifact-C4JTa7D5.cjs} +3 -3
- package/dist/cli-chunks/{build-BqCFUfmY.cjs → build-wK5IcYmp.cjs} +5 -5
- package/dist/cli-chunks/{create-C_vnYgLI.cjs → create-D1DAg4er.cjs} +1 -1
- package/dist/cli-chunks/{dev-context-C82TNyzm.cjs → dev-context-4ZGqANND.cjs} +2 -2
- package/dist/cli-chunks/{dev-Z3taoc-T.cjs → dev-zh_Wb9WZ.cjs} +131 -25
- package/dist/cli-chunks/{doctor-DDIsyoxg.cjs → doctor-Br31MP94.cjs} +1 -1
- package/dist/cli-chunks/{games-CTCD0YEP.cjs → games-B5bUkOCp.cjs} +1 -1
- package/dist/cli-chunks/{index-BiV06A8-.cjs → index-B8tKOZ1w.cjs} +20 -19
- package/dist/cli-chunks/{index-DCu4v5vi.cjs → index-CkPh8IQn.cjs} +1 -1
- package/dist/cli-chunks/{index.esm-BRUvLPPL.cjs → index.esm-DOvuMPDE.cjs} +6 -6
- package/dist/cli-chunks/{login-DrWMllmo.cjs → login-BGxsC07i.cjs} +1 -1
- package/dist/cli-chunks/{project-vite-Bt1IWMur.cjs → project-vite-DU7Wp4o5.cjs} +1 -1
- package/dist/cli-chunks/{remote-CtJrk68J.cjs → remote-HX0wMZ6W.cjs} +10 -8
- package/dist/cli-chunks/{runtime-permission-env-CIoMGBsf.cjs → runtime-permission-env-CAnNV2Lw.cjs} +23 -10
- package/dist/cli-chunks/{skill-B2MlFRqa.cjs → skill-B6KtNum4.cjs} +2 -2
- package/dist/cli-chunks/{version-DWFMQ8sw.cjs → version-DIhLu9jy.cjs} +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/devtools/browser-dev-host/assets/{browser-dev-host-W4n05_Hx.js → browser-dev-host-5lgAW5KL.js} +12 -12
- package/dist/devtools/browser-dev-host/assets/{desktop-app-launch-CCRhmr4a.js → desktop-app-launch-B4cpTP3G.js} +1 -1
- package/dist/devtools/browser-dev-host/assets/{index-I6DUyM3f.js → index-DxL85blk.js} +3 -3
- package/dist/devtools/browser-dev-host/index.html +2 -2
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/vite.cjs.js +34 -9
- package/dist/vite.esm.js +34 -9
- package/package.json +7 -7
- package/skill/skill.json +4 -4
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var index_esm = require('./index.esm-CvMA_ppV.cjs');
|
|
4
|
-
var runtimePermissionEnv = require('./runtime-permission-env-
|
|
5
|
-
var devContext = require('./dev-context-
|
|
4
|
+
var runtimePermissionEnv = require('./runtime-permission-env-CAnNV2Lw.cjs');
|
|
5
|
+
var devContext = require('./dev-context-4ZGqANND.cjs');
|
|
6
6
|
var promises = require('node:readline/promises');
|
|
7
|
-
var index = require('./index-
|
|
7
|
+
var index = require('./index-B8tKOZ1w.cjs');
|
|
8
8
|
var childProcess = require('node:child_process');
|
|
9
9
|
var fs = require('node:fs');
|
|
10
10
|
var fs$1 = require('node:fs/promises');
|
|
11
11
|
var path = require('node:path');
|
|
12
12
|
var node_crypto = require('node:crypto');
|
|
13
13
|
require('node:zlib');
|
|
14
|
-
var artifact = require('./artifact-
|
|
15
|
-
require('./version-
|
|
14
|
+
var artifact = require('./artifact-C4JTa7D5.cjs');
|
|
15
|
+
require('./version-DIhLu9jy.cjs');
|
|
16
16
|
require('node:async_hooks');
|
|
17
17
|
require('sharp');
|
|
18
18
|
require('node:module');
|
|
@@ -310,7 +310,7 @@ function createDefaultCosClient(uploadToken, COS) {
|
|
|
310
310
|
};
|
|
311
311
|
}
|
|
312
312
|
async function loadCosConstructor() {
|
|
313
|
-
const cosModule = await Promise.resolve().then(function () { return require('./index-
|
|
313
|
+
const cosModule = await Promise.resolve().then(function () { return require('./index-CkPh8IQn.cjs'); }).then(function (n) { return n.index; });
|
|
314
314
|
return cosModule.default;
|
|
315
315
|
}
|
|
316
316
|
function formatSize(bytes) {
|
|
@@ -426,7 +426,7 @@ async function runDeployCommand(options, runtime = {}) {
|
|
|
426
426
|
const projectRoot = index.findProjectRoot(cwd);
|
|
427
427
|
const packageJson = await readPackageJson(projectRoot);
|
|
428
428
|
const miniProgramId = packageJson.heybox?.miniProgramId;
|
|
429
|
-
const autoPublish =
|
|
429
|
+
const autoPublish = options.autoPublish ?? true;
|
|
430
430
|
const env = options.env ?? process.env;
|
|
431
431
|
const apiBaseUrl = index.resolveHeyboxApiBaseUrl({ ...options, env });
|
|
432
432
|
const loginBaseUrl = index.resolveHeyboxLoginBaseUrl({ ...options, env });
|
|
@@ -471,6 +471,7 @@ async function runDeployCommand(options, runtime = {}) {
|
|
|
471
471
|
}, runtime, apiBaseUrl, projectRoot, logger);
|
|
472
472
|
let skipPlatformCsp = false;
|
|
473
473
|
let networkPolicy;
|
|
474
|
+
let firstParty = false;
|
|
474
475
|
try {
|
|
475
476
|
const { detail } = await logger.task('正在读取远端小程序权限', () => (runtime.getBoundMiniProgram ?? devContext.getBoundMiniProgram)({
|
|
476
477
|
allowUnsafeApiBaseUrl: options.allowUnsafeApiBaseUrl,
|
|
@@ -482,6 +483,7 @@ async function runDeployCommand(options, runtime = {}) {
|
|
|
482
483
|
session,
|
|
483
484
|
}), { successText: '已读取远端小程序权限' });
|
|
484
485
|
const effectivePermissions = runtimePermissionEnv.composeMiniappRuntimePermissions(localPermissions, detail.runtime_permissions, detail.party_type).runtimePermissions;
|
|
486
|
+
firstParty = detail.party_type === 'first_party';
|
|
485
487
|
skipPlatformCsp = devContext.shouldSkipMiniappPlatformCsp(effectivePermissions);
|
|
486
488
|
networkPolicy = effectivePermissions.entries.some((entry) => entry.key === 'network' && entry.status === 'enabled')
|
|
487
489
|
? detail.network_policy : undefined;
|
|
@@ -499,7 +501,7 @@ async function runDeployCommand(options, runtime = {}) {
|
|
|
499
501
|
const buildScript = await readProjectBuildScript(projectRoot);
|
|
500
502
|
logger.info(`开始构建: ${pm} ${createBuildArgs(pm, buildMode, buildScript).join(' ')}`);
|
|
501
503
|
await runBuildScript(pm, projectRoot, runtime.spawn ?? childProcess.spawn, {
|
|
502
|
-
env: { ...runtimePermissionEnv.createMiniappPlatformCspEnv(env, skipPlatformCsp, networkPolicy), HB_SDK_DEFER_METADATA_WARNINGS: '1' },
|
|
504
|
+
env: { ...runtimePermissionEnv.createMiniappPlatformCspEnv(env, skipPlatformCsp, networkPolicy, firstParty), HB_SDK_DEFER_METADATA_WARNINGS: '1' },
|
|
503
505
|
mode: buildMode,
|
|
504
506
|
outputMode: options.buildOutputMode ?? 'inherit',
|
|
505
507
|
platform,
|
package/dist/cli-chunks/{runtime-permission-env-CIoMGBsf.cjs → runtime-permission-env-CAnNV2Lw.cjs}
RENAMED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
var fs = require('node:fs');
|
|
4
4
|
var path = require('node:path');
|
|
5
|
-
var version = require('./version-
|
|
5
|
+
var version = require('./version-DIhLu9jy.cjs');
|
|
6
6
|
require('node:crypto');
|
|
7
7
|
var index_esm = require('./index.esm-CvMA_ppV.cjs');
|
|
8
|
-
var index = require('./index-
|
|
8
|
+
var index = require('./index-B8tKOZ1w.cjs');
|
|
9
9
|
var node_async_hooks = require('node:async_hooks');
|
|
10
10
|
|
|
11
11
|
const BASIC_INFO_MAX_BYTES = 10 * 1024 * 1024;
|
|
@@ -315,7 +315,7 @@ partyType) {
|
|
|
315
315
|
}
|
|
316
316
|
const requestedOfficialDomain = declaration?.enabled === true && 'useOfficialDomain' in declaration && declaration.useOfficialDomain;
|
|
317
317
|
const approvedOfficialDomain = approval?.config.useOfficialDomain === true;
|
|
318
|
-
const effectiveOfficialDomain = effective && (local.declared ? requestedOfficialDomain : true) &&
|
|
318
|
+
const effectiveOfficialDomain = effective && (autoApproved || ((local.declared ? requestedOfficialDomain : true) && approvedOfficialDomain));
|
|
319
319
|
views.push({
|
|
320
320
|
key: definition.key,
|
|
321
321
|
access: definition.access,
|
|
@@ -9734,23 +9734,29 @@ const HB_SDK_RUNTIME_USE_OFFICIAL_DOMAIN_ENV = 'HB_SDK_RUNTIME_USE_OFFICIAL_DOMA
|
|
|
9734
9734
|
const HB_SDK_RUNTIME_PERMISSION_CONTEXT_ENV = 'HB_SDK_RUNTIME_PERMISSION_CONTEXT';
|
|
9735
9735
|
const VERIFIED_RUNTIME_PERMISSION_CONTEXT = 'verified';
|
|
9736
9736
|
const NETWORK_POLICY_ENV = 'HB_SDK_RUNTIME_NETWORK_POLICY';
|
|
9737
|
+
const FIRST_PARTY_ENV = 'HB_SDK_RUNTIME_FIRST_PARTY';
|
|
9737
9738
|
const environmentScopeStorage = new node_async_hooks.AsyncLocalStorage();
|
|
9738
9739
|
let environmentScopeTail = Promise.resolve();
|
|
9739
9740
|
function shouldSkipMiniappPlatformCspFromEnv(_env = process.env) {
|
|
9740
9741
|
return false;
|
|
9741
9742
|
}
|
|
9742
|
-
|
|
9743
|
-
|
|
9743
|
+
/** 仅消费 CLI 远端身份上下文;不复用网络权限或本地 Manifest 作为第一方身份。 */
|
|
9744
|
+
function readMiniappFirstPartyFromEnv(env = process.env) {
|
|
9745
|
+
return env[HB_SDK_RUNTIME_PERMISSION_CONTEXT_ENV] === VERIFIED_RUNTIME_PERMISSION_CONTEXT && env[FIRST_PARTY_ENV] === '1';
|
|
9746
|
+
}
|
|
9747
|
+
function createMiniappPlatformCspEnv(env, _skipPlatformCsp, networkPolicy, firstParty = false) {
|
|
9748
|
+
const policy = firstParty === true ? undefined : parseMiniappBuildImagePolicy(networkPolicy);
|
|
9744
9749
|
return {
|
|
9745
9750
|
...env,
|
|
9746
9751
|
[HB_SDK_RUNTIME_PERMISSION_CONTEXT_ENV]: VERIFIED_RUNTIME_PERMISSION_CONTEXT,
|
|
9747
9752
|
[HB_SDK_RUNTIME_USE_OFFICIAL_DOMAIN_ENV]: '0',
|
|
9748
9753
|
[NETWORK_POLICY_ENV]: policy ? JSON.stringify(policy) : '',
|
|
9754
|
+
[FIRST_PARTY_ENV]: firstParty === true ? '1' : '0',
|
|
9749
9755
|
};
|
|
9750
9756
|
}
|
|
9751
|
-
async function withMiniappPlatformCspEnv(skipPlatformCsp, action, env = process.env, networkPolicy) {
|
|
9757
|
+
async function withMiniappPlatformCspEnv(skipPlatformCsp, action, env = process.env, networkPolicy, firstParty) {
|
|
9752
9758
|
if (environmentScopeStorage.getStore()?.active) {
|
|
9753
|
-
return runMiniappPlatformCspEnvScope(skipPlatformCsp, action, env, networkPolicy);
|
|
9759
|
+
return runMiniappPlatformCspEnvScope(skipPlatformCsp, action, env, networkPolicy, firstParty);
|
|
9754
9760
|
}
|
|
9755
9761
|
let releaseScope = () => undefined;
|
|
9756
9762
|
const previousScope = environmentScopeTail;
|
|
@@ -9760,15 +9766,16 @@ async function withMiniappPlatformCspEnv(skipPlatformCsp, action, env = process.
|
|
|
9760
9766
|
await previousScope;
|
|
9761
9767
|
const scope = { active: true };
|
|
9762
9768
|
try {
|
|
9763
|
-
return await environmentScopeStorage.run(scope, () => runMiniappPlatformCspEnvScope(skipPlatformCsp, action, env, networkPolicy));
|
|
9769
|
+
return await environmentScopeStorage.run(scope, () => runMiniappPlatformCspEnvScope(skipPlatformCsp, action, env, networkPolicy, firstParty));
|
|
9764
9770
|
}
|
|
9765
9771
|
finally {
|
|
9766
9772
|
scope.active = false;
|
|
9767
9773
|
releaseScope();
|
|
9768
9774
|
}
|
|
9769
9775
|
}
|
|
9770
|
-
async function runMiniappPlatformCspEnvScope(skipPlatformCsp, action, env, networkPolicy) {
|
|
9771
|
-
const
|
|
9776
|
+
async function runMiniappPlatformCspEnvScope(skipPlatformCsp, action, env, networkPolicy, firstParty) {
|
|
9777
|
+
const verifiedFirstParty = firstParty === undefined ? readMiniappFirstPartyFromEnv(env) : firstParty === true;
|
|
9778
|
+
const policyValue = verifiedFirstParty ? undefined : networkPolicy === undefined && env[HB_SDK_RUNTIME_PERMISSION_CONTEXT_ENV] === VERIFIED_RUNTIME_PERMISSION_CONTEXT && env[NETWORK_POLICY_ENV]
|
|
9772
9779
|
? JSON.parse(env[NETWORK_POLICY_ENV]) : networkPolicy;
|
|
9773
9780
|
const policy = parseMiniappBuildImagePolicy(policyValue);
|
|
9774
9781
|
const targets = env === process.env ? [env] : [env, process.env];
|
|
@@ -9776,11 +9783,13 @@ async function runMiniappPlatformCspEnvScope(skipPlatformCsp, action, env, netwo
|
|
|
9776
9783
|
context: target[HB_SDK_RUNTIME_PERMISSION_CONTEXT_ENV],
|
|
9777
9784
|
officialDomain: target[HB_SDK_RUNTIME_USE_OFFICIAL_DOMAIN_ENV],
|
|
9778
9785
|
networkPolicy: target[NETWORK_POLICY_ENV],
|
|
9786
|
+
firstParty: target[FIRST_PARTY_ENV],
|
|
9779
9787
|
}));
|
|
9780
9788
|
for (const target of targets) {
|
|
9781
9789
|
target[HB_SDK_RUNTIME_PERMISSION_CONTEXT_ENV] = VERIFIED_RUNTIME_PERMISSION_CONTEXT;
|
|
9782
9790
|
target[HB_SDK_RUNTIME_USE_OFFICIAL_DOMAIN_ENV] = '0';
|
|
9783
9791
|
target[NETWORK_POLICY_ENV] = policy ? JSON.stringify(policy) : '';
|
|
9792
|
+
target[FIRST_PARTY_ENV] = verifiedFirstParty === true ? '1' : '0';
|
|
9784
9793
|
}
|
|
9785
9794
|
try {
|
|
9786
9795
|
return await action();
|
|
@@ -9788,6 +9797,10 @@ async function runMiniappPlatformCspEnvScope(skipPlatformCsp, action, env, netwo
|
|
|
9788
9797
|
finally {
|
|
9789
9798
|
targets.forEach((target, index) => {
|
|
9790
9799
|
const previousValue = previousValues[index];
|
|
9800
|
+
if (previousValue?.firstParty === undefined)
|
|
9801
|
+
delete target[FIRST_PARTY_ENV];
|
|
9802
|
+
else
|
|
9803
|
+
target[FIRST_PARTY_ENV] = previousValue.firstParty;
|
|
9791
9804
|
if (previousValue?.networkPolicy === undefined)
|
|
9792
9805
|
delete target[NETWORK_POLICY_ENV];
|
|
9793
9806
|
else
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var version = require('./version-
|
|
3
|
+
var version = require('./version-DIhLu9jy.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-
|
|
7
|
+
var index = require('./index-B8tKOZ1w.cjs');
|
|
8
8
|
require('node:module');
|
|
9
9
|
require('readline');
|
|
10
10
|
require('os');
|