@teambit/workspace 1.0.974 → 1.0.976
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/dist/{preview-1778178157117.js → preview-1778254115658.js} +2 -2
- package/dist/scope-trust/index.d.ts +2 -0
- package/dist/scope-trust/index.js +33 -0
- package/dist/scope-trust/index.js.map +1 -0
- package/dist/scope-trust/scope-trust.cmd.d.ts +18 -0
- package/dist/scope-trust/scope-trust.cmd.js +109 -0
- package/dist/scope-trust/scope-trust.cmd.js.map +1 -0
- package/dist/scope-trust/scope-trust.d.ts +93 -0
- package/dist/scope-trust/scope-trust.js +262 -0
- package/dist/scope-trust/scope-trust.js.map +1 -0
- package/dist/types.d.ts +10 -0
- package/dist/types.js.map +1 -1
- package/dist/workspace-aspects-loader.js +4 -0
- package/dist/workspace-aspects-loader.js.map +1 -1
- package/dist/workspace.main.runtime.js +13 -0
- package/dist/workspace.main.runtime.js.map +1 -1
- package/package.json +38 -37
- package/scope-trust/index.ts +2 -0
- package/scope-trust/scope-trust.cmd.ts +111 -0
- package/scope-trust/scope-trust.ts +260 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.workspace_workspace@1.0.
|
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.workspace_workspace@1.0.
|
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.workspace_workspace@1.0.976/dist/workspace.composition.js';
|
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.workspace_workspace@1.0.976/dist/workspace.docs.mdx';
|
|
3
3
|
|
|
4
4
|
export const compositions = [compositions_0];
|
|
5
5
|
export const overview = [overview_0];
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "ScopeTrust", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _scopeTrust().ScopeTrust;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "ScopeTrustCmd", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _scopeTrust2().ScopeTrustCmd;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
function _scopeTrust() {
|
|
19
|
+
const data = require("./scope-trust");
|
|
20
|
+
_scopeTrust = function () {
|
|
21
|
+
return data;
|
|
22
|
+
};
|
|
23
|
+
return data;
|
|
24
|
+
}
|
|
25
|
+
function _scopeTrust2() {
|
|
26
|
+
const data = require("./scope-trust.cmd");
|
|
27
|
+
_scopeTrust2 = function () {
|
|
28
|
+
return data;
|
|
29
|
+
};
|
|
30
|
+
return data;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_scopeTrust","data","require","_scopeTrust2"],"sources":["index.ts"],"sourcesContent":["export { ScopeTrust } from './scope-trust';\nexport { ScopeTrustCmd } from './scope-trust.cmd';\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,SAAAA,YAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,WAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,aAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,YAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA","ignoreList":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Command } from '@teambit/cli';
|
|
2
|
+
import type { ScopeTrust } from './scope-trust';
|
|
3
|
+
export declare class ScopeTrustCmd implements Command {
|
|
4
|
+
private scopeTrust;
|
|
5
|
+
name: string;
|
|
6
|
+
description: string;
|
|
7
|
+
arguments: {
|
|
8
|
+
name: string;
|
|
9
|
+
description: string;
|
|
10
|
+
}[];
|
|
11
|
+
options: never[];
|
|
12
|
+
group: string;
|
|
13
|
+
loadAspects: boolean;
|
|
14
|
+
extendedDescription: string;
|
|
15
|
+
constructor(scopeTrust: ScopeTrust);
|
|
16
|
+
report(args: string[]): Promise<string>;
|
|
17
|
+
private formatList;
|
|
18
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ScopeTrustCmd = void 0;
|
|
7
|
+
function _cli() {
|
|
8
|
+
const data = require("@teambit/cli");
|
|
9
|
+
_cli = function () {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
function _bitError() {
|
|
15
|
+
const data = require("@teambit/bit-error");
|
|
16
|
+
_bitError = function () {
|
|
17
|
+
return data;
|
|
18
|
+
};
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
function _chalk() {
|
|
22
|
+
const data = _interopRequireDefault(require("chalk"));
|
|
23
|
+
_chalk = function () {
|
|
24
|
+
return data;
|
|
25
|
+
};
|
|
26
|
+
return data;
|
|
27
|
+
}
|
|
28
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
29
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
30
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
31
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
32
|
+
const ACTIONS = ['list', 'enable', 'disable', 'add', 'remove'];
|
|
33
|
+
class ScopeTrustCmd {
|
|
34
|
+
constructor(scopeTrust) {
|
|
35
|
+
this.scopeTrust = scopeTrust;
|
|
36
|
+
_defineProperty(this, "name", 'trust [action] [pattern]');
|
|
37
|
+
_defineProperty(this, "description", "manage which scopes are trusted to load aspects (envs, etc.) into the workspace's process");
|
|
38
|
+
_defineProperty(this, "arguments", [{
|
|
39
|
+
name: 'action',
|
|
40
|
+
description: `one of: ${ACTIONS.join(', ')}. defaults to "list".`
|
|
41
|
+
}, {
|
|
42
|
+
name: 'pattern',
|
|
43
|
+
description: 'scope pattern (required for "add" and "remove")'
|
|
44
|
+
}]);
|
|
45
|
+
_defineProperty(this, "options", []);
|
|
46
|
+
_defineProperty(this, "group", 'component-config');
|
|
47
|
+
// Don't load aspects for this command. If the workspace already references
|
|
48
|
+
// an aspect from a scope that the trust list doesn't allow, the pre-command
|
|
49
|
+
// aspect-load step would itself trip the gate, leaving the user with no way
|
|
50
|
+
// to run `bit scope trust` to fix it. Skipping aspect-load keeps the command
|
|
51
|
+
// usable as a recovery path.
|
|
52
|
+
_defineProperty(this, "loadAspects", false);
|
|
53
|
+
_defineProperty(this, "extendedDescription", `scope-trust is opt-in. when off (the default), aspects from any scope load without a check. when on, aspects from a scope outside the trust list trigger a prompt (interactive shells) or an error (non-interactive).
|
|
54
|
+
|
|
55
|
+
bit scope trust # same as "list"
|
|
56
|
+
bit scope trust list # show status; if on, print the effective trust list
|
|
57
|
+
bit scope trust enable # turn on (writes "trustedScopes": [] to workspace.jsonc)
|
|
58
|
+
bit scope trust disable # turn off (removes "trustedScopes" from workspace.jsonc)
|
|
59
|
+
bit scope trust add PATTERN # add a pattern (auto-enables if needed)
|
|
60
|
+
bit scope trust remove PATTERN # remove a pattern (does NOT disable when list is empty)
|
|
61
|
+
|
|
62
|
+
once on, the effective trust set is: builtin scopes (teambit.*, bitdev.*, and a few others — run "bit scope trust list" to see) + the owner of defaultScope + entries listed under "trustedScopes". patterns are exact ("acme.frontend") or owner wildcard ("acme.*").`);
|
|
63
|
+
}
|
|
64
|
+
async report(args) {
|
|
65
|
+
const [rawAction, pattern] = args;
|
|
66
|
+
const action = rawAction || 'list';
|
|
67
|
+
if (!ACTIONS.includes(action)) {
|
|
68
|
+
throw new (_bitError().BitError)(`unknown action "${rawAction}". valid actions: ${ACTIONS.join(', ')}.`);
|
|
69
|
+
}
|
|
70
|
+
switch (action) {
|
|
71
|
+
case 'list':
|
|
72
|
+
return this.formatList();
|
|
73
|
+
case 'enable':
|
|
74
|
+
await this.scopeTrust.enable();
|
|
75
|
+
return (0, _cli().formatSuccessSummary)('scope-trust enabled (added trustedScopes: [] to workspace.jsonc)');
|
|
76
|
+
case 'disable':
|
|
77
|
+
await this.scopeTrust.disable();
|
|
78
|
+
return (0, _cli().formatSuccessSummary)('scope-trust disabled (removed trustedScopes from workspace.jsonc)');
|
|
79
|
+
case 'add':
|
|
80
|
+
{
|
|
81
|
+
const p = requirePattern(action, pattern);
|
|
82
|
+
await this.scopeTrust.addTrustedScope(p);
|
|
83
|
+
return (0, _cli().formatSuccessSummary)(`added ${_chalk().default.bold(p)} to trustedScopes in workspace.jsonc`);
|
|
84
|
+
}
|
|
85
|
+
case 'remove':
|
|
86
|
+
{
|
|
87
|
+
const p = requirePattern(action, pattern);
|
|
88
|
+
await this.scopeTrust.removeTrustedScope(p);
|
|
89
|
+
return (0, _cli().formatSuccessSummary)(`removed ${_chalk().default.bold(p)} from trustedScopes in workspace.jsonc`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
formatList() {
|
|
94
|
+
if (!this.scopeTrust.isOptedIn()) {
|
|
95
|
+
return (0, _cli().joinSections)([(0, _cli().formatTitle)('scope-trust is off for this workspace.'), 'aspects from any scope load without a check.', (0, _cli().formatHint)('to turn on:\n bit scope trust enable (no scopes added; only builtins + owner-of-defaultScope auto-trusted)\n bit scope trust add <pattern> (turns on and adds the first scope)')]);
|
|
96
|
+
}
|
|
97
|
+
const groups = this.scopeTrust.getEffectiveTrustedPatterns();
|
|
98
|
+
return (0, _cli().joinSections)([(0, _cli().formatTitle)('scope-trust is on. aspects from these scopes load without a prompt:'), (0, _cli().formatSection)('builtin', '', groups.builtin.map(p => (0, _cli().formatItem)(p))), (0, _cli().formatSection)('inferred from workspace defaultScope', '', groups.owner.map(p => (0, _cli().formatItem)(p))), groups.configured.length ? (0, _cli().formatSection)('configured in workspace.jsonc', '', groups.configured.map(p => (0, _cli().formatItem)(p))) : (0, _cli().formatHint)('no scopes configured in workspace.jsonc. add one with `bit scope trust add <pattern>`.')]);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
exports.ScopeTrustCmd = ScopeTrustCmd;
|
|
102
|
+
function requirePattern(action, pattern) {
|
|
103
|
+
if (!pattern) {
|
|
104
|
+
throw new (_bitError().BitError)(`"${action}" requires a pattern. example: bit scope trust ${action} acme.frontend`);
|
|
105
|
+
}
|
|
106
|
+
return pattern;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
//# sourceMappingURL=scope-trust.cmd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_cli","data","require","_bitError","_chalk","_interopRequireDefault","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","ACTIONS","ScopeTrustCmd","constructor","scopeTrust","name","description","join","report","args","rawAction","pattern","action","includes","BitError","formatList","enable","formatSuccessSummary","disable","p","requirePattern","addTrustedScope","chalk","bold","removeTrustedScope","isOptedIn","joinSections","formatTitle","formatHint","groups","getEffectiveTrustedPatterns","formatSection","builtin","map","formatItem","owner","configured","length","exports"],"sources":["scope-trust.cmd.ts"],"sourcesContent":["import type { Command } from '@teambit/cli';\nimport { formatHint, formatItem, formatSection, formatSuccessSummary, formatTitle, joinSections } from '@teambit/cli';\nimport { BitError } from '@teambit/bit-error';\nimport chalk from 'chalk';\nimport type { ScopeTrust } from './scope-trust';\n\nconst ACTIONS = ['list', 'enable', 'disable', 'add', 'remove'] as const;\ntype Action = (typeof ACTIONS)[number];\n\nexport class ScopeTrustCmd implements Command {\n name = 'trust [action] [pattern]';\n description = \"manage which scopes are trusted to load aspects (envs, etc.) into the workspace's process\";\n arguments = [\n {\n name: 'action',\n description: `one of: ${ACTIONS.join(', ')}. defaults to \"list\".`,\n },\n {\n name: 'pattern',\n description: 'scope pattern (required for \"add\" and \"remove\")',\n },\n ];\n options = [];\n group = 'component-config';\n // Don't load aspects for this command. If the workspace already references\n // an aspect from a scope that the trust list doesn't allow, the pre-command\n // aspect-load step would itself trip the gate, leaving the user with no way\n // to run `bit scope trust` to fix it. Skipping aspect-load keeps the command\n // usable as a recovery path.\n loadAspects = false;\n extendedDescription = `scope-trust is opt-in. when off (the default), aspects from any scope load without a check. when on, aspects from a scope outside the trust list trigger a prompt (interactive shells) or an error (non-interactive).\n\n bit scope trust # same as \"list\"\n bit scope trust list # show status; if on, print the effective trust list\n bit scope trust enable # turn on (writes \"trustedScopes\": [] to workspace.jsonc)\n bit scope trust disable # turn off (removes \"trustedScopes\" from workspace.jsonc)\n bit scope trust add PATTERN # add a pattern (auto-enables if needed)\n bit scope trust remove PATTERN # remove a pattern (does NOT disable when list is empty)\n\nonce on, the effective trust set is: builtin scopes (teambit.*, bitdev.*, and a few others — run \"bit scope trust list\" to see) + the owner of defaultScope + entries listed under \"trustedScopes\". patterns are exact (\"acme.frontend\") or owner wildcard (\"acme.*\").`;\n\n constructor(private scopeTrust: ScopeTrust) {}\n\n async report(args: string[]): Promise<string> {\n const [rawAction, pattern] = args;\n const action = (rawAction || 'list') as Action;\n if (!ACTIONS.includes(action)) {\n throw new BitError(`unknown action \"${rawAction}\". valid actions: ${ACTIONS.join(', ')}.`);\n }\n switch (action) {\n case 'list':\n return this.formatList();\n case 'enable':\n await this.scopeTrust.enable();\n return formatSuccessSummary('scope-trust enabled (added trustedScopes: [] to workspace.jsonc)');\n case 'disable':\n await this.scopeTrust.disable();\n return formatSuccessSummary('scope-trust disabled (removed trustedScopes from workspace.jsonc)');\n case 'add': {\n const p = requirePattern(action, pattern);\n await this.scopeTrust.addTrustedScope(p);\n return formatSuccessSummary(`added ${chalk.bold(p)} to trustedScopes in workspace.jsonc`);\n }\n case 'remove': {\n const p = requirePattern(action, pattern);\n await this.scopeTrust.removeTrustedScope(p);\n return formatSuccessSummary(`removed ${chalk.bold(p)} from trustedScopes in workspace.jsonc`);\n }\n }\n }\n\n private formatList(): string {\n if (!this.scopeTrust.isOptedIn()) {\n return joinSections([\n formatTitle('scope-trust is off for this workspace.'),\n 'aspects from any scope load without a check.',\n formatHint(\n 'to turn on:\\n bit scope trust enable (no scopes added; only builtins + owner-of-defaultScope auto-trusted)\\n bit scope trust add <pattern> (turns on and adds the first scope)'\n ),\n ]);\n }\n const groups = this.scopeTrust.getEffectiveTrustedPatterns();\n return joinSections([\n formatTitle('scope-trust is on. aspects from these scopes load without a prompt:'),\n formatSection(\n 'builtin',\n '',\n groups.builtin.map((p) => formatItem(p))\n ),\n formatSection(\n 'inferred from workspace defaultScope',\n '',\n groups.owner.map((p) => formatItem(p))\n ),\n groups.configured.length\n ? formatSection(\n 'configured in workspace.jsonc',\n '',\n groups.configured.map((p) => formatItem(p))\n )\n : formatHint('no scopes configured in workspace.jsonc. add one with `bit scope trust add <pattern>`.'),\n ]);\n }\n}\n\nfunction requirePattern(action: Action, pattern: string | undefined): string {\n if (!pattern) {\n throw new BitError(`\"${action}\" requires a pattern. example: bit scope trust ${action} acme.frontend`);\n }\n return pattern;\n}\n"],"mappings":";;;;;;AACA,SAAAA,KAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,IAAA,YAAAA,CAAA;IAAA,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ACH,GAAG,CAAEd,CAAC,IAAK,IAAAe,iBAAU,EAACf,CAAC,CAAC,CAC5C,CAAC,GACD,IAAAS,iBAAU,EAAC,wFAAwF,CAAC,CACzG,CAAC;EACJ;AACF;AAACU,OAAA,CAAApC,aAAA,GAAAA,aAAA;AAED,SAASkB,cAAcA,CAACR,MAAc,EAAED,OAA2B,EAAU;EAC3E,IAAI,CAACA,OAAO,EAAE;IACZ,MAAM,KAAIG,oBAAQ,EAAC,IAAIF,MAAM,kDAAkDA,MAAM,gBAAgB,CAAC;EACxG;EACA,OAAOD,OAAO;AAChB","ignoreList":[]}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { ComponentID } from '@teambit/component-id';
|
|
2
|
+
import type { Logger } from '@teambit/logger';
|
|
3
|
+
import type { Workspace } from '../workspace';
|
|
4
|
+
export type TrustedScopesGroups = {
|
|
5
|
+
/** patterns built into Bit (e.g. `teambit.*`, `bitdev.*`) */
|
|
6
|
+
builtin: string[];
|
|
7
|
+
/** owner wildcard inferred from `defaultScope` (e.g. `acme.frontend` → `acme.*`) */
|
|
8
|
+
owner: string[];
|
|
9
|
+
/** patterns explicitly configured in `workspace.jsonc` under `trustedScopes` */
|
|
10
|
+
configured: string[];
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Workspace-level scope-trust policy. Opt-in: when the `trustedScopes` key is
|
|
14
|
+
* present in workspace.jsonc (even as an empty array), the aspect-load gate
|
|
15
|
+
* is active. When the key is absent, no gate runs and any aspect loads.
|
|
16
|
+
*
|
|
17
|
+
* Once opted in, a scope is trusted if it matches any pattern in:
|
|
18
|
+
* - the builtin set (e.g. `teambit.*`, `bitdev.*`; see `BUILTIN_TRUSTED_PATTERNS`),
|
|
19
|
+
* - the pattern derived from the workspace's `defaultScope`
|
|
20
|
+
* (e.g. `acme.frontend` → `acme.*`; legacy dotless `my-scope` → `my-scope`),
|
|
21
|
+
* - the `trustedScopes` array configured in workspace.jsonc.
|
|
22
|
+
*
|
|
23
|
+
* Patterns are exact (`acme.frontend`) or owner wildcard (`acme.*`).
|
|
24
|
+
*
|
|
25
|
+
* Wired into `ScopeMain` via `setAspectLoadGuard`; the guard runs in the
|
|
26
|
+
* aspect-loader path so untrusted aspects never reach `require()`.
|
|
27
|
+
*/
|
|
28
|
+
export declare class ScopeTrust {
|
|
29
|
+
private workspace;
|
|
30
|
+
private logger;
|
|
31
|
+
private deniedThisRun;
|
|
32
|
+
constructor(workspace: Workspace, logger: Logger);
|
|
33
|
+
/**
|
|
34
|
+
* `true` when the workspace has opted in (the `trustedScopes` key is present
|
|
35
|
+
* in workspace.jsonc, even as an empty array). When `false`, the aspect-load
|
|
36
|
+
* gate is a no-op.
|
|
37
|
+
*/
|
|
38
|
+
isOptedIn(): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Effective trust list, broken down by source. Useful for both internal
|
|
41
|
+
* checks and the `bit scope trust list` UX.
|
|
42
|
+
*/
|
|
43
|
+
getEffectiveTrustedPatterns(): TrustedScopesGroups;
|
|
44
|
+
/**
|
|
45
|
+
* True iff `scopeName` matches any pattern in the effective trust list.
|
|
46
|
+
* `scopeName` is expected to be the bare scope (e.g. `acme.frontend`).
|
|
47
|
+
*/
|
|
48
|
+
isScopeTrusted(scopeName: string): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Pattern matcher. Two forms:
|
|
51
|
+
* - exact: `acme.frontend` matches only `acme.frontend`.
|
|
52
|
+
* - owner wildcard: `acme.*` matches `acme.<anything>`.
|
|
53
|
+
*/
|
|
54
|
+
static matchesPattern(scopeName: string, pattern: string): boolean;
|
|
55
|
+
/** Opt the workspace in by writing `trustedScopes: []` (idempotent). */
|
|
56
|
+
enable(): Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Opt the workspace out by removing the `trustedScopes` key (idempotent).
|
|
59
|
+
* Uses `overrideExisting` because key deletion isn't expressible via
|
|
60
|
+
* `mergeIntoExisting`; comments on other keys may be reformatted as a result.
|
|
61
|
+
*/
|
|
62
|
+
disable(): Promise<void>;
|
|
63
|
+
/** Add `pattern` to `trustedScopes` (auto-enables if not yet). */
|
|
64
|
+
addTrustedScope(pattern: string): Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* Remove `pattern` from `trustedScopes`. Leaves the key in place even if
|
|
67
|
+
* the list becomes empty — use `disable()` to fully turn the gate off.
|
|
68
|
+
*/
|
|
69
|
+
removeTrustedScope(pattern: string): Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* Build the aspect-load guard. No-op when not opted in. When opted in:
|
|
72
|
+
* untrusted scopes get a TTY prompt to extend the trust list, or in
|
|
73
|
+
* non-TTY contexts an instructional error.
|
|
74
|
+
*/
|
|
75
|
+
createGuard(): (componentId: ComponentID) => Promise<void>;
|
|
76
|
+
private readExt;
|
|
77
|
+
/**
|
|
78
|
+
* Apply `mutator` to the current `trustedScopes` list. If the mutator
|
|
79
|
+
* returns `null`, treat the call as a no-op (idempotent fast path).
|
|
80
|
+
* Uses `mergeIntoExisting` so other keys' comments are preserved.
|
|
81
|
+
*/
|
|
82
|
+
private mutateConfiguredList;
|
|
83
|
+
private writeExtPatch;
|
|
84
|
+
/**
|
|
85
|
+
* Returns the trust pattern derived from the workspace's `defaultScope`:
|
|
86
|
+
* - `acme.frontend` → `acme.*` (owner wildcard)
|
|
87
|
+
* - `my-scope` (legacy dotless) → `my-scope` (exact match)
|
|
88
|
+
* - empty / unset → undefined
|
|
89
|
+
*/
|
|
90
|
+
private getInferredOwnerPattern;
|
|
91
|
+
private promptForTrust;
|
|
92
|
+
static isValidPattern(pattern: string): boolean;
|
|
93
|
+
}
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ScopeTrust = void 0;
|
|
7
|
+
function _bitError() {
|
|
8
|
+
const data = require("@teambit/bit-error");
|
|
9
|
+
_bitError = function () {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
function _legacyBitId() {
|
|
15
|
+
const data = require("@teambit/legacy-bit-id");
|
|
16
|
+
_legacyBitId = function () {
|
|
17
|
+
return data;
|
|
18
|
+
};
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
function _enquirer() {
|
|
22
|
+
const data = require("enquirer");
|
|
23
|
+
_enquirer = function () {
|
|
24
|
+
return data;
|
|
25
|
+
};
|
|
26
|
+
return data;
|
|
27
|
+
}
|
|
28
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
29
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
30
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
31
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
32
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
33
|
+
const BUILTIN_TRUSTED_PATTERNS = ['teambit.*', 'bitdev.*', 'learn-bit-react.*', 'bitdesign.*', 'frontend.*'];
|
|
34
|
+
const WORKSPACE_ASPECT_ID = 'teambit.workspace/workspace';
|
|
35
|
+
const TRUSTED_SCOPES_KEY = 'trustedScopes';
|
|
36
|
+
/**
|
|
37
|
+
* Workspace-level scope-trust policy. Opt-in: when the `trustedScopes` key is
|
|
38
|
+
* present in workspace.jsonc (even as an empty array), the aspect-load gate
|
|
39
|
+
* is active. When the key is absent, no gate runs and any aspect loads.
|
|
40
|
+
*
|
|
41
|
+
* Once opted in, a scope is trusted if it matches any pattern in:
|
|
42
|
+
* - the builtin set (e.g. `teambit.*`, `bitdev.*`; see `BUILTIN_TRUSTED_PATTERNS`),
|
|
43
|
+
* - the pattern derived from the workspace's `defaultScope`
|
|
44
|
+
* (e.g. `acme.frontend` → `acme.*`; legacy dotless `my-scope` → `my-scope`),
|
|
45
|
+
* - the `trustedScopes` array configured in workspace.jsonc.
|
|
46
|
+
*
|
|
47
|
+
* Patterns are exact (`acme.frontend`) or owner wildcard (`acme.*`).
|
|
48
|
+
*
|
|
49
|
+
* Wired into `ScopeMain` via `setAspectLoadGuard`; the guard runs in the
|
|
50
|
+
* aspect-loader path so untrusted aspects never reach `require()`.
|
|
51
|
+
*/
|
|
52
|
+
class ScopeTrust {
|
|
53
|
+
constructor(workspace, logger) {
|
|
54
|
+
this.workspace = workspace;
|
|
55
|
+
this.logger = logger;
|
|
56
|
+
_defineProperty(this, "deniedThisRun", new Set());
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* `true` when the workspace has opted in (the `trustedScopes` key is present
|
|
61
|
+
* in workspace.jsonc, even as an empty array). When `false`, the aspect-load
|
|
62
|
+
* gate is a no-op.
|
|
63
|
+
*/
|
|
64
|
+
isOptedIn() {
|
|
65
|
+
return Object.prototype.hasOwnProperty.call(this.readExt(), TRUSTED_SCOPES_KEY);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Effective trust list, broken down by source. Useful for both internal
|
|
70
|
+
* checks and the `bit scope trust list` UX.
|
|
71
|
+
*/
|
|
72
|
+
getEffectiveTrustedPatterns() {
|
|
73
|
+
const ext = this.readExt();
|
|
74
|
+
const configured = Array.isArray(ext[TRUSTED_SCOPES_KEY]) ? ext[TRUSTED_SCOPES_KEY].slice() : [];
|
|
75
|
+
const owner = this.getInferredOwnerPattern();
|
|
76
|
+
return {
|
|
77
|
+
builtin: BUILTIN_TRUSTED_PATTERNS.slice(),
|
|
78
|
+
owner: owner ? [owner] : [],
|
|
79
|
+
configured
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* True iff `scopeName` matches any pattern in the effective trust list.
|
|
85
|
+
* `scopeName` is expected to be the bare scope (e.g. `acme.frontend`).
|
|
86
|
+
*/
|
|
87
|
+
isScopeTrusted(scopeName) {
|
|
88
|
+
if (!scopeName) return false;
|
|
89
|
+
const groups = this.getEffectiveTrustedPatterns();
|
|
90
|
+
const all = [...groups.builtin, ...groups.owner, ...groups.configured];
|
|
91
|
+
return all.some(pattern => ScopeTrust.matchesPattern(scopeName, pattern));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Pattern matcher. Two forms:
|
|
96
|
+
* - exact: `acme.frontend` matches only `acme.frontend`.
|
|
97
|
+
* - owner wildcard: `acme.*` matches `acme.<anything>`.
|
|
98
|
+
*/
|
|
99
|
+
static matchesPattern(scopeName, pattern) {
|
|
100
|
+
if (pattern === scopeName) return true;
|
|
101
|
+
if (pattern.endsWith('.*')) {
|
|
102
|
+
const owner = pattern.slice(0, -2);
|
|
103
|
+
return scopeName.startsWith(`${owner}.`);
|
|
104
|
+
}
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** Opt the workspace in by writing `trustedScopes: []` (idempotent). */
|
|
109
|
+
async enable() {
|
|
110
|
+
if (this.isOptedIn()) return;
|
|
111
|
+
await this.writeExtPatch({
|
|
112
|
+
[TRUSTED_SCOPES_KEY]: []
|
|
113
|
+
}, 'enable scope-trust');
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Opt the workspace out by removing the `trustedScopes` key (idempotent).
|
|
118
|
+
* Uses `overrideExisting` because key deletion isn't expressible via
|
|
119
|
+
* `mergeIntoExisting`; comments on other keys may be reformatted as a result.
|
|
120
|
+
*/
|
|
121
|
+
async disable() {
|
|
122
|
+
if (!this.isOptedIn()) return;
|
|
123
|
+
const updated = _objectSpread({}, this.readExt());
|
|
124
|
+
delete updated[TRUSTED_SCOPES_KEY];
|
|
125
|
+
const wsConfig = this.workspace.getWorkspaceConfig();
|
|
126
|
+
wsConfig.setExtension(WORKSPACE_ASPECT_ID, updated, {
|
|
127
|
+
overrideExisting: true,
|
|
128
|
+
ignoreVersion: true
|
|
129
|
+
});
|
|
130
|
+
await wsConfig.write({
|
|
131
|
+
reasonForChange: 'disable scope-trust'
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** Add `pattern` to `trustedScopes` (auto-enables if not yet). */
|
|
136
|
+
async addTrustedScope(pattern) {
|
|
137
|
+
if (!ScopeTrust.isValidPattern(pattern)) {
|
|
138
|
+
throw new (_bitError().BitError)(`invalid scope pattern: "${pattern}". use an exact scope name (e.g. "acme.frontend" or "my-scope") or an owner wildcard (e.g. "acme.*").`);
|
|
139
|
+
}
|
|
140
|
+
await this.mutateConfiguredList(list => list.includes(pattern) ? null : [...list, pattern], `add trusted scope ${pattern}`);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Remove `pattern` from `trustedScopes`. Leaves the key in place even if
|
|
145
|
+
* the list becomes empty — use `disable()` to fully turn the gate off.
|
|
146
|
+
*/
|
|
147
|
+
async removeTrustedScope(pattern) {
|
|
148
|
+
await this.mutateConfiguredList(list => list.includes(pattern) ? list.filter(p => p !== pattern) : null, `remove trusted scope ${pattern}`);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Build the aspect-load guard. No-op when not opted in. When opted in:
|
|
153
|
+
* untrusted scopes get a TTY prompt to extend the trust list, or in
|
|
154
|
+
* non-TTY contexts an instructional error.
|
|
155
|
+
*/
|
|
156
|
+
createGuard() {
|
|
157
|
+
return async componentId => {
|
|
158
|
+
if (!this.isOptedIn()) return;
|
|
159
|
+
const scopeName = componentId.scope;
|
|
160
|
+
if (this.isScopeTrusted(scopeName)) return;
|
|
161
|
+
const deny = () => {
|
|
162
|
+
throw makeUntrustedError(scopeName, componentId);
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
// The user's answer is persisted to workspace.jsonc on accept; remember
|
|
166
|
+
// a denial so we don't re-prompt for the same scope in this run.
|
|
167
|
+
if (this.deniedThisRun.has(scopeName)) deny();
|
|
168
|
+
const isInteractive = Boolean(process.stdin.isTTY) && Boolean(process.stdout.isTTY);
|
|
169
|
+
if (!isInteractive) deny();
|
|
170
|
+
const accepted = await this.promptForTrust(scopeName, componentId);
|
|
171
|
+
if (!accepted) {
|
|
172
|
+
this.deniedThisRun.add(scopeName);
|
|
173
|
+
deny();
|
|
174
|
+
}
|
|
175
|
+
await this.addTrustedScope(scopeName);
|
|
176
|
+
this.logger.consoleSuccess(`added "${scopeName}" to trustedScopes in workspace.jsonc`);
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
readExt() {
|
|
180
|
+
try {
|
|
181
|
+
return this.workspace.getWorkspaceConfig().extension(WORKSPACE_ASPECT_ID, true) || {};
|
|
182
|
+
} catch {
|
|
183
|
+
return {};
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Apply `mutator` to the current `trustedScopes` list. If the mutator
|
|
189
|
+
* returns `null`, treat the call as a no-op (idempotent fast path).
|
|
190
|
+
* Uses `mergeIntoExisting` so other keys' comments are preserved.
|
|
191
|
+
*/
|
|
192
|
+
async mutateConfiguredList(mutator, reason) {
|
|
193
|
+
const ext = this.readExt();
|
|
194
|
+
const current = Array.isArray(ext[TRUSTED_SCOPES_KEY]) ? ext[TRUSTED_SCOPES_KEY] : [];
|
|
195
|
+
const next = mutator(current);
|
|
196
|
+
if (next === null) return;
|
|
197
|
+
await this.writeExtPatch({
|
|
198
|
+
[TRUSTED_SCOPES_KEY]: next
|
|
199
|
+
}, reason);
|
|
200
|
+
}
|
|
201
|
+
async writeExtPatch(patch, reason) {
|
|
202
|
+
const wsConfig = this.workspace.getWorkspaceConfig();
|
|
203
|
+
wsConfig.setExtension(WORKSPACE_ASPECT_ID, patch, {
|
|
204
|
+
mergeIntoExisting: true,
|
|
205
|
+
ignoreVersion: true
|
|
206
|
+
});
|
|
207
|
+
await wsConfig.write({
|
|
208
|
+
reasonForChange: reason
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Returns the trust pattern derived from the workspace's `defaultScope`:
|
|
214
|
+
* - `acme.frontend` → `acme.*` (owner wildcard)
|
|
215
|
+
* - `my-scope` (legacy dotless) → `my-scope` (exact match)
|
|
216
|
+
* - empty / unset → undefined
|
|
217
|
+
*/
|
|
218
|
+
getInferredOwnerPattern() {
|
|
219
|
+
const defaultScope = this.workspace.defaultScope;
|
|
220
|
+
if (!defaultScope) return undefined;
|
|
221
|
+
if (!defaultScope.includes('.')) return defaultScope;
|
|
222
|
+
const owner = defaultScope.split('.')[0];
|
|
223
|
+
if (!owner) return undefined;
|
|
224
|
+
return `${owner}.*`;
|
|
225
|
+
}
|
|
226
|
+
async promptForTrust(scopeName, componentId) {
|
|
227
|
+
try {
|
|
228
|
+
const response = await (0, _enquirer().prompt)({
|
|
229
|
+
type: 'toggle',
|
|
230
|
+
name: 'trust',
|
|
231
|
+
message: `Aspect ${componentId.toString()} comes from scope "${scopeName}", which isn't on your workspace's trusted list.\n` + `Trust "${scopeName}" and add it to workspace.jsonc?`,
|
|
232
|
+
enabled: 'Yes',
|
|
233
|
+
disabled: 'No',
|
|
234
|
+
initial: false
|
|
235
|
+
// The `toggle` prompt's option type isn't exported by enquirer's main
|
|
236
|
+
// typings; cast just the literal so the rest of the call stays typed.
|
|
237
|
+
});
|
|
238
|
+
return Boolean(response.trust);
|
|
239
|
+
} catch {
|
|
240
|
+
// user cancelled the prompt (Ctrl+C etc.)
|
|
241
|
+
return false;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
static isValidPattern(pattern) {
|
|
245
|
+
if (!pattern || typeof pattern !== 'string') return false;
|
|
246
|
+
if (pattern.endsWith('.*')) {
|
|
247
|
+
const owner = pattern.slice(0, -2);
|
|
248
|
+
// wildcard must be a single owner segment ("acme.*"), not nested
|
|
249
|
+
// ("acme.frontend.*") — the matcher only consults scope owners.
|
|
250
|
+
if (owner.includes('.')) return false;
|
|
251
|
+
return (0, _legacyBitId().isValidScopeName)(owner);
|
|
252
|
+
}
|
|
253
|
+
// exact match: "acme.frontend" or dotless legacy "my-scope".
|
|
254
|
+
return (0, _legacyBitId().isValidScopeName)(pattern);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
exports.ScopeTrust = ScopeTrust;
|
|
258
|
+
function makeUntrustedError(scopeName, componentId) {
|
|
259
|
+
return new (_bitError().BitError)(`cannot load aspect ${componentId.toString()}: scope "${scopeName}" isn't on the workspace's trusted list.\n` + `\n` + `to trust this scope, run:\n` + ` bit scope trust add ${scopeName}\n` + `or add it to "trustedScopes" under "${WORKSPACE_ASPECT_ID}" in workspace.jsonc.`);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
//# sourceMappingURL=scope-trust.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_bitError","data","require","_legacyBitId","_enquirer","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","BUILTIN_TRUSTED_PATTERNS","WORKSPACE_ASPECT_ID","TRUSTED_SCOPES_KEY","ScopeTrust","constructor","workspace","logger","Set","isOptedIn","prototype","hasOwnProperty","readExt","getEffectiveTrustedPatterns","ext","configured","Array","isArray","slice","owner","getInferredOwnerPattern","builtin","isScopeTrusted","scopeName","groups","all","some","pattern","matchesPattern","endsWith","startsWith","enable","writeExtPatch","disable","updated","wsConfig","getWorkspaceConfig","setExtension","overrideExisting","ignoreVersion","write","reasonForChange","addTrustedScope","isValidPattern","BitError","mutateConfiguredList","list","includes","removeTrustedScope","p","createGuard","componentId","scope","deny","makeUntrustedError","deniedThisRun","has","isInteractive","Boolean","process","stdin","isTTY","stdout","accepted","promptForTrust","add","consoleSuccess","extension","mutator","reason","current","next","patch","mergeIntoExisting","defaultScope","undefined","split","response","prompt","type","name","message","toString","enabled","disabled","initial","trust","isValidScopeName","exports"],"sources":["scope-trust.ts"],"sourcesContent":["import type { ComponentID } from '@teambit/component-id';\nimport type { Logger } from '@teambit/logger';\nimport { BitError } from '@teambit/bit-error';\nimport { isValidScopeName } from '@teambit/legacy-bit-id';\nimport { prompt } from 'enquirer';\nimport type { Workspace } from '../workspace';\n\nconst BUILTIN_TRUSTED_PATTERNS = ['teambit.*', 'bitdev.*', 'learn-bit-react.*', 'bitdesign.*', 'frontend.*'];\n\nconst WORKSPACE_ASPECT_ID = 'teambit.workspace/workspace';\n\nconst TRUSTED_SCOPES_KEY = 'trustedScopes';\n\nexport type TrustedScopesGroups = {\n /** patterns built into Bit (e.g. `teambit.*`, `bitdev.*`) */\n builtin: string[];\n /** owner wildcard inferred from `defaultScope` (e.g. `acme.frontend` → `acme.*`) */\n owner: string[];\n /** patterns explicitly configured in `workspace.jsonc` under `trustedScopes` */\n configured: string[];\n};\n\n/**\n * Workspace-level scope-trust policy. Opt-in: when the `trustedScopes` key is\n * present in workspace.jsonc (even as an empty array), the aspect-load gate\n * is active. When the key is absent, no gate runs and any aspect loads.\n *\n * Once opted in, a scope is trusted if it matches any pattern in:\n * - the builtin set (e.g. `teambit.*`, `bitdev.*`; see `BUILTIN_TRUSTED_PATTERNS`),\n * - the pattern derived from the workspace's `defaultScope`\n * (e.g. `acme.frontend` → `acme.*`; legacy dotless `my-scope` → `my-scope`),\n * - the `trustedScopes` array configured in workspace.jsonc.\n *\n * Patterns are exact (`acme.frontend`) or owner wildcard (`acme.*`).\n *\n * Wired into `ScopeMain` via `setAspectLoadGuard`; the guard runs in the\n * aspect-loader path so untrusted aspects never reach `require()`.\n */\nexport class ScopeTrust {\n private deniedThisRun = new Set<string>();\n\n constructor(\n private workspace: Workspace,\n private logger: Logger\n ) {}\n\n /**\n * `true` when the workspace has opted in (the `trustedScopes` key is present\n * in workspace.jsonc, even as an empty array). When `false`, the aspect-load\n * gate is a no-op.\n */\n isOptedIn(): boolean {\n return Object.prototype.hasOwnProperty.call(this.readExt(), TRUSTED_SCOPES_KEY);\n }\n\n /**\n * Effective trust list, broken down by source. Useful for both internal\n * checks and the `bit scope trust list` UX.\n */\n getEffectiveTrustedPatterns(): TrustedScopesGroups {\n const ext = this.readExt();\n const configured = Array.isArray(ext[TRUSTED_SCOPES_KEY]) ? (ext[TRUSTED_SCOPES_KEY] as string[]).slice() : [];\n const owner = this.getInferredOwnerPattern();\n return {\n builtin: BUILTIN_TRUSTED_PATTERNS.slice(),\n owner: owner ? [owner] : [],\n configured,\n };\n }\n\n /**\n * True iff `scopeName` matches any pattern in the effective trust list.\n * `scopeName` is expected to be the bare scope (e.g. `acme.frontend`).\n */\n isScopeTrusted(scopeName: string): boolean {\n if (!scopeName) return false;\n const groups = this.getEffectiveTrustedPatterns();\n const all = [...groups.builtin, ...groups.owner, ...groups.configured];\n return all.some((pattern) => ScopeTrust.matchesPattern(scopeName, pattern));\n }\n\n /**\n * Pattern matcher. Two forms:\n * - exact: `acme.frontend` matches only `acme.frontend`.\n * - owner wildcard: `acme.*` matches `acme.<anything>`.\n */\n static matchesPattern(scopeName: string, pattern: string): boolean {\n if (pattern === scopeName) return true;\n if (pattern.endsWith('.*')) {\n const owner = pattern.slice(0, -2);\n return scopeName.startsWith(`${owner}.`);\n }\n return false;\n }\n\n /** Opt the workspace in by writing `trustedScopes: []` (idempotent). */\n async enable(): Promise<void> {\n if (this.isOptedIn()) return;\n await this.writeExtPatch({ [TRUSTED_SCOPES_KEY]: [] }, 'enable scope-trust');\n }\n\n /**\n * Opt the workspace out by removing the `trustedScopes` key (idempotent).\n * Uses `overrideExisting` because key deletion isn't expressible via\n * `mergeIntoExisting`; comments on other keys may be reformatted as a result.\n */\n async disable(): Promise<void> {\n if (!this.isOptedIn()) return;\n const updated = { ...this.readExt() };\n delete updated[TRUSTED_SCOPES_KEY];\n const wsConfig = this.workspace.getWorkspaceConfig();\n wsConfig.setExtension(WORKSPACE_ASPECT_ID, updated, { overrideExisting: true, ignoreVersion: true });\n await wsConfig.write({ reasonForChange: 'disable scope-trust' });\n }\n\n /** Add `pattern` to `trustedScopes` (auto-enables if not yet). */\n async addTrustedScope(pattern: string): Promise<void> {\n if (!ScopeTrust.isValidPattern(pattern)) {\n throw new BitError(\n `invalid scope pattern: \"${pattern}\". use an exact scope name (e.g. \"acme.frontend\" or \"my-scope\") or an owner wildcard (e.g. \"acme.*\").`\n );\n }\n await this.mutateConfiguredList(\n (list) => (list.includes(pattern) ? null : [...list, pattern]),\n `add trusted scope ${pattern}`\n );\n }\n\n /**\n * Remove `pattern` from `trustedScopes`. Leaves the key in place even if\n * the list becomes empty — use `disable()` to fully turn the gate off.\n */\n async removeTrustedScope(pattern: string): Promise<void> {\n await this.mutateConfiguredList(\n (list) => (list.includes(pattern) ? list.filter((p) => p !== pattern) : null),\n `remove trusted scope ${pattern}`\n );\n }\n\n /**\n * Build the aspect-load guard. No-op when not opted in. When opted in:\n * untrusted scopes get a TTY prompt to extend the trust list, or in\n * non-TTY contexts an instructional error.\n */\n createGuard(): (componentId: ComponentID) => Promise<void> {\n return async (componentId: ComponentID) => {\n if (!this.isOptedIn()) return;\n const scopeName = componentId.scope;\n if (this.isScopeTrusted(scopeName)) return;\n\n const deny = (): never => {\n throw makeUntrustedError(scopeName, componentId);\n };\n\n // The user's answer is persisted to workspace.jsonc on accept; remember\n // a denial so we don't re-prompt for the same scope in this run.\n if (this.deniedThisRun.has(scopeName)) deny();\n\n const isInteractive = Boolean(process.stdin.isTTY) && Boolean(process.stdout.isTTY);\n if (!isInteractive) deny();\n\n const accepted = await this.promptForTrust(scopeName, componentId);\n if (!accepted) {\n this.deniedThisRun.add(scopeName);\n deny();\n }\n await this.addTrustedScope(scopeName);\n this.logger.consoleSuccess(`added \"${scopeName}\" to trustedScopes in workspace.jsonc`);\n };\n }\n\n private readExt(): Record<string, unknown> {\n try {\n return (this.workspace.getWorkspaceConfig().extension(WORKSPACE_ASPECT_ID, true) || {}) as Record<\n string,\n unknown\n >;\n } catch {\n return {};\n }\n }\n\n /**\n * Apply `mutator` to the current `trustedScopes` list. If the mutator\n * returns `null`, treat the call as a no-op (idempotent fast path).\n * Uses `mergeIntoExisting` so other keys' comments are preserved.\n */\n private async mutateConfiguredList(mutator: (list: string[]) => string[] | null, reason: string): Promise<void> {\n const ext = this.readExt();\n const current: string[] = Array.isArray(ext[TRUSTED_SCOPES_KEY]) ? (ext[TRUSTED_SCOPES_KEY] as string[]) : [];\n const next = mutator(current);\n if (next === null) return;\n await this.writeExtPatch({ [TRUSTED_SCOPES_KEY]: next }, reason);\n }\n\n private async writeExtPatch(patch: Record<string, unknown>, reason: string): Promise<void> {\n const wsConfig = this.workspace.getWorkspaceConfig();\n wsConfig.setExtension(WORKSPACE_ASPECT_ID, patch, { mergeIntoExisting: true, ignoreVersion: true });\n await wsConfig.write({ reasonForChange: reason });\n }\n\n /**\n * Returns the trust pattern derived from the workspace's `defaultScope`:\n * - `acme.frontend` → `acme.*` (owner wildcard)\n * - `my-scope` (legacy dotless) → `my-scope` (exact match)\n * - empty / unset → undefined\n */\n private getInferredOwnerPattern(): string | undefined {\n const defaultScope = this.workspace.defaultScope;\n if (!defaultScope) return undefined;\n if (!defaultScope.includes('.')) return defaultScope;\n const owner = defaultScope.split('.')[0];\n if (!owner) return undefined;\n return `${owner}.*`;\n }\n\n private async promptForTrust(scopeName: string, componentId: ComponentID): Promise<boolean> {\n try {\n const response = (await prompt({\n type: 'toggle',\n name: 'trust',\n message:\n `Aspect ${componentId.toString()} comes from scope \"${scopeName}\", which isn't on your workspace's trusted list.\\n` +\n `Trust \"${scopeName}\" and add it to workspace.jsonc?`,\n enabled: 'Yes',\n disabled: 'No',\n initial: false,\n // The `toggle` prompt's option type isn't exported by enquirer's main\n // typings; cast just the literal so the rest of the call stays typed.\n } as Parameters<typeof prompt>[0])) as { trust: boolean };\n return Boolean(response.trust);\n } catch {\n // user cancelled the prompt (Ctrl+C etc.)\n return false;\n }\n }\n\n static isValidPattern(pattern: string): boolean {\n if (!pattern || typeof pattern !== 'string') return false;\n if (pattern.endsWith('.*')) {\n const owner = pattern.slice(0, -2);\n // wildcard must be a single owner segment (\"acme.*\"), not nested\n // (\"acme.frontend.*\") — the matcher only consults scope owners.\n if (owner.includes('.')) return false;\n return isValidScopeName(owner);\n }\n // exact match: \"acme.frontend\" or dotless legacy \"my-scope\".\n return isValidScopeName(pattern);\n }\n}\n\nfunction makeUntrustedError(scopeName: string, componentId: ComponentID): BitError {\n return new BitError(\n `cannot load aspect ${componentId.toString()}: scope \"${scopeName}\" isn't on the workspace's trusted list.\\n` +\n `\\n` +\n `to trust this scope, run:\\n` +\n ` bit scope trust add ${scopeName}\\n` +\n `or add it to \"trustedScopes\" under \"${WORKSPACE_ASPECT_ID}\" in workspace.jsonc.`\n );\n}\n"],"mappings":";;;;;;AAEA,SAAAA,UAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,SAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,aAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EA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E4B,WAAwB,EAAY;EACjF,OAAO,KAAIP,oBAAQ,EACjB,sBAAsBO,WAAW,CAAC+B,QAAQ,CAAC,CAAC,YAAY3D,SAAS,4CAA4C,GAC3G,IAAI,GACJ,6BAA6B,GAC7B,yBAAyBA,SAAS,IAAI,GACtC,uCAAuCrB,mBAAmB,uBAC9D,CAAC;AACH","ignoreList":[]}
|
package/dist/types.d.ts
CHANGED
|
@@ -81,6 +81,16 @@ export interface WorkspaceExtConfig {
|
|
|
81
81
|
* Example: ["oxlint.config.json", "biome.json", "*.bak"]
|
|
82
82
|
*/
|
|
83
83
|
ignoredFiles?: string[];
|
|
84
|
+
/**
|
|
85
|
+
* Scope-name patterns that the workspace trusts when loading aspects (envs,
|
|
86
|
+
* generators, etc.) imported from those scopes. The effective trust set is:
|
|
87
|
+
* a builtin set (e.g. `teambit.*`, `bitdev.*`) + the owner of `defaultScope`
|
|
88
|
+
* (e.g. `acme.frontend` → `acme.*`) + entries listed here.
|
|
89
|
+
*
|
|
90
|
+
* Patterns: exact (`acme.frontend`) or owner wildcard (`acme.*`).
|
|
91
|
+
* Manage via `bit scope trust [enable|disable|add|remove] [pattern]`.
|
|
92
|
+
*/
|
|
93
|
+
trustedScopes?: string[];
|
|
84
94
|
/**
|
|
85
95
|
* If set to `true`, Bit auto-syncs the local `.bitmap` to the latest scope HEAD versions
|
|
86
96
|
* whenever the git HEAD has moved since the last sync (sentinel-driven, runs once per
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["interface VendorConfig {\n directory: string;\n}\n\nexport interface WorkspaceExtConfig {\n /**\n * name of the workspace.\n */\n name: string;\n\n /**\n * path to icon.\n */\n icon: string;\n\n /**\n * set the default scope when there is no matching for the component in the components array.\n */\n defaultScope: string;\n\n /**\n * set the default directory when there is no matching for the component in the components array.\n */\n defaultDirectory: string;\n\n /**\n * sets the location of the root components directory.\n * The location is a relative path to the workspace root and should use linux path separators (/).\n */\n rootComponentsDirectory?: string;\n\n /**\n * set the default structure of components in your project\n */\n vendor: VendorConfig;\n\n /**\n * All component extensions applied by default on all components in the workspace (except vendor components)\n */\n extensions: { [extensionsId: string]: string };\n\n /**\n * If set to\n * `true`, it allows the workspace to resolve scope's aspects from node modules\n * installed in the workspace's `node_modules` directory. If not set or set to `false`, aspects will only be resolved\n * from the scope aspects capsule.\n */\n resolveAspectsFromNodeModules?: boolean;\n\n /**\n * If set to `true`, it allows the workspace to resolve envs from node modules\n * installed in the workspace's `node_modules` directory.\n * the envs will be resolved from the node_modules of the env's root (workspace/node_modules/.bit_roots/{envId})\n * and if not found (usually when the env was hoisted to the root node_modules) then from the node_modules of the\n * workspace.\n * If not set or set to `false`, envs will only be resolved from the scope envs capsule.\n */\n resolveEnvsFromRoots?: boolean;\n\n /**\n * If set to `true`, bit will try to load aspects dependencies automatically.\n * even if the aspects dependencies are not configured in the workspace.jsonc root config.\n * for example having the aspect\n * main aspect\n * export class MainAspectMain {\n * ...\n * static dependencies = [MyDepAspect];\n * }\n * and the in the workspace.jsonc file:\n * {\n * ...\n * main-aspect: {}\n * }\n * when set to true, bit will try to load MyDepAspect automatically.\n */\n autoLoadAspectsDeps?: boolean;\n\n /**\n * If set to `true`, enables external package manager mode. When enabled:\n * - `bit install` will not install dependencies and will prompt the user to use their package manager.\n * - Other commands that trigger installation (e.g., `bit import`, `bit checkout`) will skip the installation and print a warning.\n * When this prop is set by bit to `true`, the following properties are automatically set to `false`:\n * - `rootComponent`.\n * - `enableWorkspaceConfigWrite`.\n */\n externalPackageManager?: boolean;\n\n /**\n * List of file patterns to ignore from all components in the workspace.\n * Uses gitignore syntax.\n * Example: [\"oxlint.config.json\", \"biome.json\", \"*.bak\"]\n */\n ignoredFiles?: string[];\n\n /**\n * If set to `true`, Bit auto-syncs the local `.bitmap` to the latest scope HEAD versions\n * whenever the git HEAD has moved since the last sync (sentinel-driven, runs once per\n * `git pull`). Designed for repos with strict branch-protection rules: combined with\n * `bit ci merge --no-bitmap-commit`, the CI never commits `.bitmap` to the default\n * branch — every developer's first Bit command after `git pull` reconciles their\n * local `.bitmap` with the latest exported scope versions automatically.\n *\n * The mechanism is a no-op when:\n * - the workspace is not inside a git repo,\n * - the workspace is on a lane (lanes have their own sync flow),\n * - git HEAD is unchanged since the last successful reconciliation.\n *\n * On a failed remote-scope fetch, the command continues with the cached `.bitmap`\n * state and the sentinel is NOT advanced, so the next command retries.\n */\n bitmapAutoSync?: boolean;\n}\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["interface VendorConfig {\n directory: string;\n}\n\nexport interface WorkspaceExtConfig {\n /**\n * name of the workspace.\n */\n name: string;\n\n /**\n * path to icon.\n */\n icon: string;\n\n /**\n * set the default scope when there is no matching for the component in the components array.\n */\n defaultScope: string;\n\n /**\n * set the default directory when there is no matching for the component in the components array.\n */\n defaultDirectory: string;\n\n /**\n * sets the location of the root components directory.\n * The location is a relative path to the workspace root and should use linux path separators (/).\n */\n rootComponentsDirectory?: string;\n\n /**\n * set the default structure of components in your project\n */\n vendor: VendorConfig;\n\n /**\n * All component extensions applied by default on all components in the workspace (except vendor components)\n */\n extensions: { [extensionsId: string]: string };\n\n /**\n * If set to\n * `true`, it allows the workspace to resolve scope's aspects from node modules\n * installed in the workspace's `node_modules` directory. If not set or set to `false`, aspects will only be resolved\n * from the scope aspects capsule.\n */\n resolveAspectsFromNodeModules?: boolean;\n\n /**\n * If set to `true`, it allows the workspace to resolve envs from node modules\n * installed in the workspace's `node_modules` directory.\n * the envs will be resolved from the node_modules of the env's root (workspace/node_modules/.bit_roots/{envId})\n * and if not found (usually when the env was hoisted to the root node_modules) then from the node_modules of the\n * workspace.\n * If not set or set to `false`, envs will only be resolved from the scope envs capsule.\n */\n resolveEnvsFromRoots?: boolean;\n\n /**\n * If set to `true`, bit will try to load aspects dependencies automatically.\n * even if the aspects dependencies are not configured in the workspace.jsonc root config.\n * for example having the aspect\n * main aspect\n * export class MainAspectMain {\n * ...\n * static dependencies = [MyDepAspect];\n * }\n * and the in the workspace.jsonc file:\n * {\n * ...\n * main-aspect: {}\n * }\n * when set to true, bit will try to load MyDepAspect automatically.\n */\n autoLoadAspectsDeps?: boolean;\n\n /**\n * If set to `true`, enables external package manager mode. When enabled:\n * - `bit install` will not install dependencies and will prompt the user to use their package manager.\n * - Other commands that trigger installation (e.g., `bit import`, `bit checkout`) will skip the installation and print a warning.\n * When this prop is set by bit to `true`, the following properties are automatically set to `false`:\n * - `rootComponent`.\n * - `enableWorkspaceConfigWrite`.\n */\n externalPackageManager?: boolean;\n\n /**\n * List of file patterns to ignore from all components in the workspace.\n * Uses gitignore syntax.\n * Example: [\"oxlint.config.json\", \"biome.json\", \"*.bak\"]\n */\n ignoredFiles?: string[];\n\n /**\n * Scope-name patterns that the workspace trusts when loading aspects (envs,\n * generators, etc.) imported from those scopes. The effective trust set is:\n * a builtin set (e.g. `teambit.*`, `bitdev.*`) + the owner of `defaultScope`\n * (e.g. `acme.frontend` → `acme.*`) + entries listed here.\n *\n * Patterns: exact (`acme.frontend`) or owner wildcard (`acme.*`).\n * Manage via `bit scope trust [enable|disable|add|remove] [pattern]`.\n */\n trustedScopes?: string[];\n\n /**\n * If set to `true`, Bit auto-syncs the local `.bitmap` to the latest scope HEAD versions\n * whenever the git HEAD has moved since the last sync (sentinel-driven, runs once per\n * `git pull`). Designed for repos with strict branch-protection rules: combined with\n * `bit ci merge --no-bitmap-commit`, the CI never commits `.bitmap` to the default\n * branch — every developer's first Bit command after `git pull` reconciles their\n * local `.bitmap` with the latest exported scope versions automatically.\n *\n * The mechanism is a no-op when:\n * - the workspace is not inside a git repo,\n * - the workspace is on a lane (lanes have their own sync flow),\n * - git HEAD is unchanged since the last successful reconciliation.\n *\n * On a failed remote-scope fetch, the command continues with the cached `.bitmap`\n * state and the sentinel is NOT advanced, so the next command retries.\n */\n bitmapAutoSync?: boolean;\n}\n"],"mappings":"","ignoreList":[]}
|