@frontmcp/utils 1.10.16 → 1.11.0-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.
Files changed (135) hide show
  1. package/README.md +1 -0
  2. package/browser/async-context/browser-async-context.mjs +177 -0
  3. package/browser/async-context/index.mjs +15 -0
  4. package/browser/async-context/overlap-error.mjs +10 -0
  5. package/browser/class-brand/class-brand.mjs +27 -0
  6. package/browser/class-brand/index.mjs +6 -0
  7. package/browser/content/content.mjs +151 -0
  8. package/browser/content/index.mjs +8 -0
  9. package/browser/crypto/browser.mjs +103 -0
  10. package/browser/crypto/encrypted-blob.mjs +119 -0
  11. package/browser/crypto/hmac-signing.mjs +70 -0
  12. package/browser/crypto/index.mjs +281 -0
  13. package/browser/crypto/jwt-alg.mjs +40 -0
  14. package/browser/crypto/key-persistence/factory.mjs +134 -0
  15. package/browser/crypto/key-persistence/index.mjs +26 -0
  16. package/browser/crypto/key-persistence/key-persistence.mjs +185 -0
  17. package/browser/crypto/key-persistence/schemas.mjs +82 -0
  18. package/browser/crypto/pkce/index.mjs +25 -0
  19. package/browser/crypto/pkce/pkce.mjs +59 -0
  20. package/browser/crypto/runtime.mjs +17 -0
  21. package/browser/crypto/secret-persistence/index.mjs +29 -0
  22. package/browser/crypto/secret-persistence/persistence.mjs +181 -0
  23. package/browser/crypto/secret-persistence/schema.mjs +40 -0
  24. package/browser/crypto/web-rsa.mjs +36 -0
  25. package/browser/env/browser-env.mjs +56 -0
  26. package/browser/env/browser-runtime-context.mjs +85 -0
  27. package/browser/env/build-target.mjs +25 -0
  28. package/browser/env/edge-scope.mjs +17 -0
  29. package/browser/env/index.mjs +47 -0
  30. package/browser/env/provider.mjs +46 -0
  31. package/browser/escape/escape.mjs +43 -0
  32. package/browser/escape/index.mjs +9 -0
  33. package/browser/event-emitter/browser-event-emitter.mjs +49 -0
  34. package/browser/event-emitter/index.mjs +5 -0
  35. package/browser/fs/fs.mjs +227 -0
  36. package/browser/fs/index.mjs +65 -0
  37. package/browser/http/cookie.mjs +85 -0
  38. package/browser/http/http.mjs +18 -0
  39. package/browser/http/index.mjs +11 -0
  40. package/browser/index.mjs +526 -0
  41. package/browser/llm/index.mjs +5 -0
  42. package/browser/llm/llm-tool-handlers.mjs +55 -0
  43. package/browser/machine-id/index.mjs +7 -0
  44. package/browser/machine-id/machine-id.mjs +108 -0
  45. package/browser/naming/index.mjs +10 -0
  46. package/browser/naming/naming.mjs +68 -0
  47. package/browser/net/index.mjs +10 -0
  48. package/browser/net/ip-address.mjs +128 -0
  49. package/browser/net/redirect.mjs +7 -0
  50. package/browser/path/browser-path.mjs +47 -0
  51. package/browser/path/index.mjs +24 -0
  52. package/browser/path/path.mjs +13 -0
  53. package/browser/process/child-process.mjs +23 -0
  54. package/browser/process/index.mjs +15 -0
  55. package/browser/process/owned-process.mjs +175 -0
  56. package/browser/process/process-tree.mjs +149 -0
  57. package/browser/process/process-watch.mjs +48 -0
  58. package/browser/redaction/index.mjs +6 -0
  59. package/browser/redaction/redaction.mjs +74 -0
  60. package/browser/regex/index.mjs +3 -0
  61. package/browser/regex/patterns.mjs +167 -0
  62. package/browser/regex/safe-regex.mjs +93 -0
  63. package/browser/serialization/index.mjs +5 -0
  64. package/browser/serialization/serialization.mjs +22 -0
  65. package/browser/stdio-bridge/errors.mjs +27 -0
  66. package/browser/stdio-bridge/index.mjs +24 -0
  67. package/browser/stdio-bridge/list-changed.mjs +21 -0
  68. package/browser/stdio-bridge/state-machine.mjs +211 -0
  69. package/browser/stdio-bridge/stdio-framer.mjs +91 -0
  70. package/browser/stdio-bridge/upstream-client.mjs +189 -0
  71. package/browser/storage/adapters/base.mjs +139 -0
  72. package/browser/storage/adapters/cloudflare-kv.mjs +149 -0
  73. package/browser/storage/adapters/filesystem.mjs +279 -0
  74. package/browser/storage/adapters/index.mjs +23 -0
  75. package/browser/storage/adapters/indexeddb.mjs +198 -0
  76. package/browser/storage/adapters/localstorage.mjs +222 -0
  77. package/browser/storage/adapters/memory.mjs +350 -0
  78. package/browser/storage/adapters/redis.mjs +497 -0
  79. package/browser/storage/adapters/upstash.mjs +299 -0
  80. package/browser/storage/adapters/vercel-kv.mjs +226 -0
  81. package/browser/storage/change-feed.mjs +189 -0
  82. package/browser/storage/encrypted-typed-storage.mjs +329 -0
  83. package/browser/storage/errors.mjs +92 -0
  84. package/browser/storage/factory.mjs +155 -0
  85. package/browser/storage/index.mjs +96 -0
  86. package/browser/storage/namespace.mjs +186 -0
  87. package/browser/storage/redis-error-listener.mjs +32 -0
  88. package/browser/storage/redis-url.mjs +66 -0
  89. package/browser/storage/typed-storage.mjs +171 -0
  90. package/browser/storage/utils/compare-and-delete.mjs +9 -0
  91. package/browser/storage/utils/index.mjs +24 -0
  92. package/browser/storage/utils/pattern.mjs +68 -0
  93. package/browser/storage/utils/ttl.mjs +48 -0
  94. package/browser/uri/index.mjs +19 -0
  95. package/browser/uri/uri-template.mjs +86 -0
  96. package/browser/uri/uri-validation.mjs +18 -0
  97. package/crypto/browser.d.ts +1 -13
  98. package/crypto/browser.js +1 -1
  99. package/crypto/node.js +1 -1
  100. package/crypto/web-rsa.d.ts +13 -0
  101. package/env/browser-runtime-context.js +1 -1
  102. package/env/runtime-context.js +1 -1
  103. package/esm/crypto/browser.mjs +1 -1
  104. package/esm/crypto/node.mjs +1 -1
  105. package/esm/env/browser-runtime-context.mjs +1 -1
  106. package/esm/env/runtime-context.mjs +1 -1
  107. package/esm/index.mjs +1 -1
  108. package/fs/fs.d.ts +20 -4
  109. package/fs/index.d.ts +1 -1
  110. package/index.d.ts +9 -3
  111. package/index.js +1 -1
  112. package/package.json +24 -8
  113. package/process/child-process.d.ts +2 -0
  114. package/process/index.d.ts +6 -0
  115. package/process/owned-process.d.ts +59 -0
  116. package/process/process-tree.d.ts +78 -0
  117. package/process/process-watch.d.ts +41 -0
  118. package/redaction/index.d.ts +2 -0
  119. package/redaction/redaction.d.ts +24 -0
  120. package/stdio-bridge/errors.d.ts +23 -0
  121. package/stdio-bridge/index.d.ts +9 -0
  122. package/stdio-bridge/list-changed.d.ts +3 -0
  123. package/stdio-bridge/state-machine.d.ts +61 -0
  124. package/stdio-bridge/stdio-framer.d.ts +49 -0
  125. package/stdio-bridge/types.d.ts +10 -0
  126. package/stdio-bridge/upstream-client.d.ts +66 -0
  127. package/storage/adapters/base.d.ts +2 -0
  128. package/storage/adapters/memory.d.ts +1 -0
  129. package/storage/adapters/redis.d.ts +3 -0
  130. package/storage/change-feed.d.ts +47 -0
  131. package/storage/factory.d.ts +6 -0
  132. package/storage/index.d.ts +3 -1
  133. package/storage/namespace.d.ts +2 -0
  134. package/storage/types.d.ts +46 -1
  135. package/storage/utils/compare-and-delete.d.ts +2 -0
