From d4e218c3aff9e714cd6537d1af1357f511752410 Mon Sep 17 00:00:00 2001 From: guanbinrui Date: Fri, 29 Aug 2025 10:51:26 +0800 Subject: [PATCH 01/13] chore: bump version to 2.34.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 91a66f0c2201..79c1e0d593fa 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "yarn": ">=999.0.0", "npm": ">=999.0.0" }, - "version": "2.34.0", + "version": "2.34.1", "private": true, "license": "AGPL-3.0-or-later", "scripts": { From 1e3dbc655cc93a02312bc203269e5ac9c415fc56 Mon Sep 17 00:00:00 2001 From: xylophonez <69069725+xylophonez@users.noreply.github.com> Date: Fri, 29 Aug 2025 01:50:54 +0100 Subject: [PATCH 02/13] chore: migrate load storage provider (#12266) --- .../plugins/FileService/src/Worker/load.ts | 40 +++++++++---------- packages/plugins/FileService/src/constants.ts | 2 +- packages/plugins/FileService/src/helpers.ts | 2 +- 3 files changed, 20 insertions(+), 24 deletions(-) diff --git a/packages/plugins/FileService/src/Worker/load.ts b/packages/plugins/FileService/src/Worker/load.ts index af1cced4cf2f..68eb04cda5ec 100644 --- a/packages/plugins/FileService/src/Worker/load.ts +++ b/packages/plugins/FileService/src/Worker/load.ts @@ -5,9 +5,8 @@ import { LANDING_PAGE, Provider } from '../constants.js' import type { ProviderAgent, LandingPageMetadata, AttachmentOptions } from '../types.js' import { makeFileKeySigned } from '../helpers.js' -const LOAD_GATEWAY_URL = 'https://load0.network/resolve' -const LOAD_UPLOAD_ENDPOINT = 'https://load0.network/upload' -const API_KEY = 'load_acc_ep4bep0uGlmUXMu46BxM0uWXKsqL5M5w' // move to env +const LOAD_GATEWAY_URL = 'https://load-s3-agent.load.network' +const LOAD_UPLOAD_ENDPOINT = 'https://load-s3-agent.load.network/upload' class LoadAgent implements ProviderAgent { static providerName = 'Load Network' @@ -79,36 +78,33 @@ class LoadAgent implements ProviderAgent { try { const blob = new Blob([data], { type }) - const headers = { - 'Content-Type': type, - Filename: fileName, - 'App-Name': 'Maskbook', - 'X-Load-Authorization': API_KEY, - } + const formData = new FormData() + formData.append('file', blob) + formData.append('content_type', type) + formData.append('app_name', 'Maskbook') const response = await fetch(LOAD_UPLOAD_ENDPOINT, { method: 'POST', - headers, - body: blob, - signal: this.uploadController?.signal, + headers: { + 'Authorization': `Bearer ${process.env.LOAD_KEY}` + }, + body: formData, + signal: this.uploadController?.signal }) if (!response.ok) { throw new Error(`Upload failed: ${response.statusText}`) } - const { optimistic_hash } = await response.json() - return optimistic_hash - } catch (error) { - const errorMessage = `Load Network upload failed: ${error instanceof Error ? error.message : String(error)}` - console.error('Load Network detailed error:', errorMessage) - - const enhancedError = new Error(errorMessage) - if (error instanceof Error && error.stack) { - enhancedError.stack = error.stack + const result = await response.json() + if (!result.success || !result.dataitem_id) { + throw new Error('Invalid response from upload service') } - throw enhancedError + return result.dataitem_id + } + catch (error) { + throw error } } } diff --git a/packages/plugins/FileService/src/constants.ts b/packages/plugins/FileService/src/constants.ts index d90b2d8b1497..77bb50e7053b 100644 --- a/packages/plugins/FileService/src/constants.ts +++ b/packages/plugins/FileService/src/constants.ts @@ -3,7 +3,7 @@ export const META_KEY_2 = 'com.maskbook.fileservice:2' export const META_KEY_3 = 'com.maskbook.fileservice:3' export const MAX_FILE_SIZE = 10 * 1000 * 1000 -export const MAX_FILE_SIZE_LOAD = 10 * 1024 * 1024 +export const MAX_FILE_SIZE_LOAD = 100 * 1024 * 1024 export const LANDING_PAGE = 'https://files.r2d2.to/partner/arweave/landing-page.html' export const RECOVERY_PAGE = 'https://fileservice.r2d2.to/recover' diff --git a/packages/plugins/FileService/src/helpers.ts b/packages/plugins/FileService/src/helpers.ts index 40050b3e5166..454d0482cf3c 100644 --- a/packages/plugins/FileService/src/helpers.ts +++ b/packages/plugins/FileService/src/helpers.ts @@ -45,7 +45,7 @@ const resolveGatewayAPI = createLookupTableResolver( { [Provider.Arweave]: 'https://arweave.net', [Provider.IPFS]: 'https://mask.infura-ipfs.io/ipfs', - [Provider.Load]: 'https://load0.network/resolve', + [Provider.Load]: 'https://load-s3-agent.load.network', }, () => 'Unknown provider', ) From fd513e416df532d0d0dc2b09007610952ff07a42 Mon Sep 17 00:00:00 2001 From: guanbinrui Date: Fri, 29 Aug 2025 00:59:42 +0000 Subject: [PATCH 03/13] fix: linter --- packages/plugins/FileService/src/Worker/load.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/plugins/FileService/src/Worker/load.ts b/packages/plugins/FileService/src/Worker/load.ts index 68eb04cda5ec..8336470e16ca 100644 --- a/packages/plugins/FileService/src/Worker/load.ts +++ b/packages/plugins/FileService/src/Worker/load.ts @@ -86,10 +86,10 @@ class LoadAgent implements ProviderAgent { const response = await fetch(LOAD_UPLOAD_ENDPOINT, { method: 'POST', headers: { - 'Authorization': `Bearer ${process.env.LOAD_KEY}` + Authorization: `Bearer ${process.env.LOAD_KEY}`, }, body: formData, - signal: this.uploadController?.signal + signal: this.uploadController?.signal, }) if (!response.ok) { @@ -102,8 +102,7 @@ class LoadAgent implements ProviderAgent { } return result.dataitem_id - } - catch (error) { + } catch (error) { throw error } } From 15b52ff9f157cb5bcbe9e6f1d9d8303e3b40f03c Mon Sep 17 00:00:00 2001 From: guanbinrui <52657989+guanbinrui@users.noreply.github.com> Date: Fri, 29 Aug 2025 09:18:25 +0800 Subject: [PATCH 04/13] chore: update key name (#12267) * chore: update key name * refactor: rm unnecessary try-catch * fix: cspell * chore: ignore patches on cspell --- cspell.json | 2 + .../plugins/FileService/src/Worker/load.ts | 50 ++++++++----------- 2 files changed, 24 insertions(+), 28 deletions(-) diff --git a/cspell.json b/cspell.json index 3845dfee63bb..3467b4e789e8 100644 --- a/cspell.json +++ b/cspell.json @@ -7,6 +7,7 @@ "./packages/icons/**", "./packages/mask/swap/webgl/**", "./packages/web3-contracts/types/**", + "./patches/**", ".github", ".gitignore", ".patch", @@ -66,6 +67,7 @@ "cyberconnect", "cyberlab", "darkweb", + "dataitem", "debank", "deficonnect", "devnet", diff --git a/packages/plugins/FileService/src/Worker/load.ts b/packages/plugins/FileService/src/Worker/load.ts index 8336470e16ca..d5593945cc81 100644 --- a/packages/plugins/FileService/src/Worker/load.ts +++ b/packages/plugins/FileService/src/Worker/load.ts @@ -67,44 +67,38 @@ class LoadAgent implements ProviderAgent { .replace('__METADATA__', encodedMetadata) const data = encodeText(replaced) - const landingPageTxId = await this.makePayload(data, 'text/html', `${metadata.name}-landing.html`) - return landingPageTxId } async makePayload(data: Uint8Array, type: string, fileName: string = 'file.dat') { this.init() - try { - const blob = new Blob([data], { type }) - const formData = new FormData() - formData.append('file', blob) - formData.append('content_type', type) - formData.append('app_name', 'Maskbook') - - const response = await fetch(LOAD_UPLOAD_ENDPOINT, { - method: 'POST', - headers: { - Authorization: `Bearer ${process.env.LOAD_KEY}`, - }, - body: formData, - signal: this.uploadController?.signal, - }) - - if (!response.ok) { - throw new Error(`Upload failed: ${response.statusText}`) - } + const blob = new Blob([data], { type }) + const formData = new FormData() + formData.append('file', blob) + formData.append('content_type', type) + formData.append('app_name', 'Maskbook') + + const response = await fetch(LOAD_UPLOAD_ENDPOINT, { + method: 'POST', + headers: { + Authorization: `Bearer ${process.env.LOAD_NETWORK_KEY}`, + }, + body: formData, + signal: this.uploadController?.signal, + }) - const result = await response.json() - if (!result.success || !result.dataitem_id) { - throw new Error('Invalid response from upload service') - } + if (!response.ok) { + throw new Error(`Upload failed: ${response.statusText}`) + } - return result.dataitem_id - } catch (error) { - throw error + const result = await response.json() + if (!result.success || !result.dataitem_id) { + throw new Error('Invalid response from upload service') } + + return result.dataitem_id } } From 264375a49d96c7d785d39b6afede48e394e4fd39 Mon Sep 17 00:00:00 2001 From: guanbinrui Date: Fri, 29 Aug 2025 20:01:39 +0800 Subject: [PATCH 05/13] fix: LOAD_NETWORK_ENV --- packages/mask/.webpack/config.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/mask/.webpack/config.ts b/packages/mask/.webpack/config.ts index cc3369ea2771..526d9c607f0b 100644 --- a/packages/mask/.webpack/config.ts +++ b/packages/mask/.webpack/config.ts @@ -239,6 +239,7 @@ export async function createConfiguration( SOLANA_DEFAULT_RPC_URL: process.env.SOLANA_DEFAULT_RPC_URL || '', MASK_ENABLE_EXCHANGE: process.env.MASK_ENABLE_EXCHANGE || '', GOOGLE_CLIENT_ID: JSON.stringify(process.env.GOOGLE_CLIENT_ID) || '', + LOAD_NETWORK_KEY: process.env.LOAD_NETWORK_KEY || '', }), new (rspack?.DefinePlugin || webpack.default.DefinePlugin)({ 'process.browser': 'true', From 74229f0662cbdc09e530d5b592868e55be283d6a Mon Sep 17 00:00:00 2001 From: Xylophone Date: Thu, 28 Aug 2025 10:46:02 +0100 Subject: [PATCH 06/13] chore: migrate load storage provider --- packages/plugins/FileService/src/Worker/load.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/plugins/FileService/src/Worker/load.ts b/packages/plugins/FileService/src/Worker/load.ts index d5593945cc81..1af30f9dfb5d 100644 --- a/packages/plugins/FileService/src/Worker/load.ts +++ b/packages/plugins/FileService/src/Worker/load.ts @@ -83,7 +83,7 @@ class LoadAgent implements ProviderAgent { const response = await fetch(LOAD_UPLOAD_ENDPOINT, { method: 'POST', headers: { - Authorization: `Bearer ${process.env.LOAD_NETWORK_KEY}`, + Authorization: `Bearer ${process.env.LOAD_KEY}`, }, body: formData, signal: this.uploadController?.signal, From b2720e5b4f73b89f222828105f9bd00e69759117 Mon Sep 17 00:00:00 2001 From: Xylophone Date: Fri, 29 Aug 2025 12:51:03 +0100 Subject: [PATCH 07/13] fix: conditional legacy gateway, .env, 30MB limit --- packages/mask/.webpack/config.ts | 58 +++++++++---------- .../plugins/FileService/src/Worker/load.ts | 9 ++- packages/plugins/FileService/src/constants.ts | 2 +- packages/plugins/FileService/src/helpers.ts | 11 +++- 4 files changed, 48 insertions(+), 32 deletions(-) diff --git a/packages/mask/.webpack/config.ts b/packages/mask/.webpack/config.ts index 526d9c607f0b..bd11796a6780 100644 --- a/packages/mask/.webpack/config.ts +++ b/packages/mask/.webpack/config.ts @@ -50,7 +50,7 @@ export async function createConfiguration( console.error("Environment variable WEB3_CONSTANTS_RPC should be JSON.stringify'ed twice") WEB3_CONSTANTS_RPC = JSON.stringify(WEB3_CONSTANTS_RPC) } - } catch (err) {} + } catch (err) { } } const baseConfig = { name: 'mask', @@ -68,7 +68,7 @@ export async function createConfiguration( experiments: rspack ? { futureDefaults: true } - : { + : { futureDefaults: true, syncImportAssertion: true, deferImport: { asyncModule: 'error' }, @@ -100,8 +100,8 @@ export async function createConfiguration( alias[require.resolve('@pmmmwh/react-refresh-webpack-plugin/client/ReactRefreshEntry.js')] = // alias[ - join(require.resolve('@rspack/plugin-react-refresh/package.json'), '../') + - 'client/reactRefreshEntry.js' + join(require.resolve('@rspack/plugin-react-refresh/package.json'), '../') + + 'client/reactRefreshEntry.js' ] = require.resolve('./package-overrides/null.mjs') } return alias @@ -128,7 +128,7 @@ export async function createConfiguration( // Source map for libraries !rspack && computedFlags.sourceMapKind ? { test: /\.js$/, enforce: 'pre', use: [require.resolve('source-map-loader')] } - : null, + : null, // TypeScript { test: /\.[mc]?[jt]sx?$/i, @@ -172,7 +172,7 @@ export async function createConfiguration( sources: (x) => x.endsWith('.tsx') || !!x.match(/use[A-Z]/), }), } - : undefined!, + : undefined!, ].filter(Boolean), }, // compress svg files @@ -190,7 +190,7 @@ export async function createConfiguration( dependency: 'url', type: 'asset/resource', } - : null, + : null, ], }, plugins: [ @@ -204,7 +204,7 @@ export async function createConfiguration( runChecks: true, diagnosticsVerbosity: 1, }) - : undefined, + : undefined, new WebExtensionPlugin({ background: { pageEntry: 'background', serviceWorkerEntry: 'backgroundWorker' }, experimental_output: { @@ -214,13 +214,13 @@ export async function createConfiguration( }), // this slow down performance for rspack !rspack && - flags.sourceMapHideFrameworks !== false && - new DevtoolsIgnorePlugin({ - shouldIgnorePath: (path) => { - if (path.includes('masknet') || path.includes('dimensiondev')) return false - return path.includes('/node_modules/') || path.includes('/webpack/') - }, - }), + flags.sourceMapHideFrameworks !== false && + new DevtoolsIgnorePlugin({ + shouldIgnorePath: (path) => { + if (path.includes('masknet') || path.includes('dimensiondev')) return false + return path.includes('/node_modules/') || path.includes('/webpack/') + }, + }), new (rspack?.ProvidePlugin || webpack.default.ProvidePlugin)({ // Widely used Node.js global variable Buffer: [require.resolve('buffer'), 'Buffer'], @@ -239,7 +239,7 @@ export async function createConfiguration( SOLANA_DEFAULT_RPC_URL: process.env.SOLANA_DEFAULT_RPC_URL || '', MASK_ENABLE_EXCHANGE: process.env.MASK_ENABLE_EXCHANGE || '', GOOGLE_CLIENT_ID: JSON.stringify(process.env.GOOGLE_CLIENT_ID) || '', - LOAD_NETWORK_KEY: process.env.LOAD_NETWORK_KEY || '', + LOAD_KEY: process.env.LOAD_KEY || '', }), new (rspack?.DefinePlugin || webpack.default.DefinePlugin)({ 'process.browser': 'true', @@ -250,11 +250,11 @@ export async function createConfiguration( 'process.stderr': '/* stdin */ null', }), flags.reactRefresh && - new ( - await (rspack ? - import('@rspack/plugin-react-refresh') - : import('@pmmmwh/react-refresh-webpack-plugin')) - ).default({ overlay: false, esModule: true }), + new ( + await (rspack ? + import('@rspack/plugin-react-refresh') + : import('@pmmmwh/react-refresh-webpack-plugin')) + ).default({ overlay: false, esModule: true }), flags.profiling && new ProfilingPlugin(), // TODO: crashes rspack !rspack && new TrustedTypesPlugin(), @@ -277,14 +277,14 @@ export async function createConfiguration( from: productionLike ? require.resolve('webextension-polyfill/dist/browser-polyfill.min.js') - : require.resolve('webextension-polyfill/dist/browser-polyfill.js'), + : require.resolve('webextension-polyfill/dist/browser-polyfill.js'), to: join(polyfillFolder, 'browser-polyfill.js'), }, { from: productionLike ? require.resolve('../../../node_modules/ses/dist/lockdown.umd.min.js') - : require.resolve('../../../node_modules/ses/dist/lockdown.umd.js'), + : require.resolve('../../../node_modules/ses/dist/lockdown.umd.js'), to: join(polyfillFolder, 'lockdown.js'), }, { @@ -317,8 +317,8 @@ export async function createConfiguration( chunkIds: productionLike ? rspack ? 'deterministic' - : 'total-size' - : 'named', + : 'total-size' + : 'named', concatenateModules: productionLike, flagIncludedChunks: productionLike, mangleExports: false, @@ -361,8 +361,8 @@ export async function createConfiguration( return ( entry.name === 'backgroundWorker' ? rspack ? 'runtime_' + entry.name - : (false as any as string) - : 'runtime' + : (false as any as string) + : 'runtime' ) }, }, @@ -399,7 +399,7 @@ export async function createConfiguration( devtoolModuleFilenameTemplate: productionLike ? 'webpack://[namespace]/[resource-path]' - : join(import.meta.dirname, '../../../[resource-path]'), + : join(import.meta.dirname, '../../../[resource-path]'), globalObject: 'globalThis', publicPath: '/', clean: flags.mode === 'production', @@ -408,7 +408,7 @@ export async function createConfiguration( { policyName: 'webpack', } - : undefined, + : undefined, }, ignoreWarnings: [ /Failed to parse source map/, diff --git a/packages/plugins/FileService/src/Worker/load.ts b/packages/plugins/FileService/src/Worker/load.ts index 1af30f9dfb5d..1bbe1d92967f 100644 --- a/packages/plugins/FileService/src/Worker/load.ts +++ b/packages/plugins/FileService/src/Worker/load.ts @@ -5,8 +5,10 @@ import { LANDING_PAGE, Provider } from '../constants.js' import type { ProviderAgent, LandingPageMetadata, AttachmentOptions } from '../types.js' import { makeFileKeySigned } from '../helpers.js' +const LOAD_LEGACY_GATEWAY_URL = 'https://load0.network/download' const LOAD_GATEWAY_URL = 'https://load-s3-agent.load.network' const LOAD_UPLOAD_ENDPOINT = 'https://load-s3-agent.load.network/upload' +const LEGACY_ID_REGEX = /^0x[a-f0-9]{64}$/i class LoadAgent implements ProviderAgent { static providerName = 'Load Network' @@ -50,7 +52,11 @@ class LoadAgent implements ProviderAgent { async uploadLandingPage(metadata: LandingPageMetadata) { this.init() - const linkPrefix = LOAD_GATEWAY_URL + // decide which gateway URL to use based on ID + const linkPrefix = LEGACY_ID_REGEX.test(metadata.txId) + ? LOAD_LEGACY_GATEWAY_URL + : LOAD_GATEWAY_URL + const encodedMetadata = JSON.stringify({ name: metadata.name, size: metadata.size, @@ -59,6 +65,7 @@ class LoadAgent implements ProviderAgent { signed: await makeFileKeySigned(metadata.key), createdAt: new Date().toISOString(), }) + const response = await fetch(LANDING_PAGE) const text = await response.text() const replaced = text diff --git a/packages/plugins/FileService/src/constants.ts b/packages/plugins/FileService/src/constants.ts index 77bb50e7053b..9a09f5d424ea 100644 --- a/packages/plugins/FileService/src/constants.ts +++ b/packages/plugins/FileService/src/constants.ts @@ -3,7 +3,7 @@ export const META_KEY_2 = 'com.maskbook.fileservice:2' export const META_KEY_3 = 'com.maskbook.fileservice:3' export const MAX_FILE_SIZE = 10 * 1000 * 1000 -export const MAX_FILE_SIZE_LOAD = 100 * 1024 * 1024 +export const MAX_FILE_SIZE_LOAD = 30 * 1024 * 1024 export const LANDING_PAGE = 'https://files.r2d2.to/partner/arweave/landing-page.html' export const RECOVERY_PAGE = 'https://fileservice.r2d2.to/recover' diff --git a/packages/plugins/FileService/src/helpers.ts b/packages/plugins/FileService/src/helpers.ts index 454d0482cf3c..3d87c85620b6 100644 --- a/packages/plugins/FileService/src/helpers.ts +++ b/packages/plugins/FileService/src/helpers.ts @@ -13,6 +13,10 @@ import schemaV1 from './schema-v1.json' with { type: 'json' } import schemaV2 from './schema-v2.json' with { type: 'json' } import schemaV3 from './schema-v3.json' with { type: 'json' } +// Load legacy detection + gateway +const LEGACY_ID_REGEX = /^0x[a-f0-9]{64}$/i +const LOAD_LEGACY_GATEWAY_URL = 'https://load0.network/download' + // Note: if the latest version has been changed, please update packages/mask/content-script/components/CompositionDialog/useSubmit.ts const reader_v1 = createTypedMessageMetadataReader(META_KEY_1, schemaV1) const reader_v2 = createTypedMessageMetadataReader(META_KEY_2, schemaV2) @@ -61,7 +65,12 @@ export function makeFileKey(length = 16) { } export function downloadFile(file: FileInfo) { - const gateway = resolveGatewayAPI(file.provider) + let gateway = resolveGatewayAPI(file.provider) + + if (file.provider === Provider.Load && LEGACY_ID_REGEX.test(String(file.landingTxID ?? ''))) { + gateway = LOAD_LEGACY_GATEWAY_URL + } + let link = urlcat(gateway, '/:txId', { txId: file.landingTxID }) if (isAfter(new Date(2022, 8, 1), new Date(file.createdAt))) { link = urlcat(RECOVERY_PAGE, { From e9337640af823803d0466fa7c1aaf52774326a3b Mon Sep 17 00:00:00 2001 From: guanbinrui Date: Fri, 29 Aug 2025 20:35:35 +0800 Subject: [PATCH 08/13] fix: lint & format --- packages/mask/.webpack/config.ts | 58 ++++++++++--------- .../plugins/FileService/src/Worker/load.ts | 4 +- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/packages/mask/.webpack/config.ts b/packages/mask/.webpack/config.ts index bd11796a6780..3601d8a1bf6c 100644 --- a/packages/mask/.webpack/config.ts +++ b/packages/mask/.webpack/config.ts @@ -50,7 +50,9 @@ export async function createConfiguration( console.error("Environment variable WEB3_CONSTANTS_RPC should be JSON.stringify'ed twice") WEB3_CONSTANTS_RPC = JSON.stringify(WEB3_CONSTANTS_RPC) } - } catch (err) { } + } catch (err) { + console.error('Environment variable WEB3_CONSTANTS_RPC is not valid JSON') + } } const baseConfig = { name: 'mask', @@ -68,7 +70,7 @@ export async function createConfiguration( experiments: rspack ? { futureDefaults: true } - : { + : { futureDefaults: true, syncImportAssertion: true, deferImport: { asyncModule: 'error' }, @@ -100,8 +102,8 @@ export async function createConfiguration( alias[require.resolve('@pmmmwh/react-refresh-webpack-plugin/client/ReactRefreshEntry.js')] = // alias[ - join(require.resolve('@rspack/plugin-react-refresh/package.json'), '../') + - 'client/reactRefreshEntry.js' + join(require.resolve('@rspack/plugin-react-refresh/package.json'), '../') + + 'client/reactRefreshEntry.js' ] = require.resolve('./package-overrides/null.mjs') } return alias @@ -128,7 +130,7 @@ export async function createConfiguration( // Source map for libraries !rspack && computedFlags.sourceMapKind ? { test: /\.js$/, enforce: 'pre', use: [require.resolve('source-map-loader')] } - : null, + : null, // TypeScript { test: /\.[mc]?[jt]sx?$/i, @@ -172,7 +174,7 @@ export async function createConfiguration( sources: (x) => x.endsWith('.tsx') || !!x.match(/use[A-Z]/), }), } - : undefined!, + : undefined!, ].filter(Boolean), }, // compress svg files @@ -190,7 +192,7 @@ export async function createConfiguration( dependency: 'url', type: 'asset/resource', } - : null, + : null, ], }, plugins: [ @@ -204,7 +206,7 @@ export async function createConfiguration( runChecks: true, diagnosticsVerbosity: 1, }) - : undefined, + : undefined, new WebExtensionPlugin({ background: { pageEntry: 'background', serviceWorkerEntry: 'backgroundWorker' }, experimental_output: { @@ -214,13 +216,13 @@ export async function createConfiguration( }), // this slow down performance for rspack !rspack && - flags.sourceMapHideFrameworks !== false && - new DevtoolsIgnorePlugin({ - shouldIgnorePath: (path) => { - if (path.includes('masknet') || path.includes('dimensiondev')) return false - return path.includes('/node_modules/') || path.includes('/webpack/') - }, - }), + flags.sourceMapHideFrameworks !== false && + new DevtoolsIgnorePlugin({ + shouldIgnorePath: (path) => { + if (path.includes('masknet') || path.includes('dimensiondev')) return false + return path.includes('/node_modules/') || path.includes('/webpack/') + }, + }), new (rspack?.ProvidePlugin || webpack.default.ProvidePlugin)({ // Widely used Node.js global variable Buffer: [require.resolve('buffer'), 'Buffer'], @@ -250,11 +252,11 @@ export async function createConfiguration( 'process.stderr': '/* stdin */ null', }), flags.reactRefresh && - new ( - await (rspack ? - import('@rspack/plugin-react-refresh') - : import('@pmmmwh/react-refresh-webpack-plugin')) - ).default({ overlay: false, esModule: true }), + new ( + await (rspack ? + import('@rspack/plugin-react-refresh') + : import('@pmmmwh/react-refresh-webpack-plugin')) + ).default({ overlay: false, esModule: true }), flags.profiling && new ProfilingPlugin(), // TODO: crashes rspack !rspack && new TrustedTypesPlugin(), @@ -277,14 +279,14 @@ export async function createConfiguration( from: productionLike ? require.resolve('webextension-polyfill/dist/browser-polyfill.min.js') - : require.resolve('webextension-polyfill/dist/browser-polyfill.js'), + : require.resolve('webextension-polyfill/dist/browser-polyfill.js'), to: join(polyfillFolder, 'browser-polyfill.js'), }, { from: productionLike ? require.resolve('../../../node_modules/ses/dist/lockdown.umd.min.js') - : require.resolve('../../../node_modules/ses/dist/lockdown.umd.js'), + : require.resolve('../../../node_modules/ses/dist/lockdown.umd.js'), to: join(polyfillFolder, 'lockdown.js'), }, { @@ -317,8 +319,8 @@ export async function createConfiguration( chunkIds: productionLike ? rspack ? 'deterministic' - : 'total-size' - : 'named', + : 'total-size' + : 'named', concatenateModules: productionLike, flagIncludedChunks: productionLike, mangleExports: false, @@ -361,8 +363,8 @@ export async function createConfiguration( return ( entry.name === 'backgroundWorker' ? rspack ? 'runtime_' + entry.name - : (false as any as string) - : 'runtime' + : (false as any as string) + : 'runtime' ) }, }, @@ -399,7 +401,7 @@ export async function createConfiguration( devtoolModuleFilenameTemplate: productionLike ? 'webpack://[namespace]/[resource-path]' - : join(import.meta.dirname, '../../../[resource-path]'), + : join(import.meta.dirname, '../../../[resource-path]'), globalObject: 'globalThis', publicPath: '/', clean: flags.mode === 'production', @@ -408,7 +410,7 @@ export async function createConfiguration( { policyName: 'webpack', } - : undefined, + : undefined, }, ignoreWarnings: [ /Failed to parse source map/, diff --git a/packages/plugins/FileService/src/Worker/load.ts b/packages/plugins/FileService/src/Worker/load.ts index 1bbe1d92967f..81cab36b477a 100644 --- a/packages/plugins/FileService/src/Worker/load.ts +++ b/packages/plugins/FileService/src/Worker/load.ts @@ -53,9 +53,7 @@ class LoadAgent implements ProviderAgent { async uploadLandingPage(metadata: LandingPageMetadata) { this.init() // decide which gateway URL to use based on ID - const linkPrefix = LEGACY_ID_REGEX.test(metadata.txId) - ? LOAD_LEGACY_GATEWAY_URL - : LOAD_GATEWAY_URL + const linkPrefix = LEGACY_ID_REGEX.test(metadata.txId) ? LOAD_LEGACY_GATEWAY_URL : LOAD_GATEWAY_URL const encodedMetadata = JSON.stringify({ name: metadata.name, From 1f88bfb219d89777caa4621c008315856a3c4871 Mon Sep 17 00:00:00 2001 From: guanbinrui Date: Fri, 29 Aug 2025 20:57:43 +0800 Subject: [PATCH 09/13] refactor: file service --- packages/plugins/FileService/src/Worker/load.ts | 6 ++---- packages/plugins/FileService/src/helpers.ts | 6 +++--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/plugins/FileService/src/Worker/load.ts b/packages/plugins/FileService/src/Worker/load.ts index 81cab36b477a..b8b66836ae63 100644 --- a/packages/plugins/FileService/src/Worker/load.ts +++ b/packages/plugins/FileService/src/Worker/load.ts @@ -3,12 +3,10 @@ import { Attachment } from '@dimensiondev/common-protocols' import { encodeText } from '@masknet/kit' import { LANDING_PAGE, Provider } from '../constants.js' import type { ProviderAgent, LandingPageMetadata, AttachmentOptions } from '../types.js' -import { makeFileKeySigned } from '../helpers.js' +import { LOAD_LEGACY_GATEWAY_URL, LOAD_LEGACY_ID_REGEX, makeFileKeySigned } from '../helpers.js' -const LOAD_LEGACY_GATEWAY_URL = 'https://load0.network/download' const LOAD_GATEWAY_URL = 'https://load-s3-agent.load.network' const LOAD_UPLOAD_ENDPOINT = 'https://load-s3-agent.load.network/upload' -const LEGACY_ID_REGEX = /^0x[a-f0-9]{64}$/i class LoadAgent implements ProviderAgent { static providerName = 'Load Network' @@ -53,7 +51,7 @@ class LoadAgent implements ProviderAgent { async uploadLandingPage(metadata: LandingPageMetadata) { this.init() // decide which gateway URL to use based on ID - const linkPrefix = LEGACY_ID_REGEX.test(metadata.txId) ? LOAD_LEGACY_GATEWAY_URL : LOAD_GATEWAY_URL + const linkPrefix = LOAD_LEGACY_ID_REGEX.test(metadata.txId) ? LOAD_LEGACY_GATEWAY_URL : LOAD_GATEWAY_URL const encodedMetadata = JSON.stringify({ name: metadata.name, diff --git a/packages/plugins/FileService/src/helpers.ts b/packages/plugins/FileService/src/helpers.ts index 3d87c85620b6..67af3a0dbdaa 100644 --- a/packages/plugins/FileService/src/helpers.ts +++ b/packages/plugins/FileService/src/helpers.ts @@ -14,8 +14,8 @@ import schemaV2 from './schema-v2.json' with { type: 'json' } import schemaV3 from './schema-v3.json' with { type: 'json' } // Load legacy detection + gateway -const LEGACY_ID_REGEX = /^0x[a-f0-9]{64}$/i -const LOAD_LEGACY_GATEWAY_URL = 'https://load0.network/download' +export const LOAD_LEGACY_ID_REGEX = /^0x[a-f0-9]{64}$/i +export const LOAD_LEGACY_GATEWAY_URL = 'https://load0.network/download' // Note: if the latest version has been changed, please update packages/mask/content-script/components/CompositionDialog/useSubmit.ts const reader_v1 = createTypedMessageMetadataReader(META_KEY_1, schemaV1) @@ -67,7 +67,7 @@ export function makeFileKey(length = 16) { export function downloadFile(file: FileInfo) { let gateway = resolveGatewayAPI(file.provider) - if (file.provider === Provider.Load && LEGACY_ID_REGEX.test(String(file.landingTxID ?? ''))) { + if (file.provider === Provider.Load && LOAD_LEGACY_ID_REGEX.test(String(file.landingTxID ?? ''))) { gateway = LOAD_LEGACY_GATEWAY_URL } From aaeba6146ca8f6cf06ad02a61e5375ff573ddf93 Mon Sep 17 00:00:00 2001 From: guanbinrui Date: Sat, 30 Aug 2025 09:39:39 +0800 Subject: [PATCH 10/13] fix: u flag --- packages/plugins/FileService/src/helpers.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/plugins/FileService/src/helpers.ts b/packages/plugins/FileService/src/helpers.ts index 67af3a0dbdaa..0cfcfe828a48 100644 --- a/packages/plugins/FileService/src/helpers.ts +++ b/packages/plugins/FileService/src/helpers.ts @@ -14,7 +14,7 @@ import schemaV2 from './schema-v2.json' with { type: 'json' } import schemaV3 from './schema-v3.json' with { type: 'json' } // Load legacy detection + gateway -export const LOAD_LEGACY_ID_REGEX = /^0x[a-f0-9]{64}$/i +export const LOAD_LEGACY_ID_REGEX = /^0x[a-f0-9]{64}$/iu export const LOAD_LEGACY_GATEWAY_URL = 'https://load0.network/download' // Note: if the latest version has been changed, please update packages/mask/content-script/components/CompositionDialog/useSubmit.ts From eada080b46ad57e7ecd622a503ec703768723897 Mon Sep 17 00:00:00 2001 From: guanbinrui Date: Wed, 24 Sep 2025 17:42:14 +0800 Subject: [PATCH 11/13] chore: hardcode key --- packages/plugins/FileService/src/Worker/load.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/plugins/FileService/src/Worker/load.ts b/packages/plugins/FileService/src/Worker/load.ts index b8b66836ae63..98577354eb13 100644 --- a/packages/plugins/FileService/src/Worker/load.ts +++ b/packages/plugins/FileService/src/Worker/load.ts @@ -86,7 +86,7 @@ class LoadAgent implements ProviderAgent { const response = await fetch(LOAD_UPLOAD_ENDPOINT, { method: 'POST', headers: { - Authorization: `Bearer ${process.env.LOAD_KEY}`, + Authorization: `Bearer maskMASKhbs3`, }, body: formData, signal: this.uploadController?.signal, From 1e0417ec05c9dfd0040c6c60f363b4a9fd1491fe Mon Sep 17 00:00:00 2001 From: guanbinrui Date: Wed, 24 Sep 2025 09:47:08 +0000 Subject: [PATCH 12/13] fix: eslint --- packages/plugins/FileService/src/Worker/load.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/plugins/FileService/src/Worker/load.ts b/packages/plugins/FileService/src/Worker/load.ts index 98577354eb13..bafd35563823 100644 --- a/packages/plugins/FileService/src/Worker/load.ts +++ b/packages/plugins/FileService/src/Worker/load.ts @@ -86,7 +86,7 @@ class LoadAgent implements ProviderAgent { const response = await fetch(LOAD_UPLOAD_ENDPOINT, { method: 'POST', headers: { - Authorization: `Bearer maskMASKhbs3`, + Authorization: "Bearer maskMASKhbs3", }, body: formData, signal: this.uploadController?.signal, From 78a545eb95686d86e3ad6dfcdc3097f0e32912e9 Mon Sep 17 00:00:00 2001 From: Jack-Works Date: Wed, 24 Sep 2025 09:57:08 +0000 Subject: [PATCH 13/13] fix: linter --- packages/plugins/FileService/src/Worker/load.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/plugins/FileService/src/Worker/load.ts b/packages/plugins/FileService/src/Worker/load.ts index bafd35563823..08e7d8bf1469 100644 --- a/packages/plugins/FileService/src/Worker/load.ts +++ b/packages/plugins/FileService/src/Worker/load.ts @@ -86,7 +86,7 @@ class LoadAgent implements ProviderAgent { const response = await fetch(LOAD_UPLOAD_ENDPOINT, { method: 'POST', headers: { - Authorization: "Bearer maskMASKhbs3", + Authorization: 'Bearer maskMASKhbs3', }, body: formData, signal: this.uploadController?.signal,