Skip to content

Commit

Permalink
Add webcrypto
Browse files Browse the repository at this point in the history
  • Loading branch information
kohlschuetter committed Aug 20, 2024
1 parent 6ebce64 commit 4671612
Show file tree
Hide file tree
Showing 11 changed files with 1,541 additions and 1 deletion.
1 change: 1 addition & 0 deletions jacline-elemental2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@
<module>media</module>
<module>svg</module>
<module>webassembly</module>
<module>webcrypto</module>
<module>webgl</module>
<module>webstorage</module>
</modules>
Expand Down
2 changes: 1 addition & 1 deletion jacline-elemental2/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ cd ..

fromBase=elemental2/bazel-bin/java/elemental2

for module in promise core dom indexeddb media svg webassembly webgl webstorage; do
for module in promise core dom indexeddb media svg webassembly webcrypto webgl webstorage; do
src="${module}/src"
javaOut=${src}/main/java
restOut=${src}/main/resources/META-INF/jacline/generated/
Expand Down
42 changes: 42 additions & 0 deletions jacline-elemental2/webcrypto/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.kohlschutter.jacline</groupId>
<artifactId>jacline-elemental2</artifactId>
<version>1.0.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>jacline-elemental2-webcrypto</artifactId>
<packaging>jar</packaging>

<description>Thin Java abstractions for the native Web Crypto APIs.</description>

<properties>
<kohlschutter.project.notice.file>
${project.parent.basedir}/NOTICE</kohlschutter.project.notice.file>
</properties>

