codex-overleaf-link 2.4.1 → 2.5.0
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 +272 -314
- package/README.zh-CN.md +287 -329
- package/extension/bootstrap/background.js +47 -10
- package/extension/bootstrap/manifest.template.json +9 -4
- package/extension/bootstrap/popup.html +10 -16
- package/extension/bootstrap/update.js +25 -2
- package/extension/runtime-manifest.json +3 -1
- package/extension/src/background.js +28 -3
- package/extension/src/backgroundSharedSessions.js +380 -0
- package/extension/src/backgroundUpdateCoordinator.js +442 -379
- package/extension/src/content/activeTurnControl.js +8 -0
- package/extension/src/content/assetTransferBroker.js +186 -12
- package/extension/src/content/changeHistoryView.js +175 -0
- package/extension/src/content/composerAttachments.js +24 -22
- package/extension/src/content/composerPanel.js +23 -8
- package/extension/src/content/contentRuntime.js +507 -507
- package/extension/src/content/diagnosticsController.js +1 -2
- package/extension/src/content/diagnosticsExport.js +222 -0
- package/extension/src/content/diagnosticsPanel.js +48 -19
- package/extension/src/content/diffReviewPanel.js +8 -5
- package/extension/src/content/generated/content.bundle.js +8330 -1349
- package/extension/src/content/generated/content.bundle.meta.json +22 -3
- package/extension/src/content/legacyGlobalRegistry.js +19 -1
- package/extension/src/content/localSkillsPanel.js +42 -7
- package/extension/src/content/markdownDomRenderer.js +9 -4
- package/extension/src/content/modelPicker.js +1 -1
- package/extension/src/content/pageBridgeClient.js +18 -3
- package/extension/src/content/panelMaintenance.js +48 -121
- package/extension/src/content/panelRenderer.js +4 -0
- package/extension/src/content/pendingInputView.js +109 -76
- package/extension/src/content/providerSettingsCoordinator.js +17 -6
- package/extension/src/content/providerSettingsDialog.js +661 -108
- package/extension/src/content/recentProjects.js +10 -1
- package/extension/src/content/runActivitySummary.js +631 -0
- package/extension/src/content/runController.js +3 -1
- package/extension/src/content/runFailureNotice.js +14 -1
- package/extension/src/content/runGuidanceController.js +4 -3
- package/extension/src/content/runPresence.js +306 -0
- package/extension/src/content/runQueueScheduler.js +2 -1
- package/extension/src/content/runResultActions.js +123 -3
- package/extension/src/content/runTimelineView.js +186 -154
- package/extension/src/content/selectionContextView.js +300 -0
- package/extension/src/content/sessionPersistence.js +6 -1
- package/extension/src/content/settingsPanel.js +77 -52
- package/extension/src/content/settingsWorkbench.js +374 -0
- package/extension/src/content/sharedSessionViewSync.js +72 -0
- package/extension/src/content/subagentActivityView.js +195 -0
- package/extension/src/content/trackedChangeCaptureController.js +7 -3
- package/extension/src/content/updateNotice.js +121 -50
- package/extension/src/content/writebackController.js +257 -0
- package/extension/src/content/writebackOrchestrator.js +146 -141
- package/extension/src/content/writebackPlan.js +231 -0
- package/extension/src/content/writebackRecovery.js +122 -0
- package/extension/src/content/writingStyleSettings.js +576 -0
- package/extension/src/content/writtenChangesView.js +152 -0
- package/extension/src/page/binaryAssetUploader.js +97 -19
- package/extension/src/page/overleafProjectSnapshot.js +1 -0
- package/extension/src/page/referenceProjects.js +148 -0
- package/extension/src/page/saveState.js +14 -2
- package/extension/src/page/snapshotRouter.js +44 -13
- package/extension/src/page/textCoordinates.js +102 -0
- package/extension/src/page/textFileCreator.js +350 -59
- package/extension/src/page/trackedChangeCapture.js +42 -56
- package/extension/src/page/trackedChangeOwnership.js +198 -0
- package/extension/src/page/trackedChangeReplay.js +164 -0
- package/extension/src/page/trackedChangesLifecycle.js +135 -149
- package/extension/src/page/treeOperations.js +26 -2
- package/extension/src/page/writebackReceiptJournal.js +112 -0
- package/extension/src/page/writebackRouter.js +175 -135
- package/extension/src/pageBridge.js +56 -101
- package/extension/src/popup.js +203 -59
- package/extension/src/shared/agentTranscript.js +18 -4
- package/extension/src/shared/auditRecords.js +71 -0
- package/extension/src/shared/changeHistoryModel.js +94 -0
- package/extension/src/shared/compatibility.js +1 -1
- package/extension/src/shared/compileAdapter.js +42 -0
- package/extension/src/shared/failureReasons.js +20 -0
- package/extension/src/shared/globalPreferences.js +1 -1
- package/extension/src/shared/i18n.js +93 -25
- package/extension/src/shared/managedUpdateProjection.js +6 -3
- package/extension/src/shared/pageRpcContract.js +7 -1
- package/extension/src/shared/providerProfiles.js +109 -0
- package/extension/src/shared/runActivityModel.js +361 -0
- package/extension/src/shared/runExecutionSnapshot.js +8 -2
- package/extension/src/shared/runExecutionSnapshotCodec.js +16 -4
- package/extension/src/shared/scopedPersistenceBrowserAdapter.js +6 -3
- package/extension/src/shared/selectionContext.js +28 -0
- package/extension/src/shared/sessionState.js +97 -6
- package/extension/src/shared/sharedSessionBridge.js +288 -0
- package/extension/src/shared/storageDb.js +22 -55
- package/extension/src/shared/storageMigration.js +3 -0
- package/extension/src/shared/storageRunActions.js +10 -4
- package/extension/src/shared/storageValuePruning.js +40 -0
- package/extension/src/shared/subagentActivityModel.js +174 -0
- package/extension/src/shared/undoOperations.js +87 -0
- package/extension/src/shared/updateConsent.js +37 -8
- package/extension/src/shared/writebackIntent.js +62 -0
- package/extension/src/shared/writebackSettlement.js +29 -10
- package/extension/src/shared/writingStyle.js +33 -0
- package/extension/styles/panel.css +1972 -384
- package/extension/styles/popup.css +110 -0
- package/native-host/src/anthropicBridgeRequest.js +2 -1
- package/native-host/src/codexModelRecovery.js +107 -0
- package/native-host/src/codexPromptAssembly.js +2 -0
- package/native-host/src/codexProviderLaunch.js +3 -3
- package/native-host/src/codexRuntimeIdentity.js +1 -0
- package/native-host/src/codexSessionRunner.js +106 -140
- package/native-host/src/codexSessionTiming.js +3 -0
- package/native-host/src/managedInstall.js +5 -4
- package/native-host/src/nativeEnvironment.js +70 -0
- package/native-host/src/nativeQuotas.js +15 -8
- package/native-host/src/overleafWorkspaceRules.js +16 -0
- package/native-host/src/processStopBarrier.js +80 -0
- package/native-host/src/providerModelCatalog.js +4 -3
- package/native-host/src/providerProfile.js +13 -1
- package/native-host/src/providerReasoning.js +9 -5
- package/native-host/src/providerStore.js +4 -0
- package/native-host/src/releaseTransport.js +14 -5
- package/native-host/src/selectionScope.js +58 -0
- package/native-host/src/skills/parallel-subagents/SKILL.md +31 -3
- package/native-host/src/skills/writing-style-builder/SKILL.md +146 -0
- package/native-host/src/subagentBroker.js +102 -98
- package/native-host/src/subagentTelemetry.js +316 -0
- package/native-host/src/subagentWorkspace.js +103 -0
- package/native-host/src/subagentWorkspacePath.js +31 -0
- package/native-host/src/taskRunnerRuntime.js +55 -5
- package/native-host/src/turnAttachments.js +113 -0
- package/native-host/src/updateManager.js +122 -12
- package/native-host/src/updateNetworkControl.js +75 -0
- package/native-host/src/updateTrust.js +21 -2
- package/native-host/src/vendor/pdfjs/LICENSE +177 -0
- package/native-host/src/vendor/pdfjs/SOURCE.txt +3 -0
- package/native-host/src/vendor/pdfjs/cmaps/78-EUC-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/78-EUC-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/78-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/78-RKSJ-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/78-RKSJ-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/78-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/78ms-RKSJ-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/78ms-RKSJ-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/83pv-RKSJ-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/90ms-RKSJ-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/90ms-RKSJ-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/90msp-RKSJ-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/90msp-RKSJ-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/90pv-RKSJ-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/90pv-RKSJ-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Add-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Add-RKSJ-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Add-RKSJ-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Add-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-CNS1-0.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-CNS1-1.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-CNS1-2.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-CNS1-3.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-CNS1-4.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-CNS1-5.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-CNS1-6.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-CNS1-UCS2.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-GB1-0.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-GB1-1.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-GB1-2.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-GB1-3.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-GB1-4.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-GB1-5.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-GB1-UCS2.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-Japan1-0.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-Japan1-1.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-Japan1-2.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-Japan1-3.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-Japan1-4.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-Japan1-5.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-Japan1-6.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-Japan1-UCS2.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-Korea1-0.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-Korea1-1.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-Korea1-2.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-Korea1-UCS2.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/B5-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/B5-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/B5pc-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/B5pc-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/CNS-EUC-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/CNS-EUC-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/CNS1-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/CNS1-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/CNS2-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/CNS2-V.bcmap +3 -0
- package/native-host/src/vendor/pdfjs/cmaps/ETHK-B5-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/ETHK-B5-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/ETen-B5-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/ETen-B5-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/ETenms-B5-H.bcmap +3 -0
- package/native-host/src/vendor/pdfjs/cmaps/ETenms-B5-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/EUC-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/EUC-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Ext-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Ext-RKSJ-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Ext-RKSJ-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Ext-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/GB-EUC-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/GB-EUC-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/GB-H.bcmap +4 -0
- package/native-host/src/vendor/pdfjs/cmaps/GB-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/GBK-EUC-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/GBK-EUC-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/GBK2K-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/GBK2K-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/GBKp-EUC-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/GBKp-EUC-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/GBT-EUC-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/GBT-EUC-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/GBT-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/GBT-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/GBTpc-EUC-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/GBTpc-EUC-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/GBpc-EUC-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/GBpc-EUC-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/HKdla-B5-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/HKdla-B5-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/HKdlb-B5-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/HKdlb-B5-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/HKgccs-B5-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/HKgccs-B5-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/HKm314-B5-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/HKm314-B5-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/HKm471-B5-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/HKm471-B5-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/HKscs-B5-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/HKscs-B5-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Hankaku.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Hiragana.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/KSC-EUC-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/KSC-EUC-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/KSC-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/KSC-Johab-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/KSC-Johab-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/KSC-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/KSCms-UHC-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/KSCms-UHC-HW-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/KSCms-UHC-HW-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/KSCms-UHC-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/KSCpc-EUC-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/KSCpc-EUC-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Katakana.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/LICENSE +36 -0
- package/native-host/src/vendor/pdfjs/cmaps/NWP-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/NWP-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/RKSJ-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/RKSJ-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Roman.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniCNS-UCS2-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniCNS-UCS2-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniCNS-UTF16-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniCNS-UTF16-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniCNS-UTF32-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniCNS-UTF32-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniCNS-UTF8-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniCNS-UTF8-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniGB-UCS2-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniGB-UCS2-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniGB-UTF16-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniGB-UTF16-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniGB-UTF32-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniGB-UTF32-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniGB-UTF8-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniGB-UTF8-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniJIS-UCS2-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniJIS-UCS2-HW-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniJIS-UCS2-HW-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniJIS-UCS2-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniJIS-UTF16-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniJIS-UTF16-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniJIS-UTF32-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniJIS-UTF32-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniJIS-UTF8-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniJIS-UTF8-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniJIS2004-UTF16-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniJIS2004-UTF16-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniJIS2004-UTF32-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniJIS2004-UTF32-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniJIS2004-UTF8-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniJIS2004-UTF8-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniJISPro-UCS2-HW-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniJISPro-UCS2-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniJISPro-UTF8-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniJISX0213-UTF32-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniJISX0213-UTF32-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniJISX02132004-UTF32-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniJISX02132004-UTF32-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniKS-UCS2-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniKS-UCS2-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniKS-UTF16-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniKS-UTF16-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniKS-UTF32-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniKS-UTF32-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniKS-UTF8-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniKS-UTF8-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/WP-Symbol.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/pdf.mjs +26740 -0
- package/native-host/src/vendor/pdfjs/pdf.worker.mjs +62201 -0
- package/native-host/src/vendor/pdfjs/standard_fonts/FoxitDingbats.pfb +0 -0
- package/native-host/src/vendor/pdfjs/standard_fonts/FoxitFixed.pfb +0 -0
- package/native-host/src/vendor/pdfjs/standard_fonts/FoxitFixedBold.pfb +0 -0
- package/native-host/src/vendor/pdfjs/standard_fonts/FoxitFixedBoldItalic.pfb +0 -0
- package/native-host/src/vendor/pdfjs/standard_fonts/FoxitFixedItalic.pfb +0 -0
- package/native-host/src/vendor/pdfjs/standard_fonts/FoxitSerif.pfb +0 -0
- package/native-host/src/vendor/pdfjs/standard_fonts/FoxitSerifBold.pfb +0 -0
- package/native-host/src/vendor/pdfjs/standard_fonts/FoxitSerifBoldItalic.pfb +0 -0
- package/native-host/src/vendor/pdfjs/standard_fonts/FoxitSerifItalic.pfb +0 -0
- package/native-host/src/vendor/pdfjs/standard_fonts/FoxitSymbol.pfb +0 -0
- package/native-host/src/vendor/pdfjs/standard_fonts/LICENSE_FOXIT +27 -0
- package/native-host/src/vendor/pdfjs/standard_fonts/LICENSE_LIBERATION +102 -0
- package/native-host/src/vendor/pdfjs/standard_fonts/LiberationSans-Bold.ttf +0 -0
- package/native-host/src/vendor/pdfjs/standard_fonts/LiberationSans-BoldItalic.ttf +0 -0
- package/native-host/src/vendor/pdfjs/standard_fonts/LiberationSans-Italic.ttf +0 -0
- package/native-host/src/vendor/pdfjs/standard_fonts/LiberationSans-Regular.ttf +0 -0
- package/native-host/src/writingStyleEvidence.js +102 -0
- package/native-host/src/writingStylePdfWorker.js +35 -0
- package/native-host/src/writingStyleProfile.js +165 -0
- package/native-host/src/writingStyleRuntime.js +447 -0
- package/package.json +1 -1
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('node:fs');
|
|
4
|
+
const path = require('node:path');
|
|
5
|
+
const { estimateBase64DecodedBytes } = require('./nativeTransportEnvelope');
|
|
6
|
+
|
|
7
|
+
const TURN_ATTACHMENTS_DIR = '.codex-overleaf-attachments';
|
|
8
|
+
const MAX_TURN_ATTACHMENT_BYTES = 12 * 1024 * 1024;
|
|
9
|
+
const MAX_TURN_ATTACHMENTS = 8;
|
|
10
|
+
const MAX_TURN_ATTACHMENT_TOTAL_BYTES = MAX_TURN_ATTACHMENT_BYTES * MAX_TURN_ATTACHMENTS;
|
|
11
|
+
|
|
12
|
+
function materializeTurnAttachments(attachments = [], workspacePath = '') {
|
|
13
|
+
if (!workspacePath) {
|
|
14
|
+
return [];
|
|
15
|
+
}
|
|
16
|
+
const attachmentDir = path.join(workspacePath, TURN_ATTACHMENTS_DIR);
|
|
17
|
+
fs.rmSync(attachmentDir, { recursive: true, force: true });
|
|
18
|
+
|
|
19
|
+
const normalized = normalizeTurnAttachments(attachments);
|
|
20
|
+
if (!normalized.length) {
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
fs.mkdirSync(attachmentDir, { recursive: true });
|
|
25
|
+
const usedNames = new Set();
|
|
26
|
+
return normalized.map(attachment => {
|
|
27
|
+
const fileName = dedupeAttachmentFileName(attachment.name, usedNames);
|
|
28
|
+
const target = path.join(attachmentDir, fileName);
|
|
29
|
+
const resolvedTarget = path.resolve(target);
|
|
30
|
+
const resolvedDir = path.resolve(attachmentDir);
|
|
31
|
+
if (!resolvedTarget.startsWith(resolvedDir + path.sep)) {
|
|
32
|
+
throw new Error('Unsafe attachment path');
|
|
33
|
+
}
|
|
34
|
+
fs.writeFileSync(target, attachment.bytes);
|
|
35
|
+
return {
|
|
36
|
+
name: fileName,
|
|
37
|
+
path: `${TURN_ATTACHMENTS_DIR}/${fileName}`,
|
|
38
|
+
mimeType: attachment.mimeType,
|
|
39
|
+
size: attachment.bytes.length
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function normalizeTurnAttachments(value) {
|
|
45
|
+
const input = Array.isArray(value) ? value : [];
|
|
46
|
+
if (input.length > MAX_TURN_ATTACHMENTS) {
|
|
47
|
+
throw new Error(`Too many attachments (${input.length}/${MAX_TURN_ATTACHMENTS})`);
|
|
48
|
+
}
|
|
49
|
+
const result = [];
|
|
50
|
+
let totalBytes = 0;
|
|
51
|
+
for (const item of input) {
|
|
52
|
+
const name = sanitizeAttachmentFileName(item?.name);
|
|
53
|
+
const contentBase64 = String(item?.contentBase64 || '').replace(/\s+/g, '');
|
|
54
|
+
if (!name || !contentBase64) {
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
const declared = Number(item?.size);
|
|
58
|
+
const estimatedBytes = Math.max(
|
|
59
|
+
Number.isFinite(declared) && declared > 0 ? declared : 0,
|
|
60
|
+
estimateBase64DecodedBytes(contentBase64)
|
|
61
|
+
);
|
|
62
|
+
if (estimatedBytes > MAX_TURN_ATTACHMENT_BYTES) {
|
|
63
|
+
throw new Error(`Attachment is too large: ${name}`);
|
|
64
|
+
}
|
|
65
|
+
const bytes = Buffer.from(contentBase64, 'base64');
|
|
66
|
+
if (!bytes.length) {
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
if (bytes.length > MAX_TURN_ATTACHMENT_BYTES) {
|
|
70
|
+
throw new Error(`Attachment is too large: ${name}`);
|
|
71
|
+
}
|
|
72
|
+
totalBytes += Math.max(estimatedBytes, bytes.length);
|
|
73
|
+
if (totalBytes > MAX_TURN_ATTACHMENT_TOTAL_BYTES) {
|
|
74
|
+
throw new Error(`Attachments are too large (${totalBytes}/${MAX_TURN_ATTACHMENT_TOTAL_BYTES} bytes)`);
|
|
75
|
+
}
|
|
76
|
+
result.push({
|
|
77
|
+
name,
|
|
78
|
+
mimeType: String(item?.mimeType || '').trim().slice(0, 120),
|
|
79
|
+
bytes
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
return result;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function sanitizeAttachmentFileName(value) {
|
|
86
|
+
const basename = String(value || '')
|
|
87
|
+
.replace(/\0/g, '')
|
|
88
|
+
.replace(/\\/g, '/')
|
|
89
|
+
.split('/')
|
|
90
|
+
.filter(Boolean)
|
|
91
|
+
.pop()
|
|
92
|
+
?.trim()
|
|
93
|
+
.slice(0, 180) || '';
|
|
94
|
+
return basename.replace(/[/:]/g, '-');
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function dedupeAttachmentFileName(name, usedNames) {
|
|
98
|
+
let candidate = name || 'attachment';
|
|
99
|
+
if (!usedNames.has(candidate)) {
|
|
100
|
+
usedNames.add(candidate);
|
|
101
|
+
return candidate;
|
|
102
|
+
}
|
|
103
|
+
const parsed = path.parse(candidate);
|
|
104
|
+
let index = 2;
|
|
105
|
+
do {
|
|
106
|
+
candidate = `${parsed.name}-${index}${parsed.ext}`;
|
|
107
|
+
index += 1;
|
|
108
|
+
} while (usedNames.has(candidate));
|
|
109
|
+
usedNames.add(candidate);
|
|
110
|
+
return candidate;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
module.exports = { materializeTurnAttachments, normalizeTurnAttachments };
|
|
@@ -4,6 +4,7 @@ const crypto = require('node:crypto');
|
|
|
4
4
|
const fs = require('node:fs');
|
|
5
5
|
const path = require('node:path');
|
|
6
6
|
const {
|
|
7
|
+
BOOTSTRAP_PROTOCOL,
|
|
7
8
|
compareSemver,
|
|
8
9
|
isNewerStableVersion,
|
|
9
10
|
parseSemver,
|
|
@@ -12,6 +13,7 @@ const {
|
|
|
12
13
|
} = require('./updateTrust');
|
|
13
14
|
const { extractVerifiedUpdateBundle } = require('./updateArchive');
|
|
14
15
|
const { requestRelease } = require('./releaseTransport');
|
|
16
|
+
const updateNetwork = require('./updateNetworkControl');
|
|
15
17
|
const RUNNING_VERSION = require('../../package.json').version;
|
|
16
18
|
|
|
17
19
|
const GITHUB_LATEST_URL = 'https://github.com/Ghqqqq/codex-overleaf-link/releases/latest';
|
|
@@ -20,6 +22,7 @@ const EXTENSION_MARKER = '.codex-overleaf-managed-extension.json';
|
|
|
20
22
|
const NATIVE_MARKER = '.codex-overleaf-managed-native.json';
|
|
21
23
|
const JOURNAL_FILE = 'transaction.json';
|
|
22
24
|
const CANDIDATE_FILE = 'candidate.json';
|
|
25
|
+
const MANUAL_CANDIDATE_FILE = 'manual-candidate.json';
|
|
23
26
|
const COOLDOWN_FILE = 'cooldowns.json';
|
|
24
27
|
const AUTHORIZATION_FILE = 'authorization.json';
|
|
25
28
|
const MUTATION_LOCK_FILE = 'mutation.lock';
|
|
@@ -38,7 +41,8 @@ const UPDATE_METHODS = new Set([
|
|
|
38
41
|
'update.activate',
|
|
39
42
|
'update.confirm',
|
|
40
43
|
'update.rollback',
|
|
41
|
-
'update.revoke'
|
|
44
|
+
'update.revoke',
|
|
45
|
+
'update.cancel'
|
|
42
46
|
]);
|
|
43
47
|
const LAYOUT_GATED_METHODS = new Set([
|
|
44
48
|
'update.check',
|
|
@@ -64,7 +68,7 @@ async function handleUpdateRequest(request, options = {}) {
|
|
|
64
68
|
return errorResponse(request?.id, 'unknown_update_method', 'Unknown managed update method.');
|
|
65
69
|
}
|
|
66
70
|
try {
|
|
67
|
-
const context = getManagedContext(options);
|
|
71
|
+
const context = { ...getManagedContext(options), operationId: request.params?.operationId || '' };
|
|
68
72
|
if (!context.managed) {
|
|
69
73
|
throw updateError('update_not_managed', 'Run install-managed once to enable coordinated automatic updates.');
|
|
70
74
|
}
|
|
@@ -73,13 +77,15 @@ async function handleUpdateRequest(request, options = {}) {
|
|
|
73
77
|
}
|
|
74
78
|
switch (request.method) {
|
|
75
79
|
case 'update.status':
|
|
76
|
-
return okResponse(request.id,
|
|
80
|
+
return okResponse(request.id, readStatusWithoutWaiting(context));
|
|
77
81
|
case 'update.check':
|
|
78
|
-
return okResponse(request.id, await
|
|
82
|
+
return okResponse(request.id, await runNetworkUpdate(context, request, options,
|
|
83
|
+
networkOptions => checkForUpdate(context, request.params || {}, networkOptions)));
|
|
79
84
|
case 'update.authorize':
|
|
80
85
|
return okResponse(request.id, await withUpdateMutex(context, () => authorizeUpdate(context, request.params || {})));
|
|
81
86
|
case 'update.stage':
|
|
82
|
-
return okResponse(request.id, await
|
|
87
|
+
return okResponse(request.id, await runNetworkUpdate(context, request, options,
|
|
88
|
+
networkOptions => stageCandidate(context, networkOptions)));
|
|
83
89
|
case 'update.canApply':
|
|
84
90
|
return okResponse(request.id, getApplyGate(options));
|
|
85
91
|
case 'update.apply':
|
|
@@ -90,8 +96,18 @@ async function handleUpdateRequest(request, options = {}) {
|
|
|
90
96
|
return okResponse(request.id, await withUpdateMutex(context, () => confirmUpdate(context, request.params || {})));
|
|
91
97
|
case 'update.rollback':
|
|
92
98
|
return okResponse(request.id, await withUpdateMutex(context, () => rollbackUpdate(context, request.params || {})));
|
|
93
|
-
case 'update.
|
|
94
|
-
return okResponse(request.id, await
|
|
99
|
+
case 'update.cancel':
|
|
100
|
+
return okResponse(request.id, await cancelNetworkUpdate(context, request.params || {}));
|
|
101
|
+
case 'update.revoke': {
|
|
102
|
+
const authorization = readAuthorization(context);
|
|
103
|
+
const params = request.params || {};
|
|
104
|
+
if (authorization?.id === params.authorizationId && authorization.targetVersion === params.targetVersion) {
|
|
105
|
+
const operationId = params.operationId || updateNetwork.readLock(context)?.operationId;
|
|
106
|
+
if (operationId) await cancelNetworkUpdate(context, { ...params, operationId });
|
|
107
|
+
}
|
|
108
|
+
return okResponse(request.id, await withUpdateMutex({ ...context, operationId: '' },
|
|
109
|
+
() => revokeUpdate(context, params)));
|
|
110
|
+
}
|
|
95
111
|
default:
|
|
96
112
|
throw updateError('unknown_update_method', 'Unknown managed update method.');
|
|
97
113
|
}
|
|
@@ -100,8 +116,31 @@ async function handleUpdateRequest(request, options = {}) {
|
|
|
100
116
|
}
|
|
101
117
|
}
|
|
102
118
|
|
|
119
|
+
async function runNetworkUpdate(context, request, options, action) {
|
|
120
|
+
const operationId = context.operationId || (isUuid(request.id) ? request.id : crypto.randomUUID());
|
|
121
|
+
const owned = { ...context, operationId };
|
|
122
|
+
return updateNetwork.run(owned, operationId, signal => withUpdateMutex(owned, () => {
|
|
123
|
+
signal.throwIfAborted();
|
|
124
|
+
return action({ ...options, network: { ...options.network, signal } });
|
|
125
|
+
}), options.network?.signal);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
async function cancelNetworkUpdate(context, params) {
|
|
129
|
+
const journal = readJournal(context);
|
|
130
|
+
if (journal && ['activation_pending', 'applying', 'awaiting_health'].includes(journal.state)) {
|
|
131
|
+
throw updateError('update_revoke_too_late', 'The update is already being installed.');
|
|
132
|
+
}
|
|
133
|
+
return updateNetwork.cancel(context, params.operationId);
|
|
134
|
+
}
|
|
135
|
+
|
|
103
136
|
function withUpdateMutex(context, action) {
|
|
104
|
-
const guardedAction = () =>
|
|
137
|
+
const guardedAction = () => {
|
|
138
|
+
updateNetwork.assertActive(context, context.operationId);
|
|
139
|
+
return withUpdateFileLock(context, () => {
|
|
140
|
+
updateNetwork.assertActive(context, context.operationId);
|
|
141
|
+
return action();
|
|
142
|
+
});
|
|
143
|
+
};
|
|
105
144
|
const result = updateMutationTail.then(guardedAction, guardedAction);
|
|
106
145
|
updateMutationTail = result.catch(() => {});
|
|
107
146
|
return result;
|
|
@@ -127,6 +166,7 @@ async function acquireUpdateFileLock(context) {
|
|
|
127
166
|
fs.writeFileSync(descriptor, JSON.stringify({
|
|
128
167
|
token,
|
|
129
168
|
pid: process.pid,
|
|
169
|
+
operationId: context.operationId || '',
|
|
130
170
|
createdAt: Date.now(),
|
|
131
171
|
expiresAt: Date.now() + MUTATION_LOCK_STALE_MS
|
|
132
172
|
}) + '\n');
|
|
@@ -218,6 +258,8 @@ async function checkForUpdate(context, params = {}, options = {}) {
|
|
|
218
258
|
// Invalid cached candidates are treated as cache misses.
|
|
219
259
|
}
|
|
220
260
|
}
|
|
261
|
+
const manual = readManualCandidate(context, currentVersion);
|
|
262
|
+
if (manual) return { ...manual, etag: params.etag || manual.etag || '', cached: true };
|
|
221
263
|
return { managed: true, available: false, reason: 'not_modified', currentVersion, etag: params.etag || '' };
|
|
222
264
|
}
|
|
223
265
|
if (!releaseResponse.ok) {
|
|
@@ -258,10 +300,27 @@ async function checkForUpdate(context, params = {}, options = {}) {
|
|
|
258
300
|
buildReleaseAssetUrl(releaseTag, 'release-manifest.sig'),
|
|
259
301
|
16 * 1024, { ...network, stage: 'release_signature' }
|
|
260
302
|
);
|
|
261
|
-
const manifest = verifySignedReleaseManifest(manifestBytes, signatureBytes);
|
|
303
|
+
const manifest = verifySignedReleaseManifest(manifestBytes, signatureBytes, { allowBootstrapMismatch: true });
|
|
262
304
|
if (manifest.version !== latestVersion || manifest.tag !== releaseTag) {
|
|
263
305
|
throw updateError('update_release_manifest_mismatch', 'GitHub release tag does not match the signed update manifest.');
|
|
264
306
|
}
|
|
307
|
+
if (manifest.bootstrapProtocol !== BOOTSTRAP_PROTOCOL) {
|
|
308
|
+
// Never staged: only a reinstall can replace the Bootstrap shell. The user
|
|
309
|
+
// gets the target version and the signed reason instead of a bare error.
|
|
310
|
+
const manual = {
|
|
311
|
+
managed: true,
|
|
312
|
+
available: false,
|
|
313
|
+
reason: 'manual_install_required',
|
|
314
|
+
currentVersion,
|
|
315
|
+
latestVersion,
|
|
316
|
+
installedBootstrapProtocol: BOOTSTRAP_PROTOCOL,
|
|
317
|
+
requiredBootstrapProtocol: manifest.bootstrapProtocol,
|
|
318
|
+
manualInstall: manifest.manualInstall?.reason ? { reason: manifest.manualInstall.reason } : {},
|
|
319
|
+
etag: releaseResponse.headers.get('etag') || ''
|
|
320
|
+
};
|
|
321
|
+
atomicWriteJson(path.join(context.updatesRoot, MANUAL_CANDIDATE_FILE), { ...manual, checkedAt: new Date().toISOString() });
|
|
322
|
+
return manual;
|
|
323
|
+
}
|
|
265
324
|
const candidate = {
|
|
266
325
|
checkedAt: new Date().toISOString(),
|
|
267
326
|
currentVersion,
|
|
@@ -275,6 +334,15 @@ async function checkForUpdate(context, params = {}, options = {}) {
|
|
|
275
334
|
return { managed: true, available: true, currentVersion, latestVersion, etag: candidate.etag };
|
|
276
335
|
}
|
|
277
336
|
|
|
337
|
+
function readManualCandidate(context, currentVersion) {
|
|
338
|
+
const manual = readJsonSafe(path.join(context.updatesRoot, MANUAL_CANDIDATE_FILE), null);
|
|
339
|
+
if (manual?.reason !== 'manual_install_required' || !parseSemver(manual.latestVersion)
|
|
340
|
+
|| !isNewerStableVersion(manual.latestVersion, currentVersion)
|
|
341
|
+
|| manual.requiredBootstrapProtocol === BOOTSTRAP_PROTOCOL) return null;
|
|
342
|
+
const { checkedAt: _checkedAt, ...result } = manual;
|
|
343
|
+
return { ...result, currentVersion };
|
|
344
|
+
}
|
|
345
|
+
|
|
278
346
|
function readAuthorizedCandidate(context, currentVersion) {
|
|
279
347
|
const authorization = readAuthorization(context);
|
|
280
348
|
if (!authorization || !['authorized', 'bound'].includes(authorization.state)) return null;
|
|
@@ -411,7 +479,13 @@ async function stageCandidate(context, options = {}) {
|
|
|
411
479
|
try {
|
|
412
480
|
const archivePath = path.join(stageRoot, manifest.updateBundle.name);
|
|
413
481
|
const bundleBytes = await fetchReleaseAsset(options.fetch, candidate.bundleUrl, manifest.updateBundle.size + 1,
|
|
414
|
-
{ ...options.network, totalTimeoutMs:
|
|
482
|
+
{ ...options.network, totalTimeoutMs: 300000, timeoutMs: 30000,
|
|
483
|
+
idleTimeoutMs: 30000, stage: 'update_bundle' });
|
|
484
|
+
options.network?.signal?.throwIfAborted();
|
|
485
|
+
const currentAuthorization = requireAuthorization(context, manifest.version, ['authorized', 'bound']);
|
|
486
|
+
if (currentAuthorization.id !== authorization.id) {
|
|
487
|
+
throw updateError('update_consent_mismatch', 'The update authorization changed while downloading.');
|
|
488
|
+
}
|
|
415
489
|
if (bundleBytes.length !== manifest.updateBundle.size) {
|
|
416
490
|
throw updateError('update_bundle_size_mismatch', 'Downloaded update bundle size does not match the signed manifest.');
|
|
417
491
|
}
|
|
@@ -640,6 +714,12 @@ function confirmUpdate(context, params = {}) {
|
|
|
640
714
|
|
|
641
715
|
function rollbackUpdate(context, params = {}) {
|
|
642
716
|
const journal = readJournal(context);
|
|
717
|
+
if (params.transactionId && journal?.id !== params.transactionId) {
|
|
718
|
+
throw updateError('update_transaction_mismatch', 'Rollback transaction identity changed.');
|
|
719
|
+
}
|
|
720
|
+
if (params.expectedState && journal?.state !== params.expectedState) {
|
|
721
|
+
throw updateError('update_transaction_state_changed', 'The update state changed before rollback.');
|
|
722
|
+
}
|
|
643
723
|
if (!journal || !['applying', 'awaiting_health', 'committed'].includes(journal.state)) {
|
|
644
724
|
throw updateError('update_rollback_unavailable', 'No applied update is available for rollback.');
|
|
645
725
|
}
|
|
@@ -783,17 +863,47 @@ function recoverAndReadStatus(context) {
|
|
|
783
863
|
readVersionPointer(context.nativeRoot, 'previous-version')
|
|
784
864
|
]));
|
|
785
865
|
}
|
|
866
|
+
return currentStatus(context, journal);
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
function currentStatus(context, journal = readJournal(context)) {
|
|
786
870
|
return {
|
|
787
871
|
managed: true,
|
|
788
872
|
activeVersion: readVersionPointer(context.nativeRoot, 'active-version'),
|
|
789
873
|
runtimeVersion: context.env?.CODEX_OVERLEAF_ACTIVE_VERSION || RUNNING_VERSION,
|
|
790
|
-
installedAligned: Boolean(
|
|
874
|
+
installedAligned: Boolean(readAlignedManagedVersion(context)),
|
|
791
875
|
previousVersion: readVersionPointer(context.nativeRoot, 'previous-version'),
|
|
792
876
|
transaction: journal ? publicTransaction(journal) : null,
|
|
793
877
|
authorization: publicAuthorization(readAuthorization(context))
|
|
794
878
|
};
|
|
795
879
|
}
|
|
796
880
|
|
|
881
|
+
function readStatusWithoutWaiting(context) {
|
|
882
|
+
const lockPath = path.join(context.updatesRoot, MUTATION_LOCK_FILE);
|
|
883
|
+
const token = crypto.randomUUID();
|
|
884
|
+
let descriptor;
|
|
885
|
+
try {
|
|
886
|
+
descriptor = fs.openSync(lockPath, 'wx', 0o600);
|
|
887
|
+
} catch (error) {
|
|
888
|
+
if (error.code !== 'EEXIST') throw error;
|
|
889
|
+
const owner = readJsonSafe(lockPath, null);
|
|
890
|
+
if (Number.isInteger(owner?.pid) && !isProcessAlive(owner.pid) && removeStaleUpdateFileLock(lockPath)) {
|
|
891
|
+
return readStatusWithoutWaiting(context);
|
|
892
|
+
}
|
|
893
|
+
// A live mutation owns recovery; report an atomic-file snapshot without
|
|
894
|
+
// queueing behind its network transfer or changing its journal.
|
|
895
|
+
return currentStatus(context);
|
|
896
|
+
}
|
|
897
|
+
try {
|
|
898
|
+
fs.writeFileSync(descriptor, JSON.stringify({ token, pid: process.pid,
|
|
899
|
+
createdAt: Date.now(), expiresAt: Date.now() + MUTATION_LOCK_STALE_MS }));
|
|
900
|
+
return recoverAndReadStatus(context);
|
|
901
|
+
} finally {
|
|
902
|
+
fs.closeSync(descriptor);
|
|
903
|
+
releaseUpdateFileLock({ lockPath, token });
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
|
|
797
907
|
function readAlignedManagedVersion(context) {
|
|
798
908
|
try {
|
|
799
909
|
return assertManagedLayout(context);
|
|
@@ -886,7 +996,7 @@ function assertManagedLayout(context) {
|
|
|
886
996
|
}
|
|
887
997
|
|
|
888
998
|
function isManagedMarker(marker, kind) {
|
|
889
|
-
return marker?.managedBy === 'codex-overleaf-link' && marker?.kind === kind && marker?.bootstrapProtocol ===
|
|
999
|
+
return marker?.managedBy === 'codex-overleaf-link' && marker?.kind === kind && marker?.bootstrapProtocol === BOOTSTRAP_PROTOCOL;
|
|
890
1000
|
}
|
|
891
1001
|
|
|
892
1002
|
function verifyStagedPair(payloadRoot, targetVersion) {
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('node:fs');
|
|
4
|
+
const path = require('node:path');
|
|
5
|
+
const { updateError } = require('./updateTrust');
|
|
6
|
+
const controllers = new Map();
|
|
7
|
+
const validId = value => /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i.test(String(value || ''));
|
|
8
|
+
const marker = (context, id) => path.join(context.updatesRoot, 'cancel-' + id);
|
|
9
|
+
|
|
10
|
+
function assertActive(context, id) {
|
|
11
|
+
if (!id) return;
|
|
12
|
+
if (!validId(id)) throw updateError('update_operation_invalid', 'Update operation identity is invalid.');
|
|
13
|
+
if (fs.existsSync(marker(context, id))) throw updateError('update_network_cancelled', 'This update operation was cancelled.');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async function run(context, id, action, callerSignal) {
|
|
17
|
+
assertActive(context, id);
|
|
18
|
+
// Retain cancellation tombstones beyond the lifetime of bounded requests.
|
|
19
|
+
for (const name of fs.readdirSync(context.updatesRoot)) {
|
|
20
|
+
if (!name.startsWith('cancel-') || !validId(name.slice(7))) continue;
|
|
21
|
+
const file = path.join(context.updatesRoot, name);
|
|
22
|
+
try { if (Date.now() - fs.statSync(file).mtimeMs > 86400000) fs.rmSync(file, { force: true }); } catch (_) {}
|
|
23
|
+
}
|
|
24
|
+
const key = context.updatesRoot + ':' + id;
|
|
25
|
+
const controller = new AbortController();
|
|
26
|
+
const entries = controllers.get(key) || new Set();
|
|
27
|
+
entries.add(controller);
|
|
28
|
+
controllers.set(key, entries);
|
|
29
|
+
const abort = () => controller.abort(updateError('update_network_cancelled', 'This update operation was cancelled.'));
|
|
30
|
+
const poll = setInterval(() => { if (fs.existsSync(marker(context, id))) abort(); }, 200);
|
|
31
|
+
poll.unref?.();
|
|
32
|
+
if (callerSignal?.aborted) abort();
|
|
33
|
+
else callerSignal?.addEventListener('abort', abort, { once: true });
|
|
34
|
+
try {
|
|
35
|
+
assertActive(context, id);
|
|
36
|
+
controller.signal.throwIfAborted();
|
|
37
|
+
return await action(controller.signal);
|
|
38
|
+
} finally {
|
|
39
|
+
clearInterval(poll);
|
|
40
|
+
callerSignal?.removeEventListener('abort', abort);
|
|
41
|
+
entries.delete(controller);
|
|
42
|
+
if (!entries.size) controllers.delete(key);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function readLock(context) {
|
|
47
|
+
try { return JSON.parse(fs.readFileSync(path.join(context.updatesRoot, 'mutation.lock'), 'utf8')); }
|
|
48
|
+
catch (_) { return null; }
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function alive(pid) {
|
|
52
|
+
if (!Number.isInteger(pid) || pid <= 0) return false;
|
|
53
|
+
try { process.kill(pid, 0); return true; } catch (error) { return error.code !== 'ESRCH'; }
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async function cancel(context, id) {
|
|
57
|
+
if (!validId(id)) throw updateError('update_operation_invalid', 'Update operation identity is invalid.');
|
|
58
|
+
// A marker also stops an operation queued in another host or delivered late.
|
|
59
|
+
const descriptor = fs.openSync(marker(context, id), 'a', 0o600);
|
|
60
|
+
try { fs.fsyncSync(descriptor); } finally { fs.closeSync(descriptor); }
|
|
61
|
+
for (const controller of controllers.get(context.updatesRoot + ':' + id) || []) {
|
|
62
|
+
controller.abort(updateError('update_network_cancelled', 'This update operation was cancelled.'));
|
|
63
|
+
}
|
|
64
|
+
const deadline = Date.now() + 10000;
|
|
65
|
+
while (true) {
|
|
66
|
+
const lock = readLock(context);
|
|
67
|
+
if (lock?.operationId !== id || !alive(Number(lock.pid))) return { operationId: id, state: 'cancelled' };
|
|
68
|
+
if (Date.now() >= deadline) {
|
|
69
|
+
throw updateError('update_cancel_unconfirmed', 'The download has been interrupted; update cleanup has not finished yet.');
|
|
70
|
+
}
|
|
71
|
+
await new Promise(resolve => setTimeout(resolve, 50));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
module.exports = { assertActive, run, cancel, readLock, validId };
|
|
@@ -5,7 +5,7 @@ const crypto = require('node:crypto');
|
|
|
5
5
|
const UPDATE_REPOSITORY = 'Ghqqqq/codex-overleaf-link';
|
|
6
6
|
const UPDATE_CHANNEL = 'stable';
|
|
7
7
|
const UPDATE_MANIFEST_SCHEMA = 2;
|
|
8
|
-
const BOOTSTRAP_PROTOCOL =
|
|
8
|
+
const BOOTSTRAP_PROTOCOL = 3;
|
|
9
9
|
const TRUSTED_UPDATE_KEYS = Object.freeze({
|
|
10
10
|
'release-2026-01': [
|
|
11
11
|
'-----BEGIN PUBLIC KEY-----',
|
|
@@ -62,9 +62,18 @@ function validateReleaseManifest(manifest, options = {}) {
|
|
|
62
62
|
if (!version || manifest.tag !== expectedTag) {
|
|
63
63
|
throw updateError('update_manifest_version_invalid', 'Update manifest version or tag is invalid.');
|
|
64
64
|
}
|
|
65
|
-
if (!Number.isInteger(manifest.bootstrapProtocol) || manifest.bootstrapProtocol
|
|
65
|
+
if (!Number.isInteger(manifest.bootstrapProtocol) || manifest.bootstrapProtocol < 1) {
|
|
66
|
+
throw updateError('update_manifest_protocol_invalid', 'Update manifest Bootstrap protocol is invalid.');
|
|
67
|
+
}
|
|
68
|
+
// A signed release for another Bootstrap protocol is still a real release:
|
|
69
|
+
// the checker reads it (allowBootstrapMismatch) to tell the user to reinstall,
|
|
70
|
+
// while staging and applying keep refusing it.
|
|
71
|
+
if (manifest.bootstrapProtocol !== bootstrapProtocol && options.allowBootstrapMismatch !== true) {
|
|
66
72
|
throw updateError('update_bootstrap_upgrade_required', 'This release requires a different Bootstrap protocol.');
|
|
67
73
|
}
|
|
74
|
+
if (manifest.manualInstall !== undefined && !isManualInstallNote(manifest.manualInstall)) {
|
|
75
|
+
throw updateError('update_manifest_manual_install_invalid', 'Update manifest manual-install note is invalid.');
|
|
76
|
+
}
|
|
68
77
|
if (!/^[0-9a-f]{40}$/.test(String(manifest.gitCommit || ''))) {
|
|
69
78
|
throw updateError('update_manifest_commit_invalid', 'Update manifest commit is invalid.');
|
|
70
79
|
}
|
|
@@ -88,6 +97,16 @@ function validateReleaseManifest(manifest, options = {}) {
|
|
|
88
97
|
return manifest;
|
|
89
98
|
}
|
|
90
99
|
|
|
100
|
+
// Optional signed note shown when a release cannot be applied in place.
|
|
101
|
+
function isManualInstallNote(value) {
|
|
102
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) return false;
|
|
103
|
+
const reason = value.reason;
|
|
104
|
+
if (reason === undefined) return true;
|
|
105
|
+
return Boolean(reason) && typeof reason === 'object' && !Array.isArray(reason)
|
|
106
|
+
&& Object.entries(reason).every(([locale, text]) => ['en', 'zh'].includes(locale)
|
|
107
|
+
&& typeof text === 'string' && text.length > 0 && text.length <= 400);
|
|
108
|
+
}
|
|
109
|
+
|
|
91
110
|
function parseSemver(value) {
|
|
92
111
|
const match = String(value || '').match(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/);
|
|
93
112
|
if (!match) {
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|