Rocky_Mountain_Vending/.pnpm-store/v10/files/f5/16c5c32994fb98855d935c1a5829b976846c6d120a389bdfee73a417fb7d98c05340ab89005fdb2a189f0457cac0cc6f2b6b1519bbb1ae2945b38ed1290e93
DMleadgen 46d973904b
Initial commit: Rocky Mountain Vending website
Next.js website for Rocky Mountain Vending company featuring:
- Product catalog with Stripe integration
- Service areas and parts pages
- Admin dashboard with Clerk authentication
- SEO optimized pages with JSON-LD structured data

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 16:22:15 -07:00

86 lines
2.9 KiB
Text

import { collectBody } from "@smithy/core/protocols";
import { HttpRequest as __HttpRequest } from "@smithy/protocol-http";
import { calculateBodyLength } from "@smithy/util-body-length-browser";
import { cbor } from "./cbor";
import { tag } from "./cbor-types";
export const parseCborBody = (streamBody, context) => {
return collectBody(streamBody, context).then(async (bytes) => {
if (bytes.length) {
try {
return cbor.deserialize(bytes);
}
catch (e) {
Object.defineProperty(e, "$responseBodyText", {
value: context.utf8Encoder(bytes),
});
throw e;
}
}
return {};
});
};
export const dateToTag = (date) => {
return tag({
tag: 1,
value: date.getTime() / 1000,
});
};
export const parseCborErrorBody = async (errorBody, context) => {
const value = await parseCborBody(errorBody, context);
value.message = value.message ?? value.Message;
return value;
};
export const loadSmithyRpcV2CborErrorCode = (output, data) => {
const sanitizeErrorCode = (rawValue) => {
let cleanValue = rawValue;
if (typeof cleanValue === "number") {
cleanValue = cleanValue.toString();
}
if (cleanValue.indexOf(",") >= 0) {
cleanValue = cleanValue.split(",")[0];
}
if (cleanValue.indexOf(":") >= 0) {
cleanValue = cleanValue.split(":")[0];
}
if (cleanValue.indexOf("#") >= 0) {
cleanValue = cleanValue.split("#")[1];
}
return cleanValue;
};
if (data["__type"] !== undefined) {
return sanitizeErrorCode(data["__type"]);
}
const codeKey = Object.keys(data).find((key) => key.toLowerCase() === "code");
if (codeKey && data[codeKey] !== undefined) {
return sanitizeErrorCode(data[codeKey]);
}
};
export const checkCborResponse = (response) => {
if (String(response.headers["smithy-protocol"]).toLowerCase() !== "rpc-v2-cbor") {
throw new Error("Malformed RPCv2 CBOR response, status: " + response.statusCode);
}
};
export const buildHttpRpcRequest = async (context, headers, path, resolvedHostname, body) => {
const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
const contents = {
protocol,
hostname,
port,
method: "POST",
path: basePath.endsWith("/") ? basePath.slice(0, -1) + path : basePath + path,
headers: {
...headers,
},
};
if (resolvedHostname !== undefined) {
contents.hostname = resolvedHostname;
}
if (body !== undefined) {
contents.body = body;
try {
contents.headers["content-length"] = String(calculateBodyLength(body));
}
catch (e) { }
}
return new __HttpRequest(contents);
};