profile
viewpoint
Kitson Kelly kitsonk @denoland Melbourne, Australia https://kitsonkelly.com/ Doing stuff @denoland, author of @oakserver and @h-o-t

csnover/dojo-boilerplate 376

A starting point for developing with Dojo

kitsonk/colors 38

Console colors for Deno

h-o-t/nocuous 12

A static code analysis tool for JavaScript and TypeScript.

kitsonk/app-example 8

An example Dojo 2 Application

kitsonk/controller 8

Commands and Action Abstractions for Dojo

kitsonk/choak 7

An example chat application using Deno and Oak

kitsonk/d2-proto 4

Dojo 2.0 Prototypes and Experiments

kitsonk/bubba 3

A GitHub bot, making Eric's life easier

kitsonk/core-js 2

Prototype Core of Dojo 2

kitsonk/api-doc 1

A TypeScript API Documentation Generator

pull request commentdenoland/deno

[WIP] refactor(cli): migrate run and cache to new infrastructure

Can you elaborate what's the hurdle with dynamic imports?

Because the module graph is the centre of the universe, it means that it tries to go get dynamic imports eagerly, when swc sees them, also, instead of waiting until they are demanded by the runtime. tsc also tries to use them in type checking, so we want to be able to eagerly fetch them. Which means we encounter all the errors there, during the building of the graph, instead when v8 attempts to loads them. This lead to errors not being catchable. I have fixed it now in my branch, basically making dynamic import resolutions in the graph non-errors, but as I said in our chat, I broke a few other things, but I think I know what happened there and am fixing that now.

kitsonk

comment created time in 21 minutes

push eventkitsonk/deno

Kitson Kelly

commit sha 0d110896d85e10c3cd8a32ae9687668716f1fd1b

revert new benchmark

view details

push time in 17 hours

push eventkitsonk/deno

Kitson Kelly

commit sha d7c4dac53a54d4c7d2664fbbe3c4d9f6cd74ca57

address feedback

view details

push time in 18 hours

PullRequestReviewEvent

Pull request review commentdenoland/deno

feat(cli): add support for bundle --no-check

 // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.  use crate::media_type::MediaType;+use crate::module_graph2::Graph2;

Let me take a look at it again... It is how to cleanly impl the bundle loader in module_graph2 without dragging all of ast in.

kitsonk

comment created time in 20 hours

PullRequestReviewEvent

PR opened denoland/deno

Reviewers
feat(cli): add support for bundle --no-check

Add support for deno bundle --no-check. This uses swc for the bundling (thanks to a lot of hard work and fixes by @kdy1). There are some substantial differences from deno bundle though:

  • The output is a single file ESM file that is a "flattened" version of the input sources. deno bundle uses the System module format and provides a custom loader. While there might be still some defects, we have tried to do some extensive testing to ensure that that the unbundle code behaviour is preserved when bundled.
  • Dynamic imports are left "untouched". This is a significant change from the current behaviour, where sometimes dynamic imports are included in the bundle if they can be statically determined at bundle time. It is a double edged sword bundling dynamic imports, as the behaviour might or might not be desired, so it is best to just leave them alone.
  • import.meta.url and import.meta.main work in the bundle, where import.meta.url will get "hardcoded" at bundle time and import.meta.main will be false for any dependent modules, but be preserved in the bundle for the main/entry point module.

We are looking at replacing deno bundle with this bundling in a subsequent PR.

Fixes #6686

+884 -57

0 comment

60 changed files

pr created time in 21 hours

create barnchkitsonk/deno

branch : swc_mg2_bundle

created branch time in 21 hours

issue commentdenoland/deno

TextDecoder converts string to lower case before throwing error

@00ff0000red

❯ deno
Deno 1.4.6
exit using ctrl+d or close()
> new TextDecoder("GBK");
Uncaught TypeError: Internal decoder ('gbk') not found.
    at new TextDecoder (deno:op_crates/web/08_text_encoding.js:984:15)
    at <anonymous>:2:1

That doesn't look like a RangeError to me. It should be a RangeError.

00ff0000red

comment created time in a day

IssuesEvent

issue closeddenoland/deno

Proposal: std/crypto

We already have bcrypt and argon2 modules on /x, it would be nice to have them in std just like in golang, also i think both of them (and others too) can be implemented via wasm for better perfomance

closed time in 2 days

ssslambda

issue commentdenoland/deno

Proposal: std/crypto

The Q4 roadmap is the current priorities of the core team, it is not everything for Q4.

WebCrypto would be preferred over any std, so closing as a duplicate of #1891.

ssslambda

comment created time in 2 days

issue commentdenoland/deno

Proposal: import.meta.test gating pattern

Oooh, I like that idea. I think with the new bundling that is being worked on, those would be elided quite easily.

guybedford

comment created time in 2 days

push eventkitsonk/deno

Bartek Iwańczuk

commit sha bd0c64b9aeeb75eea25402b0ebd5aecc2cec8e3a

