MCPcopy
hub / github.com/agent-infra/sandbox / request

Function request

sdk/js/src/providers/sign.ts:110–237  ·  view source on GitHub ↗
(
  method: string,
  date: Date,
  query: Record<string, string>,
  header: Record<string, string>,
  ak: string,
  sk: string,
  token: string | null,
  action: string,
  body: string,
  region?: string,
  version?: string,
)

Source from the content-addressed store, hash-verified

108 * Sign and send HTTP request to Volcengine API
109 */
110export async function request(
111 method: string,
112 date: Date,
113 query: Record<string, string>,
114 header: Record<string, string>,
115 ak: string,
116 sk: string,
117 token: string | null,
118 action: string,
119 body: string,
120 region?: string,
121 version?: string,
122): Promise<any> {
123 // Get action configuration from map or use defaults
124 const actionConfig = ACTION_CONFIG_MAP.get(action) || {
125 service: DEFAULT_SERVICE,
126 version: DEFAULT_VERSION,
127 };
128
129 // Initialize credential
130 const credential: Credential = {
131 access_key_id: ak,
132 secret_access_key: sk,
133 service: actionConfig.service,
134 region: region || DEFAULT_REGION,
135 };
136
137 if (token) {
138 credential.session_token = token;
139 }
140
141 // Determine content type
142 let contentType = actionConfig.contentType || ContentType;
143 if (method === 'POST') {
144 contentType = 'application/json';
145 }
146
147 const apiVersion = version || actionConfig.version;
148
149 // Initialize request parameters
150 const requestParam: RequestParam = {
151 body: body || '',
152 host: Host,
153 path: '/',
154 method,
155 content_type: contentType,
156 date,
157 query: { Action: action, Version: apiVersion, ...query },
158 };
159
160 // Calculate signature
161 const xDate = date
162 .toISOString()
163 .replace(/[-:]/g, '')
164 .replace(/\.\d{3}/, '');
165 const shortXDate = xDate.slice(0, 8);
166 const xContentSha256 = hashSha256(requestParam.body);
167

Callers 7

createSandboxMethod · 0.90
deleteSandboxMethod · 0.90
getSandboxMethod · 0.90
setSandboxTimeoutMethod · 0.90
listSandboxesMethod · 0.90
getApigTriggerMethod · 0.90

Calls 8

hashSha256Function · 0.85
normQueryFunction · 0.85
hmacSha256Function · 0.85
getMethod · 0.80
forEachMethod · 0.80
entriesMethod · 0.80
jsonMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…