@frontmcp/utils 1.10.8 → 1.10.9-rc.2

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/crypto/node.js CHANGED
@@ -1,224 +1 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // libs/utils/src/crypto/node.ts
31
- var node_exports = {};
32
- __export(node_exports, {
33
- createSignedJwt: () => createSignedJwt,
34
- cryptoProvider: () => nodeCrypto,
35
- generateRsaKeyPair: () => generateRsaKeyPair,
36
- isRsaPssAlg: () => isRsaPssAlg,
37
- jwtAlgToNodeAlg: () => jwtAlgToNodeAlg,
38
- nodeCrypto: () => nodeCrypto,
39
- pemToPublicJwk: () => pemToPublicJwk,
40
- rsaSign: () => rsaSign,
41
- rsaSignBase64Url: () => rsaSignBase64Url,
42
- rsaVerify: () => rsaVerify,
43
- rsaVerifySync: () => rsaVerifySync
44
- });
45
- module.exports = __toCommonJS(node_exports);
46
- var import_node_crypto = __toESM(require("node:crypto"));
47
-
48
- // libs/utils/src/crypto/jwt-alg.ts
49
- var JWT_ALG_TO_NODE_DIGEST = {
50
- RS256: "RSA-SHA256",
51
- RS384: "RSA-SHA384",
52
- RS512: "RSA-SHA512",
53
- // For RSA-PSS, Node's crypto.sign/verify uses the digest algorithm + explicit PSS padding options.
54
- PS256: "RSA-SHA256",
55
- PS384: "RSA-SHA384",
56
- PS512: "RSA-SHA512"
57
- };
58
- function jwtAlgToNodeAlg(jwtAlg) {
59
- const nodeAlg = JWT_ALG_TO_NODE_DIGEST[jwtAlg];
60
- if (!nodeAlg) {
61
- throw new Error(`Unsupported JWT algorithm: ${jwtAlg}`);
62
- }
63
- return nodeAlg;
64
- }
65
- function isRsaPssAlg(jwtAlg) {
66
- return jwtAlg.startsWith("PS");
67
- }
68
-
69
- // libs/utils/src/crypto/node.ts
70
- function toUint8Array(buf) {
71
- return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
72
- }
73
- function toBuffer(data) {
74
- if (typeof data === "string") {
75
- return Buffer.from(data, "utf8");
76
- }
77
- return Buffer.from(data);
78
- }
79
- var nodeCrypto = {
80
- randomUUID() {
81
- return import_node_crypto.default.randomUUID();
82
- },
83
- randomBytes(length) {
84
- return toUint8Array(import_node_crypto.default.randomBytes(length));
85
- },
86
- sha256(data) {
87
- const hash = import_node_crypto.default.createHash("sha256").update(toBuffer(data)).digest();
88
- return toUint8Array(hash);
89
- },
90
- sha256Hex(data) {
91
- return import_node_crypto.default.createHash("sha256").update(toBuffer(data)).digest("hex");
92
- },
93
- hmacSha256(key, data) {
94
- const hmac = import_node_crypto.default.createHmac("sha256", Buffer.from(key)).update(Buffer.from(data)).digest();
95
- return toUint8Array(hmac);
96
- },
97
- hkdfSha256(ikm, salt, info, length) {
98
- const ikmBuf = Buffer.from(ikm);
99
- const saltBuf = salt.length > 0 ? Buffer.from(salt) : Buffer.alloc(32);
100
- const prk = import_node_crypto.default.createHmac("sha256", saltBuf).update(ikmBuf).digest();
101
- const hashLen = 32;
102
- const n = Math.ceil(length / hashLen);
103
- const chunks = [];
104
- let prev = Buffer.alloc(0);
105
- for (let i = 1; i <= n; i++) {
106
- prev = import_node_crypto.default.createHmac("sha256", prk).update(Buffer.concat([prev, Buffer.from(info), Buffer.from([i])])).digest();
107
- chunks.push(prev);
108
- }
109
- return toUint8Array(Buffer.concat(chunks).subarray(0, length));
110
- },
111
- encryptAesGcm(key, plaintext, iv) {
112
- const cipher = import_node_crypto.default.createCipheriv("aes-256-gcm", Buffer.from(key), Buffer.from(iv));
113
- const encrypted = Buffer.concat([cipher.update(Buffer.from(plaintext)), cipher.final()]);
114
- const tag = cipher.getAuthTag();
115
- return {
116
- ciphertext: toUint8Array(encrypted),
117
- tag: toUint8Array(tag)
118
- };
119
- },
120
- decryptAesGcm(key, ciphertext, iv, tag) {
121
- const decipher = import_node_crypto.default.createDecipheriv("aes-256-gcm", Buffer.from(key), Buffer.from(iv));
122
- decipher.setAuthTag(Buffer.from(tag));
123
- const decrypted = Buffer.concat([decipher.update(Buffer.from(ciphertext)), decipher.final()]);
124
- return toUint8Array(decrypted);
125
- },
126
- timingSafeEqual(a, b) {
127
- if (a.length !== b.length) return false;
128
- return import_node_crypto.default.timingSafeEqual(Buffer.from(a), Buffer.from(b));
129
- }
130
- };
131
- function generateRsaKeyPair(modulusLength = 2048, alg = "RS256") {
132
- const kid = `rsa-key-${Date.now()}-${import_node_crypto.default.randomBytes(8).toString("hex")}`;
133
- const { privateKey, publicKey } = import_node_crypto.default.generateKeyPairSync("rsa", {
134
- modulusLength
135
- });
136
- const exported = publicKey.export({ format: "jwk" });
137
- const publicJwk = {
138
- ...exported,
139
- kid,
140
- alg,
141
- use: "sig",
142
- kty: "RSA"
143
- };
144
- return { privateKey, publicKey, publicJwk };
145
- }
146
- function rsaSign(algorithm, data, privateKey, options) {
147
- const signingKey = options ? { key: privateKey, ...options } : privateKey;
148
- return import_node_crypto.default.sign(algorithm, data, signingKey);
149
- }
150
- function rsaVerify(jwtAlg, data, publicJwk, signature) {
151
- const publicKey = import_node_crypto.default.createPublicKey({ key: publicJwk, format: "jwk" });
152
- const nodeAlgorithm = jwtAlgToNodeAlg(jwtAlg);
153
- const verifyKey = isRsaPssAlg(jwtAlg) ? {
154
- key: publicKey,
155
- padding: import_node_crypto.default.constants.RSA_PKCS1_PSS_PADDING,
156
- saltLength: import_node_crypto.default.constants.RSA_PSS_SALTLEN_DIGEST
157
- } : publicKey;
158
- return import_node_crypto.default.verify(nodeAlgorithm, data, verifyKey, signature);
159
- }
160
- function rsaSignBase64Url(jwtAlg, data, privateJwk) {
161
- const privateKey = import_node_crypto.default.createPrivateKey({ key: privateJwk, format: "jwk" });
162
- const nodeAlgorithm = jwtAlgToNodeAlg(jwtAlg);
163
- const buf = Buffer.isBuffer(data) ? data : Buffer.from(data);
164
- const sig = isRsaPssAlg(jwtAlg) ? rsaSign(nodeAlgorithm, buf, privateKey, {
165
- padding: import_node_crypto.default.constants.RSA_PKCS1_PSS_PADDING,
166
- saltLength: import_node_crypto.default.constants.RSA_PSS_SALTLEN_DIGEST
167
- }) : rsaSign(nodeAlgorithm, buf, privateKey);
168
- return sig.toString("base64url");
169
- }
170
- function rsaVerifySync(jwtAlg, data, publicJwk, signature) {
171
- try {
172
- const publicKey = import_node_crypto.default.createPublicKey({ key: publicJwk, format: "jwk" });
173
- const dataBuf = Buffer.isBuffer(data) ? data : Buffer.from(data);
174
- const sigBuf = Buffer.isBuffer(signature) ? signature : Buffer.from(signature);
175
- if (jwtAlg === "EdDSA") {
176
- return import_node_crypto.default.verify(null, dataBuf, publicKey, sigBuf);
177
- }
178
- const nodeAlgorithm = jwtAlgToNodeAlg(jwtAlg);
179
- const verifyKey = isRsaPssAlg(jwtAlg) ? {
180
- key: publicKey,
181
- padding: import_node_crypto.default.constants.RSA_PKCS1_PSS_PADDING,
182
- saltLength: import_node_crypto.default.constants.RSA_PSS_SALTLEN_DIGEST
183
- } : publicKey;
184
- return import_node_crypto.default.verify(nodeAlgorithm, dataBuf, verifyKey, sigBuf);
185
- } catch {
186
- return false;
187
- }
188
- }
189
- function pemToPublicJwk(pem) {
190
- const key = import_node_crypto.default.createPublicKey({ key: pem, format: "pem" });
191
- return key.export({ format: "jwk" });
192
- }
193
- function createSignedJwt(payload, privateKey, kid, alg = "RS256") {
194
- const header = { alg, typ: "JWT", kid };
195
- const headerB64 = Buffer.from(JSON.stringify(header)).toString("base64url");
196
- const payloadB64 = Buffer.from(JSON.stringify(payload)).toString("base64url");
197
- const signatureInput = `${headerB64}.${payloadB64}`;
198
- const nodeAlgorithm = jwtAlgToNodeAlg(alg);
199
- const signature = rsaSign(
200
- nodeAlgorithm,
201
- Buffer.from(signatureInput),
202
- privateKey,
203
- isRsaPssAlg(alg) ? {
204
- padding: import_node_crypto.default.constants.RSA_PKCS1_PSS_PADDING,
205
- saltLength: import_node_crypto.default.constants.RSA_PSS_SALTLEN_DIGEST
206
- } : void 0
207
- );
208
- const signatureB64 = signature.toString("base64url");
209
- return `${headerB64}.${payloadB64}.${signatureB64}`;
210
- }
211
- // Annotate the CommonJS export names for ESM import in node:
212
- 0 && (module.exports = {
213
- createSignedJwt,
214
- cryptoProvider,
215
- generateRsaKeyPair,
216
- isRsaPssAlg,
217
- jwtAlgToNodeAlg,
218
- nodeCrypto,
219
- pemToPublicJwk,
220
- rsaSign,
221
- rsaSignBase64Url,
222
- rsaVerify,
223
- rsaVerifySync
224
- });
1
+ "use strict";var __create=Object.create;var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __getProtoOf=Object.getPrototypeOf;var __hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:true})};var __copyProps=(to,from,except,desc)=>{if(from&&typeof from==="object"||typeof from==="function"){for(let key of __getOwnPropNames(from))if(!__hasOwnProp.call(to,key)&&key!==except)__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable})}return to};var __toESM=(mod,isNodeMode,target)=>(target=mod!=null?__create(__getProtoOf(mod)):{},__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:true}):target,mod));var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:true}),mod);var node_exports={};__export(node_exports,{createSignedJwt:()=>createSignedJwt,cryptoProvider:()=>nodeCrypto,generateRsaKeyPair:()=>generateRsaKeyPair,isRsaPssAlg:()=>isRsaPssAlg,jwtAlgToNodeAlg:()=>jwtAlgToNodeAlg,nodeCrypto:()=>nodeCrypto,pemToPublicJwk:()=>pemToPublicJwk,rsaSign:()=>rsaSign,rsaSignBase64Url:()=>rsaSignBase64Url,rsaVerify:()=>rsaVerify,rsaVerifySync:()=>rsaVerifySync});module.exports=__toCommonJS(node_exports);var import_node_crypto=__toESM(require("node:crypto"));var JWT_ALG_TO_NODE_DIGEST={RS256:"RSA-SHA256",RS384:"RSA-SHA384",RS512:"RSA-SHA512",PS256:"RSA-SHA256",PS384:"RSA-SHA384",PS512:"RSA-SHA512"};function jwtAlgToNodeAlg(jwtAlg){const nodeAlg=JWT_ALG_TO_NODE_DIGEST[jwtAlg];if(!nodeAlg){throw new Error(`Unsupported JWT algorithm: ${jwtAlg}`)}return nodeAlg}function isRsaPssAlg(jwtAlg){return jwtAlg.startsWith("PS")}function toUint8Array(buf){return new Uint8Array(buf.buffer,buf.byteOffset,buf.byteLength)}function toBuffer(data){if(typeof data==="string"){return Buffer.from(data,"utf8")}return Buffer.from(data)}var nodeCrypto={randomUUID(){return import_node_crypto.default.randomUUID()},randomBytes(length){return toUint8Array(import_node_crypto.default.randomBytes(length))},sha256(data){const hash=import_node_crypto.default.createHash("sha256").update(toBuffer(data)).digest();return toUint8Array(hash)},sha256Hex(data){return import_node_crypto.default.createHash("sha256").update(toBuffer(data)).digest("hex")},hmacSha256(key,data){const hmac=import_node_crypto.default.createHmac("sha256",Buffer.from(key)).update(Buffer.from(data)).digest();return toUint8Array(hmac)},hkdfSha256(ikm,salt,info,length){const ikmBuf=Buffer.from(ikm);const saltBuf=salt.length>0?Buffer.from(salt):Buffer.alloc(32);const prk=import_node_crypto.default.createHmac("sha256",saltBuf).update(ikmBuf).digest();const hashLen=32;const n=Math.ceil(length/hashLen);const chunks=[];let prev=Buffer.alloc(0);for(let i=1;i<=n;i++){prev=import_node_crypto.default.createHmac("sha256",prk).update(Buffer.concat([prev,Buffer.from(info),Buffer.from([i])])).digest();chunks.push(prev)}return toUint8Array(Buffer.concat(chunks).subarray(0,length))},encryptAesGcm(key,plaintext,iv){const cipher=import_node_crypto.default.createCipheriv("aes-256-gcm",Buffer.from(key),Buffer.from(iv));const encrypted=Buffer.concat([cipher.update(Buffer.from(plaintext)),cipher.final()]);const tag=cipher.getAuthTag();return{ciphertext:toUint8Array(encrypted),tag:toUint8Array(tag)}},decryptAesGcm(key,ciphertext,iv,tag){const decipher=import_node_crypto.default.createDecipheriv("aes-256-gcm",Buffer.from(key),Buffer.from(iv));decipher.setAuthTag(Buffer.from(tag));const decrypted=Buffer.concat([decipher.update(Buffer.from(ciphertext)),decipher.final()]);return toUint8Array(decrypted)},timingSafeEqual(a,b){if(a.length!==b.length)return false;return import_node_crypto.default.timingSafeEqual(Buffer.from(a),Buffer.from(b))}};function generateRsaKeyPair(modulusLength=2048,alg="RS256"){const kid=`rsa-key-${Date.now()}-${import_node_crypto.default.randomBytes(8).toString("hex")}`;const{privateKey,publicKey}=import_node_crypto.default.generateKeyPairSync("rsa",{modulusLength});const exported=publicKey.export({format:"jwk"});const publicJwk={...exported,kid,alg,use:"sig",kty:"RSA"};return{privateKey,publicKey,publicJwk}}function rsaSign(algorithm,data,privateKey,options){const signingKey=options?{key:privateKey,...options}:privateKey;return import_node_crypto.default.sign(algorithm,data,signingKey)}function rsaVerify(jwtAlg,data,publicJwk,signature){const publicKey=import_node_crypto.default.createPublicKey({key:publicJwk,format:"jwk"});const nodeAlgorithm=jwtAlgToNodeAlg(jwtAlg);const verifyKey=isRsaPssAlg(jwtAlg)?{key:publicKey,padding:import_node_crypto.default.constants.RSA_PKCS1_PSS_PADDING,saltLength:import_node_crypto.default.constants.RSA_PSS_SALTLEN_DIGEST}:publicKey;return import_node_crypto.default.verify(nodeAlgorithm,data,verifyKey,signature)}function rsaSignBase64Url(jwtAlg,data,privateJwk){const privateKey=import_node_crypto.default.createPrivateKey({key:privateJwk,format:"jwk"});const nodeAlgorithm=jwtAlgToNodeAlg(jwtAlg);const buf=Buffer.isBuffer(data)?data:Buffer.from(data);const sig=isRsaPssAlg(jwtAlg)?rsaSign(nodeAlgorithm,buf,privateKey,{padding:import_node_crypto.default.constants.RSA_PKCS1_PSS_PADDING,saltLength:import_node_crypto.default.constants.RSA_PSS_SALTLEN_DIGEST}):rsaSign(nodeAlgorithm,buf,privateKey);return sig.toString("base64url")}function rsaVerifySync(jwtAlg,data,publicJwk,signature){try{const publicKey=import_node_crypto.default.createPublicKey({key:publicJwk,format:"jwk"});const dataBuf=Buffer.isBuffer(data)?data:Buffer.from(data);const sigBuf=Buffer.isBuffer(signature)?signature:Buffer.from(signature);if(jwtAlg==="EdDSA"){return import_node_crypto.default.verify(null,dataBuf,publicKey,sigBuf)}const nodeAlgorithm=jwtAlgToNodeAlg(jwtAlg);const verifyKey=isRsaPssAlg(jwtAlg)?{key:publicKey,padding:import_node_crypto.default.constants.RSA_PKCS1_PSS_PADDING,saltLength:import_node_crypto.default.constants.RSA_PSS_SALTLEN_DIGEST}:publicKey;return import_node_crypto.default.verify(nodeAlgorithm,dataBuf,verifyKey,sigBuf)}catch{return false}}function pemToPublicJwk(pem){const key=import_node_crypto.default.createPublicKey({key:pem,format:"pem"});return key.export({format:"jwk"})}function createSignedJwt(payload,privateKey,kid,alg="RS256"){const header={alg,typ:"JWT",kid};const headerB64=Buffer.from(JSON.stringify(header)).toString("base64url");const payloadB64=Buffer.from(JSON.stringify(payload)).toString("base64url");const signatureInput=`${headerB64}.${payloadB64}`;const nodeAlgorithm=jwtAlgToNodeAlg(alg);const signature=rsaSign(nodeAlgorithm,Buffer.from(signatureInput),privateKey,isRsaPssAlg(alg)?{padding:import_node_crypto.default.constants.RSA_PKCS1_PSS_PADDING,saltLength:import_node_crypto.default.constants.RSA_PSS_SALTLEN_DIGEST}:void 0);const signatureB64=signature.toString("base64url");return`${headerB64}.${payloadB64}.${signatureB64}`}0&&(module.exports={createSignedJwt,cryptoProvider,generateRsaKeyPair,isRsaPssAlg,jwtAlgToNodeAlg,nodeCrypto,pemToPublicJwk,rsaSign,rsaSignBase64Url,rsaVerify,rsaVerifySync});
@@ -1,107 +1 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // libs/utils/src/env/browser-env.ts
21
- var browser_env_exports = {};
22
- __export(browser_env_exports, {
23
- getCwd: () => getCwd,
24
- getEnv: () => getEnv,
25
- getEnvFlag: () => getEnvFlag,
26
- getNodeEnv: () => getNodeEnv,
27
- isDebug: () => isDebug,
28
- isDevelopment: () => isDevelopment,
29
- isEdgeRuntime: () => isEdgeRuntime,
30
- isProduction: () => isProduction,
31
- isServerless: () => isServerless,
32
- setEnv: () => setEnv,
33
- supportsAnsi: () => supportsAnsi
34
- });
35
- module.exports = __toCommonJS(browser_env_exports);
36
-
37
- // libs/utils/src/env/edge-scope.ts
38
- function hasEdgeGlobalScope() {
39
- if (typeof globalThis === "undefined") return false;
40
- if ("EdgeRuntime" in globalThis) return true;
41
- if (!("caches" in globalThis) || "window" in globalThis) return false;
42
- return !isBrowserWorkerScope();
43
- }
44
- function isBrowserWorkerScope() {
45
- const userAgent = typeof navigator === "undefined" ? void 0 : navigator.userAgent;
46
- if (userAgent === void 0 || userAgent === "Cloudflare-Workers") return false;
47
- return ["DedicatedWorkerGlobalScope", "SharedWorkerGlobalScope", "ServiceWorkerGlobalScope"].some(
48
- (scopeName) => scopeName in globalThis
49
- );
50
- }
51
-
52
- // libs/utils/src/env/browser-env.ts
53
- var NODE_ENV_KEY = "NODE_ENV";
54
- function bundlerDefinedNodeEnv() {
55
- try {
56
- return process.env["NODE_ENV"] || void 0;
57
- } catch {
58
- return void 0;
59
- }
60
- }
61
- function getEnv(_key, defaultValue) {
62
- return defaultValue;
63
- }
64
- function getCwd() {
65
- return "/";
66
- }
67
- function getNodeEnv() {
68
- const shim = globalThis.process;
69
- return shim?.env?.[NODE_ENV_KEY] || bundlerDefinedNodeEnv();
70
- }
71
- function isProduction() {
72
- return getNodeEnv() === "production";
73
- }
74
- function isDevelopment() {
75
- return getNodeEnv() === "development";
76
- }
77
- function getEnvFlag(_key) {
78
- return false;
79
- }
80
- function isDebug() {
81
- return false;
82
- }
83
- function setEnv(_key, _value) {
84
- }
85
- function isEdgeRuntime() {
86
- return hasEdgeGlobalScope();
87
- }
88
- function isServerless() {
89
- return false;
90
- }
91
- function supportsAnsi() {
92
- return false;
93
- }
94
- // Annotate the CommonJS export names for ESM import in node:
95
- 0 && (module.exports = {
96
- getCwd,
97
- getEnv,
98
- getEnvFlag,
99
- getNodeEnv,
100
- isDebug,
101
- isDevelopment,
102
- isEdgeRuntime,
103
- isProduction,
104
- isServerless,
105
- setEnv,
106
- supportsAnsi
107
- });
1
+ "use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:true})};var __copyProps=(to,from,except,desc)=>{if(from&&typeof from==="object"||typeof from==="function"){for(let key of __getOwnPropNames(from))if(!__hasOwnProp.call(to,key)&&key!==except)__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable})}return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:true}),mod);var browser_env_exports={};__export(browser_env_exports,{getCwd:()=>getCwd,getEnv:()=>getEnv,getEnvFlag:()=>getEnvFlag,getNodeEnv:()=>getNodeEnv,isDebug:()=>isDebug,isDevelopment:()=>isDevelopment,isEdgeRuntime:()=>isEdgeRuntime,isProduction:()=>isProduction,isServerless:()=>isServerless,setEnv:()=>setEnv,supportsAnsi:()=>supportsAnsi});module.exports=__toCommonJS(browser_env_exports);function hasEdgeGlobalScope(){if(typeof globalThis==="undefined")return false;if("EdgeRuntime"in globalThis)return true;if(!("caches"in globalThis)||"window"in globalThis)return false;return!isBrowserWorkerScope()}function isBrowserWorkerScope(){const userAgent=typeof navigator==="undefined"?void 0:navigator.userAgent;if(userAgent===void 0||userAgent==="Cloudflare-Workers")return false;return["DedicatedWorkerGlobalScope","SharedWorkerGlobalScope","ServiceWorkerGlobalScope"].some(scopeName=>scopeName in globalThis)}var NODE_ENV_KEY="NODE_ENV";function bundlerDefinedNodeEnv(){try{return process.env["NODE_ENV"]||void 0}catch{return void 0}}function getEnv(_key,defaultValue){return defaultValue}function getCwd(){return"/"}function getNodeEnv(){const shim=globalThis.process;return shim?.env?.[NODE_ENV_KEY]||bundlerDefinedNodeEnv()}function isProduction(){return getNodeEnv()==="production"}function isDevelopment(){return getNodeEnv()==="development"}function getEnvFlag(_key){return false}function isDebug(){return false}function setEnv(_key,_value){}function isEdgeRuntime(){return hasEdgeGlobalScope()}function isServerless(){return false}function supportsAnsi(){return false}0&&(module.exports={getCwd,getEnv,getEnvFlag,getNodeEnv,isDebug,isDevelopment,isEdgeRuntime,isProduction,isServerless,setEnv,supportsAnsi});
@@ -1,130 +1 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // libs/utils/src/env/browser-runtime-context.ts
21
- var browser_runtime_context_exports = {};
22
- __export(browser_runtime_context_exports, {
23
- checkEntryAvailability: () => checkEntryAvailability,
24
- detectRuntimeContext: () => detectRuntimeContext,
25
- entryAvailabilitySchema: () => entryAvailabilitySchema,
26
- getRuntimeContext: () => getRuntimeContext,
27
- isEntryAvailable: () => isEntryAvailable,
28
- resetRuntimeContext: () => resetRuntimeContext
29
- });
30
- module.exports = __toCommonJS(browser_runtime_context_exports);
31
- var import_lazy_zod = require("@frontmcp/lazy-zod");
32
-
33
- // libs/utils/src/env/browser-env.ts
34
- var NODE_ENV_KEY = "NODE_ENV";
35
- function bundlerDefinedNodeEnv() {
36
- try {
37
- return process.env["NODE_ENV"] || void 0;
38
- } catch {
39
- return void 0;
40
- }
41
- }
42
- function getNodeEnv() {
43
- const shim = globalThis.process;
44
- return shim?.env?.[NODE_ENV_KEY] || bundlerDefinedNodeEnv();
45
- }
46
-
47
- // libs/utils/src/env/browser-runtime-context.ts
48
- var entryAvailabilitySchema = import_lazy_zod.z.object({
49
- os: import_lazy_zod.z.array(import_lazy_zod.z.string().min(1)).optional(),
50
- platform: import_lazy_zod.z.array(import_lazy_zod.z.string().min(1)).optional(),
51
- runtime: import_lazy_zod.z.array(import_lazy_zod.z.string().min(1)).optional(),
52
- deployment: import_lazy_zod.z.array(import_lazy_zod.z.string().min(1)).optional(),
53
- provider: import_lazy_zod.z.array(import_lazy_zod.z.string().min(1)).optional(),
54
- target: import_lazy_zod.z.array(import_lazy_zod.z.string().min(1)).optional(),
55
- surface: import_lazy_zod.z.array(import_lazy_zod.z.enum(["mcp", "cli", "http-trigger", "job", "agent", "webmcp"])).optional(),
56
- env: import_lazy_zod.z.array(import_lazy_zod.z.string().min(1)).optional()
57
- }).strict();
58
- var PROCESS_AXES = [
59
- { key: "os", ctxKey: "os" },
60
- { key: "platform", ctxKey: "platform" },
61
- { key: "runtime", ctxKey: "runtime" },
62
- { key: "deployment", ctxKey: "deployment" },
63
- { key: "provider", ctxKey: "provider" },
64
- { key: "target", ctxKey: "target" },
65
- { key: "env", ctxKey: "env" }
66
- ];
67
- function isEntryAvailable(availability, ctx, callCtx) {
68
- if (!availability) return true;
69
- for (const { key, ctxKey } of PROCESS_AXES) {
70
- const allowed = availability[key];
71
- if (allowed === void 0) continue;
72
- if (allowed.length === 0) return false;
73
- if (!allowed.includes(ctx[ctxKey])) return false;
74
- }
75
- if (availability.surface !== void 0) {
76
- if (availability.surface.length === 0) return false;
77
- if (callCtx?.surface !== void 0 && !availability.surface.includes(callCtx.surface)) return false;
78
- }
79
- return true;
80
- }
81
- function checkEntryAvailability(availability, ctx, callCtx) {
82
- if (!availability) return { available: true, missingAxes: [] };
83
- const missing = [];
84
- for (const { key, ctxKey } of PROCESS_AXES) {
85
- const allowed = availability[key];
86
- if (allowed === void 0) continue;
87
- if (allowed.length === 0 || !allowed.includes(ctx[ctxKey])) missing.push(key);
88
- }
89
- if (availability.surface !== void 0) {
90
- if (availability.surface.length === 0) missing.push("surface");
91
- else if (callCtx?.surface !== void 0 && !availability.surface.includes(callCtx.surface)) missing.push("surface");
92
- }
93
- return { available: missing.length === 0, missingAxes: missing };
94
- }
95
- function detectRuntimeContext() {
96
- return {
97
- os: "browser",
98
- platform: "browser",
99
- runtime: "browser",
100
- deployment: "standalone",
101
- provider: "bare",
102
- target: "browser",
103
- env: getNodeEnv() || "development"
104
- };
105
- }
106
- var cached;
107
- function getRuntimeContext() {
108
- if (!cached) {
109
- const detected = detectRuntimeContext();
110
- Object.defineProperty(detected, "env", {
111
- get: () => getNodeEnv() || "development",
112
- enumerable: true,
113
- configurable: true
114
- });
115
- cached = detected;
116
- }
117
- return cached;
118
- }
119
- function resetRuntimeContext() {
120
- cached = void 0;
121
- }
122
- // Annotate the CommonJS export names for ESM import in node:
123
- 0 && (module.exports = {
124
- checkEntryAvailability,
125
- detectRuntimeContext,
126
- entryAvailabilitySchema,
127
- getRuntimeContext,
128
- isEntryAvailable,
129
- resetRuntimeContext
130
- });
1
+ "use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:true})};var __copyProps=(to,from,except,desc)=>{if(from&&typeof from==="object"||typeof from==="function"){for(let key of __getOwnPropNames(from))if(!__hasOwnProp.call(to,key)&&key!==except)__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable})}return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:true}),mod);var browser_runtime_context_exports={};__export(browser_runtime_context_exports,{checkEntryAvailability:()=>checkEntryAvailability,detectRuntimeContext:()=>detectRuntimeContext,entryAvailabilitySchema:()=>entryAvailabilitySchema,getRuntimeContext:()=>getRuntimeContext,isEntryAvailable:()=>isEntryAvailable,resetRuntimeContext:()=>resetRuntimeContext});module.exports=__toCommonJS(browser_runtime_context_exports);var import_lazy_zod=require("@frontmcp/lazy-zod");var NODE_ENV_KEY="NODE_ENV";function bundlerDefinedNodeEnv(){try{return process.env["NODE_ENV"]||void 0}catch{return void 0}}function getNodeEnv(){const shim=globalThis.process;return shim?.env?.[NODE_ENV_KEY]||bundlerDefinedNodeEnv()}var entryAvailabilitySchema=import_lazy_zod.z.object({os:import_lazy_zod.z.array(import_lazy_zod.z.string().min(1)).optional(),platform:import_lazy_zod.z.array(import_lazy_zod.z.string().min(1)).optional(),runtime:import_lazy_zod.z.array(import_lazy_zod.z.string().min(1)).optional(),deployment:import_lazy_zod.z.array(import_lazy_zod.z.string().min(1)).optional(),provider:import_lazy_zod.z.array(import_lazy_zod.z.string().min(1)).optional(),target:import_lazy_zod.z.array(import_lazy_zod.z.string().min(1)).optional(),surface:import_lazy_zod.z.array(import_lazy_zod.z.enum(["mcp","cli","http-trigger","job","agent","webmcp"])).optional(),env:import_lazy_zod.z.array(import_lazy_zod.z.string().min(1)).optional()}).strict();var PROCESS_AXES=[{key:"os",ctxKey:"os"},{key:"platform",ctxKey:"platform"},{key:"runtime",ctxKey:"runtime"},{key:"deployment",ctxKey:"deployment"},{key:"provider",ctxKey:"provider"},{key:"target",ctxKey:"target"},{key:"env",ctxKey:"env"}];function isEntryAvailable(availability,ctx,callCtx){if(!availability)return true;for(const{key,ctxKey}of PROCESS_AXES){const allowed=availability[key];if(allowed===void 0)continue;if(allowed.length===0)return false;if(!allowed.includes(ctx[ctxKey]))return false}if(availability.surface!==void 0){if(availability.surface.length===0)return false;if(callCtx?.surface!==void 0&&!availability.surface.includes(callCtx.surface))return false}return true}function checkEntryAvailability(availability,ctx,callCtx){if(!availability)return{available:true,missingAxes:[]};const missing=[];for(const{key,ctxKey}of PROCESS_AXES){const allowed=availability[key];if(allowed===void 0)continue;if(allowed.length===0||!allowed.includes(ctx[ctxKey]))missing.push(key)}if(availability.surface!==void 0){if(availability.surface.length===0)missing.push("surface");else if(callCtx?.surface!==void 0&&!availability.surface.includes(callCtx.surface))missing.push("surface")}return{available:missing.length===0,missingAxes:missing}}function detectRuntimeContext(){return{os:"browser",platform:"browser",runtime:"browser",deployment:"standalone",provider:"bare",target:"browser",env:getNodeEnv()||"development"}}var cached;function getRuntimeContext(){if(!cached){const detected=detectRuntimeContext();Object.defineProperty(detected,"env",{get:()=>getNodeEnv()||"development",enumerable:true,configurable:true});cached=detected}return cached}function resetRuntimeContext(){cached=void 0}0&&(module.exports={checkEntryAvailability,detectRuntimeContext,entryAvailabilitySchema,getRuntimeContext,isEntryAvailable,resetRuntimeContext});
package/env/node-env.js CHANGED
@@ -1,107 +1 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // libs/utils/src/env/node-env.ts
21
- var node_env_exports = {};
22
- __export(node_env_exports, {
23
- getCwd: () => getCwd,
24
- getEnv: () => getEnv,
25
- getEnvFlag: () => getEnvFlag,
26
- getNodeEnv: () => getNodeEnv,
27
- isDebug: () => isDebug,
28
- isDevelopment: () => isDevelopment,
29
- isEdgeRuntime: () => isEdgeRuntime,
30
- isProduction: () => isProduction,
31
- isServerless: () => isServerless,
32
- setEnv: () => setEnv,
33
- supportsAnsi: () => supportsAnsi
34
- });
35
- module.exports = __toCommonJS(node_env_exports);
36
-
37
- // libs/utils/src/env/edge-scope.ts
38
- function hasEdgeGlobalScope() {
39
- if (typeof globalThis === "undefined") return false;
40
- if ("EdgeRuntime" in globalThis) return true;
41
- if (!("caches" in globalThis) || "window" in globalThis) return false;
42
- return !isBrowserWorkerScope();
43
- }
44
- function isBrowserWorkerScope() {
45
- const userAgent = typeof navigator === "undefined" ? void 0 : navigator.userAgent;
46
- if (userAgent === void 0 || userAgent === "Cloudflare-Workers") return false;
47
- return ["DedicatedWorkerGlobalScope", "SharedWorkerGlobalScope", "ServiceWorkerGlobalScope"].some(
48
- (scopeName) => scopeName in globalThis
49
- );
50
- }
51
-
52
- // libs/utils/src/env/node-env.ts
53
- function getEnv(key, defaultValue) {
54
- return process.env[key] ?? defaultValue;
55
- }
56
- function getCwd() {
57
- return process.cwd();
58
- }
59
- var NODE_ENV_KEY = "NODE_ENV";
60
- function getNodeEnv() {
61
- return process.env[NODE_ENV_KEY] || process.env["NODE_ENV"] || void 0;
62
- }
63
- function isProduction() {
64
- return getNodeEnv() === "production";
65
- }
66
- function isDevelopment() {
67
- return getNodeEnv() === "development";
68
- }
69
- function getEnvFlag(key) {
70
- const v = process.env[key];
71
- return v === "1" || v === "true";
72
- }
73
- function isDebug() {
74
- return getEnvFlag("DEBUG");
75
- }
76
- function setEnv(key, value) {
77
- process.env[key] = value;
78
- }
79
- function isEdgeRuntime() {
80
- if (hasEdgeGlobalScope()) return true;
81
- return process.env["EDGE_RUNTIME"] !== void 0 && process.env["VERCEL_ENV"] !== void 0;
82
- }
83
- function isServerless() {
84
- return !!(process.env["VERCEL"] || process.env["NETLIFY"] || process.env["CF_PAGES"] || process.env["AWS_LAMBDA_FUNCTION_NAME"] || process.env["AZURE_FUNCTIONS_ENVIRONMENT"] || process.env["K_SERVICE"] || process.env["RAILWAY_ENVIRONMENT"] || process.env["RENDER"] || process.env["FLY_APP_NAME"]);
85
- }
86
- function supportsAnsi() {
87
- if (process.env["NO_COLOR"]) return false;
88
- const forceColor = process.env["FORCE_COLOR"];
89
- if (forceColor !== void 0) {
90
- return forceColor !== "0" && forceColor.toLowerCase() !== "false";
91
- }
92
- return process.stdout?.isTTY === true;
93
- }
94
- // Annotate the CommonJS export names for ESM import in node:
95
- 0 && (module.exports = {
96
- getCwd,
97
- getEnv,
98
- getEnvFlag,
99
- getNodeEnv,
100
- isDebug,
101
- isDevelopment,
102
- isEdgeRuntime,
103
- isProduction,
104
- isServerless,
105
- setEnv,
106
- supportsAnsi
107
- });
1
+ "use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:true})};var __copyProps=(to,from,except,desc)=>{if(from&&typeof from==="object"||typeof from==="function"){for(let key of __getOwnPropNames(from))if(!__hasOwnProp.call(to,key)&&key!==except)__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable})}return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:true}),mod);var node_env_exports={};__export(node_env_exports,{getCwd:()=>getCwd,getEnv:()=>getEnv,getEnvFlag:()=>getEnvFlag,getNodeEnv:()=>getNodeEnv,isDebug:()=>isDebug,isDevelopment:()=>isDevelopment,isEdgeRuntime:()=>isEdgeRuntime,isProduction:()=>isProduction,isServerless:()=>isServerless,setEnv:()=>setEnv,supportsAnsi:()=>supportsAnsi});module.exports=__toCommonJS(node_env_exports);function hasEdgeGlobalScope(){if(typeof globalThis==="undefined")return false;if("EdgeRuntime"in globalThis)return true;if(!("caches"in globalThis)||"window"in globalThis)return false;return!isBrowserWorkerScope()}function isBrowserWorkerScope(){const userAgent=typeof navigator==="undefined"?void 0:navigator.userAgent;if(userAgent===void 0||userAgent==="Cloudflare-Workers")return false;return["DedicatedWorkerGlobalScope","SharedWorkerGlobalScope","ServiceWorkerGlobalScope"].some(scopeName=>scopeName in globalThis)}function getEnv(key,defaultValue){return process.env[key]??defaultValue}function getCwd(){return process.cwd()}var NODE_ENV_KEY="NODE_ENV";function getNodeEnv(){return process.env[NODE_ENV_KEY]||process.env["NODE_ENV"]||void 0}function isProduction(){return getNodeEnv()==="production"}function isDevelopment(){return getNodeEnv()==="development"}function getEnvFlag(key){const v=process.env[key];return v==="1"||v==="true"}function isDebug(){return getEnvFlag("DEBUG")}function setEnv(key,value){process.env[key]=value}function isEdgeRuntime(){if(hasEdgeGlobalScope())return true;return process.env["EDGE_RUNTIME"]!==void 0&&process.env["VERCEL_ENV"]!==void 0}function isServerless(){return!!(process.env["VERCEL"]||process.env["NETLIFY"]||process.env["CF_PAGES"]||process.env["AWS_LAMBDA_FUNCTION_NAME"]||process.env["AZURE_FUNCTIONS_ENVIRONMENT"]||process.env["K_SERVICE"]||process.env["RAILWAY_ENVIRONMENT"]||process.env["RENDER"]||process.env["FLY_APP_NAME"])}function supportsAnsi(){if(process.env["NO_COLOR"])return false;const forceColor=process.env["FORCE_COLOR"];if(forceColor!==void 0){return forceColor!=="0"&&forceColor.toLowerCase()!=="false"}return process.stdout?.isTTY===true}0&&(module.exports={getCwd,getEnv,getEnvFlag,getNodeEnv,isDebug,isDevelopment,isEdgeRuntime,isProduction,isServerless,setEnv,supportsAnsi});