zeed 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +50 -211
- package/README.md +16 -0
- package/dist/_experiments/bitcask.cjs +243 -1
- package/dist/_experiments/bitcask.cjs.map +1 -1
- package/dist/_experiments/bitcask.mjs +230 -1
- package/dist/_experiments/bitcask.mjs.map +1 -1
- package/dist/bin-BAoS4qtm.mjs +593 -0
- package/dist/{bin-SPdenYkw.mjs.map → bin-BAoS4qtm.mjs.map} +1 -1
- package/dist/bin-Ddaz2lxM.cjs +862 -0
- package/dist/{bin-Ce3i6ABn.cjs.map → bin-Ddaz2lxM.cjs.map} +1 -1
- package/dist/browser/base64.cjs +14 -1
- package/dist/browser/base64.cjs.map +1 -1
- package/dist/browser/base64.mjs +12 -1
- package/dist/browser/base64.mjs.map +1 -1
- package/dist/browser/gravatar.cjs +186 -1
- package/dist/browser/gravatar.cjs.map +1 -1
- package/dist/browser/gravatar.mjs +184 -1
- package/dist/browser/gravatar.mjs.map +1 -1
- package/dist/browser/index.cjs +14 -1
- package/dist/browser/index.mjs +8 -1
- package/dist/browser/localstorage.cjs +46 -1
- package/dist/browser/localstorage.cjs.map +1 -1
- package/dist/browser/localstorage.mjs +45 -1
- package/dist/browser/localstorage.mjs.map +1 -1
- package/dist/browser/log/index.cjs +8 -1
- package/dist/browser/log/index.mjs +5 -1
- package/dist/browser/log/log-browser-factory.cjs +65 -1
- package/dist/browser/log/log-browser-factory.cjs.map +1 -1
- package/dist/browser/log/log-browser-factory.mjs +64 -1
- package/dist/browser/log/log-browser-factory.mjs.map +1 -1
- package/dist/browser/log/log-browser.cjs +72 -1
- package/dist/browser/log/log-browser.cjs.map +1 -1
- package/dist/browser/log/log-browser.mjs +71 -1
- package/dist/browser/log/log-browser.mjs.map +1 -1
- package/dist/browser/log/log-colors.cjs +11 -1
- package/dist/browser/log/log-colors.cjs.map +1 -1
- package/dist/browser/log/log-colors.mjs +9 -1
- package/dist/browser/log/log-colors.mjs.map +1 -1
- package/dist/browser/log/log-context-browser.cjs +25 -1
- package/dist/browser/log/log-context-browser.cjs.map +1 -1
- package/dist/browser/log/log-context-browser.mjs +23 -1
- package/dist/browser/log/log-context-browser.mjs.map +1 -1
- package/dist/chunk-DQk6qfdC.mjs +18 -0
- package/dist/chunk-uaV2rQ02.cjs +53 -0
- package/dist/common/assert.cjs +22 -1
- package/dist/common/assert.cjs.map +1 -1
- package/dist/common/assert.mjs +19 -1
- package/dist/common/assert.mjs.map +1 -1
- package/dist/common/bin/index.cjs +106 -1
- package/dist/common/bin/index.cjs.map +1 -1
- package/dist/common/bin/index.mjs +98 -1
- package/dist/common/bin/index.mjs.map +1 -1
- package/dist/common/bin/lib0/binary.cjs +146 -1
- package/dist/common/bin/lib0/binary.cjs.map +1 -1
- package/dist/common/bin/lib0/binary.mjs +80 -1
- package/dist/common/bin/lib0/binary.mjs.map +1 -1
- package/dist/common/bin/lib0/buffer.cjs +42 -1
- package/dist/common/bin/lib0/buffer.cjs.map +1 -1
- package/dist/common/bin/lib0/buffer.mjs +38 -1
- package/dist/common/bin/lib0/buffer.mjs.map +1 -1
- package/dist/common/bin/lib0/create.cjs +24 -1
- package/dist/common/bin/lib0/create.cjs.map +1 -1
- package/dist/common/bin/lib0/create.mjs +21 -1
- package/dist/common/bin/lib0/create.mjs.map +1 -1
- package/dist/common/bin/lib0/decoding.cjs +325 -1
- package/dist/common/bin/lib0/decoding.cjs.map +1 -1
- package/dist/common/bin/lib0/decoding.mjs +298 -1
- package/dist/common/bin/lib0/decoding.mjs.map +1 -1
- package/dist/common/bin/lib0/encoding.cjs +404 -1
- package/dist/common/bin/lib0/encoding.cjs.map +1 -1
- package/dist/common/bin/lib0/encoding.mjs +377 -1
- package/dist/common/bin/lib0/encoding.mjs.map +1 -1
- package/dist/common/bin/lib0/string.cjs +81 -1
- package/dist/common/bin/lib0/string.cjs.map +1 -1
- package/dist/common/bin/lib0/string.mjs +71 -1
- package/dist/common/bin/lib0/string.mjs.map +1 -1
- package/dist/common/crypto/aes-sealed.cjs +34 -1
- package/dist/common/crypto/aes-sealed.cjs.map +1 -1
- package/dist/common/crypto/aes-sealed.mjs +32 -1
- package/dist/common/crypto/aes-sealed.mjs.map +1 -1
- package/dist/common/crypto/crypto.cjs +91 -1
- package/dist/common/crypto/crypto.cjs.map +1 -1
- package/dist/common/crypto/crypto.mjs +80 -1
- package/dist/common/crypto/crypto.mjs.map +1 -1
- package/dist/common/crypto/index.cjs +23 -1
- package/dist/common/crypto/index.mjs +5 -1
- package/dist/common/crypto/xaes.cjs +128 -1
- package/dist/common/crypto/xaes.cjs.map +1 -1
- package/dist/common/crypto/xaes.mjs +123 -1
- package/dist/common/crypto/xaes.mjs.map +1 -1
- package/dist/common/csv.cjs +49 -4
- package/dist/common/csv.cjs.map +1 -1
- package/dist/common/csv.mjs +46 -4
- package/dist/common/csv.mjs.map +1 -1
- package/dist/common/data/array.cjs +299 -1
- package/dist/common/data/array.cjs.map +1 -1
- package/dist/common/data/array.mjs +274 -1
- package/dist/common/data/array.mjs.map +1 -1
- package/dist/common/data/basex-secure.cjs +30 -1
- package/dist/common/data/basex-secure.mjs +3 -1
- package/dist/common/data/basex.cjs +163 -1
- package/dist/common/data/basex.cjs.map +1 -1
- package/dist/common/data/basex.mjs +152 -1
- package/dist/common/data/basex.mjs.map +1 -1
- package/dist/common/data/bin-types.mjs +1 -1
- package/dist/common/data/bin.cjs +21 -1
- package/dist/common/data/bin.mjs +3 -1
- package/dist/common/data/camelcase.cjs +27 -1
- package/dist/common/data/camelcase.cjs.map +1 -1
- package/dist/common/data/camelcase.mjs +22 -1
- package/dist/common/data/camelcase.mjs.map +1 -1
- package/dist/common/data/convert.cjs +104 -1
- package/dist/common/data/convert.cjs.map +1 -1
- package/dist/common/data/convert.mjs +88 -1
- package/dist/common/data/convert.mjs.map +1 -1
- package/dist/common/data/datauri.cjs +32 -1
- package/dist/common/data/datauri.cjs.map +1 -1
- package/dist/common/data/datauri.mjs +27 -1
- package/dist/common/data/datauri.mjs.map +1 -1
- package/dist/common/data/day-legacy.cjs +148 -1
- package/dist/common/data/day-legacy.cjs.map +1 -1
- package/dist/common/data/day-legacy.mjs +143 -1
- package/dist/common/data/day-legacy.mjs.map +1 -1
- package/dist/common/data/day.cjs +335 -1
- package/dist/common/data/day.cjs.map +1 -1
- package/dist/common/data/day.mjs +305 -1
- package/dist/common/data/day.mjs.map +1 -1
- package/dist/common/data/decimal.cjs +28 -1
- package/dist/common/data/decimal.cjs.map +1 -1
- package/dist/common/data/decimal.mjs +23 -1
- package/dist/common/data/decimal.mjs.map +1 -1
- package/dist/common/data/deep.cjs +57 -1
- package/dist/common/data/deep.cjs.map +1 -1
- package/dist/common/data/deep.mjs +54 -1
- package/dist/common/data/deep.mjs.map +1 -1
- package/dist/common/data/diff.cjs +62 -1
- package/dist/common/data/diff.cjs.map +1 -1
- package/dist/common/data/diff.mjs +60 -1
- package/dist/common/data/diff.mjs.map +1 -1
- package/dist/common/data/distributed.cjs +24 -1
- package/dist/common/data/distributed.cjs.map +1 -1
- package/dist/common/data/distributed.mjs +22 -1
- package/dist/common/data/distributed.mjs.map +1 -1
- package/dist/common/data/format.cjs +63 -1
- package/dist/common/data/format.cjs.map +1 -1
- package/dist/common/data/format.mjs +59 -1
- package/dist/common/data/format.mjs.map +1 -1
- package/dist/common/data/html.cjs +13 -1
- package/dist/common/data/html.cjs.map +1 -1
- package/dist/common/data/html.mjs +10 -1
- package/dist/common/data/html.mjs.map +1 -1
- package/dist/common/data/index.cjs +296 -1
- package/dist/common/data/index.mjs +37 -1
- package/dist/common/data/is.cjs +106 -1
- package/dist/common/data/is.cjs.map +1 -1
- package/dist/common/data/is.mjs +85 -1
- package/dist/common/data/is.mjs.map +1 -1
- package/dist/common/data/json.cjs +70 -1
- package/dist/common/data/json.cjs.map +1 -1
- package/dist/common/data/json.mjs +65 -1
- package/dist/common/data/json.mjs.map +1 -1
- package/dist/common/data/list.cjs +32 -1
- package/dist/common/data/list.cjs.map +1 -1
- package/dist/common/data/list.mjs +27 -1
- package/dist/common/data/list.mjs.map +1 -1
- package/dist/common/data/lru.mjs +1 -1
- package/dist/common/data/math.cjs +79 -1
- package/dist/common/data/math.cjs.map +1 -1
- package/dist/common/data/math.mjs +65 -1
- package/dist/common/data/math.mjs.map +1 -1
- package/dist/common/data/message.cjs +30 -1
- package/dist/common/data/message.cjs.map +1 -1
- package/dist/common/data/message.mjs +28 -1
- package/dist/common/data/message.mjs.map +1 -1
- package/dist/common/data/object-changes.cjs +66 -1
- package/dist/common/data/object-changes.cjs.map +1 -1
- package/dist/common/data/object-changes.mjs +63 -1
- package/dist/common/data/object-changes.mjs.map +1 -1
- package/dist/common/data/object.cjs +112 -1
- package/dist/common/data/object.cjs.map +1 -1
- package/dist/common/data/object.mjs +104 -1
- package/dist/common/data/object.mjs.map +1 -1
- package/dist/common/data/orderby.cjs +42 -1
- package/dist/common/data/orderby.cjs.map +1 -1
- package/dist/common/data/orderby.mjs +37 -1
- package/dist/common/data/orderby.mjs.map +1 -1
- package/dist/common/data/path.cjs +26 -1
- package/dist/common/data/path.cjs.map +1 -1
- package/dist/common/data/path.mjs +25 -1
- package/dist/common/data/path.mjs.map +1 -1
- package/dist/common/data/regexp.cjs +12 -1
- package/dist/common/data/regexp.cjs.map +1 -1
- package/dist/common/data/regexp.mjs +10 -1
- package/dist/common/data/regexp.mjs.map +1 -1
- package/dist/common/data/rounding.cjs +107 -1
- package/dist/common/data/rounding.cjs.map +1 -1
- package/dist/common/data/rounding.mjs +95 -1
- package/dist/common/data/rounding.mjs.map +1 -1
- package/dist/common/data/signal.cjs +39 -1
- package/dist/common/data/signal.cjs.map +1 -1
- package/dist/common/data/signal.mjs +38 -1
- package/dist/common/data/signal.mjs.map +1 -1
- package/dist/common/data/sortable.cjs +35 -1
- package/dist/common/data/sortable.cjs.map +1 -1
- package/dist/common/data/sortable.mjs +31 -1
- package/dist/common/data/sortable.mjs.map +1 -1
- package/dist/common/data/sorted.cjs +54 -1
- package/dist/common/data/sorted.cjs.map +1 -1
- package/dist/common/data/sorted.mjs +53 -1
- package/dist/common/data/sorted.mjs.map +1 -1
- package/dist/common/data/string-deburr.cjs +240 -1
- package/dist/common/data/string-deburr.cjs.map +1 -1
- package/dist/common/data/string-deburr.mjs +238 -1
- package/dist/common/data/string-deburr.mjs.map +1 -1
- package/dist/common/data/string-hash-fnv.cjs +69 -1
- package/dist/common/data/string-hash-fnv.cjs.map +1 -1
- package/dist/common/data/string-hash-fnv.mjs +67 -1
- package/dist/common/data/string-hash-fnv.mjs.map +1 -1
- package/dist/common/data/string-hash-pool.cjs +28 -1
- package/dist/common/data/string-hash-pool.cjs.map +1 -1
- package/dist/common/data/string-hash-pool.mjs +27 -1
- package/dist/common/data/string-hash-pool.mjs.map +1 -1
- package/dist/common/data/url.cjs +98 -2
- package/dist/common/data/url.cjs.map +1 -1
- package/dist/common/data/url.mjs +91 -2
- package/dist/common/data/url.mjs.map +1 -1
- package/dist/common/data/utils.cjs +118 -1
- package/dist/common/data/utils.cjs.map +1 -1
- package/dist/common/data/utils.mjs +107 -1
- package/dist/common/data/utils.mjs.map +1 -1
- package/dist/common/data/wordlist.cjs +531 -1
- package/dist/common/data/wordlist.cjs.map +1 -1
- package/dist/common/data/wordlist.mjs +529 -1
- package/dist/common/data/wordlist.mjs.map +1 -1
- package/dist/common/data/xrx.cjs +96 -1
- package/dist/common/data/xrx.cjs.map +1 -1
- package/dist/common/data/xrx.mjs +92 -1
- package/dist/common/data/xrx.mjs.map +1 -1
- package/dist/common/dispose-defer.cjs +133 -1
- package/dist/common/dispose-defer.cjs.map +1 -1
- package/dist/common/dispose-defer.mjs +130 -1
- package/dist/common/dispose-defer.mjs.map +1 -1
- package/dist/common/dispose-types.mjs +1 -1
- package/dist/common/dispose-utils.cjs +113 -1
- package/dist/common/dispose-utils.cjs.map +1 -1
- package/dist/common/dispose-utils.mjs +106 -1
- package/dist/common/dispose-utils.mjs.map +1 -1
- package/dist/common/exec/index.cjs +24 -1
- package/dist/common/exec/index.d.cts +1 -1
- package/dist/common/exec/index.d.mts +1 -1
- package/dist/common/exec/index.mjs +8 -1
- package/dist/common/exec/mutex.cjs +44 -1
- package/dist/common/exec/mutex.cjs.map +1 -1
- package/dist/common/exec/mutex.mjs +42 -1
- package/dist/common/exec/mutex.mjs.map +1 -1
- package/dist/common/exec/pool.cjs +181 -1
- package/dist/common/exec/pool.cjs.map +1 -1
- package/dist/common/exec/pool.d.cts +1 -1
- package/dist/common/exec/pool.d.mts +1 -1
- package/dist/common/exec/pool.mjs +180 -1
- package/dist/common/exec/pool.mjs.map +1 -1
- package/dist/common/exec/progress.cjs +149 -1
- package/dist/common/exec/progress.cjs.map +1 -1
- package/dist/common/exec/progress.d.cts +1 -1
- package/dist/common/exec/progress.d.mts +1 -1
- package/dist/common/exec/progress.mjs +148 -1
- package/dist/common/exec/progress.mjs.map +1 -1
- package/dist/common/exec/promise.cjs +113 -1
- package/dist/common/exec/promise.cjs.map +1 -1
- package/dist/common/exec/promise.mjs +103 -1
- package/dist/common/exec/promise.mjs.map +1 -1
- package/dist/common/exec/queue.cjs +125 -1
- package/dist/common/exec/queue.cjs.map +1 -1
- package/dist/common/exec/queue.d.cts +1 -1
- package/dist/common/exec/queue.d.mts +1 -1
- package/dist/common/exec/queue.mjs +124 -1
- package/dist/common/exec/queue.mjs.map +1 -1
- package/dist/common/exec/throttle-debounce.cjs +114 -1
- package/dist/common/exec/throttle-debounce.cjs.map +1 -1
- package/dist/common/exec/throttle-debounce.mjs +112 -1
- package/dist/common/exec/throttle-debounce.mjs.map +1 -1
- package/dist/common/global.cjs +22 -1
- package/dist/common/global.cjs.map +1 -1
- package/dist/common/global.mjs +19 -1
- package/dist/common/global.mjs.map +1 -1
- package/dist/common/index.cjs +559 -1
- package/dist/common/index.d.cts +1 -1
- package/dist/common/index.d.mts +1 -1
- package/dist/common/index.mjs +89 -1
- package/dist/common/localhost.cjs +16 -1
- package/dist/common/localhost.cjs.map +1 -1
- package/dist/common/localhost.mjs +14 -1
- package/dist/common/localhost.mjs.map +1 -1
- package/dist/common/log/index.cjs +34 -1
- package/dist/common/log/index.mjs +11 -1
- package/dist/common/log/log-base.cjs +40 -1
- package/dist/common/log/log-base.cjs.map +1 -1
- package/dist/common/log/log-base.mjs +31 -1
- package/dist/common/log/log-base.mjs.map +1 -1
- package/dist/common/log/log-colors.cjs +92 -1
- package/dist/common/log/log-colors.cjs.map +1 -1
- package/dist/common/log/log-colors.mjs +90 -1
- package/dist/common/log/log-colors.mjs.map +1 -1
- package/dist/common/log/log-config.cjs +15 -1
- package/dist/common/log/log-config.cjs.map +1 -1
- package/dist/common/log/log-config.mjs +14 -1
- package/dist/common/log/log-config.mjs.map +1 -1
- package/dist/common/log/log-console-capture.cjs +33 -1
- package/dist/common/log/log-console-capture.cjs.map +1 -1
- package/dist/common/log/log-console-capture.mjs +32 -1
- package/dist/common/log/log-console-capture.mjs.map +1 -1
- package/dist/common/log/log-console-original.cjs +27 -1
- package/dist/common/log/log-console-original.cjs.map +1 -1
- package/dist/common/log/log-console-original.mjs +26 -1
- package/dist/common/log/log-console-original.mjs.map +1 -1
- package/dist/common/log/log-console.cjs +39 -1
- package/dist/common/log/log-console.cjs.map +1 -1
- package/dist/common/log/log-console.mjs +38 -1
- package/dist/common/log/log-console.mjs.map +1 -1
- package/dist/common/log/log-context.cjs +109 -1
- package/dist/common/log/log-context.cjs.map +1 -1
- package/dist/common/log/log-context.mjs +108 -1
- package/dist/common/log/log-context.mjs.map +1 -1
- package/dist/common/log/log-filter.cjs +80 -1
- package/dist/common/log/log-filter.cjs.map +1 -1
- package/dist/common/log/log-filter.mjs +75 -1
- package/dist/common/log/log-filter.mjs.map +1 -1
- package/dist/common/log/log-memory.cjs +45 -1
- package/dist/common/log/log-memory.cjs.map +1 -1
- package/dist/common/log/log-memory.mjs +43 -1
- package/dist/common/log/log-memory.mjs.map +1 -1
- package/dist/common/log/log-noop.cjs +17 -1
- package/dist/common/log/log-noop.cjs.map +1 -1
- package/dist/common/log/log-noop.mjs +15 -1
- package/dist/common/log/log-noop.mjs.map +1 -1
- package/dist/common/log/log.cjs +46 -1
- package/dist/common/log/log.cjs.map +1 -1
- package/dist/common/log/log.mjs +43 -1
- package/dist/common/log/log.mjs.map +1 -1
- package/dist/common/msg/channel-debug.cjs +17 -1
- package/dist/common/msg/channel-debug.cjs.map +1 -1
- package/dist/common/msg/channel-debug.d.cts +1 -1
- package/dist/common/msg/channel-debug.d.mts +1 -1
- package/dist/common/msg/channel-debug.mjs +16 -1
- package/dist/common/msg/channel-debug.mjs.map +1 -1
- package/dist/common/msg/channel-local.cjs +28 -1
- package/dist/common/msg/channel-local.cjs.map +1 -1
- package/dist/common/msg/channel-local.d.cts +1 -1
- package/dist/common/msg/channel-local.d.mts +1 -1
- package/dist/common/msg/channel-local.mjs +26 -1
- package/dist/common/msg/channel-local.mjs.map +1 -1
- package/dist/common/msg/channel-resilient.cjs +63 -1
- package/dist/common/msg/channel-resilient.cjs.map +1 -1
- package/dist/common/msg/channel-resilient.d.cts +1 -1
- package/dist/common/msg/channel-resilient.d.mts +1 -1
- package/dist/common/msg/channel-resilient.mjs +62 -1
- package/dist/common/msg/channel-resilient.mjs.map +1 -1
- package/dist/common/msg/channel-wkwebview.cjs +35 -1
- package/dist/common/msg/channel-wkwebview.cjs.map +1 -1
- package/dist/common/msg/channel-wkwebview.d.cts +2 -1
- package/dist/common/msg/channel-wkwebview.d.mts +2 -1
- package/dist/common/msg/channel-wkwebview.mjs +34 -1
- package/dist/common/msg/channel-wkwebview.mjs.map +1 -1
- package/dist/common/msg/channel.cjs +23 -1
- package/dist/common/msg/channel.cjs.map +1 -1
- package/dist/common/msg/channel.d.cts +1 -1
- package/dist/common/msg/channel.d.mts +1 -1
- package/dist/common/msg/channel.mjs +22 -1
- package/dist/common/msg/channel.mjs.map +1 -1
- package/dist/common/msg/emitter.cjs +141 -1
- package/dist/common/msg/emitter.cjs.map +1 -1
- package/dist/common/msg/emitter.d.cts +1 -1
- package/dist/common/msg/emitter.d.mts +1 -1
- package/dist/common/msg/emitter.mjs +139 -1
- package/dist/common/msg/emitter.mjs.map +1 -1
- package/dist/common/msg/encoder.cjs +38 -1
- package/dist/common/msg/encoder.cjs.map +1 -1
- package/dist/common/msg/encoder.mjs +35 -1
- package/dist/common/msg/encoder.mjs.map +1 -1
- package/dist/common/msg/index.cjs +28 -1
- package/dist/common/msg/index.d.cts +1 -1
- package/dist/common/msg/index.d.mts +1 -1
- package/dist/common/msg/index.mjs +11 -1
- package/dist/common/msg/messages.cjs +135 -1
- package/dist/common/msg/messages.cjs.map +1 -1
- package/dist/common/msg/messages.d.cts +1 -1
- package/dist/common/msg/messages.d.mts +1 -1
- package/dist/common/msg/messages.mjs +133 -1
- package/dist/common/msg/messages.mjs.map +1 -1
- package/dist/common/msg/pipe.mjs +1 -1
- package/dist/common/msg/pubsub.cjs +78 -1
- package/dist/common/msg/pubsub.cjs.map +1 -1
- package/dist/common/msg/pubsub.d.cts +1 -1
- package/dist/common/msg/pubsub.d.mts +1 -1
- package/dist/common/msg/pubsub.mjs +76 -1
- package/dist/common/msg/pubsub.mjs.map +1 -1
- package/dist/common/msg/rpc.cjs +142 -1
- package/dist/common/msg/rpc.cjs.map +1 -1
- package/dist/common/msg/rpc.mjs +139 -1
- package/dist/common/msg/rpc.mjs.map +1 -1
- package/dist/common/network.cjs +129 -1
- package/dist/common/network.cjs.map +1 -1
- package/dist/common/network.mjs +122 -1
- package/dist/common/network.mjs.map +1 -1
- package/dist/common/platform.cjs +92 -1
- package/dist/common/platform.cjs.map +1 -1
- package/dist/common/platform.mjs +84 -1
- package/dist/common/platform.mjs.map +1 -1
- package/dist/common/schema/_sandbox/sandbox-inherit.mjs +1 -1
- package/dist/common/schema/_sandbox/sandbox.mjs +1 -1
- package/dist/common/schema/_sandbox/sandbox.xspec.mjs +1 -1
- package/dist/common/schema/export-json-schema.cjs +54 -1
- package/dist/common/schema/export-json-schema.cjs.map +1 -1
- package/dist/common/schema/export-json-schema.mjs +52 -1
- package/dist/common/schema/export-json-schema.mjs.map +1 -1
- package/dist/common/schema/export-swift.cjs +30 -2
- package/dist/common/schema/export-swift.cjs.map +1 -1
- package/dist/common/schema/export-swift.mjs +29 -2
- package/dist/common/schema/export-swift.mjs.map +1 -1
- package/dist/common/schema/export-typescript.cjs +20 -2
- package/dist/common/schema/export-typescript.cjs.map +1 -1
- package/dist/common/schema/export-typescript.mjs +19 -2
- package/dist/common/schema/export-typescript.mjs.map +1 -1
- package/dist/common/schema/index.cjs +55 -1
- package/dist/common/schema/index.mjs +12 -1
- package/dist/common/schema/parse-args.cjs +62 -2
- package/dist/common/schema/parse-args.cjs.map +1 -1
- package/dist/common/schema/parse-args.mjs +60 -2
- package/dist/common/schema/parse-args.mjs.map +1 -1
- package/dist/common/schema/parse-env.cjs +48 -3
- package/dist/common/schema/parse-env.cjs.map +1 -1
- package/dist/common/schema/parse-env.mjs +46 -3
- package/dist/common/schema/parse-env.mjs.map +1 -1
- package/dist/common/schema/parse-object.cjs +122 -1
- package/dist/common/schema/parse-object.cjs.map +1 -1
- package/dist/common/schema/parse-object.mjs +119 -1
- package/dist/common/schema/parse-object.mjs.map +1 -1
- package/dist/common/schema/schema-standard.mjs +1 -1
- package/dist/common/schema/schema.cjs +423 -1
- package/dist/common/schema/schema.cjs.map +1 -1
- package/dist/common/schema/schema.mjs +404 -1
- package/dist/common/schema/schema.mjs.map +1 -1
- package/dist/common/schema/serialize.cjs +109 -1
- package/dist/common/schema/serialize.cjs.map +1 -1
- package/dist/common/schema/serialize.mjs +107 -1
- package/dist/common/schema/serialize.mjs.map +1 -1
- package/dist/common/schema/type-test.mjs +1 -1
- package/dist/common/schema/utils.cjs +25 -1
- package/dist/common/schema/utils.cjs.map +1 -1
- package/dist/common/schema/utils.mjs +19 -1
- package/dist/common/schema/utils.mjs.map +1 -1
- package/dist/common/schema/z-collection.cjs +51 -1
- package/dist/common/schema/z-collection.mjs +27 -1
- package/dist/common/schema/z.cjs +9 -1
- package/dist/common/schema/z.mjs +3 -1
- package/dist/common/storage/index.cjs +4 -1
- package/dist/common/storage/index.mjs +3 -1
- package/dist/common/storage/memstorage.cjs +26 -1
- package/dist/common/storage/memstorage.cjs.map +1 -1
- package/dist/common/storage/memstorage.mjs +25 -1
- package/dist/common/storage/memstorage.mjs.map +1 -1
- package/dist/common/test.cjs +14 -1
- package/dist/common/test.cjs.map +1 -1
- package/dist/common/test.mjs +13 -1
- package/dist/common/test.mjs.map +1 -1
- package/dist/common/time.cjs +220 -1
- package/dist/common/time.cjs.map +1 -1
- package/dist/common/time.mjs +194 -1
- package/dist/common/time.mjs.map +1 -1
- package/dist/common/timeout.cjs +27 -1
- package/dist/common/timeout.cjs.map +1 -1
- package/dist/common/timeout.mjs +25 -1
- package/dist/common/timeout.mjs.map +1 -1
- package/dist/common/types.mjs +1 -1
- package/dist/common/utils.cjs +7 -1
- package/dist/common/utils.cjs.map +1 -1
- package/dist/common/utils.mjs +5 -1
- package/dist/common/utils.mjs.map +1 -1
- package/dist/common/uuid.cjs +307 -1
- package/dist/common/uuid.cjs.map +1 -1
- package/dist/common/uuid.mjs +284 -1
- package/dist/common/uuid.mjs.map +1 -1
- package/dist/{index-DHXVOH8h.d.cts → index-CFkMqHvX.d.cts} +1 -2
- package/dist/{index-DMaPyx9O.d.mts → index-C_3Y_s6f.d.mts} +1 -2
- package/dist/index.all.cjs +641 -1
- package/dist/index.all.d.cts +1 -1
- package/dist/index.all.d.mts +1 -1
- package/dist/index.all.mjs +113 -1
- package/dist/index.browser.cjs +576 -1
- package/dist/index.browser.d.cts +1 -1
- package/dist/index.browser.d.mts +1 -1
- package/dist/index.browser.mjs +98 -1
- package/dist/index.jsr.cjs +57 -1
- package/dist/index.jsr.mjs +6 -1
- package/dist/index.node.cjs +628 -1
- package/dist/index.node.d.cts +1 -1
- package/dist/index.node.d.mts +1 -1
- package/dist/index.node.mjs +106 -1
- package/dist/node/args.cjs +56 -1
- package/dist/node/args.cjs.map +1 -1
- package/dist/node/args.mjs +53 -1
- package/dist/node/args.mjs.map +1 -1
- package/dist/node/clipboard.cjs +18 -1
- package/dist/node/clipboard.cjs.map +1 -1
- package/dist/node/clipboard.mjs +16 -1
- package/dist/node/clipboard.mjs.map +1 -1
- package/dist/node/crypto.cjs +28 -1
- package/dist/node/crypto.cjs.map +1 -1
- package/dist/node/crypto.mjs +24 -1
- package/dist/node/crypto.mjs.map +1 -1
- package/dist/node/env.cjs +100 -4
- package/dist/node/env.cjs.map +1 -1
- package/dist/node/env.mjs +90 -4
- package/dist/node/env.mjs.map +1 -1
- package/dist/node/files-async.cjs +66 -1
- package/dist/node/files-async.cjs.map +1 -1
- package/dist/node/files-async.mjs +60 -1
- package/dist/node/files-async.mjs.map +1 -1
- package/dist/node/files.cjs +52 -1
- package/dist/node/files.cjs.map +1 -1
- package/dist/node/files.mjs +46 -1
- package/dist/node/files.mjs.map +1 -1
- package/dist/node/filestorage.cjs +100 -1
- package/dist/node/filestorage.cjs.map +1 -1
- package/dist/node/filestorage.mjs +97 -1
- package/dist/node/filestorage.mjs.map +1 -1
- package/dist/node/fs.cjs +119 -1
- package/dist/node/fs.cjs.map +1 -1
- package/dist/node/fs.mjs +101 -1
- package/dist/node/fs.mjs.map +1 -1
- package/dist/node/glob.cjs +75 -1
- package/dist/node/glob.cjs.map +1 -1
- package/dist/node/glob.mjs +73 -1
- package/dist/node/glob.mjs.map +1 -1
- package/dist/node/index.cjs +66 -1
- package/dist/node/index.mjs +16 -1
- package/dist/node/log/index.cjs +20 -1
- package/dist/node/log/index.mjs +7 -1
- package/dist/node/log/log-context-node.cjs +39 -1
- package/dist/node/log/log-context-node.cjs.map +1 -1
- package/dist/node/log/log-context-node.mjs +35 -1
- package/dist/node/log/log-context-node.mjs.map +1 -1
- package/dist/node/log/log-file-rotation.cjs +71 -1
- package/dist/node/log/log-file-rotation.cjs.map +1 -1
- package/dist/node/log/log-file-rotation.mjs +68 -1
- package/dist/node/log/log-file-rotation.mjs.map +1 -1
- package/dist/node/log/log-file.cjs +57 -1
- package/dist/node/log/log-file.cjs.map +1 -1
- package/dist/node/log/log-file.mjs +54 -1
- package/dist/node/log/log-file.mjs.map +1 -1
- package/dist/node/log/log-node.cjs +162 -1
- package/dist/node/log/log-node.cjs.map +1 -1
- package/dist/node/log/log-node.mjs +155 -1
- package/dist/node/log/log-node.mjs.map +1 -1
- package/dist/node/log/log-rotation.cjs +543 -3
- package/dist/node/log/log-rotation.cjs.map +1 -1
- package/dist/node/log/log-rotation.mjs +538 -3
- package/dist/node/log/log-rotation.mjs.map +1 -1
- package/dist/node/log/log-util.cjs +69 -3
- package/dist/node/log/log-util.cjs.map +1 -1
- package/dist/node/log/log-util.mjs +63 -3
- package/dist/node/log/log-util.mjs.map +1 -1
- package/dist/node/open-browser.cjs +20 -1
- package/dist/node/open-browser.cjs.map +1 -1
- package/dist/node/open-browser.mjs +18 -1
- package/dist/node/open-browser.mjs.map +1 -1
- package/package.json +15 -15
- package/src/common/schema/README.md +247 -66
- package/src/eslint-defaults.js +4 -0
- package/src/index.spec.ts +6 -6
- package/dist/bin-Ce3i6ABn.cjs +0 -3
- package/dist/bin-SPdenYkw.mjs +0 -3
- package/dist/chunk-0Lt9GpW0.mjs +0 -1
- package/dist/chunk-D-qHiVGv.cjs +0 -1
- package/src/common/schema/README-SCHEMA.md +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xaes.cjs","names":["ensureUint8Array"],"sources":["../../../src/common/crypto/xaes.ts"],"sourcesContent":["// Original at https://github.com/dchest/xaes MIT License as of 2024-07-02\n// More at https://words.filippo.io/dispatches/xaes-256-gcm/\n\nimport { ensureUint8Array } from '../data/bin'\n\n/**\n * Implementation of XAES-256-GCM as defined in https://c2sp.org/XAES-256-GCM\n * based on the Web Cryptography API (https://www.w3.org/TR/WebCryptoAPI/).\n *\n * It uses a 256-bit AES-CBC CryptoKey and a 192-bit nonce to derive\n * a 256-bit key and a 96-bit nonce for AES-GCM.\n *\n * Due to the use of the standard CryptoKey and Web Cryptography API operations,\n * this implementation is fully compatible with other parts of the Web Cryptography API.\n * For example, keys can be stored in IndexedDB and be non-extractable. The only\n * additional requirement is that the key must have 'encrypt' usage even for decryption,\n * however, there's no real distinction between encryption and decryption operations\n * for AES-GCM anyway (you can simulate decryption by encrypting the ciphertext).\n */\n\n/**\n * Generates an AES block using the given key and data xored with the given xor.\n */\nasync function aesBlock(key: CryptoKey, data: BufferSource, xor: BufferSource): Promise<Uint8Array> {\n const block = await crypto.subtle.encrypt(\n { name: 'AES-CBC', iv: xor },\n key,\n data,\n )\n return new Uint8Array(block, 0, 16)\n}\n\n/**\n * Derives a half key.\n */\nasync function halfKey(index: number, key: CryptoKey, iv: Uint8Array, k1: Uint8Array): Promise<Uint8Array> {\n const m = new Uint8Array(16)\n m[1] = index\n m[2] = 0x58 // 'X'\n m.set(ensureUint8Array(iv.subarray(0, 12)), 4)\n return await aesBlock(key, m, ensureUint8Array(k1))\n}\n\n/**\n * Derives a 256-bit key and 96-bit nonce from the given 256-bit key and a 192-bit nonce.\n */\nasync function deriveKeyNonce(key: CryptoKey, iv: BufferSource): Promise<{ key: CryptoKey, iv: Uint8Array }> {\n if (key.algorithm.name !== 'AES-CBC') {\n throw new Error('key must be for AES-CBC')\n }\n if (!key.usages.includes('encrypt')) {\n throw new Error('key must have \\'encrypt\\' usage')\n }\n // @ts-expect-error todo\n if (key.algorithm.length !== 256) {\n throw new Error('key must be 256 bits')\n }\n if (iv == null || iv.byteLength !== 24) {\n throw new Error('iv must be 24 bytes')\n }\n const ivBytes = ArrayBuffer.isView(iv)\n ? new Uint8Array(iv.buffer, iv.byteOffset, iv.byteLength)\n : new Uint8Array(iv)\n const k1 = await aesBlock(key, new Uint8Array(16), new Uint8Array(16))\n\n let msb = 0\n for (let i = k1.length - 1; i >= 0; i--) {\n [msb, k1[i]] = [(k1[i] >>> 7) & 0xFF, ((k1[i] << 1) | msb) & 0xFF]\n }\n k1[k1.length - 1] ^= (msb * 0b10000111) & 0xFF\n\n const kxBytes = new Uint8Array(32)\n kxBytes.set(await halfKey(0x01, key, ivBytes, k1), 0)\n kxBytes.set(await halfKey(0x02, key, ivBytes, k1), 16)\n\n const kx = await crypto.subtle.importKey(\n 'raw',\n kxBytes,\n { name: 'AES-GCM', length: 256 },\n false,\n [...key.usages],\n )\n return {\n key: kx,\n iv: ensureUint8Array(ivBytes.subarray(12)),\n }\n}\n/**\n * Encrypts data using XAES-256-GCM with the given key and iv.\n * Key must be a 256-bit AES-CBC CryptoKey with 'encrypt' usage.\n */\nexport async function encryptXAES(params: {\n iv: BufferSource\n additionalData?: BufferSource\n}, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer> {\n const derived = await deriveKeyNonce(key, params.iv)\n return await crypto.subtle.encrypt(\n {\n name: 'AES-GCM',\n iv: derived.iv as BufferSource,\n tagLength: 128,\n additionalData: params.additionalData ?? new Uint8Array(),\n },\n derived.key,\n data,\n )\n}\n\n/**\n * Decrypts data using XAES-256-GCM with the given key and iv.\n * Key must be a 256-bit AES-CBC CryptoKey with 'encrypt' and 'decrypt' usages.\n */\nexport async function decryptXAES(params: {\n iv: BufferSource\n additionalData?: BufferSource\n}, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer> {\n const derived = await deriveKeyNonce(key, params.iv)\n return await crypto.subtle.decrypt(\n {\n name: 'AES-GCM',\n iv: derived.iv as BufferSource,\n tagLength: 128,\n additionalData: params.additionalData ?? new Uint8Array(),\n },\n derived.key,\n data,\n )\n}\n\n/**\n * Generate a random key suitable for XAES-256-GCM.\n * The actual key is an AES-CBC CryptoKey with 256-bit length.\n *\n * This function is not necessary, as you can use crypto.subtle.generateKey with AES-CBC directly.\n */\nexport async function generateKeyXAES(extractable?: boolean): Promise<CryptoKey> {\n return await crypto.subtle.generateKey(\n {\n name: 'AES-CBC',\n // @ts-expect-error todo\n length: 256,\n },\n extractable,\n ['encrypt', 'decrypt'],\n )\n}\n\n/**\n * Import a key suitable for XAES-256-GCM.\n * The actual key must be an AES-CBC CryptoKey with 256-bit length.\n *\n * This function is not necessary, as you can use crypto.subtle.importKey with AES-CBC directly.\n */\nexport async function importKeyXAES(format: 'jwk' | 'raw' | 'pkcs8' | 'spki', keyData: BufferSource | JsonWebKey, extractable?: boolean): Promise<CryptoKey> {\n return await crypto.subtle.importKey( // @ts-expect-error-next-line\n format,\n keyData,\n { name: 'AES-CBC', length: 256 },\n extractable,\n ['encrypt', 'decrypt'],\n )\n}\n\n/**\n * Export a key.\n * The resulting export will have AES-CBC algorithm specified.\n *\n * This function is not necessary, as you can use crypto.subtle.exportKey directly.\n */\nexport async function exportKeyXAES(format: 'jwk' | 'pkcs8' | 'raw' | 'spki', key: CryptoKey): Promise<ArrayBuffer | JsonWebKey> {\n return await crypto.subtle.exportKey(format, key)\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"xaes.cjs","names":["ensureUint8Array"],"sources":["../../../src/common/crypto/xaes.ts"],"sourcesContent":["// Original at https://github.com/dchest/xaes MIT License as of 2024-07-02\n// More at https://words.filippo.io/dispatches/xaes-256-gcm/\n\nimport { ensureUint8Array } from '../data/bin'\n\n/**\n * Implementation of XAES-256-GCM as defined in https://c2sp.org/XAES-256-GCM\n * based on the Web Cryptography API (https://www.w3.org/TR/WebCryptoAPI/).\n *\n * It uses a 256-bit AES-CBC CryptoKey and a 192-bit nonce to derive\n * a 256-bit key and a 96-bit nonce for AES-GCM.\n *\n * Due to the use of the standard CryptoKey and Web Cryptography API operations,\n * this implementation is fully compatible with other parts of the Web Cryptography API.\n * For example, keys can be stored in IndexedDB and be non-extractable. The only\n * additional requirement is that the key must have 'encrypt' usage even for decryption,\n * however, there's no real distinction between encryption and decryption operations\n * for AES-GCM anyway (you can simulate decryption by encrypting the ciphertext).\n */\n\n/**\n * Generates an AES block using the given key and data xored with the given xor.\n */\nasync function aesBlock(key: CryptoKey, data: BufferSource, xor: BufferSource): Promise<Uint8Array> {\n const block = await crypto.subtle.encrypt(\n { name: 'AES-CBC', iv: xor },\n key,\n data,\n )\n return new Uint8Array(block, 0, 16)\n}\n\n/**\n * Derives a half key.\n */\nasync function halfKey(index: number, key: CryptoKey, iv: Uint8Array, k1: Uint8Array): Promise<Uint8Array> {\n const m = new Uint8Array(16)\n m[1] = index\n m[2] = 0x58 // 'X'\n m.set(ensureUint8Array(iv.subarray(0, 12)), 4)\n return await aesBlock(key, m, ensureUint8Array(k1))\n}\n\n/**\n * Derives a 256-bit key and 96-bit nonce from the given 256-bit key and a 192-bit nonce.\n */\nasync function deriveKeyNonce(key: CryptoKey, iv: BufferSource): Promise<{ key: CryptoKey, iv: Uint8Array }> {\n if (key.algorithm.name !== 'AES-CBC') {\n throw new Error('key must be for AES-CBC')\n }\n if (!key.usages.includes('encrypt')) {\n throw new Error('key must have \\'encrypt\\' usage')\n }\n // @ts-expect-error todo\n if (key.algorithm.length !== 256) {\n throw new Error('key must be 256 bits')\n }\n if (iv == null || iv.byteLength !== 24) {\n throw new Error('iv must be 24 bytes')\n }\n const ivBytes = ArrayBuffer.isView(iv)\n ? new Uint8Array(iv.buffer, iv.byteOffset, iv.byteLength)\n : new Uint8Array(iv)\n const k1 = await aesBlock(key, new Uint8Array(16), new Uint8Array(16))\n\n let msb = 0\n for (let i = k1.length - 1; i >= 0; i--) {\n [msb, k1[i]] = [(k1[i] >>> 7) & 0xFF, ((k1[i] << 1) | msb) & 0xFF]\n }\n k1[k1.length - 1] ^= (msb * 0b10000111) & 0xFF\n\n const kxBytes = new Uint8Array(32)\n kxBytes.set(await halfKey(0x01, key, ivBytes, k1), 0)\n kxBytes.set(await halfKey(0x02, key, ivBytes, k1), 16)\n\n const kx = await crypto.subtle.importKey(\n 'raw',\n kxBytes,\n { name: 'AES-GCM', length: 256 },\n false,\n [...key.usages],\n )\n return {\n key: kx,\n iv: ensureUint8Array(ivBytes.subarray(12)),\n }\n}\n/**\n * Encrypts data using XAES-256-GCM with the given key and iv.\n * Key must be a 256-bit AES-CBC CryptoKey with 'encrypt' usage.\n */\nexport async function encryptXAES(params: {\n iv: BufferSource\n additionalData?: BufferSource\n}, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer> {\n const derived = await deriveKeyNonce(key, params.iv)\n return await crypto.subtle.encrypt(\n {\n name: 'AES-GCM',\n iv: derived.iv as BufferSource,\n tagLength: 128,\n additionalData: params.additionalData ?? new Uint8Array(),\n },\n derived.key,\n data,\n )\n}\n\n/**\n * Decrypts data using XAES-256-GCM with the given key and iv.\n * Key must be a 256-bit AES-CBC CryptoKey with 'encrypt' and 'decrypt' usages.\n */\nexport async function decryptXAES(params: {\n iv: BufferSource\n additionalData?: BufferSource\n}, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer> {\n const derived = await deriveKeyNonce(key, params.iv)\n return await crypto.subtle.decrypt(\n {\n name: 'AES-GCM',\n iv: derived.iv as BufferSource,\n tagLength: 128,\n additionalData: params.additionalData ?? new Uint8Array(),\n },\n derived.key,\n data,\n )\n}\n\n/**\n * Generate a random key suitable for XAES-256-GCM.\n * The actual key is an AES-CBC CryptoKey with 256-bit length.\n *\n * This function is not necessary, as you can use crypto.subtle.generateKey with AES-CBC directly.\n */\nexport async function generateKeyXAES(extractable?: boolean): Promise<CryptoKey> {\n return await crypto.subtle.generateKey(\n {\n name: 'AES-CBC',\n // @ts-expect-error todo\n length: 256,\n },\n extractable,\n ['encrypt', 'decrypt'],\n )\n}\n\n/**\n * Import a key suitable for XAES-256-GCM.\n * The actual key must be an AES-CBC CryptoKey with 256-bit length.\n *\n * This function is not necessary, as you can use crypto.subtle.importKey with AES-CBC directly.\n */\nexport async function importKeyXAES(format: 'jwk' | 'raw' | 'pkcs8' | 'spki', keyData: BufferSource | JsonWebKey, extractable?: boolean): Promise<CryptoKey> {\n return await crypto.subtle.importKey( // @ts-expect-error-next-line\n format,\n keyData,\n { name: 'AES-CBC', length: 256 },\n extractable,\n ['encrypt', 'decrypt'],\n )\n}\n\n/**\n * Export a key.\n * The resulting export will have AES-CBC algorithm specified.\n *\n * This function is not necessary, as you can use crypto.subtle.exportKey directly.\n */\nexport async function exportKeyXAES(format: 'jwk' | 'pkcs8' | 'raw' | 'spki', key: CryptoKey): Promise<ArrayBuffer | JsonWebKey> {\n return await crypto.subtle.exportKey(format, key)\n}\n"],"mappings":"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"}
|
|
@@ -1,2 +1,124 @@
|
|
|
1
|
-
import{o as
|
|
1
|
+
import { o as ensureUint8Array } from "../../bin-BAoS4qtm.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/common/crypto/xaes.ts
|
|
4
|
+
/**
|
|
5
|
+
* Implementation of XAES-256-GCM as defined in https://c2sp.org/XAES-256-GCM
|
|
6
|
+
* based on the Web Cryptography API (https://www.w3.org/TR/WebCryptoAPI/).
|
|
7
|
+
*
|
|
8
|
+
* It uses a 256-bit AES-CBC CryptoKey and a 192-bit nonce to derive
|
|
9
|
+
* a 256-bit key and a 96-bit nonce for AES-GCM.
|
|
10
|
+
*
|
|
11
|
+
* Due to the use of the standard CryptoKey and Web Cryptography API operations,
|
|
12
|
+
* this implementation is fully compatible with other parts of the Web Cryptography API.
|
|
13
|
+
* For example, keys can be stored in IndexedDB and be non-extractable. The only
|
|
14
|
+
* additional requirement is that the key must have 'encrypt' usage even for decryption,
|
|
15
|
+
* however, there's no real distinction between encryption and decryption operations
|
|
16
|
+
* for AES-GCM anyway (you can simulate decryption by encrypting the ciphertext).
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Generates an AES block using the given key and data xored with the given xor.
|
|
20
|
+
*/
|
|
21
|
+
async function aesBlock(key, data, xor) {
|
|
22
|
+
const block = await crypto.subtle.encrypt({
|
|
23
|
+
name: "AES-CBC",
|
|
24
|
+
iv: xor
|
|
25
|
+
}, key, data);
|
|
26
|
+
return new Uint8Array(block, 0, 16);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Derives a half key.
|
|
30
|
+
*/
|
|
31
|
+
async function halfKey(index, key, iv, k1) {
|
|
32
|
+
const m = new Uint8Array(16);
|
|
33
|
+
m[1] = index;
|
|
34
|
+
m[2] = 88;
|
|
35
|
+
m.set(ensureUint8Array(iv.subarray(0, 12)), 4);
|
|
36
|
+
return await aesBlock(key, m, ensureUint8Array(k1));
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Derives a 256-bit key and 96-bit nonce from the given 256-bit key and a 192-bit nonce.
|
|
40
|
+
*/
|
|
41
|
+
async function deriveKeyNonce(key, iv) {
|
|
42
|
+
if (key.algorithm.name !== "AES-CBC") throw new Error("key must be for AES-CBC");
|
|
43
|
+
if (!key.usages.includes("encrypt")) throw new Error("key must have 'encrypt' usage");
|
|
44
|
+
if (key.algorithm.length !== 256) throw new Error("key must be 256 bits");
|
|
45
|
+
if (iv == null || iv.byteLength !== 24) throw new Error("iv must be 24 bytes");
|
|
46
|
+
const ivBytes = ArrayBuffer.isView(iv) ? new Uint8Array(iv.buffer, iv.byteOffset, iv.byteLength) : new Uint8Array(iv);
|
|
47
|
+
const k1 = await aesBlock(key, new Uint8Array(16), new Uint8Array(16));
|
|
48
|
+
let msb = 0;
|
|
49
|
+
for (let i = k1.length - 1; i >= 0; i--) [msb, k1[i]] = [k1[i] >>> 7 & 255, (k1[i] << 1 | msb) & 255];
|
|
50
|
+
k1[k1.length - 1] ^= msb * 135 & 255;
|
|
51
|
+
const kxBytes = new Uint8Array(32);
|
|
52
|
+
kxBytes.set(await halfKey(1, key, ivBytes, k1), 0);
|
|
53
|
+
kxBytes.set(await halfKey(2, key, ivBytes, k1), 16);
|
|
54
|
+
return {
|
|
55
|
+
key: await crypto.subtle.importKey("raw", kxBytes, {
|
|
56
|
+
name: "AES-GCM",
|
|
57
|
+
length: 256
|
|
58
|
+
}, false, [...key.usages]),
|
|
59
|
+
iv: ensureUint8Array(ivBytes.subarray(12))
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Encrypts data using XAES-256-GCM with the given key and iv.
|
|
64
|
+
* Key must be a 256-bit AES-CBC CryptoKey with 'encrypt' usage.
|
|
65
|
+
*/
|
|
66
|
+
async function encryptXAES(params, key, data) {
|
|
67
|
+
const derived = await deriveKeyNonce(key, params.iv);
|
|
68
|
+
return await crypto.subtle.encrypt({
|
|
69
|
+
name: "AES-GCM",
|
|
70
|
+
iv: derived.iv,
|
|
71
|
+
tagLength: 128,
|
|
72
|
+
additionalData: params.additionalData ?? new Uint8Array()
|
|
73
|
+
}, derived.key, data);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Decrypts data using XAES-256-GCM with the given key and iv.
|
|
77
|
+
* Key must be a 256-bit AES-CBC CryptoKey with 'encrypt' and 'decrypt' usages.
|
|
78
|
+
*/
|
|
79
|
+
async function decryptXAES(params, key, data) {
|
|
80
|
+
const derived = await deriveKeyNonce(key, params.iv);
|
|
81
|
+
return await crypto.subtle.decrypt({
|
|
82
|
+
name: "AES-GCM",
|
|
83
|
+
iv: derived.iv,
|
|
84
|
+
tagLength: 128,
|
|
85
|
+
additionalData: params.additionalData ?? new Uint8Array()
|
|
86
|
+
}, derived.key, data);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Generate a random key suitable for XAES-256-GCM.
|
|
90
|
+
* The actual key is an AES-CBC CryptoKey with 256-bit length.
|
|
91
|
+
*
|
|
92
|
+
* This function is not necessary, as you can use crypto.subtle.generateKey with AES-CBC directly.
|
|
93
|
+
*/
|
|
94
|
+
async function generateKeyXAES(extractable) {
|
|
95
|
+
return await crypto.subtle.generateKey({
|
|
96
|
+
name: "AES-CBC",
|
|
97
|
+
length: 256
|
|
98
|
+
}, extractable, ["encrypt", "decrypt"]);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Import a key suitable for XAES-256-GCM.
|
|
102
|
+
* The actual key must be an AES-CBC CryptoKey with 256-bit length.
|
|
103
|
+
*
|
|
104
|
+
* This function is not necessary, as you can use crypto.subtle.importKey with AES-CBC directly.
|
|
105
|
+
*/
|
|
106
|
+
async function importKeyXAES(format, keyData, extractable) {
|
|
107
|
+
return await crypto.subtle.importKey(format, keyData, {
|
|
108
|
+
name: "AES-CBC",
|
|
109
|
+
length: 256
|
|
110
|
+
}, extractable, ["encrypt", "decrypt"]);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Export a key.
|
|
114
|
+
* The resulting export will have AES-CBC algorithm specified.
|
|
115
|
+
*
|
|
116
|
+
* This function is not necessary, as you can use crypto.subtle.exportKey directly.
|
|
117
|
+
*/
|
|
118
|
+
async function exportKeyXAES(format, key) {
|
|
119
|
+
return await crypto.subtle.exportKey(format, key);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
//#endregion
|
|
123
|
+
export { decryptXAES, encryptXAES, exportKeyXAES, generateKeyXAES, importKeyXAES };
|
|
2
124
|
//# sourceMappingURL=xaes.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xaes.mjs","names":[],"sources":["../../../src/common/crypto/xaes.ts"],"sourcesContent":["// Original at https://github.com/dchest/xaes MIT License as of 2024-07-02\n// More at https://words.filippo.io/dispatches/xaes-256-gcm/\n\nimport { ensureUint8Array } from '../data/bin'\n\n/**\n * Implementation of XAES-256-GCM as defined in https://c2sp.org/XAES-256-GCM\n * based on the Web Cryptography API (https://www.w3.org/TR/WebCryptoAPI/).\n *\n * It uses a 256-bit AES-CBC CryptoKey and a 192-bit nonce to derive\n * a 256-bit key and a 96-bit nonce for AES-GCM.\n *\n * Due to the use of the standard CryptoKey and Web Cryptography API operations,\n * this implementation is fully compatible with other parts of the Web Cryptography API.\n * For example, keys can be stored in IndexedDB and be non-extractable. The only\n * additional requirement is that the key must have 'encrypt' usage even for decryption,\n * however, there's no real distinction between encryption and decryption operations\n * for AES-GCM anyway (you can simulate decryption by encrypting the ciphertext).\n */\n\n/**\n * Generates an AES block using the given key and data xored with the given xor.\n */\nasync function aesBlock(key: CryptoKey, data: BufferSource, xor: BufferSource): Promise<Uint8Array> {\n const block = await crypto.subtle.encrypt(\n { name: 'AES-CBC', iv: xor },\n key,\n data,\n )\n return new Uint8Array(block, 0, 16)\n}\n\n/**\n * Derives a half key.\n */\nasync function halfKey(index: number, key: CryptoKey, iv: Uint8Array, k1: Uint8Array): Promise<Uint8Array> {\n const m = new Uint8Array(16)\n m[1] = index\n m[2] = 0x58 // 'X'\n m.set(ensureUint8Array(iv.subarray(0, 12)), 4)\n return await aesBlock(key, m, ensureUint8Array(k1))\n}\n\n/**\n * Derives a 256-bit key and 96-bit nonce from the given 256-bit key and a 192-bit nonce.\n */\nasync function deriveKeyNonce(key: CryptoKey, iv: BufferSource): Promise<{ key: CryptoKey, iv: Uint8Array }> {\n if (key.algorithm.name !== 'AES-CBC') {\n throw new Error('key must be for AES-CBC')\n }\n if (!key.usages.includes('encrypt')) {\n throw new Error('key must have \\'encrypt\\' usage')\n }\n // @ts-expect-error todo\n if (key.algorithm.length !== 256) {\n throw new Error('key must be 256 bits')\n }\n if (iv == null || iv.byteLength !== 24) {\n throw new Error('iv must be 24 bytes')\n }\n const ivBytes = ArrayBuffer.isView(iv)\n ? new Uint8Array(iv.buffer, iv.byteOffset, iv.byteLength)\n : new Uint8Array(iv)\n const k1 = await aesBlock(key, new Uint8Array(16), new Uint8Array(16))\n\n let msb = 0\n for (let i = k1.length - 1; i >= 0; i--) {\n [msb, k1[i]] = [(k1[i] >>> 7) & 0xFF, ((k1[i] << 1) | msb) & 0xFF]\n }\n k1[k1.length - 1] ^= (msb * 0b10000111) & 0xFF\n\n const kxBytes = new Uint8Array(32)\n kxBytes.set(await halfKey(0x01, key, ivBytes, k1), 0)\n kxBytes.set(await halfKey(0x02, key, ivBytes, k1), 16)\n\n const kx = await crypto.subtle.importKey(\n 'raw',\n kxBytes,\n { name: 'AES-GCM', length: 256 },\n false,\n [...key.usages],\n )\n return {\n key: kx,\n iv: ensureUint8Array(ivBytes.subarray(12)),\n }\n}\n/**\n * Encrypts data using XAES-256-GCM with the given key and iv.\n * Key must be a 256-bit AES-CBC CryptoKey with 'encrypt' usage.\n */\nexport async function encryptXAES(params: {\n iv: BufferSource\n additionalData?: BufferSource\n}, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer> {\n const derived = await deriveKeyNonce(key, params.iv)\n return await crypto.subtle.encrypt(\n {\n name: 'AES-GCM',\n iv: derived.iv as BufferSource,\n tagLength: 128,\n additionalData: params.additionalData ?? new Uint8Array(),\n },\n derived.key,\n data,\n )\n}\n\n/**\n * Decrypts data using XAES-256-GCM with the given key and iv.\n * Key must be a 256-bit AES-CBC CryptoKey with 'encrypt' and 'decrypt' usages.\n */\nexport async function decryptXAES(params: {\n iv: BufferSource\n additionalData?: BufferSource\n}, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer> {\n const derived = await deriveKeyNonce(key, params.iv)\n return await crypto.subtle.decrypt(\n {\n name: 'AES-GCM',\n iv: derived.iv as BufferSource,\n tagLength: 128,\n additionalData: params.additionalData ?? new Uint8Array(),\n },\n derived.key,\n data,\n )\n}\n\n/**\n * Generate a random key suitable for XAES-256-GCM.\n * The actual key is an AES-CBC CryptoKey with 256-bit length.\n *\n * This function is not necessary, as you can use crypto.subtle.generateKey with AES-CBC directly.\n */\nexport async function generateKeyXAES(extractable?: boolean): Promise<CryptoKey> {\n return await crypto.subtle.generateKey(\n {\n name: 'AES-CBC',\n // @ts-expect-error todo\n length: 256,\n },\n extractable,\n ['encrypt', 'decrypt'],\n )\n}\n\n/**\n * Import a key suitable for XAES-256-GCM.\n * The actual key must be an AES-CBC CryptoKey with 256-bit length.\n *\n * This function is not necessary, as you can use crypto.subtle.importKey with AES-CBC directly.\n */\nexport async function importKeyXAES(format: 'jwk' | 'raw' | 'pkcs8' | 'spki', keyData: BufferSource | JsonWebKey, extractable?: boolean): Promise<CryptoKey> {\n return await crypto.subtle.importKey( // @ts-expect-error-next-line\n format,\n keyData,\n { name: 'AES-CBC', length: 256 },\n extractable,\n ['encrypt', 'decrypt'],\n )\n}\n\n/**\n * Export a key.\n * The resulting export will have AES-CBC algorithm specified.\n *\n * This function is not necessary, as you can use crypto.subtle.exportKey directly.\n */\nexport async function exportKeyXAES(format: 'jwk' | 'pkcs8' | 'raw' | 'spki', key: CryptoKey): Promise<ArrayBuffer | JsonWebKey> {\n return await crypto.subtle.exportKey(format, key)\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"xaes.mjs","names":[],"sources":["../../../src/common/crypto/xaes.ts"],"sourcesContent":["// Original at https://github.com/dchest/xaes MIT License as of 2024-07-02\n// More at https://words.filippo.io/dispatches/xaes-256-gcm/\n\nimport { ensureUint8Array } from '../data/bin'\n\n/**\n * Implementation of XAES-256-GCM as defined in https://c2sp.org/XAES-256-GCM\n * based on the Web Cryptography API (https://www.w3.org/TR/WebCryptoAPI/).\n *\n * It uses a 256-bit AES-CBC CryptoKey and a 192-bit nonce to derive\n * a 256-bit key and a 96-bit nonce for AES-GCM.\n *\n * Due to the use of the standard CryptoKey and Web Cryptography API operations,\n * this implementation is fully compatible with other parts of the Web Cryptography API.\n * For example, keys can be stored in IndexedDB and be non-extractable. The only\n * additional requirement is that the key must have 'encrypt' usage even for decryption,\n * however, there's no real distinction between encryption and decryption operations\n * for AES-GCM anyway (you can simulate decryption by encrypting the ciphertext).\n */\n\n/**\n * Generates an AES block using the given key and data xored with the given xor.\n */\nasync function aesBlock(key: CryptoKey, data: BufferSource, xor: BufferSource): Promise<Uint8Array> {\n const block = await crypto.subtle.encrypt(\n { name: 'AES-CBC', iv: xor },\n key,\n data,\n )\n return new Uint8Array(block, 0, 16)\n}\n\n/**\n * Derives a half key.\n */\nasync function halfKey(index: number, key: CryptoKey, iv: Uint8Array, k1: Uint8Array): Promise<Uint8Array> {\n const m = new Uint8Array(16)\n m[1] = index\n m[2] = 0x58 // 'X'\n m.set(ensureUint8Array(iv.subarray(0, 12)), 4)\n return await aesBlock(key, m, ensureUint8Array(k1))\n}\n\n/**\n * Derives a 256-bit key and 96-bit nonce from the given 256-bit key and a 192-bit nonce.\n */\nasync function deriveKeyNonce(key: CryptoKey, iv: BufferSource): Promise<{ key: CryptoKey, iv: Uint8Array }> {\n if (key.algorithm.name !== 'AES-CBC') {\n throw new Error('key must be for AES-CBC')\n }\n if (!key.usages.includes('encrypt')) {\n throw new Error('key must have \\'encrypt\\' usage')\n }\n // @ts-expect-error todo\n if (key.algorithm.length !== 256) {\n throw new Error('key must be 256 bits')\n }\n if (iv == null || iv.byteLength !== 24) {\n throw new Error('iv must be 24 bytes')\n }\n const ivBytes = ArrayBuffer.isView(iv)\n ? new Uint8Array(iv.buffer, iv.byteOffset, iv.byteLength)\n : new Uint8Array(iv)\n const k1 = await aesBlock(key, new Uint8Array(16), new Uint8Array(16))\n\n let msb = 0\n for (let i = k1.length - 1; i >= 0; i--) {\n [msb, k1[i]] = [(k1[i] >>> 7) & 0xFF, ((k1[i] << 1) | msb) & 0xFF]\n }\n k1[k1.length - 1] ^= (msb * 0b10000111) & 0xFF\n\n const kxBytes = new Uint8Array(32)\n kxBytes.set(await halfKey(0x01, key, ivBytes, k1), 0)\n kxBytes.set(await halfKey(0x02, key, ivBytes, k1), 16)\n\n const kx = await crypto.subtle.importKey(\n 'raw',\n kxBytes,\n { name: 'AES-GCM', length: 256 },\n false,\n [...key.usages],\n )\n return {\n key: kx,\n iv: ensureUint8Array(ivBytes.subarray(12)),\n }\n}\n/**\n * Encrypts data using XAES-256-GCM with the given key and iv.\n * Key must be a 256-bit AES-CBC CryptoKey with 'encrypt' usage.\n */\nexport async function encryptXAES(params: {\n iv: BufferSource\n additionalData?: BufferSource\n}, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer> {\n const derived = await deriveKeyNonce(key, params.iv)\n return await crypto.subtle.encrypt(\n {\n name: 'AES-GCM',\n iv: derived.iv as BufferSource,\n tagLength: 128,\n additionalData: params.additionalData ?? new Uint8Array(),\n },\n derived.key,\n data,\n )\n}\n\n/**\n * Decrypts data using XAES-256-GCM with the given key and iv.\n * Key must be a 256-bit AES-CBC CryptoKey with 'encrypt' and 'decrypt' usages.\n */\nexport async function decryptXAES(params: {\n iv: BufferSource\n additionalData?: BufferSource\n}, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer> {\n const derived = await deriveKeyNonce(key, params.iv)\n return await crypto.subtle.decrypt(\n {\n name: 'AES-GCM',\n iv: derived.iv as BufferSource,\n tagLength: 128,\n additionalData: params.additionalData ?? new Uint8Array(),\n },\n derived.key,\n data,\n )\n}\n\n/**\n * Generate a random key suitable for XAES-256-GCM.\n * The actual key is an AES-CBC CryptoKey with 256-bit length.\n *\n * This function is not necessary, as you can use crypto.subtle.generateKey with AES-CBC directly.\n */\nexport async function generateKeyXAES(extractable?: boolean): Promise<CryptoKey> {\n return await crypto.subtle.generateKey(\n {\n name: 'AES-CBC',\n // @ts-expect-error todo\n length: 256,\n },\n extractable,\n ['encrypt', 'decrypt'],\n )\n}\n\n/**\n * Import a key suitable for XAES-256-GCM.\n * The actual key must be an AES-CBC CryptoKey with 256-bit length.\n *\n * This function is not necessary, as you can use crypto.subtle.importKey with AES-CBC directly.\n */\nexport async function importKeyXAES(format: 'jwk' | 'raw' | 'pkcs8' | 'spki', keyData: BufferSource | JsonWebKey, extractable?: boolean): Promise<CryptoKey> {\n return await crypto.subtle.importKey( // @ts-expect-error-next-line\n format,\n keyData,\n { name: 'AES-CBC', length: 256 },\n extractable,\n ['encrypt', 'decrypt'],\n )\n}\n\n/**\n * Export a key.\n * The resulting export will have AES-CBC algorithm specified.\n *\n * This function is not necessary, as you can use crypto.subtle.exportKey directly.\n */\nexport async function exportKeyXAES(format: 'jwk' | 'pkcs8' | 'raw' | 'spki', key: CryptoKey): Promise<ArrayBuffer | JsonWebKey> {\n return await crypto.subtle.exportKey(format, key)\n}\n"],"mappings":"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"}
|
package/dist/common/csv.cjs
CHANGED
|
@@ -1,5 +1,50 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_common_data_json = require('./data/json.cjs');
|
|
3
|
+
const require_common_data_is = require('./data/is.cjs');
|
|
4
|
+
const require_common_data_regexp = require('./data/regexp.cjs');
|
|
5
|
+
|
|
6
|
+
//#region src/common/csv.ts
|
|
7
|
+
const defaultSeparator = ",";
|
|
8
|
+
function csvStringify(data, opt = {}) {
|
|
9
|
+
const { separator = defaultSeparator } = opt;
|
|
10
|
+
let body = "";
|
|
11
|
+
if (opt.addBom) body = "";
|
|
12
|
+
for (let i = 0; i < data.length; i++) body += `${data[i].map((field) => {
|
|
13
|
+
if (field == null || field === "") return "";
|
|
14
|
+
if (require_common_data_is.isBoolean(field)) return field ? 1 : 0;
|
|
15
|
+
let s = String(field);
|
|
16
|
+
if (require_common_data_is.isRecord(field) || require_common_data_is.isArray(field)) s = require_common_data_json.jsonStringifySafe(field);
|
|
17
|
+
if (s.includes("\"") || s.includes("\n") || s.includes(separator)) return `"${s.replace(/"/g, "\"\"")}"`;
|
|
18
|
+
return s;
|
|
19
|
+
}).join(separator)}\n`;
|
|
20
|
+
return body;
|
|
21
|
+
}
|
|
22
|
+
function csvParse(raw, opt = {}) {
|
|
23
|
+
let rxOneValueWithSeparator = /("((?:(?:[^"]*?)(?:"")?)*)"|([^,;\t\n]*))([,;\t\n]|\r\n)/g;
|
|
24
|
+
if (opt.separator) rxOneValueWithSeparator = new RegExp(rxOneValueWithSeparator.source.replace(/',;\\t/g, require_common_data_regexp.escapeRegExp(opt.separator)), rxOneValueWithSeparator.flags);
|
|
25
|
+
const lines = [];
|
|
26
|
+
let row = [];
|
|
27
|
+
let m;
|
|
28
|
+
const text = `${raw.replace(/\r\n/g, "\n").trim()}\n`;
|
|
29
|
+
while (m = rxOneValueWithSeparator.exec(text)) {
|
|
30
|
+
let value = m[2] ?? m[3] ?? "";
|
|
31
|
+
value = value.replace(/""/g, "\"");
|
|
32
|
+
row.push(value);
|
|
33
|
+
if (m[4] === "\n") {
|
|
34
|
+
lines.push(row);
|
|
35
|
+
row = [];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return lines;
|
|
39
|
+
}
|
|
40
|
+
function csvParseToObjects(raw, opt = {}) {
|
|
41
|
+
const lines = csvParse(raw, opt);
|
|
42
|
+
const header = lines[0];
|
|
43
|
+
return lines.slice(1).map((l) => Object.fromEntries(l.map((v, i) => [header[i], v])));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
//#endregion
|
|
47
|
+
exports.csvParse = csvParse;
|
|
48
|
+
exports.csvParseToObjects = csvParseToObjects;
|
|
49
|
+
exports.csvStringify = csvStringify;
|
|
5
50
|
//# sourceMappingURL=csv.cjs.map
|
package/dist/common/csv.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"csv.cjs","names":["isBoolean","isRecord","isArray","jsonStringifySafe","escapeRegExp"],"sources":["../../src/common/csv.ts"],"sourcesContent":["import { isArray, isBoolean, isRecord } from './data/is'\nimport { jsonStringifySafe } from './data/json'\nimport { escapeRegExp } from './data/regexp'\n\nconst defaultSeparator = ','\n\nexport function csvStringify(data: any[], opt: {\n // header?: string[]\n separator?: string\n addBom?: boolean // option to add byte order mark for improved Excel support\n} = {}): string {\n const { separator = defaultSeparator } = opt\n let body = ''\n if (opt.addBom)\n body = '\\uFEFF'\n\n // Append the header row to the response if requested\n // if (header)\n // body = `${header.join(separator)}\\n`\n\n // Convert the data to a CSV-like structure\n for (let i = 0; i < data.length; i++) {\n body += `${data[i].map((field: string) => {\n if (field == null || field === '')\n return ''\n if (isBoolean(field))\n return field ? 1 : 0\n let s = String(field)\n if (isRecord(field) || isArray(field))\n s = jsonStringifySafe(field)\n if (s.includes('\"') || s.includes('\\n') || s.includes(separator))\n return `\"${s.replace(/\"/g, '\"\"')}\"`\n return s\n }).join(separator)}\\n`\n }\n\n return body\n}\n\nexport function csvParse(raw: string, opt: {\n separator?: string\n} = {}) {\n // https://regex101.com/r/BCpKyV/1\n // eslint-disable-next-line regexp/no-unused-capturing-group, regexp/no-super-linear-backtracking, regexp/no-dupe-disjunctions, regexp/no-useless-non-capturing-group\n let rxOneValueWithSeparator = /(\"((?:(?:[^\"]*?)(?:\"\")?)*)\"|([^,;\\t\\n]*))([,;\\t\\n]|\\r\\n)/g\n if (opt.separator)\n rxOneValueWithSeparator = new RegExp(rxOneValueWithSeparator.source.replace(/',;\\\\t/g, escapeRegExp(opt.separator)), rxOneValueWithSeparator.flags)\n\n const lines: any[][] = []\n let row: any[] = []\n let m: any\n const text = `${raw.replace(/\\r\\n/g, '\\n').trim()}\\n`\n\n // eslint-disable-next-line no-cond-assign\n while (m = rxOneValueWithSeparator.exec(text)) {\n let value = m[2] ?? m[3] ?? ''\n value = value.replace(/\"\"/g, '\"')\n row.push(value)\n if (m[4] === '\\n') {\n lines.push(row)\n row = []\n }\n }\n return lines\n}\n\nexport function csvParseToObjects(raw: string, opt: {\n separator?: string\n} = {}) {\n const lines = csvParse(raw, opt)\n const header = lines[0]\n return lines.slice(1).map(l =>\n Object.fromEntries (l.map((v, i) => [header[i], v])),\n )\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"csv.cjs","names":["isBoolean","isRecord","isArray","jsonStringifySafe","escapeRegExp"],"sources":["../../src/common/csv.ts"],"sourcesContent":["import { isArray, isBoolean, isRecord } from './data/is'\nimport { jsonStringifySafe } from './data/json'\nimport { escapeRegExp } from './data/regexp'\n\nconst defaultSeparator = ','\n\nexport function csvStringify(data: any[], opt: {\n // header?: string[]\n separator?: string\n addBom?: boolean // option to add byte order mark for improved Excel support\n} = {}): string {\n const { separator = defaultSeparator } = opt\n let body = ''\n if (opt.addBom)\n body = '\\uFEFF'\n\n // Append the header row to the response if requested\n // if (header)\n // body = `${header.join(separator)}\\n`\n\n // Convert the data to a CSV-like structure\n for (let i = 0; i < data.length; i++) {\n body += `${data[i].map((field: string) => {\n if (field == null || field === '')\n return ''\n if (isBoolean(field))\n return field ? 1 : 0\n let s = String(field)\n if (isRecord(field) || isArray(field))\n s = jsonStringifySafe(field)\n if (s.includes('\"') || s.includes('\\n') || s.includes(separator))\n return `\"${s.replace(/\"/g, '\"\"')}\"`\n return s\n }).join(separator)}\\n`\n }\n\n return body\n}\n\nexport function csvParse(raw: string, opt: {\n separator?: string\n} = {}) {\n // https://regex101.com/r/BCpKyV/1\n // eslint-disable-next-line regexp/no-unused-capturing-group, regexp/no-super-linear-backtracking, regexp/no-dupe-disjunctions, regexp/no-useless-non-capturing-group\n let rxOneValueWithSeparator = /(\"((?:(?:[^\"]*?)(?:\"\")?)*)\"|([^,;\\t\\n]*))([,;\\t\\n]|\\r\\n)/g\n if (opt.separator)\n rxOneValueWithSeparator = new RegExp(rxOneValueWithSeparator.source.replace(/',;\\\\t/g, escapeRegExp(opt.separator)), rxOneValueWithSeparator.flags)\n\n const lines: any[][] = []\n let row: any[] = []\n let m: any\n const text = `${raw.replace(/\\r\\n/g, '\\n').trim()}\\n`\n\n // eslint-disable-next-line no-cond-assign\n while (m = rxOneValueWithSeparator.exec(text)) {\n let value = m[2] ?? m[3] ?? ''\n value = value.replace(/\"\"/g, '\"')\n row.push(value)\n if (m[4] === '\\n') {\n lines.push(row)\n row = []\n }\n }\n return lines\n}\n\nexport function csvParseToObjects(raw: string, opt: {\n separator?: string\n} = {}) {\n const lines = csvParse(raw, opt)\n const header = lines[0]\n return lines.slice(1).map(l =>\n Object.fromEntries (l.map((v, i) => [header[i], v])),\n )\n}\n"],"mappings":";;;;;;AAIA,MAAM,mBAAmB;AAEzB,SAAgB,aAAa,MAAa,MAItC,EAAE,EAAU;CACd,MAAM,EAAE,YAAY,qBAAqB;CACzC,IAAI,OAAO;AACX,KAAI,IAAI,OACN,QAAO;AAOT,MAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,IAC/B,SAAQ,GAAG,KAAK,GAAG,KAAK,UAAkB;AACxC,MAAI,SAAS,QAAQ,UAAU,GAC7B,QAAO;AACT,MAAIA,iCAAU,MAAM,CAClB,QAAO,QAAQ,IAAI;EACrB,IAAI,IAAI,OAAO,MAAM;AACrB,MAAIC,gCAAS,MAAM,IAAIC,+BAAQ,MAAM,CACnC,KAAIC,2CAAkB,MAAM;AAC9B,MAAI,EAAE,SAAS,KAAI,IAAI,EAAE,SAAS,KAAK,IAAI,EAAE,SAAS,UAAU,CAC9D,QAAO,IAAI,EAAE,QAAQ,MAAM,OAAK,CAAC;AACnC,SAAO;GACP,CAAC,KAAK,UAAU,CAAC;AAGrB,QAAO;;AAGT,SAAgB,SAAS,KAAa,MAElC,EAAE,EAAE;CAGN,IAAI,0BAA0B;AAC9B,KAAI,IAAI,UACN,2BAA0B,IAAI,OAAO,wBAAwB,OAAO,QAAQ,WAAWC,wCAAa,IAAI,UAAU,CAAC,EAAE,wBAAwB,MAAM;CAErJ,MAAM,QAAiB,EAAE;CACzB,IAAI,MAAa,EAAE;CACnB,IAAI;CACJ,MAAM,OAAO,GAAG,IAAI,QAAQ,SAAS,KAAK,CAAC,MAAM,CAAC;AAGlD,QAAO,IAAI,wBAAwB,KAAK,KAAK,EAAE;EAC7C,IAAI,QAAQ,EAAE,MAAM,EAAE,MAAM;AAC5B,UAAQ,MAAM,QAAQ,OAAO,KAAI;AACjC,MAAI,KAAK,MAAM;AACf,MAAI,EAAE,OAAO,MAAM;AACjB,SAAM,KAAK,IAAI;AACf,SAAM,EAAE;;;AAGZ,QAAO;;AAGT,SAAgB,kBAAkB,KAAa,MAE3C,EAAE,EAAE;CACN,MAAM,QAAQ,SAAS,KAAK,IAAI;CAChC,MAAM,SAAS,MAAM;AACrB,QAAO,MAAM,MAAM,EAAE,CAAC,KAAI,MACxB,OAAO,YAAa,EAAE,KAAK,GAAG,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,CACrD"}
|
package/dist/common/csv.mjs
CHANGED
|
@@ -1,5 +1,47 @@
|
|
|
1
|
-
import{jsonStringifySafe
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { jsonStringifySafe } from "./data/json.mjs";
|
|
2
|
+
import { isArray, isBoolean, isRecord } from "./data/is.mjs";
|
|
3
|
+
import { escapeRegExp } from "./data/regexp.mjs";
|
|
4
|
+
|
|
5
|
+
//#region src/common/csv.ts
|
|
6
|
+
const defaultSeparator = ",";
|
|
7
|
+
function csvStringify(data, opt = {}) {
|
|
8
|
+
const { separator = defaultSeparator } = opt;
|
|
9
|
+
let body = "";
|
|
10
|
+
if (opt.addBom) body = "";
|
|
11
|
+
for (let i = 0; i < data.length; i++) body += `${data[i].map((field) => {
|
|
12
|
+
if (field == null || field === "") return "";
|
|
13
|
+
if (isBoolean(field)) return field ? 1 : 0;
|
|
14
|
+
let s = String(field);
|
|
15
|
+
if (isRecord(field) || isArray(field)) s = jsonStringifySafe(field);
|
|
16
|
+
if (s.includes("\"") || s.includes("\n") || s.includes(separator)) return `"${s.replace(/"/g, "\"\"")}"`;
|
|
17
|
+
return s;
|
|
18
|
+
}).join(separator)}\n`;
|
|
19
|
+
return body;
|
|
20
|
+
}
|
|
21
|
+
function csvParse(raw, opt = {}) {
|
|
22
|
+
let rxOneValueWithSeparator = /("((?:(?:[^"]*?)(?:"")?)*)"|([^,;\t\n]*))([,;\t\n]|\r\n)/g;
|
|
23
|
+
if (opt.separator) rxOneValueWithSeparator = new RegExp(rxOneValueWithSeparator.source.replace(/',;\\t/g, escapeRegExp(opt.separator)), rxOneValueWithSeparator.flags);
|
|
24
|
+
const lines = [];
|
|
25
|
+
let row = [];
|
|
26
|
+
let m;
|
|
27
|
+
const text = `${raw.replace(/\r\n/g, "\n").trim()}\n`;
|
|
28
|
+
while (m = rxOneValueWithSeparator.exec(text)) {
|
|
29
|
+
let value = m[2] ?? m[3] ?? "";
|
|
30
|
+
value = value.replace(/""/g, "\"");
|
|
31
|
+
row.push(value);
|
|
32
|
+
if (m[4] === "\n") {
|
|
33
|
+
lines.push(row);
|
|
34
|
+
row = [];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return lines;
|
|
38
|
+
}
|
|
39
|
+
function csvParseToObjects(raw, opt = {}) {
|
|
40
|
+
const lines = csvParse(raw, opt);
|
|
41
|
+
const header = lines[0];
|
|
42
|
+
return lines.slice(1).map((l) => Object.fromEntries(l.map((v, i) => [header[i], v])));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
46
|
+
export { csvParse, csvParseToObjects, csvStringify };
|
|
5
47
|
//# sourceMappingURL=csv.mjs.map
|
package/dist/common/csv.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"csv.mjs","names":[],"sources":["../../src/common/csv.ts"],"sourcesContent":["import { isArray, isBoolean, isRecord } from './data/is'\nimport { jsonStringifySafe } from './data/json'\nimport { escapeRegExp } from './data/regexp'\n\nconst defaultSeparator = ','\n\nexport function csvStringify(data: any[], opt: {\n // header?: string[]\n separator?: string\n addBom?: boolean // option to add byte order mark for improved Excel support\n} = {}): string {\n const { separator = defaultSeparator } = opt\n let body = ''\n if (opt.addBom)\n body = '\\uFEFF'\n\n // Append the header row to the response if requested\n // if (header)\n // body = `${header.join(separator)}\\n`\n\n // Convert the data to a CSV-like structure\n for (let i = 0; i < data.length; i++) {\n body += `${data[i].map((field: string) => {\n if (field == null || field === '')\n return ''\n if (isBoolean(field))\n return field ? 1 : 0\n let s = String(field)\n if (isRecord(field) || isArray(field))\n s = jsonStringifySafe(field)\n if (s.includes('\"') || s.includes('\\n') || s.includes(separator))\n return `\"${s.replace(/\"/g, '\"\"')}\"`\n return s\n }).join(separator)}\\n`\n }\n\n return body\n}\n\nexport function csvParse(raw: string, opt: {\n separator?: string\n} = {}) {\n // https://regex101.com/r/BCpKyV/1\n // eslint-disable-next-line regexp/no-unused-capturing-group, regexp/no-super-linear-backtracking, regexp/no-dupe-disjunctions, regexp/no-useless-non-capturing-group\n let rxOneValueWithSeparator = /(\"((?:(?:[^\"]*?)(?:\"\")?)*)\"|([^,;\\t\\n]*))([,;\\t\\n]|\\r\\n)/g\n if (opt.separator)\n rxOneValueWithSeparator = new RegExp(rxOneValueWithSeparator.source.replace(/',;\\\\t/g, escapeRegExp(opt.separator)), rxOneValueWithSeparator.flags)\n\n const lines: any[][] = []\n let row: any[] = []\n let m: any\n const text = `${raw.replace(/\\r\\n/g, '\\n').trim()}\\n`\n\n // eslint-disable-next-line no-cond-assign\n while (m = rxOneValueWithSeparator.exec(text)) {\n let value = m[2] ?? m[3] ?? ''\n value = value.replace(/\"\"/g, '\"')\n row.push(value)\n if (m[4] === '\\n') {\n lines.push(row)\n row = []\n }\n }\n return lines\n}\n\nexport function csvParseToObjects(raw: string, opt: {\n separator?: string\n} = {}) {\n const lines = csvParse(raw, opt)\n const header = lines[0]\n return lines.slice(1).map(l =>\n Object.fromEntries (l.map((v, i) => [header[i], v])),\n )\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"csv.mjs","names":[],"sources":["../../src/common/csv.ts"],"sourcesContent":["import { isArray, isBoolean, isRecord } from './data/is'\nimport { jsonStringifySafe } from './data/json'\nimport { escapeRegExp } from './data/regexp'\n\nconst defaultSeparator = ','\n\nexport function csvStringify(data: any[], opt: {\n // header?: string[]\n separator?: string\n addBom?: boolean // option to add byte order mark for improved Excel support\n} = {}): string {\n const { separator = defaultSeparator } = opt\n let body = ''\n if (opt.addBom)\n body = '\\uFEFF'\n\n // Append the header row to the response if requested\n // if (header)\n // body = `${header.join(separator)}\\n`\n\n // Convert the data to a CSV-like structure\n for (let i = 0; i < data.length; i++) {\n body += `${data[i].map((field: string) => {\n if (field == null || field === '')\n return ''\n if (isBoolean(field))\n return field ? 1 : 0\n let s = String(field)\n if (isRecord(field) || isArray(field))\n s = jsonStringifySafe(field)\n if (s.includes('\"') || s.includes('\\n') || s.includes(separator))\n return `\"${s.replace(/\"/g, '\"\"')}\"`\n return s\n }).join(separator)}\\n`\n }\n\n return body\n}\n\nexport function csvParse(raw: string, opt: {\n separator?: string\n} = {}) {\n // https://regex101.com/r/BCpKyV/1\n // eslint-disable-next-line regexp/no-unused-capturing-group, regexp/no-super-linear-backtracking, regexp/no-dupe-disjunctions, regexp/no-useless-non-capturing-group\n let rxOneValueWithSeparator = /(\"((?:(?:[^\"]*?)(?:\"\")?)*)\"|([^,;\\t\\n]*))([,;\\t\\n]|\\r\\n)/g\n if (opt.separator)\n rxOneValueWithSeparator = new RegExp(rxOneValueWithSeparator.source.replace(/',;\\\\t/g, escapeRegExp(opt.separator)), rxOneValueWithSeparator.flags)\n\n const lines: any[][] = []\n let row: any[] = []\n let m: any\n const text = `${raw.replace(/\\r\\n/g, '\\n').trim()}\\n`\n\n // eslint-disable-next-line no-cond-assign\n while (m = rxOneValueWithSeparator.exec(text)) {\n let value = m[2] ?? m[3] ?? ''\n value = value.replace(/\"\"/g, '\"')\n row.push(value)\n if (m[4] === '\\n') {\n lines.push(row)\n row = []\n }\n }\n return lines\n}\n\nexport function csvParseToObjects(raw: string, opt: {\n separator?: string\n} = {}) {\n const lines = csvParse(raw, opt)\n const header = lines[0]\n return lines.slice(1).map(l =>\n Object.fromEntries (l.map((v, i) => [header[i], v])),\n )\n}\n"],"mappings":";;;;;AAIA,MAAM,mBAAmB;AAEzB,SAAgB,aAAa,MAAa,MAItC,EAAE,EAAU;CACd,MAAM,EAAE,YAAY,qBAAqB;CACzC,IAAI,OAAO;AACX,KAAI,IAAI,OACN,QAAO;AAOT,MAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,IAC/B,SAAQ,GAAG,KAAK,GAAG,KAAK,UAAkB;AACxC,MAAI,SAAS,QAAQ,UAAU,GAC7B,QAAO;AACT,MAAI,UAAU,MAAM,CAClB,QAAO,QAAQ,IAAI;EACrB,IAAI,IAAI,OAAO,MAAM;AACrB,MAAI,SAAS,MAAM,IAAI,QAAQ,MAAM,CACnC,KAAI,kBAAkB,MAAM;AAC9B,MAAI,EAAE,SAAS,KAAI,IAAI,EAAE,SAAS,KAAK,IAAI,EAAE,SAAS,UAAU,CAC9D,QAAO,IAAI,EAAE,QAAQ,MAAM,OAAK,CAAC;AACnC,SAAO;GACP,CAAC,KAAK,UAAU,CAAC;AAGrB,QAAO;;AAGT,SAAgB,SAAS,KAAa,MAElC,EAAE,EAAE;CAGN,IAAI,0BAA0B;AAC9B,KAAI,IAAI,UACN,2BAA0B,IAAI,OAAO,wBAAwB,OAAO,QAAQ,WAAW,aAAa,IAAI,UAAU,CAAC,EAAE,wBAAwB,MAAM;CAErJ,MAAM,QAAiB,EAAE;CACzB,IAAI,MAAa,EAAE;CACnB,IAAI;CACJ,MAAM,OAAO,GAAG,IAAI,QAAQ,SAAS,KAAK,CAAC,MAAM,CAAC;AAGlD,QAAO,IAAI,wBAAwB,KAAK,KAAK,EAAE;EAC7C,IAAI,QAAQ,EAAE,MAAM,EAAE,MAAM;AAC5B,UAAQ,MAAM,QAAQ,OAAO,KAAI;AACjC,MAAI,KAAK,MAAM;AACf,MAAI,EAAE,OAAO,MAAM;AACjB,SAAM,KAAK,IAAI;AACf,SAAM,EAAE;;;AAGZ,QAAO;;AAGT,SAAgB,kBAAkB,KAAa,MAE3C,EAAE,EAAE;CACN,MAAM,QAAQ,SAAS,KAAK,IAAI;CAChC,MAAM,SAAS,MAAM;AACrB,QAAO,MAAM,MAAM,EAAE,CAAC,KAAI,MACxB,OAAO,YAAa,EAAE,KAAK,GAAG,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,CACrD"}
|