Rocky_Mountain_Vending/.pnpm-store/v10/files/cb/e753162663f0e8dc3939ce574427f1e3512efa54bb29eefb8eb21d0a6c5f9ad0ae6e8f641d3f13a03c8c04aa1326ab352ab279d8466fda79271c3d10297c7f
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

79 lines
3 KiB
Text

import { toHex } from "@smithy/util-hex-encoding";
import { normalizeProvider } from "@smithy/util-middleware";
import { escapeUri } from "@smithy/util-uri-escape";
import { toUint8Array } from "@smithy/util-utf8";
import { getCanonicalQuery } from "./getCanonicalQuery";
import { iso8601 } from "./utilDate";
export class SignatureV4Base {
service;
regionProvider;
credentialProvider;
sha256;
uriEscapePath;
applyChecksum;
constructor({ applyChecksum, credentials, region, service, sha256, uriEscapePath = true, }) {
this.service = service;
this.sha256 = sha256;
this.uriEscapePath = uriEscapePath;
this.applyChecksum = typeof applyChecksum === "boolean" ? applyChecksum : true;
this.regionProvider = normalizeProvider(region);
this.credentialProvider = normalizeProvider(credentials);
}
createCanonicalRequest(request, canonicalHeaders, payloadHash) {
const sortedHeaders = Object.keys(canonicalHeaders).sort();
return `${request.method}
${this.getCanonicalPath(request)}
${getCanonicalQuery(request)}
${sortedHeaders.map((name) => `${name}:${canonicalHeaders[name]}`).join("\n")}
${sortedHeaders.join(";")}
${payloadHash}`;
}
async createStringToSign(longDate, credentialScope, canonicalRequest, algorithmIdentifier) {
const hash = new this.sha256();
hash.update(toUint8Array(canonicalRequest));
const hashedRequest = await hash.digest();
return `${algorithmIdentifier}
${longDate}
${credentialScope}
${toHex(hashedRequest)}`;
}
getCanonicalPath({ path }) {
if (this.uriEscapePath) {
const normalizedPathSegments = [];
for (const pathSegment of path.split("/")) {
if (pathSegment?.length === 0)
continue;
if (pathSegment === ".")
continue;
if (pathSegment === "..") {
normalizedPathSegments.pop();
}
else {
normalizedPathSegments.push(pathSegment);
}
}
const normalizedPath = `${path?.startsWith("/") ? "/" : ""}${normalizedPathSegments.join("/")}${normalizedPathSegments.length > 0 && path?.endsWith("/") ? "/" : ""}`;
const doubleEncoded = escapeUri(normalizedPath);
return doubleEncoded.replace(/%2F/g, "/");
}
return path;
}
validateResolvedCredentials(credentials) {
if (typeof credentials !== "object" ||
typeof credentials.accessKeyId !== "string" ||
typeof credentials.secretAccessKey !== "string") {
throw new Error("Resolved credential object is not valid");
}
}
formatDate(now) {
const longDate = iso8601(now).replace(/[\-:]/g, "");
return {
longDate,
shortDate: longDate.slice(0, 8),
};
}
getCanonicalHeaderList(headers) {
return Object.keys(headers).sort().join(";");
}
}