<dependencies>
<dependency>
<groupId>com.kohlschutter.jacline</groupId>
<artifactId>jacline-elemental2-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.kohlschutter.jacline</groupId>
<artifactId>jacline-elemental2-dom</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.kohlschutter.jacline</groupId>
<artifactId>jacline-elemental2-promise</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package elemental2.webcrypto;
import java.lang.String;
import jsinterop.annotations.JsType;
import jsinterop.annotations.JsPackage;
import elemental2.core.JsObject;
@JsType(isNative = true,namespace = JsPackage.GLOBAL)
public class CryptoKey{
public JsObject algorithm;
public boolean extractable;
public String type;
public JsObject usages;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package elemental2.webcrypto;
import jsinterop.annotations.JsType;
import jsinterop.annotations.JsPackage;
import elemental2.webcrypto.CryptoKey;
@JsType(isNative = true,namespace = JsPackage.GLOBAL)
public class CryptoKeyPair{
public CryptoKey privateKey;
public CryptoKey publicKey;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package elemental2.webcrypto;
import elemental2.webcrypto.webcrypto.Crypto;
import jsinterop.annotations.JsType;
import jsinterop.annotations.JsPackage;
@JsType(isNative = true,name = "goog.global",namespace = JsPackage.GLOBAL)
public class WebCryptoGlobal{
public static Crypto crypto;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package elemental2.webcrypto;
import jsinterop.annotations.JsProperty;
import jsinterop.base.Js;
import elemental2.webcrypto.webcrypto.Crypto;
import elemental2.dom.WorkerGlobalScope;
import jsinterop.annotations.JsOverlay;
import jsinterop.annotations.JsType;
import jsinterop.annotations.JsPackage;
@JsType(isNative = true,name = "WorkerGlobalScope",namespace = JsPackage.GLOBAL)
public interface WebCryptoWorkerGlobalScope extends WorkerGlobalScope{
@JsOverlay
static WebCryptoWorkerGlobalScope of(WorkerGlobalScope o){
return Js.cast(o);
}
@JsProperty
Crypto getCrypto();
@JsProperty
void setCrypto(Crypto crypto);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,221 @@
package elemental2.webcrypto.webcrypto;
import elemental2.core.Uint32Array;
import elemental2.core.BigUint64Array;
import elemental2.core.Int16Array;
import elemental2.core.BigInt64Array;
import elemental2.webcrypto.webcrypto.SubtleCrypto;
import jsinterop.annotations.JsProperty;
import elemental2.core.Uint8Array;
import elemental2.core.Uint8ClampedArray;
import elemental2.core.Uint16Array;
import jsinterop.base.Js;
import jsinterop.annotations.JsOverlay;
import elemental2.core.Int32Array;
import java.lang.Object;
import java.lang.String;
import jsinterop.annotations.JsType;
import elemental2.core.Int8Array;
import jsinterop.annotations.JsPackage;
@JsType(isNative = true,name = "webCrypto.Crypto",namespace = JsPackage.GLOBAL)
public interface Crypto{
@JsType(isNative = true,name = "?",namespace = JsPackage.GLOBAL)
public interface GetRandomValuesTypedArrayUnionType{
@JsOverlay
static Crypto.GetRandomValuesTypedArrayUnionType of(Object o){
return Js.cast(o);
}
@JsOverlay
default BigInt64Array asBigInt64Array(){
return Js.cast(this);
}
@JsOverlay
default BigUint64Array asBigUint64Array(){
return Js.cast(this);
}
@JsOverlay
default Int16Array asInt16Array(){
return Js.cast(this);
}
@JsOverlay
default Int32Array asInt32Array(){
return Js.cast(this);
}
@JsOverlay
default Int8Array asInt8Array(){
return Js.cast(this);
}
@JsOverlay
default Uint16Array asUint16Array(){
return Js.cast(this);
}
@JsOverlay
default Uint32Array asUint32Array(){
return Js.cast(this);
}
@JsOverlay
default Uint8Array asUint8Array(){
return Js.cast(this);
}
@JsOverlay
default Uint8ClampedArray asUint8ClampedArray(){
return Js.cast(this);
}
@JsOverlay
default boolean isBigInt64Array(){
return (Object)this instanceof BigInt64Array;
}
@JsOverlay
default boolean isBigUint64Array(){
return (Object)this instanceof BigUint64Array;
}
@JsOverlay
default boolean isInt16Array(){
return (Object)this instanceof Int16Array;
}
@JsOverlay
default boolean isInt32Array(){
return (Object)this instanceof Int32Array;
}
@JsOverlay
default boolean isInt8Array(){
return (Object)this instanceof Int8Array;
}
@JsOverlay
default boolean isUint16Array(){
return (Object)this instanceof Uint16Array;
}
@JsOverlay
default boolean isUint32Array(){
return (Object)this instanceof Uint32Array;
}
@JsOverlay
default boolean isUint8Array(){
return (Object)this instanceof Uint8Array;
}
@JsOverlay
default boolean isUint8ClampedArray(){
return (Object)this instanceof Uint8ClampedArray;
}
}
@JsType(isNative = true,name = "?",namespace = JsPackage.GLOBAL)
public interface GetRandomValuesUnionType{
@JsOverlay
static Crypto.GetRandomValuesUnionType of(Object o){
return Js.cast(o);
}
@JsOverlay
default BigInt64Array asBigInt64Array(){
return Js.cast(this);
}
@JsOverlay
default BigUint64Array asBigUint64Array(){
return Js.cast(this);
}
@JsOverlay
default Int16Array asInt16Array(){
return Js.cast(this);
}
@JsOverlay
default Int32Array asInt32Array(){
return Js.cast(this);
}
@JsOverlay
default Int8Array asInt8Array(){
return Js.cast(this);
}
@JsOverlay
default Uint16Array asUint16Array(){
return Js.cast(this);
}
@JsOverlay
default Uint32Array asUint32Array(){
return Js.cast(this);
}
@JsOverlay
default Uint8Array asUint8Array(){
return Js.cast(this);
}
@JsOverlay
default Uint8ClampedArray asUint8ClampedArray(){
return Js.cast(this);
}
@JsOverlay
default boolean isBigInt64Array(){
return (Object)this instanceof BigInt64Array;
}
@JsOverlay
default boolean isBigUint64Array(){
return (Object)this instanceof BigUint64Array;
}
@JsOverlay
default boolean isInt16Array(){
return (Object)this instanceof Int16Array;
}
@JsOverlay
default boolean isInt32Array(){
return (Object)this instanceof Int32Array;
}
@JsOverlay
default boolean isInt8Array(){
return (Object)this instanceof Int8Array;
}
@JsOverlay
default boolean isUint16Array(){
return (Object)this instanceof Uint16Array;
}
@JsOverlay
default boolean isUint32Array(){
return (Object)this instanceof Uint32Array;
}
@JsOverlay
default boolean isUint8Array(){
return (Object)this instanceof Uint8Array;
}
@JsOverlay
default boolean isUint8ClampedArray(){
return (Object)this instanceof Uint8ClampedArray;
}
}
@JsOverlay
default Crypto.GetRandomValuesUnionType getRandomValues(BigInt64Array typedArray){
return getRandomValues(Js.<Crypto.GetRandomValuesTypedArrayUnionType>uncheckedCast(typedArray));
}
@JsOverlay
default Crypto.GetRandomValuesUnionType getRandomValues(BigUint64Array typedArray){
return getRandomValues(Js.<Crypto.GetRandomValuesTypedArrayUnionType>uncheckedCast(typedArray));
}
Crypto.GetRandomValuesUnionType getRandomValues(Crypto.GetRandomValuesTypedArrayUnionType typedArray);
@JsOverlay
default Crypto.GetRandomValuesUnionType getRandomValues(Int16Array typedArray){
return getRandomValues(Js.<Crypto.GetRandomValuesTypedArrayUnionType>uncheckedCast(typedArray));
}
@JsOverlay
default Crypto.GetRandomValuesUnionType getRandomValues(Int32Array typedArray){
return getRandomValues(Js.<Crypto.GetRandomValuesTypedArrayUnionType>uncheckedCast(typedArray));
}
@JsOverlay
default Crypto.GetRandomValuesUnionType getRandomValues(Int8Array typedArray){
return getRandomValues(Js.<Crypto.GetRandomValuesTypedArrayUnionType>uncheckedCast(typedArray));
}
@JsOverlay
default Crypto.GetRandomValuesUnionType getRandomValues(Uint16Array typedArray){
return getRandomValues(Js.<Crypto.GetRandomValuesTypedArrayUnionType>uncheckedCast(typedArray));
}
@JsOverlay
default Crypto.GetRandomValuesUnionType getRandomValues(Uint32Array typedArray){
return getRandomValues(Js.<Crypto.GetRandomValuesTypedArrayUnionType>uncheckedCast(typedArray));
}
@JsOverlay
default Crypto.GetRandomValuesUnionType getRandomValues(Uint8Array typedArray){
return getRandomValues(Js.<Crypto.GetRandomValuesTypedArrayUnionType>uncheckedCast(typedArray));
}
@JsOverlay
default Crypto.GetRandomValuesUnionType getRandomValues(Uint8ClampedArray typedArray){
return getRandomValues(Js.<Crypto.GetRandomValuesTypedArrayUnionType>uncheckedCast(typedArray));
}
@JsProperty
SubtleCrypto getSubtle();
String randomUUID();
@JsProperty
void setSubtle(SubtleCrypto subtle);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package elemental2.webcrypto.webcrypto;
import elemental2.webcrypto.webcrypto.RsaOtherPrimesInfo;
import java.lang.String;
import jsinterop.annotations.JsType;
import jsinterop.annotations.JsPackage;
import elemental2.core.JsArray;
@JsType(isNative = true,name = "webCrypto.JsonWebKey",namespace = JsPackage.GLOBAL)
public class JsonWebKey{
public String alg;
public String crv;
public String d;
public String dp;
public String dq;
public String e;
public boolean ext;
public String k;
public JsArray<String> key_ops;
public String kty;
public String n;
public JsArray<RsaOtherPrimesInfo> oth;
public String p;
public String q;
public String qi;
public String use;
public String x;
public String y;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package elemental2.webcrypto.webcrypto;
import java.lang.String;
import jsinterop.annotations.JsType;
import jsinterop.annotations.JsPackage;
@JsType(isNative = true,name = "webCrypto.RsaOtherPrimesInfo",namespace = JsPackage.GLOBAL)
public class RsaOtherPrimesInfo{
public String d;
public String r;
public String t;
}
Loading

0 comments on commit 4671612

Please sign in to comment.