altcha 2.2.4 → 3.0.0-beta.1
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/LICENSE.txt +1 -1
- package/README.md +152 -197
- package/dist/external/altcha.css +1 -0
- package/dist/external/altcha.js +6681 -0
- package/dist/external/altcha.min.js +1 -0
- package/dist/external/altcha.umd.cjs +6687 -0
- package/dist/external/altcha.umd.min.cjs +1 -0
- package/dist/external/index.d.ts +1 -0
- package/dist/i18n/419.d.ts +1 -0
- package/dist/i18n/af.d.ts +1 -0
- package/dist/i18n/af.js +22 -0
- package/dist/i18n/af.umd.cjs +27 -0
- package/dist/i18n/africa.d.ts +1 -0
- package/{dist_i18n → dist/i18n}/africa.js +52 -97
- package/dist/i18n/africa.umd.cjs +159 -0
- package/dist/i18n/all.d.ts +1 -0
- package/{dist_i18n → dist/i18n}/all.js +465 -299
- package/dist/i18n/all.umd.cjs +1325 -0
- package/dist/i18n/am.d.ts +1 -0
- package/dist/i18n/am.js +22 -0
- package/dist/i18n/am.umd.cjs +27 -0
- package/dist/i18n/americas.d.ts +1 -0
- package/{dist_i18n → dist/i18n}/americas.js +24 -85
- package/dist/i18n/americas.umd.cjs +71 -0
- package/dist/i18n/ar.d.ts +1 -0
- package/dist/i18n/ar.js +22 -0
- package/dist/i18n/ar.umd.cjs +27 -0
- package/dist/i18n/asia.d.ts +1 -0
- package/{dist_i18n → dist/i18n}/asia.js +177 -158
- package/dist/i18n/asia.umd.cjs +511 -0
- package/dist/i18n/az.d.ts +1 -0
- package/dist/i18n/az.js +22 -0
- package/dist/i18n/az.umd.cjs +27 -0
- package/dist/i18n/be.d.ts +1 -0
- package/dist/i18n/be.js +22 -0
- package/dist/i18n/be.umd.cjs +27 -0
- package/dist/i18n/bg.d.ts +1 -0
- package/dist/i18n/bg.js +22 -0
- package/dist/i18n/bg.umd.cjs +27 -0
- package/dist/i18n/bn.d.ts +1 -0
- package/dist/i18n/bn.js +22 -0
- package/dist/i18n/bn.umd.cjs +27 -0
- package/dist/i18n/br.d.ts +1 -0
- package/dist/i18n/bs.d.ts +1 -0
- package/dist/i18n/bs.js +22 -0
- package/dist/i18n/bs.umd.cjs +27 -0
- package/dist/i18n/ca.d.ts +1 -0
- package/dist/i18n/ca.js +22 -0
- package/dist/i18n/ca.umd.cjs +27 -0
- package/dist/i18n/cn.d.ts +1 -0
- package/dist/i18n/cs.d.ts +1 -0
- package/dist/i18n/cs.js +22 -0
- package/dist/i18n/cs.umd.cjs +27 -0
- package/dist/i18n/da.d.ts +1 -0
- package/dist/i18n/da.js +22 -0
- package/dist/i18n/da.umd.cjs +27 -0
- package/dist/i18n/de.d.ts +1 -0
- package/dist/i18n/de.js +22 -0
- package/dist/i18n/de.umd.cjs +27 -0
- package/dist/i18n/el.d.ts +1 -0
- package/dist/i18n/el.js +22 -0
- package/dist/i18n/el.umd.cjs +27 -0
- package/dist/i18n/en.d.ts +1 -0
- package/dist/i18n/en.js +22 -0
- package/dist/i18n/en.umd.cjs +27 -0
- package/dist/i18n/es-419.js +22 -0
- package/dist/i18n/es-419.umd.cjs +27 -0
- package/dist/i18n/es-es.js +22 -0
- package/dist/i18n/es-es.umd.cjs +27 -0
- package/dist/i18n/es.d.ts +1 -0
- package/dist/i18n/et.d.ts +1 -0
- package/dist/i18n/et.js +22 -0
- package/dist/i18n/et.umd.cjs +27 -0
- package/dist/i18n/eu.d.ts +1 -0
- package/dist/i18n/eu.js +22 -0
- package/dist/i18n/eu.umd.cjs +27 -0
- package/dist/i18n/europe.d.ts +1 -0
- package/{dist_i18n → dist/i18n}/europe.js +283 -209
- package/dist/i18n/europe.umd.cjs +819 -0
- package/dist/i18n/fa.d.ts +1 -0
- package/dist/i18n/fa.js +22 -0
- package/dist/i18n/fa.umd.cjs +27 -0
- package/dist/i18n/fi.d.ts +1 -0
- package/dist/i18n/fi.js +22 -0
- package/dist/i18n/fi.umd.cjs +27 -0
- package/dist/i18n/fr-ca.js +22 -0
- package/dist/i18n/fr-ca.umd.cjs +27 -0
- package/dist/i18n/fr-fr.js +22 -0
- package/dist/i18n/fr-fr.umd.cjs +27 -0
- package/dist/i18n/fr.d.ts +1 -0
- package/dist/i18n/ga.d.ts +1 -0
- package/dist/i18n/ga.js +22 -0
- package/dist/i18n/ga.umd.cjs +27 -0
- package/dist/i18n/he.d.ts +1 -0
- package/dist/i18n/he.js +22 -0
- package/dist/i18n/he.umd.cjs +27 -0
- package/dist/i18n/hi.d.ts +1 -0
- package/dist/i18n/hi.js +22 -0
- package/dist/i18n/hi.umd.cjs +27 -0
- package/dist/i18n/hr.d.ts +1 -0
- package/dist/i18n/hr.js +22 -0
- package/dist/i18n/hr.umd.cjs +27 -0
- package/dist/i18n/hu.d.ts +1 -0
- package/dist/i18n/hu.js +22 -0
- package/dist/i18n/hu.umd.cjs +27 -0
- package/dist/i18n/hy.d.ts +1 -0
- package/dist/i18n/hy.js +22 -0
- package/dist/i18n/hy.umd.cjs +27 -0
- package/dist/i18n/id.d.ts +1 -0
- package/dist/i18n/id.js +22 -0
- package/dist/i18n/id.umd.cjs +27 -0
- package/dist/i18n/is.d.ts +1 -0
- package/dist/i18n/is.js +22 -0
- package/dist/i18n/is.umd.cjs +27 -0
- package/dist/i18n/it.d.ts +1 -0
- package/dist/i18n/it.js +22 -0
- package/dist/i18n/it.umd.cjs +27 -0
- package/dist/i18n/ja.d.ts +1 -0
- package/dist/i18n/ja.js +22 -0
- package/dist/i18n/ja.umd.cjs +27 -0
- package/dist/i18n/ka.d.ts +1 -0
- package/dist/i18n/ka.js +22 -0
- package/dist/i18n/ka.umd.cjs +27 -0
- package/dist/i18n/kk.d.ts +1 -0
- package/dist/i18n/kk.js +22 -0
- package/dist/i18n/kk.umd.cjs +27 -0
- package/dist/i18n/ko.d.ts +1 -0
- package/dist/i18n/ko.js +22 -0
- package/dist/i18n/ko.umd.cjs +27 -0
- package/dist/i18n/lb.d.ts +1 -0
- package/dist/i18n/lb.js +22 -0
- package/dist/i18n/lb.umd.cjs +27 -0
- package/dist/i18n/lt.d.ts +1 -0
- package/dist/i18n/lt.js +22 -0
- package/dist/i18n/lt.umd.cjs +27 -0
- package/dist/i18n/lv.d.ts +1 -0
- package/dist/i18n/lv.js +22 -0
- package/dist/i18n/lv.umd.cjs +27 -0
- package/dist/i18n/me.d.ts +1 -0
- package/dist/i18n/me.js +22 -0
- package/dist/i18n/me.umd.cjs +27 -0
- package/dist/i18n/mk.d.ts +1 -0
- package/dist/i18n/mk.js +22 -0
- package/dist/i18n/mk.umd.cjs +27 -0
- package/dist/i18n/mr.d.ts +1 -0
- package/dist/i18n/mr.js +22 -0
- package/dist/i18n/mr.umd.cjs +27 -0
- package/dist/i18n/mt.d.ts +1 -0
- package/dist/i18n/mt.js +22 -0
- package/dist/i18n/mt.umd.cjs +27 -0
- package/dist/i18n/nb.d.ts +1 -0
- package/dist/i18n/nb.js +22 -0
- package/dist/i18n/nb.umd.cjs +27 -0
- package/dist/i18n/nl.d.ts +1 -0
- package/dist/i18n/nl.js +22 -0
- package/dist/i18n/nl.umd.cjs +27 -0
- package/dist/i18n/pl.d.ts +1 -0
- package/dist/i18n/pl.js +22 -0
- package/dist/i18n/pl.umd.cjs +27 -0
- package/dist/i18n/pt-br.js +22 -0
- package/dist/i18n/pt-br.umd.cjs +27 -0
- package/dist/i18n/pt-pt.js +22 -0
- package/dist/i18n/pt-pt.umd.cjs +27 -0
- package/dist/i18n/pt.d.ts +1 -0
- package/dist/i18n/ro.d.ts +1 -0
- package/dist/i18n/ro.js +22 -0
- package/dist/i18n/ro.umd.cjs +27 -0
- package/dist/i18n/ru.d.ts +1 -0
- package/dist/i18n/ru.js +22 -0
- package/dist/i18n/ru.umd.cjs +27 -0
- package/dist/i18n/sk.d.ts +1 -0
- package/dist/i18n/sk.js +22 -0
- package/dist/i18n/sk.umd.cjs +27 -0
- package/dist/i18n/sl.d.ts +1 -0
- package/dist/i18n/sl.js +22 -0
- package/dist/i18n/sl.umd.cjs +27 -0
- package/dist/i18n/sq.d.ts +1 -0
- package/dist/i18n/sq.js +22 -0
- package/dist/i18n/sq.umd.cjs +27 -0
- package/dist/i18n/sr.d.ts +1 -0
- package/dist/i18n/sr.js +22 -0
- package/dist/i18n/sr.umd.cjs +27 -0
- package/dist/i18n/sv.d.ts +1 -0
- package/dist/i18n/sv.js +22 -0
- package/dist/i18n/sv.umd.cjs +27 -0
- package/dist/i18n/sw.d.ts +1 -0
- package/dist/i18n/sw.js +22 -0
- package/dist/i18n/sw.umd.cjs +27 -0
- package/dist/i18n/ta.d.ts +1 -0
- package/dist/i18n/ta.js +22 -0
- package/dist/i18n/ta.umd.cjs +27 -0
- package/dist/i18n/te.d.ts +1 -0
- package/dist/i18n/te.js +22 -0
- package/dist/i18n/te.umd.cjs +27 -0
- package/dist/i18n/th.d.ts +1 -0
- package/dist/i18n/th.js +22 -0
- package/dist/i18n/th.umd.cjs +27 -0
- package/dist/i18n/tk.d.ts +1 -0
- package/dist/i18n/tk.js +22 -0
- package/dist/i18n/tk.umd.cjs +27 -0
- package/dist/i18n/tr.d.ts +1 -0
- package/dist/i18n/tr.js +22 -0
- package/dist/i18n/tr.umd.cjs +27 -0
- package/dist/i18n/tw.d.ts +1 -0
- package/dist/i18n/uk.d.ts +1 -0
- package/dist/i18n/uk.js +22 -0
- package/dist/i18n/uk.umd.cjs +27 -0
- package/dist/i18n/ur.d.ts +1 -0
- package/dist/i18n/ur.js +22 -0
- package/dist/i18n/ur.umd.cjs +27 -0
- package/dist/i18n/uz.d.ts +1 -0
- package/dist/i18n/uz.js +22 -0
- package/dist/i18n/uz.umd.cjs +27 -0
- package/dist/i18n/vi.d.ts +1 -0
- package/dist/i18n/vi.js +22 -0
- package/dist/i18n/vi.umd.cjs +27 -0
- package/dist/i18n/yo.d.ts +1 -0
- package/dist/i18n/yo.js +22 -0
- package/dist/i18n/yo.umd.cjs +27 -0
- package/dist/i18n/zh-cn.js +22 -0
- package/dist/i18n/zh-cn.umd.cjs +27 -0
- package/dist/i18n/zh-tw.js +22 -0
- package/dist/i18n/zh-tw.umd.cjs +27 -0
- package/dist/lib/index.d.ts +143 -0
- package/dist/lib/index.js +1344 -0
- package/dist/lib/index.min.js +1 -0
- package/dist/lib/index.umd.cjs +1348 -0
- package/dist/lib/index.umd.min.cjs +1 -0
- package/dist/main/altcha.i18n.js +8389 -0
- package/dist/main/altcha.i18n.min.js +1 -0
- package/dist/main/altcha.i18n.umd.cjs +8392 -0
- package/dist/main/altcha.i18n.umd.min.cjs +1 -0
- package/dist/main/altcha.js +7069 -0
- package/dist/main/altcha.min.js +1 -0
- package/dist/main/altcha.umd.cjs +7072 -0
- package/dist/main/altcha.umd.min.cjs +1 -0
- package/dist/plugins/obfuscation.plugin.d.ts +1 -0
- package/dist/plugins/obfuscation.plugin.js +320 -0
- package/dist/plugins/obfuscation.plugin.min.js +1 -0
- package/dist/plugins/obfuscation.plugin.umd.cjs +325 -0
- package/dist/plugins/obfuscation.plugin.umd.min.cjs +1 -0
- package/dist/themes/aqua.css +19 -0
- package/dist/themes/aqua.min.css +1 -0
- package/dist/themes/business.css +15 -0
- package/dist/themes/business.min.css +1 -0
- package/dist/themes/caramel.css +19 -0
- package/dist/themes/caramel.min.css +1 -0
- package/dist/themes/cupcake.css +16 -0
- package/dist/themes/cupcake.min.css +1 -0
- package/dist/themes/cyberpunk.css +24 -0
- package/dist/themes/cyberpunk.min.css +1 -0
- package/dist/themes/lime.css +13 -0
- package/dist/themes/lime.min.css +1 -0
- package/dist/themes/wireframe.css +17 -0
- package/dist/themes/wireframe.min.css +1 -0
- package/dist/types/generic.d.ts +25 -0
- package/dist/types/generic.js +1 -0
- package/dist/types/global.d.ts +5 -0
- package/dist/types/global.js +1 -0
- package/dist/types/index.d.ts +352 -0
- package/dist/types/index.js +23 -0
- package/dist/types/jsx.d.ts +13 -0
- package/dist/types/jsx.js +1 -0
- package/dist/types/react.d.ts +35 -0
- package/dist/types/react.js +1 -0
- package/dist/types/svelte.d.ts +26 -0
- package/dist/types/svelte.js +1 -0
- package/dist/workers/argon2id.js +786 -0
- package/dist/workers/pbkdf2.js +166 -0
- package/dist/workers/scrypt.js +739 -0
- package/dist/workers/sha.js +160 -0
- package/package.json +115 -95
- package/dist/altcha.d.ts +0 -183
- package/dist/altcha.i18n.d.ts +0 -183
- package/dist/altcha.i18n.js +0 -4182
- package/dist/altcha.i18n.umd.js +0 -4
- package/dist/altcha.js +0 -3105
- package/dist/altcha.umd.cjs +0 -4
- package/dist_external/altcha.css +0 -1
- package/dist_external/altcha.d.ts +0 -183
- package/dist_external/altcha.js +0 -3075
- package/dist_external/altcha.umd.cjs +0 -3
- package/dist_external/worker.js +0 -1
- package/dist_i18n/af.d.ts +0 -1
- package/dist_i18n/af.js +0 -94
- package/dist_i18n/af.umd.cjs +0 -1
- package/dist_i18n/africa.d.ts +0 -1
- package/dist_i18n/africa.umd.cjs +0 -1
- package/dist_i18n/all.d.ts +0 -1
- package/dist_i18n/all.umd.cjs +0 -1
- package/dist_i18n/am.d.ts +0 -1
- package/dist_i18n/am.js +0 -94
- package/dist_i18n/am.umd.cjs +0 -1
- package/dist_i18n/americas.d.ts +0 -1
- package/dist_i18n/americas.umd.cjs +0 -1
- package/dist_i18n/ar.d.ts +0 -1
- package/dist_i18n/ar.js +0 -94
- package/dist_i18n/ar.umd.cjs +0 -1
- package/dist_i18n/asia.d.ts +0 -1
- package/dist_i18n/asia.umd.cjs +0 -1
- package/dist_i18n/az.d.ts +0 -1
- package/dist_i18n/az.js +0 -94
- package/dist_i18n/az.umd.cjs +0 -1
- package/dist_i18n/be.d.ts +0 -1
- package/dist_i18n/be.js +0 -94
- package/dist_i18n/be.umd.cjs +0 -1
- package/dist_i18n/bg.d.ts +0 -1
- package/dist_i18n/bg.js +0 -94
- package/dist_i18n/bg.umd.cjs +0 -1
- package/dist_i18n/bn.d.ts +0 -1
- package/dist_i18n/bn.js +0 -94
- package/dist_i18n/bn.umd.cjs +0 -1
- package/dist_i18n/bs.d.ts +0 -1
- package/dist_i18n/bs.js +0 -94
- package/dist_i18n/bs.umd.cjs +0 -1
- package/dist_i18n/ca.d.ts +0 -1
- package/dist_i18n/ca.js +0 -94
- package/dist_i18n/ca.umd.cjs +0 -1
- package/dist_i18n/cs.d.ts +0 -1
- package/dist_i18n/cs.js +0 -94
- package/dist_i18n/cs.umd.cjs +0 -1
- package/dist_i18n/da.d.ts +0 -1
- package/dist_i18n/da.js +0 -94
- package/dist_i18n/da.umd.cjs +0 -1
- package/dist_i18n/de.d.ts +0 -1
- package/dist_i18n/de.js +0 -94
- package/dist_i18n/de.umd.cjs +0 -1
- package/dist_i18n/el.d.ts +0 -1
- package/dist_i18n/el.js +0 -94
- package/dist_i18n/el.umd.cjs +0 -1
- package/dist_i18n/en.d.ts +0 -1
- package/dist_i18n/en.js +0 -94
- package/dist_i18n/en.umd.cjs +0 -1
- package/dist_i18n/es-419.d.ts +0 -1
- package/dist_i18n/es-419.js +0 -94
- package/dist_i18n/es-419.umd.cjs +0 -1
- package/dist_i18n/es-es.d.ts +0 -1
- package/dist_i18n/es-es.js +0 -94
- package/dist_i18n/es-es.umd.cjs +0 -1
- package/dist_i18n/et.d.ts +0 -1
- package/dist_i18n/et.js +0 -94
- package/dist_i18n/et.umd.cjs +0 -1
- package/dist_i18n/eu.d.ts +0 -1
- package/dist_i18n/eu.js +0 -94
- package/dist_i18n/eu.umd.cjs +0 -1
- package/dist_i18n/europe.d.ts +0 -1
- package/dist_i18n/europe.umd.cjs +0 -1
- package/dist_i18n/fa.d.ts +0 -1
- package/dist_i18n/fa.js +0 -94
- package/dist_i18n/fa.umd.cjs +0 -1
- package/dist_i18n/fi.d.ts +0 -1
- package/dist_i18n/fi.js +0 -94
- package/dist_i18n/fi.umd.cjs +0 -1
- package/dist_i18n/fr-ca.d.ts +0 -1
- package/dist_i18n/fr-ca.js +0 -94
- package/dist_i18n/fr-ca.umd.cjs +0 -1
- package/dist_i18n/fr-fr.d.ts +0 -1
- package/dist_i18n/fr-fr.js +0 -94
- package/dist_i18n/fr-fr.umd.cjs +0 -1
- package/dist_i18n/ga.d.ts +0 -1
- package/dist_i18n/ga.js +0 -94
- package/dist_i18n/ga.umd.cjs +0 -1
- package/dist_i18n/he.d.ts +0 -1
- package/dist_i18n/he.js +0 -94
- package/dist_i18n/he.umd.cjs +0 -1
- package/dist_i18n/hi.d.ts +0 -1
- package/dist_i18n/hi.js +0 -94
- package/dist_i18n/hi.umd.cjs +0 -1
- package/dist_i18n/hr.d.ts +0 -1
- package/dist_i18n/hr.js +0 -94
- package/dist_i18n/hr.umd.cjs +0 -1
- package/dist_i18n/hu.d.ts +0 -1
- package/dist_i18n/hu.js +0 -94
- package/dist_i18n/hu.umd.cjs +0 -1
- package/dist_i18n/hy.d.ts +0 -1
- package/dist_i18n/hy.js +0 -94
- package/dist_i18n/hy.umd.cjs +0 -1
- package/dist_i18n/id.d.ts +0 -1
- package/dist_i18n/id.js +0 -94
- package/dist_i18n/id.umd.cjs +0 -1
- package/dist_i18n/is.d.ts +0 -1
- package/dist_i18n/is.js +0 -94
- package/dist_i18n/is.umd.cjs +0 -1
- package/dist_i18n/it.d.ts +0 -1
- package/dist_i18n/it.js +0 -94
- package/dist_i18n/it.umd.cjs +0 -1
- package/dist_i18n/ja.d.ts +0 -1
- package/dist_i18n/ja.js +0 -94
- package/dist_i18n/ja.umd.cjs +0 -1
- package/dist_i18n/ka.d.ts +0 -1
- package/dist_i18n/ka.js +0 -94
- package/dist_i18n/ka.umd.cjs +0 -1
- package/dist_i18n/kk.d.ts +0 -1
- package/dist_i18n/kk.js +0 -94
- package/dist_i18n/kk.umd.cjs +0 -1
- package/dist_i18n/ko.d.ts +0 -1
- package/dist_i18n/ko.js +0 -94
- package/dist_i18n/ko.umd.cjs +0 -1
- package/dist_i18n/lb.d.ts +0 -1
- package/dist_i18n/lb.js +0 -94
- package/dist_i18n/lb.umd.cjs +0 -1
- package/dist_i18n/lt.d.ts +0 -1
- package/dist_i18n/lt.js +0 -94
- package/dist_i18n/lt.umd.cjs +0 -1
- package/dist_i18n/lv.d.ts +0 -1
- package/dist_i18n/lv.js +0 -94
- package/dist_i18n/lv.umd.cjs +0 -1
- package/dist_i18n/me.d.ts +0 -1
- package/dist_i18n/me.js +0 -94
- package/dist_i18n/me.umd.cjs +0 -1
- package/dist_i18n/mk.d.ts +0 -1
- package/dist_i18n/mk.js +0 -94
- package/dist_i18n/mk.umd.cjs +0 -1
- package/dist_i18n/mr.d.ts +0 -1
- package/dist_i18n/mr.js +0 -94
- package/dist_i18n/mr.umd.cjs +0 -1
- package/dist_i18n/mt.d.ts +0 -1
- package/dist_i18n/mt.js +0 -94
- package/dist_i18n/mt.umd.cjs +0 -1
- package/dist_i18n/nb.d.ts +0 -1
- package/dist_i18n/nb.js +0 -95
- package/dist_i18n/nb.umd.cjs +0 -1
- package/dist_i18n/nl.d.ts +0 -1
- package/dist_i18n/nl.js +0 -94
- package/dist_i18n/nl.umd.cjs +0 -1
- package/dist_i18n/pl.d.ts +0 -1
- package/dist_i18n/pl.js +0 -94
- package/dist_i18n/pl.umd.cjs +0 -1
- package/dist_i18n/pt-br.d.ts +0 -1
- package/dist_i18n/pt-br.js +0 -94
- package/dist_i18n/pt-br.umd.cjs +0 -1
- package/dist_i18n/pt-pt.d.ts +0 -1
- package/dist_i18n/pt-pt.js +0 -94
- package/dist_i18n/pt-pt.umd.cjs +0 -1
- package/dist_i18n/ro.d.ts +0 -1
- package/dist_i18n/ro.js +0 -94
- package/dist_i18n/ro.umd.cjs +0 -1
- package/dist_i18n/ru.d.ts +0 -1
- package/dist_i18n/ru.js +0 -94
- package/dist_i18n/ru.umd.cjs +0 -1
- package/dist_i18n/sk.d.ts +0 -1
- package/dist_i18n/sk.js +0 -94
- package/dist_i18n/sk.umd.cjs +0 -1
- package/dist_i18n/sl.d.ts +0 -1
- package/dist_i18n/sl.js +0 -94
- package/dist_i18n/sl.umd.cjs +0 -1
- package/dist_i18n/sq.d.ts +0 -1
- package/dist_i18n/sq.js +0 -94
- package/dist_i18n/sq.umd.cjs +0 -1
- package/dist_i18n/sr.d.ts +0 -1
- package/dist_i18n/sr.js +0 -94
- package/dist_i18n/sr.umd.cjs +0 -1
- package/dist_i18n/sv.d.ts +0 -1
- package/dist_i18n/sv.js +0 -94
- package/dist_i18n/sv.umd.cjs +0 -1
- package/dist_i18n/sw.d.ts +0 -1
- package/dist_i18n/sw.js +0 -94
- package/dist_i18n/sw.umd.cjs +0 -1
- package/dist_i18n/ta.d.ts +0 -1
- package/dist_i18n/ta.js +0 -94
- package/dist_i18n/ta.umd.cjs +0 -1
- package/dist_i18n/te.d.ts +0 -1
- package/dist_i18n/te.js +0 -94
- package/dist_i18n/te.umd.cjs +0 -1
- package/dist_i18n/th.d.ts +0 -1
- package/dist_i18n/th.js +0 -94
- package/dist_i18n/th.umd.cjs +0 -1
- package/dist_i18n/tk.d.ts +0 -1
- package/dist_i18n/tk.js +0 -94
- package/dist_i18n/tk.umd.cjs +0 -1
- package/dist_i18n/tr.d.ts +0 -1
- package/dist_i18n/tr.js +0 -94
- package/dist_i18n/tr.umd.cjs +0 -1
- package/dist_i18n/uk.d.ts +0 -1
- package/dist_i18n/uk.js +0 -94
- package/dist_i18n/uk.umd.cjs +0 -1
- package/dist_i18n/ur.d.ts +0 -1
- package/dist_i18n/ur.js +0 -94
- package/dist_i18n/ur.umd.cjs +0 -1
- package/dist_i18n/uz.d.ts +0 -1
- package/dist_i18n/uz.js +0 -94
- package/dist_i18n/uz.umd.cjs +0 -1
- package/dist_i18n/vi.d.ts +0 -1
- package/dist_i18n/vi.js +0 -94
- package/dist_i18n/vi.umd.cjs +0 -1
- package/dist_i18n/yo.d.ts +0 -1
- package/dist_i18n/yo.js +0 -94
- package/dist_i18n/yo.umd.cjs +0 -1
- package/dist_i18n/zh-cn.d.ts +0 -1
- package/dist_i18n/zh-cn.js +0 -94
- package/dist_i18n/zh-cn.umd.cjs +0 -1
- package/dist_i18n/zh-tw.d.ts +0 -1
- package/dist_i18n/zh-tw.js +0 -94
- package/dist_i18n/zh-tw.umd.cjs +0 -1
- package/dist_plugins/analytics.d.ts +0 -1
- package/dist_plugins/analytics.js +0 -276
- package/dist_plugins/analytics.umd.cjs +0 -1
- package/dist_plugins/obfuscation.d.ts +0 -1
- package/dist_plugins/obfuscation.js +0 -129
- package/dist_plugins/obfuscation.umd.cjs +0 -1
- package/dist_plugins/upload.d.ts +0 -1
- package/dist_plugins/upload.js +0 -503
- package/dist_plugins/upload.umd.cjs +0 -4
package/dist_plugins/upload.js
DELETED
|
@@ -1,503 +0,0 @@
|
|
|
1
|
-
const u = {
|
|
2
|
-
generateKey: v,
|
|
3
|
-
exportKey: S,
|
|
4
|
-
importKey: x,
|
|
5
|
-
decrypt: C,
|
|
6
|
-
encrypt: L
|
|
7
|
-
};
|
|
8
|
-
async function v(n = 256) {
|
|
9
|
-
return crypto.subtle.generateKey({
|
|
10
|
-
name: "AES-GCM",
|
|
11
|
-
length: n
|
|
12
|
-
}, !0, ["encrypt", "decrypt"]);
|
|
13
|
-
}
|
|
14
|
-
async function S(n) {
|
|
15
|
-
return new Uint8Array(await crypto.subtle.exportKey("raw", n));
|
|
16
|
-
}
|
|
17
|
-
async function x(n) {
|
|
18
|
-
return crypto.subtle.importKey("raw", n, {
|
|
19
|
-
name: "AES-GCM"
|
|
20
|
-
}, !0, ["encrypt", "decrypt"]);
|
|
21
|
-
}
|
|
22
|
-
async function L(n, e, t = 16) {
|
|
23
|
-
const r = crypto.getRandomValues(new Uint8Array(t));
|
|
24
|
-
return {
|
|
25
|
-
encrypted: new Uint8Array(await crypto.subtle.encrypt({
|
|
26
|
-
name: "AES-GCM",
|
|
27
|
-
iv: r
|
|
28
|
-
}, n, e)),
|
|
29
|
-
iv: r
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
async function C(n, e, t) {
|
|
33
|
-
return new Uint8Array(await crypto.subtle.decrypt({
|
|
34
|
-
name: "AES-GCM",
|
|
35
|
-
iv: t
|
|
36
|
-
}, n, e));
|
|
37
|
-
}
|
|
38
|
-
function I(n, e = !1) {
|
|
39
|
-
return e && (n = n.replace(/_/g, "/").replace(/-/g, "+") + "=".repeat(3 - (3 + n.length) % 4)), Uint8Array.from(atob(n), (t) => t.charCodeAt(0));
|
|
40
|
-
}
|
|
41
|
-
function h(n, e = !1) {
|
|
42
|
-
const t = btoa(String.fromCharCode(...n));
|
|
43
|
-
return e ? t.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "") : t;
|
|
44
|
-
}
|
|
45
|
-
function f(n, e = 80) {
|
|
46
|
-
let t = "";
|
|
47
|
-
for (; n.length > 0; )
|
|
48
|
-
t += n.slice(0, e) + `
|
|
49
|
-
`, n = n.slice(e);
|
|
50
|
-
return t;
|
|
51
|
-
}
|
|
52
|
-
function g(n) {
|
|
53
|
-
return I(n.split(/\r?\n/).filter((e) => !e.startsWith("-----")).join(""));
|
|
54
|
-
}
|
|
55
|
-
const l = "RSA-OAEP", p = "SHA-256", N = 2048, z = new Uint8Array([1, 0, 1]), T = {
|
|
56
|
-
generateKeyPair: _,
|
|
57
|
-
encrypt: R,
|
|
58
|
-
decrypt: j,
|
|
59
|
-
exportPrivateKey: m,
|
|
60
|
-
exportPrivateKeyPem: H,
|
|
61
|
-
exportPublicKey: d,
|
|
62
|
-
exportPublicKeyPem: k,
|
|
63
|
-
exportPublicKeyFromPrivateKey: O,
|
|
64
|
-
importPrivateKey: E,
|
|
65
|
-
importPrivateKeyPem: q,
|
|
66
|
-
importPublicKey: w,
|
|
67
|
-
importPublicKeyPem: b
|
|
68
|
-
};
|
|
69
|
-
async function _() {
|
|
70
|
-
return crypto.subtle.generateKey({
|
|
71
|
-
name: l,
|
|
72
|
-
modulusLength: N,
|
|
73
|
-
publicExponent: z,
|
|
74
|
-
hash: p
|
|
75
|
-
}, !0, ["encrypt", "decrypt"]);
|
|
76
|
-
}
|
|
77
|
-
async function R(n, e) {
|
|
78
|
-
return new Uint8Array(await crypto.subtle.encrypt({
|
|
79
|
-
name: l
|
|
80
|
-
}, n, e));
|
|
81
|
-
}
|
|
82
|
-
async function j(n, e) {
|
|
83
|
-
return new Uint8Array(await crypto.subtle.decrypt({
|
|
84
|
-
name: l
|
|
85
|
-
}, n, e));
|
|
86
|
-
}
|
|
87
|
-
async function d(n) {
|
|
88
|
-
return new Uint8Array(await crypto.subtle.exportKey("spki", n));
|
|
89
|
-
}
|
|
90
|
-
async function m(n) {
|
|
91
|
-
return new Uint8Array(await crypto.subtle.exportKey("pkcs8", n));
|
|
92
|
-
}
|
|
93
|
-
async function k(n) {
|
|
94
|
-
return `-----BEGIN PUBLIC KEY-----
|
|
95
|
-
` + f(h(await d(n)), 64) + "-----END PUBLIC KEY-----";
|
|
96
|
-
}
|
|
97
|
-
async function H(n) {
|
|
98
|
-
return `-----BEGIN PRIVATE KEY-----
|
|
99
|
-
` + f(h(await m(n)), 64) + "-----END PRIVATE KEY-----";
|
|
100
|
-
}
|
|
101
|
-
async function w(n) {
|
|
102
|
-
return crypto.subtle.importKey("spki", n, {
|
|
103
|
-
name: l,
|
|
104
|
-
hash: p
|
|
105
|
-
}, !0, ["encrypt"]);
|
|
106
|
-
}
|
|
107
|
-
async function b(n) {
|
|
108
|
-
return w(g(n));
|
|
109
|
-
}
|
|
110
|
-
async function E(n) {
|
|
111
|
-
return crypto.subtle.importKey("pkcs8", n, {
|
|
112
|
-
name: l,
|
|
113
|
-
hash: p
|
|
114
|
-
}, !0, ["decrypt"]);
|
|
115
|
-
}
|
|
116
|
-
async function q(n) {
|
|
117
|
-
return E(g(n));
|
|
118
|
-
}
|
|
119
|
-
async function O(n) {
|
|
120
|
-
const e = await crypto.subtle.exportKey("jwk", n);
|
|
121
|
-
delete e.d, delete e.dp, delete e.dq, delete e.q, delete e.qi, e.key_ops = ["encrypt"];
|
|
122
|
-
const t = await crypto.subtle.importKey("jwk", e, {
|
|
123
|
-
name: l,
|
|
124
|
-
hash: p
|
|
125
|
-
}, !0, ["encrypt"]);
|
|
126
|
-
return d(t);
|
|
127
|
-
}
|
|
128
|
-
const $ = new Uint8Array([1, 0, 1]), B = 256, G = 16;
|
|
129
|
-
async function M(n, e, t = {}) {
|
|
130
|
-
const { aesIVLength: r = G, aesKeyLength: i = B } = t, s = await u.generateKey(i), { encrypted: o, iv: a } = await u.encrypt(s, e, r), c = await T.encrypt(n, await u.exportKey(s));
|
|
131
|
-
return new Uint8Array([
|
|
132
|
-
...$,
|
|
133
|
-
...new Uint8Array([c.length]),
|
|
134
|
-
...new Uint8Array([a.length]),
|
|
135
|
-
...c,
|
|
136
|
-
...a,
|
|
137
|
-
...o
|
|
138
|
-
]);
|
|
139
|
-
}
|
|
140
|
-
class U {
|
|
141
|
-
/**
|
|
142
|
-
* Constructs a new instance of the Plugin.
|
|
143
|
-
*
|
|
144
|
-
* @param {PluginContext} context - The context provided to the plugin, containing necessary configurations and dependencies.
|
|
145
|
-
*/
|
|
146
|
-
constructor(e) {
|
|
147
|
-
this.context = e;
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* A distinct name of the plugin. Every plugin must have it's own name.
|
|
151
|
-
*/
|
|
152
|
-
static pluginName;
|
|
153
|
-
/**
|
|
154
|
-
* Registers a plugin class in the global `altchaPlugins` array.
|
|
155
|
-
* Ensures the plugin is added only once.
|
|
156
|
-
*
|
|
157
|
-
* @param {new(context: PluginContext) => Plugin} cls - The plugin class to register.
|
|
158
|
-
*/
|
|
159
|
-
static register(e) {
|
|
160
|
-
typeof globalThis.altchaPlugins != "object" && (globalThis.altchaPlugins = []), globalThis.altchaPlugins.includes(e) || globalThis.altchaPlugins.push(e);
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Clean up resources when the plugin is destroyed.
|
|
164
|
-
* Override this method in subclasses to implement custom destruction logic.
|
|
165
|
-
*/
|
|
166
|
-
destroy() {
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* Callback triggered when an error changes.
|
|
170
|
-
* Override this method in subclasses to handle error state changes.
|
|
171
|
-
*
|
|
172
|
-
* @param {string | null} err - The error message or `null` if there's no error.
|
|
173
|
-
*/
|
|
174
|
-
onErrorChange(e) {
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Callback triggered when the plugin state changes.
|
|
178
|
-
* Override this method in subclasses to handle state changes.
|
|
179
|
-
*
|
|
180
|
-
* @param {State} state - The new state of the plugin.
|
|
181
|
-
*/
|
|
182
|
-
onStateChange(e) {
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
class Y extends U {
|
|
186
|
-
static pluginName = "upload";
|
|
187
|
-
pendingFiles = [];
|
|
188
|
-
uploadHandles = [];
|
|
189
|
-
elForm;
|
|
190
|
-
#e = this.#c.bind(this);
|
|
191
|
-
#t = this.#l.bind(this);
|
|
192
|
-
/**
|
|
193
|
-
* Constructor initializes the plugin, setting up event listeners on the form.
|
|
194
|
-
*
|
|
195
|
-
* @param {PluginContext} context - Plugin context providing access to the element, configuration, and utility methods.
|
|
196
|
-
*/
|
|
197
|
-
constructor(e) {
|
|
198
|
-
super(e), this.elForm = this.context.el.closest("form"), this.elForm && (this.elForm.addEventListener("change", this.#e), this.elForm.addEventListener("submit", this.#t, {
|
|
199
|
-
capture: !0
|
|
200
|
-
}));
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* Adds a file to the pending files list for upload.
|
|
204
|
-
*
|
|
205
|
-
* @param {string} fieldName - The field name associated with the file input.
|
|
206
|
-
* @param {File} file - The file to be uploaded.
|
|
207
|
-
*/
|
|
208
|
-
addFile(e, t) {
|
|
209
|
-
this.pendingFiles.find(([r, i]) => r === e && i === t) || this.pendingFiles.push([e, t]);
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* Cleans up event listeners and other resources when the plugin is destroyed.
|
|
213
|
-
*/
|
|
214
|
-
destroy() {
|
|
215
|
-
this.elForm && (this.elForm.removeEventListener("change", this.#e), this.elForm.removeEventListener("submit", this.#t));
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* Uploads all pending files in the list.
|
|
219
|
-
*/
|
|
220
|
-
async uploadPendingFiles() {
|
|
221
|
-
const e = async () => {
|
|
222
|
-
const t = this.pendingFiles[0];
|
|
223
|
-
if (t && await this.#r(this.#s(t)), this.pendingFiles.length)
|
|
224
|
-
return e();
|
|
225
|
-
};
|
|
226
|
-
try {
|
|
227
|
-
await e();
|
|
228
|
-
} catch (t) {
|
|
229
|
-
return this.context.log("upload failed", t), this.context.dispatch("uploaderror", {
|
|
230
|
-
error: t
|
|
231
|
-
}), !1;
|
|
232
|
-
}
|
|
233
|
-
this.pendingFiles.length === 0 && (this.#i(), this.elForm?.requestSubmit());
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
* Adds hidden input fields to the form containing the file IDs of uploaded files.
|
|
237
|
-
*/
|
|
238
|
-
#i() {
|
|
239
|
-
const e = this.uploadHandles.reduce(
|
|
240
|
-
(t, r) => (t[r.fieldName] || (t[r.fieldName] = []), r.fileId && t[r.fieldName].push(r.fileId), t),
|
|
241
|
-
{}
|
|
242
|
-
);
|
|
243
|
-
for (const t in e) {
|
|
244
|
-
const r = document.createElement("input");
|
|
245
|
-
r.name = t, r.type = "hidden", r.value = e[t].join(","), this.elForm?.querySelector(`[name="${t}"]`)?.setAttribute("disabled", "disabled"), this.elForm?.appendChild(r);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
/**
|
|
249
|
-
* Creates an upload handle for the specified pending file.
|
|
250
|
-
*
|
|
251
|
-
* @param {[string, File]} pendingFile - The field name and file to be uploaded.
|
|
252
|
-
* @returns {UploadHandle} The created upload handle.
|
|
253
|
-
* @throws Will throw an error if the upload handle cannot be created.
|
|
254
|
-
*/
|
|
255
|
-
#s(e) {
|
|
256
|
-
const t = this.pendingFiles.findIndex(
|
|
257
|
-
([i, s]) => i === e[0] && s === e[1]
|
|
258
|
-
);
|
|
259
|
-
if (t < 0)
|
|
260
|
-
throw new Error("Cannot create upload handle.");
|
|
261
|
-
const r = new D(e[0], e[1]);
|
|
262
|
-
return this.uploadHandles.push(r), this.pendingFiles.splice(t, 1), this.#o(r), this.#n(), r;
|
|
263
|
-
}
|
|
264
|
-
/**
|
|
265
|
-
* Dispatches a custom event when a file upload starts.
|
|
266
|
-
*
|
|
267
|
-
* @param {UploadHandle} handle - The upload handle associated with the file upload.
|
|
268
|
-
*/
|
|
269
|
-
#o(e) {
|
|
270
|
-
this.context.dispatch("upload", { handle: e });
|
|
271
|
-
}
|
|
272
|
-
/**
|
|
273
|
-
* Dispatches a custom event to track the progress of ongoing file uploads.
|
|
274
|
-
*/
|
|
275
|
-
#n() {
|
|
276
|
-
const e = this.pendingFiles.reduce((r, [i, s]) => r + s.size, 0) + this.uploadHandles.reduce((r, { uploadSize: i }) => r + i, 0), t = this.uploadHandles.reduce(
|
|
277
|
-
(r, { loaded: i }) => r + i,
|
|
278
|
-
0
|
|
279
|
-
);
|
|
280
|
-
this.context.dispatch("uploadprogress", {
|
|
281
|
-
bytesLoaded: t,
|
|
282
|
-
bytesTotal: e,
|
|
283
|
-
pendingFiles: this.pendingFiles,
|
|
284
|
-
uploadHandles: this.uploadHandles
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
|
-
/**
|
|
288
|
-
* Retrieves the upload URL from the form's attributes.
|
|
289
|
-
*
|
|
290
|
-
* @returns {string | null} The upload URL, or null if not found.
|
|
291
|
-
*/
|
|
292
|
-
#a() {
|
|
293
|
-
if (this.elForm) {
|
|
294
|
-
const e = this.elForm.getAttribute("action"), t = this.elForm.getAttribute("data-upload-url");
|
|
295
|
-
if (t)
|
|
296
|
-
return t;
|
|
297
|
-
const r = new URL(e || location.origin);
|
|
298
|
-
return r.pathname = r.pathname + "/file", r.toString();
|
|
299
|
-
}
|
|
300
|
-
return null;
|
|
301
|
-
}
|
|
302
|
-
/**
|
|
303
|
-
* Handles the form's change event, adding files to the pending files list.
|
|
304
|
-
*
|
|
305
|
-
* @param {Event} ev - The change event.
|
|
306
|
-
*/
|
|
307
|
-
#c(e) {
|
|
308
|
-
const t = e.target;
|
|
309
|
-
if (t && t.type === "file") {
|
|
310
|
-
const r = t.files;
|
|
311
|
-
if (r?.length)
|
|
312
|
-
for (const i of r)
|
|
313
|
-
this.addFile(t.name, i);
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
/**
|
|
317
|
-
* Handles the form's submit event, preventing submission until all pending files are uploaded.
|
|
318
|
-
*
|
|
319
|
-
* @param {SubmitEvent} ev - The submit event.
|
|
320
|
-
*/
|
|
321
|
-
#l(e) {
|
|
322
|
-
e.target?.hasAttribute(
|
|
323
|
-
"data-code-challenge-form"
|
|
324
|
-
) || this.pendingFiles.length && (e.preventDefault(), e.stopPropagation(), this.uploadPendingFiles());
|
|
325
|
-
}
|
|
326
|
-
/**
|
|
327
|
-
* Uploads a single file, handling encryption and ALTCHA challenges if necessary.
|
|
328
|
-
*
|
|
329
|
-
* @param {UploadHandle} handle - The upload handle associated with the file.
|
|
330
|
-
* @param {string} [altchaPayload] - The ALTCHA payload, if available.
|
|
331
|
-
* @returns {Promise<unknown>} A promise that resolves when the upload is complete.
|
|
332
|
-
* @throws Will throw an error if the upload fails or if an ALTCHA challenge cannot be solved.
|
|
333
|
-
*/
|
|
334
|
-
async #r(e, t) {
|
|
335
|
-
const r = this.#a();
|
|
336
|
-
if (!r)
|
|
337
|
-
throw new Error("Upload url not specified.");
|
|
338
|
-
const i = {
|
|
339
|
-
"content-type": "application/json"
|
|
340
|
-
};
|
|
341
|
-
t && (i.authorization = "Altcha payload=" + t);
|
|
342
|
-
const s = await fetch(r, {
|
|
343
|
-
body: JSON.stringify({
|
|
344
|
-
name: e.file.name || "file",
|
|
345
|
-
size: e.file.size,
|
|
346
|
-
type: e.file.type || "application/octet-stream"
|
|
347
|
-
}),
|
|
348
|
-
credentials: "include",
|
|
349
|
-
headers: i,
|
|
350
|
-
method: "POST"
|
|
351
|
-
});
|
|
352
|
-
if (s.status === 401)
|
|
353
|
-
return this.#p(s, e);
|
|
354
|
-
if (s.status !== 200)
|
|
355
|
-
throw new Error(`Unexpected server response ${s.status}.`);
|
|
356
|
-
const o = await s.json();
|
|
357
|
-
let a = e.file;
|
|
358
|
-
if (o.encrypted && o.encryptionPublicKey) {
|
|
359
|
-
const c = await b(o.encryptionPublicKey), P = await new Response(
|
|
360
|
-
new ReadableStream({
|
|
361
|
-
async start(y) {
|
|
362
|
-
const A = e.file.stream().getReader();
|
|
363
|
-
for (; ; ) {
|
|
364
|
-
const { done: F, value: K } = await A.read();
|
|
365
|
-
if (F)
|
|
366
|
-
break;
|
|
367
|
-
y.enqueue(K);
|
|
368
|
-
}
|
|
369
|
-
y.close();
|
|
370
|
-
}
|
|
371
|
-
})
|
|
372
|
-
).arrayBuffer();
|
|
373
|
-
a = await M(c, new Uint8Array(P));
|
|
374
|
-
}
|
|
375
|
-
return e.uploadSize = a instanceof Uint8Array ? a.byteLength : e.file.size, await this.#d(o.uploadUrl, e, a, {
|
|
376
|
-
"content-type": e.file.type || "application/octet-stream"
|
|
377
|
-
}), o.finalizeUrl && await this.#u(o.finalizeUrl, e.uploadSize), e.fileId = o.fileId, e.resolve({
|
|
378
|
-
encrypted: o.encrypted,
|
|
379
|
-
fileId: o.fileId
|
|
380
|
-
}), e.promise;
|
|
381
|
-
}
|
|
382
|
-
/**
|
|
383
|
-
* Handles ALTCHA challenges during file upload, solving the challenge and retrying the upload.
|
|
384
|
-
*
|
|
385
|
-
* @param {Response} resp - The response from the server containing the ALTCHA challenge.
|
|
386
|
-
* @param {UploadHandle} handle - The upload handle associated with the file.
|
|
387
|
-
* @returns {Promise<unknown>} A promise that resolves when the challenge is solved and the upload is complete.
|
|
388
|
-
* @throws Will throw an error if the challenge cannot be solved.
|
|
389
|
-
*/
|
|
390
|
-
async #p(e, t) {
|
|
391
|
-
try {
|
|
392
|
-
const i = e.headers.get("www-authenticate")?.match(/challenge=(.*),/)?.[1];
|
|
393
|
-
if (!i)
|
|
394
|
-
throw new Error(
|
|
395
|
-
"Unable to retrieve altcha challenge from www-authenticate header."
|
|
396
|
-
);
|
|
397
|
-
const s = JSON.parse(i);
|
|
398
|
-
if (s && "challenge" in s) {
|
|
399
|
-
const { solution: o } = await this.context.solve(s);
|
|
400
|
-
if (o && "number" in o)
|
|
401
|
-
return this.#r(
|
|
402
|
-
t,
|
|
403
|
-
btoa(
|
|
404
|
-
JSON.stringify({
|
|
405
|
-
...s,
|
|
406
|
-
number: o.number
|
|
407
|
-
})
|
|
408
|
-
)
|
|
409
|
-
);
|
|
410
|
-
throw new Error("Invalid challenge solution.");
|
|
411
|
-
}
|
|
412
|
-
} catch (r) {
|
|
413
|
-
throw this.context.log(r), new Error("Unable to solve altcha challenge for upload.");
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
/**
|
|
417
|
-
* Finalizes the file upload by sending a request to the server.
|
|
418
|
-
*
|
|
419
|
-
* @param {string} finalizeUrl - The URL to finalize the upload.
|
|
420
|
-
* @param {number} uploadSize - The size of the uploaded file.
|
|
421
|
-
*/
|
|
422
|
-
async #u(e, t) {
|
|
423
|
-
const r = await fetch(e, {
|
|
424
|
-
body: JSON.stringify({
|
|
425
|
-
uploadedBytes: t
|
|
426
|
-
}),
|
|
427
|
-
headers: {
|
|
428
|
-
"content-type": "application/json"
|
|
429
|
-
},
|
|
430
|
-
method: "POST"
|
|
431
|
-
});
|
|
432
|
-
if (r.status > 204)
|
|
433
|
-
throw new Error(`Unexpected server response ${r.status}.`);
|
|
434
|
-
return !0;
|
|
435
|
-
}
|
|
436
|
-
/**
|
|
437
|
-
* Uploads the file's contents to the server using the PUT method.
|
|
438
|
-
*
|
|
439
|
-
* @param {string} url - The URL to upload the file to.
|
|
440
|
-
* @param {UploadHandle} handle - The upload handle associated with the file.
|
|
441
|
-
* @param {Uint8Array | File} body - The file's contents.
|
|
442
|
-
* @param {Record<string, string>} headers - Additional headers for the upload request.
|
|
443
|
-
*/
|
|
444
|
-
async #d(e, t, r, i = {}) {
|
|
445
|
-
return e = new URL(
|
|
446
|
-
e,
|
|
447
|
-
this.elForm?.getAttribute("action") || location.origin
|
|
448
|
-
).toString(), new Promise((s, o) => {
|
|
449
|
-
const a = new XMLHttpRequest();
|
|
450
|
-
t.controller.signal.addEventListener("abort", () => {
|
|
451
|
-
a.abort();
|
|
452
|
-
}), a.upload.addEventListener("progress", (c) => {
|
|
453
|
-
t.setProgress(c.loaded), this.#n();
|
|
454
|
-
}), a.addEventListener("error", (c) => {
|
|
455
|
-
o(new Error("Upload failed."));
|
|
456
|
-
}), a.addEventListener("load", () => {
|
|
457
|
-
a.status >= 400 ? o(new Error(`Server responded with ${a.status}`)) : s(void 0);
|
|
458
|
-
}), a.open("PUT", e);
|
|
459
|
-
for (const c in i)
|
|
460
|
-
a.setRequestHeader(c, i[c]);
|
|
461
|
-
a.send(r);
|
|
462
|
-
});
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
class D {
|
|
466
|
-
/**
|
|
467
|
-
* Creates an instance of UploadHandle.
|
|
468
|
-
*
|
|
469
|
-
* @param {string} fieldName - The name of the field associated with the file upload.
|
|
470
|
-
* @param {File} file - The file to be uploaded.
|
|
471
|
-
*/
|
|
472
|
-
constructor(e, t) {
|
|
473
|
-
this.fieldName = e, this.file = t, this.uploadSize = this.file.size, this.promise = new Promise((r, i) => {
|
|
474
|
-
this.resolve = r, this.reject = i;
|
|
475
|
-
});
|
|
476
|
-
}
|
|
477
|
-
controller = new AbortController();
|
|
478
|
-
promise;
|
|
479
|
-
fileId;
|
|
480
|
-
loaded = 0;
|
|
481
|
-
progress = 0;
|
|
482
|
-
uploadSize = 0;
|
|
483
|
-
resolve;
|
|
484
|
-
reject;
|
|
485
|
-
/**
|
|
486
|
-
* Aborts the file upload by invoking the AbortController's abort method.
|
|
487
|
-
*/
|
|
488
|
-
abort() {
|
|
489
|
-
this.controller.abort();
|
|
490
|
-
}
|
|
491
|
-
/**
|
|
492
|
-
* Updates the progress of the file upload.
|
|
493
|
-
*
|
|
494
|
-
* @param {number} loaded - The number of bytes that have been uploaded.
|
|
495
|
-
*/
|
|
496
|
-
setProgress(e) {
|
|
497
|
-
this.loaded = e, this.progress = this.file.size && e ? Math.min(1, e / this.file.size) : 0;
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
U.register(Y);
|
|
501
|
-
export {
|
|
502
|
-
Y as PluginUpload
|
|
503
|
-
};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
(function(p,l){typeof exports=="object"&&typeof module<"u"?l(exports):typeof define=="function"&&define.amd?define(["exports"],l):(p=typeof globalThis<"u"?globalThis:p||self,l(p["[name]"]={}))})(this,function(p){"use strict";const l={generateKey:F,exportKey:K,importKey:v,decrypt:x,encrypt:S};async function F(n=256){return crypto.subtle.generateKey({name:"AES-GCM",length:n},!0,["encrypt","decrypt"])}async function K(n){return new Uint8Array(await crypto.subtle.exportKey("raw",n))}async function v(n){return crypto.subtle.importKey("raw",n,{name:"AES-GCM"},!0,["encrypt","decrypt"])}async function S(n,e,t=16){const r=crypto.getRandomValues(new Uint8Array(t));return{encrypted:new Uint8Array(await crypto.subtle.encrypt({name:"AES-GCM",iv:r},n,e)),iv:r}}async function x(n,e,t){return new Uint8Array(await crypto.subtle.decrypt({name:"AES-GCM",iv:t},n,e))}function L(n,e=!1){return e&&(n=n.replace(/_/g,"/").replace(/-/g,"+")+"=".repeat(3-(3+n.length)%4)),Uint8Array.from(atob(n),t=>t.charCodeAt(0))}function h(n,e=!1){const t=btoa(String.fromCharCode(...n));return e?t.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""):t}function f(n,e=80){let t="";for(;n.length>0;)t+=n.slice(0,e)+`
|
|
2
|
-
`,n=n.slice(e);return t}function m(n){return L(n.split(/\r?\n/).filter(e=>!e.startsWith("-----")).join(""))}const u="RSA-OAEP",d="SHA-256",C=2048,I=new Uint8Array([1,0,1]),T={generateKeyPair:N,encrypt:z,decrypt:j,exportPrivateKey:g,exportPrivateKeyPem:R,exportPublicKey:y,exportPublicKeyPem:_,exportPublicKeyFromPrivateKey:H,importPrivateKey:E,importPrivateKeyPem:k,importPublicKey:w,importPublicKeyPem:b};async function N(){return crypto.subtle.generateKey({name:u,modulusLength:C,publicExponent:I,hash:d},!0,["encrypt","decrypt"])}async function z(n,e){return new Uint8Array(await crypto.subtle.encrypt({name:u},n,e))}async function j(n,e){return new Uint8Array(await crypto.subtle.decrypt({name:u},n,e))}async function y(n){return new Uint8Array(await crypto.subtle.exportKey("spki",n))}async function g(n){return new Uint8Array(await crypto.subtle.exportKey("pkcs8",n))}async function _(n){return`-----BEGIN PUBLIC KEY-----
|
|
3
|
-
`+f(h(await y(n)),64)+"-----END PUBLIC KEY-----"}async function R(n){return`-----BEGIN PRIVATE KEY-----
|
|
4
|
-
`+f(h(await g(n)),64)+"-----END PRIVATE KEY-----"}async function w(n){return crypto.subtle.importKey("spki",n,{name:u,hash:d},!0,["encrypt"])}async function b(n){return w(m(n))}async function E(n){return crypto.subtle.importKey("pkcs8",n,{name:u,hash:d},!0,["decrypt"])}async function k(n){return E(m(n))}async function H(n){const e=await crypto.subtle.exportKey("jwk",n);delete e.d,delete e.dp,delete e.dq,delete e.q,delete e.qi,e.key_ops=["encrypt"];const t=await crypto.subtle.importKey("jwk",e,{name:u,hash:d},!0,["encrypt"]);return y(t)}const O=new Uint8Array([1,0,1]),q=256,M=16;async function $(n,e,t={}){const{aesIVLength:r=M,aesKeyLength:i=q}=t,s=await l.generateKey(i),{encrypted:o,iv:a}=await l.encrypt(s,e,r),c=await T.encrypt(n,await l.exportKey(s));return new Uint8Array([...O,...new Uint8Array([c.length]),...new Uint8Array([a.length]),...c,...a,...o])}class P{constructor(e){this.context=e}static pluginName;static register(e){typeof globalThis.altchaPlugins!="object"&&(globalThis.altchaPlugins=[]),globalThis.altchaPlugins.includes(e)||globalThis.altchaPlugins.push(e)}destroy(){}onErrorChange(e){}onStateChange(e){}}class U extends P{static pluginName="upload";pendingFiles=[];uploadHandles=[];elForm;#e=this.#c.bind(this);#t=this.#l.bind(this);constructor(e){super(e),this.elForm=this.context.el.closest("form"),this.elForm&&(this.elForm.addEventListener("change",this.#e),this.elForm.addEventListener("submit",this.#t,{capture:!0}))}addFile(e,t){this.pendingFiles.find(([r,i])=>r===e&&i===t)||this.pendingFiles.push([e,t])}destroy(){this.elForm&&(this.elForm.removeEventListener("change",this.#e),this.elForm.removeEventListener("submit",this.#t))}async uploadPendingFiles(){const e=async()=>{const t=this.pendingFiles[0];if(t&&await this.#r(this.#s(t)),this.pendingFiles.length)return e()};try{await e()}catch(t){return this.context.log("upload failed",t),this.context.dispatch("uploaderror",{error:t}),!1}this.pendingFiles.length===0&&(this.#i(),this.elForm?.requestSubmit())}#i(){const e=this.uploadHandles.reduce((t,r)=>(t[r.fieldName]||(t[r.fieldName]=[]),r.fileId&&t[r.fieldName].push(r.fileId),t),{});for(const t in e){const r=document.createElement("input");r.name=t,r.type="hidden",r.value=e[t].join(","),this.elForm?.querySelector(`[name="${t}"]`)?.setAttribute("disabled","disabled"),this.elForm?.appendChild(r)}}#s(e){const t=this.pendingFiles.findIndex(([i,s])=>i===e[0]&&s===e[1]);if(t<0)throw new Error("Cannot create upload handle.");const r=new B(e[0],e[1]);return this.uploadHandles.push(r),this.pendingFiles.splice(t,1),this.#o(r),this.#n(),r}#o(e){this.context.dispatch("upload",{handle:e})}#n(){const e=this.pendingFiles.reduce((r,[i,s])=>r+s.size,0)+this.uploadHandles.reduce((r,{uploadSize:i})=>r+i,0),t=this.uploadHandles.reduce((r,{loaded:i})=>r+i,0);this.context.dispatch("uploadprogress",{bytesLoaded:t,bytesTotal:e,pendingFiles:this.pendingFiles,uploadHandles:this.uploadHandles})}#a(){if(this.elForm){const e=this.elForm.getAttribute("action"),t=this.elForm.getAttribute("data-upload-url");if(t)return t;const r=new URL(e||location.origin);return r.pathname=r.pathname+"/file",r.toString()}return null}#c(e){const t=e.target;if(t&&t.type==="file"){const r=t.files;if(r?.length)for(const i of r)this.addFile(t.name,i)}}#l(e){e.target?.hasAttribute("data-code-challenge-form")||this.pendingFiles.length&&(e.preventDefault(),e.stopPropagation(),this.uploadPendingFiles())}async#r(e,t){const r=this.#a();if(!r)throw new Error("Upload url not specified.");const i={"content-type":"application/json"};t&&(i.authorization="Altcha payload="+t);const s=await fetch(r,{body:JSON.stringify({name:e.file.name||"file",size:e.file.size,type:e.file.type||"application/octet-stream"}),credentials:"include",headers:i,method:"POST"});if(s.status===401)return this.#p(s,e);if(s.status!==200)throw new Error(`Unexpected server response ${s.status}.`);const o=await s.json();let a=e.file;if(o.encrypted&&o.encryptionPublicKey){const c=await b(o.encryptionPublicKey),G=await new Response(new ReadableStream({async start(A){const Y=e.file.stream().getReader();for(;;){const{done:D,value:V}=await Y.read();if(D)break;A.enqueue(V)}A.close()}})).arrayBuffer();a=await $(c,new Uint8Array(G))}return e.uploadSize=a instanceof Uint8Array?a.byteLength:e.file.size,await this.#d(o.uploadUrl,e,a,{"content-type":e.file.type||"application/octet-stream"}),o.finalizeUrl&&await this.#u(o.finalizeUrl,e.uploadSize),e.fileId=o.fileId,e.resolve({encrypted:o.encrypted,fileId:o.fileId}),e.promise}async#p(e,t){try{const i=e.headers.get("www-authenticate")?.match(/challenge=(.*),/)?.[1];if(!i)throw new Error("Unable to retrieve altcha challenge from www-authenticate header.");const s=JSON.parse(i);if(s&&"challenge"in s){const{solution:o}=await this.context.solve(s);if(o&&"number"in o)return this.#r(t,btoa(JSON.stringify({...s,number:o.number})));throw new Error("Invalid challenge solution.")}}catch(r){throw this.context.log(r),new Error("Unable to solve altcha challenge for upload.")}}async#u(e,t){const r=await fetch(e,{body:JSON.stringify({uploadedBytes:t}),headers:{"content-type":"application/json"},method:"POST"});if(r.status>204)throw new Error(`Unexpected server response ${r.status}.`);return!0}async#d(e,t,r,i={}){return e=new URL(e,this.elForm?.getAttribute("action")||location.origin).toString(),new Promise((s,o)=>{const a=new XMLHttpRequest;t.controller.signal.addEventListener("abort",()=>{a.abort()}),a.upload.addEventListener("progress",c=>{t.setProgress(c.loaded),this.#n()}),a.addEventListener("error",c=>{o(new Error("Upload failed."))}),a.addEventListener("load",()=>{a.status>=400?o(new Error(`Server responded with ${a.status}`)):s(void 0)}),a.open("PUT",e);for(const c in i)a.setRequestHeader(c,i[c]);a.send(r)})}}class B{constructor(e,t){this.fieldName=e,this.file=t,this.uploadSize=this.file.size,this.promise=new Promise((r,i)=>{this.resolve=r,this.reject=i})}controller=new AbortController;promise;fileId;loaded=0;progress=0;uploadSize=0;resolve;reject;abort(){this.controller.abort()}setProgress(e){this.loaded=e,this.progress=this.file.size&&e?Math.min(1,e/this.file.size):0}}P.register(U),p.PluginUpload=U,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
|