@@ -0,0 +1,86 @@
1
+ // libs/utils/src/uri/uri-template.ts
2
+ function parseUriTemplate(template) {
3
+ if (template.length > 1e3) {
4
+ throw new Error("URI template too long (max 1000 characters)");
5
+ }
6
+ const paramCount = (template.match(/\{[^{}]+\}/g) || []).length;
7
+ if (paramCount > 50) {
8
+ throw new Error("URI template has too many parameters (max 50)");
9
+ }
10
+ const paramNames = [];
11
+ const placeholder = /\{([^{}]+)\}/g;
12
+ let regexStr = "";
13
+ let lastIndex = 0;
14
+ for (let m = placeholder.exec(template); m !== null; m = placeholder.exec(template)) {
15
+ regexStr += escapeRegex(template.slice(lastIndex, m.index));
16
+ const raw = m[1];
17
+ const reserved = raw.startsWith("+");
18
+ paramNames.push(reserved ? raw.slice(1) : raw);
19
+ regexStr += reserved ? "(.+?)" : "([^/]+)";
20
+ lastIndex = m.index + m[0].length;
21
+ }
22
+ regexStr += escapeRegex(template.slice(lastIndex));
23
+ return {
24
+ pattern: new RegExp(`^${regexStr}$`),
25
+ paramNames
26
+ };
27
+ }
28
+ function escapeRegex(literal) {
29
+ return literal.replace(/[.*+?^${}()|[\]\\]/g, (c) => `\\${c}`);
30
+ }
31
+ function matchUriTemplate(template, uri) {
32
+ const { pattern, paramNames } = parseUriTemplate(template);
33
+ const match = uri.match(pattern);
34
+ if (!match) return null;
35
+ const params = {};
36
+ paramNames.forEach((name, index) => {
37
+ params[name] = decodeURIComponent(match[index + 1]);
38
+ });
39
+ return params;
40
+ }
41
+ function expandUriTemplate(template, params) {
42
+ return template.replace(/\{([^{}]+)\}/g, (_, raw) => {
43
+ const reserved = raw.startsWith("+");
44
+ const paramName = reserved ? raw.slice(1) : raw;
45
+ const value = params[paramName];
46
+ if (value === void 0) {
47
+ throw new Error(`Missing parameter '${paramName}' for URI template '${template}'`);
48
+ }
49
+ return reserved ? encodeReserved(value) : encodeURIComponent(value);
50
+ });
51
+ }
52
+ function encodeReserved(value) {
53
+ const decoded = safeDecode(value);
54
+ return decoded.replace(/[^A-Za-z0-9\-._~:/?#[\]@!$&'()*+,;=]/g, (c) => encodeURIComponent(c));
55
+ }
56
+ function safeDecode(value) {
57
+ try {
58
+ return decodeURIComponent(value);
59
+ } catch {
60
+ return value.replace(/%[0-9A-Fa-f]{2}/g, (triplet) => {
61
+ try {
62
+ return decodeURIComponent(triplet);
63
+ } catch {
64
+ return triplet;
65
+ }
66
+ });
67
+ }
68
+ }
69
+ function extractTemplateParams(template) {
70
+ const params = [];
71
+ template.replace(/\{([^{}]+)\}/g, (_, raw) => {
72
+ params.push(raw.startsWith("+") ? raw.slice(1) : raw);
73
+ return "";
74
+ });
75
+ return params;
76
+ }
77
+ function isUriTemplate(uri) {
78
+ return /\{[^{}]+\}/.test(uri);
79
+ }
80
+ export {
81
+ expandUriTemplate,
82
+ extractTemplateParams,
83
+ isUriTemplate,
84
+ matchUriTemplate,
85
+ parseUriTemplate
86
+ };
@@ -0,0 +1,18 @@
1
+ // libs/utils/src/uri/uri-validation.ts
2
+ var RFC_3986_SCHEME_PATTERN = /^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//;
3
+ var SCHEME_EXTRACT_PATTERN = /^([a-zA-Z][a-zA-Z0-9+.-]*):/;
4
+ function isValidMcpUri(uri) {
5
+ return RFC_3986_SCHEME_PATTERN.test(uri);
6
+ }
7
+ function extractUriScheme(uri) {
8
+ const match = uri.match(SCHEME_EXTRACT_PATTERN);
9
+ return match ? match[1].toLowerCase() : null;
10
+ }
11
+ function isValidMcpUriTemplate(uriTemplate) {
12
+ return RFC_3986_SCHEME_PATTERN.test(uriTemplate);
13
+ }
14
+ export {
15
+ extractUriScheme,
16
+ isValidMcpUri,
17
+ isValidMcpUriTemplate
18
+ };
@@ -17,16 +17,4 @@ export declare function rsaVerifySync(): boolean;
17
17
  export declare function pemToPublicJwk(): JsonWebKey;
18
18
  export declare function generateRsaKeyPair(): never;
19
19
  export { isRsaPssAlg, jwtAlgToWebCryptoAlg } from './jwt-alg';
20
- /**
21
- * Verify an RSA signature using WebCrypto.
22
- *
23
- * Supports RS256/RS384/RS512 (RSASSA-PKCS1-v1_5) and PS256/PS384/PS512 (RSA-PSS).
24
- * Works in both browsers and Node.js environments that provide `crypto.subtle`.
25
- *
26
- * @param jwtAlg - JWT algorithm identifier (e.g. 'RS256', 'PS256')
27
- * @param data - The signed data (e.g. `headerB64.payloadB64`)
28
- * @param publicJwk - Public key in JWK format
29
- * @param signature - The signature bytes
30
- * @returns true if the signature is valid
31
- */
32
- export declare function rsaVerifyBrowser(jwtAlg: string, data: Uint8Array, publicJwk: JsonWebKey, signature: Uint8Array): Promise<boolean>;
20
+ export { rsaVerifyBrowser } from './web-rsa';
package/crypto/browser.js CHANGED
@@ -1 +1 @@
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_exports={};__export(browser_exports,{browserCrypto:()=>browserCrypto,cryptoProvider:()=>browserCrypto,generateRsaKeyPair:()=>generateRsaKeyPair,isRsaPssAlg:()=>isRsaPssAlg,jwtAlgToWebCryptoAlg:()=>jwtAlgToWebCryptoAlg,pemToPublicJwk:()=>pemToPublicJwk,rsaSignBase64Url:()=>rsaSignBase64Url,rsaVerify:()=>rsaVerify,rsaVerifyBrowser:()=>rsaVerifyBrowser,rsaVerifySync:()=>rsaVerifySync});module.exports=__toCommonJS(browser_exports);var import_aes=require("@noble/ciphers/aes.js");var import_hkdf=require("@noble/hashes/hkdf.js");var import_hmac=require("@noble/hashes/hmac.js");var import_sha2=require("@noble/hashes/sha2.js");var import_utils=require("@noble/hashes/utils.js");function isRsaPssAlg(jwtAlg){return jwtAlg.startsWith("PS")}var JWT_ALG_TO_WEB_CRYPTO={RS256:"SHA-256",RS384:"SHA-384",RS512:"SHA-512",PS256:"SHA-256",PS384:"SHA-384",PS512:"SHA-512"};function jwtAlgToWebCryptoAlg(jwtAlg){const webAlg=JWT_ALG_TO_WEB_CRYPTO[jwtAlg];if(!webAlg){throw new Error(`Unsupported JWT algorithm for WebCrypto: ${jwtAlg}`)}return webAlg}function toBytes(data){if(typeof data==="string"){return new TextEncoder().encode(data)}return data}function toHex(bytes){return Array.from(bytes).map(b=>b.toString(16).padStart(2,"0")).join("")}function generateUUID(){if(typeof crypto!=="undefined"&&typeof crypto.randomUUID==="function"){return crypto.randomUUID()}const bytes=(0,import_utils.randomBytes)(16);bytes[6]=bytes[6]&15|64;bytes[8]=bytes[8]&63|128;const hex=toHex(bytes);return`${hex.slice(0,8)}-${hex.slice(8,12)}-${hex.slice(12,16)}-${hex.slice(16,20)}-${hex.slice(20)}`}function constantTimeEqual(a,b){if(a.length!==b.length)return false;let result=0;for(let i=0;i<a.length;i++){result|=a[i]^b[i]}return result===0}var browserCrypto={randomUUID(){return generateUUID()},randomBytes(length){return(0,import_utils.randomBytes)(length)},sha256(data){return(0,import_sha2.sha256)(toBytes(data))},sha256Hex(data){return toHex((0,import_sha2.sha256)(toBytes(data)))},hmacSha256(key,data){return(0,import_hmac.hmac)(import_sha2.sha256,key,data)},hkdfSha256(ikm,salt,info,length){const effectiveSalt=salt.length>0?salt:new Uint8Array(32);return(0,import_hkdf.hkdf)(import_sha2.sha256,ikm,effectiveSalt,info,length)},encryptAesGcm(key,plaintext,iv){const cipher=(0,import_aes.gcm)(key,iv);const sealed=cipher.encrypt(plaintext);const ciphertext=sealed.slice(0,-16);const tag=sealed.slice(-16);return{ciphertext,tag}},decryptAesGcm(key,ciphertext,iv,tag){const cipher=(0,import_aes.gcm)(key,iv);const sealed=new Uint8Array(ciphertext.length+tag.length);sealed.set(ciphertext);sealed.set(tag,ciphertext.length);return cipher.decrypt(sealed)},timingSafeEqual(a,b){return constantTimeEqual(a,b)}};function nodeOnly(name){throw new Error(`${name} is only available in Node.js runtimes`)}function rsaVerify(){return nodeOnly("rsaVerify")}function rsaSignBase64Url(){return nodeOnly("rsaSignBase64Url")}function rsaVerifySync(){return nodeOnly("rsaVerifySync")}function pemToPublicJwk(){return nodeOnly("pemToPublicJwk")}function generateRsaKeyPair(){return nodeOnly("generateRsaKeyPair")}async function rsaVerifyBrowser(jwtAlg,data,publicJwk,signature){if(typeof globalThis.crypto?.subtle==="undefined"){throw new Error("WebCrypto API (crypto.subtle) is not available in this environment")}const webAlg=jwtAlgToWebCryptoAlg(jwtAlg);const isPss=isRsaPssAlg(jwtAlg);const algorithm={name:isPss?"RSA-PSS":"RSASSA-PKCS1-v1_5",hash:{name:webAlg}};const key=await globalThis.crypto.subtle.importKey("jwk",publicJwk,algorithm,false,["verify"]);const verifyAlgorithm=isPss?{name:"RSA-PSS",saltLength:getSaltLength(jwtAlg)}:{name:"RSASSA-PKCS1-v1_5"};const sigBuf=new Uint8Array(signature).buffer;const dataBuf=new Uint8Array(data).buffer;return globalThis.crypto.subtle.verify(verifyAlgorithm,key,sigBuf,dataBuf)}function getSaltLength(jwtAlg){switch(jwtAlg){case"PS256":return 32;case"PS384":return 48;case"PS512":return 64;default:return 32}}0&&(module.exports={browserCrypto,cryptoProvider,generateRsaKeyPair,isRsaPssAlg,jwtAlgToWebCryptoAlg,pemToPublicJwk,rsaSignBase64Url,rsaVerify,rsaVerifyBrowser,rsaVerifySync});
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_exports={};__export(browser_exports,{browserCrypto:()=>browserCrypto,cryptoProvider:()=>browserCrypto,generateRsaKeyPair:()=>generateRsaKeyPair,isRsaPssAlg:()=>isRsaPssAlg,jwtAlgToWebCryptoAlg:()=>jwtAlgToWebCryptoAlg,pemToPublicJwk:()=>pemToPublicJwk,rsaSignBase64Url:()=>rsaSignBase64Url,rsaVerify:()=>rsaVerify,rsaVerifyBrowser:()=>rsaVerifyBrowser,rsaVerifySync:()=>rsaVerifySync});module.exports=__toCommonJS(browser_exports);var import_aes=require("@noble/ciphers/aes.js");var import_hkdf=require("@noble/hashes/hkdf.js");var import_hmac=require("@noble/hashes/hmac.js");var import_sha2=require("@noble/hashes/sha2.js");var import_utils=require("@noble/hashes/utils.js");function isRsaPssAlg(jwtAlg){return jwtAlg.startsWith("PS")}var JWT_ALG_TO_WEB_CRYPTO={RS256:"SHA-256",RS384:"SHA-384",RS512:"SHA-512",PS256:"SHA-256",PS384:"SHA-384",PS512:"SHA-512"};function jwtAlgToWebCryptoAlg(jwtAlg){const webAlg=JWT_ALG_TO_WEB_CRYPTO[jwtAlg];if(!webAlg){throw new Error(`Unsupported JWT algorithm for WebCrypto: ${jwtAlg}`)}return webAlg}async function rsaVerifyBrowser(jwtAlg,data,publicJwk,signature){if(typeof globalThis.crypto?.subtle==="undefined"){throw new Error("WebCrypto API (crypto.subtle) is not available in this environment")}const webAlg=jwtAlgToWebCryptoAlg(jwtAlg);const isPss=isRsaPssAlg(jwtAlg);const algorithm={name:isPss?"RSA-PSS":"RSASSA-PKCS1-v1_5",hash:{name:webAlg}};const key=await globalThis.crypto.subtle.importKey("jwk",publicJwk,algorithm,false,["verify"]);const verifyAlgorithm=isPss?{name:"RSA-PSS",saltLength:getSaltLength(jwtAlg)}:{name:"RSASSA-PKCS1-v1_5"};const sigBuf=new Uint8Array(signature).buffer;const dataBuf=new Uint8Array(data).buffer;return globalThis.crypto.subtle.verify(verifyAlgorithm,key,sigBuf,dataBuf)}function getSaltLength(jwtAlg){switch(jwtAlg){case"PS256":return 32;case"PS384":return 48;case"PS512":return 64;default:return 32}}function toBytes(data){if(typeof data==="string"){return new TextEncoder().encode(data)}return data}function toHex(bytes){return Array.from(bytes).map(b=>b.toString(16).padStart(2,"0")).join("")}function generateUUID(){if(typeof crypto!=="undefined"&&typeof crypto.randomUUID==="function"){return crypto.randomUUID()}const bytes=(0,import_utils.randomBytes)(16);bytes[6]=bytes[6]&15|64;bytes[8]=bytes[8]&63|128;const hex=toHex(bytes);return`${hex.slice(0,8)}-${hex.slice(8,12)}-${hex.slice(12,16)}-${hex.slice(16,20)}-${hex.slice(20)}`}function constantTimeEqual(a,b){if(a.length!==b.length)return false;let result=0;for(let i=0;i<a.length;i++){result|=a[i]^b[i]}return result===0}var browserCrypto={randomUUID(){return generateUUID()},randomBytes(length){return(0,import_utils.randomBytes)(length)},sha256(data){return(0,import_sha2.sha256)(toBytes(data))},sha256Hex(data){return toHex((0,import_sha2.sha256)(toBytes(data)))},hmacSha256(key,data){return(0,import_hmac.hmac)(import_sha2.sha256,key,data)},hkdfSha256(ikm,salt,info,length){const effectiveSalt=salt.length>0?salt:new Uint8Array(32);return(0,import_hkdf.hkdf)(import_sha2.sha256,ikm,effectiveSalt,info,length)},encryptAesGcm(key,plaintext,iv){const cipher=(0,import_aes.gcm)(key,iv);const sealed=cipher.encrypt(plaintext);const ciphertext=sealed.slice(0,-16);const tag=sealed.slice(-16);return{ciphertext,tag}},decryptAesGcm(key,ciphertext,iv,tag){const cipher=(0,import_aes.gcm)(key,iv);const sealed=new Uint8Array(ciphertext.length+tag.length);sealed.set(ciphertext);sealed.set(tag,ciphertext.length);return cipher.decrypt(sealed)},timingSafeEqual(a,b){return constantTimeEqual(a,b)}};function nodeOnly(name){throw new Error(`${name} is only available in Node.js runtimes`)}function rsaVerify(){return nodeOnly("rsaVerify")}function rsaSignBase64Url(){return nodeOnly("rsaSignBase64Url")}function rsaVerifySync(){return nodeOnly("rsaVerifySync")}function pemToPublicJwk(){return nodeOnly("pemToPublicJwk")}function generateRsaKeyPair(){return nodeOnly("generateRsaKeyPair")}0&&(module.exports={browserCrypto,cryptoProvider,generateRsaKeyPair,isRsaPssAlg,jwtAlgToWebCryptoAlg,pemToPublicJwk,rsaSignBase64Url,rsaVerify,rsaVerifyBrowser,rsaVerifySync});
package/crypto/node.js CHANGED
@@ -1 +1 @@
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
+ "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)}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(data).digest();return toUint8Array(hash)},sha256Hex(data){return import_node_crypto.default.createHash("sha256").update(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});
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Verify an RSA signature using WebCrypto.
3
+ *
4
+ * Supports RS256/RS384/RS512 (RSASSA-PKCS1-v1_5) and PS256/PS384/PS512 (RSA-PSS).
5
+ * Works in both browsers and Node.js environments that provide `crypto.subtle`.
6
+ *
7
+ * @param jwtAlg - JWT algorithm identifier (e.g. 'RS256', 'PS256')
8
+ * @param data - The signed data (e.g. `headerB64.payloadB64`)
9
+ * @param publicJwk - Public key in JWK format
10
+ * @param signature - The signature bytes
11
+ * @returns true if the signature is valid
12
+ */
13
+ export declare function rsaVerifyBrowser(jwtAlg: string, data: Uint8Array, publicJwk: JsonWebKey, signature: Uint8Array): Promise<boolean>;
@@ -1 +1 @@
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});
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.internalZ.object({os:import_lazy_zod.internalZ.array(import_lazy_zod.internalZ.string().min(1)).optional(),platform:import_lazy_zod.internalZ.array(import_lazy_zod.internalZ.string().min(1)).optional(),runtime:import_lazy_zod.internalZ.array(import_lazy_zod.internalZ.string().min(1)).optional(),deployment:import_lazy_zod.internalZ.array(import_lazy_zod.internalZ.string().min(1)).optional(),provider:import_lazy_zod.internalZ.array(import_lazy_zod.internalZ.string().min(1)).optional(),target:import_lazy_zod.internalZ.array(import_lazy_zod.internalZ.string().min(1)).optional(),surface:import_lazy_zod.internalZ.array(import_lazy_zod.internalZ.enum(["mcp","cli","http-trigger","job","agent","webmcp"])).optional(),env:import_lazy_zod.internalZ.array(import_lazy_zod.internalZ.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});
@@ -1 +1 @@
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 runtime_context_exports={};__export(runtime_context_exports,{checkEntryAvailability:()=>checkEntryAvailability,detectRuntimeContext:()=>detectRuntimeContext,entryAvailabilitySchema:()=>entryAvailabilitySchema,getRuntimeContext:()=>getRuntimeContext,isEntryAvailable:()=>isEntryAvailable,resetRuntimeContext:()=>resetRuntimeContext});module.exports=__toCommonJS(runtime_context_exports);var import_lazy_zod=require("@frontmcp/lazy-zod");var import_env=require("#env");var cached;function getBuildTarget(){if(cached)return cached;cached=resolveBuildTarget();return cached}function resolveBuildTarget(){const globalAny=globalThis;const fromGlobal=globalAny.FRONTMCP_BUILD_TARGET;if(typeof fromGlobal==="string"&&isKnownTarget(fromGlobal))return fromGlobal;const fromEnv=typeof process!=="undefined"?process.env?.["FRONTMCP_BUILD_TARGET"]:void 0;if(typeof fromEnv==="string"&&isKnownTarget(fromEnv))return fromEnv;return"unknown"}function isKnownTarget(value){return value==="unknown"||value==="node"||value==="distributed"||value==="cli"||value==="vercel"||value==="lambda"||value==="cloudflare"||value==="browser"||value==="sdk"||value==="mcpb"}var cached2;function detectProvider(){if(cached2)return cached2;cached2=detectProviderUncached();return cached2}function detectProviderUncached(){const explicit=process.env["FRONTMCP_PROVIDER"];if(explicit&&isKnownProvider(explicit))return explicit;if(process.env["VERCEL"])return"vercel";if(process.env["AWS_LAMBDA_FUNCTION_NAME"])return"lambda";if(process.env["CF_PAGES"])return"cloudflare";if(process.env["NETLIFY"])return"netlify";if(process.env["AZURE_FUNCTIONS_ENVIRONMENT"])return"azure";if(process.env["K_SERVICE"])return"gcp";if(process.env["FLY_APP_NAME"])return"fly";if(process.env["RENDER"])return"render";if(process.env["RAILWAY_ENVIRONMENT"])return"railway";try{const nodeFs=require("node:fs");if(nodeFs.existsSync("/.dockerenv"))return"docker"}catch{}return"bare"}function isKnownProvider(value){return value==="bare"||value==="docker"||value==="vercel"||value==="lambda"||value==="cloudflare"||value==="netlify"||value==="azure"||value==="gcp"||value==="fly"||value==="render"||value==="railway"}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 detectRuntime(){if(typeof globalThis!=="undefined"&&"Bun"in globalThis)return"bun";if(typeof globalThis!=="undefined"&&"Deno"in globalThis)return"deno";if((0,import_env.isEdgeRuntime)())return"edge";return"node"}function detectDeployment(runtime){const explicit=process.env["FRONTMCP_DEPLOYMENT_MODE"];if(explicit==="distributed")return"distributed";if(explicit==="serverless")return"serverless";if(runtime==="browser")return"browser";if((0,import_env.isServerless)())return"serverless";return"standalone"}function detectRuntimeContext(){const runtime=detectRuntime();const os=process.platform;return{os,platform:os,runtime,deployment:detectDeployment(runtime),provider:detectProvider(),target:getBuildTarget(),env:(0,import_env.getNodeEnv)()||"development"}}var cached3;function getRuntimeContext(){if(!cached3){const detected=detectRuntimeContext();Object.defineProperty(detected,"env",{get:()=>(0,import_env.getNodeEnv)()||"development",enumerable:true,configurable:true});cached3=detected}return cached3}function resetRuntimeContext(){cached3=void 0}0&&(module.exports={checkEntryAvailability,detectRuntimeContext,entryAvailabilitySchema,getRuntimeContext,isEntryAvailable,resetRuntimeContext});
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 runtime_context_exports={};__export(runtime_context_exports,{checkEntryAvailability:()=>checkEntryAvailability,detectRuntimeContext:()=>detectRuntimeContext,entryAvailabilitySchema:()=>entryAvailabilitySchema,getRuntimeContext:()=>getRuntimeContext,isEntryAvailable:()=>isEntryAvailable,resetRuntimeContext:()=>resetRuntimeContext});module.exports=__toCommonJS(runtime_context_exports);var import_lazy_zod=require("@frontmcp/lazy-zod");var import_env=require("#env");var cached;function getBuildTarget(){if(cached)return cached;cached=resolveBuildTarget();return cached}function resolveBuildTarget(){const globalAny=globalThis;const fromGlobal=globalAny.FRONTMCP_BUILD_TARGET;if(typeof fromGlobal==="string"&&isKnownTarget(fromGlobal))return fromGlobal;const fromEnv=typeof process!=="undefined"?process.env?.["FRONTMCP_BUILD_TARGET"]:void 0;if(typeof fromEnv==="string"&&isKnownTarget(fromEnv))return fromEnv;return"unknown"}function isKnownTarget(value){return value==="unknown"||value==="node"||value==="distributed"||value==="cli"||value==="vercel"||value==="lambda"||value==="cloudflare"||value==="browser"||value==="sdk"||value==="mcpb"}var cached2;function detectProvider(){if(cached2)return cached2;cached2=detectProviderUncached();return cached2}function detectProviderUncached(){const explicit=process.env["FRONTMCP_PROVIDER"];if(explicit&&isKnownProvider(explicit))return explicit;if(process.env["VERCEL"])return"vercel";if(process.env["AWS_LAMBDA_FUNCTION_NAME"])return"lambda";if(process.env["CF_PAGES"])return"cloudflare";if(process.env["NETLIFY"])return"netlify";if(process.env["AZURE_FUNCTIONS_ENVIRONMENT"])return"azure";if(process.env["K_SERVICE"])return"gcp";if(process.env["FLY_APP_NAME"])return"fly";if(process.env["RENDER"])return"render";if(process.env["RAILWAY_ENVIRONMENT"])return"railway";try{const nodeFs=require("node:fs");if(nodeFs.existsSync("/.dockerenv"))return"docker"}catch{}return"bare"}function isKnownProvider(value){return value==="bare"||value==="docker"||value==="vercel"||value==="lambda"||value==="cloudflare"||value==="netlify"||value==="azure"||value==="gcp"||value==="fly"||value==="render"||value==="railway"}var entryAvailabilitySchema=import_lazy_zod.internalZ.object({os:import_lazy_zod.internalZ.array(import_lazy_zod.internalZ.string().min(1)).optional(),platform:import_lazy_zod.internalZ.array(import_lazy_zod.internalZ.string().min(1)).optional(),runtime:import_lazy_zod.internalZ.array(import_lazy_zod.internalZ.string().min(1)).optional(),deployment:import_lazy_zod.internalZ.array(import_lazy_zod.internalZ.string().min(1)).optional(),provider:import_lazy_zod.internalZ.array(import_lazy_zod.internalZ.string().min(1)).optional(),target:import_lazy_zod.internalZ.array(import_lazy_zod.internalZ.string().min(1)).optional(),surface:import_lazy_zod.internalZ.array(import_lazy_zod.internalZ.enum(["mcp","cli","http-trigger","job","agent","webmcp"])).optional(),env:import_lazy_zod.internalZ.array(import_lazy_zod.internalZ.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 detectRuntime(){if(typeof globalThis!=="undefined"&&"Bun"in globalThis)return"bun";if(typeof globalThis!=="undefined"&&"Deno"in globalThis)return"deno";if((0,import_env.isEdgeRuntime)())return"edge";return"node"}function detectDeployment(runtime){const explicit=process.env["FRONTMCP_DEPLOYMENT_MODE"];if(explicit==="distributed")return"distributed";if(explicit==="serverless")return"serverless";if(runtime==="browser")return"browser";if((0,import_env.isServerless)())return"serverless";return"standalone"}function detectRuntimeContext(){const runtime=detectRuntime();const os=process.platform;return{os,platform:os,runtime,deployment:detectDeployment(runtime),provider:detectProvider(),target:getBuildTarget(),env:(0,import_env.getNodeEnv)()||"development"}}var cached3;function getRuntimeContext(){if(!cached3){const detected=detectRuntimeContext();Object.defineProperty(detected,"env",{get:()=>(0,import_env.getNodeEnv)()||"development",enumerable:true,configurable:true});cached3=detected}return cached3}function resetRuntimeContext(){cached3=void 0}0&&(module.exports={checkEntryAvailability,detectRuntimeContext,entryAvailabilitySchema,getRuntimeContext,isEntryAvailable,resetRuntimeContext});
@@ -1 +1 @@
1
- import{gcm}from"@noble/ciphers/aes.js";import{hkdf}from"@noble/hashes/hkdf.js";import{hmac}from"@noble/hashes/hmac.js";import{sha256 as sha256Hash}from"@noble/hashes/sha2.js";import{randomBytes as nobleRandomBytes}from"@noble/hashes/utils.js";function isRsaPssAlg(jwtAlg){return jwtAlg.startsWith("PS")}var JWT_ALG_TO_WEB_CRYPTO={RS256:"SHA-256",RS384:"SHA-384",RS512:"SHA-512",PS256:"SHA-256",PS384:"SHA-384",PS512:"SHA-512"};function jwtAlgToWebCryptoAlg(jwtAlg){const webAlg=JWT_ALG_TO_WEB_CRYPTO[jwtAlg];if(!webAlg){throw new Error(`Unsupported JWT algorithm for WebCrypto: ${jwtAlg}`)}return webAlg}function toBytes(data){if(typeof data==="string"){return new TextEncoder().encode(data)}return data}function toHex(bytes){return Array.from(bytes).map(b=>b.toString(16).padStart(2,"0")).join("")}function generateUUID(){if(typeof crypto!=="undefined"&&typeof crypto.randomUUID==="function"){return crypto.randomUUID()}const bytes=nobleRandomBytes(16);bytes[6]=bytes[6]&15|64;bytes[8]=bytes[8]&63|128;const hex=toHex(bytes);return`${hex.slice(0,8)}-${hex.slice(8,12)}-${hex.slice(12,16)}-${hex.slice(16,20)}-${hex.slice(20)}`}function constantTimeEqual(a,b){if(a.length!==b.length)return false;let result=0;for(let i=0;i<a.length;i++){result|=a[i]^b[i]}return result===0}var browserCrypto={randomUUID(){return generateUUID()},randomBytes(length){return nobleRandomBytes(length)},sha256(data){return sha256Hash(toBytes(data))},sha256Hex(data){return toHex(sha256Hash(toBytes(data)))},hmacSha256(key,data){return hmac(sha256Hash,key,data)},hkdfSha256(ikm,salt,info,length){const effectiveSalt=salt.length>0?salt:new Uint8Array(32);return hkdf(sha256Hash,ikm,effectiveSalt,info,length)},encryptAesGcm(key,plaintext,iv){const cipher=gcm(key,iv);const sealed=cipher.encrypt(plaintext);const ciphertext=sealed.slice(0,-16);const tag=sealed.slice(-16);return{ciphertext,tag}},decryptAesGcm(key,ciphertext,iv,tag){const cipher=gcm(key,iv);const sealed=new Uint8Array(ciphertext.length+tag.length);sealed.set(ciphertext);sealed.set(tag,ciphertext.length);return cipher.decrypt(sealed)},timingSafeEqual(a,b){return constantTimeEqual(a,b)}};function nodeOnly(name){throw new Error(`${name} is only available in Node.js runtimes`)}function rsaVerify(){return nodeOnly("rsaVerify")}function rsaSignBase64Url(){return nodeOnly("rsaSignBase64Url")}function rsaVerifySync(){return nodeOnly("rsaVerifySync")}function pemToPublicJwk(){return nodeOnly("pemToPublicJwk")}function generateRsaKeyPair(){return nodeOnly("generateRsaKeyPair")}async function rsaVerifyBrowser(jwtAlg,data,publicJwk,signature){if(typeof globalThis.crypto?.subtle==="undefined"){throw new Error("WebCrypto API (crypto.subtle) is not available in this environment")}const webAlg=jwtAlgToWebCryptoAlg(jwtAlg);const isPss=isRsaPssAlg(jwtAlg);const algorithm={name:isPss?"RSA-PSS":"RSASSA-PKCS1-v1_5",hash:{name:webAlg}};const key=await globalThis.crypto.subtle.importKey("jwk",publicJwk,algorithm,false,["verify"]);const verifyAlgorithm=isPss?{name:"RSA-PSS",saltLength:getSaltLength(jwtAlg)}:{name:"RSASSA-PKCS1-v1_5"};const sigBuf=new Uint8Array(signature).buffer;const dataBuf=new Uint8Array(data).buffer;return globalThis.crypto.subtle.verify(verifyAlgorithm,key,sigBuf,dataBuf)}function getSaltLength(jwtAlg){switch(jwtAlg){case"PS256":return 32;case"PS384":return 48;case"PS512":return 64;default:return 32}}export{browserCrypto,browserCrypto as cryptoProvider,generateRsaKeyPair,isRsaPssAlg,jwtAlgToWebCryptoAlg,pemToPublicJwk,rsaSignBase64Url,rsaVerify,rsaVerifyBrowser,rsaVerifySync};
1
+ import{gcm}from"@noble/ciphers/aes.js";import{hkdf}from"@noble/hashes/hkdf.js";import{hmac}from"@noble/hashes/hmac.js";import{sha256 as sha256Hash}from"@noble/hashes/sha2.js";import{randomBytes as nobleRandomBytes}from"@noble/hashes/utils.js";function isRsaPssAlg(jwtAlg){return jwtAlg.startsWith("PS")}var JWT_ALG_TO_WEB_CRYPTO={RS256:"SHA-256",RS384:"SHA-384",RS512:"SHA-512",PS256:"SHA-256",PS384:"SHA-384",PS512:"SHA-512"};function jwtAlgToWebCryptoAlg(jwtAlg){const webAlg=JWT_ALG_TO_WEB_CRYPTO[jwtAlg];if(!webAlg){throw new Error(`Unsupported JWT algorithm for WebCrypto: ${jwtAlg}`)}return webAlg}async function rsaVerifyBrowser(jwtAlg,data,publicJwk,signature){if(typeof globalThis.crypto?.subtle==="undefined"){throw new Error("WebCrypto API (crypto.subtle) is not available in this environment")}const webAlg=jwtAlgToWebCryptoAlg(jwtAlg);const isPss=isRsaPssAlg(jwtAlg);const algorithm={name:isPss?"RSA-PSS":"RSASSA-PKCS1-v1_5",hash:{name:webAlg}};const key=await globalThis.crypto.subtle.importKey("jwk",publicJwk,algorithm,false,["verify"]);const verifyAlgorithm=isPss?{name:"RSA-PSS",saltLength:getSaltLength(jwtAlg)}:{name:"RSASSA-PKCS1-v1_5"};const sigBuf=new Uint8Array(signature).buffer;const dataBuf=new Uint8Array(data).buffer;return globalThis.crypto.subtle.verify(verifyAlgorithm,key,sigBuf,dataBuf)}function getSaltLength(jwtAlg){switch(jwtAlg){case"PS256":return 32;case"PS384":return 48;case"PS512":return 64;default:return 32}}function toBytes(data){if(typeof data==="string"){return new TextEncoder().encode(data)}return data}function toHex(bytes){return Array.from(bytes).map(b=>b.toString(16).padStart(2,"0")).join("")}function generateUUID(){if(typeof crypto!=="undefined"&&typeof crypto.randomUUID==="function"){return crypto.randomUUID()}const bytes=nobleRandomBytes(16);bytes[6]=bytes[6]&15|64;bytes[8]=bytes[8]&63|128;const hex=toHex(bytes);return`${hex.slice(0,8)}-${hex.slice(8,12)}-${hex.slice(12,16)}-${hex.slice(16,20)}-${hex.slice(20)}`}function constantTimeEqual(a,b){if(a.length!==b.length)return false;let result=0;for(let i=0;i<a.length;i++){result|=a[i]^b[i]}return result===0}var browserCrypto={randomUUID(){return generateUUID()},randomBytes(length){return nobleRandomBytes(length)},sha256(data){return sha256Hash(toBytes(data))},sha256Hex(data){return toHex(sha256Hash(toBytes(data)))},hmacSha256(key,data){return hmac(sha256Hash,key,data)},hkdfSha256(ikm,salt,info,length){const effectiveSalt=salt.length>0?salt:new Uint8Array(32);return hkdf(sha256Hash,ikm,effectiveSalt,info,length)},encryptAesGcm(key,plaintext,iv){const cipher=gcm(key,iv);const sealed=cipher.encrypt(plaintext);const ciphertext=sealed.slice(0,-16);const tag=sealed.slice(-16);return{ciphertext,tag}},decryptAesGcm(key,ciphertext,iv,tag){const cipher=gcm(key,iv);const sealed=new Uint8Array(ciphertext.length+tag.length);sealed.set(ciphertext);sealed.set(tag,ciphertext.length);return cipher.decrypt(sealed)},timingSafeEqual(a,b){return constantTimeEqual(a,b)}};function nodeOnly(name){throw new Error(`${name} is only available in Node.js runtimes`)}function rsaVerify(){return nodeOnly("rsaVerify")}function rsaSignBase64Url(){return nodeOnly("rsaSignBase64Url")}function rsaVerifySync(){return nodeOnly("rsaVerifySync")}function pemToPublicJwk(){return nodeOnly("pemToPublicJwk")}function generateRsaKeyPair(){return nodeOnly("generateRsaKeyPair")}export{browserCrypto,browserCrypto as cryptoProvider,generateRsaKeyPair,isRsaPssAlg,jwtAlgToWebCryptoAlg,pemToPublicJwk,rsaSignBase64Url,rsaVerify,rsaVerifyBrowser,rsaVerifySync};
@@ -1 +1 @@
1
- import crypto from"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 crypto.randomUUID()},randomBytes(length){return toUint8Array(crypto.randomBytes(length))},sha256(data){const hash=crypto.createHash("sha256").update(toBuffer(data)).digest();return toUint8Array(hash)},sha256Hex(data){return crypto.createHash("sha256").update(toBuffer(data)).digest("hex")},hmacSha256(key,data){const hmac=crypto.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=crypto.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=crypto.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=crypto.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=crypto.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 crypto.timingSafeEqual(Buffer.from(a),Buffer.from(b))}};function generateRsaKeyPair(modulusLength=2048,alg="RS256"){const kid=`rsa-key-${Date.now()}-${crypto.randomBytes(8).toString("hex")}`;const{privateKey,publicKey}=crypto.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 crypto.sign(algorithm,data,signingKey)}function rsaVerify(jwtAlg,data,publicJwk,signature){const publicKey=crypto.createPublicKey({key:publicJwk,format:"jwk"});const nodeAlgorithm=jwtAlgToNodeAlg(jwtAlg);const verifyKey=isRsaPssAlg(jwtAlg)?{key:publicKey,padding:crypto.constants.RSA_PKCS1_PSS_PADDING,saltLength:crypto.constants.RSA_PSS_SALTLEN_DIGEST}:publicKey;return crypto.verify(nodeAlgorithm,data,verifyKey,signature)}function rsaSignBase64Url(jwtAlg,data,privateJwk){const privateKey=crypto.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:crypto.constants.RSA_PKCS1_PSS_PADDING,saltLength:crypto.constants.RSA_PSS_SALTLEN_DIGEST}):rsaSign(nodeAlgorithm,buf,privateKey);return sig.toString("base64url")}function rsaVerifySync(jwtAlg,data,publicJwk,signature){try{const publicKey=crypto.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 crypto.verify(null,dataBuf,publicKey,sigBuf)}const nodeAlgorithm=jwtAlgToNodeAlg(jwtAlg);const verifyKey=isRsaPssAlg(jwtAlg)?{key:publicKey,padding:crypto.constants.RSA_PKCS1_PSS_PADDING,saltLength:crypto.constants.RSA_PSS_SALTLEN_DIGEST}:publicKey;return crypto.verify(nodeAlgorithm,dataBuf,verifyKey,sigBuf)}catch{return false}}function pemToPublicJwk(pem){const key=crypto.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:crypto.constants.RSA_PKCS1_PSS_PADDING,saltLength:crypto.constants.RSA_PSS_SALTLEN_DIGEST}:void 0);const signatureB64=signature.toString("base64url");return`${headerB64}.${payloadB64}.${signatureB64}`}export{createSignedJwt,nodeCrypto as cryptoProvider,generateRsaKeyPair,isRsaPssAlg,jwtAlgToNodeAlg,nodeCrypto,pemToPublicJwk,rsaSign,rsaSignBase64Url,rsaVerify,rsaVerifySync};
1
+ import crypto from"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)}var nodeCrypto={randomUUID(){return crypto.randomUUID()},randomBytes(length){return toUint8Array(crypto.randomBytes(length))},sha256(data){const hash=crypto.createHash("sha256").update(data).digest();return toUint8Array(hash)},sha256Hex(data){return crypto.createHash("sha256").update(data).digest("hex")},hmacSha256(key,data){const hmac=crypto.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=crypto.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=crypto.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=crypto.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=crypto.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 crypto.timingSafeEqual(Buffer.from(a),Buffer.from(b))}};function generateRsaKeyPair(modulusLength=2048,alg="RS256"){const kid=`rsa-key-${Date.now()}-${crypto.randomBytes(8).toString("hex")}`;const{privateKey,publicKey}=crypto.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 crypto.sign(algorithm,data,signingKey)}function rsaVerify(jwtAlg,data,publicJwk,signature){const publicKey=crypto.createPublicKey({key:publicJwk,format:"jwk"});const nodeAlgorithm=jwtAlgToNodeAlg(jwtAlg);const verifyKey=isRsaPssAlg(jwtAlg)?{key:publicKey,padding:crypto.constants.RSA_PKCS1_PSS_PADDING,saltLength:crypto.constants.RSA_PSS_SALTLEN_DIGEST}:publicKey;return crypto.verify(nodeAlgorithm,data,verifyKey,signature)}function rsaSignBase64Url(jwtAlg,data,privateJwk){const privateKey=crypto.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:crypto.constants.RSA_PKCS1_PSS_PADDING,saltLength:crypto.constants.RSA_PSS_SALTLEN_DIGEST}):rsaSign(nodeAlgorithm,buf,privateKey);return sig.toString("base64url")}function rsaVerifySync(jwtAlg,data,publicJwk,signature){try{const publicKey=crypto.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 crypto.verify(null,dataBuf,publicKey,sigBuf)}const nodeAlgorithm=jwtAlgToNodeAlg(jwtAlg);const verifyKey=isRsaPssAlg(jwtAlg)?{key:publicKey,padding:crypto.constants.RSA_PKCS1_PSS_PADDING,saltLength:crypto.constants.RSA_PSS_SALTLEN_DIGEST}:publicKey;return crypto.verify(nodeAlgorithm,dataBuf,verifyKey,sigBuf)}catch{return false}}function pemToPublicJwk(pem){const key=crypto.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:crypto.constants.RSA_PKCS1_PSS_PADDING,saltLength:crypto.constants.RSA_PSS_SALTLEN_DIGEST}:void 0);const signatureB64=signature.toString("base64url");return`${headerB64}.${payloadB64}.${signatureB64}`}export{createSignedJwt,nodeCrypto as cryptoProvider,generateRsaKeyPair,isRsaPssAlg,jwtAlgToNodeAlg,nodeCrypto,pemToPublicJwk,rsaSign,rsaSignBase64Url,rsaVerify,rsaVerifySync};
@@ -1 +1 @@
1
- import{z}from"@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=z.object({os:z.array(z.string().min(1)).optional(),platform:z.array(z.string().min(1)).optional(),runtime:z.array(z.string().min(1)).optional(),deployment:z.array(z.string().min(1)).optional(),provider:z.array(z.string().min(1)).optional(),target:z.array(z.string().min(1)).optional(),surface:z.array(z.enum(["mcp","cli","http-trigger","job","agent","webmcp"])).optional(),env:z.array(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}export{checkEntryAvailability,detectRuntimeContext,entryAvailabilitySchema,getRuntimeContext,isEntryAvailable,resetRuntimeContext};
1
+ import{internalZ as z}from"@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=z.object({os:z.array(z.string().min(1)).optional(),platform:z.array(z.string().min(1)).optional(),runtime:z.array(z.string().min(1)).optional(),deployment:z.array(z.string().min(1)).optional(),provider:z.array(z.string().min(1)).optional(),target:z.array(z.string().min(1)).optional(),surface:z.array(z.enum(["mcp","cli","http-trigger","job","agent","webmcp"])).optional(),env:z.array(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}export{checkEntryAvailability,detectRuntimeContext,entryAvailabilitySchema,getRuntimeContext,isEntryAvailable,resetRuntimeContext};
@@ -1,4 +1,4 @@
1
1
  var __frontmcpModule = typeof process !== "undefined" && typeof process.getBuiltinModule === "function" ? process.getBuiltinModule("module") : undefined;
2
2
  const require = __frontmcpModule ? __frontmcpModule.createRequire(import.meta.url || 'file:///') : undefined;
3
3
  // __frontmcpCreateRequire
4
- var __require=(x=>typeof require!=="undefined"?require:typeof Proxy!=="undefined"?new Proxy(x,{get:(a,b)=>(typeof require!=="undefined"?require:a)[b]}):x)(function(x){if(typeof require!=="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+x+'" is not supported')});import{z}from"@frontmcp/lazy-zod";import{getNodeEnv,isEdgeRuntime,isServerless}from"#env";var cached;function getBuildTarget(){if(cached)return cached;cached=resolveBuildTarget();return cached}function resolveBuildTarget(){const globalAny=globalThis;const fromGlobal=globalAny.FRONTMCP_BUILD_TARGET;if(typeof fromGlobal==="string"&&isKnownTarget(fromGlobal))return fromGlobal;const fromEnv=typeof process!=="undefined"?process.env?.["FRONTMCP_BUILD_TARGET"]:void 0;if(typeof fromEnv==="string"&&isKnownTarget(fromEnv))return fromEnv;return"unknown"}function isKnownTarget(value){return value==="unknown"||value==="node"||value==="distributed"||value==="cli"||value==="vercel"||value==="lambda"||value==="cloudflare"||value==="browser"||value==="sdk"||value==="mcpb"}var cached2;function detectProvider(){if(cached2)return cached2;cached2=detectProviderUncached();return cached2}function detectProviderUncached(){const explicit=process.env["FRONTMCP_PROVIDER"];if(explicit&&isKnownProvider(explicit))return explicit;if(process.env["VERCEL"])return"vercel";if(process.env["AWS_LAMBDA_FUNCTION_NAME"])return"lambda";if(process.env["CF_PAGES"])return"cloudflare";if(process.env["NETLIFY"])return"netlify";if(process.env["AZURE_FUNCTIONS_ENVIRONMENT"])return"azure";if(process.env["K_SERVICE"])return"gcp";if(process.env["FLY_APP_NAME"])return"fly";if(process.env["RENDER"])return"render";if(process.env["RAILWAY_ENVIRONMENT"])return"railway";try{const nodeFs=__require("node:fs");if(nodeFs.existsSync("/.dockerenv"))return"docker"}catch{}return"bare"}function isKnownProvider(value){return value==="bare"||value==="docker"||value==="vercel"||value==="lambda"||value==="cloudflare"||value==="netlify"||value==="azure"||value==="gcp"||value==="fly"||value==="render"||value==="railway"}var entryAvailabilitySchema=z.object({os:z.array(z.string().min(1)).optional(),platform:z.array(z.string().min(1)).optional(),runtime:z.array(z.string().min(1)).optional(),deployment:z.array(z.string().min(1)).optional(),provider:z.array(z.string().min(1)).optional(),target:z.array(z.string().min(1)).optional(),surface:z.array(z.enum(["mcp","cli","http-trigger","job","agent","webmcp"])).optional(),env:z.array(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 detectRuntime(){if(typeof globalThis!=="undefined"&&"Bun"in globalThis)return"bun";if(typeof globalThis!=="undefined"&&"Deno"in globalThis)return"deno";if(isEdgeRuntime())return"edge";return"node"}function detectDeployment(runtime){const explicit=process.env["FRONTMCP_DEPLOYMENT_MODE"];if(explicit==="distributed")return"distributed";if(explicit==="serverless")return"serverless";if(runtime==="browser")return"browser";if(isServerless())return"serverless";return"standalone"}function detectRuntimeContext(){const runtime=detectRuntime();const os=process.platform;return{os,platform:os,runtime,deployment:detectDeployment(runtime),provider:detectProvider(),target:getBuildTarget(),env:getNodeEnv()||"development"}}var cached3;function getRuntimeContext(){if(!cached3){const detected=detectRuntimeContext();Object.defineProperty(detected,"env",{get:()=>getNodeEnv()||"development",enumerable:true,configurable:true});cached3=detected}return cached3}function resetRuntimeContext(){cached3=void 0}export{checkEntryAvailability,detectRuntimeContext,entryAvailabilitySchema,getRuntimeContext,isEntryAvailable,resetRuntimeContext};
4
+ var __require=(x=>typeof require!=="undefined"?require:typeof Proxy!=="undefined"?new Proxy(x,{get:(a,b)=>(typeof require!=="undefined"?require:a)[b]}):x)(function(x){if(typeof require!=="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+x+'" is not supported')});import{internalZ as z}from"@frontmcp/lazy-zod";import{getNodeEnv,isEdgeRuntime,isServerless}from"#env";var cached;function getBuildTarget(){if(cached)return cached;cached=resolveBuildTarget();return cached}function resolveBuildTarget(){const globalAny=globalThis;const fromGlobal=globalAny.FRONTMCP_BUILD_TARGET;if(typeof fromGlobal==="string"&&isKnownTarget(fromGlobal))return fromGlobal;const fromEnv=typeof process!=="undefined"?process.env?.["FRONTMCP_BUILD_TARGET"]:void 0;if(typeof fromEnv==="string"&&isKnownTarget(fromEnv))return fromEnv;return"unknown"}function isKnownTarget(value){return value==="unknown"||value==="node"||value==="distributed"||value==="cli"||value==="vercel"||value==="lambda"||value==="cloudflare"||value==="browser"||value==="sdk"||value==="mcpb"}var cached2;function detectProvider(){if(cached2)return cached2;cached2=detectProviderUncached();return cached2}function detectProviderUncached(){const explicit=process.env["FRONTMCP_PROVIDER"];if(explicit&&isKnownProvider(explicit))return explicit;if(process.env["VERCEL"])return"vercel";if(process.env["AWS_LAMBDA_FUNCTION_NAME"])return"lambda";if(process.env["CF_PAGES"])return"cloudflare";if(process.env["NETLIFY"])return"netlify";if(process.env["AZURE_FUNCTIONS_ENVIRONMENT"])return"azure";if(process.env["K_SERVICE"])return"gcp";if(process.env["FLY_APP_NAME"])return"fly";if(process.env["RENDER"])return"render";if(process.env["RAILWAY_ENVIRONMENT"])return"railway";try{const nodeFs=__require("node:fs");if(nodeFs.existsSync("/.dockerenv"))return"docker"}catch{}return"bare"}function isKnownProvider(value){return value==="bare"||value==="docker"||value==="vercel"||value==="lambda"||value==="cloudflare"||value==="netlify"||value==="azure"||value==="gcp"||value==="fly"||value==="render"||value==="railway"}var entryAvailabilitySchema=z.object({os:z.array(z.string().min(1)).optional(),platform:z.array(z.string().min(1)).optional(),runtime:z.array(z.string().min(1)).optional(),deployment:z.array(z.string().min(1)).optional(),provider:z.array(z.string().min(1)).optional(),target:z.array(z.string().min(1)).optional(),surface:z.array(z.enum(["mcp","cli","http-trigger","job","agent","webmcp"])).optional(),env:z.array(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 detectRuntime(){if(typeof globalThis!=="undefined"&&"Bun"in globalThis)return"bun";if(typeof globalThis!=="undefined"&&"Deno"in globalThis)return"deno";if(isEdgeRuntime())return"edge";return"node"}function detectDeployment(runtime){const explicit=process.env["FRONTMCP_DEPLOYMENT_MODE"];if(explicit==="distributed")return"distributed";if(explicit==="serverless")return"serverless";if(runtime==="browser")return"browser";if(isServerless())return"serverless";return"standalone"}function detectRuntimeContext(){const runtime=detectRuntime();const os=process.platform;return{os,platform:os,runtime,deployment:detectDeployment(runtime),provider:detectProvider(),target:getBuildTarget(),env:getNodeEnv()||"development"}}var cached3;function getRuntimeContext(){if(!cached3){const detected=detectRuntimeContext();Object.defineProperty(detected,"env",{get:()=>getNodeEnv()||"development",enumerable:true,configurable:true});cached3=detected}return cached3}function resetRuntimeContext(){cached3=void 0}export{checkEntryAvailability,detectRuntimeContext,entryAvailabilitySchema,getRuntimeContext,isEntryAvailable,resetRuntimeContext};