Skip to content

Initial implementation. #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 4, 2022
Merged

Conversation

sjrd
Copy link
Member

@sjrd sjrd commented Mar 30, 2022

Goes together with scala-js/scala-js#4659

Draft because the CI script mentions my fork of scala-js/scala-js. We'll need it to change that once scala-js/scala-js#4659 is merged.

But otherwise it's ready to review.

@sjrd sjrd requested a review from gzm0 March 30, 2022 14:25
@sjrd
Copy link
Member Author

sjrd commented Mar 30, 2022

README.md Outdated

You can then use `java.security.SecureRandom` from your code, and by extension, the `java.util.UUID.randomUUID()` method.

When running on environments other than browsers or Node.js, attempts to use the above features will throw a `java.lang.UnsupportedOperationException`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is somewhat pessimistic. Other runtimes such as Cloudflare Workers (serverless) and Deno have also implemented the WebCrypto APIs.
https://developers.cloudflare.com/workers/runtime-apis/web-crypto/#methods
https://deno.com/blog/v1.11#more-web-crypto-apis-supported

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it better now?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! Thanks :)

@sjrd sjrd force-pushed the initial-implementation branch from d8ed45c to 69dc31e Compare March 31, 2022 07:44
Copy link

@gzm0 gzm0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All comments from scala-js/scala-js-fake-insecure-java-securerandom#1 also apply here.

build.sbt Outdated
.settings(commonSettings: _*)
.settings(
testOptions += Tests.Argument(TestFramework("com.novocode.junit.JUnitFramework"), "-v", "-a"),
buildInfoKeys := Seq(BuildInfoKey("expectFailure" -> (jsEnvKind.value == JSEnvKind.JSDOMNodeJS))),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider passing in the raw info so the logic if why we expect a failure remains encapsulated in the relevant test.

lazy val testSuite = crossProject(JSPlatform, JVMPlatform)
.in(file("test-suite"))
.jsConfigure(_.enablePlugins(ScalaJSJUnitPlugin))
.enablePlugins(BuildInfoPlugin)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Side note: We should use this for the core repo as well. Right now, we roll our own :)

addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.2.0")

addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.0")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use 0.11.0?

@sjrd sjrd force-pushed the initial-implementation branch 2 times, most recently from b5f62dc to 1bd1795 Compare April 4, 2022 09:25
@sjrd sjrd marked this pull request as ready for review April 4, 2022 09:26
@sjrd sjrd requested a review from gzm0 April 4, 2022 09:26
@sjrd
Copy link
Member Author

sjrd commented Apr 4, 2022

I think I have addressed all the comments here as well, now.

@sjrd sjrd force-pushed the initial-implementation branch from 1bd1795 to d6cf1c8 Compare April 4, 2022 14:52
@sjrd
Copy link
Member Author

sjrd commented Apr 4, 2022

Upgraded to Scala.js 1.10.0 final.
Green CI build: https://github.com/sjrd/scala-js-java-securerandom/actions/runs/2090651909

@sjrd sjrd merged commit 58267be into scala-js:main Apr 4, 2022
@sjrd sjrd deleted the initial-implementation branch April 4, 2022 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants