Skip to content

Commit

Permalink
build
Browse files Browse the repository at this point in the history
  • Loading branch information
zirkelc committed Mar 27, 2024
1 parent 5345e5a commit bcf0b6b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 18 deletions.
19 changes: 10 additions & 9 deletions dist/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,21 @@ var getHeaders = (init) => {

// src/create-signed-fetcher.ts
var createSignedFetcher = (opts) => {
const service = opts.service;
const region = opts.region || "us-east-1";
const credentials = opts.credentials || (0, import_credential_provider_node.defaultProvider)();
const fetchFn = getFetchFn(opts.fetch);
return async (input, init) => {
const service = opts.service;
const region = opts.region || "us-east-1";
const credentials = opts.credentials || (0, import_credential_provider_node.defaultProvider)();
const url = new URL(
typeof input === "string" ? input : input instanceof URL ? input.href : input.url
);
url.pathname = encodeRfc3986(url.pathname);
url.searchParams.forEach((value, key) => {
url.searchParams.delete(key);
url.searchParams.append(encodeRfc3986(key), encodeRfc3986(value));
});
if (opts.encodeRfc3986) {
url.pathname = encodeRfc3986(url.pathname);
url.searchParams.forEach((value, key) => {
url.searchParams.delete(key);
url.searchParams.append(encodeRfc3986(key), encodeRfc3986(value));
});
}
const headers = getHeaders(init?.headers);
headers.set("host", url.host);
const request = new import_protocol_http.HttpRequest({
Expand All @@ -102,7 +104,6 @@ var createSignedFetcher = (opts) => {
fragment: url.hash,
headers: Object.fromEntries(headers.entries())
});
console.log(request);
const signer = new import_signature_v4.SignatureV4({
credentials,
service,
Expand Down
1 change: 1 addition & 0 deletions dist/index.d.cts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ type SignedFetcherOptions = {
region?: string;
credentials?: AwsCredentialIdentity | Provider<AwsCredentialIdentity>;
fetch?: typeof fetch;
encodeRfc3986?: boolean;
};
type CreateSignedFetcher = (init: SignedFetcherOptions) => typeof fetch;
declare const createSignedFetcher: CreateSignedFetcher;
Expand Down
1 change: 1 addition & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ type SignedFetcherOptions = {
region?: string;
credentials?: AwsCredentialIdentity | Provider<AwsCredentialIdentity>;
fetch?: typeof fetch;
encodeRfc3986?: boolean;
};
type CreateSignedFetcher = (init: SignedFetcherOptions) => typeof fetch;
declare const createSignedFetcher: CreateSignedFetcher;
Expand Down
19 changes: 10 additions & 9 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,21 @@ var getHeaders = (init) => {

// src/create-signed-fetcher.ts
var createSignedFetcher = (opts) => {
const service = opts.service;
const region = opts.region || "us-east-1";
const credentials = opts.credentials || defaultProvider();
const fetchFn = getFetchFn(opts.fetch);
return async (input, init) => {
const service = opts.service;
const region = opts.region || "us-east-1";
const credentials = opts.credentials || defaultProvider();
const url = new URL(
typeof input === "string" ? input : input instanceof URL ? input.href : input.url
);
url.pathname = encodeRfc3986(url.pathname);
url.searchParams.forEach((value, key) => {
url.searchParams.delete(key);
url.searchParams.append(encodeRfc3986(key), encodeRfc3986(value));
});
if (opts.encodeRfc3986) {
url.pathname = encodeRfc3986(url.pathname);
url.searchParams.forEach((value, key) => {
url.searchParams.delete(key);
url.searchParams.append(encodeRfc3986(key), encodeRfc3986(value));
});
}
const headers = getHeaders(init?.headers);
headers.set("host", url.host);
const request = new HttpRequest({
Expand All @@ -77,7 +79,6 @@ var createSignedFetcher = (opts) => {
fragment: url.hash,
headers: Object.fromEntries(headers.entries())
});
console.log(request);
const signer = new SignatureV4({
credentials,
service,
Expand Down

0 comments on commit bcf0b6b

Please sign in to comment.