@antdigital/cube-cli-shared
Advanced tools
@@ -1,2 +0,1 @@ | ||
| export * from './AFTSUtil'; | ||
| export * from './camelize'; | ||
@@ -3,0 +2,0 @@ export * from './capnp'; |
@@ -17,3 +17,2 @@ "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| __exportStar(require("./AFTSUtil"), exports); | ||
| __exportStar(require("./camelize"), exports); | ||
@@ -20,0 +19,0 @@ __exportStar(require("./capnp"), exports); |
+3
-4
| { | ||
| "name": "@antdigital/cube-cli-shared", | ||
| "version": "4.7.13", | ||
| "version": "4.7.14", | ||
| "main": "lib/index.js", | ||
@@ -13,3 +13,4 @@ "files": [ | ||
| "publishConfig": { | ||
| "registry": "https://registry.npmjs.org" | ||
| "registry": "https://registry.npmjs.org", | ||
| "access": "public" | ||
| }, | ||
@@ -24,4 +25,2 @@ "scripts": { | ||
| "dependencies": { | ||
| "@alipay/afts-sdk": "^1.2.13", | ||
| "@alipay/yuyan-common-util": "^4.14.6", | ||
| "axios": "^1.7.7", | ||
@@ -28,0 +27,0 @@ "chalk": "^4.1.2", |
| interface ICardBlockAFTSResult { | ||
| md5: string; | ||
| fileId: string; | ||
| mockMd5: string; | ||
| mockFileId: string; | ||
| fileList: { | ||
| fileId: string; | ||
| md5: string; | ||
| name: string; | ||
| }[]; | ||
| } | ||
| export declare class AFTSUtil { | ||
| static upload(distPath: string): Promise<ICardBlockAFTSResult>; | ||
| } | ||
| export {}; |
| "use strict"; | ||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||
| return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.AFTSUtil = void 0; | ||
| const node_fs_1 = __importDefault(require("node:fs")); | ||
| const node_path_1 = __importDefault(require("node:path")); | ||
| const fast_glob_1 = require("fast-glob"); | ||
| const afts_sdk_1 = __importDefault(require("@alipay/afts-sdk")); | ||
| const yuyan_common_util_1 = require("@alipay/yuyan-common-util"); | ||
| const logger_1 = require("./logger"); | ||
| class AFTSUtil { | ||
| static async upload(distPath) { | ||
| let aftsConfig = { | ||
| appId: 'apwallet', | ||
| bizKey: 'card_playground', | ||
| bizSecret: 'd670045d2cc547ce91ef904b57ec6620', | ||
| env: 'dev', | ||
| }; | ||
| switch (process.env.NODE_ENV) { | ||
| case 'development': | ||
| aftsConfig = { | ||
| ...aftsConfig, | ||
| bizSecret: 'd670045d2cc547ce91ef904b57ec6620', | ||
| env: 'dev', | ||
| }; | ||
| break; | ||
| case 'sit': | ||
| aftsConfig = { | ||
| ...aftsConfig, | ||
| bizSecret: 'e684bb47a2da4117a5482aed381cda05', | ||
| env: 'sit', | ||
| }; | ||
| break; | ||
| case 'production': | ||
| aftsConfig = { | ||
| ...aftsConfig, | ||
| bizSecret: '8b21376b03814a6e898391dbd090cb71', | ||
| env: 'prod', | ||
| }; | ||
| break; | ||
| default: | ||
| aftsConfig = { | ||
| ...aftsConfig, | ||
| bizSecret: '8b21376b03814a6e898391dbd090cb71', | ||
| env: 'prod', | ||
| }; | ||
| } | ||
| const zstPaths = await (0, fast_glob_1.glob)([`${distPath}/**/*.zst`], { | ||
| cwd: distPath, | ||
| }); | ||
| const binPaths = await (0, fast_glob_1.glob)([`${distPath}/**/*.bin`], { | ||
| cwd: distPath, | ||
| }); | ||
| const mockPaths = await (0, fast_glob_1.glob)([`${distPath}/**/*.mock`], { | ||
| cwd: distPath, | ||
| }); | ||
| if (zstPaths.length === 0) { | ||
| throw new Error(`${distPath} 中不包含任何 .zst 文件,请检查卡片构建产物`); | ||
| } | ||
| if (zstPaths.length > 1) { | ||
| throw new Error(`${distPath} 中包含多个 .zst 文件,请检查卡片构建产物,不支持同时上传多张卡片`); | ||
| } | ||
| const artifactPathList = [...zstPaths, ...binPaths, ...mockPaths].map((p) => { | ||
| return { | ||
| name: node_path_1.default.parse(p).name, | ||
| extName: node_path_1.default.extname(p), | ||
| fullName: node_path_1.default.basename(p), | ||
| fullPath: p, | ||
| }; | ||
| }); | ||
| logger_1.logger.debug('artifactPathList', artifactPathList, aftsConfig); | ||
| const afts = new afts_sdk_1.default({ | ||
| appId: aftsConfig.appId, | ||
| bizKey: aftsConfig.bizKey, | ||
| bizSecret: aftsConfig.bizSecret, | ||
| }, { | ||
| env: aftsConfig.env, | ||
| }); | ||
| logger_1.logger.debug('AFTS generate success with env: %s', aftsConfig.env); | ||
| const resp = await (0, yuyan_common_util_1.promiseControl)(artifactPathList, async (artifact) => { | ||
| logger_1.logger.debug('AFTS now upload: %j', artifact); | ||
| const fileStream = node_fs_1.default.createReadStream(artifact.fullPath); | ||
| const [uploadResp] = await afts.upload({ | ||
| name: artifact.name, | ||
| stream: fileStream, | ||
| access: 'public', | ||
| }, {}); | ||
| logger_1.logger.debug('upload file: %j to AFTS result: %j', artifact, uploadResp); | ||
| return { | ||
| ...uploadResp, | ||
| ...artifact, | ||
| }; | ||
| }, { | ||
| concurrency: 1, | ||
| }); | ||
| const zstFileInfo = resp.find((file) => file.extName === '.zst'); | ||
| const binFileInfo = resp.find((file) => file.extName === '.bin'); | ||
| const mockFileInfo = resp.find((file) => file.extName === '.mock'); | ||
| if (!zstFileInfo) { | ||
| throw new Error('cannot find .zst upload record'); | ||
| } | ||
| const fileList = [ | ||
| { | ||
| fileId: zstFileInfo.id, | ||
| md5: zstFileInfo.md5, | ||
| name: zstFileInfo.fullName, | ||
| }, | ||
| ]; | ||
| if (binFileInfo) { | ||
| fileList.push({ | ||
| fileId: binFileInfo.id, | ||
| md5: binFileInfo.md5, | ||
| name: binFileInfo.fullName, | ||
| }); | ||
| } | ||
| if (mockFileInfo) { | ||
| fileList.push({ | ||
| fileId: mockFileInfo.id, | ||
| md5: mockFileInfo.md5, | ||
| name: mockFileInfo.fullName, | ||
| }); | ||
| } | ||
| return { | ||
| md5: zstFileInfo.md5, | ||
| fileId: zstFileInfo.id, | ||
| mockMd5: mockFileInfo?.md5 || '', | ||
| mockFileId: mockFileInfo?.id || '', | ||
| fileList, | ||
| }; | ||
| } | ||
| } | ||
| exports.AFTSUtil = AFTSUtil; |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
11
-15.38%18
-5.26%54144335
-0.01%74
-2.63%992
-13.21%- Removed
- Removed