@heybox/hb-sdk 0.9.1-alpha.1 → 0.9.1-alpha.10
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 +117 -2
- package/README.md +43 -5
- package/dist/card-controller.cjs.js +194 -0
- package/dist/card-controller.esm.js +159 -0
- package/dist/cli-chunks/_commonjs-dynamic-modules-DUamuDzp.cjs +7 -0
- package/dist/cli-chunks/{build-C5jFqooo.cjs → build-BK0MOduC.cjs} +15 -7
- package/dist/cli-chunks/{context-BkvtRlQM.cjs → context-D7AFyc_9.cjs} +14 -14
- package/dist/cli-chunks/{create-uHfLV3qo.cjs → create-C-pAXZR_.cjs} +5 -3
- package/dist/cli-chunks/{dev-BGgykbLg.cjs → dev-CONKtd6c.cjs} +59 -14
- package/dist/cli-chunks/{doctor-Cfn2luVo.cjs → doctor-D18leeH7.cjs} +8 -5
- package/dist/cli-chunks/{index-B0eNYO7I.cjs → index-BWRDIX1T.cjs} +7851 -486
- package/dist/cli-chunks/{index-DZQ84rXZ.cjs → index-DJoBhXcG.cjs} +9 -13
- package/dist/cli-chunks/{index.esm-I50IudW7.cjs → index.esm-CtAKePcf.cjs} +36 -37
- package/dist/cli-chunks/{login-BonS2uKg.cjs → login-BHq8vDRt.cjs} +36 -36
- package/dist/cli-chunks/{project-vite-BA_CFVq_.cjs → project-vite-DD3bmbqm.cjs} +1 -1
- package/dist/cli-chunks/{remote-NMK4n5ov.cjs → remote-DeLLzkXt.cjs} +71 -90
- package/dist/cli-chunks/runtime-gate-wKj1l5xM.cjs +201946 -0
- package/dist/cli-chunks/{runtime-permission-env-Bg7f-uj8.cjs → runtime-permission-env-DBra_0-U.cjs} +7012 -3305
- package/dist/cli-chunks/{skill-DV2oEH-I.cjs → skill-Cq3wjRBj.cjs} +9 -6
- package/dist/cli-chunks/{version-rxh3jOOI.cjs → version-BF4JQQCU.cjs} +1 -1
- package/dist/cli.cjs +10 -7
- package/dist/devtools/browser-dev-host/assets/browser-dev-host-C4b9nlYA.js +102 -0
- package/dist/devtools/browser-dev-host/assets/desktop-app-launch-DXmUwcoE.js +6 -0
- package/dist/devtools/browser-dev-host/assets/index-BRxbUJVN.css +1 -0
- package/dist/devtools/browser-dev-host/assets/{index-sykXQUSO.js → index-CVZ3CdPt.js} +4 -4
- package/dist/devtools/browser-dev-host/index.html +3 -3
- package/dist/index.cjs.js +6331 -280
- package/dist/index.esm.js +6331 -281
- package/dist/miniapp-publish.cjs.js +6613 -157
- package/dist/miniapp-publish.esm.js +6613 -158
- package/dist/protocol.cjs.js +5824 -0
- package/dist/protocol.esm.js +5823 -1
- package/dist/vite.cjs.js +7476 -206
- package/dist/vite.esm.js +7475 -207
- package/dist/workspace-card-build-sandbox-worker.mjs +72 -0
- package/package.json +33 -18
- package/skill/SKILL.md +15 -0
- package/skill/skill.json +5 -5
- package/types/card-controller.d.ts +3682 -0
- package/types/index.d.ts +7639 -35
- package/types/miniapp-publish/index.d.ts +542 -64
- package/types/protocol.d.ts +2094 -9
- package/types/vite/index.d.ts +25 -12
- package/dist/cli-chunks/runtime-gate-CKGRK3wC.cjs +0 -65
- package/dist/cli-chunks/session-XP1Y_N72.cjs +0 -3403
- package/dist/devtools/browser-dev-host/assets/browser-dev-host-CBMI8jM6.js +0 -102
- package/dist/devtools/browser-dev-host/assets/desktop-app-launch-DXfb_JMF.js +0 -6
- package/dist/devtools/browser-dev-host/assets/index-DRM3hPNc.css +0 -1
- package/types/core/client.d.ts +0 -108
- package/types/core/csp-violation.d.ts +0 -5
- package/types/core/errors.d.ts +0 -78
- package/types/core/event-bus.d.ts +0 -11
- package/types/core/handshake-state.d.ts +0 -54
- package/types/core/history-observer.d.ts +0 -4
- package/types/core/mini-dev-console.d.ts +0 -36
- package/types/core/network-sanitize.d.ts +0 -31
- package/types/core/sdk.d.ts +0 -104
- package/types/core/singleton.d.ts +0 -372
- package/types/core/utils.d.ts +0 -10
- package/types/core/version.d.ts +0 -2
- package/types/devtools/device-logs.d.ts +0 -48
- package/types/miniapp-manifest/basic-info-browser.d.ts +0 -37
- package/types/miniapp-manifest/basic-info-image-header.d.ts +0 -6
- package/types/miniapp-manifest/basic-info-node.d.ts +0 -17
- package/types/miniapp-manifest/basic-info-placeholder.d.ts +0 -1
- package/types/miniapp-manifest/basic-info.d.ts +0 -33
- package/types/miniapp-manifest/bindings.d.ts +0 -70
- package/types/miniapp-manifest/category.d.ts +0 -11
- package/types/miniapp-manifest/companion-directory.d.ts +0 -2
- package/types/miniapp-manifest/companion-executable.d.ts +0 -4
- package/types/miniapp-manifest/companion-types.d.ts +0 -63
- package/types/miniapp-manifest/companions.d.ts +0 -17
- package/types/miniapp-manifest/index.d.ts +0 -7
- package/types/miniapp-manifest/node.d.ts +0 -22
- package/types/miniapp-manifest/permissions.d.ts +0 -48
- package/types/miniapp-manifest/runtime-gate.d.ts +0 -12
- package/types/miniapp-manifest/schema.d.ts +0 -302
- package/types/modules/auth/index.d.ts +0 -204
- package/types/modules/cloud/index.d.ts +0 -669
- package/types/modules/companion/index.d.ts +0 -1619
- package/types/modules/device/index.d.ts +0 -193
- package/types/modules/environment/index.d.ts +0 -238
- package/types/modules/files/index.d.ts +0 -5
- package/types/modules/files/registry.d.ts +0 -35
- package/types/modules/files/types.d.ts +0 -1548
- package/types/modules/navigation/app-pages/index.d.ts +0 -4
- package/types/modules/navigation/app-pages/types.d.ts +0 -135
- package/types/modules/navigation/index.d.ts +0 -312
- package/types/modules/network/index.d.ts +0 -457
- package/types/modules/network/observability.d.ts +0 -38
- package/types/modules/network/request-shape.d.ts +0 -44
- package/types/modules/share/copy-link.d.ts +0 -46
- package/types/modules/share/extra.d.ts +0 -5
- package/types/modules/share/index.d.ts +0 -294
- package/types/modules/share/screenshot.d.ts +0 -34
- package/types/modules/share/show-share-menu.d.ts +0 -29
- package/types/modules/share/types.d.ts +0 -201
- package/types/modules/storage/index.d.ts +0 -214
- package/types/modules/ui/index.d.ts +0 -315
- package/types/modules/user/get-info.d.ts +0 -44
- package/types/modules/user/index.d.ts +0 -245
- package/types/modules/user/revoke-authorization.d.ts +0 -31
- package/types/modules/user/steam-game-list.d.ts +0 -153
- package/types/modules/user/types.d.ts +0 -2
- package/types/modules/viewport/index.d.ts +0 -319
- package/types/protocol/capabilities.d.ts +0 -2
- package/types/protocol/constants.d.ts +0 -1
- package/types/protocol/dev-session.d.ts +0 -74
- package/types/protocol/guards.d.ts +0 -1
- package/types/protocol/runtime-permissions.d.ts +0 -2
- package/types/protocol/types.d.ts +0 -22
- package/types/skill-metadata.d.ts +0 -18
- package/types/vite/html-policy.d.ts +0 -6
- package/types/vite/runtime-permission-env.d.ts +0 -9
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
var node_crypto = require('node:crypto');
|
|
4
4
|
var fs = require('node:fs/promises');
|
|
5
5
|
var path = require('node:path');
|
|
6
|
-
var runtimePermissionEnv = require('./runtime-permission-env-
|
|
6
|
+
var runtimePermissionEnv = require('./runtime-permission-env-DBra_0-U.cjs');
|
|
7
7
|
var fs$1 = require('node:fs');
|
|
8
8
|
var sharp = require('sharp');
|
|
9
|
-
var
|
|
9
|
+
var index = require('./index-BWRDIX1T.cjs');
|
|
10
10
|
|
|
11
11
|
async function inspectBasicInfoImage(bytes, sourcePath, kind) {
|
|
12
12
|
const inspected = await inspectDecodedBasicInfoImage(bytes, kind);
|
|
@@ -345,8 +345,8 @@ function resolveBrowserFakeContext(context, now = Date.now()) {
|
|
|
345
345
|
runtimePermissions: context.runtimePermissions,
|
|
346
346
|
revision: parsed.grant.revision,
|
|
347
347
|
eligiblePermissionKeys: context.platforms?.some((platform) => ['windows', 'macos', 'linux'].includes(platform))
|
|
348
|
-
? ['network', 'companion']
|
|
349
|
-
: ['network'],
|
|
348
|
+
? ['network', 'companion', 'appProtocol']
|
|
349
|
+
: ['network', 'appProtocol'],
|
|
350
350
|
}),
|
|
351
351
|
};
|
|
352
352
|
}
|
|
@@ -525,20 +525,20 @@ async function listUserMiniprogramVersions(options, runtime) {
|
|
|
525
525
|
}
|
|
526
526
|
async function remoteGet(path, query, runtime) {
|
|
527
527
|
const pathWithQuery = createPathWithQuery(path, query);
|
|
528
|
-
const context =
|
|
528
|
+
const context = index.createHeyboxOpenPlatformRequestContext(runtime.session, pathWithQuery);
|
|
529
529
|
const fetchImpl = runtime.fetchImpl ?? fetch;
|
|
530
|
-
const response = await fetchImpl(
|
|
530
|
+
const response = await fetchImpl(index.createHeyboxApiUrl(runtime.baseUrl ?? context.baseUrl, pathWithQuery, context.platformParams), {
|
|
531
531
|
method: 'GET',
|
|
532
532
|
headers: context.headers,
|
|
533
533
|
});
|
|
534
534
|
return readRequiredResult(response, pathWithQuery);
|
|
535
535
|
}
|
|
536
536
|
async function remotePostForm(path, fields, runtime, options = {}) {
|
|
537
|
-
const context =
|
|
537
|
+
const context = index.createHeyboxOpenPlatformRequestContext(runtime.session, path, {
|
|
538
538
|
contentType: 'application/x-www-form-urlencoded',
|
|
539
539
|
});
|
|
540
540
|
const fetchImpl = runtime.fetchImpl ?? fetch;
|
|
541
|
-
const response = await fetchImpl(
|
|
541
|
+
const response = await fetchImpl(index.createHeyboxApiUrl(runtime.baseUrl ?? context.baseUrl, path, context.platformParams), {
|
|
542
542
|
method: 'POST',
|
|
543
543
|
headers: context.headers,
|
|
544
544
|
body: createFormBody(fields),
|
|
@@ -549,11 +549,11 @@ async function remotePostForm(path, fields, runtime, options = {}) {
|
|
|
549
549
|
return readRequiredResult(response, path);
|
|
550
550
|
}
|
|
551
551
|
async function readRequiredResult(response, pathWithQuery) {
|
|
552
|
-
const result = await
|
|
552
|
+
const result = await index.readHeyboxApiEnvelope(response, { pathWithQuery, requireResult: true });
|
|
553
553
|
return result;
|
|
554
554
|
}
|
|
555
555
|
async function readOptionalResult(response, pathWithQuery) {
|
|
556
|
-
return
|
|
556
|
+
return index.readHeyboxApiEnvelope(response, { pathWithQuery, requireResult: false });
|
|
557
557
|
}
|
|
558
558
|
function createPathWithQuery(path, query) {
|
|
559
559
|
const params = new URLSearchParams();
|
|
@@ -586,16 +586,16 @@ function createFormBody(fields) {
|
|
|
586
586
|
|
|
587
587
|
async function resolveRemoteEnvironment(options = {}, runtime = {}) {
|
|
588
588
|
const env = options.env ?? process.env;
|
|
589
|
-
const apiBaseUrl =
|
|
590
|
-
const loginBaseUrl =
|
|
591
|
-
const session
|
|
589
|
+
const apiBaseUrl = index.resolveHeyboxApiBaseUrl({ ...options, env });
|
|
590
|
+
const loginBaseUrl = index.resolveHeyboxLoginBaseUrl({ ...options, env });
|
|
591
|
+
const session = options.session ?? (await (runtime.requireAuthSession ?? index.requireHeyboxAuthSession)({ loginBaseUrl }));
|
|
592
592
|
return {
|
|
593
593
|
apiBaseUrl,
|
|
594
594
|
loginBaseUrl,
|
|
595
595
|
allowUnsafeApiBaseUrl: options.allowUnsafeApiBaseUrl === true || isTruthyEnvFlag(env.HB_SDK_ALLOW_UNSAFE_API_BASE_URL),
|
|
596
596
|
env,
|
|
597
597
|
fetchImpl: runtime.fetchImpl ?? options.fetchImpl ?? fetch,
|
|
598
|
-
session
|
|
598
|
+
session,
|
|
599
599
|
};
|
|
600
600
|
}
|
|
601
601
|
function createRemoteApiClientForEnvironment(environment) {
|
|
@@ -5,17 +5,19 @@ var fs = require('node:fs/promises');
|
|
|
5
5
|
var path = require('node:path');
|
|
6
6
|
var require$$0 = require('fs');
|
|
7
7
|
var require$$1 = require('path');
|
|
8
|
-
var index = require('./index-
|
|
8
|
+
var index = require('./index-BWRDIX1T.cjs');
|
|
9
9
|
require('node:module');
|
|
10
|
-
require('os');
|
|
11
|
-
require('node:crypto');
|
|
12
10
|
require('readline');
|
|
11
|
+
require('os');
|
|
13
12
|
require('tty');
|
|
14
13
|
require('assert');
|
|
15
14
|
require('events');
|
|
16
15
|
require('stream');
|
|
17
16
|
require('buffer');
|
|
18
17
|
require('util');
|
|
18
|
+
require('node:crypto');
|
|
19
|
+
require('constants');
|
|
20
|
+
require('node:zlib');
|
|
19
21
|
|
|
20
22
|
var ejs = {};
|
|
21
23
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var context = require('./context-
|
|
3
|
+
var index = require('./index-BWRDIX1T.cjs');
|
|
4
|
+
var context = require('./context-D7AFyc_9.cjs');
|
|
5
5
|
var node_crypto = require('node:crypto');
|
|
6
6
|
var fs = require('node:fs');
|
|
7
|
-
var runtimePermissionEnv = require('./runtime-permission-env-
|
|
7
|
+
var runtimePermissionEnv = require('./runtime-permission-env-DBra_0-U.cjs');
|
|
8
8
|
var os = require('node:os');
|
|
9
9
|
var path = require('node:path');
|
|
10
10
|
var net = require('node:net');
|
|
@@ -13,12 +13,11 @@ var node_http = require('node:http');
|
|
|
13
13
|
var node_module = require('node:module');
|
|
14
14
|
var undici = require('undici');
|
|
15
15
|
var fs$1 = require('node:fs/promises');
|
|
16
|
-
var index = require('./index-B0eNYO7I.cjs');
|
|
17
16
|
var require$$0$1 = require('crypto');
|
|
18
17
|
var require$$0 = require('buffer');
|
|
19
18
|
var browser = require('./browser-RAy8e8cV.cjs');
|
|
20
|
-
var projectVite = require('./project-vite-
|
|
21
|
-
var version = require('./version-
|
|
19
|
+
var projectVite = require('./project-vite-DD3bmbqm.cjs');
|
|
20
|
+
var version = require('./version-BF4JQQCU.cjs');
|
|
22
21
|
require('node:zlib');
|
|
23
22
|
|
|
24
23
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
@@ -1993,8 +1992,8 @@ const DEFAULT_CHANNEL_TRANSPORT = {
|
|
|
1993
1992
|
};
|
|
1994
1993
|
const IPV4_LOOPBACK_ADDRESSES = new net.BlockList();
|
|
1995
1994
|
IPV4_LOOPBACK_ADDRESSES.addSubnet('127.0.0.0', 8, 'ipv4');
|
|
1996
|
-
const { WebSocket, WebSocketServer } = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/dev-
|
|
1997
|
-
const { parse: parseHtml } = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/dev-
|
|
1995
|
+
const { WebSocket, WebSocketServer } = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/dev-CONKtd6c.cjs', document.baseURI).href)))('ws');
|
|
1996
|
+
const { parse: parseHtml } = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/dev-CONKtd6c.cjs', document.baseURI).href)))('parse5');
|
|
1998
1997
|
const BROWSER_DEV_HOST_ROOT_CANDIDATES = [
|
|
1999
1998
|
path.resolve(__dirname, 'devtools/browser-dev-host'),
|
|
2000
1999
|
path.resolve(__dirname, '../devtools/browser-dev-host'),
|
|
@@ -2023,10 +2022,12 @@ async function startBrowserDevHostServer(options) {
|
|
|
2023
2022
|
csrfToken: sessionController.csrfToken,
|
|
2024
2023
|
defaultLanAddressId: options.defaultLanAddressId,
|
|
2025
2024
|
devContext: options.devContext,
|
|
2025
|
+
devSessionId: options.devSessionId,
|
|
2026
2026
|
lanAddresses: options.lanAddresses ?? [],
|
|
2027
2027
|
loginAvailable: options.loginService !== undefined,
|
|
2028
2028
|
miniProgram: options.miniProgram,
|
|
2029
2029
|
miniProgramSupportsDesktop: options.miniProgramSupportsDesktop,
|
|
2030
|
+
workspaceCardsEnabled: options.workspaceCardsEnabled === true,
|
|
2030
2031
|
mobileLaunchRedirect: initialMobileLaunchRedirect,
|
|
2031
2032
|
nativeAppLaunchUnavailableReason: options.nativeAppLaunchUnavailableReason,
|
|
2032
2033
|
miniProgramManifestAccessToken: options.miniProgramManifestAccessToken,
|
|
@@ -2118,6 +2119,8 @@ async function startBrowserDevHostServer(options) {
|
|
|
2118
2119
|
bootstrap.miniProgram = next.miniProgram;
|
|
2119
2120
|
if (next.miniProgramSupportsDesktop !== undefined)
|
|
2120
2121
|
bootstrap.miniProgramSupportsDesktop = next.miniProgramSupportsDesktop;
|
|
2122
|
+
if (next.workspaceCardsEnabled !== undefined)
|
|
2123
|
+
bootstrap.workspaceCardsEnabled = next.workspaceCardsEnabled;
|
|
2121
2124
|
bootstrapJson = serializeBrowserDevHostBootstrap(bootstrap);
|
|
2122
2125
|
},
|
|
2123
2126
|
networkUrls: createBrowserDevHostNetworkUrls({
|
|
@@ -11090,7 +11093,7 @@ function assertNodeRuntimeCapabilities(ctx, settings) {
|
|
|
11090
11093
|
function createNodeRealtimeDriverRegistry() {
|
|
11091
11094
|
const registry = createRuntimeRealtimeDriverRegistry();
|
|
11092
11095
|
registry.registerLazy('node-websocket', async () => {
|
|
11093
|
-
const mod = await Promise.resolve().then(function () { return require('./index.esm-
|
|
11096
|
+
const mod = await Promise.resolve().then(function () { return require('./index.esm-CtAKePcf.cjs'); });
|
|
11094
11097
|
return mod.createNodeWebSocketRuntimeDriver();
|
|
11095
11098
|
});
|
|
11096
11099
|
return registry;
|
|
@@ -14901,7 +14904,7 @@ function createBrowserDevHostCliAuth(options = {}) {
|
|
|
14901
14904
|
const fetchImpl = options.fetchImpl ?? fetch;
|
|
14902
14905
|
const noRedirectFetch = (input, init) => fetchImpl(input, { ...init, redirect: 'manual' });
|
|
14903
14906
|
const store = options.store ?? { env: options.env };
|
|
14904
|
-
const readSession = options.readSession ?? (() =>
|
|
14907
|
+
const readSession = options.readSession ?? (() => index.readHeyboxAuthSession(store));
|
|
14905
14908
|
let lastKey = '';
|
|
14906
14909
|
let revision = 0;
|
|
14907
14910
|
let profileKey = '';
|
|
@@ -15402,6 +15405,9 @@ function writeResponse(response, status, body) {
|
|
|
15402
15405
|
response.end(body === undefined ? '' : JSON.stringify(body));
|
|
15403
15406
|
}
|
|
15404
15407
|
|
|
15408
|
+
const WORKSPACE_CARD_LOCAL_DEV_DESCRIPTOR_PATH = '/__hb_sdk__/mini-program/workspace-cards.json';
|
|
15409
|
+
const WORKSPACE_CARD_LOCAL_DEV_MANIFEST_TOKEN_HEADER = 'x-hb-sdk-mini-program-manifest-token';
|
|
15410
|
+
|
|
15405
15411
|
const DEFAULT_APP_PORT = 5173;
|
|
15406
15412
|
const DEFAULT_BROWSER_DEV_HOST_PORT = 5174;
|
|
15407
15413
|
const DEFAULT_DEV_CONTEXT_TIMEOUT_MS = 3000;
|
|
@@ -15575,6 +15581,7 @@ async function runDevCommand(options, runtime = {}) {
|
|
|
15575
15581
|
port: appPort,
|
|
15576
15582
|
};
|
|
15577
15583
|
const projectRoot = projectVite.findProjectRoot(runtime.cwd ?? process.cwd());
|
|
15584
|
+
const workspaceCardsDeclared = runtimePermissionEnv.readMiniappWorkspaceCardsFromPackageJson(projectRoot).declaration !== undefined;
|
|
15578
15585
|
const companionArtifactAccessToken = (runtime.randomBytes ?? node_crypto.randomBytes)(32).toString('base64url');
|
|
15579
15586
|
const miniProgramManifestAccessToken = (runtime.randomBytes ?? node_crypto.randomBytes)(32).toString('base64url');
|
|
15580
15587
|
const devSessionId = node_crypto.randomBytes(16).toString('hex');
|
|
@@ -15658,7 +15665,7 @@ async function runDevCommand(options, runtime = {}) {
|
|
|
15658
15665
|
const grant = runtimePermissionEnv.createMiniProgramLocalDevGrant({ declaredPermissions: currentDevContext.declaredPermissions ?? {},
|
|
15659
15666
|
runtimePermissions: currentDevContext.runtimePermissions, revision: contextRevision,
|
|
15660
15667
|
eligiblePermissionKeys: currentCompanionManifestSha256 && runtimePermissionEnv.hasMiniappDesktopPlatform(currentDevContext.platforms)
|
|
15661
|
-
? ['network', 'companion'] : ['network'] });
|
|
15668
|
+
? ['network', 'companion', 'appProtocol'] : ['network', 'appProtocol'] });
|
|
15662
15669
|
if (allowedTemporaryKeys)
|
|
15663
15670
|
grant.entries = grant.entries.filter(entry => allowedTemporaryKeys.has(entry.key));
|
|
15664
15671
|
const temporaryWarning = grant.entries.map(entry => entry.key).join('、');
|
|
@@ -15700,6 +15707,42 @@ async function runDevCommand(options, runtime = {}) {
|
|
|
15700
15707
|
readContextPath: () => devContextPath,
|
|
15701
15708
|
});
|
|
15702
15709
|
const launchPlugin = createMiniProgramDevLaunchVitePlugin(readLaunchSource, async (request, response) => {
|
|
15710
|
+
if (request.url === WORKSPACE_CARD_LOCAL_DEV_DESCRIPTOR_PATH) {
|
|
15711
|
+
response.setHeader('Cache-Control', 'no-store');
|
|
15712
|
+
response.setHeader('X-Content-Type-Options', 'nosniff');
|
|
15713
|
+
if (request.method !== 'GET' && request.method !== 'HEAD') {
|
|
15714
|
+
response.writeHead(405, { Allow: 'GET, HEAD' }).end();
|
|
15715
|
+
return true;
|
|
15716
|
+
}
|
|
15717
|
+
const remote = request.socket.remoteAddress;
|
|
15718
|
+
const host = request.headers.host ?? '';
|
|
15719
|
+
const token = request.headers[WORKSPACE_CARD_LOCAL_DEV_MANIFEST_TOKEN_HEADER];
|
|
15720
|
+
const candidate = Buffer.alloc(43);
|
|
15721
|
+
if (typeof token === 'string')
|
|
15722
|
+
Buffer.from(token).copy(candidate, 0, 0, candidate.length);
|
|
15723
|
+
const tokenMatches = node_crypto.timingSafeEqual(candidate, Buffer.from(miniProgramManifestAccessToken));
|
|
15724
|
+
if (!tokenMatches || typeof token !== 'string' || !/^[A-Za-z0-9_-]{43}$/.test(token) ||
|
|
15725
|
+
!['127.0.0.1', '::1', '::ffff:127.0.0.1'].includes(remote ?? '') ||
|
|
15726
|
+
!/^127\.0\.0\.1:\d{1,5}$/.test(host)) {
|
|
15727
|
+
response.writeHead(403).end();
|
|
15728
|
+
return true;
|
|
15729
|
+
}
|
|
15730
|
+
const source = readLaunchSource();
|
|
15731
|
+
if (!source.miniProgramId || !source.localDevLaunchToken || !source.devSessionId || !source.expiresAt) {
|
|
15732
|
+
response.writeHead(503).end();
|
|
15733
|
+
return true;
|
|
15734
|
+
}
|
|
15735
|
+
const body = JSON.stringify({
|
|
15736
|
+
schema_version: 1,
|
|
15737
|
+
mini_program_id: source.miniProgramId,
|
|
15738
|
+
local_dev_launch_token: source.localDevLaunchToken,
|
|
15739
|
+
dev_session_id: source.devSessionId,
|
|
15740
|
+
expires_at_ms: source.expiresAt,
|
|
15741
|
+
});
|
|
15742
|
+
response.writeHead(200, { 'Content-Type': 'application/json; charset=utf-8', 'Content-Length': Buffer.byteLength(body) });
|
|
15743
|
+
response.end(request.method === 'HEAD' ? undefined : body);
|
|
15744
|
+
return true;
|
|
15745
|
+
}
|
|
15703
15746
|
if (await networkProxy.handle(request, response))
|
|
15704
15747
|
return true;
|
|
15705
15748
|
if (request.url !== MINI_PROGRAM_DEV_LAUNCH_PATH || request.headers[COMPANION_ARTIFACT_ACCESS_TOKEN_HEADER] === undefined)
|
|
@@ -15766,8 +15809,9 @@ async function runDevCommand(options, runtime = {}) {
|
|
|
15766
15809
|
let browserDevHost;
|
|
15767
15810
|
try {
|
|
15768
15811
|
browserDevHost = await runDevStartupTask(logger, '正在启动浏览器调试页服务', () => startBrowserDevHostServer({
|
|
15769
|
-
openPlatformBaseUrl:
|
|
15812
|
+
openPlatformBaseUrl: index.resolveHeyboxOpenPlatformBaseUrl(runtime.env),
|
|
15770
15813
|
appUrl,
|
|
15814
|
+
devSessionId,
|
|
15771
15815
|
devContext: currentDevContext,
|
|
15772
15816
|
fetchImpl,
|
|
15773
15817
|
getPort: getPortImpl,
|
|
@@ -15779,6 +15823,7 @@ async function runDevCommand(options, runtime = {}) {
|
|
|
15779
15823
|
miniProgram,
|
|
15780
15824
|
// 只在项目声明了桌面平台时向调试台暴露「在桌面端打开」入口。
|
|
15781
15825
|
miniProgramSupportsDesktop: runtimePermissionEnv.hasMiniappDesktopPlatform(miniProgramPlatforms),
|
|
15826
|
+
workspaceCardsEnabled: workspaceCardsDeclared,
|
|
15782
15827
|
cliAuth: runtime.cliAuth ?? createBrowserDevHostCliAuth({ env: runtime.env, fetchImpl }),
|
|
15783
15828
|
onMobileDevSessionCreated: ({ devContextUrl, miniUrlOrigin }) => {
|
|
15784
15829
|
mobileDevContextUrlsByOrigin.set(miniUrlOrigin, devContextUrl);
|
|
@@ -15989,7 +16034,7 @@ async function loadDevLaunchContext(options) {
|
|
|
15989
16034
|
const anonymous = (warning) => ({ context: { source: 'anonymous', warning,
|
|
15990
16035
|
declaredPermissions: localPermissions.permissions ?? {}, platforms,
|
|
15991
16036
|
runtimePermissions: runtimePermissionEnv.composeMiniappRuntimePermissions(localPermissions, undefined).runtimePermissions }, miniProgram: null });
|
|
15992
|
-
if (!(await
|
|
16037
|
+
if (!(await index.readHeyboxAuthSession({ env: options.env })))
|
|
15993
16038
|
return anonymous('尚未登录 CLI,真实手机和 PC 调试不可用');
|
|
15994
16039
|
const miniProgramId = await context.readBoundMiniProgramId(options.projectRoot);
|
|
15995
16040
|
if (!miniProgramId)
|
|
@@ -16012,7 +16057,7 @@ async function loadDevLaunchContext(options) {
|
|
|
16012
16057
|
options.logger.info('已迁移当前正式发布名称与图片,继续启动开发环境');
|
|
16013
16058
|
if (!runtimePermissionEnv.parseMiniProgramRuntimePermissions(detail.runtime_permissions).valid)
|
|
16014
16059
|
return anonymous('线上权限快照无效,真实手机和 PC 调试不可用');
|
|
16015
|
-
const effectivePermissions = runtimePermissionEnv.composeMiniappRuntimePermissions(localPermissions, detail.runtime_permissions).runtimePermissions;
|
|
16060
|
+
const effectivePermissions = runtimePermissionEnv.composeMiniappRuntimePermissions(localPermissions, detail.runtime_permissions, detail.party_type).runtimePermissions;
|
|
16016
16061
|
return {
|
|
16017
16062
|
context: {
|
|
16018
16063
|
source: 'remote',
|
|
@@ -3,19 +3,22 @@
|
|
|
3
3
|
var fs = require('node:fs/promises');
|
|
4
4
|
var os = require('node:os');
|
|
5
5
|
var path = require('node:path');
|
|
6
|
-
var index = require('./index-
|
|
6
|
+
var index = require('./index-BWRDIX1T.cjs');
|
|
7
7
|
require('node:module');
|
|
8
|
-
require('node:fs');
|
|
9
|
-
require('path');
|
|
10
|
-
require('os');
|
|
11
|
-
require('node:crypto');
|
|
12
8
|
require('readline');
|
|
9
|
+
require('os');
|
|
13
10
|
require('tty');
|
|
14
11
|
require('assert');
|
|
15
12
|
require('events');
|
|
16
13
|
require('stream');
|
|
17
14
|
require('buffer');
|
|
18
15
|
require('util');
|
|
16
|
+
require('node:crypto');
|
|
17
|
+
require('path');
|
|
18
|
+
require('fs');
|
|
19
|
+
require('constants');
|
|
20
|
+
require('node:fs');
|
|
21
|
+
require('node:zlib');
|
|
19
22
|
|
|
20
23
|
const CANDIDATES = [
|
|
21
24
|
path.resolve(__dirname, '..', 'package.json'),
|