git.iko.soy/rowtype-yoga/purescript-yoga-subtlecrypto
on master help sign in
.gitignore+1
since splitsnapshots
unifiedsplit
@@ -7,3 +7,4 @@
7/.psc*
7/.psc*
8/.purs*
8/.purs*
9/.psa*
9/.psa*
10+/.spago/
LICENSE+1−1
@@ -1,4 +1,4 @@
1−Copyright 2017 Athan Clark
1+Copyright 2019, 2020 Athan Clark
2
2
3Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
3Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4
4
README.md+10−1
@@ -1,5 +1,14 @@
1−# purescript-subtlecrypto
1+# purescript-yoga-subtlecrypto
2
2
3Simple bindings to the Browser's `window.crypto.subtle` API thing.
3Simple bindings to the Browser's `window.crypto.subtle` API thing.
4
4
5*__Warning__*: This only works on specific browsers - not even node.js!
5*__Warning__*: This only works on specific browsers - not even node.js!
6+
7+## Provenance
8+
9+Forked from https://github.com/athanclark/purescript-subtlecrypto
10+
11+# State of affairs
12+In its current state, these modules compile with purs 0.15.5 and Registry 60.6.0.
13+
14+The tests can be built but the browser test fails.
bower.json+30−22
@@ -1,24 +1,32 @@
1{
1{
2− "name": "purescript-subtlecrypto",
2+ "name": "purescript-subtlecrypto",
3− "ignore": [
3+ "license": [
4− "**/.*",
5− "node_modules",
6− "bower_components",
7− "output"
8− ],
9− "license": "BSD-3-Clause",
4+ "BSD-3-Clause"
5+ ],
10− "repository": {
6+ "repository": {
11− "type": "git",
7+ "type": "git",
12− "url": "git://github.com/athanclark/purescript-subtlecrypto.git"
8+ "url": "https://github.com/rowtype-yoga/purescript-yoga-subtlecrypto.git"
13− },
9+ },
10+ "ignore": [
11+ "**/.*",
12+ "node_modules",
13+ "bower_components",
14+ "output"
15+ ],
14− "dependencies": {
16+ "dependencies": {
17+ "purescript-aff": "^v7.0.0",
15− "purescript-prelude": "^4.1.0",
18+ "purescript-aff-promise": "^v4.0.0",
16− "purescript-arraybuffer-types": "^2.0.0",
19+ "purescript-arraybuffer-types": "^v3.0.2",
20+ "purescript-console": "^v6.0.0",
21+ "purescript-effect": "^v4.0.0",
17− "purescript-aff": "^5.1.0",
22+ "purescript-either": "^v6.0.0",
18− "purescript-promises": "^3.0.0",
23+ "purescript-exceptions": "^v6.0.0",
19− "purescript-foreign": "^5.0.0"
24+ "purescript-foreign": "^v7.0.0",
20− },
25+ "purescript-functions": "^v6.0.0",
21− "devDependencies": {
26+ "purescript-maybe": "^v6.0.0",
22− "purescript-psci-support": "^4.0.0"
27+ "purescript-prelude": "^v6.0.0",
28+ "purescript-transformers": "^v6.0.0",
29+ "purescript-tuples": "^v7.0.0",
30+ "purescript-unsafe-coerce": "^v6.0.0"
23− }
31+ }
24}
32}
buildTests.shnew file+6
@@ -0,0 +1,6 @@
1+#!/bin/bash
2+
3+spago build
4+echo "Bundling..."
5+spago bundle --module Test.Main --outfile test.browser.js
6+echo "Bundled."
spago.locknew file+1173
@@ -0,0 +1,1173 @@
1+{
2+ "workspace": {
3+ "packages": {
4+ "subtlecrypto": {
5+ "path": "./",
6+ "core": {
7+ "dependencies": [
8+ "aff",
9+ "aff-promise",
10+ "arraybuffer-types",
11+ "console",
12+ "effect",
13+ "either",
14+ "exceptions",
15+ "foreign",
16+ "functions",
17+ "maybe",
18+ "prelude",
19+ "transformers",
20+ "tuples",
21+ "unsafe-coerce"
22+ ],
23+ "build_plan": [
24+ "aff",
25+ "aff-promise",
26+ "arraybuffer-types",
27+ "arrays",
28+ "bifunctors",
29+ "console",
30+ "const",
31+ "contravariant",
32+ "control",
33+ "datetime",
34+ "distributive",
35+ "effect",
36+ "either",
37+ "enums",
38+ "exceptions",
39+ "exists",
40+ "foldable-traversable",
41+ "foreign",
42+ "functions",
43+ "functors",
44+ "gen",
45+ "identity",
46+ "integers",
47+ "invariant",
48+ "lazy",
49+ "lists",
50+ "maybe",
51+ "newtype",
52+ "nonempty",
53+ "numbers",
54+ "ordered-collections",
55+ "orders",
56+ "parallel",
57+ "partial",
58+ "prelude",
59+ "profunctor",
60+ "refs",
61+ "safe-coerce",
62+ "st",
63+ "strings",
64+ "tailrec",
65+ "transformers",
66+ "tuples",
67+ "type-equality",
68+ "unfoldable",
69+ "unsafe-coerce"
70+ ]
71+ },
72+ "test": {
73+ "dependencies": [],
74+ "build_plan": []
75+ }
76+ }
77+ },
78+ "package_set": {
79+ "address": {
80+ "registry": "60.6.0"
81+ },
82+ "compiler": ">=0.15.15 <0.16.0",
83+ "content": {
84+ "abc-parser": "2.0.1",
85+ "ace": "9.1.0",
86+ "address-rfc2821": "0.1.1",
87+ "aff": "8.0.0",
88+ "aff-bus": "6.0.0",
89+ "aff-coroutines": "9.0.0",
90+ "aff-promise": "4.0.0",
91+ "aff-retry": "2.0.0",
92+ "affjax": "13.0.0",
93+ "affjax-node": "1.0.0",
94+ "affjax-web": "1.0.0",
95+ "ansi": "7.0.0",
96+ "apexcharts": "0.5.0",
97+ "applicative-phases": "1.0.0",
98+ "argonaut": "9.0.0",
99+ "argonaut-aeson-generic": "0.4.1",
100+ "argonaut-codecs": "9.1.0",
101+ "argonaut-core": "7.0.0",
102+ "argonaut-generic": "8.0.0",
103+ "argonaut-traversals": "10.0.0",
104+ "argparse-basic": "2.0.0",
105+ "array-builder": "0.1.2",
106+ "array-search": "0.6.0",
107+ "arraybuffer": "13.2.0",
108+ "arraybuffer-builder": "3.1.0",
109+ "arraybuffer-types": "3.0.2",
110+ "arrays": "7.3.0",
111+ "arrays-extra": "0.6.1",
112+ "arrays-zipper": "2.0.1",
113+ "ask": "1.0.0",
114+ "assert": "6.0.0",
115+ "assert-multiple": "0.4.0",
116+ "avar": "5.0.0",
117+ "b64": "0.0.8",
118+ "barbies": "1.0.1",
119+ "barlow-lens": "0.9.0",
120+ "bifunctors": "6.0.0",
121+ "bigints": "7.0.1",
122+ "bolson": "0.3.9",
123+ "bookhound": "0.1.7",
124+ "bower-json": "3.0.0",
125+ "call-by-name": "4.0.1",
126+ "canvas": "6.0.0",
127+ "canvas-action": "9.0.0",
128+ "cartesian": "1.0.6",
129+ "catenable-lists": "7.0.0",
130+ "cbor-stream": "1.3.0",
131+ "chameleon": "1.0.0",
132+ "chameleon-halogen": "1.0.3",
133+ "chameleon-react-basic": "1.1.0",
134+ "chameleon-styled": "2.5.0",
135+ "chameleon-transformers": "1.0.0",
136+ "channel": "1.0.0",
137+ "checked-exceptions": "3.1.1",
138+ "choku": "1.0.1",
139+ "classless": "0.1.1",
140+ "classless-arbitrary": "0.1.1",
141+ "classless-decode-json": "0.1.1",
142+ "classless-encode-json": "0.1.3",
143+ "classnames": "2.0.0",
144+ "codec": "6.1.0",
145+ "codec-argonaut": "10.0.0",
146+ "codec-json": "2.0.0",
147+ "colors": "7.0.1",
148+ "concur-core": "0.5.0",
149+ "concur-react": "0.5.0",
150+ "concurrent-queues": "3.0.0",
151+ "console": "6.1.0",
152+ "const": "6.0.0",
153+ "contravariant": "6.0.0",
154+ "control": "6.0.0",
155+ "convertable-options": "1.0.0",
156+ "coroutines": "7.0.0",
157+ "css": "6.0.0",
158+ "css-frameworks": "1.0.1",
159+ "csv-stream": "2.3.0",
160+ "data-mvc": "0.0.2",
161+ "datetime": "6.1.0",
162+ "datetime-parsing": "0.2.0",
163+ "debounce": "0.1.0",
164+ "debug": "6.0.2",
165+ "decimals": "7.1.0",
166+ "default-values": "1.0.1",
167+ "deku": "0.9.23",
168+ "deno": "0.0.5",
169+ "dissect": "1.0.0",
170+ "distributive": "6.0.0",
171+ "dom-filereader": "7.0.0",
172+ "dom-indexed": "12.0.0",
173+ "dom-simple": "0.4.0",
174+ "dotenv": "4.0.3",
175+ "droplet": "0.6.0",
176+ "dts": "1.0.0",
177+ "dual-numbers": "1.0.3",
178+ "dynamic-buffer": "3.0.1",
179+ "echarts-simple": "0.0.1",
180+ "effect": "4.0.0",
181+ "either": "6.1.0",
182+ "elmish": "0.13.0",
183+ "elmish-enzyme": "0.1.1",
184+ "elmish-hooks": "0.10.3",
185+ "elmish-html": "0.9.0",
186+ "elmish-testing-library": "0.3.2",
187+ "email-validate": "7.0.0",
188+ "encoding": "0.0.9",
189+ "enums": "6.0.1",
190+ "env-names": "0.4.0",
191+ "error": "2.0.0",
192+ "eta-conversion": "0.3.2",
193+ "exceptions": "6.1.0",
194+ "exists": "6.0.0",
195+ "exitcodes": "4.0.0",
196+ "expect-inferred": "3.0.0",
197+ "ezfetch": "1.0.0",
198+ "fahrtwind": "2.0.0",
199+ "fallback": "0.1.0",
200+ "fast-vect": "1.2.0",
201+ "fetch": "4.1.0",
202+ "fetch-argonaut": "1.0.1",
203+ "fetch-core": "5.1.0",
204+ "fetch-yoga-json": "1.1.0",
205+ "ffi-simple": "0.5.1",
206+ "fft-js": "0.1.0",
207+ "filterable": "5.0.0",
208+ "fix-functor": "0.1.0",
209+ "fixed-points": "7.0.0",
210+ "fixed-precision": "5.0.0",
211+ "flame": "1.3.0",
212+ "float32": "2.0.0",
213+ "fmt": "0.2.1",
214+ "foldable-traversable": "6.0.0",
215+ "foldable-traversable-extra": "0.0.6",
216+ "foreign": "7.0.0",
217+ "foreign-object": "4.1.0",
218+ "foreign-readwrite": "3.4.0",
219+ "forgetmenot": "0.1.0",
220+ "fork": "6.0.0",
221+ "form-urlencoded": "7.0.0",
222+ "formatters": "7.0.0",
223+ "framer-motion": "1.0.1",
224+ "free": "7.1.0",
225+ "freeap": "7.0.0",
226+ "freer-free": "0.0.1",
227+ "freet": "7.0.0",
228+ "functions": "6.0.0",
229+ "functor1": "3.0.0",
230+ "functors": "5.0.0",
231+ "fuzzy": "0.4.0",
232+ "gen": "4.0.0",
233+ "generate-values": "1.0.1",
234+ "generic-router": "0.0.1",
235+ "geojson": "0.0.5",
236+ "geometria": "2.2.0",
237+ "gojs": "0.1.1",
238+ "grain": "3.0.0",
239+ "grain-router": "3.0.0",
240+ "grain-virtualized": "3.0.0",
241+ "graphs": "8.1.0",
242+ "group": "4.1.1",
243+ "halogen": "7.0.0",
244+ "halogen-bootstrap5": "5.3.2",
245+ "halogen-canvas": "1.0.0",
246+ "halogen-css": "10.0.0",
247+ "halogen-echarts-simple": "0.0.4",
248+ "halogen-formless": "4.0.3",
249+ "halogen-helix": "1.0.1",
250+ "halogen-hooks": "0.6.3",
251+ "halogen-hooks-extra": "0.9.0",
252+ "halogen-infinite-scroll": "1.1.0",
253+ "halogen-store": "0.5.4",
254+ "halogen-storybook": "2.0.0",
255+ "halogen-subscriptions": "2.0.0",
256+ "halogen-svg-elems": "8.0.0",
257+ "halogen-typewriter": "1.0.4",
258+ "halogen-vdom": "8.0.0",
259+ "halogen-vdom-string-renderer": "0.5.0",
260+ "halogen-xterm": "2.0.0",
261+ "heckin": "2.0.1",
262+ "heterogeneous": "0.6.0",
263+ "homogeneous": "0.4.0",
264+ "http-methods": "6.0.0",
265+ "httpurple": "4.0.0",
266+ "huffman": "0.4.0",
267+ "humdrum": "0.0.1",
268+ "hyrule": "2.3.8",
269+ "identity": "6.0.0",
270+ "identy": "4.0.1",
271+ "indexed-db": "1.0.0",
272+ "indexed-monad": "3.0.0",
273+ "int64": "3.0.0",
274+ "integers": "6.0.0",
275+ "interpolate": "5.0.2",
276+ "intersection-observer": "1.0.1",
277+ "invariant": "6.0.0",
278+ "jarilo": "1.0.1",
279+ "jelly": "0.10.0",
280+ "jelly-router": "0.3.0",
281+ "jelly-signal": "0.4.0",
282+ "jest": "1.0.0",
283+ "js-abort-controller": "1.0.0",
284+ "js-bigints": "2.2.1",
285+ "js-date": "8.0.0",
286+ "js-fetch": "0.2.1",
287+ "js-fileio": "3.0.0",
288+ "js-intl": "1.0.4",
289+ "js-iterators": "0.1.1",
290+ "js-maps": "0.1.2",
291+ "js-promise": "1.0.0",
292+ "js-promise-aff": "1.0.0",
293+ "js-timers": "6.1.0",
294+ "js-uri": "3.1.0",
295+ "jsdom": "1.0.0",
296+ "json": "1.1.0",
297+ "json-codecs": "5.0.0",
298+ "justifill": "0.5.0",
299+ "jwt": "0.0.9",
300+ "labeled-data": "0.2.0",
301+ "language-cst-parser": "0.14.0",
302+ "lazy": "6.0.0",
303+ "lazy-joe": "1.0.0",
304+ "lcg": "4.0.0",
305+ "leibniz": "5.0.0",
306+ "leveldb": "1.0.1",
307+ "liminal": "1.0.1",
308+ "linalg": "6.0.0",
309+ "lists": "7.0.0",
310+ "literals": "1.0.2",
311+ "logging": "3.0.0",
312+ "logging-journald": "0.4.0",
313+ "lumi-components": "18.0.0",
314+ "machines": "7.0.0",
315+ "maps-eager": "0.5.0",
316+ "marionette": "1.0.0",
317+ "marionette-react-basic-hooks": "0.1.1",
318+ "marked": "0.1.0",
319+ "matrices": "5.0.1",
320+ "matryoshka": "1.0.0",
321+ "maybe": "6.0.0",
322+ "media-types": "6.0.0",
323+ "meowclient": "1.0.0",
324+ "midi": "4.0.0",
325+ "milkis": "9.0.0",
326+ "minibench": "4.0.1",
327+ "mmorph": "7.0.0",
328+ "monad-control": "5.0.0",
329+ "monad-logger": "1.3.1",
330+ "monad-loops": "0.5.0",
331+ "monad-unlift": "1.0.1",
332+ "monoid-extras": "0.0.1",
333+ "monoidal": "0.16.0",
334+ "morello": "0.4.0",
335+ "mote": "3.0.0",
336+ "motsunabe": "2.0.0",
337+ "mvc": "0.0.1",
338+ "mysql": "6.0.1",
339+ "n3": "0.1.0",
340+ "nano-id": "1.1.0",
341+ "nanoid": "0.1.0",
342+ "naturals": "3.0.0",
343+ "nested-functor": "0.2.1",
344+ "newtype": "5.0.0",
345+ "nextjs": "0.1.1",
346+ "nextui": "0.2.0",
347+ "node-buffer": "9.0.0",
348+ "node-child-process": "11.1.0",
349+ "node-event-emitter": "3.0.0",
350+ "node-execa": "5.0.0",
351+ "node-fs": "9.2.0",
352+ "node-glob-basic": "1.3.0",
353+ "node-http": "9.1.0",
354+ "node-http2": "1.1.1",
355+ "node-human-signals": "1.0.0",
356+ "node-net": "5.1.0",
357+ "node-os": "5.1.0",
358+ "node-path": "5.0.0",
359+ "node-process": "11.2.0",
360+ "node-readline": "8.1.1",
361+ "node-sqlite3": "8.0.0",
362+ "node-stream-pipes": "2.1.6",
363+ "node-streams": "9.0.0",
364+ "node-tls": "0.3.1",
365+ "node-url": "7.0.1",
366+ "node-zlib": "0.4.0",
367+ "nonempty": "7.0.0",
368+ "now": "6.0.0",
369+ "npm-package-json": "2.0.0",
370+ "nullable": "6.0.0",
371+ "numberfield": "0.2.2",
372+ "numbers": "9.0.1",
373+ "oak": "3.1.1",
374+ "oak-debug": "1.2.2",
375+ "object-maps": "0.3.0",
376+ "ocarina": "1.5.4",
377+ "oooooooooorrrrrrrmm-lib": "0.0.1",
378+ "open-colors-scales-and-schemes": "1.0.0",
379+ "open-folds": "6.4.0",
380+ "open-foreign-generic": "11.0.3",
381+ "open-memoize": "6.2.0",
382+ "open-mkdirp-aff": "1.2.0",
383+ "open-pairing": "6.2.0",
384+ "open-smolder": "12.0.2",
385+ "options": "7.0.0",
386+ "optparse": "5.0.1",
387+ "ordered-collections": "3.2.0",
388+ "ordered-set": "0.4.0",
389+ "orders": "6.0.0",
390+ "owoify": "1.2.0",
391+ "pairs": "9.0.1",
392+ "parallel": "7.0.0",
393+ "parsing": "10.2.0",
394+ "parsing-dataview": "3.2.4",
395+ "partial": "4.0.0",
396+ "pathy": "9.0.0",
397+ "pha": "0.13.0",
398+ "phaser": "0.7.0",
399+ "phylio": "1.1.2",
400+ "pipes": "8.0.0",
401+ "pirates-charm": "0.0.1",
402+ "pmock": "0.9.0",
403+ "point-free": "1.0.0",
404+ "pointed-list": "0.5.1",
405+ "polymorphic-vectors": "4.0.0",
406+ "posix-types": "6.0.0",
407+ "postgresql": "2.0.19",
408+ "precise": "6.0.0",
409+ "precise-datetime": "7.0.0",
410+ "prelude": "6.0.1",
411+ "prettier-printer": "3.0.0",
412+ "priority-queue": "0.1.2",
413+ "profunctor": "6.0.1",
414+ "profunctor-lenses": "8.0.0",
415+ "protobuf": "4.4.0",
416+ "psa-utils": "8.0.0",
417+ "psci-support": "6.0.0",
418+ "punycode": "1.0.0",
419+ "qualified-do": "2.2.0",
420+ "quantities": "12.2.0",
421+ "quickcheck": "8.0.1",
422+ "quickcheck-combinators": "0.1.3",
423+ "quickcheck-laws": "7.0.0",
424+ "quickcheck-utf8": "0.0.0",
425+ "random": "6.0.0",
426+ "rationals": "6.0.0",
427+ "rdf": "0.1.0",
428+ "react": "11.0.0",
429+ "react-aria": "0.2.0",
430+ "react-basic": "17.0.0",
431+ "react-basic-classic": "3.0.0",
432+ "react-basic-dnd": "10.1.0",
433+ "react-basic-dom": "6.1.0",
434+ "react-basic-dom-beta": "0.1.1",
435+ "react-basic-emotion": "7.1.0",
436+ "react-basic-hooks": "8.2.0",
437+ "react-basic-storybook": "2.0.0",
438+ "react-dom": "8.0.0",
439+ "react-halo": "3.0.0",
440+ "react-icons": "1.1.5",
441+ "react-markdown": "0.1.0",
442+ "react-testing-library": "4.0.1",
443+ "react-virtuoso": "1.0.0",
444+ "reactix": "0.6.1",
445+ "read": "1.0.1",
446+ "recharts": "1.1.0",
447+ "record": "4.0.0",
448+ "record-extra": "5.0.1",
449+ "record-ptional-fields": "0.1.2",
450+ "record-studio": "1.0.4",
451+ "refs": "6.0.0",
452+ "remotedata": "5.0.1",
453+ "repr": "0.5.0",
454+ "resize-observer": "1.0.0",
455+ "resource": "2.0.1",
456+ "resourcet": "1.0.0",
457+ "result": "1.0.3",
458+ "return": "0.2.0",
459+ "ring-modules": "5.0.1",
460+ "rito": "0.3.4",
461+ "roman": "0.4.0",
462+ "rough-notation": "1.0.2",
463+ "routing": "11.0.0",
464+ "routing-duplex": "0.7.0",
465+ "run": "5.0.0",
466+ "safe-coerce": "2.0.0",
467+ "safely": "4.0.1",
468+ "school-of-music": "1.3.0",
469+ "selection-foldable": "0.2.0",
470+ "selective-functors": "1.0.1",
471+ "semirings": "7.0.0",
472+ "signal": "13.0.0",
473+ "simple-emitter": "3.0.1",
474+ "simple-i18n": "2.0.1",
475+ "simple-json": "9.0.0",
476+ "simple-json-generics": "0.2.1",
477+ "simple-ulid": "3.0.0",
478+ "sized-matrices": "1.0.0",
479+ "sized-vectors": "5.0.2",
480+ "slug": "3.1.0",
481+ "small-ffi": "4.0.1",
482+ "soundfonts": "4.1.0",
483+ "sparse-matrices": "2.0.1",
484+ "sparse-polynomials": "3.0.1",
485+ "spec": "8.1.0",
486+ "spec-discovery": "8.4.0",
487+ "spec-mocha": "5.1.1",
488+ "spec-node": "0.0.3",
489+ "spec-quickcheck": "5.0.2",
490+ "spec-reporter-xunit": "0.7.1",
491+ "splitmix": "2.1.0",
492+ "ssrs": "1.0.0",
493+ "st": "6.2.0",
494+ "statistics": "0.3.2",
495+ "strictlypositiveint": "1.0.1",
496+ "string-parsers": "8.0.0",
497+ "strings": "6.0.1",
498+ "strings-extra": "4.0.0",
499+ "stringutils": "0.0.12",
500+ "substitute": "0.2.3",
501+ "supply": "0.2.0",
502+ "svg-parser": "3.0.0",
503+ "systemd-journald": "0.3.0",
504+ "tagged": "4.0.2",
505+ "tailrec": "6.1.0",
506+ "tecton": "0.2.1",
507+ "tecton-halogen": "0.2.0",
508+ "test-unit": "17.0.0",
509+ "thermite": "6.3.1",
510+ "thermite-dom": "0.3.1",
511+ "these": "6.0.0",
512+ "threading": "0.0.3",
513+ "tldr": "0.0.0",
514+ "toestand": "0.9.0",
515+ "transformation-matrix": "1.0.1",
516+ "transformers": "6.1.0",
517+ "tree-rose": "4.0.2",
518+ "ts-bridge": "4.0.0",
519+ "tuples": "7.0.0",
520+ "two-or-more": "1.0.0",
521+ "type-equality": "4.0.1",
522+ "typedenv": "2.0.1",
523+ "typelevel": "6.0.0",
524+ "typelevel-lists": "2.1.0",
525+ "typelevel-peano": "1.0.1",
526+ "typelevel-prelude": "7.0.0",
527+ "typelevel-regex": "0.0.3",
528+ "typelevel-rows": "0.1.0",
529+ "typisch": "0.4.0",
530+ "uint": "7.0.0",
531+ "ulid": "3.0.1",
532+ "uncurried-transformers": "1.1.0",
533+ "undefined": "2.0.0",
534+ "undefined-is-not-a-problem": "1.1.0",
535+ "unfoldable": "6.0.0",
536+ "unicode": "6.0.0",
537+ "unique": "0.6.1",
538+ "unlift": "1.0.1",
539+ "unordered-collections": "3.1.0",
540+ "unsafe-coerce": "6.0.0",
541+ "unsafe-reference": "5.0.0",
542+ "untagged-to-tagged": "0.1.4",
543+ "untagged-union": "1.0.0",
544+ "uri": "9.0.0",
545+ "url-immutable": "1.0.0",
546+ "uuid": "9.0.0",
547+ "uuidv4": "1.0.0",
548+ "validation": "6.0.0",
549+ "variant": "8.0.0",
550+ "variant-encodings": "2.0.0",
551+ "vectorfield": "1.0.1",
552+ "vectors": "2.1.0",
553+ "versions": "7.0.0",
554+ "visx": "0.0.2",
555+ "web-clipboard": "6.0.0",
556+ "web-cssom": "2.0.0",
557+ "web-cssom-view": "0.1.0",
558+ "web-dom": "6.0.0",
559+ "web-dom-parser": "8.0.0",
560+ "web-dom-xpath": "3.0.0",
561+ "web-encoding": "3.0.0",
562+ "web-events": "4.0.0",
563+ "web-fetch": "4.0.1",
564+ "web-file": "4.0.0",
565+ "web-geometry": "0.1.0",
566+ "web-html": "4.1.0",
567+ "web-pointerevents": "2.0.0",
568+ "web-proletarian": "1.0.0",
569+ "web-promise": "3.2.0",
570+ "web-resize-observer": "2.1.0",
571+ "web-router": "1.0.0",
572+ "web-socket": "4.0.0",
573+ "web-storage": "5.0.0",
574+ "web-streams": "4.0.0",
575+ "web-touchevents": "4.0.0",
576+ "web-uievents": "5.0.0",
577+ "web-url": "2.0.0",
578+ "web-workers": "1.1.0",
579+ "web-xhr": "5.0.1",
580+ "webextension-polyfill": "0.1.0",
581+ "webgpu": "0.0.1",
582+ "which": "2.0.0",
583+ "xterm": "1.0.0",
584+ "yoga-fetch": "1.0.1",
585+ "yoga-json": "5.1.0",
586+ "yoga-om": "0.1.0",
587+ "yoga-postgres": "6.0.0",
588+ "yoga-tree": "1.0.0",
589+ "z3": "0.0.2",
590+ "zipperarray": "2.0.0"
591+ }
592+ },
593+ "extra_packages": {}
594+ },
595+ "packages": {
596+ "aff": {
597+ "type": "registry",
598+ "version": "8.0.0",
599+ "integrity": "sha256-5MmdI4+0RHBtSBy+YlU3/Cq4R5W2ih3OaRedJIrVHdk=",
600+ "dependencies": [
601+ "bifunctors",
602+ "control",
603+ "datetime",
604+ "effect",
605+ "either",
606+ "exceptions",
607+ "foldable-traversable",
608+ "functions",
609+ "maybe",
610+ "newtype",
611+ "parallel",
612+ "prelude",
613+ "refs",
614+ "tailrec",
615+ "transformers",
616+ "unsafe-coerce"
617+ ]
618+ },
619+ "aff-promise": {
620+ "type": "registry",
621+ "version": "4.0.0",
622+ "integrity": "sha256-Kq5EupbUpXeUXx4JqGQE7/RTTz/H6idzWhsocwlEFhM=",
623+ "dependencies": [
624+ "aff",
625+ "foreign"
626+ ]
627+ },
628+ "arraybuffer-types": {
629+ "type": "registry",
630+ "version": "3.0.2",
631+ "integrity": "sha256-mQKokysYVkooS4uXbO+yovmV/s8b138Ws3zQvOwIHRA=",
632+ "dependencies": []
633+ },
634+ "arrays": {
635+ "type": "registry",
636+ "version": "7.3.0",
637+ "integrity": "sha256-tmcklBlc/muUtUfr9RapdCPwnlQeB3aSrC4dK85gQlc=",
638+ "dependencies": [
639+ "bifunctors",
640+ "control",
641+ "foldable-traversable",
642+ "functions",
643+ "maybe",
644+ "nonempty",
645+ "partial",
646+ "prelude",
647+ "safe-coerce",
648+ "st",
649+ "tailrec",
650+ "tuples",
651+ "unfoldable",
652+ "unsafe-coerce"
653+ ]
654+ },
655+ "bifunctors": {
656+ "type": "registry",
657+ "version": "6.0.0",
658+ "integrity": "sha256-/gZwC9YhNxZNQpnHa5BIYerCGM2jeX9ukZiEvYxm5Nw=",
659+ "dependencies": [
660+ "const",
661+ "either",
662+ "newtype",
663+ "prelude",
664+ "tuples"
665+ ]
666+ },
667+ "console": {
668+ "type": "registry",
669+ "version": "6.1.0",
670+ "integrity": "sha256-CxmAzjgyuGDmt9FZW51VhV6rBPwR6o0YeKUzA9rSzcM=",
671+ "dependencies": [
672+ "effect",
673+ "prelude"
674+ ]
675+ },
676+ "const": {
677+ "type": "registry",
678+ "version": "6.0.0",
679+ "integrity": "sha256-tNrxDW8D8H4jdHE2HiPzpLy08zkzJMmGHdRqt5BQuTc=",
680+ "dependencies": [
681+ "invariant",
682+ "newtype",
683+ "prelude"
684+ ]
685+ },
686+ "contravariant": {
687+ "type": "registry",
688+ "version": "6.0.0",
689+ "integrity": "sha256-TP+ooAp3vvmdjfQsQJSichF5B4BPDHp3wAJoWchip6c=",
690+ "dependencies": [
691+ "const",
692+ "either",
693+ "newtype",
694+ "prelude",
695+ "tuples"
696+ ]
697+ },
698+ "control": {
699+ "type": "registry",
700+ "version": "6.0.0",
701+ "integrity": "sha256-sH7Pg9E96JCPF9PIA6oQ8+BjTyO/BH1ZuE/bOcyj4Jk=",
702+ "dependencies": [
703+ "newtype",
704+ "prelude"
705+ ]
706+ },
707+ "datetime": {
708+ "type": "registry",
709+ "version": "6.1.0",
710+ "integrity": "sha256-g/5X5BBegQWLpI9IWD+sY6mcaYpzzlW5lz5NBzaMtyI=",
711+ "dependencies": [
712+ "bifunctors",
713+ "control",
714+ "either",
715+ "enums",
716+ "foldable-traversable",
717+ "functions",
718+ "gen",
719+ "integers",
720+ "lists",
721+ "maybe",
722+ "newtype",
723+ "numbers",
724+ "ordered-collections",
725+ "partial",
726+ "prelude",
727+ "tuples"
728+ ]
729+ },
730+ "distributive": {
731+ "type": "registry",
732+ "version": "6.0.0",
733+ "integrity": "sha256-HTDdmEnzigMl+02SJB88j+gAXDx9VKsbvR4MJGDPbOQ=",
734+ "dependencies": [
735+ "identity",
736+ "newtype",
737+ "prelude",
738+ "tuples",
739+ "type-equality"
740+ ]
741+ },
742+ "effect": {
743+ "type": "registry",
744+ "version": "4.0.0",
745+ "integrity": "sha256-eBtZu+HZcMa5HilvI6kaDyVX3ji8p0W9MGKy2K4T6+M=",
746+ "dependencies": [
747+ "prelude"
748+ ]
749+ },
750+ "either": {
751+ "type": "registry",
752+ "version": "6.1.0",
753+ "integrity": "sha256-6hgTPisnMWVwQivOu2PKYcH8uqjEOOqDyaDQVUchTpY=",
754+ "dependencies": [
755+ "control",
756+ "invariant",
757+ "maybe",
758+ "prelude"
759+ ]
760+ },
761+ "enums": {
762+ "type": "registry",
763+ "version": "6.0.1",
764+ "integrity": "sha256-HWaD73JFLorc4A6trKIRUeDMdzE+GpkJaEOM1nTNkC8=",
765+ "dependencies": [
766+ "control",
767+ "either",
768+ "gen",
769+ "maybe",
770+ "newtype",
771+ "nonempty",
772+ "partial",
773+ "prelude",
774+ "tuples",
775+ "unfoldable"
776+ ]
777+ },
778+ "exceptions": {
779+ "type": "registry",
780+ "version": "6.1.0",
781+ "integrity": "sha256-K0T89IHtF3vBY7eSAO7eDOqSb2J9kZGAcDN5+IKsF8E=",
782+ "dependencies": [
783+ "effect",
784+ "either",
785+ "maybe",
786+ "prelude"
787+ ]
788+ },
789+ "exists": {
790+ "type": "registry",
791+ "version": "6.0.0",
792+ "integrity": "sha256-A0JQHpTfo1dNOj9U5/Fd3xndlRSE0g2IQWOGor2yXn8=",
793+ "dependencies": [
794+ "unsafe-coerce"
795+ ]
796+ },
797+ "foldable-traversable": {
798+ "type": "registry",
799+ "version": "6.0.0",
800+ "integrity": "sha256-fLeqRYM4jUrZD5H4WqcwUgzU7XfYkzO4zhgtNc3jcWM=",
801+ "dependencies": [
802+ "bifunctors",
803+ "const",
804+ "control",
805+ "either",
806+ "functors",
807+ "identity",
808+ "maybe",
809+ "newtype",
810+ "orders",
811+ "prelude",
812+ "tuples"
813+ ]
814+ },
815+ "foreign": {
816+ "type": "registry",
817+ "version": "7.0.0",
818+ "integrity": "sha256-1ORiqoS3HW+qfwSZAppHPWy4/6AQysxZ2t29jcdUMNA=",
819+ "dependencies": [
820+ "either",
821+ "functions",
822+ "identity",
823+ "integers",
824+ "lists",
825+ "maybe",
826+ "prelude",
827+ "strings",
828+ "transformers"
829+ ]
830+ },
831+ "functions": {
832+ "type": "registry",
833+ "version": "6.0.0",
834+ "integrity": "sha256-adMyJNEnhGde2unHHAP79gPtlNjNqzgLB8arEOn9hLI=",
835+ "dependencies": [
836+ "prelude"
837+ ]
838+ },
839+ "functors": {
840+ "type": "registry",
841+ "version": "5.0.0",
842+ "integrity": "sha256-zfPWWYisbD84MqwpJSZFlvM6v86McM68ob8p9s27ywU=",
843+ "dependencies": [
844+ "bifunctors",
845+ "const",
846+ "contravariant",
847+ "control",
848+ "distributive",
849+ "either",
850+ "invariant",
851+ "maybe",
852+ "newtype",
853+ "prelude",
854+ "profunctor",
855+ "tuples",
856+ "unsafe-coerce"
857+ ]
858+ },
859+ "gen": {
860+ "type": "registry",
861+ "version": "4.0.0",
862+ "integrity": "sha256-f7yzAXWwr+xnaqEOcvyO3ezKdoes8+WXWdXIHDBCAPI=",
863+ "dependencies": [
864+ "either",
865+ "foldable-traversable",
866+ "identity",
867+ "maybe",
868+ "newtype",
869+ "nonempty",
870+ "prelude",
871+ "tailrec",
872+ "tuples",
873+ "unfoldable"
874+ ]
875+ },
876+ "identity": {
877+ "type": "registry",
878+ "version": "6.0.0",
879+ "integrity": "sha256-4wY0XZbAksjY6UAg99WkuKyJlQlWAfTi2ssadH0wVMY=",
880+ "dependencies": [
881+ "control",
882+ "invariant",
883+ "newtype",
884+ "prelude"
885+ ]
886+ },
887+ "integers": {
888+ "type": "registry",
889+ "version": "6.0.0",
890+ "integrity": "sha256-sf+sK26R1hzwl3NhXR7WAu9zCDjQnfoXwcyGoseX158=",
891+ "dependencies": [
892+ "maybe",
893+ "numbers",
894+ "prelude"
895+ ]
896+ },
897+ "invariant": {
898+ "type": "registry",
899+ "version": "6.0.0",
900+ "integrity": "sha256-RGWWyYrz0Hs1KjPDA+87Kia67ZFBhfJ5lMGOMCEFoLo=",
901+ "dependencies": [
902+ "control",
903+ "prelude"
904+ ]
905+ },
906+ "lazy": {
907+ "type": "registry",
908+ "version": "6.0.0",
909+ "integrity": "sha256-lMsfFOnlqfe4KzRRiW8ot5ge6HtcU3Eyh2XkXcP5IgU=",
910+ "dependencies": [
911+ "control",
912+ "foldable-traversable",
913+ "invariant",
914+ "prelude"
915+ ]
916+ },
917+ "lists": {
918+ "type": "registry",
919+ "version": "7.0.0",
920+ "integrity": "sha256-EKF15qYqucuXP2lT/xPxhqy58f0FFT6KHdIB/yBOayI=",
921+ "dependencies": [
922+ "bifunctors",
923+ "control",
924+ "foldable-traversable",
925+ "lazy",
926+ "maybe",
927+ "newtype",
928+ "nonempty",
929+ "partial",
930+ "prelude",
931+ "tailrec",
932+ "tuples",
933+ "unfoldable"
934+ ]
935+ },
936+ "maybe": {
937+ "type": "registry",
938+ "version": "6.0.0",
939+ "integrity": "sha256-5cCIb0wPwbat2PRkQhUeZO0jcAmf8jCt2qE0wbC3v2Q=",
940+ "dependencies": [
941+ "control",
942+ "invariant",
943+ "newtype",
944+ "prelude"
945+ ]
946+ },
947+ "newtype": {
948+ "type": "registry",
949+ "version": "5.0.0",
950+ "integrity": "sha256-gdrQu8oGe9eZE6L3wOI8ql/igOg+zEGB5ITh2g+uttw=",
951+ "dependencies": [
952+ "prelude",
953+ "safe-coerce"
954+ ]
955+ },
956+ "nonempty": {
957+ "type": "registry",
958+ "version": "7.0.0",
959+ "integrity": "sha256-54ablJZUHGvvlTJzi3oXyPCuvY6zsrWJuH/dMJ/MFLs=",
960+ "dependencies": [
961+ "control",
962+ "foldable-traversable",
963+ "maybe",
964+ "prelude",
965+ "tuples",
966+ "unfoldable"
967+ ]
968+ },
969+ "numbers": {
970+ "type": "registry",
971+ "version": "9.0.1",
972+ "integrity": "sha256-/9M6aeMDBdB4cwYDeJvLFprAHZ49EbtKQLIJsneXLIk=",
973+ "dependencies": [
974+ "functions",
975+ "maybe"
976+ ]
977+ },
978+ "ordered-collections": {
979+ "type": "registry",
980+ "version": "3.2.0",
981+ "integrity": "sha256-o9jqsj5rpJmMdoe/zyufWHFjYYFTTsJpgcuCnqCO6PM=",
982+ "dependencies": [
983+ "arrays",
984+ "foldable-traversable",
985+ "gen",
986+ "lists",
987+ "maybe",
988+ "partial",
989+ "prelude",
990+ "st",
991+ "tailrec",
992+ "tuples",
993+ "unfoldable"
994+ ]
995+ },
996+ "orders": {
997+ "type": "registry",
998+ "version": "6.0.0",
999+ "integrity": "sha256-nBA0g3/ai0euH8q9pSbGqk53W2q6agm/dECZTHcoink=",
1000+ "dependencies": [
1001+ "newtype",
1002+ "prelude"
1003+ ]
1004+ },
1005+ "parallel": {
1006+ "type": "registry",
1007+ "version": "7.0.0",
1008+ "integrity": "sha256-gUC9i4Txnx9K9RcMLsjujbwZz6BB1bnE2MLvw4GIw5o=",
1009+ "dependencies": [
1010+ "control",
1011+ "effect",
1012+ "either",
1013+ "foldable-traversable",
1014+ "functors",
1015+ "maybe",
1016+ "newtype",
1017+ "prelude",
1018+ "profunctor",
1019+ "refs",
1020+ "transformers"
1021+ ]
1022+ },
1023+ "partial": {
1024+ "type": "registry",
1025+ "version": "4.0.0",
1026+ "integrity": "sha256-fwXerld6Xw1VkReh8yeQsdtLVrjfGiVuC5bA1Wyo/J4=",
1027+ "dependencies": []
1028+ },
1029+ "prelude": {
1030+ "type": "registry",
1031+ "version": "6.0.1",
1032+ "integrity": "sha256-o8p6SLYmVPqzXZhQFd2hGAWEwBoXl1swxLG/scpJ0V0=",
1033+ "dependencies": []
1034+ },
1035+ "profunctor": {
1036+ "type": "registry",
1037+ "version": "6.0.1",
1038+ "integrity": "sha256-E58hSYdJvF2Qjf9dnWLPlJKh2Z2fLfFLkQoYi16vsFk=",
1039+ "dependencies": [
1040+ "control",
1041+ "distributive",
1042+ "either",
1043+ "exists",
1044+ "invariant",
1045+ "newtype",
1046+ "prelude",
1047+ "tuples"
1048+ ]
1049+ },
1050+ "refs": {
1051+ "type": "registry",
1052+ "version": "6.0.0",
1053+ "integrity": "sha256-Vgwne7jIbD3ZMoLNNETLT8Litw6lIYo3MfYNdtYWj9s=",
1054+ "dependencies": [
1055+ "effect",
1056+ "prelude"
1057+ ]
1058+ },
1059+ "safe-coerce": {
1060+ "type": "registry",
1061+ "version": "2.0.0",
1062+ "integrity": "sha256-a1ibQkiUcbODbLE/WAq7Ttbbh9ex+x33VCQ7GngKudU=",
1063+ "dependencies": [
1064+ "unsafe-coerce"
1065+ ]
1066+ },
1067+ "st": {
1068+ "type": "registry",
1069+ "version": "6.2.0",
1070+ "integrity": "sha256-z9X0WsOUlPwNx9GlCC+YccCyz8MejC8Wb0C4+9fiBRY=",
1071+ "dependencies": [
1072+ "partial",
1073+ "prelude",
1074+ "tailrec",
1075+ "unsafe-coerce"
1076+ ]
1077+ },
1078+ "strings": {
1079+ "type": "registry",
1080+ "version": "6.0.1",
1081+ "integrity": "sha256-WssD3DbX4OPzxSdjvRMX0yvc9+pS7n5gyPv5I2Trb7k=",
1082+ "dependencies": [
1083+ "arrays",
1084+ "control",
1085+ "either",
1086+ "enums",
1087+ "foldable-traversable",
1088+ "gen",
1089+ "integers",
1090+ "maybe",
1091+ "newtype",
1092+ "nonempty",
1093+ "partial",
1094+ "prelude",
1095+ "tailrec",
1096+ "tuples",
1097+ "unfoldable",
1098+ "unsafe-coerce"
1099+ ]
1100+ },
1101+ "tailrec": {
1102+ "type": "registry",
1103+ "version": "6.1.0",
1104+ "integrity": "sha256-Xx19ECVDRrDWpz9D2GxQHHV89vd61dnXxQm0IcYQHGk=",
1105+ "dependencies": [
1106+ "bifunctors",
1107+ "effect",
1108+ "either",
1109+ "identity",
1110+ "maybe",
1111+ "partial",
1112+ "prelude",
1113+ "refs"
1114+ ]
1115+ },
1116+ "transformers": {
1117+ "type": "registry",
1118+ "version": "6.1.0",
1119+ "integrity": "sha256-3Bm+Z6tsC/paG888XkywDngJ2JMos+JfOhRlkVfb7gI=",
1120+ "dependencies": [
1121+ "control",
1122+ "distributive",
1123+ "effect",
1124+ "either",
1125+ "exceptions",
1126+ "foldable-traversable",
1127+ "identity",
1128+ "lazy",
1129+ "maybe",
1130+ "newtype",
1131+ "prelude",
1132+ "st",
1133+ "tailrec",
1134+ "tuples",
1135+ "unfoldable"
1136+ ]
1137+ },
1138+ "tuples": {
1139+ "type": "registry",
1140+ "version": "7.0.0",
1141+ "integrity": "sha256-1rXgTomes9105BjgXqIw0FL6Fz1lqqUTLWOumhWec1M=",
1142+ "dependencies": [
1143+ "control",
1144+ "invariant",
1145+ "prelude"
1146+ ]
1147+ },
1148+ "type-equality": {
1149+ "type": "registry",
1150+ "version": "4.0.1",
1151+ "integrity": "sha256-Hs9D6Y71zFi/b+qu5NSbuadUQXe5iv5iWx0226vOHUw=",
1152+ "dependencies": []
1153+ },
1154+ "unfoldable": {
1155+ "type": "registry",
1156+ "version": "6.0.0",
1157+ "integrity": "sha256-JtikvJdktRap7vr/K4ITlxUX1QexpnqBq0G/InLr6eg=",
1158+ "dependencies": [
1159+ "foldable-traversable",
1160+ "maybe",
1161+ "partial",
1162+ "prelude",
1163+ "tuples"
1164+ ]
1165+ },
1166+ "unsafe-coerce": {
1167+ "type": "registry",
1168+ "version": "6.0.0",
1169+ "integrity": "sha256-IqIYW4Vkevn8sI+6aUwRGvd87tVL36BBeOr0cGAE7t0=",
1170+ "dependencies": []
1171+ }
1172+ }
1173+}
spago.yamlnew file+21
@@ -0,0 +1,21 @@
1+package:
2+ dependencies:
3+ - aff
4+ - aff-promise
5+ - arraybuffer-types
6+ - console
7+ - effect
8+ - either
9+ - exceptions
10+ - foreign
11+ - functions
12+ - maybe
13+ - prelude
14+ - transformers
15+ - tuples
16+ - unsafe-coerce
17+ name: subtlecrypto
18+workspace:
19+ extra_packages: {}
20+ package_set:
21+ registry: 60.6.0
src/Crypto/Subtle.pursdeleted−2
@@ -1,2 +0,0 @@
1−module Crypto.Subtle where
2−
src/Crypto/Subtle/AES.pursdeleted−16
@@ -1,16 +0,0 @@
1−module Crypto.Subtle.AES
2− ( AESAlgorithm, aesCTR, aesCBC, aesGCM, aesKW
3− ) where
4−
5−
6−
7−newtype AESAlgorithm = AESAlgorithm String
8−
9−aesCTR :: AESAlgorithm
10−aesCTR = AESAlgorithm "AES-CTR"
11−aesCBC :: AESAlgorithm
12−aesCBC = AESAlgorithm "ES-CBC"
13−aesGCM :: AESAlgorithm
14−aesGCM = AESAlgorithm "AES-GCM"
15−aesKW :: AESAlgorithm
16−aesKW = AESAlgorithm "ES-KW"
src/Crypto/Subtle/Constants/AES.pursnew file+55
@@ -0,0 +1,55 @@
1+module Crypto.Subtle.Constants.AES
2+ ( AESAlgorithm, aesCTR, aesCBC, aesGCM, aesKW
3+ , AESBitLength, l128, l192, l256
4+ , AESTagLength, t32, t64, t96, t104, t112, t120, t128
5+ ) where
6+
7+import Prelude (class Eq)
8+
9+
10+newtype AESAlgorithm = AESAlgorithm String
11+
12+derive newtype instance eqAESAlgorithm :: Eq AESAlgorithm
13+
14+aesCTR :: AESAlgorithm
15+aesCTR = AESAlgorithm "AES-CTR"
16+aesCBC :: AESAlgorithm
17+aesCBC = AESAlgorithm "AES-CBC"
18+aesGCM :: AESAlgorithm
19+aesGCM = AESAlgorithm "AES-GCM"
20+aesKW :: AESAlgorithm
21+aesKW = AESAlgorithm "AES-KW"
22+
23+
24+
25+newtype AESBitLength = AESBitLength Int
26+
27+derive newtype instance eqAESBitLength :: Eq AESBitLength
28+
29+l128 :: AESBitLength
30+l128 = AESBitLength 128
31+l192 :: AESBitLength
32+l192 = AESBitLength 192
33+l256 :: AESBitLength
34+l256 = AESBitLength 256
35+
36+
37+
38+newtype AESTagLength = AESTagLength Int
39+
40+derive newtype instance eqAESTagLength :: Eq AESTagLength
41+
42+t32 :: AESTagLength
43+t32 = AESTagLength 32
44+t64 :: AESTagLength
45+t64 = AESTagLength 64
46+t96 :: AESTagLength
47+t96 = AESTagLength 96
48+t104 :: AESTagLength
49+t104 = AESTagLength 104
50+t112 :: AESTagLength
51+t112 = AESTagLength 112
52+t120 :: AESTagLength
53+t120 = AESTagLength 120
54+t128 :: AESTagLength
55+t128 = AESTagLength 128
src/Crypto/Subtle/EC.purs → src/Crypto/Subtle/Constants/EC.pursrenamed+6−1
@@ -1,12 +1,15 @@
1−module Crypto.Subtle.EC
1+module Crypto.Subtle.Constants.EC
2 ( ECAlgorithm, ecdsa, ecdh
2 ( ECAlgorithm, ecdsa, ecdh
3 , ECCurve, p256, p384, p521
3 , ECCurve, p256, p384, p521
4 ) where
4 ) where
5
5
6+import Prelude (class Eq)
6
7
7
8
8newtype ECAlgorithm = ECAlgorithm String
9newtype ECAlgorithm = ECAlgorithm String
9
10
11+derive newtype instance eqECAlgorithm :: Eq ECAlgorithm
12+
10ecdsa :: ECAlgorithm
13ecdsa :: ECAlgorithm
11ecdsa = ECAlgorithm "ECDSA"
14ecdsa = ECAlgorithm "ECDSA"
12ecdh :: ECAlgorithm
15ecdh :: ECAlgorithm
@@ -16,6 +19,8 @@ ecdh = ECAlgorithm "ECDH"
16
19
17newtype ECCurve = ECCurve String
20newtype ECCurve = ECCurve String
18
21
22+derive newtype instance eqECCurve :: Eq ECCurve
23+
19p256 :: ECCurve
24p256 :: ECCurve
20p256 = ECCurve "P-256"
25p256 = ECCurve "P-256"
21p384 :: ECCurve
26p384 :: ECCurve
src/Crypto/Subtle/RSA.purs → src/Crypto/Subtle/Constants/RSA.pursrenamed+4−2
@@ -1,11 +1,13 @@
1−module Crypto.Subtle.RSA
1+module Crypto.Subtle.Constants.RSA
2 ( RSAAlgorithm, rsaPKCS1, rsaPSS, rsaOAEP
2 ( RSAAlgorithm, rsaPKCS1, rsaPSS, rsaOAEP
3 ) where
3 ) where
4
4
5−
5+import Prelude (class Eq)
6
6
7newtype RSAAlgorithm = RSAAlgorithm String
7newtype RSAAlgorithm = RSAAlgorithm String
8
8
9+derive newtype instance eqRSAAlgorithm :: Eq RSAAlgorithm
10+
9rsaPKCS1 :: RSAAlgorithm
11rsaPKCS1 :: RSAAlgorithm
10rsaPKCS1 = RSAAlgorithm "RSASSA-PKCS1-v1_5"
12rsaPKCS1 = RSAAlgorithm "RSASSA-PKCS1-v1_5"
11rsaPSS :: RSAAlgorithm
13rsaPSS :: RSAAlgorithm
src/Crypto/Subtle/Encrypt.jsnew file+6
@@ -0,0 +1,6 @@
1+export function encryptImpl (a,k,x) {
2+ return crypto.subtle.encrypt(a,k,x);
3+};
4+export function decryptImpl (a,k,x) {
5+ return crypto.subtle.decrypt(a,k,x);
6+};
src/Crypto/Subtle/Encrypt.pursnew file+73
@@ -0,0 +1,73 @@
1+module Crypto.Subtle.Encrypt
2+ ( encrypt, decrypt
3+ , EncryptAlgorithm, rsaOAEP, aesCTR, aesCBC, aesGCM, aesKW
4+ ) where
5+
6+import Control.Promise (Promise, toAff')
7+import Crypto.Subtle.Constants.AES (AESTagLength)
8+import Crypto.Subtle.Key.Types (CryptoKey, errorFromDOMException)
9+import Data.ArrayBuffer.Types (ArrayBuffer)
10+import Data.Function.Uncurried (Fn3, runFn3)
11+import Data.Maybe (Maybe(..))
12+import Data.Tuple (Tuple(..))
13+import Effect.Aff (Aff)
14+import Unsafe.Coerce (unsafeCoerce)
15+
16+
17+
18+foreign import data EncryptAlgorithm :: Type
19+
20+-- | https://developer.mozilla.org/en-US/docs/Web/API/RsaOaepParams
21+rsaOAEP :: Maybe ArrayBuffer -- ^ Label
22+ -> EncryptAlgorithm
23+rsaOAEP mL = case mL of
24+ Nothing -> unsafeCoerce {name: "RSA_OAEP"}
25+ Just l -> unsafeCoerce {name: "RSA_OAEP", label: l}
26+
27+-- | https://developer.mozilla.org/en-US/docs/Web/API/AesCtrParams
28+aesCTR :: ArrayBuffer -- ^ Counter
29+ -> Int -- ^ Counter length
30+ -> EncryptAlgorithm
31+aesCTR c l = unsafeCoerce {name: "AES-CTR", counter: c, length: l}
32+
33+-- | https://developer.mozilla.org/en-US/docs/Web/API/AesCbcParams
34+aesCBC :: ArrayBuffer -- ^ Initialization vector
35+ -> EncryptAlgorithm
36+aesCBC i = unsafeCoerce {name: "AES-CBC", iv: i}
37+
38+-- | https://developer.mozilla.org/en-US/docs/Web/API/AesGcmParams
39+aesGCM :: ArrayBuffer -- ^ Initialization vector
40+ -> Maybe ArrayBuffer -- ^ Additional data
41+ -> Maybe AESTagLength -- ^ Tag length
42+ -> EncryptAlgorithm
43+aesGCM i mD mT = case Tuple mD mT of
44+ Tuple Nothing Nothing -> unsafeCoerce {name: "AES-GCM", iv: i}
45+ Tuple (Just d) (Just t) -> unsafeCoerce {name: "AES-GCM", iv: i, additionalData: d, tagLength: t}
46+ Tuple (Just d) Nothing -> unsafeCoerce {name: "AES-GCM", iv: i, additionalData: d}
47+ Tuple Nothing (Just t) -> unsafeCoerce {name: "AES-GCM", iv: i, tagLength: t}
48+
49+aesKW :: EncryptAlgorithm
50+aesKW = unsafeCoerce {name: "AES-KW"}
51+
52+
53+
54+
55+foreign import encryptImpl :: Fn3 EncryptAlgorithm CryptoKey ArrayBuffer (Promise ArrayBuffer)
56+
57+-- | https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/encrypt
58+encrypt :: EncryptAlgorithm
59+ -> CryptoKey
60+ -> ArrayBuffer
61+ -> Aff ArrayBuffer
62+encrypt a k x = toAff' errorFromDOMException (runFn3 encryptImpl a k x)
63+
64+
65+
66+foreign import decryptImpl :: Fn3 EncryptAlgorithm CryptoKey ArrayBuffer (Promise ArrayBuffer)
67+
68+-- | https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/decrypt
69+decrypt :: EncryptAlgorithm
70+ -> CryptoKey
71+ -> ArrayBuffer
72+ -> Aff ArrayBuffer
73+decrypt a k x = toAff' errorFromDOMException (runFn3 decryptImpl a k x)
src/Crypto/Subtle/Hash.js+3−3
@@ -1,3 +1,3 @@
1−"use strict";
1+export function digestImpl (h,x) {
2−
3−exports.digestImpl = crypto.subtle.digest;
2+ return crypto.subtle.digest(h,x);
3+};
src/Crypto/Subtle/Hash.purs+8−9
@@ -1,16 +1,18 @@
1module Crypto.Subtle.Hash (HashingFunction, sha1, sha256, sha384, sha512, digest) where
1module Crypto.Subtle.Hash (HashingFunction, sha1, sha256, sha384, sha512, digest) where
2
2
3−import Prelude ((<<<), (<$))
3+import Control.Promise (Promise, toAff')
4+import Crypto.Subtle.Key.Types (errorFromDOMException)
4import Data.ArrayBuffer.Types (ArrayBuffer)
5import Data.ArrayBuffer.Types (ArrayBuffer)
5import Data.Function.Uncurried (Fn2, runFn2)
6import Data.Function.Uncurried (Fn2, runFn2)
6−import Data.Either (Either (..))
7+import Effect.Aff (Aff)
7−import Effect.Promise (Promise, runPromise)
8+import Prelude (class Eq)
8−import Effect.Aff (Aff, makeAff, nonCanceler)
9
9
10
10
11
11
12newtype HashingFunction = HashingFunction String
12newtype HashingFunction = HashingFunction String
13
13
14+derive newtype instance eqHashingFunction :: Eq HashingFunction
15+
14sha1 :: HashingFunction
16sha1 :: HashingFunction
15sha1 = HashingFunction "SHA-1"
17sha1 = HashingFunction "SHA-1"
16
18
@@ -23,11 +25,8 @@ sha384 = HashingFunction "SHA-384"
23sha512 :: HashingFunction
25sha512 :: HashingFunction
24sha512 = HashingFunction "SHA-512"
26sha512 = HashingFunction "SHA-512"
25
27
26−
27foreign import digestImpl :: Fn2 HashingFunction ArrayBuffer (Promise ArrayBuffer)
28foreign import digestImpl :: Fn2 HashingFunction ArrayBuffer (Promise ArrayBuffer)
28
29
29−
30+-- | https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest
30digest :: HashingFunction -> ArrayBuffer -> Aff ArrayBuffer
31digest :: HashingFunction -> ArrayBuffer -> Aff ArrayBuffer
31−digest h x =
32− let p = runFn2 digestImpl h x
32+digest h x = toAff' errorFromDOMException (runFn2 digestImpl h x)
33− in makeAff \resolve -> nonCanceler <$ runPromise (resolve <<< Right) (resolve <<< Left) p
src/Crypto/Subtle/Key/Derive.jsnew file+6
@@ -0,0 +1,6 @@
1+export function deriveKeyImpl (a,k,t,e,u) {
2+ return crypto.subtle.deriveKey(a,k,t,e,u);
3+};
4+export function deriveBitsImpl (a,k,l) {
5+ return crypto.subtle.deriveBits(a,k,l);
6+};
src/Crypto/Subtle/Key/Derive.pursnew file+74
@@ -0,0 +1,74 @@
1+module Crypto.Subtle.Key.Derive
2+ ( deriveKey
3+ , deriveBits
4+ , DeriveAlgorithm, ec, hkdf, pbkdf2
5+ , DeriveTargetAlgorithm, hmac, aes
6+ ) where
7+
8+import Control.Promise (Promise, toAff')
9+import Crypto.Subtle.Constants.AES (AESAlgorithm, AESBitLength)
10+import Crypto.Subtle.Constants.EC (ECAlgorithm)
11+import Crypto.Subtle.Hash (HashingFunction)
12+import Crypto.Subtle.Key.Types (CryptoKey, CryptoKeyUsage, errorFromDOMException)
13+import Data.ArrayBuffer.Types (ArrayBuffer)
14+import Data.Function.Uncurried (Fn3, Fn5, runFn3, runFn5)
15+import Effect.Aff (Aff)
16+import Unsafe.Coerce (unsafeCoerce)
17+
18+
19+
20+foreign import deriveKeyImpl :: Fn5 DeriveAlgorithm CryptoKey DeriveTargetAlgorithm Boolean (Array CryptoKeyUsage) (Promise CryptoKey)
21+foreign import deriveBitsImpl :: Fn3 DeriveAlgorithm CryptoKey Int (Promise ArrayBuffer)
22+
23+
24+-- | https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/deriveKey
25+deriveKey :: DeriveAlgorithm
26+ -> CryptoKey -- ^ Base key
27+ -> DeriveTargetAlgorithm
28+ -> Boolean -- ^ Extractable
29+ -> Array CryptoKeyUsage
30+ -> Aff CryptoKey
31+deriveKey a k t e u = toAff' errorFromDOMException (runFn5 deriveKeyImpl a k t e u)
32+
33+-- | https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/deriveBits
34+deriveBits :: DeriveAlgorithm
35+ -> CryptoKey -- ^ Base key
36+ -> Int -- ^ Length in bits
37+ -> Aff ArrayBuffer
38+deriveBits a k l = toAff' errorFromDOMException (runFn3 deriveBitsImpl a k l)
39+
40+
41+foreign import data DeriveAlgorithm :: Type
42+foreign import data DeriveTargetAlgorithm :: Type
43+
44+
45+-- | https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/deriveKey#ecdh
46+ec :: ECAlgorithm
47+ -> CryptoKey -- ^ Public key of the other entity
48+ -> DeriveAlgorithm
49+ec e k = unsafeCoerce {name: e, public: k}
50+
51+-- | https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/deriveKey#hkdf
52+hkdf :: HashingFunction
53+ -> ArrayBuffer -- ^ Salt
54+ -> ArrayBuffer -- ^ Info
55+ -> DeriveAlgorithm
56+hkdf h s i = unsafeCoerce {name: "HKDF", hash: h, salt: s, info: i}
57+
58+-- | https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/deriveKey#pbkdf2
59+pbkdf2 :: HashingFunction
60+ -> ArrayBuffer -- ^ Salt
61+ -> Int -- ^ Iterations
62+ -> DeriveAlgorithm
63+pbkdf2 h s i = unsafeCoerce {name: "PBKDF2", hash: h, salt: s, iterations: i}
64+
65+
66+
67+
68+-- | https://developer.mozilla.org/en-US/docs/Web/API/HmacKeyGenParams
69+hmac :: HashingFunction -> DeriveTargetAlgorithm
70+hmac h = unsafeCoerce {name: "HMAC", hash: h}
71+
72+-- | https://developer.mozilla.org/en-US/docs/Web/API/AesKeyGenParams
73+aes :: AESAlgorithm -> AESBitLength -> DeriveTargetAlgorithm
74+aes a l = unsafeCoerce {name: a, length: l}
src/Crypto/Subtle/Key/Generate.jsnew file+4
@@ -0,0 +1,4 @@
1+export function generateKeyImpl (a,e,u) {
2+ return crypto.subtle.generateKey(a,e,u);
3+};
4+export const exp65537 = new Uint8Array([0x01,0x00,0x01]);
src/Crypto/Subtle/Key/Generate.pursnew file+70
@@ -0,0 +1,70 @@
1+module Crypto.Subtle.Key.Generate
2+ ( generateKey, generateKeyPair
3+ , AsymmetricAlgorithm, rsa, ec
4+ , SymmetricAlgorithm, hmac, aes
5+ , exp65537
6+ ) where
7+
8+import Control.Promise (Promise, toAff')
9+import Crypto.Subtle.Constants.AES (AESAlgorithm, AESBitLength)
10+import Crypto.Subtle.Constants.EC (ECAlgorithm, ECCurve)
11+import Crypto.Subtle.Constants.RSA (RSAAlgorithm)
12+import Crypto.Subtle.Hash (HashingFunction)
13+import Crypto.Subtle.Key.Types (CryptoKey, CryptoKeyPair, CryptoKeyUsage, errorFromDOMException)
14+import Data.ArrayBuffer.Types (Uint8Array)
15+import Data.Function.Uncurried (Fn3, runFn3)
16+import Effect.Aff (Aff)
17+import Unsafe.Coerce (unsafeCoerce)
18+
19+
20+
21+foreign import generateKeyImpl :: forall a b. Fn3 a Boolean (Array CryptoKeyUsage) (Promise b)
22+
23+
24+-- | Generate a symmetric key
25+-- |
26+-- | https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/generateKey
27+generateKey :: SymmetricAlgorithm
28+ -> Boolean -- ^ Extractable
29+ -> Array CryptoKeyUsage
30+ -> Aff CryptoKey
31+generateKey a e u = toAff' errorFromDOMException (runFn3 generateKeyImpl a e u)
32+
33+-- | Generate an asymmetric keypair
34+-- |
35+-- | https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/generateKey
36+generateKeyPair :: AsymmetricAlgorithm
37+ -> Boolean -- ^ Extractable
38+ -> Array CryptoKeyUsage
39+ -> Aff CryptoKeyPair
40+generateKeyPair a e u = toAff' errorFromDOMException (runFn3 generateKeyImpl a e u)
41+
42+
43+foreign import data SymmetricAlgorithm :: Type
44+foreign import data AsymmetricAlgorithm :: Type
45+
46+
47+foreign import exp65537 :: Uint8Array
48+
49+
50+-- | https://developer.mozilla.org/en-US/docs/Web/API/RsaHashedKeyGenParams
51+rsa :: RSAAlgorithm
52+ -> Int -- ^ Modulus length. Should be at least 2048, or 4096 according to some bozo
53+ -> Uint8Array -- ^ Public exponent. Just use `exp65537`.
54+ -> HashingFunction
55+ -> AsymmetricAlgorithm
56+rsa r l e h = unsafeCoerce {name: r, modulusLength: l, publicExponent: e, hash: h}
57+
58+-- | https://developer.mozilla.org/en-US/docs/Web/API/EcKeyGenParams
59+ec :: ECAlgorithm -> ECCurve -> AsymmetricAlgorithm
60+ec e c = unsafeCoerce {name: e, namedCurve: c}
61+
62+-- | https://developer.mozilla.org/en-US/docs/Web/API/HmacKeyGenParams
63+hmac :: HashingFunction -> SymmetricAlgorithm
64+hmac h = unsafeCoerce {name: "HMAC", hash: h}
65+
66+-- | https://developer.mozilla.org/en-US/docs/Web/API/AesKeyGenParams
67+aes :: AESAlgorithm
68+ -> AESBitLength
69+ -> SymmetricAlgorithm
70+aes a l = unsafeCoerce {name: a, length: l}
src/Crypto/Subtle/Key/Import.js+3−3
@@ -1,3 +1,3 @@
1−"use strict";
1+export function importKeyImpl (f,x,a,e,u) {
2−
3−exports.importKeyImpl = crypto.subtle.importKey;
2+ return crypto.subtle.importKey(f,x,a,e,u);
3+};
src/Crypto/Subtle/Key/Import.purs+11−29
@@ -1,50 +1,32 @@
1module Crypto.Subtle.Key.Import
1module Crypto.Subtle.Key.Import
2 ( importKey
2 ( importKey
3− , ImportFormat, raw, pkcs8, spki, jwk
4 , ImportAlgorithm, rsa, ec, hmac, aes
3 , ImportAlgorithm, rsa, ec, hmac, aes
5 ) where
4 ) where
6
5
7−import Crypto.Subtle.Key.Types (CryptoKey, CryptoKeyUsage)
6+import Control.Promise (Promise, toAff')
7+import Crypto.Subtle.Constants.AES (AESAlgorithm)
8+import Crypto.Subtle.Constants.EC (ECAlgorithm, ECCurve)
9+import Crypto.Subtle.Constants.RSA (RSAAlgorithm)
8import Crypto.Subtle.Hash (HashingFunction)
10import Crypto.Subtle.Hash (HashingFunction)
9−import Crypto.Subtle.RSA (RSAAlgorithm)
11+import Crypto.Subtle.Key.Types (CryptoKey, CryptoKeyUsage, ExternalFormat, errorFromDOMException)
10−import Crypto.Subtle.EC (ECAlgorithm, ECCurve)
11−import Crypto.Subtle.AES (AESAlgorithm)
12−
13−import Prelude ((<<<), (<$))
14−import Data.Function.Uncurried (Fn5, runFn5)
15import Data.ArrayBuffer.Types (ArrayBuffer)
12import Data.ArrayBuffer.Types (ArrayBuffer)
16−import Data.Either (Either (..))
13+import Data.Function.Uncurried (Fn5, runFn5)
17−import Effect.Promise (Promise, runPromise)
18−import Effect.Aff (Aff, makeAff, nonCanceler)
14+import Effect.Aff (Aff)
19import Unsafe.Coerce (unsafeCoerce)
15import Unsafe.Coerce (unsafeCoerce)
20
16
21
17
22
18
23−foreign import importKeyImpl :: Fn5 ImportFormat ArrayBuffer ImportAlgorithm Boolean (Array CryptoKeyUsage) (Promise CryptoKey)
19+foreign import importKeyImpl :: Fn5 ExternalFormat ArrayBuffer ImportAlgorithm Boolean (Array CryptoKeyUsage) (Promise CryptoKey)
24
20
25
21
22+-- | https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey
26−importKey :: ImportFormat
23+importKey :: ExternalFormat
27 -> ArrayBuffer -- ^ Key data
24 -> ArrayBuffer -- ^ Key data
28 -> ImportAlgorithm
25 -> ImportAlgorithm
29 -> Boolean -- ^ Extractable
26 -> Boolean -- ^ Extractable
30 -> Array CryptoKeyUsage
27 -> Array CryptoKeyUsage
31 -> Aff CryptoKey
28 -> Aff CryptoKey
32−importKey f x a e u = makeAff \resolve ->
29+importKey f x a e u = toAff' errorFromDOMException (runFn5 importKeyImpl f x a e u)
33− nonCanceler <$ runPromise (resolve <<< Right) (resolve <<< Left) (runFn5 importKeyImpl f x a e u)
34−
35−
36−newtype ImportFormat = ImportFormat String
37−
38−raw :: ImportFormat
39−raw = ImportFormat "raw"
40−pkcs8 :: ImportFormat
41−pkcs8 = ImportFormat "pkcs8"
42−spki :: ImportFormat
43−spki = ImportFormat "spki"
44−jwk :: ImportFormat
45−jwk = ImportFormat "jwk"
46−
47−
48
30
49
31
50foreign import data ImportAlgorithm :: Type
32foreign import data ImportAlgorithm :: Type
src/Crypto/Subtle/Key/Types.jsnew file+3
@@ -0,0 +1,3 @@
1+export function exportKeyImpl (f,x) {
2+ return crypto.subtle.exportKey(f,x);
3+};
src/Crypto/Subtle/Key/Types.purs+100−19
@@ -1,20 +1,63 @@
1module Crypto.Subtle.Key.Types
1module Crypto.Subtle.Key.Types
2+ ( CryptoKey
3+ , CryptoKeyPair(..)
2− ( CryptoKeyType
4+ , CryptoKeyType
3 , CryptoKeyUsage
5 , CryptoKeyUsage
4− , encrypt, decrypt, sign, verify, deriveKey, deriveBits, unwrapKey, wrapKey
6+ , ExternalFormat
5− , CryptoKey (..)
7+ , allUsages
8+ , decrypt
9+ , deriveBits
10+ , deriveKey
11+ , encrypt
12+ , errorFromDOMException
13+ , exportKey
6− , getType, getExtractable, getAlgorithm, getUsages
14+ , getAlgorithm
15+ , getExtractable
16+ , getType
17+ , getUsages
18+ , jwk
19+ , pkcs8
20+ , private
21+ , public
22+ , raw
23+ , secret
24+ , sign
25+ , spki
26+ , unwrapKey
27+ , verify
28+ , wrapKey
29+ )
7− ) where
30+ where
8−
31+
32+import Prelude ((>>=), class Eq)
33+import Control.Monad.Except (runExcept)
34+import Control.Promise (Promise, toAff')
35+import Data.ArrayBuffer.Types (ArrayBuffer)
36+import Data.Either (Either(..))
37+import Data.Function.Uncurried (Fn2, runFn2)
38+import Effect.Aff (Aff, Error, error)
39+import Foreign (Foreign, readString)
40+import Foreign.Index (readProp)
41+import Unsafe.Coerce (unsafeCoerce)
42+
43+
44+-- TODO enumerate different key types - public, secret, etc.
45+newtype CryptoKeyType = CryptoKeyType String
9
46
10−import Foreign (Foreign)
47+derive newtype instance eqCryptoKeyType :: Eq CryptoKeyType
11
48
49+secret :: CryptoKeyType
50+secret = CryptoKeyType "secret"
51+public :: CryptoKeyType
52+public = CryptoKeyType "public"
53+private :: CryptoKeyType
54+private = CryptoKeyType "private"
12
55
13
56
14−newtype CryptoKeyType = CryptoKeyType String
15−
16newtype CryptoKeyUsage = CryptoKeyUsage String
57newtype CryptoKeyUsage = CryptoKeyUsage String
17
58
59+derive newtype instance eqCryptoKeyUsage :: Eq CryptoKeyUsage
60+
18
61
19encrypt :: CryptoKeyUsage
62encrypt :: CryptoKeyUsage
20encrypt = CryptoKeyUsage "encrypt"
63encrypt = CryptoKeyUsage "encrypt"
@@ -34,24 +77,62 @@ unwrapKey :: CryptoKeyUsage
34unwrapKey = CryptoKeyUsage "unwrapKey"
77unwrapKey = CryptoKeyUsage "unwrapKey"
35
78
36
79
80+allUsages :: Array CryptoKeyUsage
81+allUsages = [encrypt, decrypt, sign, verify, deriveKey, deriveBits, wrapKey, unwrapKey]
37
82
38
83
39−newtype CryptoKey = CryptoKey
84+
40− { "type" :: CryptoKeyType
85+foreign import data CryptoKey :: Type
41− , extractable :: Boolean
42− , algorithm :: Foreign
43− , usages :: Array CryptoKeyUsage
44− }
45
86
46
87
47getType :: CryptoKey -> CryptoKeyType
88getType :: CryptoKey -> CryptoKeyType
48−getType (CryptoKey r) = r."type"
89+getType r = (unsafeCoerce r)."type"
49
90
50getExtractable :: CryptoKey -> Boolean
91getExtractable :: CryptoKey -> Boolean
51−getExtractable (CryptoKey r) = r.extractable
92+getExtractable r = (unsafeCoerce r).extractable
52
93
53getAlgorithm :: CryptoKey -> Foreign
94getAlgorithm :: CryptoKey -> Foreign
54−getAlgorithm (CryptoKey r) = r.algorithm
95+getAlgorithm r = (unsafeCoerce r).algorithm
55
96
56getUsages :: CryptoKey -> Array CryptoKeyUsage
97getUsages :: CryptoKey -> Array CryptoKeyUsage
57−getUsages (CryptoKey r) = r.usages
98+getUsages r = (unsafeCoerce r).usages
99+
100+
101+newtype CryptoKeyPair = CryptoKeyPair
102+ { privateKey :: CryptoKey
103+ , publicKey :: CryptoKey
104+ }
105+
106+
107+
108+
109+newtype ExternalFormat = ExternalFormat String
110+
111+derive newtype instance eqExternalFormat :: Eq ExternalFormat
112+
113+raw :: ExternalFormat
114+raw = ExternalFormat "raw"
115+pkcs8 :: ExternalFormat
116+pkcs8 = ExternalFormat "pkcs8"
117+spki :: ExternalFormat
118+spki = ExternalFormat "spki"
119+jwk :: ExternalFormat
120+jwk = ExternalFormat "jwk"
121+
122+
123+foreign import exportKeyImpl :: Fn2 ExternalFormat CryptoKey (Promise ArrayBuffer)
124+
125+-- | https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/exportKey
126+exportKey :: ExternalFormat
127+ -> CryptoKey
128+ -> Aff ArrayBuffer
129+exportKey f x = toAff' errorFromDOMException (runFn2 exportKeyImpl f x)
130+
131+-- Most of the Promises throw DOMException, so read the message from the DOMException.
132+-- https://developer.mozilla.org/en-US/docs/Web/API/DOMException
133+-- Some of the Promises throw TypeError, which also has a message property.
134+-- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError
135+errorFromDOMException :: Foreign -> Error
136+errorFromDOMException x = case runExcept (readProp "message" x >>= readString) of
137+ Left _ -> error "Not a DOMException"
138+ Right m -> error m
src/Crypto/Subtle/Key/Wrap.jsnew file+6
@@ -0,0 +1,6 @@
1+export function wrapKeyImpl (f,x,k,a) {
2+ return crypto.subtle.wrapKey(f,x,k,a);
3+};
4+export function unwrapKeyImpl (f,x,k,a,i,e,u) {
5+ return crypto.subtle.unwrapKey(f,x,k,a,i,e,u);
6+};
src/Crypto/Subtle/Key/Wrap.pursnew file+37
@@ -0,0 +1,37 @@
1+module Crypto.Subtle.Key.Wrap
2+ where
3+
4+import Control.Promise (Promise, toAff')
5+import Crypto.Subtle.Encrypt (EncryptAlgorithm)
6+import Crypto.Subtle.Key.Import (ImportAlgorithm)
7+import Crypto.Subtle.Key.Types (CryptoKey, CryptoKeyUsage, ExternalFormat, errorFromDOMException)
8+import Data.ArrayBuffer.Types (ArrayBuffer)
9+import Data.Function.Uncurried (Fn4, Fn7, runFn4, runFn7)
10+import Effect.Aff (Aff)
11+
12+
13+
14+foreign import wrapKeyImpl :: Fn4 ExternalFormat CryptoKey CryptoKey EncryptAlgorithm (Promise ArrayBuffer)
15+
16+-- | https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/wrapKey
17+wrapKey :: ExternalFormat
18+ -> CryptoKey -- ^ Subject key
19+ -> CryptoKey -- ^ Wrapping key
20+ -> EncryptAlgorithm
21+ -> Aff ArrayBuffer
22+wrapKey f x k a = toAff' errorFromDOMException (runFn4 wrapKeyImpl f x k a)
23+
24+
25+foreign import unwrapKeyImpl :: Fn7 ExternalFormat ArrayBuffer CryptoKey EncryptAlgorithm ImportAlgorithm Boolean (Array CryptoKeyUsage) (Promise CryptoKey)
26+
27+-- | https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/unwrapKey
28+unwrapKey :: ExternalFormat
29+ -> ArrayBuffer -- ^ Wrapped key
30+ -> CryptoKey -- ^ Unwrapping key
31+ -> EncryptAlgorithm
32+ -> ImportAlgorithm
33+ -> Boolean -- ^ Extractable
34+ -> Array CryptoKeyUsage
35+ -- -> Aff (Maybe CryptoKey)
36+ -> Aff CryptoKey
37+unwrapKey f x k a i e u = toAff' errorFromDOMException (runFn7 unwrapKeyImpl f x k a i e u)
src/Crypto/Subtle/Sign.jsnew file+6
@@ -0,0 +1,6 @@
1+export function signImpl (a,k,x) {
2+ return crypto.subtle.sign(a,k,x);
3+};
4+export function verifyImpl(a, k, s, x) {
5+ return crypto.subtle.verify(a, k, s, x);
6+}
src/Crypto/Subtle/Sign.pursnew file+53
@@ -0,0 +1,53 @@
1+module Crypto.Subtle.Sign
2+ ( sign, verify
3+ , SignAlgorithm, rsaPKCS1, rsaPSS, ecdsa, hmac
4+ ) where
5+
6+import Control.Promise (Promise, toAff')
7+import Crypto.Subtle.Hash (HashingFunction)
8+import Crypto.Subtle.Key.Types (CryptoKey, errorFromDOMException)
9+import Data.ArrayBuffer.Types (ArrayBuffer)
10+import Data.Function.Uncurried (Fn3, Fn4, runFn3, runFn4)
11+import Effect.Aff (Aff)
12+import Unsafe.Coerce (unsafeCoerce)
13+
14+
15+
16+foreign import data SignAlgorithm :: Type
17+
18+rsaPKCS1 :: SignAlgorithm
19+rsaPKCS1 = unsafeCoerce {name: "RSASSA-PKCS1-v1_5"}
20+
21+-- | https://developer.mozilla.org/en-US/docs/Web/API/RsaPssParams
22+rsaPSS :: Int -- ^ Salt length
23+ -> SignAlgorithm
24+rsaPSS l = unsafeCoerce {name: "RSA-PSS", saltLength: l}
25+
26+-- | https://developer.mozilla.org/en-US/docs/Web/API/EcdsaParams
27+ecdsa :: HashingFunction
28+ -> SignAlgorithm
29+ecdsa h = unsafeCoerce {name: "ECDSA", hash: h}
30+
31+hmac :: SignAlgorithm
32+hmac = unsafeCoerce {name: "HMAC"}
33+
34+
35+foreign import signImpl :: Fn3 SignAlgorithm CryptoKey ArrayBuffer (Promise ArrayBuffer)
36+
37+-- | https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/sign
38+sign :: SignAlgorithm
39+ -> CryptoKey
40+ -> ArrayBuffer
41+ -> Aff ArrayBuffer
42+sign a k x = toAff' errorFromDOMException (runFn3 signImpl a k x)
43+
44+
45+foreign import verifyImpl :: Fn4 SignAlgorithm CryptoKey ArrayBuffer ArrayBuffer (Promise Boolean)
46+
47+-- | https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/verify
48+verify :: SignAlgorithm
49+ -> CryptoKey
50+ -> ArrayBuffer -- ^ Signature
51+ -> ArrayBuffer -- ^ Subject data
52+ -> Aff Boolean
53+verify a k s x = toAff' errorFromDOMException (runFn4 verifyImpl a k s x)
test.browser.jsnew file+2281
@@ -0,0 +1,2281 @@
1+/* Generated by Spago v0.93.40 */
2+(() => {
3+ // output/Control.Semigroupoid/index.js
4+ var semigroupoidFn = {
5+ compose: function(f) {
6+ return function(g) {
7+ return function(x) {
8+ return f(g(x));
9+ };
10+ };
11+ }
12+ };
13+
14+ // output/Control.Category/index.js
15+ var identity = function(dict) {
16+ return dict.identity;
17+ };
18+ var categoryFn = {
19+ identity: function(x) {
20+ return x;
21+ },
22+ Semigroupoid0: function() {
23+ return semigroupoidFn;
24+ }
25+ };
26+
27+ // output/Data.Boolean/index.js
28+ var otherwise = true;
29+
30+ // output/Data.Function/index.js
31+ var flip = function(f) {
32+ return function(b) {
33+ return function(a) {
34+ return f(a)(b);
35+ };
36+ };
37+ };
38+ var $$const = function(a) {
39+ return function(v) {
40+ return a;
41+ };
42+ };
43+
44+ // output/Data.Unit/foreign.js
45+ var unit = void 0;
46+
47+ // output/Data.Functor/index.js
48+ var map = function(dict) {
49+ return dict.map;
50+ };
51+ var $$void = function(dictFunctor) {
52+ return map(dictFunctor)($$const(unit));
53+ };
54+ var voidRight = function(dictFunctor) {
55+ var map1 = map(dictFunctor);
56+ return function(x) {
57+ return map1($$const(x));
58+ };
59+ };
60+
61+ // output/Control.Apply/index.js
62+ var identity2 = /* @__PURE__ */ identity(categoryFn);
63+ var apply = function(dict) {
64+ return dict.apply;
65+ };
66+ var applySecond = function(dictApply) {
67+ var apply1 = apply(dictApply);
68+ var map3 = map(dictApply.Functor0());
69+ return function(a) {
70+ return function(b) {
71+ return apply1(map3($$const(identity2))(a))(b);
72+ };
73+ };
74+ };
75+
76+ // output/Control.Applicative/index.js
77+ var pure = function(dict) {
78+ return dict.pure;
79+ };
80+ var liftA1 = function(dictApplicative) {
81+ var apply2 = apply(dictApplicative.Apply0());
82+ var pure1 = pure(dictApplicative);
83+ return function(f) {
84+ return function(a) {
85+ return apply2(pure1(f))(a);
86+ };
87+ };
88+ };
89+
90+ // output/Control.Bind/index.js
91+ var discard = function(dict) {
92+ return dict.discard;
93+ };
94+ var bind = function(dict) {
95+ return dict.bind;
96+ };
97+ var bindFlipped = function(dictBind) {
98+ return flip(bind(dictBind));
99+ };
100+ var discardUnit = {
101+ discard: function(dictBind) {
102+ return bind(dictBind);
103+ }
104+ };
105+
106+ // output/Crypto.Subtle.Constants.AES/index.js
107+ var l256 = 256;
108+ var l192 = 192;
109+ var l128 = 128;
110+ var aesKW = "AES-KW";
111+ var aesGCM = "AES-GCM";
112+ var aesCTR = "AES-CTR";
113+ var aesCBC = "AES-CBC";
114+
115+ // output/Crypto.Subtle.Constants.EC/index.js
116+ var p521 = "P-521";
117+ var p384 = "P-384";
118+ var p256 = "P-256";
119+ var ecdsa = "ECDSA";
120+ var ecdh = "ECDH";
121+
122+ // output/Crypto.Subtle.Constants.RSA/index.js
123+ var rsaPSS = "RSA-PSS";
124+ var rsaPKCS1 = "RSASSA-PKCS1-v1_5";
125+ var rsaOAEP = "RSA-OAEP";
126+
127+ // output/Control.Promise/foreign.js
128+ function thenImpl(promise2) {
129+ return function(errCB) {
130+ return function(succCB) {
131+ return function() {
132+ promise2.then(succCB, errCB);
133+ };
134+ };
135+ };
136+ }
137+
138+ // output/Data.Semigroup/index.js
139+ var append = function(dict) {
140+ return dict.append;
141+ };
142+
143+ // output/Data.Bounded/foreign.js
144+ var topChar = String.fromCharCode(65535);
145+ var bottomChar = String.fromCharCode(0);
146+ var topNumber = Number.POSITIVE_INFINITY;
147+ var bottomNumber = Number.NEGATIVE_INFINITY;
148+
149+ // output/Data.Either/index.js
150+ var Left = /* @__PURE__ */ function() {
151+ function Left2(value0) {
152+ this.value0 = value0;
153+ }
154+ ;
155+ Left2.create = function(value0) {
156+ return new Left2(value0);
157+ };
158+ return Left2;
159+ }();
160+ var Right = /* @__PURE__ */ function() {
161+ function Right2(value0) {
162+ this.value0 = value0;
163+ }
164+ ;
165+ Right2.create = function(value0) {
166+ return new Right2(value0);
167+ };
168+ return Right2;
169+ }();
170+ var functorEither = {
171+ map: function(f) {
172+ return function(m) {
173+ if (m instanceof Left) {
174+ return new Left(m.value0);
175+ }
176+ ;
177+ if (m instanceof Right) {
178+ return new Right(f(m.value0));
179+ }
180+ ;
181+ throw new Error("Failed pattern match at Data.Either (line 0, column 0 - line 0, column 0): " + [m.constructor.name]);
182+ };
183+ }
184+ };
185+ var either = function(v) {
186+ return function(v1) {
187+ return function(v2) {
188+ if (v2 instanceof Left) {
189+ return v(v2.value0);
190+ }
191+ ;
192+ if (v2 instanceof Right) {
193+ return v1(v2.value0);
194+ }
195+ ;
196+ throw new Error("Failed pattern match at Data.Either (line 208, column 1 - line 208, column 64): " + [v.constructor.name, v1.constructor.name, v2.constructor.name]);
197+ };
198+ };
199+ };
200+
201+ // output/Effect/foreign.js
202+ var pureE = function(a) {
203+ return function() {
204+ return a;
205+ };
206+ };
207+ var bindE = function(a) {
208+ return function(f) {
209+ return function() {
210+ return f(a())();
211+ };
212+ };
213+ };
214+
215+ // output/Control.Monad/index.js
216+ var ap = function(dictMonad) {
217+ var bind4 = bind(dictMonad.Bind1());
218+ var pure4 = pure(dictMonad.Applicative0());
219+ return function(f) {
220+ return function(a) {
221+ return bind4(f)(function(f$prime) {
222+ return bind4(a)(function(a$prime) {
223+ return pure4(f$prime(a$prime));
224+ });
225+ });
226+ };
227+ };
228+ };
229+
230+ // output/Data.Monoid/index.js
231+ var mempty = function(dict) {
232+ return dict.mempty;
233+ };
234+
235+ // output/Effect/index.js
236+ var $runtime_lazy = function(name2, moduleName, init2) {
237+ var state2 = 0;
238+ var val;
239+ return function(lineNumber) {
240+ if (state2 === 2) return val;
241+ if (state2 === 1) throw new ReferenceError(name2 + " was needed before it finished initializing (module " + moduleName + ", line " + lineNumber + ")", moduleName, lineNumber);
242+ state2 = 1;
243+ val = init2();
244+ state2 = 2;
245+ return val;
246+ };
247+ };
248+ var monadEffect = {
249+ Applicative0: function() {
250+ return applicativeEffect;
251+ },
252+ Bind1: function() {
253+ return bindEffect;
254+ }
255+ };
256+ var bindEffect = {
257+ bind: bindE,
258+ Apply0: function() {
259+ return $lazy_applyEffect(0);
260+ }
261+ };
262+ var applicativeEffect = {
263+ pure: pureE,
264+ Apply0: function() {
265+ return $lazy_applyEffect(0);
266+ }
267+ };
268+ var $lazy_functorEffect = /* @__PURE__ */ $runtime_lazy("functorEffect", "Effect", function() {
269+ return {
270+ map: liftA1(applicativeEffect)
271+ };
272+ });
273+ var $lazy_applyEffect = /* @__PURE__ */ $runtime_lazy("applyEffect", "Effect", function() {
274+ return {
275+ apply: ap(monadEffect),
276+ Functor0: function() {
277+ return $lazy_functorEffect(0);
278+ }
279+ };
280+ });
281+ var functorEffect = /* @__PURE__ */ $lazy_functorEffect(20);
282+
283+ // output/Effect.Exception/foreign.js
284+ function error(msg) {
285+ return new Error(msg);
286+ }
287+ function throwException(e) {
288+ return function() {
289+ throw e;
290+ };
291+ }
292+
293+ // output/Control.Monad.Error.Class/index.js
294+ var throwError = function(dict) {
295+ return dict.throwError;
296+ };
297+ var catchError = function(dict) {
298+ return dict.catchError;
299+ };
300+ var $$try = function(dictMonadError) {
301+ var catchError1 = catchError(dictMonadError);
302+ var Monad0 = dictMonadError.MonadThrow0().Monad0();
303+ var map3 = map(Monad0.Bind1().Apply0().Functor0());
304+ var pure4 = pure(Monad0.Applicative0());
305+ return function(a) {
306+ return catchError1(map3(Right.create)(a))(function($52) {
307+ return pure4(Left.create($52));
308+ });
309+ };
310+ };
311+
312+ // output/Data.Identity/index.js
313+ var Identity = function(x) {
314+ return x;
315+ };
316+ var functorIdentity = {
317+ map: function(f) {
318+ return function(m) {
319+ return f(m);
320+ };
321+ }
322+ };
323+ var applyIdentity = {
324+ apply: function(v) {
325+ return function(v1) {
326+ return v(v1);
327+ };
328+ },
329+ Functor0: function() {
330+ return functorIdentity;
331+ }
332+ };
333+ var bindIdentity = {
334+ bind: function(v) {
335+ return function(f) {
336+ return f(v);
337+ };
338+ },
339+ Apply0: function() {
340+ return applyIdentity;
341+ }
342+ };
343+ var applicativeIdentity = {
344+ pure: Identity,
345+ Apply0: function() {
346+ return applyIdentity;
347+ }
348+ };
349+ var monadIdentity = {
350+ Applicative0: function() {
351+ return applicativeIdentity;
352+ },
353+ Bind1: function() {
354+ return bindIdentity;
355+ }
356+ };
357+
358+ // output/Unsafe.Coerce/foreign.js
359+ var unsafeCoerce2 = function(x) {
360+ return x;
361+ };
362+
363+ // output/Effect.Class/index.js
364+ var liftEffect = function(dict) {
365+ return dict.liftEffect;
366+ };
367+
368+ // output/Control.Monad.Except.Trans/index.js
369+ var map2 = /* @__PURE__ */ map(functorEither);
370+ var ExceptT = function(x) {
371+ return x;
372+ };
373+ var runExceptT = function(v) {
374+ return v;
375+ };
376+ var mapExceptT = function(f) {
377+ return function(v) {
378+ return f(v);
379+ };
380+ };
381+ var functorExceptT = function(dictFunctor) {
382+ var map1 = map(dictFunctor);
383+ return {
384+ map: function(f) {
385+ return mapExceptT(map1(map2(f)));
386+ }
387+ };
388+ };
389+ var monadExceptT = function(dictMonad) {
390+ return {
391+ Applicative0: function() {
392+ return applicativeExceptT(dictMonad);
393+ },
394+ Bind1: function() {
395+ return bindExceptT(dictMonad);
396+ }
397+ };
398+ };
399+ var bindExceptT = function(dictMonad) {
400+ var bind4 = bind(dictMonad.Bind1());
401+ var pure4 = pure(dictMonad.Applicative0());
402+ return {
403+ bind: function(v) {
404+ return function(k) {
405+ return bind4(v)(either(function($193) {
406+ return pure4(Left.create($193));
407+ })(function(a) {
408+ var v1 = k(a);
409+ return v1;
410+ }));
411+ };
412+ },
413+ Apply0: function() {
414+ return applyExceptT(dictMonad);
415+ }
416+ };
417+ };
418+ var applyExceptT = function(dictMonad) {
419+ var functorExceptT1 = functorExceptT(dictMonad.Bind1().Apply0().Functor0());
420+ return {
421+ apply: ap(monadExceptT(dictMonad)),
422+ Functor0: function() {
423+ return functorExceptT1;
424+ }
425+ };
426+ };
427+ var applicativeExceptT = function(dictMonad) {
428+ return {
429+ pure: function() {
430+ var $194 = pure(dictMonad.Applicative0());
431+ return function($195) {
432+ return ExceptT($194(Right.create($195)));
433+ };
434+ }(),
435+ Apply0: function() {
436+ return applyExceptT(dictMonad);
437+ }
438+ };
439+ };
440+ var monadThrowExceptT = function(dictMonad) {
441+ var monadExceptT1 = monadExceptT(dictMonad);
442+ return {
443+ throwError: function() {
444+ var $204 = pure(dictMonad.Applicative0());
445+ return function($205) {
446+ return ExceptT($204(Left.create($205)));
447+ };
448+ }(),
449+ Monad0: function() {
450+ return monadExceptT1;
451+ }
452+ };
453+ };
454+
455+ // output/Safe.Coerce/index.js
456+ var coerce = function() {
457+ return unsafeCoerce2;
458+ };
459+
460+ // output/Data.Newtype/index.js
461+ var coerce2 = /* @__PURE__ */ coerce();
462+ var unwrap = function() {
463+ return coerce2;
464+ };
465+
466+ // output/Control.Monad.Except/index.js
467+ var unwrap2 = /* @__PURE__ */ unwrap();
468+ var runExcept = function($3) {
469+ return unwrap2(runExceptT($3));
470+ };
471+
472+ // output/Data.Foldable/foreign.js
473+ var foldrArray = function(f) {
474+ return function(init2) {
475+ return function(xs) {
476+ var acc = init2;
477+ var len = xs.length;
478+ for (var i = len - 1; i >= 0; i--) {
479+ acc = f(xs[i])(acc);
480+ }
481+ return acc;
482+ };
483+ };
484+ };
485+ var foldlArray = function(f) {
486+ return function(init2) {
487+ return function(xs) {
488+ var acc = init2;
489+ var len = xs.length;
490+ for (var i = 0; i < len; i++) {
491+ acc = f(acc)(xs[i]);
492+ }
493+ return acc;
494+ };
495+ };
496+ };
497+
498+ // output/Control.Plus/index.js
499+ var empty = function(dict) {
500+ return dict.empty;
501+ };
502+
503+ // output/Data.Foldable/index.js
504+ var foldr = function(dict) {
505+ return dict.foldr;
506+ };
507+ var traverse_ = function(dictApplicative) {
508+ var applySecond2 = applySecond(dictApplicative.Apply0());
509+ var pure4 = pure(dictApplicative);
510+ return function(dictFoldable) {
511+ var foldr22 = foldr(dictFoldable);
512+ return function(f) {
513+ return foldr22(function($454) {
514+ return applySecond2(f($454));
515+ })(pure4(unit));
516+ };
517+ };
518+ };
519+ var foldl = function(dict) {
520+ return dict.foldl;
521+ };
522+ var foldMapDefaultR = function(dictFoldable) {
523+ var foldr22 = foldr(dictFoldable);
524+ return function(dictMonoid) {
525+ var append2 = append(dictMonoid.Semigroup0());
526+ var mempty3 = mempty(dictMonoid);
527+ return function(f) {
528+ return foldr22(function(x) {
529+ return function(acc) {
530+ return append2(f(x))(acc);
531+ };
532+ })(mempty3);
533+ };
534+ };
535+ };
536+ var foldableArray = {
537+ foldr: foldrArray,
538+ foldl: foldlArray,
539+ foldMap: function(dictMonoid) {
540+ return foldMapDefaultR(foldableArray)(dictMonoid);
541+ }
542+ };
543+
544+ // output/Data.NonEmpty/index.js
545+ var NonEmpty = /* @__PURE__ */ function() {
546+ function NonEmpty2(value0, value1) {
547+ this.value0 = value0;
548+ this.value1 = value1;
549+ }
550+ ;
551+ NonEmpty2.create = function(value0) {
552+ return function(value1) {
553+ return new NonEmpty2(value0, value1);
554+ };
555+ };
556+ return NonEmpty2;
557+ }();
558+ var singleton2 = function(dictPlus) {
559+ var empty2 = empty(dictPlus);
560+ return function(a) {
561+ return new NonEmpty(a, empty2);
562+ };
563+ };
564+
565+ // output/Data.List.Types/index.js
566+ var Nil = /* @__PURE__ */ function() {
567+ function Nil2() {
568+ }
569+ ;
570+ Nil2.value = new Nil2();
571+ return Nil2;
572+ }();
573+ var Cons = /* @__PURE__ */ function() {
574+ function Cons2(value0, value1) {
575+ this.value0 = value0;
576+ this.value1 = value1;
577+ }
578+ ;
579+ Cons2.create = function(value0) {
580+ return function(value1) {
581+ return new Cons2(value0, value1);
582+ };
583+ };
584+ return Cons2;
585+ }();
586+ var NonEmptyList = function(x) {
587+ return x;
588+ };
589+ var listMap = function(f) {
590+ var chunkedRevMap = function($copy_v) {
591+ return function($copy_v1) {
592+ var $tco_var_v = $copy_v;
593+ var $tco_done = false;
594+ var $tco_result;
595+ function $tco_loop(v, v1) {
596+ if (v1 instanceof Cons && (v1.value1 instanceof Cons && v1.value1.value1 instanceof Cons)) {
597+ $tco_var_v = new Cons(v1, v);
598+ $copy_v1 = v1.value1.value1.value1;
599+ return;
600+ }
601+ ;
602+ var unrolledMap = function(v2) {
603+ if (v2 instanceof Cons && (v2.value1 instanceof Cons && v2.value1.value1 instanceof Nil)) {
604+ return new Cons(f(v2.value0), new Cons(f(v2.value1.value0), Nil.value));
605+ }
606+ ;
607+ if (v2 instanceof Cons && v2.value1 instanceof Nil) {
608+ return new Cons(f(v2.value0), Nil.value);
609+ }
610+ ;
611+ return Nil.value;
612+ };
613+ var reverseUnrolledMap = function($copy_v2) {
614+ return function($copy_v3) {
615+ var $tco_var_v2 = $copy_v2;
616+ var $tco_done1 = false;
617+ var $tco_result2;
618+ function $tco_loop2(v2, v3) {
619+ if (v2 instanceof Cons && (v2.value0 instanceof Cons && (v2.value0.value1 instanceof Cons && v2.value0.value1.value1 instanceof Cons))) {
620+ $tco_var_v2 = v2.value1;
621+ $copy_v3 = new Cons(f(v2.value0.value0), new Cons(f(v2.value0.value1.value0), new Cons(f(v2.value0.value1.value1.value0), v3)));
622+ return;
623+ }
624+ ;
625+ $tco_done1 = true;
626+ return v3;
627+ }
628+ ;
629+ while (!$tco_done1) {
630+ $tco_result2 = $tco_loop2($tco_var_v2, $copy_v3);
631+ }
632+ ;
633+ return $tco_result2;
634+ };
635+ };
636+ $tco_done = true;
637+ return reverseUnrolledMap(v)(unrolledMap(v1));
638+ }
639+ ;
640+ while (!$tco_done) {
641+ $tco_result = $tco_loop($tco_var_v, $copy_v1);
642+ }
643+ ;
644+ return $tco_result;
645+ };
646+ };
647+ return chunkedRevMap(Nil.value);
648+ };
649+ var functorList = {
650+ map: listMap
651+ };
652+ var foldableList = {
653+ foldr: function(f) {
654+ return function(b) {
655+ var rev = function() {
656+ var go = function($copy_v) {
657+ return function($copy_v1) {
658+ var $tco_var_v = $copy_v;
659+ var $tco_done = false;
660+ var $tco_result;
661+ function $tco_loop(v, v1) {
662+ if (v1 instanceof Nil) {
663+ $tco_done = true;
664+ return v;
665+ }
666+ ;
667+ if (v1 instanceof Cons) {
668+ $tco_var_v = new Cons(v1.value0, v);
669+ $copy_v1 = v1.value1;
670+ return;
671+ }
672+ ;
673+ throw new Error("Failed pattern match at Data.List.Types (line 107, column 7 - line 107, column 23): " + [v.constructor.name, v1.constructor.name]);
674+ }
675+ ;
676+ while (!$tco_done) {
677+ $tco_result = $tco_loop($tco_var_v, $copy_v1);
678+ }
679+ ;
680+ return $tco_result;
681+ };
682+ };
683+ return go(Nil.value);
684+ }();
685+ var $284 = foldl(foldableList)(flip(f))(b);
686+ return function($285) {
687+ return $284(rev($285));
688+ };
689+ };
690+ },
691+ foldl: function(f) {
692+ var go = function($copy_b) {
693+ return function($copy_v) {
694+ var $tco_var_b = $copy_b;
695+ var $tco_done1 = false;
696+ var $tco_result;
697+ function $tco_loop(b, v) {
698+ if (v instanceof Nil) {
699+ $tco_done1 = true;
700+ return b;
701+ }
702+ ;
703+ if (v instanceof Cons) {
704+ $tco_var_b = f(b)(v.value0);
705+ $copy_v = v.value1;
706+ return;
707+ }
708+ ;
709+ throw new Error("Failed pattern match at Data.List.Types (line 111, column 12 - line 113, column 30): " + [v.constructor.name]);
710+ }
711+ ;
712+ while (!$tco_done1) {
713+ $tco_result = $tco_loop($tco_var_b, $copy_v);
714+ }
715+ ;
716+ return $tco_result;
717+ };
718+ };
719+ return go;
720+ },
721+ foldMap: function(dictMonoid) {
722+ var append2 = append(dictMonoid.Semigroup0());
723+ var mempty3 = mempty(dictMonoid);
724+ return function(f) {
725+ return foldl(foldableList)(function(acc) {
726+ var $286 = append2(acc);
727+ return function($287) {
728+ return $286(f($287));
729+ };
730+ })(mempty3);
731+ };
732+ }
733+ };
734+ var foldr2 = /* @__PURE__ */ foldr(foldableList);
735+ var semigroupList = {
736+ append: function(xs) {
737+ return function(ys) {
738+ return foldr2(Cons.create)(ys)(xs);
739+ };
740+ }
741+ };
742+ var append1 = /* @__PURE__ */ append(semigroupList);
743+ var altList = {
744+ alt: append1,
745+ Functor0: function() {
746+ return functorList;
747+ }
748+ };
749+ var plusList = /* @__PURE__ */ function() {
750+ return {
751+ empty: Nil.value,
752+ Alt0: function() {
753+ return altList;
754+ }
755+ };
756+ }();
757+
758+ // output/Effect.Aff/foreign.js
759+ var Aff = function() {
760+ var EMPTY = {};
761+ var PURE = "Pure";
762+ var THROW = "Throw";
763+ var CATCH = "Catch";
764+ var SYNC = "Sync";
765+ var ASYNC = "Async";
766+ var BIND = "Bind";
767+ var BRACKET = "Bracket";
768+ var FORK = "Fork";
769+ var SEQ = "Sequential";
770+ var MAP = "Map";
771+ var APPLY = "Apply";
772+ var ALT = "Alt";
773+ var CONS = "Cons";
774+ var RESUME = "Resume";
775+ var RELEASE = "Release";
776+ var FINALIZER = "Finalizer";
777+ var FINALIZED = "Finalized";
778+ var FORKED = "Forked";
779+ var FIBER = "Fiber";
780+ var THUNK = "Thunk";
781+ function Aff2(tag, _1, _2, _3) {
782+ this.tag = tag;
783+ this._1 = _1;
784+ this._2 = _2;
785+ this._3 = _3;
786+ }
787+ function AffCtr(tag) {
788+ var fn = function(_1, _2, _3) {
789+ return new Aff2(tag, _1, _2, _3);
790+ };
791+ fn.tag = tag;
792+ return fn;
793+ }
794+ function nonCanceler2(error3) {
795+ return new Aff2(PURE, void 0);
796+ }
797+ function runEff(eff) {
798+ try {
799+ eff();
800+ } catch (error3) {
801+ setTimeout(function() {
802+ throw error3;
803+ }, 0);
804+ }
805+ }
806+ function runSync(left, right, eff) {
807+ try {
808+ return right(eff());
809+ } catch (error3) {
810+ return left(error3);
811+ }
812+ }
813+ function runAsync(left, eff, k) {
814+ try {
815+ return eff(k)();
816+ } catch (error3) {
817+ k(left(error3))();
818+ return nonCanceler2;
819+ }
820+ }
821+ var Scheduler = function() {
822+ var limit = 1024;
823+ var size = 0;
824+ var ix = 0;
825+ var queue = new Array(limit);
826+ var draining = false;
827+ function drain() {
828+ var thunk;
829+ draining = true;
830+ while (size !== 0) {
831+ size--;
832+ thunk = queue[ix];
833+ queue[ix] = void 0;
834+ ix = (ix + 1) % limit;
835+ thunk();
836+ }
837+ draining = false;
838+ }
839+ return {
840+ isDraining: function() {
841+ return draining;
842+ },
843+ enqueue: function(cb) {
844+ var i, tmp;
845+ if (size === limit) {
846+ tmp = draining;
847+ drain();
848+ draining = tmp;
849+ }
850+ queue[(ix + size) % limit] = cb;
851+ size++;
852+ if (!draining) {
853+ drain();
854+ }
855+ }
856+ };
857+ }();
858+ function Supervisor(util) {
859+ var fibers = {};
860+ var fiberId = 0;
861+ var count = 0;
862+ return {
863+ register: function(fiber) {
864+ var fid = fiberId++;
865+ fiber.onComplete({
866+ rethrow: true,
867+ handler: function(result) {
868+ return function() {
869+ count--;
870+ delete fibers[fid];
871+ };
872+ }
873+ })();
874+ fibers[fid] = fiber;
875+ count++;
876+ },
877+ isEmpty: function() {
878+ return count === 0;
879+ },
880+ killAll: function(killError, cb) {
881+ return function() {
882+ if (count === 0) {
883+ return cb();
884+ }
885+ var killCount = 0;
886+ var kills = {};
887+ function kill(fid) {
888+ kills[fid] = fibers[fid].kill(killError, function(result) {
889+ return function() {
890+ delete kills[fid];
891+ killCount--;
892+ if (util.isLeft(result) && util.fromLeft(result)) {
893+ setTimeout(function() {
894+ throw util.fromLeft(result);
895+ }, 0);
896+ }
897+ if (killCount === 0) {
898+ cb();
899+ }
900+ };
901+ })();
902+ }
903+ for (var k in fibers) {
904+ if (fibers.hasOwnProperty(k)) {
905+ killCount++;
906+ kill(k);
907+ }
908+ }
909+ fibers = {};
910+ fiberId = 0;
911+ count = 0;
912+ return function(error3) {
913+ return new Aff2(SYNC, function() {
914+ for (var k2 in kills) {
915+ if (kills.hasOwnProperty(k2)) {
916+ kills[k2]();
917+ }
918+ }
919+ });
920+ };
921+ };
922+ }
923+ };
924+ }
925+ var SUSPENDED = 0;
926+ var CONTINUE = 1;
927+ var STEP_BIND = 2;
928+ var STEP_RESULT = 3;
929+ var PENDING = 4;
930+ var RETURN = 5;
931+ var COMPLETED = 6;
932+ function Fiber(util, supervisor, aff) {
933+ var runTick = 0;
934+ var status = SUSPENDED;
935+ var step = aff;
936+ var fail2 = null;
937+ var interrupt = null;
938+ var bhead = null;
939+ var btail = null;
940+ var attempts = null;
941+ var bracketCount = 0;
942+ var joinId = 0;
943+ var joins = null;
944+ var rethrow = true;
945+ function run2(localRunTick) {
946+ var tmp, result, attempt;
947+ while (true) {
948+ tmp = null;
949+ result = null;
950+ attempt = null;
951+ switch (status) {
952+ case STEP_BIND:
953+ status = CONTINUE;
954+ try {
955+ step = bhead(step);
956+ if (btail === null) {
957+ bhead = null;
958+ } else {
959+ bhead = btail._1;
960+ btail = btail._2;
961+ }
962+ } catch (e) {
963+ status = RETURN;
964+ fail2 = util.left(e);
965+ step = null;
966+ }
967+ break;
968+ case STEP_RESULT:
969+ if (util.isLeft(step)) {
970+ status = RETURN;
971+ fail2 = step;
972+ step = null;
973+ } else if (bhead === null) {
974+ status = RETURN;
975+ } else {
976+ status = STEP_BIND;
977+ step = util.fromRight(step);
978+ }
979+ break;
980+ case CONTINUE:
981+ switch (step.tag) {
982+ case BIND:
983+ if (bhead) {
984+ btail = new Aff2(CONS, bhead, btail);
985+ }
986+ bhead = step._2;
987+ status = CONTINUE;
988+ step = step._1;
989+ break;
990+ case PURE:
991+ if (bhead === null) {
992+ status = RETURN;
993+ step = util.right(step._1);
994+ } else {
995+ status = STEP_BIND;
996+ step = step._1;
997+ }
998+ break;
999+ case SYNC:
1000+ status = STEP_RESULT;
1001+ step = runSync(util.left, util.right, step._1);
1002+ break;
1003+ case ASYNC:
1004+ status = PENDING;
1005+ step = runAsync(util.left, step._1, function(result2) {
1006+ return function() {
1007+ if (runTick !== localRunTick) {
1008+ return;
1009+ }
1010+ runTick++;
1011+ Scheduler.enqueue(function() {
1012+ if (runTick !== localRunTick + 1) {
1013+ return;
1014+ }
1015+ status = STEP_RESULT;
1016+ step = result2;
1017+ run2(runTick);
1018+ });
1019+ };
1020+ });
1021+ return;
1022+ case THROW:
1023+ status = RETURN;
1024+ fail2 = util.left(step._1);
1025+ step = null;
1026+ break;
1027+ // Enqueue the Catch so that we can call the error handler later on
1028+ // in case of an exception.
1029+ case CATCH:
1030+ if (bhead === null) {
1031+ attempts = new Aff2(CONS, step, attempts, interrupt);
1032+ } else {
1033+ attempts = new Aff2(CONS, step, new Aff2(CONS, new Aff2(RESUME, bhead, btail), attempts, interrupt), interrupt);
1034+ }
1035+ bhead = null;
1036+ btail = null;
1037+ status = CONTINUE;
1038+ step = step._1;
1039+ break;
1040+ // Enqueue the Bracket so that we can call the appropriate handlers
1041+ // after resource acquisition.
1042+ case BRACKET:
1043+ bracketCount++;
1044+ if (bhead === null) {
1045+ attempts = new Aff2(CONS, step, attempts, interrupt);
1046+ } else {
1047+ attempts = new Aff2(CONS, step, new Aff2(CONS, new Aff2(RESUME, bhead, btail), attempts, interrupt), interrupt);
1048+ }
1049+ bhead = null;
1050+ btail = null;
1051+ status = CONTINUE;
1052+ step = step._1;
1053+ break;
1054+ case FORK:
1055+ status = STEP_RESULT;
1056+ tmp = Fiber(util, supervisor, step._2);
1057+ if (supervisor) {
1058+ supervisor.register(tmp);
1059+ }
1060+ if (step._1) {
1061+ tmp.run();
1062+ }
1063+ step = util.right(tmp);
1064+ break;
1065+ case SEQ:
1066+ status = CONTINUE;
1067+ step = sequential2(util, supervisor, step._1);
1068+ break;
1069+ }
1070+ break;
1071+ case RETURN:
1072+ bhead = null;
1073+ btail = null;
1074+ if (attempts === null) {
1075+ status = COMPLETED;
1076+ step = interrupt || fail2 || step;
1077+ } else {
1078+ tmp = attempts._3;
1079+ attempt = attempts._1;
1080+ attempts = attempts._2;
1081+ switch (attempt.tag) {
1082+ // We cannot recover from an unmasked interrupt. Otherwise we should
1083+ // continue stepping, or run the exception handler if an exception
1084+ // was raised.
1085+ case CATCH:
1086+ if (interrupt && interrupt !== tmp && bracketCount === 0) {
1087+ status = RETURN;
1088+ } else if (fail2) {
1089+ status = CONTINUE;
1090+ step = attempt._2(util.fromLeft(fail2));
1091+ fail2 = null;
1092+ }
1093+ break;
1094+ // We cannot resume from an unmasked interrupt or exception.
1095+ case RESUME:
1096+ if (interrupt && interrupt !== tmp && bracketCount === 0 || fail2) {
1097+ status = RETURN;
1098+ } else {
1099+ bhead = attempt._1;
1100+ btail = attempt._2;
1101+ status = STEP_BIND;
1102+ step = util.fromRight(step);
1103+ }
1104+ break;
1105+ // If we have a bracket, we should enqueue the handlers,
1106+ // and continue with the success branch only if the fiber has
1107+ // not been interrupted. If the bracket acquisition failed, we
1108+ // should not run either.
1109+ case BRACKET:
1110+ bracketCount--;
1111+ if (fail2 === null) {
1112+ result = util.fromRight(step);
1113+ attempts = new Aff2(CONS, new Aff2(RELEASE, attempt._2, result), attempts, tmp);
1114+ if (interrupt === tmp || bracketCount > 0) {
1115+ status = CONTINUE;
1116+ step = attempt._3(result);
1117+ }
1118+ }
1119+ break;
1120+ // Enqueue the appropriate handler. We increase the bracket count
1121+ // because it should not be cancelled.
1122+ case RELEASE:
1123+ attempts = new Aff2(CONS, new Aff2(FINALIZED, step, fail2), attempts, interrupt);
1124+ status = CONTINUE;
1125+ if (interrupt && interrupt !== tmp && bracketCount === 0) {
1126+ step = attempt._1.killed(util.fromLeft(interrupt))(attempt._2);
1127+ } else if (fail2) {
1128+ step = attempt._1.failed(util.fromLeft(fail2))(attempt._2);
1129+ } else {
1130+ step = attempt._1.completed(util.fromRight(step))(attempt._2);
1131+ }
1132+ fail2 = null;
1133+ bracketCount++;
1134+ break;
1135+ case FINALIZER:
1136+ bracketCount++;
1137+ attempts = new Aff2(CONS, new Aff2(FINALIZED, step, fail2), attempts, interrupt);
1138+ status = CONTINUE;
1139+ step = attempt._1;
1140+ break;
1141+ case FINALIZED:
1142+ bracketCount--;
1143+ status = RETURN;
1144+ step = attempt._1;
1145+ fail2 = attempt._2;
1146+ break;
1147+ }
1148+ }
1149+ break;
1150+ case COMPLETED:
1151+ for (var k in joins) {
1152+ if (joins.hasOwnProperty(k)) {
1153+ rethrow = rethrow && joins[k].rethrow;
1154+ runEff(joins[k].handler(step));
1155+ }
1156+ }
1157+ joins = null;
1158+ if (interrupt && fail2) {
1159+ setTimeout(function() {
1160+ throw util.fromLeft(fail2);
1161+ }, 0);
1162+ } else if (util.isLeft(step) && rethrow) {
1163+ setTimeout(function() {
1164+ if (rethrow) {
1165+ throw util.fromLeft(step);
1166+ }
1167+ }, 0);
1168+ }
1169+ return;
1170+ case SUSPENDED:
1171+ status = CONTINUE;
1172+ break;
1173+ case PENDING:
1174+ return;
1175+ }
1176+ }
1177+ }
1178+ function onComplete(join3) {
1179+ return function() {
1180+ if (status === COMPLETED) {
1181+ rethrow = rethrow && join3.rethrow;
1182+ join3.handler(step)();
1183+ return function() {
1184+ };
1185+ }
1186+ var jid = joinId++;
1187+ joins = joins || {};
1188+ joins[jid] = join3;
1189+ return function() {
1190+ if (joins !== null) {
1191+ delete joins[jid];
1192+ }
1193+ };
1194+ };
1195+ }
1196+ function kill(error3, cb) {
1197+ return function() {
1198+ if (status === COMPLETED) {
1199+ cb(util.right(void 0))();
1200+ return function() {
1201+ };
1202+ }
1203+ var canceler = onComplete({
1204+ rethrow: false,
1205+ handler: function() {
1206+ return cb(util.right(void 0));
1207+ }
1208+ })();
1209+ switch (status) {
1210+ case SUSPENDED:
1211+ interrupt = util.left(error3);
1212+ status = COMPLETED;
1213+ step = interrupt;
1214+ run2(runTick);
1215+ break;
1216+ case PENDING:
1217+ if (interrupt === null) {
1218+ interrupt = util.left(error3);
1219+ }
1220+ if (bracketCount === 0) {
1221+ if (status === PENDING) {
1222+ attempts = new Aff2(CONS, new Aff2(FINALIZER, step(error3)), attempts, interrupt);
1223+ }
1224+ status = RETURN;
1225+ step = null;
1226+ fail2 = null;
1227+ run2(++runTick);
1228+ }
1229+ break;
1230+ default:
1231+ if (interrupt === null) {
1232+ interrupt = util.left(error3);
1233+ }
1234+ if (bracketCount === 0) {
1235+ status = RETURN;
1236+ step = null;
1237+ fail2 = null;
1238+ }
1239+ }
1240+ return canceler;
1241+ };
1242+ }
1243+ function join2(cb) {
1244+ return function() {
1245+ var canceler = onComplete({
1246+ rethrow: false,
1247+ handler: cb
1248+ })();
1249+ if (status === SUSPENDED) {
1250+ run2(runTick);
1251+ }
1252+ return canceler;
1253+ };
1254+ }
1255+ return {
1256+ kill,
1257+ join: join2,
1258+ onComplete,
1259+ isSuspended: function() {
1260+ return status === SUSPENDED;
1261+ },
1262+ run: function() {
1263+ if (status === SUSPENDED) {
1264+ if (!Scheduler.isDraining()) {
1265+ Scheduler.enqueue(function() {
1266+ run2(runTick);
1267+ });
1268+ } else {
1269+ run2(runTick);
1270+ }
1271+ }
1272+ }
1273+ };
1274+ }
1275+ function runPar(util, supervisor, par, cb) {
1276+ var fiberId = 0;
1277+ var fibers = {};
1278+ var killId = 0;
1279+ var kills = {};
1280+ var early = new Error("[ParAff] Early exit");
1281+ var interrupt = null;
1282+ var root = EMPTY;
1283+ function kill(error3, par2, cb2) {
1284+ var step = par2;
1285+ var head = null;
1286+ var tail = null;
1287+ var count = 0;
1288+ var kills2 = {};
1289+ var tmp, kid;
1290+ loop: while (true) {
1291+ tmp = null;
1292+ switch (step.tag) {
1293+ case FORKED:
1294+ if (step._3 === EMPTY) {
1295+ tmp = fibers[step._1];
1296+ kills2[count++] = tmp.kill(error3, function(result) {
1297+ return function() {
1298+ count--;
1299+ if (count === 0) {
1300+ cb2(result)();
1301+ }
1302+ };
1303+ });
1304+ }
1305+ if (head === null) {
1306+ break loop;
1307+ }
1308+ step = head._2;
1309+ if (tail === null) {
1310+ head = null;
1311+ } else {
1312+ head = tail._1;
1313+ tail = tail._2;
1314+ }
1315+ break;
1316+ case MAP:
1317+ step = step._2;
1318+ break;
1319+ case APPLY:
1320+ case ALT:
1321+ if (head) {
1322+ tail = new Aff2(CONS, head, tail);
1323+ }
1324+ head = step;
1325+ step = step._1;
1326+ break;
1327+ }
1328+ }
1329+ if (count === 0) {
1330+ cb2(util.right(void 0))();
1331+ } else {
1332+ kid = 0;
1333+ tmp = count;
1334+ for (; kid < tmp; kid++) {
1335+ kills2[kid] = kills2[kid]();
1336+ }
1337+ }
1338+ return kills2;
1339+ }
1340+ function join2(result, head, tail) {
1341+ var fail2, step, lhs, rhs, tmp, kid;
1342+ if (util.isLeft(result)) {
1343+ fail2 = result;
1344+ step = null;
1345+ } else {
1346+ step = result;
1347+ fail2 = null;
1348+ }
1349+ loop: while (true) {
1350+ lhs = null;
1351+ rhs = null;
1352+ tmp = null;
1353+ kid = null;
1354+ if (interrupt !== null) {
1355+ return;
1356+ }
1357+ if (head === null) {
1358+ cb(fail2 || step)();
1359+ return;
1360+ }
1361+ if (head._3 !== EMPTY) {
1362+ return;
1363+ }
1364+ switch (head.tag) {
1365+ case MAP:
1366+ if (fail2 === null) {
1367+ head._3 = util.right(head._1(util.fromRight(step)));
1368+ step = head._3;
1369+ } else {
1370+ head._3 = fail2;
1371+ }
1372+ break;
1373+ case APPLY:
1374+ lhs = head._1._3;
1375+ rhs = head._2._3;
1376+ if (fail2) {
1377+ head._3 = fail2;
1378+ tmp = true;
1379+ kid = killId++;
1380+ kills[kid] = kill(early, fail2 === lhs ? head._2 : head._1, function() {
1381+ return function() {
1382+ delete kills[kid];
1383+ if (tmp) {
1384+ tmp = false;
1385+ } else if (tail === null) {
1386+ join2(fail2, null, null);
1387+ } else {
1388+ join2(fail2, tail._1, tail._2);
1389+ }
1390+ };
1391+ });
1392+ if (tmp) {
1393+ tmp = false;
1394+ return;
1395+ }
1396+ } else if (lhs === EMPTY || rhs === EMPTY) {
1397+ return;
1398+ } else {
1399+ step = util.right(util.fromRight(lhs)(util.fromRight(rhs)));
1400+ head._3 = step;
1401+ }
1402+ break;
1403+ case ALT:
1404+ lhs = head._1._3;
1405+ rhs = head._2._3;
1406+ if (lhs === EMPTY && util.isLeft(rhs) || rhs === EMPTY && util.isLeft(lhs)) {
1407+ return;
1408+ }
1409+ if (lhs !== EMPTY && util.isLeft(lhs) && rhs !== EMPTY && util.isLeft(rhs)) {
1410+ fail2 = step === lhs ? rhs : lhs;
1411+ step = null;
1412+ head._3 = fail2;
1413+ } else {
1414+ head._3 = step;
1415+ tmp = true;
1416+ kid = killId++;
1417+ kills[kid] = kill(early, step === lhs ? head._2 : head._1, function() {
1418+ return function() {
1419+ delete kills[kid];
1420+ if (tmp) {
1421+ tmp = false;
1422+ } else if (tail === null) {
1423+ join2(step, null, null);
1424+ } else {
1425+ join2(step, tail._1, tail._2);
1426+ }
1427+ };
1428+ });
1429+ if (tmp) {
1430+ tmp = false;
1431+ return;
1432+ }
1433+ }
1434+ break;
1435+ }
1436+ if (tail === null) {
1437+ head = null;
1438+ } else {
1439+ head = tail._1;
1440+ tail = tail._2;
1441+ }
1442+ }
1443+ }
1444+ function resolve(fiber) {
1445+ return function(result) {
1446+ return function() {
1447+ delete fibers[fiber._1];
1448+ fiber._3 = result;
1449+ join2(result, fiber._2._1, fiber._2._2);
1450+ };
1451+ };
1452+ }
1453+ function run2() {
1454+ var status = CONTINUE;
1455+ var step = par;
1456+ var head = null;
1457+ var tail = null;
1458+ var tmp, fid;
1459+ loop: while (true) {
1460+ tmp = null;
1461+ fid = null;
1462+ switch (status) {
1463+ case CONTINUE:
1464+ switch (step.tag) {
1465+ case MAP:
1466+ if (head) {
1467+ tail = new Aff2(CONS, head, tail);
1468+ }
1469+ head = new Aff2(MAP, step._1, EMPTY, EMPTY);
1470+ step = step._2;
1471+ break;
1472+ case APPLY:
1473+ if (head) {
1474+ tail = new Aff2(CONS, head, tail);
1475+ }
1476+ head = new Aff2(APPLY, EMPTY, step._2, EMPTY);
1477+ step = step._1;
1478+ break;
1479+ case ALT:
1480+ if (head) {
1481+ tail = new Aff2(CONS, head, tail);
1482+ }
1483+ head = new Aff2(ALT, EMPTY, step._2, EMPTY);
1484+ step = step._1;
1485+ break;
1486+ default:
1487+ fid = fiberId++;
1488+ status = RETURN;
1489+ tmp = step;
1490+ step = new Aff2(FORKED, fid, new Aff2(CONS, head, tail), EMPTY);
1491+ tmp = Fiber(util, supervisor, tmp);
1492+ tmp.onComplete({
1493+ rethrow: false,
1494+ handler: resolve(step)
1495+ })();
1496+ fibers[fid] = tmp;
1497+ if (supervisor) {
1498+ supervisor.register(tmp);
1499+ }
1500+ }
1501+ break;
1502+ case RETURN:
1503+ if (head === null) {
1504+ break loop;
1505+ }
1506+ if (head._1 === EMPTY) {
1507+ head._1 = step;
1508+ status = CONTINUE;
1509+ step = head._2;
1510+ head._2 = EMPTY;
1511+ } else {
1512+ head._2 = step;
1513+ step = head;
1514+ if (tail === null) {
1515+ head = null;
1516+ } else {
1517+ head = tail._1;
1518+ tail = tail._2;
1519+ }
1520+ }
1521+ }
1522+ }
1523+ root = step;
1524+ for (fid = 0; fid < fiberId; fid++) {
1525+ fibers[fid].run();
1526+ }
1527+ }
1528+ function cancel(error3, cb2) {
1529+ interrupt = util.left(error3);
1530+ var innerKills;
1531+ for (var kid in kills) {
1532+ if (kills.hasOwnProperty(kid)) {
1533+ innerKills = kills[kid];
1534+ for (kid in innerKills) {
1535+ if (innerKills.hasOwnProperty(kid)) {
1536+ innerKills[kid]();
1537+ }
1538+ }
1539+ }
1540+ }
1541+ kills = null;
1542+ var newKills = kill(error3, root, cb2);
1543+ return function(killError) {
1544+ return new Aff2(ASYNC, function(killCb) {
1545+ return function() {
1546+ for (var kid2 in newKills) {
1547+ if (newKills.hasOwnProperty(kid2)) {
1548+ newKills[kid2]();
1549+ }
1550+ }
1551+ return nonCanceler2;
1552+ };
1553+ });
1554+ };
1555+ }
1556+ run2();
1557+ return function(killError) {
1558+ return new Aff2(ASYNC, function(killCb) {
1559+ return function() {
1560+ return cancel(killError, killCb);
1561+ };
1562+ });
1563+ };
1564+ }
1565+ function sequential2(util, supervisor, par) {
1566+ return new Aff2(ASYNC, function(cb) {
1567+ return function() {
1568+ return runPar(util, supervisor, par, cb);
1569+ };
1570+ });
1571+ }
1572+ Aff2.EMPTY = EMPTY;
1573+ Aff2.Pure = AffCtr(PURE);
1574+ Aff2.Throw = AffCtr(THROW);
1575+ Aff2.Catch = AffCtr(CATCH);
1576+ Aff2.Sync = AffCtr(SYNC);
1577+ Aff2.Async = AffCtr(ASYNC);
1578+ Aff2.Bind = AffCtr(BIND);
1579+ Aff2.Bracket = AffCtr(BRACKET);
1580+ Aff2.Fork = AffCtr(FORK);
1581+ Aff2.Seq = AffCtr(SEQ);
1582+ Aff2.ParMap = AffCtr(MAP);
1583+ Aff2.ParApply = AffCtr(APPLY);
1584+ Aff2.ParAlt = AffCtr(ALT);
1585+ Aff2.Fiber = Fiber;
1586+ Aff2.Supervisor = Supervisor;
1587+ Aff2.Scheduler = Scheduler;
1588+ Aff2.nonCanceler = nonCanceler2;
1589+ return Aff2;
1590+ }();
1591+ var _pure = Aff.Pure;
1592+ var _throwError = Aff.Throw;
1593+ function _catchError(aff) {
1594+ return function(k) {
1595+ return Aff.Catch(aff, k);
1596+ };
1597+ }
1598+ function _map(f) {
1599+ return function(aff) {
1600+ if (aff.tag === Aff.Pure.tag) {
1601+ return Aff.Pure(f(aff._1));
1602+ } else {
1603+ return Aff.Bind(aff, function(value) {
1604+ return Aff.Pure(f(value));
1605+ });
1606+ }
1607+ };
1608+ }
1609+ function _bind(aff) {
1610+ return function(k) {
1611+ return Aff.Bind(aff, k);
1612+ };
1613+ }
1614+ var _liftEffect = Aff.Sync;
1615+ function _parAffMap(f) {
1616+ return function(aff) {
1617+ return Aff.ParMap(f, aff);
1618+ };
1619+ }
1620+ function _parAffApply(aff1) {
1621+ return function(aff2) {
1622+ return Aff.ParApply(aff1, aff2);
1623+ };
1624+ }
1625+ var makeAff = Aff.Async;
1626+ function _makeFiber(util, aff) {
1627+ return function() {
1628+ return Aff.Fiber(util, null, aff);
1629+ };
1630+ }
1631+ var _sequential = Aff.Seq;
1632+
1633+ // output/Control.Parallel.Class/index.js
1634+ var sequential = function(dict) {
1635+ return dict.sequential;
1636+ };
1637+ var parallel = function(dict) {
1638+ return dict.parallel;
1639+ };
1640+
1641+ // output/Control.Parallel/index.js
1642+ var identity3 = /* @__PURE__ */ identity(categoryFn);
1643+ var parTraverse_ = function(dictParallel) {
1644+ var sequential2 = sequential(dictParallel);
1645+ var parallel3 = parallel(dictParallel);
1646+ return function(dictApplicative) {
1647+ var traverse_2 = traverse_(dictApplicative);
1648+ return function(dictFoldable) {
1649+ var traverse_1 = traverse_2(dictFoldable);
1650+ return function(f) {
1651+ var $51 = traverse_1(function($53) {
1652+ return parallel3(f($53));
1653+ });
1654+ return function($52) {
1655+ return sequential2($51($52));
1656+ };
1657+ };
1658+ };
1659+ };
1660+ };
1661+ var parSequence_ = function(dictParallel) {
1662+ var parTraverse_1 = parTraverse_(dictParallel);
1663+ return function(dictApplicative) {
1664+ var parTraverse_2 = parTraverse_1(dictApplicative);
1665+ return function(dictFoldable) {
1666+ return parTraverse_2(dictFoldable)(identity3);
1667+ };
1668+ };
1669+ };
1670+
1671+ // output/Partial.Unsafe/foreign.js
1672+ var _unsafePartial = function(f) {
1673+ return f();
1674+ };
1675+
1676+ // output/Partial/foreign.js
1677+ var _crashWith = function(msg) {
1678+ throw new Error(msg);
1679+ };
1680+
1681+ // output/Partial/index.js
1682+ var crashWith = function() {
1683+ return _crashWith;
1684+ };
1685+
1686+ // output/Partial.Unsafe/index.js
1687+ var crashWith2 = /* @__PURE__ */ crashWith();
1688+ var unsafePartial = _unsafePartial;
1689+ var unsafeCrashWith = function(msg) {
1690+ return unsafePartial(function() {
1691+ return crashWith2(msg);
1692+ });
1693+ };
1694+
1695+ // output/Effect.Aff/index.js
1696+ var $runtime_lazy2 = function(name2, moduleName, init2) {
1697+ var state2 = 0;
1698+ var val;
1699+ return function(lineNumber) {
1700+ if (state2 === 2) return val;
1701+ if (state2 === 1) throw new ReferenceError(name2 + " was needed before it finished initializing (module " + moduleName + ", line " + lineNumber + ")", moduleName, lineNumber);
1702+ state2 = 1;
1703+ val = init2();
1704+ state2 = 2;
1705+ return val;
1706+ };
1707+ };
1708+ var $$void2 = /* @__PURE__ */ $$void(functorEffect);
1709+ var functorParAff = {
1710+ map: _parAffMap
1711+ };
1712+ var functorAff = {
1713+ map: _map
1714+ };
1715+ var ffiUtil = /* @__PURE__ */ function() {
1716+ var unsafeFromRight = function(v) {
1717+ if (v instanceof Right) {
1718+ return v.value0;
1719+ }
1720+ ;
1721+ if (v instanceof Left) {
1722+ return unsafeCrashWith("unsafeFromRight: Left");
1723+ }
1724+ ;
1725+ throw new Error("Failed pattern match at Effect.Aff (line 412, column 21 - line 414, column 54): " + [v.constructor.name]);
1726+ };
1727+ var unsafeFromLeft = function(v) {
1728+ if (v instanceof Left) {
1729+ return v.value0;
1730+ }
1731+ ;
1732+ if (v instanceof Right) {
1733+ return unsafeCrashWith("unsafeFromLeft: Right");
1734+ }
1735+ ;
1736+ throw new Error("Failed pattern match at Effect.Aff (line 407, column 20 - line 409, column 55): " + [v.constructor.name]);
1737+ };
1738+ var isLeft = function(v) {
1739+ if (v instanceof Left) {
1740+ return true;
1741+ }
1742+ ;
1743+ if (v instanceof Right) {
1744+ return false;
1745+ }
1746+ ;
1747+ throw new Error("Failed pattern match at Effect.Aff (line 402, column 12 - line 404, column 21): " + [v.constructor.name]);
1748+ };
1749+ return {
1750+ isLeft,
1751+ fromLeft: unsafeFromLeft,
1752+ fromRight: unsafeFromRight,
1753+ left: Left.create,
1754+ right: Right.create
1755+ };
1756+ }();
1757+ var makeFiber = function(aff) {
1758+ return _makeFiber(ffiUtil, aff);
1759+ };
1760+ var launchAff = function(aff) {
1761+ return function __do() {
1762+ var fiber = makeFiber(aff)();
1763+ fiber.run();
1764+ return fiber;
1765+ };
1766+ };
1767+ var applyParAff = {
1768+ apply: _parAffApply,
1769+ Functor0: function() {
1770+ return functorParAff;
1771+ }
1772+ };
1773+ var monadAff = {
1774+ Applicative0: function() {
1775+ return applicativeAff;
1776+ },
1777+ Bind1: function() {
1778+ return bindAff;
1779+ }
1780+ };
1781+ var bindAff = {
1782+ bind: _bind,
1783+ Apply0: function() {
1784+ return $lazy_applyAff(0);
1785+ }
1786+ };
1787+ var applicativeAff = {
1788+ pure: _pure,
1789+ Apply0: function() {
1790+ return $lazy_applyAff(0);
1791+ }
1792+ };
1793+ var $lazy_applyAff = /* @__PURE__ */ $runtime_lazy2("applyAff", "Effect.Aff", function() {
1794+ return {
1795+ apply: ap(monadAff),
1796+ Functor0: function() {
1797+ return functorAff;
1798+ }
1799+ };
1800+ });
1801+ var applyAff = /* @__PURE__ */ $lazy_applyAff(73);
1802+ var pure2 = /* @__PURE__ */ pure(applicativeAff);
1803+ var bindFlipped2 = /* @__PURE__ */ bindFlipped(bindAff);
1804+ var parallelAff = {
1805+ parallel: unsafeCoerce2,
1806+ sequential: _sequential,
1807+ Apply0: function() {
1808+ return applyAff;
1809+ },
1810+ Apply1: function() {
1811+ return applyParAff;
1812+ }
1813+ };
1814+ var parallel2 = /* @__PURE__ */ parallel(parallelAff);
1815+ var applicativeParAff = {
1816+ pure: function($76) {
1817+ return parallel2(pure2($76));
1818+ },
1819+ Apply0: function() {
1820+ return applyParAff;
1821+ }
1822+ };
1823+ var parSequence_2 = /* @__PURE__ */ parSequence_(parallelAff)(applicativeParAff)(foldableArray);
1824+ var semigroupCanceler = {
1825+ append: function(v) {
1826+ return function(v1) {
1827+ return function(err) {
1828+ return parSequence_2([v(err), v1(err)]);
1829+ };
1830+ };
1831+ }
1832+ };
1833+ var monadEffectAff = {
1834+ liftEffect: _liftEffect,
1835+ Monad0: function() {
1836+ return monadAff;
1837+ }
1838+ };
1839+ var liftEffect2 = /* @__PURE__ */ liftEffect(monadEffectAff);
1840+ var monadThrowAff = {
1841+ throwError: _throwError,
1842+ Monad0: function() {
1843+ return monadAff;
1844+ }
1845+ };
1846+ var monadErrorAff = {
1847+ catchError: _catchError,
1848+ MonadThrow0: function() {
1849+ return monadThrowAff;
1850+ }
1851+ };
1852+ var $$try2 = /* @__PURE__ */ $$try(monadErrorAff);
1853+ var runAff = function(k) {
1854+ return function(aff) {
1855+ return launchAff(bindFlipped2(function($83) {
1856+ return liftEffect2(k($83));
1857+ })($$try2(aff)));
1858+ };
1859+ };
1860+ var runAff_ = function(k) {
1861+ return function(aff) {
1862+ return $$void2(runAff(k)(aff));
1863+ };
1864+ };
1865+ var nonCanceler = /* @__PURE__ */ $$const(/* @__PURE__ */ pure2(unit));
1866+ var monoidCanceler = {
1867+ mempty: nonCanceler,
1868+ Semigroup0: function() {
1869+ return semigroupCanceler;
1870+ }
1871+ };
1872+
1873+ // output/Foreign/foreign.js
1874+ function typeOf(value) {
1875+ return typeof value;
1876+ }
1877+ function tagOf(value) {
1878+ return Object.prototype.toString.call(value).slice(8, -1);
1879+ }
1880+ var isArray = Array.isArray || function(value) {
1881+ return Object.prototype.toString.call(value) === "[object Array]";
1882+ };
1883+
1884+ // output/Data.List.NonEmpty/index.js
1885+ var singleton3 = /* @__PURE__ */ function() {
1886+ var $200 = singleton2(plusList);
1887+ return function($201) {
1888+ return NonEmptyList($200($201));
1889+ };
1890+ }();
1891+
1892+ // output/Foreign/index.js
1893+ var TypeMismatch = /* @__PURE__ */ function() {
1894+ function TypeMismatch2(value0, value1) {
1895+ this.value0 = value0;
1896+ this.value1 = value1;
1897+ }
1898+ ;
1899+ TypeMismatch2.create = function(value0) {
1900+ return function(value1) {
1901+ return new TypeMismatch2(value0, value1);
1902+ };
1903+ };
1904+ return TypeMismatch2;
1905+ }();
1906+ var unsafeFromForeign = unsafeCoerce2;
1907+ var fail = function(dictMonad) {
1908+ var $153 = throwError(monadThrowExceptT(dictMonad));
1909+ return function($154) {
1910+ return $153(singleton3($154));
1911+ };
1912+ };
1913+ var unsafeReadTagged = function(dictMonad) {
1914+ var pure1 = pure(applicativeExceptT(dictMonad));
1915+ var fail1 = fail(dictMonad);
1916+ return function(tag) {
1917+ return function(value) {
1918+ if (tagOf(value) === tag) {
1919+ return pure1(unsafeFromForeign(value));
1920+ }
1921+ ;
1922+ if (otherwise) {
1923+ return fail1(new TypeMismatch(tag, tagOf(value)));
1924+ }
1925+ ;
1926+ throw new Error("Failed pattern match at Foreign (line 123, column 1 - line 123, column 104): " + [tag.constructor.name, value.constructor.name]);
1927+ };
1928+ };
1929+ };
1930+ var readString = function(dictMonad) {
1931+ return unsafeReadTagged(dictMonad)("String");
1932+ };
1933+
1934+ // output/Control.Promise/index.js
1935+ var voidRight2 = /* @__PURE__ */ voidRight(functorEffect);
1936+ var mempty2 = /* @__PURE__ */ mempty(monoidCanceler);
1937+ var toAff$prime = function(customCoerce) {
1938+ return function(p) {
1939+ return makeAff(function(cb) {
1940+ return voidRight2(mempty2)(thenImpl(p)(function($14) {
1941+ return cb(Left.create(customCoerce($14)))();
1942+ })(function($15) {
1943+ return cb(Right.create($15))();
1944+ }));
1945+ });
1946+ };
1947+ };
1948+
1949+ // output/Crypto.Subtle.Key.Types/foreign.js
1950+ function exportKeyImpl(f, x) {
1951+ return crypto.subtle.exportKey(f, x);
1952+ }
1953+
1954+ // output/Foreign.Index/foreign.js
1955+ function unsafeReadPropImpl(f, s, key, value) {
1956+ return value == null ? f : s(value[key]);
1957+ }
1958+
1959+ // output/Foreign.Index/index.js
1960+ var unsafeReadProp = function(dictMonad) {
1961+ var fail2 = fail(dictMonad);
1962+ var pure4 = pure(applicativeExceptT(dictMonad));
1963+ return function(k) {
1964+ return function(value) {
1965+ return unsafeReadPropImpl(fail2(new TypeMismatch("object", typeOf(value))), pure4, k, value);
1966+ };
1967+ };
1968+ };
1969+ var readProp = function(dictMonad) {
1970+ return unsafeReadProp(dictMonad);
1971+ };
1972+
1973+ // output/Crypto.Subtle.Key.Types/index.js
1974+ var bind2 = /* @__PURE__ */ bind(/* @__PURE__ */ bindExceptT(monadIdentity));
1975+ var readProp2 = /* @__PURE__ */ readProp(monadIdentity);
1976+ var readString2 = /* @__PURE__ */ readString(monadIdentity);
1977+ var wrapKey = "wrapKey";
1978+ var verify = "verify";
1979+ var unwrapKey = "unwrapKey";
1980+ var sign2 = "sign";
1981+ var raw = "raw";
1982+ var errorFromDOMException = function(x) {
1983+ var v = runExcept(bind2(readProp2("message")(x))(readString2));
1984+ if (v instanceof Left) {
1985+ return error("Not a DOMException");
1986+ }
1987+ ;
1988+ if (v instanceof Right) {
1989+ return error(v.value0);
1990+ }
1991+ ;
1992+ throw new Error("Failed pattern match at Crypto.Subtle.Key.Types (line 136, column 27 - line 138, column 21): " + [v.constructor.name]);
1993+ };
1994+ var exportKey = function(f) {
1995+ return function(x) {
1996+ return toAff$prime(errorFromDOMException)(exportKeyImpl(f, x));
1997+ };
1998+ };
1999+ var encrypt = "encrypt";
2000+ var deriveKey = "deriveKey";
2001+ var deriveBits = "deriveBits";
2002+ var decrypt = "decrypt";
2003+ var allUsages = [encrypt, decrypt, sign2, verify, deriveKey, deriveBits, wrapKey, unwrapKey];
2004+
2005+ // output/Crypto.Subtle.Hash/index.js
2006+ var sha512 = "SHA-512";
2007+ var sha384 = "SHA-384";
2008+ var sha256 = "SHA-256";
2009+ var sha1 = "SHA-1";
2010+
2011+ // output/Crypto.Subtle.Key.Generate/foreign.js
2012+ function generateKeyImpl(a, e, u) {
2013+ return crypto.subtle.generateKey(a, e, u);
2014+ }
2015+ var exp65537 = new Uint8Array([1, 0, 1]);
2016+
2017+ // output/Crypto.Subtle.Key.Generate/index.js
2018+ var rsa = function(r) {
2019+ return function(l) {
2020+ return function(e) {
2021+ return function(h) {
2022+ return {
2023+ name: r,
2024+ modulusLength: l,
2025+ publicExponent: e,
2026+ hash: h
2027+ };
2028+ };
2029+ };
2030+ };
2031+ };
2032+ var hmac = function(h) {
2033+ return {
2034+ name: "HMAC",
2035+ hash: h
2036+ };
2037+ };
2038+ var generateKeyPair = function(a) {
2039+ return function(e) {
2040+ return function(u) {
2041+ return toAff$prime(errorFromDOMException)(generateKeyImpl(a, e, u));
2042+ };
2043+ };
2044+ };
2045+ var generateKey = function(a) {
2046+ return function(e) {
2047+ return function(u) {
2048+ return toAff$prime(errorFromDOMException)(generateKeyImpl(a, e, u));
2049+ };
2050+ };
2051+ };
2052+ var ec = function(e) {
2053+ return function(c) {
2054+ return {
2055+ name: e,
2056+ namedCurve: c
2057+ };
2058+ };
2059+ };
2060+ var aes = function(a) {
2061+ return function(l) {
2062+ return {
2063+ name: a,
2064+ length: l
2065+ };
2066+ };
2067+ };
2068+
2069+ // output/Effect.Console/foreign.js
2070+ var log2 = function(s) {
2071+ return function() {
2072+ console.log(s);
2073+ };
2074+ };
2075+
2076+ // output/Test.Main/index.js
2077+ var pure3 = /* @__PURE__ */ pure(applicativeEffect);
2078+ var discard2 = /* @__PURE__ */ discard(discardUnit)(bindAff);
2079+ var bind3 = /* @__PURE__ */ bind(bindAff);
2080+ var bindFlipped3 = /* @__PURE__ */ bindFlipped(bindAff);
2081+ var log$prime = /* @__PURE__ */ function() {
2082+ var $38 = liftEffect(monadEffectAff);
2083+ return function($39) {
2084+ return $38(log2($39));
2085+ };
2086+ }();
2087+ var main = /* @__PURE__ */ function() {
2088+ var resolve = function(eX) {
2089+ if (eX instanceof Left) {
2090+ return throwException(eX.value0);
2091+ }
2092+ ;
2093+ if (eX instanceof Right) {
2094+ return pure3(unit);
2095+ }
2096+ ;
2097+ throw new Error("Failed pattern match at Test.Main (line 24, column 20 - line 26, column 29): " + [eX.constructor.name]);
2098+ };
2099+ return runAff_(resolve)(discard2(log$prime("Generating Keys..."))(function() {
2100+ return discard2(function() {
2101+ var genAES = function(mode) {
2102+ return discard2(bind3(bindFlipped3(exportKey(raw))(generateKey(aes(mode)(l128))(true)(allUsages)))(function(k) {
2103+ return discard2(log$prime(" - 128"))(function() {
2104+ return log$prime(k);
2105+ });
2106+ }))(function() {
2107+ return discard2(bind3(bindFlipped3(exportKey(raw))(generateKey(aes(mode)(l192))(true)(allUsages)))(function(k) {
2108+ return discard2(log$prime(" - 192"))(function() {
2109+ return log$prime(k);
2110+ });
2111+ }))(function() {
2112+ return bind3(bindFlipped3(exportKey(raw))(generateKey(aes(mode)(l256))(true)(allUsages)))(function(k) {
2113+ return discard2(log$prime(" - 256"))(function() {
2114+ return log$prime(k);
2115+ });
2116+ });
2117+ });
2118+ });
2119+ };
2120+ return discard2(log$prime("- AES-CTR"))(function() {
2121+ return discard2(genAES(aesCTR))(function() {
2122+ return discard2(log$prime("- AES-CBC"))(function() {
2123+ return discard2(genAES(aesCBC))(function() {
2124+ return discard2(log$prime("- AES-GCM"))(function() {
2125+ return discard2(genAES(aesGCM))(function() {
2126+ return discard2(log$prime("- AES-KW"))(function() {
2127+ return genAES(aesKW);
2128+ });
2129+ });
2130+ });
2131+ });
2132+ });
2133+ });
2134+ });
2135+ }())(function() {
2136+ return discard2(discard2(log$prime("HMAC"))(function() {
2137+ return discard2(bind3(bindFlipped3(exportKey(raw))(generateKey(hmac(sha1))(true)(allUsages)))(function(k) {
2138+ return discard2(log$prime(" - SHA-1"))(function() {
2139+ return log$prime(k);
2140+ });
2141+ }))(function() {
2142+ return discard2(bind3(bindFlipped3(exportKey(raw))(generateKey(hmac(sha256))(true)(allUsages)))(function(k) {
2143+ return discard2(log$prime(" - SHA-256"))(function() {
2144+ return log$prime(k);
2145+ });
2146+ }))(function() {
2147+ return discard2(bind3(bindFlipped3(exportKey(raw))(generateKey(hmac(sha384))(true)(allUsages)))(function(k) {
2148+ return discard2(log$prime(" - SHA-384"))(function() {
2149+ return log$prime(k);
2150+ });
2151+ }))(function() {
2152+ return bind3(bindFlipped3(exportKey(raw))(generateKey(hmac(sha512))(true)(allUsages)))(function(k) {
2153+ return discard2(log$prime(" - SHA-512"))(function() {
2154+ return log$prime(k);
2155+ });
2156+ });
2157+ });
2158+ });
2159+ });
2160+ }))(function() {
2161+ return discard2(function() {
2162+ var genEC = function(alg) {
2163+ return discard2(bind3(generateKeyPair(ec(alg)(p256))(true)(allUsages))(function(v) {
2164+ return discard2(log$prime(" - P-256"))(function() {
2165+ return discard2(log$prime(" - privateKey"))(function() {
2166+ return discard2(log$prime(v.privateKey))(function() {
2167+ return discard2(log$prime(" - publicKey"))(function() {
2168+ return bind3(exportKey(raw)(v.publicKey))(function(publicKey$prime) {
2169+ return log$prime(publicKey$prime);
2170+ });
2171+ });
2172+ });
2173+ });
2174+ });
2175+ }))(function() {
2176+ return discard2(bind3(generateKeyPair(ec(alg)(p384))(true)(allUsages))(function(v) {
2177+ return discard2(log$prime(" - P-384"))(function() {
2178+ return discard2(log$prime(" - privateKey"))(function() {
2179+ return discard2(log$prime(v.privateKey))(function() {
2180+ return discard2(log$prime(" - publicKey"))(function() {
2181+ return bind3(exportKey(raw)(v.publicKey))(function(publicKey$prime) {
2182+ return log$prime(publicKey$prime);
2183+ });
2184+ });
2185+ });
2186+ });
2187+ });
2188+ }))(function() {
2189+ return bind3(generateKeyPair(ec(alg)(p521))(true)(allUsages))(function(v) {
2190+ return discard2(log$prime(" - P-521"))(function() {
2191+ return discard2(log$prime(" - privateKey"))(function() {
2192+ return discard2(log$prime(v.privateKey))(function() {
2193+ return discard2(log$prime(" - publicKey"))(function() {
2194+ return bind3(exportKey(raw)(v.publicKey))(function(publicKey$prime) {
2195+ return log$prime(publicKey$prime);
2196+ });
2197+ });
2198+ });
2199+ });
2200+ });
2201+ });
2202+ });
2203+ });
2204+ };
2205+ return discard2(log$prime("- ECDSA"))(function() {
2206+ return discard2(genEC(ecdsa))(function() {
2207+ return discard2(log$prime("- ECDH"))(function() {
2208+ return genEC(ecdh);
2209+ });
2210+ });
2211+ });
2212+ }())(function() {
2213+ var genRSA = function(alg) {
2214+ return discard2(bind3(generateKeyPair(rsa(alg)(2048)(exp65537)(sha1))(true)(allUsages))(function(v) {
2215+ return discard2(log$prime(" - SHA-1"))(function() {
2216+ return discard2(log$prime(" - privateKey"))(function() {
2217+ return discard2(log$prime(v.privateKey))(function() {
2218+ return discard2(log$prime(" - publicKey"))(function() {
2219+ return log$prime(v.publicKey);
2220+ });
2221+ });
2222+ });
2223+ });
2224+ }))(function() {
2225+ return discard2(bind3(generateKeyPair(rsa(alg)(2048)(exp65537)(sha256))(true)(allUsages))(function(v) {
2226+ return discard2(log$prime(" - SHA-256"))(function() {
2227+ return discard2(log$prime(" - privateKey"))(function() {
2228+ return discard2(log$prime(v.privateKey))(function() {
2229+ return discard2(log$prime(" - publicKey"))(function() {
2230+ return log$prime(v.publicKey);
2231+ });
2232+ });
2233+ });
2234+ });
2235+ }))(function() {
2236+ return discard2(bind3(generateKeyPair(rsa(alg)(2048)(exp65537)(sha384))(true)(allUsages))(function(v) {
2237+ return discard2(log$prime(" - SHA-384"))(function() {
2238+ return discard2(log$prime(" - privateKey"))(function() {
2239+ return discard2(log$prime(v.privateKey))(function() {
2240+ return discard2(log$prime(" - publicKey"))(function() {
2241+ return log$prime(v.publicKey);
2242+ });
2243+ });
2244+ });
2245+ });
2246+ }))(function() {
2247+ return bind3(generateKeyPair(rsa(alg)(2048)(exp65537)(sha512))(true)(allUsages))(function(v) {
2248+ return discard2(log$prime(" - SHA-512"))(function() {
2249+ return discard2(log$prime(" - privateKey"))(function() {
2250+ return discard2(log$prime(v.privateKey))(function() {
2251+ return discard2(log$prime(" - publicKey"))(function() {
2252+ return log$prime(v.publicKey);
2253+ });
2254+ });
2255+ });
2256+ });
2257+ });
2258+ });
2259+ });
2260+ });
2261+ };
2262+ return discard2(log$prime("- RSASSA-PKCS1-v1_5"))(function() {
2263+ return discard2(genRSA(rsaPKCS1))(function() {
2264+ return discard2(log$prime("- RSA-PSS"))(function() {
2265+ return discard2(genRSA(rsaPSS))(function() {
2266+ return discard2(log$prime("- RSA-OAEP"))(function() {
2267+ return genRSA(rsaOAEP);
2268+ });
2269+ });
2270+ });
2271+ });
2272+ });
2273+ });
2274+ });
2275+ });
2276+ }));
2277+ }();
2278+
2279+ // <stdin>
2280+ main();
2281+})();
test.htmlnew file+9
@@ -0,0 +1,9 @@
1+<!doctype html>
2+<html>
3+ <head>
4+ <meta charset="utf-8">
5+ </head>
6+ <body>
7+ <script src="./test.browser.js"></script>
8+ </body>
9+</html>
test/Main.purs+112−1
@@ -1,9 +1,120 @@
1module Test.Main where
1module Test.Main where
2
2
3+import Crypto.Subtle.Key.Types (allUsages, CryptoKeyPair (..), exportKey, raw)
4+import Crypto.Subtle.Key.Generate (generateKey, generateKeyPair, aes, hmac, ec, rsa, exp65537)
5+import Crypto.Subtle.Constants.AES as AES
6+import Crypto.Subtle.Constants.RSA as RSA
7+import Crypto.Subtle.Constants.EC as EC
8+import Crypto.Subtle.Hash as Hash
9+
3import Prelude
10import Prelude
11+import Data.Either (Either (..))
4import Effect (Effect)
12import Effect (Effect)
13+import Effect.Exception (throwException)
14+import Effect.Class (liftEffect)
15+import Effect.Aff (Aff, runAff_)
5import Effect.Console (log)
16import Effect.Console (log)
17+import Unsafe.Coerce (unsafeCoerce)
18+
19+
20+
6
21
7main :: Effect Unit
22main :: Effect Unit
8main = do
23main = do
9− log "You should add some tests."
24+ let resolve eX = case eX of
25+ Left e -> throwException e
26+ Right _ -> pure unit
27+ runAff_ resolve do
28+ log' "Generating Keys..."
29+ do let genAES mode = do
30+ do k <- exportKey raw =<< generateKey (aes mode AES.l128) true allUsages
31+ log' " - 128"
32+ log' (unsafeCoerce k)
33+ do k <- exportKey raw =<< generateKey (aes mode AES.l192) true allUsages
34+ log' " - 192"
35+ log' (unsafeCoerce k)
36+ do k <- exportKey raw =<< generateKey (aes mode AES.l256) true allUsages
37+ log' " - 256"
38+ log' (unsafeCoerce k)
39+ log' "- AES-CTR"
40+ genAES AES.aesCTR
41+ log' "- AES-CBC"
42+ genAES AES.aesCBC
43+ log' "- AES-GCM"
44+ genAES AES.aesGCM
45+ log' "- AES-KW"
46+ genAES AES.aesKW
47+ do log' "HMAC"
48+ do k <- exportKey raw =<< generateKey (hmac Hash.sha1) true allUsages
49+ log' " - SHA-1"
50+ log' (unsafeCoerce k)
51+ do k <- exportKey raw =<< generateKey (hmac Hash.sha256) true allUsages
52+ log' " - SHA-256"
53+ log' (unsafeCoerce k)
54+ do k <- exportKey raw =<< generateKey (hmac Hash.sha384) true allUsages
55+ log' " - SHA-384"
56+ log' (unsafeCoerce k)
57+ do k <- exportKey raw =<< generateKey (hmac Hash.sha512) true allUsages
58+ log' " - SHA-512"
59+ log' (unsafeCoerce k)
60+ do let genEC alg = do
61+ do CryptoKeyPair {privateKey,publicKey} <- generateKeyPair (ec alg EC.p256) true allUsages
62+ log' " - P-256"
63+ log' " - privateKey"
64+ log' (unsafeCoerce privateKey)
65+ log' " - publicKey"
66+ publicKey' <- exportKey raw publicKey
67+ log' (unsafeCoerce publicKey')
68+ do CryptoKeyPair {privateKey,publicKey} <- generateKeyPair (ec alg EC.p384) true allUsages
69+ log' " - P-384"
70+ log' " - privateKey"
71+ log' (unsafeCoerce privateKey)
72+ log' " - publicKey"
73+ publicKey' <- exportKey raw publicKey
74+ log' (unsafeCoerce publicKey')
75+ do CryptoKeyPair {privateKey,publicKey} <- generateKeyPair (ec alg EC.p521) true allUsages
76+ log' " - P-521"
77+ log' " - privateKey"
78+ log' (unsafeCoerce privateKey)
79+ log' " - publicKey"
80+ publicKey' <- exportKey raw publicKey
81+ log' (unsafeCoerce publicKey')
82+ log' "- ECDSA"
83+ genEC EC.ecdsa
84+ log' "- ECDH"
85+ genEC EC.ecdh
86+ do let genRSA alg = do
87+ do CryptoKeyPair {privateKey,publicKey} <- generateKeyPair (rsa alg 2048 exp65537 Hash.sha1) true allUsages
88+ log' " - SHA-1"
89+ log' " - privateKey"
90+ log' (unsafeCoerce privateKey)
91+ log' " - publicKey"
92+ log' (unsafeCoerce publicKey)
93+ do CryptoKeyPair {privateKey,publicKey} <- generateKeyPair (rsa alg 2048 exp65537 Hash.sha256) true allUsages
94+ log' " - SHA-256"
95+ log' " - privateKey"
96+ log' (unsafeCoerce privateKey)
97+ log' " - publicKey"
98+ log' (unsafeCoerce publicKey)
99+ do CryptoKeyPair {privateKey,publicKey} <- generateKeyPair (rsa alg 2048 exp65537 Hash.sha384) true allUsages
100+ log' " - SHA-384"
101+ log' " - privateKey"
102+ log' (unsafeCoerce privateKey)
103+ log' " - publicKey"
104+ log' (unsafeCoerce publicKey)
105+ do CryptoKeyPair {privateKey,publicKey} <- generateKeyPair (rsa alg 2048 exp65537 Hash.sha512) true allUsages
106+ log' " - SHA-512"
107+ log' " - privateKey"
108+ log' (unsafeCoerce privateKey)
109+ log' " - publicKey"
110+ log' (unsafeCoerce publicKey)
111+ log' "- RSASSA-PKCS1-v1_5"
112+ genRSA RSA.rsaPKCS1
113+ log' "- RSA-PSS"
114+ genRSA RSA.rsaPSS
115+ log' "- RSA-OAEP"
116+ genRSA RSA.rsaOAEP
117+
118+
119+log' :: String -> Aff Unit
120+log' = liftEffect <<< log