Skip to content

Commit

Permalink
JSR Fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Marcos Candeia <[email protected]>
  • Loading branch information
mcandeia committed Aug 7, 2024
1 parent 899c2f4 commit d2776d8
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
4 changes: 2 additions & 2 deletions client/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ const fetchJSON = async <T>(
init?: RequestInit,
): Promise<T> => {
const response = await fetchSuccessResponse(path, opts, init);
return response.json<T>();
return response.json() as Promise<T>;
};

export const start = async <
Expand Down Expand Up @@ -189,7 +189,7 @@ export const get = async <
if (!response.ok) {
throw new Error(`error was thrown from durable ${response.status}`);
}
return response.json<WorkflowExecution<TArgs, TResult, TMetadata>>();
return response.json() as Promise<WorkflowExecution<TArgs, TResult, TMetadata>>;
};

export const cancel = async (
Expand Down
2 changes: 1 addition & 1 deletion context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class WorkflowContext<TMetadata extends Metadata = Metadata> {
exec: WorkflowExecutionBase,
opts?: ClientOptions,
): LocalActivityCommand {
return this.callLocalActivity(() => start(exec, opts));
return this.callLocalActivity(() => start(exec, true, opts));
}

/**
Expand Down
3 changes: 2 additions & 1 deletion security/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ export const asChannel = async <Send, Recv>(
recv.push(event.data);
});
socket.addEventListener("error", (event) => {
console.log("error", JSON.stringify(event.error), event.message);
const evt = event as any;
console.log("error", JSON.stringify(evt.error), evt.message);
});

await Promise.race([ready.wait(), closed.wait()]);
Expand Down
2 changes: 1 addition & 1 deletion security/jwks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const fetchKeyFromAddr = async (
if (!response.ok) {
return null;
}
const { keys = [] } = await response.json<JwksKeys>();
const { keys = [] } = await (response.json() as Promise<JwksKeys>);
const key = kid ? keys.find((key) => key?.kid === kid) ?? keys[0] : keys[0];
if (!key) {
return null;
Expand Down
16 changes: 11 additions & 5 deletions security/keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const importJWK = (
jwk: JsonWebKey,
usages?: string[],
): Promise<CryptoKey> =>
// @ts-ignore
crypto.subtle.importKey(
"jwk",
jwk,
Expand All @@ -45,19 +46,24 @@ export const importJWKFromString = (
);

const getOrGenerateKeyPair = async (): Promise<[JsonWebKey, JsonWebKey]> => {
const hasProcess = typeof process !== "undefined";
// @ts-ignore
const publicKeyEnvValue = typeof Deno !== "undefined"
const isDeno = typeof Deno !== "undefined";
// @ts-ignore
const publicKeyEnvValue = isDeno
// @ts-ignore
? Deno.env.get(PUBLIC_KEY_ENV_VAR)
: hasProcess
// @ts-ignore
: typeof process !== "undefined"
// @ts-ignore
? process.env[PUBLIC_KEY_ENV_VAR]
: undefined;
// @ts-ignore
const privateKeyEnvValue = typeof Deno !== "undefined"
const privateKeyEnvValue = isDeno
// @ts-ignore
? Deno.env.get(PRIVATE_KEY_ENV_VAR)
: hasProcess
// @ts-ignore
: typeof process !== "undefined"
// @ts-ignore
? process.env[PRIVATE_KEY_ENV_VAR]
: undefined;
if (!publicKeyEnvValue || !privateKeyEnvValue) {
Expand Down

0 comments on commit d2776d8

Please sign in to comment.