Skip to content

Commit

Permalink
fix: zod auth parsing rule
Browse files Browse the repository at this point in the history
  • Loading branch information
Eduard Lavuš committed Feb 11, 2021
1 parent 33a080f commit daa371b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/client/query/providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,9 @@ export class Provider {
// read in files
return parseFile(
await fsp.readFile(input.slice('file:'.length), { encoding: 'utf-8' })
);
} else if (false) { // eslint-disable-line no-constant-condition
);
// eslint-disable-next-line no-constant-condition
} else if (false) {
// TODO: detect remote url and fetch it, or call a callback
} else {
// unpack nested and recursively process them
Expand Down
16 changes: 16 additions & 0 deletions src/internal/interpreter/map-interpreter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,22 @@ export class MapInterpreter<TInput extends NonPrimitive | undefined>

debug('Performing http request:', node.url);

// TODO: Merge the auth?
/*
// merge auth from bind with auth from super.json
let auth = this.parameters.superJson?.providers?.[this.parameters.provider.name].auth;
if (this.parameters.config?.auth !== undefined) {
if (auth === undefined) {
auth = this.parameters.config.auth;
} else {
auth = {
...auth,
...this.parameters.config.auth
}
}
}
*/

const response = await HttpClient.request(node.url, {
method: node.method,
headers: request?.headers,
Expand Down
5 changes: 3 additions & 2 deletions src/internal/superjson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ const profileSettings = zod.union([
const profile = zod.union([semanticVersion, localPath, profileSettings]);

const auth = zod.union([
// allow empty object
zod.object({}),
zod.object({
BasicAuth: zod.object({
username: zod.string(),
Expand All @@ -79,6 +77,9 @@ const auth = zod.union([
value: zod.string(),
}),
}),
// allow empty object
// note: Zod is order sensitive, so this has to come last
zod.object({}),
]);

const providerService = zod.object({
Expand Down

0 comments on commit daa371b

Please sign in to comment.