Reland feat(cli/console): inspect with colors regardless of Deno.noColor (#7976)

view details

Kitson Kelly

commit sha bbe4474d39aecfabed52bd080e73d34978b6481b

fix(cli): ModuleGraph2 properly handles redirects (#7981)

view details

William Perron

commit sha 943b0980c7ff97cb6096291efa5e3d5dbfe10805

feat(cli/ops): add the sleep_sync op (#7974)

view details

Ben Noordhuis

commit sha 46b892ad37df9ba9bed77fb923a1cfe284b208dc

refactor(core): more control over isolate creation (#8000) Make JSRuntime::new() accept a custom v8::CreateParams object to tune the v8::Isolate it creates. Subsumes the functionality of HeapLimits, which I therefore removed.

view details

Bartek Iwańczuk

commit sha c1c760130406405c8fde9a74bd88c62ca721967b

upgrade: deno_doc, deno_lint, dprint, swc (#8009)

view details

push time in 2 days

push eventkitsonk/deno

Kitson Kelly

commit sha 7c7387e5df42686d8d01b77bebd7e61b597b2508

[WIP] bundle via swc

view details

push time in 2 days

PR closed denoland/deno

[WIP] feat(cli): bundling using swc

This is very much still a WIP, but I have it working.

I adapted @kdy1's #7461 into the refactor of the module graph... I need to DRY up the code a bit, as well as provide type checking variant, as well are re-organise the code in the main.rs that shouldn't really be there. It does demonstrate how incongruent we handle stuff though, and all of this needs a really good scrub.

Raising it now for review and discussion.

+682 -294

6 comments

16 changed files

kitsonk

pr closed time in 2 days

pull request commentdenoland/deno

[WIP] feat(cli): bundling using swc

Going to reland this under a different PR.

kitsonk

comment created time in 2 days

issue commentdenoland/deno

TextDecoder converts string to lower case before throwing error

RangeError should be used when matching a list of enumerated values. Sometimes the specs specify the error type, sometimes they don't. While it might be strictly open for interpretation, we want to interpret the same error type as Chromium.

00ff0000red

comment created time in 2 days

issue commentdenoland/deno

TextDecoder converts string to lower case before throwing error

Ah, I see what you were referring to.

It should be a RangeError though, instead of a TypeError... that message text though is never specified in the standards and runtimes vary quite a lot, though we should return what was input instead of modifying it.

00ff0000red

comment created time in 3 days

issue commentdenoland/deno

TextDecoder converts string to lower case before throwing error

It is supposed to be case insensitive: https://www.w3.org/International/docs/encoding/#concept-encoding-get

00ff0000red

comment created time in 3 days

PR opened denoland/deno_lint

Reviewers
chore: update swc dependencies
+18 -18

0 comment

2 changed files

pr created time in 3 days

create barnchkitsonk/deno_lint

branch : chore_update_swc

created branch time in 3 days

push eventkitsonk/deno_lint

강동윤

commit sha 0c37124d9304321745f67fdff3d2cf5f769bd261

fix: no-unreachable (#341)

view details

Bartek Iwańczuk

commit sha 81675018908a0f66693caca9f03b471c309a6af6

Add LintRule::docs() and LintDiagnostic::hint (#343)

view details

Yusuke Tanaka

commit sha d7a6de1e2fd46ee4bbf6fbf75cd7f7c1e5e5a40c

Add prefer-const rule (#342)

view details

Yusuke Tanaka

commit sha 9a0771151e503d9dd3d038ae2b39d1bc97240372

fix(prefer-const): treat param of catch clause like thet of function (#346) (#347)

view details

Yusuke Tanaka

commit sha 1e7d00d6152686985d63b2a9c7560073ad9bba0e

fix(prefer-const): handle `+=` and `-=` correctly (#344) (#345)

view details

Dom Parfitt

commit sha 24e0bf3410ef343f56d627cba118624649909a0b

docs: no-empty (#349)

view details

Yusuke Tanaka

commit sha 78240c072be9a060959620eb9912681a5ab786f7

fix(no-case-declarations): handle nested switch statements (#356)

view details

Yusuke Tanaka

commit sha 9593b3ba9ca649fba322b3babe50ba781c0ea073

fix(no-compare-neg-zero): handle nested stuff (#354)

view details

Yusuke Tanaka

commit sha 6baf756a6b1a9005fb75c6cd2155be65e96cd638

fix(control_flow): handle class constructors (#355)

view details

Yusuke Tanaka

commit sha 827145f3a2b42aa3c66066b9e4d7bfdfc330b331

fix(no-class-assign): add more tests and fix to pass them (#352)

view details

Dom Parfitt

commit sha 7d2f205feaaaa5cb82f3931f92dae96d2c5036ba

docs: valid-typeof (#351)

view details

Dom Parfitt

commit sha 7a6f33fe04fc566fefc50f644de37c558bb7fc19

docs: no_cond_assign (#350)

view details

Bartek Iwańczuk

commit sha a85043b82fef1d363639812f753b869504722b79

v0.2.1

view details

Bartek Iwańczuk

commit sha 59ab7c1397cd151232d6dcd42be44cdf6561df12

v0.2.2

view details

Yusuke Tanaka

commit sha 7c447aeb601d4cd578cb40023c2c2b9b2bdd7675

fix(prefer-const): handle nested assignments correctly (#361)

view details

Kitson Kelly

commit sha c78e4d6aba1c89839c25ff74b46ac6370ab710b4

chore: update swc_ecmascript (#363)

view details

Yusuke Tanaka

commit sha b1375b92df244aad5997f4e9a5e5ad0f54091830

fix(prefer-const): refactor & handle hoisting (#362)

view details

Kitson Kelly

commit sha d5ea5fb51963948f53dbdb381dbb34cc90d41378

chore: update swc_ecmascript to 0.9.1 (#370)

view details

Yusuke Tanaka

commit sha e8097ffd544f9a3515be40c83fbb483548cb7f99

chore: Add prefer-const to recommended rules (#369)

view details

Bartek Iwańczuk

commit sha a83bbbcd9a65f31860212a13bf125d8dad0d2d7a

v0.2.3

view details

push time in 3 days

PR opened denoland/deno_doc

Reviewers
chore: update swc dependencies
+14 -14

0 comment

2 changed files

pr created time in 3 days

create barnchkitsonk/deno_doc

branch : chore_update_swc

created branch time in 3 days

PR opened dprint/dprint-plugin-typescript

chore: update swc dependencies

Updating the swc dependencies to the latest release.

+2 -2

0 comment

1 changed file

pr created time in 3 days

create barnchkitsonk/dprint-plugin-typescript

branch : chore-update-swc

created branch time in 3 days

issue commentdenoland/deno

relative import path <node_module> not prefixed with

could you explain what it's doing with a bit more depth?

It is more than a few lines in an issue I am afraid. As I said, I know what is wrong, the behaviour experienced is undesired, and I am in a process of a major refactor of this part of the code under #7225 that should make the whole process more maintainable in the future, but the whole process has grown organically over the past 2.5 years and needs a good clean out. There are a handful of other issues that need to be address as part of this which I am taking care as well.

cztomsik

comment created time in 3 days

push eventkitsonk/kitsonkelly.com

Kitson Kelly

commit sha b6bc42b4c62533a46f16ccc359060a999e3f0363

Update hugo and theme

view details

push time in 3 days

issue commentdenoland/deno

relative import path <node_module> not prefixed with

It is a defect... we statically analyze the dependencies to try to ensure that we eagerly fetch all modules and have them ready. For dynamic import we should "try" so we don't get caught off guard, but we shouldn't log any errors/terminate when this occurs. This is a great example of why we shouldn't do it, and I wanted the details of what arguments were passed so I can make sure we can ensure that we have a test case that covers this issue.

As stated, I will try to address it in #7225, which should be closed for 1.5, so about two weeks away.

cztomsik

comment created time in 3 days

issue commentswc-project/swc

Jest with SWC doesn't seem much faster than Jest with babel :(

For testing, especially benchmarks, transpiling code is likely less than 1% of the time spent on the test, so optimising 1% of a process will lead to the results you are seeing. I don't know the internals of jest, but I suspect it doesn't even transpile on every run, so you are only get a one off improvement in startup.

benwainwright

comment created time in 3 days

issue closeddenoland/deno

More detailed `deno test` output

My only complaint about deno test is its lack of detail at the time of executing the tests, specially for big codebases.

I understand it's influenced by cargo test, but I argue that a much cleaner way to address this is by telling what file is being tested at the time of running the test. Specially since Deno does pattern match when running it's tests instead of looking for them inside the code itself _ a la rust_.

This will improve quite a few aspects:

Shorter test name

Currently for describing tests that handle different things inside the code you would go with this approach:

// server.js
Deno.test(`Server starts correctly`, ...);
Deno.test(`Server serves correct files`, ...);
Deno.test(`Server pauses on event`, ...);

//With the new approach
Deno.test(`Starts correctly`, ...);
Deno.test(`Serves correct files`, ...);
Deno.test(`Pauses on event`, ...);

Easier to debug assert errors

The stack trace does it's job, but it's just harder to guess where it's failing following this approach (specially when it fails on multiple tests)

at assertEquals (file:///home/nicolas/Documents/Programming/deno/std/testing/asserts.ts:196:9)
at file:///home/nicolas/Documents/Programming/deno/std/node/_stream/stream_test.ts:40:3
at async asyncOpSanitizer (deno:cli/rt/40_testing.js:34:7)
at async Object.resourceSanitizer [as fn] (deno:cli/rt/40_testing.js:68:7)
at async TestRunner.[Symbol.asyncIterator] (deno:cli/rt/40_testing.js:240:13)
at async Object.runTests (deno:cli/rt/40_testing.js:317:22)

The new approach would be more descriptive in less space

running 34 tests
-- stream_test.ts
test Stream to async iterator ... FAILED (5ms)
test Stream to async iterator throws on 'error' emitted ... ok (7ms)
-- async_iterator_test.ts
test Async iterator matches values of Readable ... ok (1ms)
test Async iterator throws on Readable destroyed sync ... ok (7ms)
test Async iterator throws on Readable destroyed async ... ok (5ms)
test Async iterator finishes the iterator when Readable destroyed ... ok (5ms)

Easier to debug compile errors

Currently a failing compile check would output the following

deno test
Check file:///some_folder/$deno$test.ts
error: TS2790 [ERROR]: The operand of a 'delete' operator must be optional.
  delete progress.queued;
         ~~~~~~~~~~~~~~~
    at https://deno.land/std@0.66.0/testing/bench.ts:323:10

I guess this is because the files are being checked all together after being matched by the test file pattern, so the main file would be resolved to $deno$test.ts but it makes it really hard to debug which one of the files has a compile error when the error isn't in the file itself. This would be solved as well by executing each file separately.

I'm not sure if this would be a breaking change, I'm sure it would involve tons of work though, and the tools like --filter would work differently, so maybe a better approach would be an option to switch between this and the classic approach?

Would love to hear your thoughts about this, I really feel like this is needed

closed time in 3 days

Soremwar

issue commentdenoland/deno

More detailed `deno test` output

Close enough. In order to try to not fracture conversations, please add to #4644 anything not covered by this.

Soremwar

comment created time in 3 days

push eventkitsonk/swc

강동윤

commit sha 626c881c981ecf6e8102409171b66174737b7e19

bundler: Fix ordering (#1171)

view details

push time in 3 days

issue commentdenoland/deno

Crash on fs.copy - thread 'main' panicked at 'already borrowed: BorrowMutError'

Wow... 🤯 amazing... great job breaking Deno in really interesting ways. Sorry it is causing you grief. Both of the panics relate to locking the op state.

About how many files are in D:\myprojects\builds\bin?

@bartlomieju @ry I've looked at cli/ops/fs.rs and I am not seeing any obvious potential deadlock situations with state, but it does seem one is occurring when we are doing a "heavy" amount of file system ops.

prcdpr

comment created time in 3 days

issue commentdenoland/deno

Add ICU in embedded v8

The core team discussed this today and agreed it is something we need to get into Deno. The "right" way to add it is to add ICU support to rusty_v8, the simple tracking issue is here: https://github.com/denoland/rusty_v8/issues/501.

Once it is added to rusty_v8 it can be integrated into the CLI.

zekth

comment created time in 3 days

issue openeddenoland/rusty_v8

Add support for ICU

We should add ICU to rusty_v8 in some fashion.

created time in 3 days

push eventkitsonk/swc

강동윤

commit sha 11d137ac1121d505bdcceebabe9f75b2b77f6b18

ast: Add support for fuzzing (#1167) swc_common: - Add support for fuzzing. swc_ecma_ast: - Add support for fuzzing.

view details

강동윤

commit sha 41d1738b822ee44b664f152c69724184d2238cad

bundler: Make output deterministic (#1166) swc_bundler: - Make output deterministic

view details

push time in 4 days

issue commentdenoland/deno

can't reexport modules typed by X-TypeScript-Types custom header

Need to try to address in #7225.

fjc0k

comment created time in 4 days

issue commentdenoland/deno

relative import path <node_module> not prefixed with

Could you provide the version of Deno you are using and what you command line looks like?

I will try to make sure this is accounted for in #7225.

cztomsik

comment created time in 4 days

PR opened denoland/deno

[WIP] refactor(cli): migrate run and cache to new infrastructure

Ref: #7225

Still a work in progress, the biggest challenge is with dynamic imports. I need to do some thinking about how best to integrate these in a way that is clean in the new infrastructure.

There is still a bit of cleanup and some more unit tests to write, but thought it was good enough. It is a ~420 LOC reduction at the moment, but there is certainly more that will be done when bundling can the runtime APIs move over.

+741 -1140

0 comment

37 changed files

pr created time in 4 days

create barnchkitsonk/deno

branch : refactor_run

created branch time in 4 days

issue commentdenoland/deno

Incorrect TypeSript doesn't throw a TSC error, but instead causes Rust main thread panic

You've made some incorrect assumptions of how Deno works internally. It does not just pass everything to the TypeScript and let it sort it out, it uses swc to attempt to determine the dependencies before doing anything, and swc is throwing here, because the code is not valid JavaScript or TypeScript.

Ultimately we need to give a better error when encountering un-lexable code like this.

00ff0000red

comment created time in 4 days

issue commentdenoland/deno

Crash on fs.copy - thread 'main' panicked at 'already borrowed: BorrowMutError'

That code is related to opening a TCP connection which is really strange, should be totally unrelated to this bit of code... Could you give an example of what the destDir value actually is, as well the output of deno run -L debug.

prcdpr

comment created time in 4 days

Pull request review commentdenoland/deno

add(std/jwt): Implement the new jwt module

+import type { Algorithm } from "./algorithm.ts";+import * as base64url from "../encoding/base64url.ts";+import { encodeToString as convertUint8ArrayToHex } from "../encoding/hex.ts";+import {+  create as createSignature,+  verify as verifySignature,+} from "./signature.ts";+import { verify as verifyAlgorithm } from "./algorithm.ts";+/*+ * JWT §4.1: The following Claim Names are registered in the IANA+ * "JSON Web Token Claims" registry established by Section 10.1. None of the+ * claims defined below are intended to be mandatory to use or implement in all+ * cases, but rather they provide a starting point for a set of useful,+ * interoperable claims.+ * Applications using JWTs should define which specific claims they use and when+ * they are required or optional.+ */+export interface PayloadObject {+  iss?: string;+  sub?: string;+  aud?: string[] | string;+  exp?: number;+  nbf?: number;+  iat?: number;+  jti?: string;+  [key: string]: unknown;+}++export type Payload = PayloadObject | string;++/*+ * JWS §4.1.1: The "alg" value is a case-sensitive ASCII string containing a + * StringOrURI value. This Header Parameter MUST be present and MUST be+ * understood and processed by implementations.+ */+export interface Header {+  alg: Algorithm;+  [key: string]: unknown;+}++const encoder = new TextEncoder();+const decoder = new TextDecoder();++function isExpired(exp: number, leeway = 0): boolean {+  return exp + leeway < Date.now() / 1000;+}++/*+ * Helper function: setExpiration()+ * returns the number of seconds since January 1, 1970, 00:00:00 UTC+ */+export function setExpiration(exp: number | Date): number {+  return Math.round(+    (exp instanceof Date ? exp.getTime() : Date.now() + exp * 1000) / 1000,+  );+}++function tryToParsePayload(input: string) {

The linter has pragmas that allow it.

timonson

comment created time in 4 days

PullRequestReviewEvent

issue commentdenoland/deno

Add ICU in embedded v8

I thought @kishiguro had already gotten full ICU support working on Linux, Mac, and Windows from reading these comments above

Yes, exactly... full ICU support is a 25% increase in executable size. 🤯 That is huge. Which leads to the "how do we only do something like en-us and if so, do we allow people to dynamically load other regions or not" problem, which gets into the too difficult category.

Here's what I think would be really cool: What if you ported Internationalization to web assembly and wrapped that with an ES6 module?

It doesn't work that way.

zekth

comment created time in 4 days

push eventdenoland/deno

Kitson Kelly

commit sha bbe4474d39aecfabed52bd080e73d34978b6481b

fix(cli): ModuleGraph2 properly handles redirects (#7981)

view details

push time in 4 days

PR merged denoland/deno

fix(cli): ModuleGraph2 properly handles redirects

Fixes issues where both --no-check and deno info do not currently handle redirects.

+155 -101

1 comment

5 changed files

kitsonk

pr closed time in 4 days

Pull request review commentdenoland/deno

fix(cli): ModuleGraph2 properly handles redirects

 impl Graph2 {     Ok(result)   } +  fn resolve_specifier<'a>(+    &'a self,+    specifier: &'a ModuleSpecifier,+  ) -> &'a ModuleSpecifier {+    let mut s = specifier;+    while let Some(redirect) = self.redirects.get(s) {+      s = redirect;+    }+    s+  }

I have guarded against infinite loops and excessive redirections... While it might be overkill, it is good to have clear logic to handle those edge cases.

kitsonk

comment created time in 4 days

PullRequestReviewEvent

push eventkitsonk/deno

Kitson Kelly

commit sha ade526bbe7cd0dbc3b358426c3191bc2707db721

address feedback

view details

push time in 4 days

Pull request review commentdenoland/deno

add(std/jwt): Implement the new jwt module

+import type { Algorithm } from "./algorithm.ts";+import { HmacSha256 } from "../hash/sha256.ts";+import { HmacSha512 } from "../hash/sha512.ts";+import { encode as convertUint8ArrayToBase64url } from "../encoding/base64url.ts";+import { decodeString as convertHexToUint8Array } from "../encoding/hex.ts";++export function convertHexToBase64url(input: string): string {+  return convertUint8ArrayToBase64url(convertHexToUint8Array(input));+}++function encrypt(+  alg: Algorithm | "none",

Algorithm already includes "none".

  alg: Algorithm,
timonson

comment created time in 4 days

Pull request review commentdenoland/deno

add(std/jwt): Implement the new jwt module

+import type { Algorithm } from "./algorithm.ts";+import * as base64url from "../encoding/base64url.ts";+import { encodeToString as convertUint8ArrayToHex } from "../encoding/hex.ts";+import {+  create as createSignature,+  verify as verifySignature,+} from "./signature.ts";+import { verify as verifyAlgorithm } from "./algorithm.ts";+/*+ * JWT §4.1: The following Claim Names are registered in the IANA+ * "JSON Web Token Claims" registry established by Section 10.1. None of the+ * claims defined below are intended to be mandatory to use or implement in all+ * cases, but rather they provide a starting point for a set of useful,+ * interoperable claims.+ * Applications using JWTs should define which specific claims they use and when+ * they are required or optional.+ */+export interface PayloadObject {+  iss?: string;+  sub?: string;+  aud?: string[] | string;+  exp?: number;+  nbf?: number;+  iat?: number;+  jti?: string;+  [key: string]: unknown;+}++export type Payload = PayloadObject | string;++/*+ * JWS §4.1.1: The "alg" value is a case-sensitive ASCII string containing a + * StringOrURI value. This Header Parameter MUST be present and MUST be+ * understood and processed by implementations.+ */+export interface Header {+  alg: Algorithm;+  [key: string]: unknown;+}++const encoder = new TextEncoder();+const decoder = new TextDecoder();++function isExpired(exp: number, leeway = 0): boolean {+  return exp + leeway < Date.now() / 1000;+}++/*+ * Helper function: setExpiration()+ * returns the number of seconds since January 1, 1970, 00:00:00 UTC+ */+export function setExpiration(exp: number | Date): number {+  return Math.round(+    (exp instanceof Date ? exp.getTime() : Date.now() + exp * 1000) / 1000,+  );+}++function tryToParsePayload(input: string) {+  try {+    return JSON.parse(input);+  } catch {+    return input;+  }+}++export function decode(+  jwt: string,+): {+  header: unknown;+  payload: unknown;+  signature: unknown;+} {+  const parsedArray = jwt+    .split(".")+    .map(base64url.decode)+    .map((uint8Array, index) =>+      index === 0+        ? JSON.parse(decoder.decode(uint8Array))+        : index === 1+        ? tryToParsePayload(decoder.decode(uint8Array))+        : convertUint8ArrayToHex(uint8Array)+    );+  if (parsedArray.length !== 3) throw TypeError("serialization is invalid");++  return {+    header: parsedArray[0],+    payload: parsedArray[1],+    signature: parsedArray[2],+  };+}++export type TokenObject = {+  header: Header;+  payload: PayloadObject | string;+  signature: string;+};++export function isTokenObject(object: TokenObject): object is TokenObject {+  return (+    typeof object?.signature === "string" &&+    typeof object?.header?.alg === "string" &&+    (typeof object?.payload === "object" && object?.payload?.exp+      ? typeof object.payload.exp === "number"+      : true)+  );+}++export async function verify(+  jwt: string,+  key: string,+  {+    algorithm = "HS512",+  }: {+    algorithm?: Algorithm | Array<Exclude<Algorithm, "none">>;+  } = {},+): Promise<Payload> {+  const obj = decode(jwt) as TokenObject;
  const obj = decode(jwt);

Your guard at 119 narrows it to a TokenObject, coercing it here is unsafe.

timonson

comment created time in 4 days

Pull request review commentdenoland/deno

add(std/jwt): Implement the new jwt module

+import type { Algorithm } from "./algorithm.ts";+import { HmacSha256 } from "../hash/sha256.ts";+import { HmacSha512 } from "../hash/sha512.ts";+import { encode as convertUint8ArrayToBase64url } from "../encoding/base64url.ts";+import { decodeString as convertHexToUint8Array } from "../encoding/hex.ts";++export function convertHexToBase64url(input: string): string {+  return convertUint8ArrayToBase64url(convertHexToUint8Array(input));+}++function encrypt(+  alg: Algorithm | "none",+  key: string,+  message: string,+): string {+  switch (alg) {+    case "none":+      return "";+    case "HS256":+      return new HmacSha256(key).update(message).toString();+    case "HS512":+      return new HmacSha512(key).update(message).toString();+    default:+      throw new RangeError(`algorithm '${alg}' in header is not supported`);+  }+}++export async function create(

If functions exported from this module are part of the public API, then they should have JSDoc. If they are just supporting mod.ts then the whole module should start with an underscore (_).

timonson

comment created time in 4 days

Pull request review commentdenoland/deno

add(std/jwt): Implement the new jwt module

+import type { Algorithm } from "./algorithm.ts";+import { HmacSha256 } from "../hash/sha256.ts";+import { HmacSha512 } from "../hash/sha512.ts";+import { encode as convertUint8ArrayToBase64url } from "../encoding/base64url.ts";+import { decodeString as convertHexToUint8Array } from "../encoding/hex.ts";++export function convertHexToBase64url(input: string): string {+  return convertUint8ArrayToBase64url(convertHexToUint8Array(input));+}++function encrypt(+  alg: Algorithm | "none",+  key: string,+  message: string,+): string {+  switch (alg) {+    case "none":+      return "";+    case "HS256":+      return new HmacSha256(key).update(message).toString();+    case "HS512":+      return new HmacSha512(key).update(message).toString();+    default:+      throw new RangeError(`algorithm '${alg}' in header is not supported`);
      throw new RangeError(`The algorithm of "${alg}" in the header is not supported.`);
timonson

comment created time in 4 days

Pull request review commentdenoland/deno

add(std/jwt): Implement the new jwt module

+import type { Algorithm } from "./algorithm.ts";+import * as base64url from "../encoding/base64url.ts";+import { encodeToString as convertUint8ArrayToHex } from "../encoding/hex.ts";+import {+  create as createSignature,+  verify as verifySignature,+} from "./signature.ts";+import { verify as verifyAlgorithm } from "./algorithm.ts";+/*+ * JWT §4.1: The following Claim Names are registered in the IANA+ * "JSON Web Token Claims" registry established by Section 10.1. None of the+ * claims defined below are intended to be mandatory to use or implement in all+ * cases, but rather they provide a starting point for a set of useful,+ * interoperable claims.+ * Applications using JWTs should define which specific claims they use and when+ * they are required or optional.+ */+export interface PayloadObject {+  iss?: string;+  sub?: string;+  aud?: string[] | string;+  exp?: number;+  nbf?: number;+  iat?: number;+  jti?: string;+  [key: string]: unknown;+}++export type Payload = PayloadObject | string;++/*+ * JWS §4.1.1: The "alg" value is a case-sensitive ASCII string containing a + * StringOrURI value. This Header Parameter MUST be present and MUST be+ * understood and processed by implementations.+ */+export interface Header {+  alg: Algorithm;+  [key: string]: unknown;+}++const encoder = new TextEncoder();+const decoder = new TextDecoder();++function isExpired(exp: number, leeway = 0): boolean {+  return exp + leeway < Date.now() / 1000;+}++/*+ * Helper function: setExpiration()+ * returns the number of seconds since January 1, 1970, 00:00:00 UTC+ */+export function setExpiration(exp: number | Date): number {+  return Math.round(+    (exp instanceof Date ? exp.getTime() : Date.now() + exp * 1000) / 1000,+  );+}++function tryToParsePayload(input: string) {+  try {+    return JSON.parse(input);+  } catch {+    return input;+  }+}++export function decode(

Ok, I see you have isTokenObject() but the examples in the README don't use this. Why would we want to potentially not validate the token object as part of the decode... no one wants an unvalidated object do they?

timonson

comment created time in 4 days

Pull request review commentdenoland/deno

add(std/jwt): Implement the new jwt module

+import type { Algorithm } from "./algorithm.ts";+import * as base64url from "../encoding/base64url.ts";+import { encodeToString as convertUint8ArrayToHex } from "../encoding/hex.ts";+import {+  create as createSignature,+  verify as verifySignature,+} from "./signature.ts";+import { verify as verifyAlgorithm } from "./algorithm.ts";+/*+ * JWT §4.1: The following Claim Names are registered in the IANA+ * "JSON Web Token Claims" registry established by Section 10.1. None of the+ * claims defined below are intended to be mandatory to use or implement in all+ * cases, but rather they provide a starting point for a set of useful,+ * interoperable claims.+ * Applications using JWTs should define which specific claims they use and when+ * they are required or optional.+ */+export interface PayloadObject {+  iss?: string;+  sub?: string;+  aud?: string[] | string;+  exp?: number;+  nbf?: number;+  iat?: number;+  jti?: string;+  [key: string]: unknown;+}++export type Payload = PayloadObject | string;++/*+ * JWS §4.1.1: The "alg" value is a case-sensitive ASCII string containing a + * StringOrURI value. This Header Parameter MUST be present and MUST be+ * understood and processed by implementations.+ */+export interface Header {+  alg: Algorithm;+  [key: string]: unknown;+}++const encoder = new TextEncoder();+const decoder = new TextDecoder();++function isExpired(exp: number, leeway = 0): boolean {+  return exp + leeway < Date.now() / 1000;+}++/*+ * Helper function: setExpiration()+ * returns the number of seconds since January 1, 1970, 00:00:00 UTC+ */+export function setExpiration(exp: number | Date): number {+  return Math.round(+    (exp instanceof Date ? exp.getTime() : Date.now() + exp * 1000) / 1000,+  );+}++function tryToParsePayload(input: string) {+  try {+    return JSON.parse(input);+  } catch {+    return input;+  }+}++export function decode(+  jwt: string,+): {+  header: unknown;+  payload: unknown;+  signature: unknown;+} {+  const parsedArray = jwt+    .split(".")+    .map(base64url.decode)+    .map((uint8Array, index) =>+      index === 0+        ? JSON.parse(decoder.decode(uint8Array))+        : index === 1+        ? tryToParsePayload(decoder.decode(uint8Array))+        : convertUint8ArrayToHex(uint8Array)+    );+  if (parsedArray.length !== 3) throw TypeError("serialization is invalid");++  return {+    header: parsedArray[0],+    payload: parsedArray[1],+    signature: parsedArray[2],+  };+}++export type TokenObject = {+  header: Header;+  payload: PayloadObject | string;+  signature: string;+};++export function isTokenObject(object: TokenObject): object is TokenObject {+  return (+    typeof object?.signature === "string" &&+    typeof object?.header?.alg === "string" &&+    (typeof object?.payload === "object" && object?.payload?.exp+      ? typeof object.payload.exp === "number"+      : true)+  );+}++export async function verify(+  jwt: string,+  key: string,+  {+    algorithm = "HS512",+  }: {+    algorithm?: Algorithm | Array<Exclude<Algorithm, "none">>;+  } = {},+): Promise<Payload> {+  const obj = decode(jwt) as TokenObject;++  if (!isTokenObject(obj)) {+    throw new Error(`jwt is invalid`);+  }++  if (+    obj?.payload !== null &&+    typeof obj?.payload === "object" &&+    "exp" in obj.payload &&+    isExpired(obj.payload.exp!, 1)+  ) {+    throw RangeError("jwt is expired");+  }++  if (!verifyAlgorithm(algorithm, obj.header.alg)) {+    throw new Error(`algorithms do not match`);+  }++  const { header, payload, signature } = obj;++  /*+   * JWS §4.1.11: The "crit" (critical) Header Parameter indicates that +   * extensions to this specification and/or [JWA] are being used that MUST be+   * understood and processed.+   */+  if ("crit" in obj.header) {+    throw new Error("implementation does not process 'crit' header parameter");+  }++  if (+    !(await verifySignature({+      signature,+      key,+      alg: header.alg,+      signingInput: jwt.slice(0, jwt.lastIndexOf(".")),+    }))+  ) {+    throw new Error("signatures do not match");+  }++  return payload;+}++/*+ * JSW §7.1: The JWS Compact Serialization represents digitally signed or MACed + * content as a compact, URL-safe string. This string is:+ *       BASE64URL(UTF8(JWS Protected Header)) || '.' ||+ *       BASE64URL(JWS Payload) || '.' ||+ *       BASE64URL(JWS Signature)+ */+function createSigningInput(header: Header, payload: Payload): string {+  return `${+    base64url.encode(+      encoder.encode(JSON.stringify(header)),+    )+  }.${+    base64url.encode(+      encoder.encode(+        typeof payload === "string" ? payload : JSON.stringify(payload),+      ),+    )+  }`;+}++export async function create(

JSDoc please.

timonson

comment created time in 4 days

Pull request review commentdenoland/deno

add(std/jwt): Implement the new jwt module

+import type { Algorithm } from "./algorithm.ts";+import * as base64url from "../encoding/base64url.ts";+import { encodeToString as convertUint8ArrayToHex } from "../encoding/hex.ts";+import {+  create as createSignature,+  verify as verifySignature,+} from "./signature.ts";+import { verify as verifyAlgorithm } from "./algorithm.ts";+/*+ * JWT §4.1: The following Claim Names are registered in the IANA+ * "JSON Web Token Claims" registry established by Section 10.1. None of the+ * claims defined below are intended to be mandatory to use or implement in all+ * cases, but rather they provide a starting point for a set of useful,+ * interoperable claims.+ * Applications using JWTs should define which specific claims they use and when+ * they are required or optional.+ */+export interface PayloadObject {+  iss?: string;+  sub?: string;+  aud?: string[] | string;+  exp?: number;+  nbf?: number;+  iat?: number;+  jti?: string;+  [key: string]: unknown;+}++export type Payload = PayloadObject | string;++/*+ * JWS §4.1.1: The "alg" value is a case-sensitive ASCII string containing a + * StringOrURI value. This Header Parameter MUST be present and MUST be+ * understood and processed by implementations.+ */+export interface Header {+  alg: Algorithm;+  [key: string]: unknown;+}++const encoder = new TextEncoder();+const decoder = new TextDecoder();++function isExpired(exp: number, leeway = 0): boolean {+  return exp + leeway < Date.now() / 1000;+}++/*+ * Helper function: setExpiration()+ * returns the number of seconds since January 1, 1970, 00:00:00 UTC+ */+export function setExpiration(exp: number | Date): number {+  return Math.round(+    (exp instanceof Date ? exp.getTime() : Date.now() + exp * 1000) / 1000,+  );+}++function tryToParsePayload(input: string) {+  try {+    return JSON.parse(input);+  } catch {+    return input;+  }+}++export function decode(+  jwt: string,+): {+  header: unknown;+  payload: unknown;+  signature: unknown;+} {+  const parsedArray = jwt+    .split(".")+    .map(base64url.decode)+    .map((uint8Array, index) =>+      index === 0+        ? JSON.parse(decoder.decode(uint8Array))+        : index === 1+        ? tryToParsePayload(decoder.decode(uint8Array))+        : convertUint8ArrayToHex(uint8Array)+    );+  if (parsedArray.length !== 3) throw TypeError("serialization is invalid");++  return {+    header: parsedArray[0],+    payload: parsedArray[1],+    signature: parsedArray[2],+  };+}++export type TokenObject = {+  header: Header;+  payload: PayloadObject | string;+  signature: string;+};++export function isTokenObject(object: TokenObject): object is TokenObject {+  return (+    typeof object?.signature === "string" &&+    typeof object?.header?.alg === "string" &&+    (typeof object?.payload === "object" && object?.payload?.exp+      ? typeof object.payload.exp === "number"+      : true)+  );+}++export async function verify(+  jwt: string,+  key: string,+  {+    algorithm = "HS512",+  }: {+    algorithm?: Algorithm | Array<Exclude<Algorithm, "none">>;+  } = {},+): Promise<Payload> {+  const obj = decode(jwt) as TokenObject;++  if (!isTokenObject(obj)) {+    throw new Error(`jwt is invalid`);+  }++  if (+    obj?.payload !== null &&+    typeof obj?.payload === "object" &&+    "exp" in obj.payload &&+    isExpired(obj.payload.exp!, 1)+  ) {+    throw RangeError("jwt is expired");+  }++  if (!verifyAlgorithm(algorithm, obj.header.alg)) {+    throw new Error(`algorithms do not match`);+  }++  const { header, payload, signature } = obj;++  /*+   * JWS §4.1.11: The "crit" (critical) Header Parameter indicates that +   * extensions to this specification and/or [JWA] are being used that MUST be+   * understood and processed.+   */+  if ("crit" in obj.header) {+    throw new Error("implementation does not process 'crit' header parameter");
    throw new Error("The 'crit' header parameter is currently not supported by this library.");
timonson

comment created time in 4 days

Pull request review commentdenoland/deno

add(std/jwt): Implement the new jwt module

+import type { Algorithm } from "./algorithm.ts";+import * as base64url from "../encoding/base64url.ts";+import { encodeToString as convertUint8ArrayToHex } from "../encoding/hex.ts";+import {+  create as createSignature,+  verify as verifySignature,+} from "./signature.ts";+import { verify as verifyAlgorithm } from "./algorithm.ts";+/*+ * JWT §4.1: The following Claim Names are registered in the IANA+ * "JSON Web Token Claims" registry established by Section 10.1. None of the+ * claims defined below are intended to be mandatory to use or implement in all+ * cases, but rather they provide a starting point for a set of useful,+ * interoperable claims.+ * Applications using JWTs should define which specific claims they use and when+ * they are required or optional.+ */+export interface PayloadObject {+  iss?: string;+  sub?: string;+  aud?: string[] | string;+  exp?: number;+  nbf?: number;+  iat?: number;+  jti?: string;+  [key: string]: unknown;+}++export type Payload = PayloadObject | string;++/*+ * JWS §4.1.1: The "alg" value is a case-sensitive ASCII string containing a + * StringOrURI value. This Header Parameter MUST be present and MUST be+ * understood and processed by implementations.+ */+export interface Header {+  alg: Algorithm;+  [key: string]: unknown;+}++const encoder = new TextEncoder();+const decoder = new TextDecoder();++function isExpired(exp: number, leeway = 0): boolean {+  return exp + leeway < Date.now() / 1000;+}++/*+ * Helper function: setExpiration()+ * returns the number of seconds since January 1, 1970, 00:00:00 UTC+ */+export function setExpiration(exp: number | Date): number {+  return Math.round(+    (exp instanceof Date ? exp.getTime() : Date.now() + exp * 1000) / 1000,+  );+}++function tryToParsePayload(input: string) {+  try {+    return JSON.parse(input);+  } catch {+    return input;+  }+}++export function decode(

For a public API, we should have some JSDoc (with examples) and a "concrete" return value... I am also surprised we can't have a narrow type than unknown.

timonson

comment created time in 4 days

Pull request review commentdenoland/deno

add(std/jwt): Implement the new jwt module

+import type { Algorithm } from "./algorithm.ts";+import * as base64url from "../encoding/base64url.ts";+import { encodeToString as convertUint8ArrayToHex } from "../encoding/hex.ts";+import {+  create as createSignature,+  verify as verifySignature,+} from "./signature.ts";+import { verify as verifyAlgorithm } from "./algorithm.ts";+/*+ * JWT §4.1: The following Claim Names are registered in the IANA+ * "JSON Web Token Claims" registry established by Section 10.1. None of the+ * claims defined below are intended to be mandatory to use or implement in all+ * cases, but rather they provide a starting point for a set of useful,+ * interoperable claims.+ * Applications using JWTs should define which specific claims they use and when+ * they are required or optional.+ */+export interface PayloadObject {+  iss?: string;+  sub?: string;+  aud?: string[] | string;+  exp?: number;+  nbf?: number;+  iat?: number;+  jti?: string;+  [key: string]: unknown;+}++export type Payload = PayloadObject | string;++/*+ * JWS §4.1.1: The "alg" value is a case-sensitive ASCII string containing a + * StringOrURI value. This Header Parameter MUST be present and MUST be+ * understood and processed by implementations.+ */+export interface Header {+  alg: Algorithm;+  [key: string]: unknown;+}++const encoder = new TextEncoder();+const decoder = new TextDecoder();++function isExpired(exp: number, leeway = 0): boolean {+  return exp + leeway < Date.now() / 1000;+}++/*+ * Helper function: setExpiration()+ * returns the number of seconds since January 1, 1970, 00:00:00 UTC+ */+export function setExpiration(exp: number | Date): number {+  return Math.round(+    (exp instanceof Date ? exp.getTime() : Date.now() + exp * 1000) / 1000,+  );+}++function tryToParsePayload(input: string) {+  try {+    return JSON.parse(input);+  } catch {+    return input;+  }+}++export function decode(+  jwt: string,+): {+  header: unknown;+  payload: unknown;+  signature: unknown;+} {+  const parsedArray = jwt+    .split(".")+    .map(base64url.decode)+    .map((uint8Array, index) =>+      index === 0+        ? JSON.parse(decoder.decode(uint8Array))+        : index === 1+        ? tryToParsePayload(decoder.decode(uint8Array))+        : convertUint8ArrayToHex(uint8Array)+    );+  if (parsedArray.length !== 3) throw TypeError("serialization is invalid");++  return {+    header: parsedArray[0],+    payload: parsedArray[1],+    signature: parsedArray[2],+  };+}++export type TokenObject = {+  header: Header;+  payload: PayloadObject | string;+  signature: string;+};++export function isTokenObject(object: TokenObject): object is TokenObject {+  return (+    typeof object?.signature === "string" &&+    typeof object?.header?.alg === "string" &&+    (typeof object?.payload === "object" && object?.payload?.exp+      ? typeof object.payload.exp === "number"+      : true)+  );+}++export async function verify(+  jwt: string,+  key: string,+  {+    algorithm = "HS512",+  }: {+    algorithm?: Algorithm | Array<Exclude<Algorithm, "none">>;+  } = {},+): Promise<Payload> {+  const obj = decode(jwt) as TokenObject;++  if (!isTokenObject(obj)) {+    throw new Error(`jwt is invalid`);+  }++  if (+    obj?.payload !== null &&+    typeof obj?.payload === "object" &&+    "exp" in obj.payload &&+    isExpired(obj.payload.exp!, 1)+  ) {+    throw RangeError("jwt is expired");+  }++  if (!verifyAlgorithm(algorithm, obj.header.alg)) {+    throw new Error(`algorithms do not match`);+  }++  const { header, payload, signature } = obj;++  /*+   * JWS §4.1.11: The "crit" (critical) Header Parameter indicates that +   * extensions to this specification and/or [JWA] are being used that MUST be+   * understood and processed.+   */+  if ("crit" in obj.header) {+    throw new Error("implementation does not process 'crit' header parameter");+  }++  if (+    !(await verifySignature({+      signature,+      key,+      alg: header.alg,+      signingInput: jwt.slice(0, jwt.lastIndexOf(".")),+    }))+  ) {+    throw new Error("signatures do not match");
    throw new Error("The token's signature do not match the verification signature.");
timonson

comment created time in 4 days

Pull request review commentdenoland/deno

add(std/jwt): Implement the new jwt module

+import type { Algorithm } from "./algorithm.ts";+import * as base64url from "../encoding/base64url.ts";+import { encodeToString as convertUint8ArrayToHex } from "../encoding/hex.ts";+import {+  create as createSignature,+  verify as verifySignature,+} from "./signature.ts";+import { verify as verifyAlgorithm } from "./algorithm.ts";+/*+ * JWT §4.1: The following Claim Names are registered in the IANA+ * "JSON Web Token Claims" registry established by Section 10.1. None of the+ * claims defined below are intended to be mandatory to use or implement in all+ * cases, but rather they provide a starting point for a set of useful,+ * interoperable claims.+ * Applications using JWTs should define which specific claims they use and when+ * they are required or optional.+ */+export interface PayloadObject {+  iss?: string;+  sub?: string;+  aud?: string[] | string;+  exp?: number;+  nbf?: number;+  iat?: number;+  jti?: string;+  [key: string]: unknown;+}++export type Payload = PayloadObject | string;++/*+ * JWS §4.1.1: The "alg" value is a case-sensitive ASCII string containing a + * StringOrURI value. This Header Parameter MUST be present and MUST be+ * understood and processed by implementations.+ */+export interface Header {+  alg: Algorithm;+  [key: string]: unknown;+}++const encoder = new TextEncoder();+const decoder = new TextDecoder();++function isExpired(exp: number, leeway = 0): boolean {+  return exp + leeway < Date.now() / 1000;+}++/*+ * Helper function: setExpiration()+ * returns the number of seconds since January 1, 1970, 00:00:00 UTC+ */+export function setExpiration(exp: number | Date): number {+  return Math.round(+    (exp instanceof Date ? exp.getTime() : Date.now() + exp * 1000) / 1000,+  );+}++function tryToParsePayload(input: string) {+  try {+    return JSON.parse(input);+  } catch {+    return input;+  }+}++export function decode(+  jwt: string,+): {+  header: unknown;+  payload: unknown;+  signature: unknown;+} {+  const parsedArray = jwt+    .split(".")+    .map(base64url.decode)+    .map((uint8Array, index) =>+      index === 0+        ? JSON.parse(decoder.decode(uint8Array))+        : index === 1+        ? tryToParsePayload(decoder.decode(uint8Array))+        : convertUint8ArrayToHex(uint8Array)+    );+  if (parsedArray.length !== 3) throw TypeError("serialization is invalid");++  return {+    header: parsedArray[0],+    payload: parsedArray[1],+    signature: parsedArray[2],+  };+}++export type TokenObject = {+  header: Header;+  payload: PayloadObject | string;+  signature: string;+};++export function isTokenObject(object: TokenObject): object is TokenObject {+  return (+    typeof object?.signature === "string" &&+    typeof object?.header?.alg === "string" &&+    (typeof object?.payload === "object" && object?.payload?.exp+      ? typeof object.payload.exp === "number"+      : true)+  );+}++export async function verify(

JSDoc please.

timonson

comment created time in 4 days

Pull request review commentdenoland/deno

add(std/jwt): Implement the new jwt module

+import type { Algorithm } from "./algorithm.ts";+import * as base64url from "../encoding/base64url.ts";+import { encodeToString as convertUint8ArrayToHex } from "../encoding/hex.ts";+import {+  create as createSignature,+  verify as verifySignature,+} from "./signature.ts";+import { verify as verifyAlgorithm } from "./algorithm.ts";+/*+ * JWT §4.1: The following Claim Names are registered in the IANA+ * "JSON Web Token Claims" registry established by Section 10.1. None of the+ * claims defined below are intended to be mandatory to use or implement in all+ * cases, but rather they provide a starting point for a set of useful,+ * interoperable claims.+ * Applications using JWTs should define which specific claims they use and when+ * they are required or optional.+ */+export interface PayloadObject {+  iss?: string;+  sub?: string;+  aud?: string[] | string;+  exp?: number;+  nbf?: number;+  iat?: number;+  jti?: string;+  [key: string]: unknown;+}++export type Payload = PayloadObject | string;++/*+ * JWS §4.1.1: The "alg" value is a case-sensitive ASCII string containing a + * StringOrURI value. This Header Parameter MUST be present and MUST be+ * understood and processed by implementations.+ */+export interface Header {+  alg: Algorithm;+  [key: string]: unknown;+}++const encoder = new TextEncoder();+const decoder = new TextDecoder();++function isExpired(exp: number, leeway = 0): boolean {+  return exp + leeway < Date.now() / 1000;+}++/*+ * Helper function: setExpiration()+ * returns the number of seconds since January 1, 1970, 00:00:00 UTC+ */+export function setExpiration(exp: number | Date): number {+  return Math.round(+    (exp instanceof Date ? exp.getTime() : Date.now() + exp * 1000) / 1000,+  );+}++function tryToParsePayload(input: string) {+  try {+    return JSON.parse(input);+  } catch {+    return input;+  }+}++export function decode(+  jwt: string,+): {+  header: unknown;+  payload: unknown;+  signature: unknown;+} {+  const parsedArray = jwt+    .split(".")+    .map(base64url.decode)+    .map((uint8Array, index) =>+      index === 0+        ? JSON.parse(decoder.decode(uint8Array))+        : index === 1+        ? tryToParsePayload(decoder.decode(uint8Array))+        : convertUint8ArrayToHex(uint8Array)+    );+  if (parsedArray.length !== 3) throw TypeError("serialization is invalid");++  return {+    header: parsedArray[0],+    payload: parsedArray[1],+    signature: parsedArray[2],+  };+}++export type TokenObject = {+  header: Header;+  payload: PayloadObject | string;+  signature: string;+};++export function isTokenObject(object: TokenObject): object is TokenObject {+  return (+    typeof object?.signature === "string" &&+    typeof object?.header?.alg === "string" &&+    (typeof object?.payload === "object" && object?.payload?.exp+      ? typeof object.payload.exp === "number"+      : true)+  );+}++export async function verify(+  jwt: string,+  key: string,+  {+    algorithm = "HS512",+  }: {+    algorithm?: Algorithm | Array<Exclude<Algorithm, "none">>;+  } = {},+): Promise<Payload> {+  const obj = decode(jwt) as TokenObject;++  if (!isTokenObject(obj)) {+    throw new Error(`jwt is invalid`);+  }++  if (+    obj?.payload !== null &&+    typeof obj?.payload === "object" &&+    "exp" in obj.payload &&+    isExpired(obj.payload.exp!, 1)+  ) {

obj cannot possible be undefined here, because of the use of isTokenObject as 119.

  const { payload } = obj;
  if (
    payload !== null &&
    typeof payload === "object" &&
    "exp" in payload &&
    isExpired(payload.exp!, 1)
  ) {

The not null assertion should be able to be refactor out as well, something must be going on with the types that is unobvious to me doing the review.

timonson

comment created time in 4 days

Pull request review commentdenoland/deno

add(std/jwt): Implement the new jwt module

+import type { Algorithm } from "./algorithm.ts";+import * as base64url from "../encoding/base64url.ts";+import { encodeToString as convertUint8ArrayToHex } from "../encoding/hex.ts";+import {+  create as createSignature,+  verify as verifySignature,+} from "./signature.ts";+import { verify as verifyAlgorithm } from "./algorithm.ts";+/*+ * JWT §4.1: The following Claim Names are registered in the IANA+ * "JSON Web Token Claims" registry established by Section 10.1. None of the+ * claims defined below are intended to be mandatory to use or implement in all+ * cases, but rather they provide a starting point for a set of useful,+ * interoperable claims.+ * Applications using JWTs should define which specific claims they use and when+ * they are required or optional.+ */+export interface PayloadObject {+  iss?: string;+  sub?: string;+  aud?: string[] | string;+  exp?: number;+  nbf?: number;+  iat?: number;+  jti?: string;+  [key: string]: unknown;+}++export type Payload = PayloadObject | string;++/*+ * JWS §4.1.1: The "alg" value is a case-sensitive ASCII string containing a + * StringOrURI value. This Header Parameter MUST be present and MUST be+ * understood and processed by implementations.+ */+export interface Header {+  alg: Algorithm;+  [key: string]: unknown;+}++const encoder = new TextEncoder();+const decoder = new TextDecoder();++function isExpired(exp: number, leeway = 0): boolean {+  return exp + leeway < Date.now() / 1000;+}++/*+ * Helper function: setExpiration()+ * returns the number of seconds since January 1, 1970, 00:00:00 UTC+ */+export function setExpiration(exp: number | Date): number {+  return Math.round(+    (exp instanceof Date ? exp.getTime() : Date.now() + exp * 1000) / 1000,+  );+}++function tryToParsePayload(input: string) {
function tryToParsePayload(input: string): any {
timonson

comment created time in 4 days

Pull request review commentdenoland/deno

add(std/jwt): Implement the new jwt module

+import type { Algorithm } from "./algorithm.ts";+import * as base64url from "../encoding/base64url.ts";+import { encodeToString as convertUint8ArrayToHex } from "../encoding/hex.ts";+import {+  create as createSignature,+  verify as verifySignature,+} from "./signature.ts";+import { verify as verifyAlgorithm } from "./algorithm.ts";+/*+ * JWT §4.1: The following Claim Names are registered in the IANA+ * "JSON Web Token Claims" registry established by Section 10.1. None of the+ * claims defined below are intended to be mandatory to use or implement in all+ * cases, but rather they provide a starting point for a set of useful,+ * interoperable claims.+ * Applications using JWTs should define which specific claims they use and when+ * they are required or optional.+ */+export interface PayloadObject {+  iss?: string;+  sub?: string;+  aud?: string[] | string;+  exp?: number;+  nbf?: number;+  iat?: number;+  jti?: string;+  [key: string]: unknown;+}++export type Payload = PayloadObject | string;++/*+ * JWS §4.1.1: The "alg" value is a case-sensitive ASCII string containing a + * StringOrURI value. This Header Parameter MUST be present and MUST be+ * understood and processed by implementations.+ */+export interface Header {+  alg: Algorithm;+  [key: string]: unknown;+}++const encoder = new TextEncoder();+const decoder = new TextDecoder();++function isExpired(exp: number, leeway = 0): boolean {+  return exp + leeway < Date.now() / 1000;+}++/*+ * Helper function: setExpiration()+ * returns the number of seconds since January 1, 1970, 00:00:00 UTC+ */+export function setExpiration(exp: number | Date): number {+  return Math.round(+    (exp instanceof Date ? exp.getTime() : Date.now() + exp * 1000) / 1000,+  );+}++function tryToParsePayload(input: string) {+  try {+    return JSON.parse(input);+  } catch {+    return input;+  }+}++export function decode(+  jwt: string,+): {+  header: unknown;+  payload: unknown;+  signature: unknown;+} {+  const parsedArray = jwt+    .split(".")+    .map(base64url.decode)+    .map((uint8Array, index) =>+      index === 0+        ? JSON.parse(decoder.decode(uint8Array))+        : index === 1+        ? tryToParsePayload(decoder.decode(uint8Array))+        : convertUint8ArrayToHex(uint8Array)+    );+  if (parsedArray.length !== 3) throw TypeError("serialization is invalid");++  return {+    header: parsedArray[0],+    payload: parsedArray[1],+    signature: parsedArray[2],+  };+}++export type TokenObject = {+  header: Header;+  payload: PayloadObject | string;+  signature: string;+};++export function isTokenObject(object: TokenObject): object is TokenObject {+  return (+    typeof object?.signature === "string" &&+    typeof object?.header?.alg === "string" &&+    (typeof object?.payload === "object" && object?.payload?.exp+      ? typeof object.payload.exp === "number"+      : true)+  );+}++export async function verify(+  jwt: string,+  key: string,+  {+    algorithm = "HS512",+  }: {+    algorithm?: Algorithm | Array<Exclude<Algorithm, "none">>;

You have now used this in two places, a type alias would make sense. Also, it would be good to make this into a concrete type, like VerifyOptions and export it, with some JSDoc.

timonson

comment created time in 4 days

Pull request review commentdenoland/deno

add(std/jwt): Implement the new jwt module

+import type { Algorithm } from "./algorithm.ts";+import * as base64url from "../encoding/base64url.ts";+import { encodeToString as convertUint8ArrayToHex } from "../encoding/hex.ts";+import {+  create as createSignature,+  verify as verifySignature,+} from "./signature.ts";+import { verify as verifyAlgorithm } from "./algorithm.ts";+/*+ * JWT §4.1: The following Claim Names are registered in the IANA+ * "JSON Web Token Claims" registry established by Section 10.1. None of the+ * claims defined below are intended to be mandatory to use or implement in all+ * cases, but rather they provide a starting point for a set of useful,+ * interoperable claims.+ * Applications using JWTs should define which specific claims they use and when+ * they are required or optional.+ */+export interface PayloadObject {+  iss?: string;+  sub?: string;+  aud?: string[] | string;+  exp?: number;+  nbf?: number;+  iat?: number;+  jti?: string;+  [key: string]: unknown;+}++export type Payload = PayloadObject | string;++/*+ * JWS §4.1.1: The "alg" value is a case-sensitive ASCII string containing a + * StringOrURI value. This Header Parameter MUST be present and MUST be+ * understood and processed by implementations.+ */+export interface Header {+  alg: Algorithm;+  [key: string]: unknown;+}++const encoder = new TextEncoder();+const decoder = new TextDecoder();++function isExpired(exp: number, leeway = 0): boolean {+  return exp + leeway < Date.now() / 1000;+}++/*+ * Helper function: setExpiration()+ * returns the number of seconds since January 1, 1970, 00:00:00 UTC+ */+export function setExpiration(exp: number | Date): number {+  return Math.round(+    (exp instanceof Date ? exp.getTime() : Date.now() + exp * 1000) / 1000,+  );+}++function tryToParsePayload(input: string) {+  try {+    return JSON.parse(input);+  } catch {+    return input;+  }+}++export function decode(+  jwt: string,+): {+  header: unknown;+  payload: unknown;+  signature: unknown;+} {+  const parsedArray = jwt+    .split(".")+    .map(base64url.decode)+    .map((uint8Array, index) =>+      index === 0+        ? JSON.parse(decoder.decode(uint8Array))+        : index === 1+        ? tryToParsePayload(decoder.decode(uint8Array))+        : convertUint8ArrayToHex(uint8Array)+    );+  if (parsedArray.length !== 3) throw TypeError("serialization is invalid");++  return {+    header: parsedArray[0],+    payload: parsedArray[1],+    signature: parsedArray[2],+  };+}++export type TokenObject = {+  header: Header;+  payload: PayloadObject | string;+  signature: string;+};++export function isTokenObject(object: TokenObject): object is TokenObject {

JSDoc with examples please.

timonson

comment created time in 4 days

Pull request review commentdenoland/deno

add(std/jwt): Implement the new jwt module

+import type { Algorithm } from "./algorithm.ts";+import * as base64url from "../encoding/base64url.ts";+import { encodeToString as convertUint8ArrayToHex } from "../encoding/hex.ts";+import {+  create as createSignature,+  verify as verifySignature,+} from "./signature.ts";+import { verify as verifyAlgorithm } from "./algorithm.ts";+/*+ * JWT §4.1: The following Claim Names are registered in the IANA+ * "JSON Web Token Claims" registry established by Section 10.1. None of the+ * claims defined below are intended to be mandatory to use or implement in all+ * cases, but rather they provide a starting point for a set of useful,+ * interoperable claims.+ * Applications using JWTs should define which specific claims they use and when+ * they are required or optional.+ */+export interface PayloadObject {+  iss?: string;+  sub?: string;+  aud?: string[] | string;+  exp?: number;+  nbf?: number;+  iat?: number;+  jti?: string;+  [key: string]: unknown;+}++export type Payload = PayloadObject | string;++/*+ * JWS §4.1.1: The "alg" value is a case-sensitive ASCII string containing a + * StringOrURI value. This Header Parameter MUST be present and MUST be+ * understood and processed by implementations.+ */+export interface Header {+  alg: Algorithm;+  [key: string]: unknown;+}++const encoder = new TextEncoder();+const decoder = new TextDecoder();++function isExpired(exp: number, leeway = 0): boolean {+  return exp + leeway < Date.now() / 1000;+}++/*+ * Helper function: setExpiration()+ * returns the number of seconds since January 1, 1970, 00:00:00 UTC+ */+export function setExpiration(exp: number | Date): number {+  return Math.round(+    (exp instanceof Date ? exp.getTime() : Date.now() + exp * 1000) / 1000,+  );+}++function tryToParsePayload(input: string) {+  try {+    return JSON.parse(input);+  } catch {+    return input;+  }+}++export function decode(+  jwt: string,+): {+  header: unknown;+  payload: unknown;+  signature: unknown;+} {+  const parsedArray = jwt+    .split(".")+    .map(base64url.decode)+    .map((uint8Array, index) =>+      index === 0+        ? JSON.parse(decoder.decode(uint8Array))+        : index === 1+        ? tryToParsePayload(decoder.decode(uint8Array))+        : convertUint8ArrayToHex(uint8Array)+    );+  if (parsedArray.length !== 3) throw TypeError("serialization is invalid");++  return {+    header: parsedArray[0],+    payload: parsedArray[1],+    signature: parsedArray[2],+  };+}++export type TokenObject = {+  header: Header;+  payload: PayloadObject | string;+  signature: string;+};++export function isTokenObject(object: TokenObject): object is TokenObject {+  return (+    typeof object?.signature === "string" &&+    typeof object?.header?.alg === "string" &&+    (typeof object?.payload === "object" && object?.payload?.exp+      ? typeof object.payload.exp === "number"+      : true)+  );+}++export async function verify(+  jwt: string,+  key: string,+  {+    algorithm = "HS512",+  }: {+    algorithm?: Algorithm | Array<Exclude<Algorithm, "none">>;+  } = {},+): Promise<Payload> {+  const obj = decode(jwt) as TokenObject;++  if (!isTokenObject(obj)) {+    throw new Error(`jwt is invalid`);+  }++  if (+    obj?.payload !== null &&+    typeof obj?.payload === "object" &&+    "exp" in obj.payload &&+    isExpired(obj.payload.exp!, 1)+  ) {+    throw RangeError("jwt is expired");+  }++  if (!verifyAlgorithm(algorithm, obj.header.alg)) {+    throw new Error(`algorithms do not match`);
    throw new TypeError(`The asserted algorithm does not match the token's algorithm.`);
timonson

comment created time in 4 days

Pull request review commentdenoland/deno

add(std/jwt): Implement the new jwt module

+import type { Algorithm } from "./algorithm.ts";+import * as base64url from "../encoding/base64url.ts";+import { encodeToString as convertUint8ArrayToHex } from "../encoding/hex.ts";+import {+  create as createSignature,+  verify as verifySignature,+} from "./signature.ts";+import { verify as verifyAlgorithm } from "./algorithm.ts";+/*+ * JWT §4.1: The following Claim Names are registered in the IANA+ * "JSON Web Token Claims" registry established by Section 10.1. None of the+ * claims defined below are intended to be mandatory to use or implement in all+ * cases, but rather they provide a starting point for a set of useful,+ * interoperable claims.+ * Applications using JWTs should define which specific claims they use and when+ * they are required or optional.+ */+export interface PayloadObject {+  iss?: string;+  sub?: string;+  aud?: string[] | string;+  exp?: number;+  nbf?: number;+  iat?: number;+  jti?: string;+  [key: string]: unknown;+}++export type Payload = PayloadObject | string;++/*+ * JWS §4.1.1: The "alg" value is a case-sensitive ASCII string containing a + * StringOrURI value. This Header Parameter MUST be present and MUST be+ * understood and processed by implementations.+ */+export interface Header {+  alg: Algorithm;+  [key: string]: unknown;+}++const encoder = new TextEncoder();+const decoder = new TextDecoder();++function isExpired(exp: number, leeway = 0): boolean {+  return exp + leeway < Date.now() / 1000;+}++/*+ * Helper function: setExpiration()+ * returns the number of seconds since January 1, 1970, 00:00:00 UTC+ */+export function setExpiration(exp: number | Date): number {

This doesn't really set anything... it converts a number or Date to the number of seconds since the start of the unix epoch.

timonson

comment created time in 4 days

Pull request review commentdenoland/deno

add(std/jwt): Implement the new jwt module

+/*

I can see this is shared between signature and mod, but it feels like this is really just a simple internal function, that gets imported as verifyAlgorithm and doesn't make part of the public API (not directly). It feels like this could be moved somewhere else though.

timonson

comment created time in 4 days

PullRequestReviewEvent
PullRequestReviewEvent

issue commentdenoland/deno

Proposal: std/testing callback helpers

I think it is a little too opinionated and specific for std.

Soremwar

comment created time in 4 days

issue commentdenoland/deno

React v17 JSX Transform

Ref: https://github.com/swc-project/swc/issues/1103

kitsonk

comment created time in 4 days

issue openeddenoland/deno

React v17 JSX Transform

React introduces a new JSX transform that is supported in TypeScript 4.1: https://devblogs.microsoft.com/typescript/announcing-typescript-4-1-beta/#jsx-factories

We should consider the impact of this on Deno and specifically --no-check.

created time in 4 days

issue commentdenoland/deno

Add ICU in embedded v8

I'm just curious: what's the main reason for delay on this? Is it due to "apprehension over whether or not to support it", or (more so) due to the "difficultly of supporting it"?

It is two fold. Priority and finding the right balance of the functional needs with the "cost" of adding ICU. If we add all of the ICU that will dramatically increase the size of the executable, for something that not everyone needs or uses. If we put just en-us, that is more reasonable, but then do we need to have a mechanism for loading other regions? Probably, then that gets into the more complex category. Because it keeps getting bumped into the hard category, and there have been lots of other things to deal with has made are the root causes... We all agree we need it though.

zekth

comment created time in 4 days

Pull request review commentdenoland/deno

fix(cli): ModuleGraph2 properly handles redirects

 impl Graph2 {     Ok(result)   } +  fn resolve_specifier<'a>(+    &'a self,+    specifier: &'a ModuleSpecifier,+  ) -> &'a ModuleSpecifier {+    let mut s = specifier;+    while let Some(redirect) = self.redirects.get(s) {+      s = redirect;+    }+    s+  }

It isn't specifically guarded, but it would like cause errors elsewhere first (in file_fetcher). I will take a look though.

kitsonk

comment created time in 4 days

PullRequestReviewEvent

Pull request review commentdenoland/deno

fix(cli): ModuleGraph2 properly handles redirects

 use std::sync::Arc; use std::sync::Mutex;  /// Structure representing local or remote file.-///-/// In case of remote file `url` might be different than originally requested URL, if so-/// `redirect_source_url` will contain original URL and `url` will be equal to final location.

Because there is no redirect_source_url. It was refactored out at some point and no one bothered to update the comment.

kitsonk

comment created time in 4 days

PullRequestReviewEvent

issue commentdenoland/deno

Suggestion: remove everything mentioned in annex B of the ECMAScript standard

If v8 implements it, and there isn't a good reason to remove it, we won't remove it. Some of them might be really difficult to remove. Most things in Annex B are being moved out anyways, as TC39 wants to kill off Annex B.

or is required to run the same legacy ECMAScript code that web browsers encounter.

Focusing on the last sentence, Deno does not fall under any of the exceptions they mention, so should Deno have these?

Deno aims for browser compatibility where logical. So yes, it does fall under this exception. If it is implemented in v8 for "free", it is harder and riskier to un-implement it than to just allow it. You mess with some internals like that, you can easily for v8 into de-optimising code, which would be bad for everyone. We had to make with the removal of __proto__ that we weren't accidentally de-optimising everyone's code.

__proto__ is deleted before user code is run, so why not remove the rest?

Because it is a security issue, and in the move of __proto__ of of Annex B (https://github.com/tc39/ecma262/pull/2125) there will be clarity around the prototype and what we did regarding the security concern.

If you have a security reason to remove the other parts of Annex B, we would potentially consider those.

00ff0000red

comment created time in 5 days

pull request commentdenoland/deno

fix(cli): ModuleGraph2 properly handles redirects

Bit more detail about this...

ModuleGraph2 no has a hash of all the redirects and when a module is attempted to be resolved, it will keep recursively looking up any redirects until the point where it no longer gets redirected, and then attempts to look the module up in the graph.

Currently the file_fetcher simply returns the "final" Url for a fetched file, so when the module is added to the graph, it only has one potential redirect. If in the future we surface up the entire change, that will "just work" with the graph, because of the recursive way it resolves modules.

I've tried this on my run/check migration branch and it seems to fix all the cases we have tests for.

kitsonk

comment created time in 5 days

push eventkitsonk/deno

Kitson Kelly

commit sha 75cda396db28d024c91b1c9604dbdddf35b90edc

one more try with clippy 📎

view details

push time in 5 days

push eventkitsonk/deno

Kitson Kelly

commit sha fbc140e24e7195a074cb92e5d49257fae58fc871

remember to run cargo clippy Kit 🤦

view details

push time in 5 days

PR opened denoland/deno

Reviewers
fix(cli): ModuleGraph2 properly handles redirects

Fixes issues where both --no-check and deno info do not currently handle redirects.

+100 -54

0 comment

5 changed files

pr created time in 5 days

create barnchkitsonk/deno

branch : fix-mg2-redirect

created branch time in 5 days

push eventkitsonk/deno

Bartek Iwańczuk

commit sha 135053486c4bd112ebd7d0b25c94a8dd346472e6

fix: top-level-await module execution (#7946) This commit changes implementation of top-level-await in "deno_core". Previously promise returned from module evaluation was not awaited, leading to out-of-order execution of modules that have TLA. It's been fixed by changing "JsRuntime::mod_evaluate" to be an async function that resolves when the promise returned from module evaluation also resolves. When waiting for promise resolution event loop is polled repeatedly, until there are no more dynamic imports or pending ops.

view details

Casper Beyer

commit sha e2a1a7c937b67d050e7e3287d7e5dbc6ffd9b168

refactor(cli/repl): clean up prelude injection (#7967) This extracts prelude injection into a helper function and moves the prelude string literal into a top level static string to help trim some of the fat out of the run function.

view details

Yoshiya Hinosawa

commit sha e9f02c231473ba42f506a895734d445cd31d379f

fix(console): fix the test cases of function inspections (#7965)

view details

Bartek Iwańczuk

commit sha 12e700bddfad8c23f6b55baca4ca4afb8337af26

fix(test): return error when awaiting unresolved promise (#7968) This commit fixes test runner by awaitning "Deno.runTests()" call, which ensures proper error is returned when there's an unresolved promise that's being awaited.

view details

vwkd

commit sha f9489e9acb0e3121bbd71ef0cf1826320d0c0995

fix typos (#7964)

view details

TTtie

commit sha f75bd89aff7cffafceb394d629995479af54a156

feat(cli/console): inspect with colors regardless of Deno.noColor (#7778) This commit adds the ability for users to inspect items stylized with ANSI colors regardless of the value of Deno.noColor.

view details

ali ahmed

commit sha 5bed06fb94214db70a27cca8fa8eff717d537dba

feat(std/fs/node): adding some functions (#7921)

view details

Bartek Iwańczuk

commit sha 81635c59e66b81a4c85aed6775aff4beedf71f14

Revert "feat(cli/console): inspect with colors regardless of Deno.noColor (#7778)" (#7973) This reverts commit f75bd89aff7cffafceb394d629995479af54a156.

view details

push time in 5 days

pull request commentswc-project/swc

bundler: Handle computed accesses correctly

🎉 🎉 🎉 🎉

Yes, I can confirm master properly builds that bundle!!!

Thank you @kdy1 great work.

kdy1

comment created time in 5 days

push eventkitsonk/swc

Pig Fang

commit sha aded151b8f4bb8f367b9e4b4c9e92e4850728457

[typescript] 4.1 mapped type 'as' clause (#1151) Co-authored-by: 강동윤 <kdy1997.dev@gmail.com>

view details

강동윤

commit sha a5e624260180c2d9c394a8dc52d192e7321317a2

Bump version

view details

강동윤

commit sha ad7cb6544d1ff019243f40fa87f59843d7b2151d

bundler: Handle computed accesses correctly (#1159) swc_bundler: - Handle computed accesses to imports correctly. - Make planning deterministic. - Prefer exports over imports while planning. - Fix https://deno.land/x/oak@v6.3.1/examples/server.ts

view details

push time in 5 days

push eventkitsonk/deno

timonson

commit sha 1956cb81372b96bc476e74ab43a62a6e60861277

fix(std/encoding): base64 properly encodes mbc and handles Uint8Arrays (#7807) Fixes #6094 Fixes #4794

view details

Kitson Kelly

commit sha 000ac5c40b71c38cc26a36e579fbb0936f0573d7

reafactor(cli): use Emit enum and rename ts_build_info (#7952)

view details

Bartek Iwańczuk

commit sha 0bd3cea0ff6d2d4840c0df2938b5ae5c5d7cc4bd

refactor(cli): rename GlobalState to ProgramState (#7914)

view details

Yoshiya Hinosawa

commit sha 0dcaea72aeec52a566764b41b10d8fd1854d6fa4

feat: add alert, confirm, and prompt (#7507) This commit adds "alert", "confirm" and "prompt" functions from web standards.

view details

Casper Beyer

commit sha bbf7b2ee72ae7dede26e4ef48b384404525f389e

feat(cli/repl): add regex based syntax highlighter (#7811) This commit adds a simple regex replace based highlighter to the REPL editor. It tries to match the color palette of Deno.inspect()

view details

Nayeem Rahman

commit sha d0c2714c033b010cbd174138638881dc65abef06

fix(op_crates/web/url): apply backslash replacement to the pathname setter (#7937)

view details

Grant Timmerman

commit sha 47eeb889e18cb5be5465a150b05b409d7f77fcb3

docs: fix runtime docs link in README (#7926)

view details

sakas

commit sha f42d0fc99e37bb0583cddeca5367a1dcf83d53b8

docs: fix links to examples (#7919)

view details

Ryan Dahl

commit sha 374d433f1f4885686dc5c166be3a25c839e22959

Remove dead code (#7963)

view details

Kitson Kelly

commit sha 10654fa95553866c63a56a7f84c7ec47fb7aac9c

refactor(cli): add tsc2 (#7942) Ref #7225

view details

push time in 6 days

push eventdenoland/deno

Kitson Kelly

commit sha 10654fa95553866c63a56a7f84c7ec47fb7aac9c

refactor(cli): add tsc2 (#7942) Ref #7225

view details

push time in 6 days

PR merged denoland/deno

refactor(cli): add tsc2

This is the last of the "new" infrastructure that will unblock being able to move everything over.

I will do a subsequent PR based on this to actually move something else over the requires the TS compiler.

+877 -80

1 comment

15 changed files

kitsonk

pr closed time in 6 days

Pull request review commentdenoland/deno

refactor(cli): add tsc2

+// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.++use crate::diagnostics::Diagnostics;+use crate::media_type::MediaType;+use crate::module_graph2::Graph2;+use crate::module_graph2::Stats;+use crate::tsc_config::TsConfig;++use deno_core::error::anyhow;+use deno_core::error::bail;+use deno_core::error::AnyError;+use deno_core::error::Context;+use deno_core::json_op_sync;+use deno_core::serde_json;+use deno_core::serde_json::json;+use deno_core::serde_json::Value;+use deno_core::JsRuntime;+use deno_core::ModuleSpecifier;+use deno_core::OpFn;+use deno_core::RuntimeOptions;+use deno_core::Snapshot;+use serde::Deserialize;+use serde::Serialize;+use std::cell::RefCell;+use std::rc::Rc;++#[derive(Debug, Clone, Default, Eq, PartialEq)]+pub struct EmittedFile {+  pub data: String,+  pub maybe_specifiers: Option<Vec<ModuleSpecifier>>,+  pub media_type: MediaType,+}++/// A structure representing a request to be sent to the tsc runtime.+#[derive(Debug, Serialize)]+#[serde(rename_all = "camelCase")]+pub struct Request {+  /// The TypeScript compiler options which will be serialized and sent to+  /// tsc.+  pub config: TsConfig,+  /// Indicates to the tsc runtime if debug logging should occur.+  pub debug: bool,+  #[serde(skip_serializing)]+  pub graph: Rc<RefCell<Graph2>>,

I am going to land it just as an Rc<> but I just ran into a problem when moving run over that mutates the graph, so I have to go and put it back in. 🤷

kitsonk

comment created time in 6 days

PullRequestReviewEvent

issue commentdenoland/deno

Expose structured clone as serialization API

Actually, that being said... for some of the web APIs that we provide in Deno, it can be useful there... so something on Deno.core might make sense. We have this in there at the moment:

https://github.com/denoland/deno/blob/374d433f1f4885686dc5c166be3a25c839e22959/cli/rt/01_web_util.js#L34-L36

Which we have to use in streams and potentially other APIs when transferring/cloning objects.

lorenbrichter

comment created time in 6 days

issue commentdenoland/deno

Expose structured clone as serialization API

Does not leak V8 concepts into user land.

Structured cloning is not a V8 concept... it is an ECMAScript/JavaScript concept, though, like I said, its exposure as a runtime API is "questionable" because it isn't useful from within the isolate. Really useful for "behind the scenes" things like plugins though.

lorenbrichter

comment created time in 6 days

push eventkitsonk/deno

Bartek Iwańczuk

commit sha 0bd3cea0ff6d2d4840c0df2938b5ae5c5d7cc4bd

refactor(cli): rename GlobalState to ProgramState (#7914)

view details

Yoshiya Hinosawa

commit sha 0dcaea72aeec52a566764b41b10d8fd1854d6fa4

feat: add alert, confirm, and prompt (#7507) This commit adds "alert", "confirm" and "prompt" functions from web standards.

view details

Casper Beyer

commit sha bbf7b2ee72ae7dede26e4ef48b384404525f389e

feat(cli/repl): add regex based syntax highlighter (#7811) This commit adds a simple regex replace based highlighter to the REPL editor. It tries to match the color palette of Deno.inspect()

view details

Nayeem Rahman

commit sha d0c2714c033b010cbd174138638881dc65abef06

fix(op_crates/web/url): apply backslash replacement to the pathname setter (#7937)

view details

Grant Timmerman

commit sha 47eeb889e18cb5be5465a150b05b409d7f77fcb3

docs: fix runtime docs link in README (#7926)

view details

sakas

commit sha f42d0fc99e37bb0583cddeca5367a1dcf83d53b8

docs: fix links to examples (#7919)

view details

Ryan Dahl

commit sha 374d433f1f4885686dc5c166be3a25c839e22959

Remove dead code (#7963)

view details

Kitson Kelly

commit sha 3ea08120d31cb59d6821ac31ebabf5b33045717d

refactor(cli): add tsc2

view details

Kitson Kelly

commit sha 26b7f5954d57e8ab0984898552da8fed95a64187

fix mediatype issues

view details

Kitson Kelly

commit sha f260e4416149ab424c85893c3ea3063f05228fd1

refactor tsc2::exec API

view details

Kitson Kelly

commit sha 2c6c3bba9fc86d912b93650dda8d83d3e33372c8

address feedback

view details

push time in 6 days

PullRequestReviewEvent

issue commentdenoland/deno

deno scripts without an extension raise errors

I confirm having this issue invoking a script with a symlink.

Could you provide more details.

aricart

comment created time in 6 days

issue commentmicrosoft/TypeScript

Suggestion: allow get/set accessors to be of different types

@xhliu as the labels indicate, it is a design limitation that is too complex to address, and therefore the issue is closed. I wouldn't not expect an update. The length of time for a closed issue is sort of irrelevant.

irakliy81

comment created time in 6 days

issue commentdenoland/deno

Expose structured clone as serialization API

This specifically goes against what Deno is doing, they don't want to provide access to V8 directly like this.

It isn't against what Deno is doing.

We need structured cloning working properly before we could consider this though. The challenge is that unless you are doing something with it (like sending it between workers or putting in a db) it doesn't make sense in a runtime isolate. Having it be something that plugins have easy access to though would be more important.

lorenbrichter

comment created time in 6 days

more