paperclip-github-plugin 0.16.1 → 0.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -16
- package/dist/manifest.js +19 -7
- package/dist/ui/index.js +108 -62
- package/dist/ui/index.js.map +4 -4
- package/dist/worker.js +169 -32
- package/package.json +11 -11
package/dist/worker.js
CHANGED
|
@@ -1414,7 +1414,11 @@ var PULL_REQUEST_ASSET_EXTENSION_BY_MIME_TYPE = {
|
|
|
1414
1414
|
"application/gzip": "gz",
|
|
1415
1415
|
"application/octet-stream": "bin"
|
|
1416
1416
|
};
|
|
1417
|
+
var COMPANY_SCOPE_DENIED_SYNC_MESSAGE = "Paperclip denied GitHub Sync worker access for this company because it has no saved GitHub Sync plugin config. Open GitHub Sync settings inside the company and save settings once so the host registers it.";
|
|
1417
1418
|
var pluginRuntimeContext = null;
|
|
1419
|
+
var rememberedTrustedConfigByCompanyId = /* @__PURE__ */ new Map();
|
|
1420
|
+
var rememberedTrustedInstanceConfig = null;
|
|
1421
|
+
var reportedTrustedConfigReadFailures = /* @__PURE__ */ new Set();
|
|
1418
1422
|
function isPendingWakeApplied(pendingWake, status, assignee) {
|
|
1419
1423
|
return (!pendingWake.nextStatus || pendingWake.nextStatus === status) && assignee?.kind === "agent" && assignee.id === pendingWake.assigneeAgentId;
|
|
1420
1424
|
}
|
|
@@ -2294,9 +2298,18 @@ function getErrorMessage(error) {
|
|
|
2294
2298
|
}
|
|
2295
2299
|
return String(error);
|
|
2296
2300
|
}
|
|
2297
|
-
function
|
|
2301
|
+
function isCompanyScopeDeniedError(error) {
|
|
2298
2302
|
const message = getErrorMessage(error).toLowerCase();
|
|
2299
|
-
|
|
2303
|
+
const errorName = error instanceof Error ? error.name : "";
|
|
2304
|
+
return errorName === "InvocationScopeDeniedError" || message.includes("invocationscopedenied") || message.includes("company context is required") || message.includes("companyid is required for plugin secret resolution");
|
|
2305
|
+
}
|
|
2306
|
+
function isPluginSecretReferenceUnavailableError(error) {
|
|
2307
|
+
const message = getErrorMessage(error).toLowerCase();
|
|
2308
|
+
const code = getErrorCode(error)?.toLowerCase();
|
|
2309
|
+
return (
|
|
2310
|
+
// Paperclip 2026.626 rejected every plugin secret ref.
|
|
2311
|
+
message.includes("plugin secret reference") && message.includes("disabled") || message.includes("company-scoped plugin config lands") || code === "binding_missing" || message.includes("not bound to plugin") || message.includes("invalid secret reference for plugin") || isCompanyScopeDeniedError(error)
|
|
2312
|
+
);
|
|
2300
2313
|
}
|
|
2301
2314
|
function getErrorCause(error) {
|
|
2302
2315
|
if (!error || typeof error !== "object" || !("cause" in error)) {
|
|
@@ -2638,9 +2651,42 @@ function buildGitHubRepositoryTokenCapabilityAudit(params) {
|
|
|
2638
2651
|
warnings
|
|
2639
2652
|
};
|
|
2640
2653
|
}
|
|
2654
|
+
var SECRET_ID_UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/iu;
|
|
2655
|
+
function isPlainRecord(value) {
|
|
2656
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
2657
|
+
}
|
|
2658
|
+
function isSecretRefBinding(value) {
|
|
2659
|
+
return isPlainRecord(value) && value.type === "secret_ref" && typeof value.secretId === "string" && Boolean(value.secretId.trim());
|
|
2660
|
+
}
|
|
2641
2661
|
function normalizeSecretRef(value) {
|
|
2662
|
+
if (isSecretRefBinding(value)) {
|
|
2663
|
+
return value.secretId.trim();
|
|
2664
|
+
}
|
|
2642
2665
|
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
2643
2666
|
}
|
|
2667
|
+
function isLegacySecretRefString(value) {
|
|
2668
|
+
return typeof value === "string" && SECRET_ID_UUID_PATTERN.test(value.trim());
|
|
2669
|
+
}
|
|
2670
|
+
function toSecretRefBinding(secretId) {
|
|
2671
|
+
return { type: "secret_ref", secretId };
|
|
2672
|
+
}
|
|
2673
|
+
function getGitHubTokenRefConfigPath(companyId) {
|
|
2674
|
+
return `githubTokenRefs.${companyId}`;
|
|
2675
|
+
}
|
|
2676
|
+
function getPaperclipBoardApiTokenRefConfigPath(companyId) {
|
|
2677
|
+
return `paperclipBoardApiTokenRefs.${companyId}`;
|
|
2678
|
+
}
|
|
2679
|
+
function readCompanyScopedConfigValue(config, key, companyId) {
|
|
2680
|
+
const map = config[key];
|
|
2681
|
+
return isPlainRecord(map) ? map[companyId] : void 0;
|
|
2682
|
+
}
|
|
2683
|
+
async function resolvePluginSecret(ctx, secretId, options = {}) {
|
|
2684
|
+
const companyId = normalizeCompanyId(options.companyId);
|
|
2685
|
+
return ctx.secrets.resolve(toSecretRefBinding(secretId), {
|
|
2686
|
+
...companyId ? { companyId } : {},
|
|
2687
|
+
...options.configPath ? { configPath: options.configPath } : {}
|
|
2688
|
+
});
|
|
2689
|
+
}
|
|
2644
2690
|
function normalizeGitHubLowercaseString(value) {
|
|
2645
2691
|
if (typeof value !== "string") {
|
|
2646
2692
|
return void 0;
|
|
@@ -3552,7 +3598,7 @@ function extractGitHubLinksFromCommentBody(body) {
|
|
|
3552
3598
|
async function buildToolbarSyncState(ctx, input) {
|
|
3553
3599
|
const companyId = typeof input.companyId === "string" && input.companyId.trim() ? input.companyId.trim() : void 0;
|
|
3554
3600
|
const settings = await getActiveOrCurrentSyncState(ctx, companyId);
|
|
3555
|
-
const config = await getResolvedConfig(ctx);
|
|
3601
|
+
const config = await getResolvedConfig(ctx, companyId);
|
|
3556
3602
|
const githubTokenConfigured = hasConfiguredGithubToken(settings, config, companyId);
|
|
3557
3603
|
const entityId = typeof input.entityId === "string" && input.entityId.trim() ? input.entityId.trim() : void 0;
|
|
3558
3604
|
const entityType = typeof input.entityType === "string" && input.entityType.trim() ? input.entityType.trim() : void 0;
|
|
@@ -4349,7 +4395,7 @@ async function createUnexpectedSyncErrorResult(ctx, trigger, error, companyId) {
|
|
|
4349
4395
|
});
|
|
4350
4396
|
const message = isGitHubRateLimitError(error) ? buildSyncFailureMessage(error, {
|
|
4351
4397
|
phase: "configuration"
|
|
4352
|
-
}) : getErrorMessage(error).trim() || "Unable to run GitHub sync.";
|
|
4398
|
+
}) : isCompanyScopeDeniedError(error) ? COMPANY_SCOPE_DENIED_SYNC_MESSAGE : getErrorMessage(error).trim() || "Unable to run GitHub sync.";
|
|
4353
4399
|
return saveSettingsSyncState(
|
|
4354
4400
|
ctx,
|
|
4355
4401
|
settings,
|
|
@@ -4633,7 +4679,10 @@ async function clearExternalCompanyPaperclipBoardApiTokenFallback(ctx, companyId
|
|
|
4633
4679
|
}
|
|
4634
4680
|
async function shouldSeedExternalPaperclipBoardTokenFallback(ctx, companyId, secretRef) {
|
|
4635
4681
|
try {
|
|
4636
|
-
return !(await ctx
|
|
4682
|
+
return !(await resolvePluginSecret(ctx, secretRef, {
|
|
4683
|
+
companyId,
|
|
4684
|
+
configPath: getPaperclipBoardApiTokenRefConfigPath(companyId)
|
|
4685
|
+
})).trim();
|
|
4637
4686
|
} catch (error) {
|
|
4638
4687
|
ctx.logger.warn("Unable to resolve the saved Paperclip board API token while checking worker fallback necessity.", {
|
|
4639
4688
|
companyId,
|
|
@@ -11719,9 +11768,62 @@ async function synchronizePaperclipPullRequestIssueStatuses(ctx, octokit, mappin
|
|
|
11719
11768
|
updatedStatusesCount
|
|
11720
11769
|
};
|
|
11721
11770
|
}
|
|
11722
|
-
|
|
11771
|
+
function rememberTrustedConfig(companyId, value) {
|
|
11772
|
+
const record = isPlainRecord(value) ? { ...value } : {};
|
|
11773
|
+
const normalizedCompanyId = normalizeCompanyId(companyId);
|
|
11774
|
+
if (normalizedCompanyId) {
|
|
11775
|
+
rememberedTrustedConfigByCompanyId.set(normalizedCompanyId, record);
|
|
11776
|
+
} else {
|
|
11777
|
+
rememberedTrustedInstanceConfig = record;
|
|
11778
|
+
}
|
|
11779
|
+
}
|
|
11780
|
+
function getRememberedConfiguredCompanyIds() {
|
|
11781
|
+
return [...rememberedTrustedConfigByCompanyId.keys()].sort((left, right) => left.localeCompare(right));
|
|
11782
|
+
}
|
|
11783
|
+
function mergeRememberedTrustedConfig() {
|
|
11784
|
+
const merged = { ...rememberedTrustedInstanceConfig ?? {} };
|
|
11785
|
+
for (const companyId of getRememberedConfiguredCompanyIds()) {
|
|
11786
|
+
const config = rememberedTrustedConfigByCompanyId.get(companyId) ?? {};
|
|
11787
|
+
for (const [key, value] of Object.entries(config)) {
|
|
11788
|
+
const existing = merged[key];
|
|
11789
|
+
if (isPlainRecord(existing) && isPlainRecord(value)) {
|
|
11790
|
+
merged[key] = { ...existing, ...value };
|
|
11791
|
+
} else if (existing === void 0) {
|
|
11792
|
+
merged[key] = value;
|
|
11793
|
+
}
|
|
11794
|
+
}
|
|
11795
|
+
}
|
|
11796
|
+
return merged;
|
|
11797
|
+
}
|
|
11798
|
+
async function readTrustedConfig(ctx, companyId) {
|
|
11799
|
+
const normalizedCompanyId = normalizeCompanyId(companyId);
|
|
11800
|
+
try {
|
|
11801
|
+
const value = await ctx.config.get(normalizedCompanyId);
|
|
11802
|
+
const record = isPlainRecord(value) ? value : {};
|
|
11803
|
+
if (normalizedCompanyId) {
|
|
11804
|
+
rememberedTrustedConfigByCompanyId.set(normalizedCompanyId, { ...record });
|
|
11805
|
+
}
|
|
11806
|
+
return record;
|
|
11807
|
+
} catch (error) {
|
|
11808
|
+
const remembered = normalizedCompanyId ? rememberedTrustedConfigByCompanyId.get(normalizedCompanyId) : mergeRememberedTrustedConfig();
|
|
11809
|
+
const warningKey = `${normalizedCompanyId ?? "<instance>"}:${getErrorMessage(error)}`;
|
|
11810
|
+
if (!reportedTrustedConfigReadFailures.has(warningKey)) {
|
|
11811
|
+
reportedTrustedConfigReadFailures.add(warningKey);
|
|
11812
|
+
ctx.logger.warn(
|
|
11813
|
+
"GitHub Sync could not read company-scoped plugin config from the Paperclip host; using the last config the host delivered for this scope.",
|
|
11814
|
+
{
|
|
11815
|
+
companyId: normalizedCompanyId ?? null,
|
|
11816
|
+
usingDeliveredConfig: Boolean(remembered && Object.keys(remembered).length > 0),
|
|
11817
|
+
error: getErrorMessage(error)
|
|
11818
|
+
}
|
|
11819
|
+
);
|
|
11820
|
+
}
|
|
11821
|
+
return remembered ?? {};
|
|
11822
|
+
}
|
|
11823
|
+
}
|
|
11824
|
+
async function getResolvedConfig(ctx, companyId) {
|
|
11723
11825
|
const [savedConfig, externalConfig] = await Promise.all([
|
|
11724
|
-
ctx
|
|
11826
|
+
readTrustedConfig(ctx, companyId),
|
|
11725
11827
|
readExternalConfig(ctx)
|
|
11726
11828
|
]);
|
|
11727
11829
|
return {
|
|
@@ -11733,7 +11835,8 @@ function getConfiguredGithubTokenSource(settings, config, companyId) {
|
|
|
11733
11835
|
const normalizedCompanyId = normalizeCompanyId(companyId);
|
|
11734
11836
|
const companyFallbackToken = normalizedCompanyId ? normalizeGitHubToken(config.githubTokensByCompanyId?.[normalizedCompanyId]) : void 0;
|
|
11735
11837
|
const hasScopedGitHubTokenRefs = hasAnyScopedValue(settings?.githubTokenRefs) || hasAnyScopedValue(config.githubTokenRefs);
|
|
11736
|
-
const
|
|
11838
|
+
const companyScopedSecretRef = normalizedCompanyId ? normalizeSecretRef(config.githubTokenRefs?.[normalizedCompanyId]) ?? normalizeSecretRef(settings?.githubTokenRefs?.[normalizedCompanyId]) : void 0;
|
|
11839
|
+
const secretRef = normalizedCompanyId ? companyScopedSecretRef ?? (!hasScopedGitHubTokenRefs ? normalizeGitHubTokenRef(config.githubTokenRef) ?? normalizeGitHubTokenRef(settings?.githubTokenRef) : void 0) : normalizeGitHubTokenRef(config.githubTokenRef) ?? normalizeGitHubTokenRef(settings?.githubTokenRef) ?? (() => {
|
|
11737
11840
|
const configuredRefs = [
|
|
11738
11841
|
...Object.values(config.githubTokenRefs ?? {}),
|
|
11739
11842
|
...Object.values(settings?.githubTokenRefs ?? {})
|
|
@@ -11744,6 +11847,7 @@ function getConfiguredGithubTokenSource(settings, config, companyId) {
|
|
|
11744
11847
|
if (secretRef) {
|
|
11745
11848
|
return {
|
|
11746
11849
|
secretRef,
|
|
11850
|
+
...normalizedCompanyId && companyScopedSecretRef === secretRef ? { configPath: getGitHubTokenRefConfigPath(normalizedCompanyId) } : {},
|
|
11747
11851
|
...companyFallbackToken ? { fallbackToken: companyFallbackToken } : {}
|
|
11748
11852
|
};
|
|
11749
11853
|
}
|
|
@@ -11843,12 +11947,15 @@ async function resolvePaperclipApiAuthTokens(ctx, settings, config, mappings) {
|
|
|
11843
11947
|
continue;
|
|
11844
11948
|
}
|
|
11845
11949
|
try {
|
|
11846
|
-
const token = (await ctx
|
|
11950
|
+
const token = (await resolvePluginSecret(ctx, secretRef, {
|
|
11951
|
+
companyId,
|
|
11952
|
+
configPath: getPaperclipBoardApiTokenRefConfigPath(companyId)
|
|
11953
|
+
})).trim();
|
|
11847
11954
|
if (token) {
|
|
11848
11955
|
tokensByCompanyId.set(companyId, token);
|
|
11849
11956
|
}
|
|
11850
11957
|
} catch (error) {
|
|
11851
|
-
if (fallbackToken &&
|
|
11958
|
+
if (fallbackToken && isPluginSecretReferenceUnavailableError(error)) {
|
|
11852
11959
|
ctx.logger.warn("GitHub Sync is using a worker-local Paperclip board token fallback because plugin secret refs are unavailable in this host.", {
|
|
11853
11960
|
companyId,
|
|
11854
11961
|
secretRef,
|
|
@@ -11868,17 +11975,20 @@ async function resolvePaperclipApiAuthTokens(ctx, settings, config, mappings) {
|
|
|
11868
11975
|
}
|
|
11869
11976
|
async function resolveGithubToken(ctx, options = {}) {
|
|
11870
11977
|
const settings = options.settings ?? normalizeSettings(await ctx.state.get(SETTINGS_SCOPE));
|
|
11871
|
-
const config = options.config ?? await getResolvedConfig(ctx);
|
|
11978
|
+
const config = options.config ?? await getResolvedConfig(ctx, options.companyId);
|
|
11872
11979
|
const configuredTokenSource = getConfiguredGithubTokenSource(settings, config, options.companyId);
|
|
11873
11980
|
if (configuredTokenSource.secretRef) {
|
|
11874
11981
|
try {
|
|
11875
|
-
const token = (await ctx
|
|
11982
|
+
const token = (await resolvePluginSecret(ctx, configuredTokenSource.secretRef, {
|
|
11983
|
+
companyId: options.companyId,
|
|
11984
|
+
...configuredTokenSource.configPath ? { configPath: configuredTokenSource.configPath } : {}
|
|
11985
|
+
})).trim();
|
|
11876
11986
|
if (token) {
|
|
11877
11987
|
return token;
|
|
11878
11988
|
}
|
|
11879
11989
|
return configuredTokenSource.fallbackToken ?? "";
|
|
11880
11990
|
} catch (error) {
|
|
11881
|
-
if (configuredTokenSource.fallbackToken &&
|
|
11991
|
+
if (configuredTokenSource.fallbackToken && isPluginSecretReferenceUnavailableError(error)) {
|
|
11882
11992
|
ctx.logger.warn("GitHub Sync is using a worker-local company token fallback because plugin secret refs are unavailable in this host.", {
|
|
11883
11993
|
companyId: normalizeCompanyId(options.companyId),
|
|
11884
11994
|
secretRef: configuredTokenSource.secretRef,
|
|
@@ -14162,7 +14272,7 @@ async function buildProjectPullRequestsPageData(ctx, input) {
|
|
|
14162
14272
|
};
|
|
14163
14273
|
}
|
|
14164
14274
|
const scope = await requireProjectPullRequestScope(ctx, input, projectMappings);
|
|
14165
|
-
const config = await getResolvedConfig(ctx);
|
|
14275
|
+
const config = await getResolvedConfig(ctx, scope.companyId);
|
|
14166
14276
|
if (!hasConfiguredGithubToken(settings, config, scope.companyId)) {
|
|
14167
14277
|
return {
|
|
14168
14278
|
status: "missing_token",
|
|
@@ -14353,7 +14463,7 @@ async function buildProjectPullRequestMetricsData(ctx, input) {
|
|
|
14353
14463
|
failingPullRequests: 0
|
|
14354
14464
|
};
|
|
14355
14465
|
}
|
|
14356
|
-
const config = await getResolvedConfig(ctx);
|
|
14466
|
+
const config = await getResolvedConfig(ctx, companyId);
|
|
14357
14467
|
if (!hasConfiguredGithubToken(settings, config, companyId)) {
|
|
14358
14468
|
return {
|
|
14359
14469
|
status: "missing_token",
|
|
@@ -14402,7 +14512,7 @@ async function buildProjectPullRequestCountData(ctx, input) {
|
|
|
14402
14512
|
totalOpenPullRequests: 0
|
|
14403
14513
|
};
|
|
14404
14514
|
}
|
|
14405
|
-
const config = await getResolvedConfig(ctx);
|
|
14515
|
+
const config = await getResolvedConfig(ctx, companyId);
|
|
14406
14516
|
if (!hasConfiguredGithubToken(settings, config, companyId)) {
|
|
14407
14517
|
return {
|
|
14408
14518
|
status: "missing_token",
|
|
@@ -14439,7 +14549,7 @@ async function buildSettingsTokenPermissionAuditData(ctx, input) {
|
|
|
14439
14549
|
};
|
|
14440
14550
|
}
|
|
14441
14551
|
const settings = normalizeSettings(await ctx.state.get(SETTINGS_SCOPE));
|
|
14442
|
-
const config = await getResolvedConfig(ctx);
|
|
14552
|
+
const config = await getResolvedConfig(ctx, requestedCompanyId);
|
|
14443
14553
|
if (!hasConfiguredGithubToken(settings, config, requestedCompanyId)) {
|
|
14444
14554
|
return {
|
|
14445
14555
|
status: "missing_token",
|
|
@@ -15423,7 +15533,7 @@ async function listScheduledSyncTargets(ctx, settings) {
|
|
|
15423
15533
|
async function performSync(ctx, trigger, options = {}) {
|
|
15424
15534
|
const targetCompanyId = normalizeCompanyId(options.target?.companyId);
|
|
15425
15535
|
const baseSettings = normalizeSettings(await ctx.state.get(SETTINGS_SCOPE));
|
|
15426
|
-
const config = await getResolvedConfig(ctx);
|
|
15536
|
+
const config = await getResolvedConfig(ctx, targetCompanyId);
|
|
15427
15537
|
const settings = materializeScopedSettings(baseSettings, config, targetCompanyId);
|
|
15428
15538
|
const importRegistry = normalizeImportRegistry(await ctx.state.get(IMPORT_REGISTRY_SCOPE));
|
|
15429
15539
|
const remoteActionRegistry = normalizeRemoteActionRegistry(await ctx.state.get(REMOTE_ACTION_REGISTRY_SCOPE));
|
|
@@ -16346,11 +16456,11 @@ async function startSync(ctx, trigger, options = {}) {
|
|
|
16346
16456
|
return quickResult2 ?? await getActiveOrCurrentSyncState(ctx);
|
|
16347
16457
|
}
|
|
16348
16458
|
await reconcileOrphanedRunningSyncState(ctx, options.target?.companyId);
|
|
16459
|
+
const targetCompanyId = normalizeCompanyId(options.target?.companyId);
|
|
16349
16460
|
const [config, persistedSettings] = await Promise.all([
|
|
16350
|
-
getResolvedConfig(ctx),
|
|
16461
|
+
getResolvedConfig(ctx, targetCompanyId),
|
|
16351
16462
|
ctx.state.get(SETTINGS_SCOPE).then((value) => normalizeSettings(value))
|
|
16352
16463
|
]);
|
|
16353
|
-
const targetCompanyId = normalizeCompanyId(options.target?.companyId);
|
|
16354
16464
|
const token = await resolveGithubToken(ctx, {
|
|
16355
16465
|
companyId: targetCompanyId,
|
|
16356
16466
|
config,
|
|
@@ -17820,6 +17930,19 @@ var __testing = {
|
|
|
17820
17930
|
}
|
|
17821
17931
|
};
|
|
17822
17932
|
var plugin = definePlugin({
|
|
17933
|
+
// GitHub Sync serves every company on the instance from one worker; Paperclip 2026.831 delivers
|
|
17934
|
+
// one company-scoped config per configured company and rejects that fan-out unless the plugin
|
|
17935
|
+
// declares it keys config by company.
|
|
17936
|
+
multiCompanyConfig: true,
|
|
17937
|
+
async onConfigChanged(newConfig, context) {
|
|
17938
|
+
const companyId = normalizeCompanyId(context?.companyId) ?? null;
|
|
17939
|
+
rememberTrustedConfig(companyId, newConfig);
|
|
17940
|
+
clearGitHubRepositoryTokenCapabilityAudits();
|
|
17941
|
+
pluginRuntimeContext?.logger.debug("GitHub Sync received company-scoped plugin config.", {
|
|
17942
|
+
companyId,
|
|
17943
|
+
configKeys: Object.keys(isPlainRecord(newConfig) ? newConfig : {})
|
|
17944
|
+
});
|
|
17945
|
+
},
|
|
17823
17946
|
async setup(ctx) {
|
|
17824
17947
|
pluginRuntimeContext = ctx;
|
|
17825
17948
|
ctx.data.register("settings.registration", async (input) => {
|
|
@@ -17830,15 +17953,24 @@ var plugin = definePlugin({
|
|
|
17830
17953
|
const saved = await ctx.state.get(SETTINGS_SCOPE);
|
|
17831
17954
|
const importRegistry = normalizeImportRegistry(await ctx.state.get(IMPORT_REGISTRY_SCOPE));
|
|
17832
17955
|
const normalizedSettings = normalizeSettings(saved);
|
|
17833
|
-
const [config,
|
|
17834
|
-
getResolvedConfig(ctx),
|
|
17835
|
-
ctx
|
|
17956
|
+
const [config, rawTrustedConfig] = await Promise.all([
|
|
17957
|
+
getResolvedConfig(ctx, requestedCompanyId),
|
|
17958
|
+
readTrustedConfig(ctx, requestedCompanyId)
|
|
17836
17959
|
]);
|
|
17960
|
+
const trustedConfig = normalizeConfig(rawTrustedConfig);
|
|
17837
17961
|
const githubTokenConfigured = hasConfiguredGithubToken(normalizedSettings, config, requestedCompanyId);
|
|
17838
17962
|
const configuredGitHubTokenRef = getConfiguredGitHubTokenRef(trustedConfig, requestedCompanyId);
|
|
17839
17963
|
const savedGitHubTokenRef = getSavedGitHubTokenRef(normalizedSettings, requestedCompanyId);
|
|
17840
17964
|
const configuredBoardTokenRef = getConfiguredPaperclipBoardApiTokenRef(trustedConfig, requestedCompanyId);
|
|
17841
17965
|
const savedBoardTokenRef = getSavedPaperclipBoardApiTokenRef(normalizedSettings, requestedCompanyId);
|
|
17966
|
+
const configuredGitHubTokenRefIsLegacy = Boolean(
|
|
17967
|
+
requestedCompanyId && isLegacySecretRefString(readCompanyScopedConfigValue(rawTrustedConfig, "githubTokenRefs", requestedCompanyId))
|
|
17968
|
+
);
|
|
17969
|
+
const configuredBoardTokenRefIsLegacy = Boolean(
|
|
17970
|
+
requestedCompanyId && isLegacySecretRefString(
|
|
17971
|
+
readCompanyScopedConfigValue(rawTrustedConfig, "paperclipBoardApiTokenRefs", requestedCompanyId)
|
|
17972
|
+
)
|
|
17973
|
+
);
|
|
17842
17974
|
const settingsForResponse = sanitizeSettingsForCurrentSetup(
|
|
17843
17975
|
materializeScopedSettings(normalizedSettings, config, requestedCompanyId),
|
|
17844
17976
|
{
|
|
@@ -17859,10 +17991,12 @@ var plugin = definePlugin({
|
|
|
17859
17991
|
githubTokenConfigured,
|
|
17860
17992
|
paperclipBoardAccessConfigured: requestedCompanyId ? hasConfiguredPaperclipBoardAccess(settingsForResponse, config, requestedCompanyId) : hasConfiguredPaperclipBoardAccessForMappings(settingsForResponse, config, scopedMappings),
|
|
17861
17993
|
...savedGitHubTokenRef ? { githubTokenConfigSyncRef: savedGitHubTokenRef } : {},
|
|
17862
|
-
githubTokenNeedsConfigSync: Boolean(
|
|
17994
|
+
githubTokenNeedsConfigSync: Boolean(
|
|
17995
|
+
savedGitHubTokenRef && (configuredGitHubTokenRef !== savedGitHubTokenRef || configuredGitHubTokenRefIsLegacy)
|
|
17996
|
+
),
|
|
17863
17997
|
...savedBoardTokenRef ? { paperclipBoardAccessConfigSyncRef: savedBoardTokenRef } : {},
|
|
17864
17998
|
paperclipBoardAccessNeedsConfigSync: Boolean(
|
|
17865
|
-
savedBoardTokenRef && configuredBoardTokenRef !== savedBoardTokenRef
|
|
17999
|
+
savedBoardTokenRef && (configuredBoardTokenRef !== savedBoardTokenRef || configuredBoardTokenRefIsLegacy)
|
|
17866
18000
|
)
|
|
17867
18001
|
};
|
|
17868
18002
|
});
|
|
@@ -17953,9 +18087,9 @@ var plugin = definePlugin({
|
|
|
17953
18087
|
});
|
|
17954
18088
|
ctx.actions.register("settings.saveRegistration", async (input, actionContext) => {
|
|
17955
18089
|
const previous = normalizeSettings(await ctx.state.get(SETTINGS_SCOPE));
|
|
17956
|
-
const config = await getResolvedConfig(ctx);
|
|
17957
18090
|
const record = normalizeActionRecord(input, actionContext);
|
|
17958
18091
|
const requestedCompanyId = normalizeCompanyId(record.companyId);
|
|
18092
|
+
const config = await getResolvedConfig(ctx, requestedCompanyId);
|
|
17959
18093
|
const requestedGitHubTokenLogin = "githubTokenLogin" in record ? normalizeOptionalString2(record.githubTokenLogin) : void 0;
|
|
17960
18094
|
const hasMappingsPatch = "mappings" in record;
|
|
17961
18095
|
const hasAdvancedSettingsPatch = "advancedSettings" in record;
|
|
@@ -18058,15 +18192,15 @@ var plugin = definePlugin({
|
|
|
18058
18192
|
});
|
|
18059
18193
|
ctx.actions.register("settings.updateBoardAccess", async (input, actionContext) => {
|
|
18060
18194
|
const previous = normalizeSettings(await ctx.state.get(SETTINGS_SCOPE));
|
|
18061
|
-
const [config, trustedConfig] = await Promise.all([
|
|
18062
|
-
getResolvedConfig(ctx),
|
|
18063
|
-
ctx.config.get().then((value) => normalizeConfig(value))
|
|
18064
|
-
]);
|
|
18065
18195
|
const record = normalizeActionRecord(input, actionContext);
|
|
18066
18196
|
const companyId = normalizeCompanyId(record.companyId);
|
|
18067
18197
|
if (!companyId) {
|
|
18068
18198
|
throw new Error("A company id is required to update Paperclip board access.");
|
|
18069
18199
|
}
|
|
18200
|
+
const [config, trustedConfig] = await Promise.all([
|
|
18201
|
+
getResolvedConfig(ctx, companyId),
|
|
18202
|
+
readTrustedConfig(ctx, companyId).then((value) => normalizeConfig(value))
|
|
18203
|
+
]);
|
|
18070
18204
|
const nextSecretRef = normalizeSecretRef(record.paperclipBoardApiTokenRef);
|
|
18071
18205
|
const boardAccessRecord = record.paperclipBoardAccess && typeof record.paperclipBoardAccess === "object" ? record.paperclipBoardAccess : {};
|
|
18072
18206
|
const boardAuthorizationRecord = boardAccessRecord.authorization && typeof boardAccessRecord.authorization === "object" ? boardAccessRecord.authorization : {};
|
|
@@ -18160,7 +18294,10 @@ var plugin = definePlugin({
|
|
|
18160
18294
|
throw new Error("A validated GitHub token is required to prepare the worker token fallback.");
|
|
18161
18295
|
}
|
|
18162
18296
|
try {
|
|
18163
|
-
const resolvedToken = (await ctx
|
|
18297
|
+
const resolvedToken = (await resolvePluginSecret(ctx, githubTokenRef, {
|
|
18298
|
+
companyId,
|
|
18299
|
+
configPath: getGitHubTokenRefConfigPath(companyId)
|
|
18300
|
+
})).trim();
|
|
18164
18301
|
if (resolvedToken) {
|
|
18165
18302
|
return {
|
|
18166
18303
|
secretResolvable: true,
|
|
@@ -18168,7 +18305,7 @@ var plugin = definePlugin({
|
|
|
18168
18305
|
};
|
|
18169
18306
|
}
|
|
18170
18307
|
} catch (error) {
|
|
18171
|
-
if (!
|
|
18308
|
+
if (!isPluginSecretReferenceUnavailableError(error)) {
|
|
18172
18309
|
throw error;
|
|
18173
18310
|
}
|
|
18174
18311
|
await writeExternalCompanyGitHubTokenFallback(ctx, companyId, token);
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "paperclip-github-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.1",
|
|
4
4
|
"description": "Paperclip plugin for synchronizing GitHub issues into Paperclip projects.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"packageManager": "pnpm@
|
|
7
|
+
"packageManager": "pnpm@12.4.1",
|
|
8
8
|
"engines": {
|
|
9
|
-
"node": ">=
|
|
9
|
+
"node": ">=24.21.0"
|
|
10
10
|
},
|
|
11
11
|
"repository": {
|
|
12
12
|
"type": "git",
|
|
@@ -41,19 +41,19 @@
|
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@octokit/rest": "^22.0.1",
|
|
44
|
-
"@paperclipai/plugin-sdk": "^2026.
|
|
45
|
-
"react": "^19.
|
|
44
|
+
"@paperclipai/plugin-sdk": "^2026.831.1",
|
|
45
|
+
"react": "^19.3.0",
|
|
46
46
|
"react-markdown": "^10.1.0",
|
|
47
47
|
"rehype-raw": "^7.0.0",
|
|
48
48
|
"rehype-sanitize": "^6.0.0",
|
|
49
49
|
"remark-gfm": "^4.0.1"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@types/node": "24.13.
|
|
53
|
-
"@types/react": "19.
|
|
54
|
-
"esbuild": "0.28.
|
|
55
|
-
"playwright": "1.
|
|
56
|
-
"tsx": "4.23.
|
|
57
|
-
"typescript": "
|
|
52
|
+
"@types/node": "24.13.4",
|
|
53
|
+
"@types/react": "19.3.0",
|
|
54
|
+
"esbuild": "0.28.2",
|
|
55
|
+
"playwright": "1.63.0",
|
|
56
|
+
"tsx": "4.23.13",
|
|
57
|
+
"typescript": "7.0.2"
|
|
58
58
|
}
|
|
59
59
|
}
|