git.iko.soy/rowtype-yoga/purescript-yoga-subtlecrypto
on master help sign in
28 files changed+3390−1745
since splitsnapshots
unifiedsplit
.gitignore+1 LICENSE+1−1 README.md+10−1 bower.json+30−22 buildTests.sh+2−3 spago.lock+1173 spago.yaml+21 src/Crypto/Subtle/Constants/AES.purs+7 src/Crypto/Subtle/Constants/EC.purs+5 src/Crypto/Subtle/Constants/RSA.purs+3−1 src/Crypto/Subtle/Encrypt.js+2−4 src/Crypto/Subtle/Encrypt.purs+15−14 src/Crypto/Subtle/Hash.js+1−3 src/Crypto/Subtle/Hash.purs+8−9 src/Crypto/Subtle/Key/Derive.js+2−4 src/Crypto/Subtle/Key/Derive.purs+15−13 src/Crypto/Subtle/Key/Generate.js+2−4 src/Crypto/Subtle/Key/Generate.purs+36−21 src/Crypto/Subtle/Key/Import.js+1−3 src/Crypto/Subtle/Key/Import.purs+9−14 src/Crypto/Subtle/Key/Types.js+1−3 src/Crypto/Subtle/Key/Types.purs+73−26 src/Crypto/Subtle/Key/Wrap.js+2−4 src/Crypto/Subtle/Key/Wrap.purs+11−14 src/Crypto/Subtle/Sign.js+4−6 src/Crypto/Subtle/Sign.purs+10−11 test.browser.js+1886−1549 test/Main.purs+59−15
.gitignore+1
@@ -7,3 +7,4 @@
77/.psc*
88/.purs*
99/.psa*
10+/.spago/
LICENSE+1−1
@@ -1,4 +1,4 @@
1−Copyright 2017 Athan Clark
1+Copyright 2019, 2020 Athan Clark
22
33Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
44
README.md+10−1
@@ -1,5 +1,14 @@
1−# purescript-subtlecrypto
1+# purescript-yoga-subtlecrypto
22
33Simple bindings to the Browser's `window.crypto.subtle` API thing.
44
55*__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 @@
11{
2− "name": "purescript-subtlecrypto",
3− "ignore": [
4− "**/.*",
5− "node_modules",
6− "bower_components",
7− "output"
8− ],
9− "license": "BSD-3-Clause",
10− "repository": {
11− "type": "git",
12− "url": "git://github.com/athanclark/purescript-subtlecrypto.git"
13− },
14− "dependencies": {
15− "purescript-prelude": "^4.1.0",
16− "purescript-arraybuffer-types": "^2.0.0",
17− "purescript-aff": "^5.1.0",
18− "purescript-promises": "^3.0.0",
19− "purescript-foreign": "^5.0.0"
20− },
21− "devDependencies": {
22− "purescript-psci-support": "^4.0.0"
23− }
2+ "name": "purescript-subtlecrypto",
3+ "license": [
4+ "BSD-3-Clause"
5+ ],
6+ "repository": {
7+ "type": "git",
8+ "url": "https://github.com/rowtype-yoga/purescript-yoga-subtlecrypto.git"
9+ },
10+ "ignore": [
11+ "**/.*",
12+ "node_modules",
13+ "bower_components",
14+ "output"
15+ ],
16+ "dependencies": {
17+ "purescript-aff": "^v7.0.0",
18+ "purescript-aff-promise": "^v4.0.0",
19+ "purescript-arraybuffer-types": "^v3.0.2",
20+ "purescript-console": "^v6.0.0",
21+ "purescript-effect": "^v4.0.0",
22+ "purescript-either": "^v6.0.0",
23+ "purescript-exceptions": "^v6.0.0",
24+ "purescript-foreign": "^v7.0.0",
25+ "purescript-functions": "^v6.0.0",
26+ "purescript-maybe": "^v6.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"
31+ }
2432}
buildTests.sh+2−3
@@ -1,7 +1,6 @@
11#!/bin/bash
22
3−pulp build && \
4− pulp test
3+spago build
54echo "Bundling..."
6−purs bundle output/**/*.js -m Test.Main --main Test.Main > test.browser.js
5+spago bundle --module Test.Main --outfile test.browser.js
76echo "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/Constants/AES.purs+7
@@ -4,10 +4,13 @@ module Crypto.Subtle.Constants.AES
44 , AESTagLength, t32, t64, t96, t104, t112, t120, t128
55 ) where
66
7+import Prelude (class Eq)
78
89
910newtype AESAlgorithm = AESAlgorithm String
1011
12+derive newtype instance eqAESAlgorithm :: Eq AESAlgorithm
13+
1114aesCTR :: AESAlgorithm
1215aesCTR = AESAlgorithm "AES-CTR"
1316aesCBC :: AESAlgorithm
@@ -21,6 +24,8 @@ aesKW = AESAlgorithm "AES-KW"
2124
2225newtype AESBitLength = AESBitLength Int
2326
27+derive newtype instance eqAESBitLength :: Eq AESBitLength
28+
2429l128 :: AESBitLength
2530l128 = AESBitLength 128
2631l192 :: AESBitLength
@@ -32,6 +37,8 @@ l256 = AESBitLength 256
3237
3338newtype AESTagLength = AESTagLength Int
3439
40+derive newtype instance eqAESTagLength :: Eq AESTagLength
41+
3542t32 :: AESTagLength
3643t32 = AESTagLength 32
3744t64 :: AESTagLength
src/Crypto/Subtle/Constants/EC.purs+5
@@ -3,10 +3,13 @@ module Crypto.Subtle.Constants.EC
33 , ECCurve, p256, p384, p521
44 ) where
55
6+import Prelude (class Eq)
67
78
89newtype ECAlgorithm = ECAlgorithm String
910
11+derive newtype instance eqECAlgorithm :: Eq ECAlgorithm
12+
1013ecdsa :: ECAlgorithm
1114ecdsa = ECAlgorithm "ECDSA"
1215ecdh :: ECAlgorithm
@@ -16,6 +19,8 @@ ecdh = ECAlgorithm "ECDH"
1619
1720newtype ECCurve = ECCurve String
1821
22+derive newtype instance eqECCurve :: Eq ECCurve
23+
1924p256 :: ECCurve
2025p256 = ECCurve "P-256"
2126p384 :: ECCurve
src/Crypto/Subtle/Constants/RSA.purs+3−1
@@ -2,10 +2,12 @@ module Crypto.Subtle.Constants.RSA
22 ( RSAAlgorithm, rsaPKCS1, rsaPSS, rsaOAEP
33 ) where
44
5−
5+import Prelude (class Eq)
66
77newtype RSAAlgorithm = RSAAlgorithm String
88
9+derive newtype instance eqRSAAlgorithm :: Eq RSAAlgorithm
10+
911rsaPKCS1 :: RSAAlgorithm
1012rsaPKCS1 = RSAAlgorithm "RSASSA-PKCS1-v1_5"
1113rsaPSS :: RSAAlgorithm
src/Crypto/Subtle/Encrypt.js+2−4
@@ -1,8 +1,6 @@
1−"use strict";
2−
3−exports.encryptImpl = function encryptImpl (a,k,x) {
1+export function encryptImpl (a,k,x) {
42 return crypto.subtle.encrypt(a,k,x);
53};
6−exports.decryptImpl = function decryptImpl (a,k,x) {
4+export function decryptImpl (a,k,x) {
75 return crypto.subtle.decrypt(a,k,x);
86};
src/Crypto/Subtle/Encrypt.purs+15−14
@@ -3,38 +3,39 @@ module Crypto.Subtle.Encrypt
33 , EncryptAlgorithm, rsaOAEP, aesCTR, aesCBC, aesGCM, aesKW
44 ) where
55
6−import Crypto.Subtle.Key.Types (CryptoKey)
6+import Control.Promise (Promise, toAff')
77import Crypto.Subtle.Constants.AES (AESTagLength)
8−
9−import Prelude ((<<<), (<$))
10−import Data.Function.Uncurried (Fn3, runFn3)
11−import Data.Tuple (Tuple (..))
12−import Data.Maybe (Maybe (..))
13−import Data.Either (Either (..))
8+import Crypto.Subtle.Key.Types (CryptoKey, errorFromDOMException)
149import Data.ArrayBuffer.Types (ArrayBuffer)
15−import Effect.Promise (Promise, runPromise)
16−import Effect.Aff (Aff, makeAff, nonCanceler)
10+import Data.Function.Uncurried (Fn3, runFn3)
11+import Data.Maybe (Maybe(..))
12+import Data.Tuple (Tuple(..))
13+import Effect.Aff (Aff)
1714import Unsafe.Coerce (unsafeCoerce)
1815
1916
2017
2118foreign import data EncryptAlgorithm :: Type
2219
20+-- | https://developer.mozilla.org/en-US/docs/Web/API/RsaOaepParams
2321rsaOAEP :: Maybe ArrayBuffer -- ^ Label
2422 -> EncryptAlgorithm
2523rsaOAEP mL = case mL of
2624 Nothing -> unsafeCoerce {name: "RSA_OAEP"}
2725 Just l -> unsafeCoerce {name: "RSA_OAEP", label: l}
2826
27+-- | https://developer.mozilla.org/en-US/docs/Web/API/AesCtrParams
2928aesCTR :: ArrayBuffer -- ^ Counter
3029 -> Int -- ^ Counter length
3130 -> EncryptAlgorithm
3231aesCTR c l = unsafeCoerce {name: "AES-CTR", counter: c, length: l}
3332
33+-- | https://developer.mozilla.org/en-US/docs/Web/API/AesCbcParams
3434aesCBC :: ArrayBuffer -- ^ Initialization vector
3535 -> EncryptAlgorithm
3636aesCBC i = unsafeCoerce {name: "AES-CBC", iv: i}
3737
38+-- | https://developer.mozilla.org/en-US/docs/Web/API/AesGcmParams
3839aesGCM :: ArrayBuffer -- ^ Initialization vector
3940 -> Maybe ArrayBuffer -- ^ Additional data
4041 -> Maybe AESTagLength -- ^ Tag length
@@ -53,20 +54,20 @@ aesKW = unsafeCoerce {name: "AES-KW"}
5354
5455foreign import encryptImpl :: Fn3 EncryptAlgorithm CryptoKey ArrayBuffer (Promise ArrayBuffer)
5556
57+-- | https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/encrypt
5658encrypt :: EncryptAlgorithm
5759 -> CryptoKey
5860 -> ArrayBuffer
5961 -> Aff ArrayBuffer
60−encrypt a k x = makeAff \resolve ->
61− nonCanceler <$ runPromise (resolve <<< Right) (resolve <<< Left) (runFn3 encryptImpl a k x)
62+encrypt a k x = toAff' errorFromDOMException (runFn3 encryptImpl a k x)
6263
6364
6465
6566foreign import decryptImpl :: Fn3 EncryptAlgorithm CryptoKey ArrayBuffer (Promise ArrayBuffer)
6667
68+-- | https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/decrypt
6769decrypt :: EncryptAlgorithm
6870 -> CryptoKey
6971 -> ArrayBuffer
70− -> Aff (Maybe ArrayBuffer)
71−decrypt a k x = makeAff \resolve ->
72− nonCanceler <$ runPromise (resolve <<< Right <<< Just) (\_ -> resolve (Right Nothing)) (runFn3 decryptImpl a k x)
72+ -> Aff ArrayBuffer
73+decrypt a k x = toAff' errorFromDOMException (runFn3 decryptImpl a k x)
src/Crypto/Subtle/Hash.js+1−3
@@ -1,5 +1,3 @@
1−"use strict";
2−
3−exports.digestImpl = function digestImpl (h,x) {
1+export function digestImpl (h,x) {
42 return crypto.subtle.digest(h,x);
53};
src/Crypto/Subtle/Hash.purs+8−9
@@ -1,16 +1,18 @@
11module Crypto.Subtle.Hash (HashingFunction, sha1, sha256, sha384, sha512, digest) where
22
3−import Prelude ((<<<), (<$))
3+import Control.Promise (Promise, toAff')
4+import Crypto.Subtle.Key.Types (errorFromDOMException)
45import Data.ArrayBuffer.Types (ArrayBuffer)
56import Data.Function.Uncurried (Fn2, runFn2)
6−import Data.Either (Either (..))
7−import Effect.Promise (Promise, runPromise)
8−import Effect.Aff (Aff, makeAff, nonCanceler)
7+import Effect.Aff (Aff)
8+import Prelude (class Eq)
99
1010
1111
1212newtype HashingFunction = HashingFunction String
1313
14+derive newtype instance eqHashingFunction :: Eq HashingFunction
15+
1416sha1 :: HashingFunction
1517sha1 = HashingFunction "SHA-1"
1618
@@ -23,11 +25,8 @@ sha384 = HashingFunction "SHA-384"
2325sha512 :: HashingFunction
2426sha512 = HashingFunction "SHA-512"
2527
26−
2728foreign import digestImpl :: Fn2 HashingFunction ArrayBuffer (Promise ArrayBuffer)
2829
29−
30+-- | https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest
3031digest :: HashingFunction -> ArrayBuffer -> Aff ArrayBuffer
31−digest h x =
32− let p = runFn2 digestImpl h x
33− in makeAff \resolve -> nonCanceler <$ runPromise (resolve <<< Right) (resolve <<< Left) p
32+digest h x = toAff' errorFromDOMException (runFn2 digestImpl h x)
src/Crypto/Subtle/Key/Derive.js+2−4
@@ -1,8 +1,6 @@
1−"use strict";
2−
3−exports.deriveKeyImpl = function deriveKeyImpl (a,k,t,e,u) {
1+export function deriveKeyImpl (a,k,t,e,u) {
42 return crypto.subtle.deriveKey(a,k,t,e,u);
53};
6−exports.deriveBitsImpl = function deriveBitsImpl (a,k,l) {
4+export function deriveBitsImpl (a,k,l) {
75 return crypto.subtle.deriveBits(a,k,l);
86};
src/Crypto/Subtle/Key/Derive.purs+15−13
@@ -5,17 +5,14 @@ module Crypto.Subtle.Key.Derive
55 , DeriveTargetAlgorithm, hmac, aes
66 ) where
77
8−import Crypto.Subtle.Key.Types (CryptoKey, CryptoKeyUsage)
9−import Crypto.Subtle.Hash (HashingFunction)
10−import Crypto.Subtle.Constants.EC (ECAlgorithm)
8+import Control.Promise (Promise, toAff')
119import Crypto.Subtle.Constants.AES (AESAlgorithm, AESBitLength)
12−
13−import Prelude ((<<<), (<$))
14−import Data.Function.Uncurried (Fn3, Fn5, runFn3, runFn5)
10+import Crypto.Subtle.Constants.EC (ECAlgorithm)
11+import Crypto.Subtle.Hash (HashingFunction)
12+import Crypto.Subtle.Key.Types (CryptoKey, CryptoKeyUsage, errorFromDOMException)
1513import Data.ArrayBuffer.Types (ArrayBuffer)
16−import Data.Either (Either (..))
17−import Effect.Promise (Promise, runPromise)
18−import Effect.Aff (Aff, makeAff, nonCanceler)
14+import Data.Function.Uncurried (Fn3, Fn5, runFn3, runFn5)
15+import Effect.Aff (Aff)
1916import Unsafe.Coerce (unsafeCoerce)
2017
2118
@@ -24,38 +21,41 @@ foreign import deriveKeyImpl :: Fn5 DeriveAlgorithm CryptoKey DeriveTargetAlgori
2421foreign import deriveBitsImpl :: Fn3 DeriveAlgorithm CryptoKey Int (Promise ArrayBuffer)
2522
2623
24+-- | https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/deriveKey
2725deriveKey :: DeriveAlgorithm
2826 -> CryptoKey -- ^ Base key
2927 -> DeriveTargetAlgorithm
3028 -> Boolean -- ^ Extractable
3129 -> Array CryptoKeyUsage
3230 -> Aff CryptoKey
33−deriveKey a k t e u = makeAff \resolve ->
34− nonCanceler <$ runPromise (resolve <<< Right) (resolve <<< Left) (runFn5 deriveKeyImpl a k t e u)
31+deriveKey a k t e u = toAff' errorFromDOMException (runFn5 deriveKeyImpl a k t e u)
3532
33+-- | https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/deriveBits
3634deriveBits :: DeriveAlgorithm
3735 -> CryptoKey -- ^ Base key
3836 -> Int -- ^ Length in bits
3937 -> Aff ArrayBuffer
40−deriveBits a k l = makeAff \resolve ->
41− nonCanceler <$ runPromise (resolve <<< Right) (resolve <<< Left) (runFn3 deriveBitsImpl a k l)
38+deriveBits a k l = toAff' errorFromDOMException (runFn3 deriveBitsImpl a k l)
4239
4340
4441foreign import data DeriveAlgorithm :: Type
4542foreign import data DeriveTargetAlgorithm :: Type
4643
4744
45+-- | https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/deriveKey#ecdh
4846ec :: ECAlgorithm
4947 -> CryptoKey -- ^ Public key of the other entity
5048 -> DeriveAlgorithm
5149ec e k = unsafeCoerce {name: e, public: k}
5250
51+-- | https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/deriveKey#hkdf
5352hkdf :: HashingFunction
5453 -> ArrayBuffer -- ^ Salt
5554 -> ArrayBuffer -- ^ Info
5655 -> DeriveAlgorithm
5756hkdf h s i = unsafeCoerce {name: "HKDF", hash: h, salt: s, info: i}
5857
58+-- | https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/deriveKey#pbkdf2
5959pbkdf2 :: HashingFunction
6060 -> ArrayBuffer -- ^ Salt
6161 -> Int -- ^ Iterations
@@ -65,8 +65,10 @@ pbkdf2 h s i = unsafeCoerce {name: "PBKDF2", hash: h, salt: s, iterations: i}
6565
6666
6767
68+-- | https://developer.mozilla.org/en-US/docs/Web/API/HmacKeyGenParams
6869hmac :: HashingFunction -> DeriveTargetAlgorithm
6970hmac h = unsafeCoerce {name: "HMAC", hash: h}
7071
72+-- | https://developer.mozilla.org/en-US/docs/Web/API/AesKeyGenParams
7173aes :: AESAlgorithm -> AESBitLength -> DeriveTargetAlgorithm
7274aes a l = unsafeCoerce {name: a, length: l}
src/Crypto/Subtle/Key/Generate.js+2−4
@@ -1,6 +1,4 @@
1−"use strict";
2−
3−exports.generateKeyImpl = function generateKeyImpl (a,e,u) {
1+export function generateKeyImpl (a,e,u) {
42 return crypto.subtle.generateKey(a,e,u);
53};
6−exports.exp65537 = new Uint8Array([0x01,0x00,0x01]);
4+export const exp65537 = new Uint8Array([0x01,0x00,0x01]);
src/Crypto/Subtle/Key/Generate.purs+36−21
@@ -1,55 +1,70 @@
11module Crypto.Subtle.Key.Generate
2− ( generateKey
3− , GenerateAlgorithm, exp65537, rsa, ec, hmac, aes
2+ ( generateKey, generateKeyPair
3+ , AsymmetricAlgorithm, rsa, ec
4+ , SymmetricAlgorithm, hmac, aes
5+ , exp65537
46 ) where
57
6−import Crypto.Subtle.Key.Types (CryptoKey, CryptoKeyUsage)
7−import Crypto.Subtle.Hash (HashingFunction)
8−import Crypto.Subtle.Constants.RSA (RSAAlgorithm)
9−import Crypto.Subtle.Constants.EC (ECAlgorithm, ECCurve)
8+import Control.Promise (Promise, toAff')
109import Crypto.Subtle.Constants.AES (AESAlgorithm, AESBitLength)
11−
12−import Prelude ((<<<), (<$))
13−import Data.Function.Uncurried (Fn3, runFn3)
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)
1414import Data.ArrayBuffer.Types (Uint8Array)
15−import Data.Either (Either (..))
16−import Effect.Promise (Promise, runPromise)
17−import Effect.Aff (Aff, makeAff, nonCanceler)
15+import Data.Function.Uncurried (Fn3, runFn3)
16+import Effect.Aff (Aff)
1817import Unsafe.Coerce (unsafeCoerce)
1918
2019
2120
22−foreign import generateKeyImpl :: Fn3 GenerateAlgorithm Boolean (Array CryptoKeyUsage) (Promise CryptoKey)
21+foreign import generateKeyImpl :: forall a b. Fn3 a Boolean (Array CryptoKeyUsage) (Promise b)
2322
2423
25−generateKey :: GenerateAlgorithm
24+-- | Generate a symmetric key
25+-- |
26+-- | https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/generateKey
27+generateKey :: SymmetricAlgorithm
2628 -> Boolean -- ^ Extractable
2729 -> Array CryptoKeyUsage
2830 -> Aff CryptoKey
29−generateKey a e u = makeAff \resolve ->
30− nonCanceler <$ runPromise (resolve <<< Right) (resolve <<< Left) (runFn3 generateKeyImpl a e u)
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)
3141
3242
33−foreign import data GenerateAlgorithm :: Type
43+foreign import data SymmetricAlgorithm :: Type
44+foreign import data AsymmetricAlgorithm :: Type
3445
3546
3647foreign import exp65537 :: Uint8Array
3748
3849
50+-- | https://developer.mozilla.org/en-US/docs/Web/API/RsaHashedKeyGenParams
3951rsa :: RSAAlgorithm
4052 -> Int -- ^ Modulus length. Should be at least 2048, or 4096 according to some bozo
4153 -> Uint8Array -- ^ Public exponent. Just use `exp65537`.
4254 -> HashingFunction
43− -> GenerateAlgorithm
55+ -> AsymmetricAlgorithm
4456rsa r l e h = unsafeCoerce {name: r, modulusLength: l, publicExponent: e, hash: h}
4557
46−ec :: ECAlgorithm -> ECCurve -> GenerateAlgorithm
58+-- | https://developer.mozilla.org/en-US/docs/Web/API/EcKeyGenParams
59+ec :: ECAlgorithm -> ECCurve -> AsymmetricAlgorithm
4760ec e c = unsafeCoerce {name: e, namedCurve: c}
4861
49−hmac :: HashingFunction -> GenerateAlgorithm
62+-- | https://developer.mozilla.org/en-US/docs/Web/API/HmacKeyGenParams
63+hmac :: HashingFunction -> SymmetricAlgorithm
5064hmac h = unsafeCoerce {name: "HMAC", hash: h}
5165
66+-- | https://developer.mozilla.org/en-US/docs/Web/API/AesKeyGenParams
5267aes :: AESAlgorithm
5368 -> AESBitLength
54− -> GenerateAlgorithm
69+ -> SymmetricAlgorithm
5570aes a l = unsafeCoerce {name: a, length: l}
src/Crypto/Subtle/Key/Import.js+1−3
@@ -1,5 +1,3 @@
1−"use strict";
2−
3−exports.importKeyImpl = function importKeyImpl (f,x,a,e,u) {
1+export function importKeyImpl (f,x,a,e,u) {
42 return crypto.subtle.importKey(f,x,a,e,u);
53};
src/Crypto/Subtle/Key/Import.purs+9−14
@@ -3,18 +3,15 @@ module Crypto.Subtle.Key.Import
33 , ImportAlgorithm, rsa, ec, hmac, aes
44 ) where
55
6−import Crypto.Subtle.Key.Types (CryptoKey, CryptoKeyUsage, ExternalFormat)
7−import Crypto.Subtle.Hash (HashingFunction)
8−import Crypto.Subtle.Constants.RSA (RSAAlgorithm)
9−import Crypto.Subtle.Constants.EC (ECAlgorithm, ECCurve)
6+import Control.Promise (Promise, toAff')
107import Crypto.Subtle.Constants.AES (AESAlgorithm)
11−
12−import Prelude ((<<<), (<$))
13−import Data.Function.Uncurried (Fn5, runFn5)
8+import Crypto.Subtle.Constants.EC (ECAlgorithm, ECCurve)
9+import Crypto.Subtle.Constants.RSA (RSAAlgorithm)
10+import Crypto.Subtle.Hash (HashingFunction)
11+import Crypto.Subtle.Key.Types (CryptoKey, CryptoKeyUsage, ExternalFormat, errorFromDOMException)
1412import Data.ArrayBuffer.Types (ArrayBuffer)
15−import Data.Either (Either (..))
16−import Effect.Promise (Promise, runPromise)
17−import Effect.Aff (Aff, makeAff, nonCanceler)
13+import Data.Function.Uncurried (Fn5, runFn5)
14+import Effect.Aff (Aff)
1815import Unsafe.Coerce (unsafeCoerce)
1916
2017
@@ -22,16 +19,14 @@ import Unsafe.Coerce (unsafeCoerce)
2219foreign import importKeyImpl :: Fn5 ExternalFormat ArrayBuffer ImportAlgorithm Boolean (Array CryptoKeyUsage) (Promise CryptoKey)
2320
2421
22+-- | https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey
2523importKey :: ExternalFormat
2624 -> ArrayBuffer -- ^ Key data
2725 -> ImportAlgorithm
2826 -> Boolean -- ^ Extractable
2927 -> Array CryptoKeyUsage
3028 -> Aff CryptoKey
31−importKey f x a e u = makeAff \resolve ->
32− nonCanceler <$ runPromise (resolve <<< Right) (resolve <<< Left) (runFn5 importKeyImpl f x a e u)
33−
34−
29+importKey f x a e u = toAff' errorFromDOMException (runFn5 importKeyImpl f x a e u)
3530
3631
3732foreign import data ImportAlgorithm :: Type
src/Crypto/Subtle/Key/Types.js+1−3
@@ -1,5 +1,3 @@
1−"use strict";
2−
3−exports.exportKeyImpl = function exportKeyImpl (f,x) {
1+export function exportKeyImpl (f,x) {
42 return crypto.subtle.exportKey(f,x);
53};
src/Crypto/Subtle/Key/Types.purs+73−26
@@ -1,29 +1,63 @@
11module Crypto.Subtle.Key.Types
2− ( CryptoKeyType
2+ ( CryptoKey
3+ , CryptoKeyPair(..)
4+ , CryptoKeyType
35 , CryptoKeyUsage
4− , encrypt, decrypt, sign, verify, deriveKey, deriveBits, unwrapKey, wrapKey
6+ , ExternalFormat
57 , allUsages
6− , CryptoKey
7− , getType, getExtractable, getAlgorithm, getUsages
8+ , decrypt
9+ , deriveBits
10+ , deriveKey
11+ , encrypt
12+ , errorFromDOMException
813 , exportKey
9− , ExternalFormat, raw, pkcs8, spki, jwk
10− ) where
11−
12−
13−import Prelude ((<<<), (<$))
14−import Data.Either (Either (..))
15−import Data.Function.Uncurried (Fn2, runFn2)
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+ )
30+ where
31+
32+import Prelude ((>>=), class Eq)
33+import Control.Monad.Except (runExcept)
34+import Control.Promise (Promise, toAff')
1635import Data.ArrayBuffer.Types (ArrayBuffer)
17−import Foreign (Foreign)
18−import Effect.Aff (Aff, makeAff, nonCanceler)
19−import Effect.Promise (Promise, runPromise)
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)
2042
2143
2244-- TODO enumerate different key types - public, secret, etc.
2345newtype CryptoKeyType = CryptoKeyType String
2446
47+derive newtype instance eqCryptoKeyType :: Eq CryptoKeyType
48+
49+secret :: CryptoKeyType
50+secret = CryptoKeyType "secret"
51+public :: CryptoKeyType
52+public = CryptoKeyType "public"
53+private :: CryptoKeyType
54+private = CryptoKeyType "private"
55+
56+
2557newtype CryptoKeyUsage = CryptoKeyUsage String
2658
59+derive newtype instance eqCryptoKeyUsage :: Eq CryptoKeyUsage
60+
2761
2862encrypt :: CryptoKeyUsage
2963encrypt = CryptoKeyUsage "encrypt"
@@ -48,30 +82,34 @@ allUsages = [encrypt, decrypt, sign, verify, deriveKey, deriveBits, wrapKey, unw
4882
4983
5084
51−newtype CryptoKey = CryptoKey
52− { "type" :: CryptoKeyType
53− , extractable :: Boolean
54− , algorithm :: Foreign
55− , usages :: Array CryptoKeyUsage
56− }
85+foreign import data CryptoKey :: Type
5786
5887
5988getType :: CryptoKey -> CryptoKeyType
60−getType (CryptoKey r) = r."type"
89+getType r = (unsafeCoerce r)."type"
6190
6291getExtractable :: CryptoKey -> Boolean
63−getExtractable (CryptoKey r) = r.extractable
92+getExtractable r = (unsafeCoerce r).extractable
6493
6594getAlgorithm :: CryptoKey -> Foreign
66−getAlgorithm (CryptoKey r) = r.algorithm
95+getAlgorithm r = (unsafeCoerce r).algorithm
6796
6897getUsages :: CryptoKey -> Array CryptoKeyUsage
69−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+
70106
71107
72108
73109newtype ExternalFormat = ExternalFormat String
74110
111+derive newtype instance eqExternalFormat :: Eq ExternalFormat
112+
75113raw :: ExternalFormat
76114raw = ExternalFormat "raw"
77115pkcs8 :: ExternalFormat
@@ -84,8 +122,17 @@ jwk = ExternalFormat "jwk"
84122
85123foreign import exportKeyImpl :: Fn2 ExternalFormat CryptoKey (Promise ArrayBuffer)
86124
125+-- | https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/exportKey
87126exportKey :: ExternalFormat
88127 -> CryptoKey
89128 -> Aff ArrayBuffer
90−exportKey f x = makeAff \resolve ->
91− nonCanceler <$ runPromise (resolve <<< Right) (resolve <<< Left) (runFn2 exportKeyImpl f x)
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.js+2−4
@@ -1,8 +1,6 @@
1−"use strict";
2−
3−exports.wrapKeyImpl = function wrapKeyImpl (f,x,k,a) {
1+export function wrapKeyImpl (f,x,k,a) {
42 return crypto.subtle.wrapKey(f,x,k,a);
53};
6−exports.unwrapKeyImpl = function unwrapKeyImpl (f,x,k,a,i,e,u) {
4+export function unwrapKeyImpl (f,x,k,a,i,e,u) {
75 return crypto.subtle.unwrapKey(f,x,k,a,i,e,u);
86};
src/Crypto/Subtle/Key/Wrap.purs+11−14
@@ -1,33 +1,30 @@
11module Crypto.Subtle.Key.Wrap
22 where
33
4−import Crypto.Subtle.Key.Types (CryptoKey, ExternalFormat, CryptoKeyUsage)
5−import Crypto.Subtle.Key.Import (ImportAlgorithm)
4+import Control.Promise (Promise, toAff')
65import Crypto.Subtle.Encrypt (EncryptAlgorithm)
7−
8−import Prelude ((<<<), (<$))
9−import Data.Function.Uncurried (Fn4, Fn7, runFn4, runFn7)
10−import Data.Maybe (Maybe (..))
11−import Data.Either (Either (..))
6+import Crypto.Subtle.Key.Import (ImportAlgorithm)
7+import Crypto.Subtle.Key.Types (CryptoKey, CryptoKeyUsage, ExternalFormat, errorFromDOMException)
128import Data.ArrayBuffer.Types (ArrayBuffer)
13−import Effect.Promise (Promise, runPromise)
14−import Effect.Aff (Aff, makeAff, nonCanceler)
9+import Data.Function.Uncurried (Fn4, Fn7, runFn4, runFn7)
10+import Effect.Aff (Aff)
1511
1612
1713
1814foreign import wrapKeyImpl :: Fn4 ExternalFormat CryptoKey CryptoKey EncryptAlgorithm (Promise ArrayBuffer)
1915
16+-- | https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/wrapKey
2017wrapKey :: ExternalFormat
2118 -> CryptoKey -- ^ Subject key
2219 -> CryptoKey -- ^ Wrapping key
2320 -> EncryptAlgorithm
2421 -> Aff ArrayBuffer
25−wrapKey f x k a = makeAff \resolve ->
26− nonCanceler <$ runPromise (resolve <<< Right) (resolve <<< Left) (runFn4 wrapKeyImpl f x k a)
22+wrapKey f x k a = toAff' errorFromDOMException (runFn4 wrapKeyImpl f x k a)
2723
2824
2925foreign import unwrapKeyImpl :: Fn7 ExternalFormat ArrayBuffer CryptoKey EncryptAlgorithm ImportAlgorithm Boolean (Array CryptoKeyUsage) (Promise CryptoKey)
3026
27+-- | https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/unwrapKey
3128unwrapKey :: ExternalFormat
3229 -> ArrayBuffer -- ^ Wrapped key
3330 -> CryptoKey -- ^ Unwrapping key
@@ -35,6 +32,6 @@ unwrapKey :: ExternalFormat
3532 -> ImportAlgorithm
3633 -> Boolean -- ^ Extractable
3734 -> Array CryptoKeyUsage
38− -> Aff (Maybe CryptoKey)
39−unwrapKey f x k a i e u = makeAff \resolve ->
40− nonCanceler <$ runPromise (resolve <<< Right <<< Just) (\_ -> resolve (Right Nothing)) (runFn7 unwrapKeyImpl f x k a i e u)
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.js+4−6
@@ -1,8 +1,6 @@
1−"use strict";
2−
3−exports.signImpl = function signImpl (a,k,x) {
1+export function signImpl (a,k,x) {
42 return crypto.subtle.sign(a,k,x);
53};
6−exports.verifyImpl = function verifyImpl (a,k,s,x) {
7− return crypto.subtle.verify(a,k,s,x);
8−};
4+export function verifyImpl(a, k, s, x) {
5+ return crypto.subtle.verify(a, k, s, x);
6+}
src/Crypto/Subtle/Sign.purs+10−11
@@ -3,15 +3,12 @@ module Crypto.Subtle.Sign
33 , SignAlgorithm, rsaPKCS1, rsaPSS, ecdsa, hmac
44 ) where
55
6−import Crypto.Subtle.Key.Types (CryptoKey)
6+import Control.Promise (Promise, toAff')
77import Crypto.Subtle.Hash (HashingFunction)
8−
9−import Prelude ((<<<), (<$))
10−import Data.Function.Uncurried (Fn3, Fn4, runFn3, runFn4)
11−import Data.Either (Either (..))
8+import Crypto.Subtle.Key.Types (CryptoKey, errorFromDOMException)
129import Data.ArrayBuffer.Types (ArrayBuffer)
13−import Effect.Promise (Promise, runPromise)
14−import Effect.Aff (Aff, makeAff, nonCanceler)
10+import Data.Function.Uncurried (Fn3, Fn4, runFn3, runFn4)
11+import Effect.Aff (Aff)
1512import Unsafe.Coerce (unsafeCoerce)
1613
1714
@@ -21,10 +18,12 @@ foreign import data SignAlgorithm :: Type
2118rsaPKCS1 :: SignAlgorithm
2219rsaPKCS1 = unsafeCoerce {name: "RSASSA-PKCS1-v1_5"}
2320
21+-- | https://developer.mozilla.org/en-US/docs/Web/API/RsaPssParams
2422rsaPSS :: Int -- ^ Salt length
2523 -> SignAlgorithm
2624rsaPSS l = unsafeCoerce {name: "RSA-PSS", saltLength: l}
2725
26+-- | https://developer.mozilla.org/en-US/docs/Web/API/EcdsaParams
2827ecdsa :: HashingFunction
2928 -> SignAlgorithm
3029ecdsa h = unsafeCoerce {name: "ECDSA", hash: h}
@@ -35,20 +34,20 @@ hmac = unsafeCoerce {name: "HMAC"}
3534
3635foreign import signImpl :: Fn3 SignAlgorithm CryptoKey ArrayBuffer (Promise ArrayBuffer)
3736
37+-- | https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/sign
3838sign :: SignAlgorithm
3939 -> CryptoKey
4040 -> ArrayBuffer
4141 -> Aff ArrayBuffer
42−sign a k x = makeAff \resolve ->
43− nonCanceler <$ runPromise (resolve <<< Right) (resolve <<< Left) (runFn3 signImpl a k x)
42+sign a k x = toAff' errorFromDOMException (runFn3 signImpl a k x)
4443
4544
4645foreign import verifyImpl :: Fn4 SignAlgorithm CryptoKey ArrayBuffer ArrayBuffer (Promise Boolean)
4746
47+-- | https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/verify
4848verify :: SignAlgorithm
4949 -> CryptoKey
5050 -> ArrayBuffer -- ^ Signature
5151 -> ArrayBuffer -- ^ Subject data
5252 -> Aff Boolean
53−verify a k s x = makeAff \resolve ->
54− nonCanceler <$ runPromise (resolve <<< Right) (resolve <<< Left) (runFn4 verifyImpl a k s x)
53+verify a k s x = toAff' errorFromDOMException (runFn4 verifyImpl a k s x)
test.browser.js+1886−1549
@@ -1,262 +1,109 @@
1−// Generated by purs bundle 0.12.0
2−var PS = {};
3−(function(exports) {
4− // Generated by purs version 0.12.0
5− "use strict";
6− var Control_Category = PS["Control.Category"];
7− var Data_Boolean = PS["Data.Boolean"];
8− var Data_Ord = PS["Data.Ord"];
9− var Data_Ring = PS["Data.Ring"];
10− var flip = function (f) {
11− return function (b) {
12− return function (a) {
13− return f(a)(b);
14− };
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+ };
1510 };
11+ }
1612 };
17− var $$const = function (a) {
18− return function (v) {
19− return a;
20− };
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+ }
2125 };
22− exports["flip"] = flip;
23− exports["const"] = $$const;
24−})(PS["Data.Function"] = PS["Data.Function"] || {});
25−(function(exports) {
26− "use strict";
2726
28− exports.unit = {};
29−})(PS["Data.Unit"] = PS["Data.Unit"] || {});
30−(function(exports) {
31− // Generated by purs version 0.12.0
32− "use strict";
33− var $foreign = PS["Data.Unit"];
34− var Data_Show = PS["Data.Show"];
35− exports["unit"] = $foreign.unit;
36−})(PS["Data.Unit"] = PS["Data.Unit"] || {});
37−(function(exports) {
38− // Generated by purs version 0.12.0
39− "use strict";
40− var $foreign = PS["Data.Functor"];
41− var Control_Semigroupoid = PS["Control.Semigroupoid"];
42− var Data_Function = PS["Data.Function"];
43− var Data_Unit = PS["Data.Unit"];
44− var Functor = function (map) {
45− this.map = map;
46− };
47− var map = function (dict) {
48− return dict.map;
49− };
50− var $$void = function (dictFunctor) {
51− return map(dictFunctor)(Data_Function["const"](Data_Unit.unit));
52− };
53− var voidRight = function (dictFunctor) {
54− return function (x) {
55− return map(dictFunctor)(Data_Function["const"](x));
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);
5635 };
36+ };
5737 };
58− exports["Functor"] = Functor;
59− exports["map"] = map;
60− exports["void"] = $$void;
61− exports["voidRight"] = voidRight;
62−})(PS["Data.Functor"] = PS["Data.Functor"] || {});
63−(function(exports) {
64− // Generated by purs version 0.12.0
65− "use strict";
66− var $foreign = PS["Control.Apply"];
67− var Control_Category = PS["Control.Category"];
68− var Data_Function = PS["Data.Function"];
69− var Data_Functor = PS["Data.Functor"];
70− var Apply = function (Functor0, apply) {
71− this.Functor0 = Functor0;
72− this.apply = apply;
73− };
74− var apply = function (dict) {
75− return dict.apply;
76− };
77− exports["Apply"] = Apply;
78− exports["apply"] = apply;
79−})(PS["Control.Apply"] = PS["Control.Apply"] || {});
80−(function(exports) {
81− // Generated by purs version 0.12.0
82− "use strict";
83− var Control_Apply = PS["Control.Apply"];
84− var Data_Functor = PS["Data.Functor"];
85− var Data_Unit = PS["Data.Unit"];
86− var Applicative = function (Apply0, pure) {
87− this.Apply0 = Apply0;
88− this.pure = pure;
89− };
90− var pure = function (dict) {
91− return dict.pure;
92− };
93− var liftA1 = function (dictApplicative) {
94− return function (f) {
95− return function (a) {
96− return Control_Apply.apply(dictApplicative.Apply0())(pure(dictApplicative)(f))(a);
97− };
98− };
38+ var $$const = function(a) {
39+ return function(v) {
40+ return a;
41+ };
9942 };
100− exports["Applicative"] = Applicative;
101− exports["pure"] = pure;
102− exports["liftA1"] = liftA1;
103−})(PS["Control.Applicative"] = PS["Control.Applicative"] || {});
104−(function(exports) {
105− // Generated by purs version 0.12.0
106− "use strict";
107− var $foreign = PS["Control.Bind"];
108− var Control_Applicative = PS["Control.Applicative"];
109− var Control_Apply = PS["Control.Apply"];
110− var Control_Category = PS["Control.Category"];
111− var Data_Function = PS["Data.Function"];
112− var Data_Functor = PS["Data.Functor"];
113− var Data_Unit = PS["Data.Unit"];
114− var Bind = function (Apply0, bind) {
115− this.Apply0 = Apply0;
116− this.bind = bind;
117− };
118− var Discard = function (discard) {
119− this.discard = discard;
120− };
121− var discard = function (dict) {
122− return dict.discard;
123− };
124− var bind = function (dict) {
125− return dict.bind;
126− };
127− var bindFlipped = function (dictBind) {
128− return Data_Function.flip(bind(dictBind));
129− };
130− var discardUnit = new Discard(function (dictBind) {
131− return bind(dictBind);
132− });
133− exports["Bind"] = Bind;
134− exports["bind"] = bind;
135− exports["bindFlipped"] = bindFlipped;
136− exports["Discard"] = Discard;
137− exports["discard"] = discard;
138− exports["discardUnit"] = discardUnit;
139−})(PS["Control.Bind"] = PS["Control.Bind"] || {});
140−(function(exports) {
141− // Generated by purs version 0.12.0
142− "use strict";
143− var Control_Applicative = PS["Control.Applicative"];
144− var Control_Apply = PS["Control.Apply"];
145− var Control_Bind = PS["Control.Bind"];
146− var Data_Functor = PS["Data.Functor"];
147− var Data_Unit = PS["Data.Unit"];
148− var Monad = function (Applicative0, Bind1) {
149− this.Applicative0 = Applicative0;
150− this.Bind1 = Bind1;
151− };
152− var ap = function (dictMonad) {
153− return function (f) {
154− return function (a) {
155− return Control_Bind.bind(dictMonad.Bind1())(f)(function (v) {
156− return Control_Bind.bind(dictMonad.Bind1())(a)(function (v1) {
157− return Control_Applicative.pure(dictMonad.Applicative0())(v(v1));
158− });
159− });
160− };
161− };
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;
16250 };
163− exports["Monad"] = Monad;
164− exports["ap"] = ap;
165−})(PS["Control.Monad"] = PS["Control.Monad"] || {});
166−(function(exports) {
167− // Generated by purs version 0.12.0
168− "use strict";
169− var Control_Alt = PS["Control.Alt"];
170− var Control_Applicative = PS["Control.Applicative"];
171− var Control_Apply = PS["Control.Apply"];
172− var Control_Bind = PS["Control.Bind"];
173− var Control_Extend = PS["Control.Extend"];
174− var Control_Monad = PS["Control.Monad"];
175− var Control_Semigroupoid = PS["Control.Semigroupoid"];
176− var Data_Bifoldable = PS["Data.Bifoldable"];
177− var Data_Bifunctor = PS["Data.Bifunctor"];
178− var Data_Bitraversable = PS["Data.Bitraversable"];
179− var Data_Bounded = PS["Data.Bounded"];
180− var Data_Eq = PS["Data.Eq"];
181− var Data_Foldable = PS["Data.Foldable"];
182− var Data_FoldableWithIndex = PS["Data.FoldableWithIndex"];
183− var Data_Function = PS["Data.Function"];
184− var Data_Functor = PS["Data.Functor"];
185− var Data_Functor_Invariant = PS["Data.Functor.Invariant"];
186− var Data_FunctorWithIndex = PS["Data.FunctorWithIndex"];
187− var Data_Maybe = PS["Data.Maybe"];
188− var Data_Monoid = PS["Data.Monoid"];
189− var Data_Ord = PS["Data.Ord"];
190− var Data_Ordering = PS["Data.Ordering"];
191− var Data_Semigroup = PS["Data.Semigroup"];
192− var Data_Show = PS["Data.Show"];
193− var Data_Traversable = PS["Data.Traversable"];
194− var Data_TraversableWithIndex = PS["Data.TraversableWithIndex"];
195− var Data_Unit = PS["Data.Unit"];
196− var Prelude = PS["Prelude"];
197− var Left = (function () {
198− function Left(value0) {
199− this.value0 = value0;
200− };
201− Left.create = function (value0) {
202− return new Left(value0);
203− };
204− return Left;
205− })();
206− var Right = (function () {
207− function Right(value0) {
208− this.value0 = value0;
209− };
210− Right.create = function (value0) {
211− return new Right(value0);
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);
21272 };
213− return Right;
214− })();
215− exports["Left"] = Left;
216− exports["Right"] = Right;
217−})(PS["Data.Either"] = PS["Data.Either"] || {});
218−(function(exports) {
219− // Generated by purs version 0.12.0
220− "use strict";
221− var Control_Applicative = PS["Control.Applicative"];
222− var Control_Bind = PS["Control.Bind"];
223− var Control_Semigroupoid = PS["Control.Semigroupoid"];
224− var Data_Either = PS["Data.Either"];
225− var Data_Function = PS["Data.Function"];
226− var Data_Functor = PS["Data.Functor"];
227− var Data_Maybe = PS["Data.Maybe"];
228− var Data_Unit = PS["Data.Unit"];
229− var Prelude = PS["Prelude"];
230− var MonadThrow = function (Monad0, throwError) {
231− this.Monad0 = Monad0;
232− this.throwError = throwError;
233− };
234− var MonadError = function (MonadThrow0, catchError) {
235− this.MonadThrow0 = MonadThrow0;
236− this.catchError = catchError;
237− };
238− var throwError = function (dict) {
239− return dict.throwError;
240− };
241− var catchError = function (dict) {
242− return dict.catchError;
243− };
244− var $$try = function (dictMonadError) {
245− return function (a) {
246− return catchError(dictMonadError)(Data_Functor.map(((((dictMonadError.MonadThrow0()).Monad0()).Bind1()).Apply0()).Functor0())(Data_Either.Right.create)(a))(function ($21) {
247− return Control_Applicative.pure(((dictMonadError.MonadThrow0()).Monad0()).Applicative0())(Data_Either.Left.create($21));
248− });
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);
24986 };
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+ }
250104 };
251− exports["catchError"] = catchError;
252− exports["throwError"] = throwError;
253− exports["MonadThrow"] = MonadThrow;
254− exports["MonadError"] = MonadError;
255− exports["try"] = $$try;
256−})(PS["Control.Monad.Error.Class"] = PS["Control.Monad.Error.Class"] || {});
257−(function(exports) {
258− // Generated by purs version 0.12.0
259− "use strict";
105+
106+ // output/Crypto.Subtle.Constants.AES/index.js
260107 var l256 = 256;
261108 var l192 = 192;
262109 var l128 = 128;
@@ -264,260 +111,786 @@ var PS = {};
264111 var aesGCM = "AES-GCM";
265112 var aesCTR = "AES-CTR";
266113 var aesCBC = "AES-CBC";
267− exports["aesCTR"] = aesCTR;
268− exports["aesCBC"] = aesCBC;
269− exports["aesGCM"] = aesGCM;
270− exports["aesKW"] = aesKW;
271− exports["l128"] = l128;
272− exports["l192"] = l192;
273− exports["l256"] = l256;
274−})(PS["Crypto.Subtle.Constants.AES"] = PS["Crypto.Subtle.Constants.AES"] || {});
275−(function(exports) {
276− // Generated by purs version 0.12.0
277− "use strict";
114+
115+ // output/Crypto.Subtle.Constants.EC/index.js
278116 var p521 = "P-521";
279117 var p384 = "P-384";
280118 var p256 = "P-256";
281119 var ecdsa = "ECDSA";
282120 var ecdh = "ECDH";
283− exports["ecdsa"] = ecdsa;
284− exports["ecdh"] = ecdh;
285− exports["p256"] = p256;
286− exports["p384"] = p384;
287− exports["p521"] = p521;
288−})(PS["Crypto.Subtle.Constants.EC"] = PS["Crypto.Subtle.Constants.EC"] || {});
289−(function(exports) {
290− "use strict";
291121
292− exports.pureE = function (a) {
293− return function () {
294− return a;
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+ };
295198 };
296199 };
297200
298− exports.bindE = function (a) {
299− return function (f) {
300− return function () {
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() {
301210 return f(a())();
302211 };
303212 };
304213 };
305−})(PS["Effect"] = PS["Effect"] || {});
306−(function(exports) {
307− // Generated by purs version 0.12.0
308− "use strict";
309− var $foreign = PS["Effect"];
310− var Control_Applicative = PS["Control.Applicative"];
311− var Control_Apply = PS["Control.Apply"];
312− var Control_Bind = PS["Control.Bind"];
313− var Control_Monad = PS["Control.Monad"];
314− var Data_Functor = PS["Data.Functor"];
315− var Data_Monoid = PS["Data.Monoid"];
316− var Data_Semigroup = PS["Data.Semigroup"];
317− var Prelude = PS["Prelude"];
318− var monadEffect = new Control_Monad.Monad(function () {
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() {
319250 return applicativeEffect;
320− }, function () {
251+ },
252+ Bind1: function() {
321253 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+ };
322280 });
323− var bindEffect = new Control_Bind.Bind(function () {
324− return applyEffect;
325− }, $foreign.bindE);
326− var applyEffect = new Control_Apply.Apply(function () {
327− return functorEffect;
328− }, Control_Monad.ap(monadEffect));
329− var applicativeEffect = new Control_Applicative.Applicative(function () {
330− return applyEffect;
331− }, $foreign.pureE);
332− var functorEffect = new Data_Functor.Functor(Control_Applicative.liftA1(applicativeEffect));
333− exports["functorEffect"] = functorEffect;
334− exports["applyEffect"] = applyEffect;
335− exports["applicativeEffect"] = applicativeEffect;
336− exports["bindEffect"] = bindEffect;
337− exports["monadEffect"] = monadEffect;
338−})(PS["Effect"] = PS["Effect"] || {});
339−(function(exports) {
340− /* globals setImmediate, clearImmediate, setTimeout, clearTimeout */
341− /* jshint -W083, -W098, -W003 */
342− "use strict";
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+ }
343292
344− var Aff = function () {
345− // A unique value for empty.
346− var EMPTY = {};
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+ };
347311
348− /*
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+ };
349357
350− An awkward approximation. We elide evidence we would otherwise need in PS for
351− efficiency sake.
358+ // output/Unsafe.Coerce/foreign.js
359+ var unsafeCoerce2 = function(x) {
360+ return x;
361+ };
352362
353− data Aff eff a
354− = Pure a
355− | Throw Error
356− | Catch (Aff eff a) (Error -> Aff eff a)
357− | Sync (Eff eff a)
358− | Async ((Either Error a -> Eff eff Unit) -> Eff eff (Canceler eff))
359− | forall b. Bind (Aff eff b) (b -> Aff eff a)
360− | forall b. Bracket (Aff eff b) (BracketConditions eff b) (b -> Aff eff a)
361− | forall b. Fork Boolean (Aff eff b) ?(Fiber eff b -> a)
362− | Sequential (ParAff aff a)
363+ // output/Effect.Class/index.js
364+ var liftEffect = function(dict) {
365+ return dict.liftEffect;
366+ };
363367
364− */
365− var PURE = "Pure";
366− var THROW = "Throw";
367− var CATCH = "Catch";
368− var SYNC = "Sync";
369− var ASYNC = "Async";
370− var BIND = "Bind";
371− var BRACKET = "Bracket";
372− var FORK = "Fork";
373− var SEQ = "Sequential";
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+ };
374454
375− /*
455+ // output/Safe.Coerce/index.js
456+ var coerce = function() {
457+ return unsafeCoerce2;
458+ };
376459
377− data ParAff eff a
378− = forall b. Map (b -> a) (ParAff eff b)
379− | forall b. Apply (ParAff eff (b -> a)) (ParAff eff b)
380− | Alt (ParAff eff a) (ParAff eff a)
381− | ?Par (Aff eff a)
460+ // output/Data.Newtype/index.js
461+ var coerce2 = /* @__PURE__ */ coerce();
462+ var unwrap = function() {
463+ return coerce2;
464+ };
382465
383− */
384− var MAP = "Map";
385− var APPLY = "Apply";
386− var ALT = "Alt";
466+ // output/Control.Monad.Except/index.js
467+ var unwrap2 = /* @__PURE__ */ unwrap();
468+ var runExcept = function($3) {
469+ return unwrap2(runExceptT($3));
470+ };
387471
388− // Various constructors used in interpretation
389− var CONS = "Cons"; // Cons-list, for stacks
390− var RESUME = "Resume"; // Continue indiscriminately
391− var RELEASE = "Release"; // Continue with bracket finalizers
392− var FINALIZER = "Finalizer"; // A non-interruptible effect
393− var FINALIZED = "Finalized"; // Marker for finalization
394− var FORKED = "Forked"; // Reference to a forked fiber, with resumption stack
395− var FIBER = "Fiber"; // Actual fiber reference
396− var THUNK = "Thunk"; // Primed effect, ready to invoke
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+ };
397497
398− function Aff(tag, _1, _2, _3) {
399− this.tag = tag;
400− this._1 = _1;
401− this._2 = _2;
402− this._3 = _3;
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;
403747 }
748+ };
749+ var plusList = /* @__PURE__ */ function() {
750+ return {
751+ empty: Nil.value,
752+ Alt0: function() {
753+ return altList;
754+ }
755+ };
756+ }();
404757
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+ }
405787 function AffCtr(tag) {
406− var fn = function (_1, _2, _3) {
407− return new Aff(tag, _1, _2, _3);
788+ var fn = function(_1, _2, _3) {
789+ return new Aff2(tag, _1, _2, _3);
408790 };
409791 fn.tag = tag;
410792 return fn;
411793 }
412−
413− function nonCanceler(error) {
414− return new Aff(PURE, void 0);
794+ function nonCanceler2(error3) {
795+ return new Aff2(PURE, void 0);
415796 }
416−
417797 function runEff(eff) {
418798 try {
419799 eff();
420− } catch (error) {
421− setTimeout(function () {
422− throw error;
800+ } catch (error3) {
801+ setTimeout(function() {
802+ throw error3;
423803 }, 0);
424804 }
425805 }
426−
427806 function runSync(left, right, eff) {
428807 try {
429808 return right(eff());
430− } catch (error) {
431− return left(error);
809+ } catch (error3) {
810+ return left(error3);
432811 }
433812 }
434−
435813 function runAsync(left, eff, k) {
436814 try {
437815 return eff(k)();
438− } catch (error) {
439− k(left(error))();
440− return nonCanceler;
816+ } catch (error3) {
817+ k(left(error3))();
818+ return nonCanceler2;
441819 }
442820 }
443−
444− var Scheduler = function () {
445− var limit = 1024;
446− var size = 0;
447− var ix = 0;
448− var queue = new Array(limit);
821+ var Scheduler = function() {
822+ var limit = 1024;
823+ var size = 0;
824+ var ix = 0;
825+ var queue = new Array(limit);
449826 var draining = false;
450−
451827 function drain() {
452828 var thunk;
453829 draining = true;
454830 while (size !== 0) {
455831 size--;
456− thunk = queue[ix];
832+ thunk = queue[ix];
457833 queue[ix] = void 0;
458− ix = (ix + 1) % limit;
834+ ix = (ix + 1) % limit;
459835 thunk();
460836 }
461837 draining = false;
462838 }
463−
464839 return {
465− isDraining: function () {
840+ isDraining: function() {
466841 return draining;
467842 },
468− enqueue: function (cb) {
843+ enqueue: function(cb) {
469844 var i, tmp;
470845 if (size === limit) {
471846 tmp = draining;
472847 drain();
473848 draining = tmp;
474849 }
475−
476850 queue[(ix + size) % limit] = cb;
477851 size++;
478−
479852 if (!draining) {
480853 drain();
481854 }
482855 }
483856 };
484857 }();
485−
486858 function Supervisor(util) {
487− var fibers = {};
859+ var fibers = {};
488860 var fiberId = 0;
489− var count = 0;
490−
861+ var count = 0;
491862 return {
492− register: function (fiber) {
863+ register: function(fiber) {
493864 var fid = fiberId++;
494865 fiber.onComplete({
495866 rethrow: true,
496− handler: function (result) {
497− return function () {
867+ handler: function(result) {
868+ return function() {
498869 count--;
499870 delete fibers[fid];
500871 };
501872 }
502− });
873+ })();
503874 fibers[fid] = fiber;
504875 count++;
505876 },
506− isEmpty: function () {
877+ isEmpty: function() {
507878 return count === 0;
508879 },
509− killAll: function (killError, cb) {
510− return function () {
880+ killAll: function(killError, cb) {
881+ return function() {
882+ if (count === 0) {
883+ return cb();
884+ }
511885 var killCount = 0;
512− var kills = {};
513−
886+ var kills = {};
514887 function kill(fid) {
515− kills[fid] = fibers[fid].kill(killError, function (result) {
516− return function () {
888+ kills[fid] = fibers[fid].kill(killError, function(result) {
889+ return function() {
517890 delete kills[fid];
518891 killCount--;
519892 if (util.isLeft(result) && util.fromLeft(result)) {
520− setTimeout(function () {
893+ setTimeout(function() {
521894 throw util.fromLeft(result);
522895 }, 0);
523896 }
@@ -527,23 +900,20 @@ var PS = {};
527900 };
528901 })();
529902 }
530−
531903 for (var k in fibers) {
532904 if (fibers.hasOwnProperty(k)) {
533905 killCount++;
534906 kill(k);
535907 }
536908 }
537−
538− fibers = {};
909+ fibers = {};
539910 fiberId = 0;
540− count = 0;
541−
542− return function (error) {
543− return new Aff(SYNC, function () {
544− for (var k in kills) {
545− if (kills.hasOwnProperty(k)) {
546− kills[k]();
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]();
547917 }
548918 }
549919 });
@@ -552,335 +922,270 @@ var PS = {};
552922 }
553923 };
554924 }
555−
556− // Fiber state machine
557− var SUSPENDED = 0; // Suspended, pending a join.
558− var CONTINUE = 1; // Interpret the next instruction.
559− var STEP_BIND = 2; // Apply the next bind.
560− var STEP_RESULT = 3; // Handle potential failure from a result.
561− var PENDING = 4; // An async effect is running.
562− var RETURN = 5; // The current stack has returned.
563− var COMPLETED = 6; // The entire fiber has completed.
564−
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;
565932 function Fiber(util, supervisor, aff) {
566− // Monotonically increasing tick, increased on each asynchronous turn.
567933 var runTick = 0;
568−
569− // The current branch of the state machine.
570934 var status = SUSPENDED;
571−
572− // The current point of interest for the state machine branch.
573− var step = aff; // Successful step
574− var fail = null; // Failure step
575− var interrupt = null; // Asynchronous interrupt
576−
577− // Stack of continuations for the current fiber.
935+ var step = aff;
936+ var fail2 = null;
937+ var interrupt = null;
578938 var bhead = null;
579939 var btail = null;
580−
581− // Stack of attempts and finalizers for error recovery. Every `Cons` is also
582− // tagged with current `interrupt` state. We use this to track which items
583− // should be ignored or evaluated as a result of a kill.
584940 var attempts = null;
585−
586− // A special state is needed for Bracket, because it cannot be killed. When
587− // we enter a bracket acquisition or finalizer, we increment the counter,
588− // and then decrement once complete.
589941 var bracketCount = 0;
590−
591− // Each join gets a new id so they can be revoked.
592− var joinId = 0;
593− var joins = null;
942+ var joinId = 0;
943+ var joins = null;
594944 var rethrow = true;
595−
596− // Each invocation of `run` requires a tick. When an asynchronous effect is
597− // resolved, we must check that the local tick coincides with the fiber
598− // tick before resuming. This prevents multiple async continuations from
599− // accidentally resuming the same fiber. A common example may be invoking
600− // the provided callback in `makeAff` more than once, but it may also be an
601− // async effect resuming after the fiber was already cancelled.
602− function run(localRunTick) {
945+ function run2(localRunTick) {
603946 var tmp, result, attempt;
604947 while (true) {
605− tmp = null;
606− result = null;
607− attempt = null;
608−
948+ tmp = null;
949+ result = null;
950+ attempt = null;
609951 switch (status) {
610− case STEP_BIND:
611− status = CONTINUE;
612− step = bhead(step);
613− if (btail === null) {
614− bhead = null;
615− } else {
616− bhead = btail._1;
617− btail = btail._2;
618− }
619− break;
620−
621− case STEP_RESULT:
622− if (util.isLeft(step)) {
623− status = RETURN;
624− fail = step;
625− step = null;
626− } else if (bhead === null) {
627− status = RETURN;
628− } else {
629− status = STEP_BIND;
630− step = util.fromRight(step);
631− }
632− break;
633−
634− case CONTINUE:
635− switch (step.tag) {
636− case BIND:
637− if (bhead) {
638− btail = new Aff(CONS, bhead, btail);
639− }
640− bhead = step._2;
952+ case STEP_BIND:
641953 status = CONTINUE;
642− step = step._1;
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+ }
643967 break;
644−
645− case PURE:
646− if (bhead === null) {
968+ case STEP_RESULT:
969+ if (util.isLeft(step)) {
970+ status = RETURN;
971+ fail2 = step;
972+ step = null;
973+ } else if (bhead === null) {
647974 status = RETURN;
648− step = util.right(step._1);
649975 } else {
650976 status = STEP_BIND;
651− step = step._1;
977+ step = util.fromRight(step);
652978 }
653979 break;
654−
655− case SYNC:
656− status = STEP_RESULT;
657− step = runSync(util.left, util.right, step._1);
658− break;
659−
660− case ASYNC:
661− status = PENDING;
662− step = runAsync(util.left, step._1, function (result) {
663− return function () {
664− if (runTick !== localRunTick) {
665− return;
980+ case CONTINUE:
981+ switch (step.tag) {
982+ case BIND:
983+ if (bhead) {
984+ btail = new Aff2(CONS, bhead, btail);
666985 }
667− runTick++;
668− Scheduler.enqueue(function () {
669− // It's possible to interrupt the fiber between enqueuing and
670− // resuming, so we need to check that the runTick is still
671− // valid.
672− if (runTick !== localRunTick + 1) {
673− return;
674− }
675− status = STEP_RESULT;
676− step = result;
677− run(runTick);
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+ };
6781020 });
679− };
680− });
681− return;
682−
683− case THROW:
684− status = RETURN;
685− fail = util.left(step._1);
686− step = null;
687− break;
688−
689− // Enqueue the Catch so that we can call the error handler later on
690− // in case of an exception.
691− case CATCH:
692− if (bhead === null) {
693− attempts = new Aff(CONS, step, attempts, interrupt);
694− } else {
695− attempts = new Aff(CONS, step, new Aff(CONS, new Aff(RESUME, bhead, btail), attempts, interrupt), interrupt);
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;
6961069 }
697− bhead = null;
698− btail = null;
699− status = CONTINUE;
700− step = step._1;
7011070 break;
702−
703− // Enqueue the Bracket so that we can call the appropriate handlers
704− // after resource acquisition.
705− case BRACKET:
706− bracketCount++;
707− if (bhead === null) {
708− attempts = new Aff(CONS, step, attempts, interrupt);
1071+ case RETURN:
1072+ bhead = null;
1073+ btail = null;
1074+ if (attempts === null) {
1075+ status = COMPLETED;
1076+ step = interrupt || fail2 || step;
7091077 } else {
710− attempts = new Aff(CONS, step, new Aff(CONS, new Aff(RESUME, bhead, btail), attempts, interrupt), interrupt);
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+ }
7111148 }
712− bhead = null;
713− btail = null;
714− status = CONTINUE;
715− step = step._1;
7161149 break;
717−
718− case FORK:
719− status = STEP_RESULT;
720− tmp = Fiber(util, supervisor, step._2);
721− if (supervisor) {
722− supervisor.register(tmp);
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+ }
7231156 }
724− if (step._1) {
725− tmp.run();
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);
7261168 }
727− step = util.right(tmp);
728− break;
729−
730− case SEQ:
1169+ return;
1170+ case SUSPENDED:
7311171 status = CONTINUE;
732− step = sequential(util, supervisor, step._1);
7331172 break;
734− }
735− break;
736−
737− case RETURN:
738− bhead = null;
739− btail = null;
740− // If the current stack has returned, and we have no other stacks to
741− // resume or finalizers to run, the fiber has halted and we can
742− // invoke all join callbacks. Otherwise we need to resume.
743− if (attempts === null) {
744− status = COMPLETED;
745− step = interrupt || fail || step;
746− } else {
747− // The interrupt status for the enqueued item.
748− tmp = attempts._3;
749− attempt = attempts._1;
750− attempts = attempts._2;
751−
752− switch (attempt.tag) {
753− // We cannot recover from an interrupt. Otherwise we should
754− // continue stepping, or run the exception handler if an exception
755− // was raised.
756− case CATCH:
757− // We should compare the interrupt status as well because we
758− // only want it to apply if there has been an interrupt since
759− // enqueuing the catch.
760− if (interrupt && interrupt !== tmp) {
761− status = RETURN;
762− } else if (fail) {
763− status = CONTINUE;
764− step = attempt._2(util.fromLeft(fail));
765− fail = null;
766− }
767− break;
768−
769− // We cannot resume from an interrupt or exception.
770− case RESUME:
771− // As with Catch, we only want to ignore in the case of an
772− // interrupt since enqueing the item.
773− if (interrupt && interrupt !== tmp || fail) {
774− status = RETURN;
775− } else {
776− bhead = attempt._1;
777− btail = attempt._2;
778− status = STEP_BIND;
779− step = util.fromRight(step);
780− }
781− break;
782−
783− // If we have a bracket, we should enqueue the handlers,
784− // and continue with the success branch only if the fiber has
785− // not been interrupted. If the bracket acquisition failed, we
786− // should not run either.
787− case BRACKET:
788− bracketCount--;
789− if (fail === null) {
790− result = util.fromRight(step);
791− // We need to enqueue the Release with the same interrupt
792− // status as the Bracket that is initiating it.
793− attempts = new Aff(CONS, new Aff(RELEASE, attempt._2, result), attempts, tmp);
794− // We should only coninue as long as the interrupt status has not changed or
795− // we are currently within a non-interruptable finalizer.
796− if (interrupt === tmp || bracketCount > 0) {
797− status = CONTINUE;
798− step = attempt._3(result);
799− }
800− }
801− break;
802−
803− // Enqueue the appropriate handler. We increase the bracket count
804− // because it should not be cancelled.
805− case RELEASE:
806− bracketCount++;
807− attempts = new Aff(CONS, new Aff(FINALIZED, step, fail), attempts, interrupt);
808− status = CONTINUE;
809− // It has only been killed if the interrupt status has changed
810− // since we enqueued the item.
811− if (interrupt && interrupt !== tmp) {
812− step = attempt._1.killed(util.fromLeft(interrupt))(attempt._2);
813− } else if (fail) {
814− step = attempt._1.failed(util.fromLeft(fail))(attempt._2);
815− } else {
816− step = attempt._1.completed(util.fromRight(step))(attempt._2);
817− }
818− fail = null;
819− break;
820−
821− case FINALIZER:
822− bracketCount++;
823− attempts = new Aff(CONS, new Aff(FINALIZED, step, fail), attempts, interrupt);
824− status = CONTINUE;
825− step = attempt._1;
826− break;
827−
828− case FINALIZED:
829− bracketCount--;
830− status = RETURN;
831− step = attempt._1;
832− fail = attempt._2;
833− break;
834− }
835− }
836− break;
837−
838− case COMPLETED:
839− for (var k in joins) {
840− if (joins.hasOwnProperty(k)) {
841− rethrow = rethrow && joins[k].rethrow;
842− runEff(joins[k].handler(step));
843− }
844− }
845− joins = null;
846− // If we have an interrupt and a fail, then the thread threw while
847− // running finalizers. This should always rethrow in a fresh stack.
848− if (interrupt && fail) {
849− setTimeout(function () {
850− throw util.fromLeft(fail);
851− }, 0);
852− // If we have an unhandled exception, and no other fiber has joined
853− // then we need to throw the exception in a fresh stack.
854− } else if (util.isLeft(step) && rethrow) {
855− setTimeout(function () {
856− // Guard on reathrow because a completely synchronous fiber can
857− // still have an observer which was added after-the-fact.
858− if (rethrow) {
859− throw util.fromLeft(step);
860− }
861− }, 0);
862− }
863− return;
864− case SUSPENDED:
865− status = CONTINUE;
866− break;
867− case PENDING: return;
1173+ case PENDING:
1174+ return;
8681175 }
8691176 }
8701177 }
871−
872− function onComplete(join) {
873− return function () {
1178+ function onComplete(join3) {
1179+ return function() {
8741180 if (status === COMPLETED) {
875− rethrow = rethrow && join.rethrow;
876− join.handler(step)();
877− return function () {};
1181+ rethrow = rethrow && join3.rethrow;
1182+ join3.handler(step)();
1183+ return function() {
1184+ };
8781185 }
879−
880− var jid = joinId++;
881− joins = joins || {};
882− joins[jid] = join;
883−
1186+ var jid = joinId++;
1187+ joins = joins || {};
1188+ joins[jid] = join3;
8841189 return function() {
8851190 if (joins !== null) {
8861191 delete joins[jid];
@@ -888,298 +1193,246 @@ var PS = {};
8881193 };
8891194 };
8901195 }
891−
892− function kill(error, cb) {
893− return function () {
1196+ function kill(error3, cb) {
1197+ return function() {
8941198 if (status === COMPLETED) {
8951199 cb(util.right(void 0))();
896− return function () {};
1200+ return function() {
1201+ };
8971202 }
898−
8991203 var canceler = onComplete({
9001204 rethrow: false,
901− handler: function (/* unused */) {
1205+ handler: function() {
9021206 return cb(util.right(void 0));
9031207 }
9041208 })();
905−
9061209 switch (status) {
907− case SUSPENDED:
908− interrupt = util.left(error);
909− status = COMPLETED;
910− step = interrupt;
911− run(runTick);
912− break;
913− case PENDING:
914− if (interrupt === null) {
915− interrupt = util.left(error);
916− }
917− if (bracketCount === 0) {
918− if (status === PENDING) {
919− attempts = new Aff(CONS, new Aff(FINALIZER, step(error)), attempts, interrupt);
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;
9201238 }
921− status = RETURN;
922− step = null;
923− fail = null;
924− run(++runTick);
925− }
926− break;
927− default:
928− if (interrupt === null) {
929− interrupt = util.left(error);
930− }
931− if (bracketCount === 0) {
932− status = RETURN;
933− step = null;
934− fail = null;
935− }
9361239 }
937−
9381240 return canceler;
9391241 };
9401242 }
941−
942− function join(cb) {
943− return function () {
1243+ function join2(cb) {
1244+ return function() {
9441245 var canceler = onComplete({
9451246 rethrow: false,
9461247 handler: cb
9471248 })();
9481249 if (status === SUSPENDED) {
949− run(runTick);
1250+ run2(runTick);
9501251 }
9511252 return canceler;
9521253 };
9531254 }
954−
9551255 return {
956− kill: kill,
957− join: join,
958− onComplete: onComplete,
959− isSuspended: function () {
1256+ kill,
1257+ join: join2,
1258+ onComplete,
1259+ isSuspended: function() {
9601260 return status === SUSPENDED;
9611261 },
962− run: function () {
1262+ run: function() {
9631263 if (status === SUSPENDED) {
9641264 if (!Scheduler.isDraining()) {
965− Scheduler.enqueue(function () {
966− run(runTick);
1265+ Scheduler.enqueue(function() {
1266+ run2(runTick);
9671267 });
9681268 } else {
969− run(runTick);
1269+ run2(runTick);
9701270 }
9711271 }
9721272 }
9731273 };
9741274 }
975−
9761275 function runPar(util, supervisor, par, cb) {
977− // Table of all forked fibers.
978− var fiberId = 0;
979− var fibers = {};
980−
981− // Table of currently running cancelers, as a product of `Alt` behavior.
982− var killId = 0;
983− var kills = {};
984−
985− // Error used for early cancelation on Alt branches.
986− var early = new Error("[ParAff] Early exit");
987−
988− // Error used to kill the entire tree.
1276+ var fiberId = 0;
1277+ var fibers = {};
1278+ var killId = 0;
1279+ var kills = {};
1280+ var early = new Error("[ParAff] Early exit");
9891281 var interrupt = null;
990−
991− // The root pointer of the tree.
992− var root = EMPTY;
993−
994− // Walks a tree, invoking all the cancelers. Returns the table of pending
995− // cancellation fibers.
996− function kill(error, par, cb) {
997− var step = par;
998− var head = null;
999− var tail = null;
1282+ var root = EMPTY;
1283+ function kill(error3, par2, cb2) {
1284+ var step = par2;
1285+ var head = null;
1286+ var tail = null;
10001287 var count = 0;
1001− var kills = {};
1288+ var kills2 = {};
10021289 var tmp, kid;
1003−
10041290 loop: while (true) {
10051291 tmp = null;
1006−
10071292 switch (step.tag) {
1008− case FORKED:
1009− if (step._3 === EMPTY) {
1010− tmp = fibers[step._1];
1011− kills[count++] = tmp.kill(error, function (result) {
1012− return function () {
1013− count--;
1014− if (count === 0) {
1015− cb(result)();
1016− }
1017− };
1018− });
1019− }
1020− // Terminal case.
1021− if (head === null) {
1022− break loop;
1023− }
1024− // Go down the right side of the tree.
1025− step = head._2;
1026− if (tail === null) {
1027− head = null;
1028− } else {
1029− head = tail._1;
1030− tail = tail._2;
1031− }
1032− break;
1033− case MAP:
1034− step = step._2;
1035− break;
1036− case APPLY:
1037− case ALT:
1038− if (head) {
1039− tail = new Aff(CONS, head, tail);
1040− }
1041− head = step;
1042− step = step._1;
1043− break;
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;
10441327 }
10451328 }
1046−
10471329 if (count === 0) {
1048− cb(util.right(void 0))();
1330+ cb2(util.right(void 0))();
10491331 } else {
1050− // Run the cancelation effects. We alias `count` because it's mutable.
10511332 kid = 0;
10521333 tmp = count;
10531334 for (; kid < tmp; kid++) {
1054− kills[kid] = kills[kid]();
1335+ kills2[kid] = kills2[kid]();
10551336 }
10561337 }
1057−
1058− return kills;
1338+ return kills2;
10591339 }
1060−
1061− // When a fiber resolves, we need to bubble back up the tree with the
1062− // result, computing the applicative nodes.
1063− function join(result, head, tail) {
1064− var fail, step, lhs, rhs, tmp, kid;
1065−
1340+ function join2(result, head, tail) {
1341+ var fail2, step, lhs, rhs, tmp, kid;
10661342 if (util.isLeft(result)) {
1067− fail = result;
1343+ fail2 = result;
10681344 step = null;
10691345 } else {
10701346 step = result;
1071− fail = null;
1347+ fail2 = null;
10721348 }
1073−
10741349 loop: while (true) {
10751350 lhs = null;
10761351 rhs = null;
10771352 tmp = null;
10781353 kid = null;
1079−
1080− // We should never continue if the entire tree has been interrupted.
10811354 if (interrupt !== null) {
10821355 return;
10831356 }
1084−
1085− // We've made it all the way to the root of the tree, which means
1086− // the tree has fully evaluated.
10871357 if (head === null) {
1088− cb(fail || step)();
1358+ cb(fail2 || step)();
10891359 return;
10901360 }
1091−
1092− // The tree has already been computed, so we shouldn't try to do it
1093− // again. This should never happen.
1094− // TODO: Remove this?
10951361 if (head._3 !== EMPTY) {
10961362 return;
10971363 }
1098−
10991364 switch (head.tag) {
1100− case MAP:
1101− if (fail === null) {
1102− head._3 = util.right(head._1(util.fromRight(step)));
1103− step = head._3;
1104− } else {
1105− head._3 = fail;
1106− }
1107− break;
1108− case APPLY:
1109− lhs = head._1._3;
1110− rhs = head._2._3;
1111− // If we have a failure we should kill the other side because we
1112− // can't possible yield a result anymore.
1113− if (fail) {
1114− head._3 = fail;
1115− tmp = true;
1116− kid = killId++;
1117−
1118− kills[kid] = kill(early, fail === lhs ? head._2 : head._1, function (/* unused */) {
1119− return function () {
1120− delete kills[kid];
1121− if (tmp) {
1122− tmp = false;
1123− } else if (tail === null) {
1124− join(fail, null, null);
1125− } else {
1126− join(fail, tail._1, tail._2);
1127− }
1128− };
1129− });
1130−
1131− if (tmp) {
1132− tmp = false;
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) {
11331397 return;
1398+ } else {
1399+ step = util.right(util.fromRight(lhs)(util.fromRight(rhs)));
1400+ head._3 = step;
11341401 }
1135− } else if (lhs === EMPTY || rhs === EMPTY) {
1136− // We can only proceed if both sides have resolved.
1137− return;
1138− } else {
1139− step = util.right(util.fromRight(lhs)(util.fromRight(rhs)));
1140− head._3 = step;
1141− }
1142− break;
1143− case ALT:
1144− lhs = head._1._3;
1145− rhs = head._2._3;
1146− // We can only proceed if both have resolved or we have a success
1147− if (lhs === EMPTY && util.isLeft(rhs) || rhs === EMPTY && util.isLeft(lhs)) {
1148− return;
1149− }
1150− // If both sides resolve with an error, we should continue with the
1151− // first error
1152− if (lhs !== EMPTY && util.isLeft(lhs) && rhs !== EMPTY && util.isLeft(rhs)) {
1153− fail = step === lhs ? rhs : lhs;
1154− step = null;
1155− head._3 = fail;
1156− } else {
1157− head._3 = step;
1158− tmp = true;
1159− kid = killId++;
1160− // Once a side has resolved, we need to cancel the side that is still
1161− // pending before we can continue.
1162− kills[kid] = kill(early, step === lhs ? head._2 : head._1, function (/* unused */) {
1163− return function () {
1164− delete kills[kid];
1165− if (tmp) {
1166− tmp = false;
1167− } else if (tail === null) {
1168− join(step, null, null);
1169− } else {
1170− join(step, tail._1, tail._2);
1171− }
1172− };
1173− });
1174−
1175− if (tmp) {
1176− tmp = false;
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)) {
11771407 return;
11781408 }
1179− }
1180− break;
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;
11811435 }
1182−
11831436 if (tail === null) {
11841437 head = null;
11851438 } else {
@@ -1188,115 +1441,92 @@ var PS = {};
11881441 }
11891442 }
11901443 }
1191−
11921444 function resolve(fiber) {
1193− return function (result) {
1194− return function () {
1445+ return function(result) {
1446+ return function() {
11951447 delete fibers[fiber._1];
11961448 fiber._3 = result;
1197− join(result, fiber._2._1, fiber._2._2);
1449+ join2(result, fiber._2._1, fiber._2._2);
11981450 };
11991451 };
12001452 }
1201−
1202− // Walks the applicative tree, substituting non-applicative nodes with
1203− // `FORKED` nodes. In this tree, all applicative nodes use the `_3` slot
1204− // as a mutable slot for memoization. In an unresolved state, the `_3`
1205− // slot is `EMPTY`. In the cases of `ALT` and `APPLY`, we always walk
1206− // the left side first, because both operations are left-associative. As
1207− // we `RETURN` from those branches, we then walk the right side.
1208− function run() {
1453+ function run2() {
12091454 var status = CONTINUE;
1210− var step = par;
1211− var head = null;
1212− var tail = null;
1455+ var step = par;
1456+ var head = null;
1457+ var tail = null;
12131458 var tmp, fid;
1214−
12151459 loop: while (true) {
12161460 tmp = null;
12171461 fid = null;
1218−
12191462 switch (status) {
1220− case CONTINUE:
1221− switch (step.tag) {
1222− case MAP:
1223− if (head) {
1224− tail = new Aff(CONS, head, tail);
1225− }
1226− head = new Aff(MAP, step._1, EMPTY, EMPTY);
1227− step = step._2;
1228− break;
1229− case APPLY:
1230− if (head) {
1231− tail = new Aff(CONS, head, tail);
1232− }
1233− head = new Aff(APPLY, EMPTY, step._2, EMPTY);
1234− step = step._1;
1235− break;
1236− case ALT:
1237− if (head) {
1238− tail = new Aff(CONS, head, tail);
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+ }
12391500 }
1240− head = new Aff(ALT, EMPTY, step._2, EMPTY);
1241− step = step._1;
12421501 break;
1243− default:
1244− // When we hit a leaf value, we suspend the stack in the `FORKED`.
1245− // When the fiber resolves, it can bubble back up the tree.
1246− fid = fiberId++;
1247− status = RETURN;
1248− tmp = step;
1249− step = new Aff(FORKED, fid, new Aff(CONS, head, tail), EMPTY);
1250− tmp = Fiber(util, supervisor, tmp);
1251− tmp.onComplete({
1252− rethrow: false,
1253− handler: resolve(step)
1254− })();
1255− fibers[fid] = tmp;
1256− if (supervisor) {
1257− supervisor.register(tmp);
1502+ case RETURN:
1503+ if (head === null) {
1504+ break loop;
12581505 }
1259− }
1260− break;
1261− case RETURN:
1262− // Terminal case, we are back at the root.
1263− if (head === null) {
1264− break loop;
1265− }
1266− // If we are done with the right side, we need to continue down the
1267− // left. Otherwise we should continue up the stack.
1268− if (head._1 === EMPTY) {
1269− head._1 = step;
1270− status = CONTINUE;
1271− step = head._2;
1272− head._2 = EMPTY;
1273− } else {
1274− head._2 = step;
1275− step = head;
1276− if (tail === null) {
1277− head = null;
1506+ if (head._1 === EMPTY) {
1507+ head._1 = step;
1508+ status = CONTINUE;
1509+ step = head._2;
1510+ head._2 = EMPTY;
12781511 } else {
1279− head = tail._1;
1280− tail = tail._2;
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+ }
12811520 }
1282− }
12831521 }
12841522 }
1285−
1286− // Keep a reference to the tree root so it can be cancelled.
12871523 root = step;
1288−
12891524 for (fid = 0; fid < fiberId; fid++) {
12901525 fibers[fid].run();
12911526 }
12921527 }
1293−
1294− // Cancels the entire tree. If there are already subtrees being canceled,
1295− // we need to first cancel those joins. We will then add fresh joins for
1296− // all pending branches including those that were in the process of being
1297− // canceled.
1298− function cancel(error, cb) {
1299− interrupt = util.left(error);
1528+ function cancel(error3, cb2) {
1529+ interrupt = util.left(error3);
13001530 var innerKills;
13011531 for (var kid in kills) {
13021532 if (kills.hasOwnProperty(kid)) {
@@ -1308,637 +1538,744 @@ var PS = {};
13081538 }
13091539 }
13101540 }
1311−
13121541 kills = null;
1313− var newKills = kill(error, root, cb);
1314−
1315− return function (killError) {
1316− return new Aff(ASYNC, function (killCb) {
1317− return function () {
1318− for (var kid in newKills) {
1319− if (newKills.hasOwnProperty(kid)) {
1320− newKills[kid]();
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]();
13211549 }
13221550 }
1323− return nonCanceler;
1551+ return nonCanceler2;
13241552 };
13251553 });
13261554 };
13271555 }
1328−
1329− run();
1330−
1331− return function (killError) {
1332− return new Aff(ASYNC, function (killCb) {
1333− return function () {
1556+ run2();
1557+ return function(killError) {
1558+ return new Aff2(ASYNC, function(killCb) {
1559+ return function() {
13341560 return cancel(killError, killCb);
13351561 };
13361562 });
13371563 };
13381564 }
1339−
1340− function sequential(util, supervisor, par) {
1341− return new Aff(ASYNC, function (cb) {
1342− return function () {
1565+ function sequential2(util, supervisor, par) {
1566+ return new Aff2(ASYNC, function(cb) {
1567+ return function() {
13431568 return runPar(util, supervisor, par, cb);
13441569 };
13451570 });
13461571 }
1347−
1348− Aff.EMPTY = EMPTY;
1349− Aff.Pure = AffCtr(PURE);
1350− Aff.Throw = AffCtr(THROW);
1351− Aff.Catch = AffCtr(CATCH);
1352− Aff.Sync = AffCtr(SYNC);
1353− Aff.Async = AffCtr(ASYNC);
1354− Aff.Bind = AffCtr(BIND);
1355− Aff.Bracket = AffCtr(BRACKET);
1356− Aff.Fork = AffCtr(FORK);
1357− Aff.Seq = AffCtr(SEQ);
1358− Aff.ParMap = AffCtr(MAP);
1359− Aff.ParApply = AffCtr(APPLY);
1360− Aff.ParAlt = AffCtr(ALT);
1361− Aff.Fiber = Fiber;
1362− Aff.Supervisor = Supervisor;
1363− Aff.Scheduler = Scheduler;
1364− Aff.nonCanceler = nonCanceler;
1365−
1366− return Aff;
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;
13671590 }();
1368−
1369− exports._pure = Aff.Pure;
1370−
1371− exports._throwError = Aff.Throw;
1372−
1373− exports._catchError = function (aff) {
1374− return function (k) {
1591+ var _pure = Aff.Pure;
1592+ var _throwError = Aff.Throw;
1593+ function _catchError(aff) {
1594+ return function(k) {
13751595 return Aff.Catch(aff, k);
13761596 };
1377− };
1378−
1379− exports._map = function (f) {
1380− return function (aff) {
1597+ }
1598+ function _map(f) {
1599+ return function(aff) {
13811600 if (aff.tag === Aff.Pure.tag) {
13821601 return Aff.Pure(f(aff._1));
13831602 } else {
1384− return Aff.Bind(aff, function (value) {
1603+ return Aff.Bind(aff, function(value) {
13851604 return Aff.Pure(f(value));
13861605 });
13871606 }
13881607 };
1389− };
1390−
1391− exports._bind = function (aff) {
1392− return function (k) {
1608+ }
1609+ function _bind(aff) {
1610+ return function(k) {
13931611 return Aff.Bind(aff, k);
13941612 };
1395− };
1396−
1397− exports._liftEffect = Aff.Sync;
1398−
1399− exports.makeAff = Aff.Async;
1400−
1401− exports._makeFiber = function (util, aff) {
1402− return function () {
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() {
14031628 return Aff.Fiber(util, null, aff);
14041629 };
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;
14051639 };
1406−})(PS["Effect.Aff"] = PS["Effect.Aff"] || {});
1407−(function(exports) {
1408− // Generated by purs version 0.12.0
1409− "use strict";
1410− var Control_Category = PS["Control.Category"];
1411− var Control_Monad = PS["Control.Monad"];
1412− var Effect = PS["Effect"];
1413− var MonadEffect = function (Monad0, liftEffect) {
1414− this.Monad0 = Monad0;
1415− this.liftEffect = liftEffect;
1416− };
1417− var liftEffect = function (dict) {
1418− return dict.liftEffect;
1419− };
1420− exports["liftEffect"] = liftEffect;
1421− exports["MonadEffect"] = MonadEffect;
1422−})(PS["Effect.Class"] = PS["Effect.Class"] || {});
1423−(function(exports) {
1424− "use strict";
14251640
1426− exports.throwException = function (e) {
1427− return function () {
1428− throw e;
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+ };
14291668 };
14301669 };
1431−})(PS["Effect.Exception"] = PS["Effect.Exception"] || {});
1432−(function(exports) {
1433− // Generated by purs version 0.12.0
1434− "use strict";
1435− var $foreign = PS["Effect.Exception"];
1436− var Control_Applicative = PS["Control.Applicative"];
1437− var Control_Semigroupoid = PS["Control.Semigroupoid"];
1438− var Data_Either = PS["Data.Either"];
1439− var Data_Functor = PS["Data.Functor"];
1440− var Data_Maybe = PS["Data.Maybe"];
1441− var Data_Show = PS["Data.Show"];
1442− var Effect = PS["Effect"];
1443− var Prelude = PS["Prelude"];
1444− exports["throwException"] = $foreign.throwException;
1445−})(PS["Effect.Exception"] = PS["Effect.Exception"] || {});
1446−(function(exports) {
1447− "use strict";
1448−
1449− // module Partial.Unsafe
14501670
1451− exports.unsafePartial = function (f) {
1671+ // output/Partial.Unsafe/foreign.js
1672+ var _unsafePartial = function(f) {
14521673 return f();
14531674 };
1454−})(PS["Partial.Unsafe"] = PS["Partial.Unsafe"] || {});
1455−(function(exports) {
1456− "use strict";
14571675
1458− // module Partial
1676+ // output/Partial/foreign.js
1677+ var _crashWith = function(msg) {
1678+ throw new Error(msg);
1679+ };
14591680
1460− exports.crashWith = function () {
1461− return function (msg) {
1462− throw new Error(msg);
1463− };
1464− };
1465−})(PS["Partial"] = PS["Partial"] || {});
1466−(function(exports) {
1467− // Generated by purs version 0.12.0
1468− "use strict";
1469− var $foreign = PS["Partial"];
1470− exports["crashWith"] = $foreign.crashWith;
1471−})(PS["Partial"] = PS["Partial"] || {});
1472−(function(exports) {
1473− // Generated by purs version 0.12.0
1474− "use strict";
1475− var $foreign = PS["Partial.Unsafe"];
1476− var Partial = PS["Partial"];
1477− var unsafeCrashWith = function (msg) {
1478− return $foreign.unsafePartial(function (dictPartial) {
1479− return Partial.crashWith(dictPartial)(msg);
1480− });
1681+ // output/Partial/index.js
1682+ var crashWith = function() {
1683+ return _crashWith;
14811684 };
1482− exports["unsafeCrashWith"] = unsafeCrashWith;
1483−})(PS["Partial.Unsafe"] = PS["Partial.Unsafe"] || {});
1484−(function(exports) {
1485− // Generated by purs version 0.12.0
1486− "use strict";
1487− var $foreign = PS["Effect.Aff"];
1488− var Control_Alt = PS["Control.Alt"];
1489− var Control_Alternative = PS["Control.Alternative"];
1490− var Control_Applicative = PS["Control.Applicative"];
1491− var Control_Apply = PS["Control.Apply"];
1492− var Control_Bind = PS["Control.Bind"];
1493− var Control_Lazy = PS["Control.Lazy"];
1494− var Control_Monad = PS["Control.Monad"];
1495− var Control_Monad_Error_Class = PS["Control.Monad.Error.Class"];
1496− var Control_Monad_Rec_Class = PS["Control.Monad.Rec.Class"];
1497− var Control_Parallel = PS["Control.Parallel"];
1498− var Control_Parallel_Class = PS["Control.Parallel.Class"];
1499− var Control_Plus = PS["Control.Plus"];
1500− var Control_Semigroupoid = PS["Control.Semigroupoid"];
1501− var Data_Either = PS["Data.Either"];
1502− var Data_Foldable = PS["Data.Foldable"];
1503− var Data_Function = PS["Data.Function"];
1504− var Data_Function_Uncurried = PS["Data.Function.Uncurried"];
1505− var Data_Functor = PS["Data.Functor"];
1506− var Data_Monoid = PS["Data.Monoid"];
1507− var Data_Newtype = PS["Data.Newtype"];
1508− var Data_Semigroup = PS["Data.Semigroup"];
1509− var Data_Time_Duration = PS["Data.Time.Duration"];
1510− var Data_Unit = PS["Data.Unit"];
1511− var Effect = PS["Effect"];
1512− var Effect_Class = PS["Effect.Class"];
1513− var Effect_Exception = PS["Effect.Exception"];
1514− var Effect_Unsafe = PS["Effect.Unsafe"];
1515− var Partial_Unsafe = PS["Partial.Unsafe"];
1516− var Prelude = PS["Prelude"];
1517− var Unsafe_Coerce = PS["Unsafe.Coerce"];
1518− var functorAff = new Data_Functor.Functor($foreign._map);
1519− var ffiUtil = (function () {
1520− var unsafeFromRight = function (v) {
1521− if (v instanceof Data_Either.Right) {
1522− return v.value0;
1523− };
1524− if (v instanceof Data_Either.Left) {
1525− return Partial_Unsafe.unsafeCrashWith("unsafeFromRight: Left");
1526− };
1527− throw new Error("Failed pattern match at Effect.Aff line 400, column 21 - line 402, column 31: " + [ v.constructor.name ]);
1528− };
1529− var unsafeFromLeft = function (v) {
1530− if (v instanceof Data_Either.Left) {
1531− return v.value0;
1532− };
1533− if (v instanceof Data_Either.Right) {
1534− return Partial_Unsafe.unsafeCrashWith("unsafeFromLeft: Right");
1535− };
1536− throw new Error("Failed pattern match at Effect.Aff line 395, column 20 - line 399, column 3: " + [ v.constructor.name ]);
1537− };
1538− var isLeft = function (v) {
1539− if (v instanceof Data_Either.Left) {
1540− return true;
1541− };
1542− if (v instanceof Data_Either.Right) {
1543− return false;
1544− };
1545− throw new Error("Failed pattern match at Effect.Aff line 390, column 12 - line 392, column 20: " + [ v.constructor.name ]);
1546− };
1547− return {
1548− isLeft: isLeft,
1549− fromLeft: unsafeFromLeft,
1550− fromRight: unsafeFromRight,
1551− left: Data_Either.Left.create,
1552− right: Data_Either.Right.create
1553− };
1554− })();
1555− var makeFiber = function (aff) {
1556− return $foreign._makeFiber(ffiUtil, aff);
1557− };
1558− var launchAff = function (aff) {
1559− return function __do() {
1560− var v = makeFiber(aff)();
1561− v.run();
1562− return v;
1563− };
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+ });
15641693 };
1565− var monadAff = new Control_Monad.Monad(function () {
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() {
15661775 return applicativeAff;
1567− }, function () {
1776+ },
1777+ Bind1: function() {
15681778 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+ };
15691800 });
1570− var bindAff = new Control_Bind.Bind(function () {
1571− return applyAff;
1572− }, $foreign._bind);
1573− var applyAff = new Control_Apply.Apply(function () {
1574− return functorAff;
1575− }, Control_Monad.ap(monadAff));
1576− var applicativeAff = new Control_Applicative.Applicative(function () {
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() {
15771808 return applyAff;
1578− }, $foreign._pure);
1579− var monadEffectAff = new Effect_Class.MonadEffect(function () {
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() {
15801836 return monadAff;
1581− }, $foreign._liftEffect);
1582− var monadThrowAff = new Control_Monad_Error_Class.MonadThrow(function () {
1837+ }
1838+ };
1839+ var liftEffect2 = /* @__PURE__ */ liftEffect(monadEffectAff);
1840+ var monadThrowAff = {
1841+ throwError: _throwError,
1842+ Monad0: function() {
15831843 return monadAff;
1584− }, $foreign._throwError);
1585− var monadErrorAff = new Control_Monad_Error_Class.MonadError(function () {
1844+ }
1845+ };
1846+ var monadErrorAff = {
1847+ catchError: _catchError,
1848+ MonadThrow0: function() {
15861849 return monadThrowAff;
1587− }, $foreign._catchError);
1588− var runAff = function (k) {
1589− return function (aff) {
1590− return launchAff(Control_Bind.bindFlipped(bindAff)(function ($52) {
1591− return Effect_Class.liftEffect(monadEffectAff)(k($52));
1592− })(Control_Monad_Error_Class["try"](monadErrorAff)(aff)));
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);
15931902 };
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+ };
15941912 };
1595− var runAff_ = function (k) {
1596− return function (aff) {
1597− return Data_Functor["void"](Effect.functorEffect)(runAff(k)(aff));
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]);
15981927 };
1928+ };
1929+ };
1930+ var readString = function(dictMonad) {
1931+ return unsafeReadTagged(dictMonad)("String");
15991932 };
1600− var nonCanceler = Data_Function["const"](Control_Applicative.pure(applicativeAff)(Data_Unit.unit));
1601− exports["launchAff"] = launchAff;
1602− exports["runAff"] = runAff;
1603− exports["runAff_"] = runAff_;
1604− exports["nonCanceler"] = nonCanceler;
1605− exports["functorAff"] = functorAff;
1606− exports["applyAff"] = applyAff;
1607− exports["applicativeAff"] = applicativeAff;
1608− exports["bindAff"] = bindAff;
1609− exports["monadAff"] = monadAff;
1610− exports["monadThrowAff"] = monadThrowAff;
1611− exports["monadErrorAff"] = monadErrorAff;
1612− exports["monadEffectAff"] = monadEffectAff;
1613− exports["makeAff"] = $foreign.makeAff;
1614−})(PS["Effect.Aff"] = PS["Effect.Aff"] || {});
1615−(function(exports) {
16161933
1617− exports.promiseToEffectImpl = function (promise, onFulfilled, onRejected) {
1618− return function () {
1619− return promise.then(function (a) {
1620− return onFulfilled(a)();
1621− }, function (err) {
1622− return onRejected(err)();
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+ }));
16231945 });
16241946 };
16251947 };
1626−})(PS["Effect.Promise"] = PS["Effect.Promise"] || {});
1627−(function(exports) {exports.undefer = function (f) {
1628− return f();
1629− };
1630−})(PS["Effect.Promise.Unsafe"] = PS["Effect.Promise.Unsafe"] || {});
1631−(function(exports) {
1632− // Generated by purs version 0.12.0
1633− "use strict";
1634− var $foreign = PS["Effect.Promise.Unsafe"];
1635− exports["undefer"] = $foreign.undefer;
1636−})(PS["Effect.Promise.Unsafe"] = PS["Effect.Promise.Unsafe"] || {});
1637−(function(exports) {
1638− // Generated by purs version 0.12.0
1639− "use strict";
1640− var $foreign = PS["Effect.Promise"];
1641− var Control_Applicative = PS["Control.Applicative"];
1642− var Control_Apply = PS["Control.Apply"];
1643− var Control_Bind = PS["Control.Bind"];
1644− var Control_Monad = PS["Control.Monad"];
1645− var Control_Monad_Error_Class = PS["Control.Monad.Error.Class"];
1646− var Control_Semigroupoid = PS["Control.Semigroupoid"];
1647− var Data_Array = PS["Data.Array"];
1648− var Data_Either = PS["Data.Either"];
1649− var Data_Foldable = PS["Data.Foldable"];
1650− var Data_Function = PS["Data.Function"];
1651− var Data_Function_Uncurried = PS["Data.Function.Uncurried"];
1652− var Data_Functor = PS["Data.Functor"];
1653− var Data_Monoid = PS["Data.Monoid"];
1654− var Data_Semigroup = PS["Data.Semigroup"];
1655− var Data_Time_Duration = PS["Data.Time.Duration"];
1656− var Data_Unfoldable = PS["Data.Unfoldable"];
1657− var Data_Unit = PS["Data.Unit"];
1658− var Effect = PS["Effect"];
1659− var Effect_Class = PS["Effect.Class"];
1660− var Effect_Exception = PS["Effect.Exception"];
1661− var Effect_Promise_Unsafe = PS["Effect.Promise.Unsafe"];
1662− var Prelude = PS["Prelude"];
1663− var runPromise = function (onSucc) {
1664− return function (onErr) {
1665− return function (p) {
1666− return $foreign.promiseToEffectImpl(Effect_Promise_Unsafe.undefer(function (dictDeferred) {
1667− return p(dictDeferred);
1668− }), onSucc, onErr);
1669− };
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);
16701966 };
1967+ };
1968+ };
1969+ var readProp = function(dictMonad) {
1970+ return unsafeReadProp(dictMonad);
16711971 };
1672− exports["runPromise"] = runPromise;
1673−})(PS["Effect.Promise"] = PS["Effect.Promise"] || {});
1674−(function(exports) {
1675− // Generated by purs version 0.12.0
1676− "use strict";
1677− var $foreign = PS["Crypto.Subtle.Hash"];
1678− var Control_Semigroupoid = PS["Control.Semigroupoid"];
1679− var Data_ArrayBuffer_Types = PS["Data.ArrayBuffer.Types"];
1680− var Data_Either = PS["Data.Either"];
1681− var Data_Function_Uncurried = PS["Data.Function.Uncurried"];
1682− var Data_Functor = PS["Data.Functor"];
1683− var Effect = PS["Effect"];
1684− var Effect_Aff = PS["Effect.Aff"];
1685− var Effect_Promise = PS["Effect.Promise"];
1686− var Prelude = PS["Prelude"];
1687− var sha512 = "SHA-512";
1688− var sha384 = "SHA-384";
1689− var sha256 = "SHA-256";
1690− var sha1 = "SHA-1";
1691− exports["sha1"] = sha1;
1692− exports["sha256"] = sha256;
1693− exports["sha384"] = sha384;
1694− exports["sha512"] = sha512;
1695−})(PS["Crypto.Subtle.Hash"] = PS["Crypto.Subtle.Hash"] || {});
1696−(function(exports) {
1697− "use strict";
16981972
1699− exports.generateKeyImpl = function generateKeyImpl (a,e,u) {
1700− return crypto.subtle.generateKey(a,e,u);
1701− };
1702−})(PS["Crypto.Subtle.Key.Generate"] = PS["Crypto.Subtle.Key.Generate"] || {});
1703−(function(exports) {
1704− // Generated by purs version 0.12.0
1705− "use strict";
1706− var $foreign = PS["Crypto.Subtle.Key.Types"];
1707− var Control_Semigroupoid = PS["Control.Semigroupoid"];
1708− var Data_ArrayBuffer_Types = PS["Data.ArrayBuffer.Types"];
1709− var Data_Either = PS["Data.Either"];
1710− var Data_Function_Uncurried = PS["Data.Function.Uncurried"];
1711− var Data_Functor = PS["Data.Functor"];
1712− var Effect = PS["Effect"];
1713− var Effect_Aff = PS["Effect.Aff"];
1714− var Effect_Promise = PS["Effect.Promise"];
1715− var Foreign = PS["Foreign"];
1716− var Prelude = PS["Prelude"];
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);
17171977 var wrapKey = "wrapKey";
17181978 var verify = "verify";
17191979 var unwrapKey = "unwrapKey";
1720− var sign = "sign";
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+ };
17211999 var encrypt = "encrypt";
17222000 var deriveKey = "deriveKey";
17232001 var deriveBits = "deriveBits";
17242002 var decrypt = "decrypt";
1725− var allUsages = [ encrypt, decrypt, sign, verify, deriveKey, deriveBits, wrapKey, unwrapKey ];
1726− exports["encrypt"] = encrypt;
1727− exports["decrypt"] = decrypt;
1728− exports["sign"] = sign;
1729− exports["verify"] = verify;
1730− exports["deriveKey"] = deriveKey;
1731− exports["deriveBits"] = deriveBits;
1732− exports["unwrapKey"] = unwrapKey;
1733− exports["wrapKey"] = wrapKey;
1734− exports["allUsages"] = allUsages;
1735−})(PS["Crypto.Subtle.Key.Types"] = PS["Crypto.Subtle.Key.Types"] || {});
1736−(function(exports) {
1737− // Generated by purs version 0.12.0
1738− "use strict";
1739− var $foreign = PS["Crypto.Subtle.Key.Generate"];
1740− var Control_Semigroupoid = PS["Control.Semigroupoid"];
1741− var Crypto_Subtle_Constants_AES = PS["Crypto.Subtle.Constants.AES"];
1742− var Crypto_Subtle_Constants_EC = PS["Crypto.Subtle.Constants.EC"];
1743− var Crypto_Subtle_Constants_RSA = PS["Crypto.Subtle.Constants.RSA"];
1744− var Crypto_Subtle_Hash = PS["Crypto.Subtle.Hash"];
1745− var Crypto_Subtle_Key_Types = PS["Crypto.Subtle.Key.Types"];
1746− var Data_ArrayBuffer_Types = PS["Data.ArrayBuffer.Types"];
1747− var Data_Either = PS["Data.Either"];
1748− var Data_Function_Uncurried = PS["Data.Function.Uncurried"];
1749− var Data_Functor = PS["Data.Functor"];
1750− var Effect = PS["Effect"];
1751− var Effect_Aff = PS["Effect.Aff"];
1752− var Effect_Promise = PS["Effect.Promise"];
1753− var Prelude = PS["Prelude"];
1754− var Unsafe_Coerce = PS["Unsafe.Coerce"];
1755− var hmac = function (h) {
1756− return {
1757− name: "HMAC",
1758− hash: h
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+ };
17592029 };
2030+ };
17602031 };
1761− var generateKey = function (a) {
1762− return function (e) {
1763− return function (u) {
1764− return Effect_Aff.makeAff(function (resolve) {
1765− return Data_Functor.voidRight(Effect.functorEffect)(Effect_Aff.nonCanceler)(Effect_Promise.runPromise(function ($1) {
1766− return resolve(Data_Either.Right.create($1));
1767− })(function ($2) {
1768− return resolve(Data_Either.Left.create($2));
1769− })(function (dictDeferred) {
1770− return $foreign.generateKeyImpl(a, e, u);
1771− }));
1772− });
1773− };
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));
17742042 };
2043+ };
17752044 };
1776− var ec = function (e) {
1777− return function (c) {
1778− return {
1779− name: e,
1780− namedCurve: c
1781− };
2045+ var generateKey = function(a) {
2046+ return function(e) {
2047+ return function(u) {
2048+ return toAff$prime(errorFromDOMException)(generateKeyImpl(a, e, u));
17822049 };
2050+ };
17832051 };
1784− var aes = function (a) {
1785− return function (l) {
1786− return {
1787− name: a,
1788− length: l
1789− };
2052+ var ec = function(e) {
2053+ return function(c) {
2054+ return {
2055+ name: e,
2056+ namedCurve: c
17902057 };
2058+ };
2059+ };
2060+ var aes = function(a) {
2061+ return function(l) {
2062+ return {
2063+ name: a,
2064+ length: l
2065+ };
2066+ };
17912067 };
1792− exports["generateKey"] = generateKey;
1793− exports["ec"] = ec;
1794− exports["hmac"] = hmac;
1795− exports["aes"] = aes;
1796−})(PS["Crypto.Subtle.Key.Generate"] = PS["Crypto.Subtle.Key.Generate"] || {});
1797−(function(exports) {
1798− "use strict";
17992068
1800− exports.log = function (s) {
1801− return function () {
2069+ // output/Effect.Console/foreign.js
2070+ var log2 = function(s) {
2071+ return function() {
18022072 console.log(s);
1803− return {};
1804− };
1805− };
1806−})(PS["Effect.Console"] = PS["Effect.Console"] || {});
1807−(function(exports) {
1808− // Generated by purs version 0.12.0
1809− "use strict";
1810− var $foreign = PS["Effect.Console"];
1811− var Data_Show = PS["Data.Show"];
1812− var Data_Unit = PS["Data.Unit"];
1813− var Effect = PS["Effect"];
1814− exports["log"] = $foreign.log;
1815−})(PS["Effect.Console"] = PS["Effect.Console"] || {});
1816−(function(exports) {
1817− // Generated by purs version 0.12.0
1818− "use strict";
1819− var Control_Applicative = PS["Control.Applicative"];
1820− var Control_Bind = PS["Control.Bind"];
1821− var Control_Semigroupoid = PS["Control.Semigroupoid"];
1822− var Crypto_Subtle_Constants_AES = PS["Crypto.Subtle.Constants.AES"];
1823− var Crypto_Subtle_Constants_EC = PS["Crypto.Subtle.Constants.EC"];
1824− var Crypto_Subtle_Hash = PS["Crypto.Subtle.Hash"];
1825− var Crypto_Subtle_Key_Generate = PS["Crypto.Subtle.Key.Generate"];
1826− var Crypto_Subtle_Key_Types = PS["Crypto.Subtle.Key.Types"];
1827− var Data_Either = PS["Data.Either"];
1828− var Data_Unit = PS["Data.Unit"];
1829− var Effect = PS["Effect"];
1830− var Effect_Aff = PS["Effect.Aff"];
1831− var Effect_Class = PS["Effect.Class"];
1832− var Effect_Console = PS["Effect.Console"];
1833− var Effect_Exception = PS["Effect.Exception"];
1834− var Prelude = PS["Prelude"];
1835− var Unsafe_Coerce = PS["Unsafe.Coerce"];
1836− var log$prime = function ($23) {
1837− return Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Effect_Console.log($23));
1838− };
1839− var main = (function () {
1840− var resolve = function (eX) {
1841− if (eX instanceof Data_Either.Left) {
1842− return Effect_Exception.throwException(eX.value0);
1843− };
1844− if (eX instanceof Data_Either.Right) {
1845− return Control_Applicative.pure(Effect.applicativeEffect)(Data_Unit.unit);
1846− };
1847− throw new Error("Failed pattern match at Test.Main line 23, column 20 - line 25, column 29: " + [ eX.constructor.name ]);
1848− };
1849− return Effect_Aff.runAff_(resolve)(Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(log$prime("Generating Keys..."))(function () {
1850− return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)((function () {
1851− var genAES = function (mode) {
1852− return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(Control_Bind.bind(Effect_Aff.bindAff)(Crypto_Subtle_Key_Generate.generateKey(Crypto_Subtle_Key_Generate.aes(mode)(Crypto_Subtle_Constants_AES.l128))(true)(Crypto_Subtle_Key_Types.allUsages))(function (v) {
1853− return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(log$prime(" - 128"))(function () {
1854− return log$prime(v);
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+ });
18552171 });
1856− }))(function () {
1857− return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(Control_Bind.bind(Effect_Aff.bindAff)(Crypto_Subtle_Key_Generate.generateKey(Crypto_Subtle_Key_Generate.aes(mode)(Crypto_Subtle_Constants_AES.l192))(true)(Crypto_Subtle_Key_Types.allUsages))(function (v) {
1858− return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(log$prime(" - 192"))(function () {
1859− return log$prime(v);
1860− });
1861− }))(function () {
1862− return Control_Bind.bind(Effect_Aff.bindAff)(Crypto_Subtle_Key_Generate.generateKey(Crypto_Subtle_Key_Generate.aes(mode)(Crypto_Subtle_Constants_AES.l256))(true)(Crypto_Subtle_Key_Types.allUsages))(function (v) {
1863− return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(log$prime(" - 256"))(function () {
1864− return log$prime(v);
1865− });
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);
18662183 });
2184+ });
18672185 });
2186+ });
18682187 });
1869− };
1870− return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(log$prime("- AES-CTR"))(function () {
1871− return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(genAES(Crypto_Subtle_Constants_AES.aesCTR))(function () {
1872− return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(log$prime("- AES-CBC"))(function () {
1873− return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(genAES(Crypto_Subtle_Constants_AES.aesCBC))(function () {
1874− return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(log$prime("- AES-GCM"))(function () {
1875− return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(genAES(Crypto_Subtle_Constants_AES.aesGCM))(function () {
1876− return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(log$prime("- AES-KW"))(function () {
1877− return genAES(Crypto_Subtle_Constants_AES.aesKW);
1878− });
1879− });
1880− });
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+ });
18812197 });
2198+ });
18822199 });
2200+ });
18832201 });
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+ });
18842210 });
1885− })())(function () {
1886− return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(log$prime("HMAC"))(function () {
1887− return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(Control_Bind.bind(Effect_Aff.bindAff)(Crypto_Subtle_Key_Generate.generateKey(Crypto_Subtle_Key_Generate.hmac(Crypto_Subtle_Hash.sha1))(true)(Crypto_Subtle_Key_Types.allUsages))(function (v) {
1888− return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(log$prime(" - SHA-1"))(function () {
1889− return log$prime(v);
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);
18902220 });
1891− }))(function () {
1892− return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(Control_Bind.bind(Effect_Aff.bindAff)(Crypto_Subtle_Key_Generate.generateKey(Crypto_Subtle_Key_Generate.hmac(Crypto_Subtle_Hash.sha256))(true)(Crypto_Subtle_Key_Types.allUsages))(function (v) {
1893− return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(log$prime(" - SHA-256"))(function () {
1894− return log$prime(v);
1895− });
1896− }))(function () {
1897− return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(Control_Bind.bind(Effect_Aff.bindAff)(Crypto_Subtle_Key_Generate.generateKey(Crypto_Subtle_Key_Generate.hmac(Crypto_Subtle_Hash.sha384))(true)(Crypto_Subtle_Key_Types.allUsages))(function (v) {
1898− return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(log$prime(" - SHA-384"))(function () {
1899− return log$prime(v);
1900− });
1901− }))(function () {
1902− return Control_Bind.bind(Effect_Aff.bindAff)(Crypto_Subtle_Key_Generate.generateKey(Crypto_Subtle_Key_Generate.hmac(Crypto_Subtle_Hash.sha512))(true)(Crypto_Subtle_Key_Types.allUsages))(function (v) {
1903− return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(log$prime(" - SHA-512"))(function () {
1904− return log$prime(v);
1905− });
1906− });
1907− });
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+ });
19082232 });
2233+ });
19092234 });
1910− }))(function () {
1911− var genEC = function (alg) {
1912− return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(Control_Bind.bind(Effect_Aff.bindAff)(Crypto_Subtle_Key_Generate.generateKey(Crypto_Subtle_Key_Generate.ec(alg)(Crypto_Subtle_Constants_EC.p256))(true)(Crypto_Subtle_Key_Types.allUsages))(function (v) {
1913− return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(log$prime(" - P-256"))(function () {
1914− return log$prime(v);
1915− });
1916− }))(function () {
1917− return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(Control_Bind.bind(Effect_Aff.bindAff)(Crypto_Subtle_Key_Generate.generateKey(Crypto_Subtle_Key_Generate.ec(alg)(Crypto_Subtle_Constants_EC.p384))(true)(Crypto_Subtle_Key_Types.allUsages))(function (v) {
1918− return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(log$prime(" - P-384"))(function () {
1919− return log$prime(v);
1920− });
1921− }))(function () {
1922− return Control_Bind.bind(Effect_Aff.bindAff)(Crypto_Subtle_Key_Generate.generateKey(Crypto_Subtle_Key_Generate.ec(alg)(Crypto_Subtle_Constants_EC.p521))(true)(Crypto_Subtle_Key_Types.allUsages))(function (v) {
1923− return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(log$prime(" - P-521"))(function () {
1924− return log$prime(v);
1925− });
1926− });
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);
19272242 });
2243+ });
19282244 });
1929− };
1930− return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(log$prime("- ECDSA"))(function () {
1931− return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(genEC(Crypto_Subtle_Constants_EC.ecdsa))(function () {
1932− return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(log$prime("- ECDH"))(function () {
1933− return genEC(Crypto_Subtle_Constants_EC.ecdh);
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+ });
19342254 });
2255+ });
19352256 });
2257+ });
19362258 });
2259+ });
19372260 });
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+ });
19382273 });
1939− }));
1940− })();
1941− exports["main"] = main;
1942− exports["log'"] = log$prime;
1943−})(PS["Test.Main"] = PS["Test.Main"] || {});
1944−PS["Test.Main"].main();
2274+ });
2275+ });
2276+ }));
2277+ }();
2278+
2279+ // <stdin>
2280+ main();
2281+})();
test/Main.purs+59−15
@@ -1,8 +1,9 @@
11module Test.Main where
22
3−import Crypto.Subtle.Key.Types (allUsages)
4−import Crypto.Subtle.Key.Generate (generateKey, aes, hmac, ec, rsa)
3+import Crypto.Subtle.Key.Types (allUsages, CryptoKeyPair (..), exportKey, raw)
4+import Crypto.Subtle.Key.Generate (generateKey, generateKeyPair, aes, hmac, ec, rsa, exp65537)
55import Crypto.Subtle.Constants.AES as AES
6+import Crypto.Subtle.Constants.RSA as RSA
67import Crypto.Subtle.Constants.EC as EC
78import Crypto.Subtle.Hash as Hash
89
@@ -26,13 +27,13 @@ main = do
2627 runAff_ resolve do
2728 log' "Generating Keys..."
2829 do let genAES mode = do
29− do k <- generateKey (aes mode AES.l128) true allUsages
30+ do k <- exportKey raw =<< generateKey (aes mode AES.l128) true allUsages
3031 log' " - 128"
3132 log' (unsafeCoerce k)
32− do k <- generateKey (aes mode AES.l192) true allUsages
33+ do k <- exportKey raw =<< generateKey (aes mode AES.l192) true allUsages
3334 log' " - 192"
3435 log' (unsafeCoerce k)
35− do k <- generateKey (aes mode AES.l256) true allUsages
36+ do k <- exportKey raw =<< generateKey (aes mode AES.l256) true allUsages
3637 log' " - 256"
3738 log' (unsafeCoerce k)
3839 log' "- AES-CTR"
@@ -44,32 +45,75 @@ main = do
4445 log' "- AES-KW"
4546 genAES AES.aesKW
4647 do log' "HMAC"
47− do k <- generateKey (hmac Hash.sha1) true allUsages
48+ do k <- exportKey raw =<< generateKey (hmac Hash.sha1) true allUsages
4849 log' " - SHA-1"
4950 log' (unsafeCoerce k)
50− do k <- generateKey (hmac Hash.sha256) true allUsages
51+ do k <- exportKey raw =<< generateKey (hmac Hash.sha256) true allUsages
5152 log' " - SHA-256"
5253 log' (unsafeCoerce k)
53− do k <- generateKey (hmac Hash.sha384) true allUsages
54+ do k <- exportKey raw =<< generateKey (hmac Hash.sha384) true allUsages
5455 log' " - SHA-384"
5556 log' (unsafeCoerce k)
56− do k <- generateKey (hmac Hash.sha512) true allUsages
57+ do k <- exportKey raw =<< generateKey (hmac Hash.sha512) true allUsages
5758 log' " - SHA-512"
5859 log' (unsafeCoerce k)
5960 do let genEC alg = do
60− do k <- generateKey (ec alg EC.p256) true allUsages
61+ do CryptoKeyPair {privateKey,publicKey} <- generateKeyPair (ec alg EC.p256) true allUsages
6162 log' " - P-256"
62− log' (unsafeCoerce k)
63− do k <- generateKey (ec alg EC.p384) true allUsages
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
6469 log' " - P-384"
65− log' (unsafeCoerce k)
66− do k <- generateKey (ec alg EC.p521) true allUsages
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
6776 log' " - P-521"
68− log' (unsafeCoerce k)
77+ log' " - privateKey"
78+ log' (unsafeCoerce privateKey)
79+ log' " - publicKey"
80+ publicKey' <- exportKey raw publicKey
81+ log' (unsafeCoerce publicKey')
6982 log' "- ECDSA"
7083 genEC EC.ecdsa
7184 log' "- ECDH"
7285 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
73117
74118
75119log' :: String -> Aff Unit