@digitaldefiance/ecies-lib 4.4.11 → 4.4.14
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/package.json +6 -4
- package/src/builders/ecies-builder.d.ts +18 -0
- package/src/builders/ecies-builder.d.ts.map +1 -0
- package/src/builders/ecies-builder.js +30 -0
- package/src/builders/ecies-builder.js.map +1 -0
- package/src/builders/index.d.ts +6 -0
- package/src/builders/index.d.ts.map +1 -0
- package/src/builders/{index.ts → index.js} +1 -1
- package/src/builders/index.js.map +1 -0
- package/src/builders/member-builder.d.ts +51 -0
- package/src/builders/member-builder.d.ts.map +1 -0
- package/src/builders/member-builder.js +97 -0
- package/src/builders/member-builder.js.map +1 -0
- package/src/constants.d.ts +60 -0
- package/src/constants.d.ts.map +1 -0
- package/src/constants.js +446 -0
- package/src/constants.js.map +1 -0
- package/src/core/errors/crypto-error.d.ts +34 -0
- package/src/core/errors/crypto-error.d.ts.map +1 -0
- package/src/core/errors/crypto-error.js +56 -0
- package/src/core/errors/crypto-error.js.map +1 -0
- package/src/core/index.d.ts +6 -0
- package/src/core/index.d.ts.map +1 -0
- package/src/core/{index.ts → index.js} +1 -1
- package/src/core/index.js.map +1 -0
- package/src/core/types/result.d.ts +16 -0
- package/src/core/types/result.d.ts.map +1 -0
- package/src/core/types/result.js +12 -0
- package/src/core/types/result.js.map +1 -0
- package/src/email-string.d.ts +42 -0
- package/src/email-string.d.ts.map +1 -0
- package/src/email-string.js +67 -0
- package/src/email-string.js.map +1 -0
- package/src/enumerations/disposed-error-type.d.ts +12 -0
- package/src/enumerations/disposed-error-type.d.ts.map +1 -0
- package/src/enumerations/disposed-error-type.js +13 -0
- package/src/enumerations/disposed-error-type.js.map +1 -0
- package/src/enumerations/ecies-cipher-suite.d.ts +4 -0
- package/src/enumerations/ecies-cipher-suite.d.ts.map +1 -0
- package/src/enumerations/ecies-cipher-suite.js +6 -0
- package/src/enumerations/ecies-cipher-suite.js.map +1 -0
- package/src/enumerations/ecies-encryption-type.d.ts +11 -0
- package/src/enumerations/ecies-encryption-type.d.ts.map +1 -0
- package/src/enumerations/ecies-encryption-type.js +27 -0
- package/src/enumerations/ecies-encryption-type.js.map +1 -0
- package/src/enumerations/ecies-error-type.d.ts +44 -0
- package/src/enumerations/ecies-error-type.d.ts.map +1 -0
- package/src/enumerations/ecies-error-type.js +45 -0
- package/src/enumerations/ecies-error-type.js.map +1 -0
- package/src/enumerations/ecies-string-key.d.ts +192 -0
- package/src/enumerations/ecies-string-key.d.ts.map +1 -0
- package/src/enumerations/ecies-string-key.js +199 -0
- package/src/enumerations/ecies-string-key.js.map +1 -0
- package/src/enumerations/ecies-version.d.ts +4 -0
- package/src/enumerations/ecies-version.d.ts.map +1 -0
- package/src/enumerations/ecies-version.js +5 -0
- package/src/enumerations/ecies-version.js.map +1 -0
- package/src/enumerations/guid-brand-type.d.ts +27 -0
- package/src/enumerations/guid-brand-type.d.ts.map +1 -0
- package/src/enumerations/guid-brand-type.js +28 -0
- package/src/enumerations/guid-brand-type.js.map +1 -0
- package/src/enumerations/guid-error-type.d.ts +7 -0
- package/src/enumerations/guid-error-type.d.ts.map +1 -0
- package/src/enumerations/guid-error-type.js +8 -0
- package/src/enumerations/guid-error-type.js.map +1 -0
- package/src/enumerations/id-provider-error-type.d.ts +43 -0
- package/src/enumerations/id-provider-error-type.d.ts.map +1 -0
- package/src/enumerations/id-provider-error-type.js +44 -0
- package/src/enumerations/id-provider-error-type.js.map +1 -0
- package/src/enumerations/index.d.ts +18 -0
- package/src/enumerations/index.d.ts.map +1 -0
- package/src/enumerations/{index.ts → index.js} +1 -0
- package/src/enumerations/index.js.map +1 -0
- package/src/enumerations/invalid-email-type.d.ts +6 -0
- package/src/enumerations/invalid-email-type.d.ts.map +1 -0
- package/src/enumerations/invalid-email-type.js +7 -0
- package/src/enumerations/invalid-email-type.js.map +1 -0
- package/src/enumerations/length-encoding-type.d.ts +7 -0
- package/src/enumerations/length-encoding-type.d.ts.map +1 -0
- package/src/enumerations/length-encoding-type.js +8 -0
- package/src/enumerations/length-encoding-type.js.map +1 -0
- package/src/enumerations/length-error-type.d.ts +6 -0
- package/src/enumerations/length-error-type.d.ts.map +1 -0
- package/src/enumerations/length-error-type.js +7 -0
- package/src/enumerations/length-error-type.js.map +1 -0
- package/src/enumerations/member-error-type.d.ts +87 -0
- package/src/enumerations/member-error-type.d.ts.map +1 -0
- package/src/enumerations/member-error-type.js +88 -0
- package/src/enumerations/member-error-type.js.map +1 -0
- package/src/enumerations/{member-type.ts → member-type.d.ts} +6 -7
- package/src/enumerations/member-type.d.ts.map +1 -0
- package/src/enumerations/member-type.js +16 -0
- package/src/enumerations/member-type.js.map +1 -0
- package/src/enumerations/password-login-error-type.d.ts +5 -0
- package/src/enumerations/password-login-error-type.d.ts.map +1 -0
- package/src/enumerations/password-login-error-type.js +6 -0
- package/src/enumerations/password-login-error-type.js.map +1 -0
- package/src/enumerations/pbkdf2-error-type.d.ts +6 -0
- package/src/enumerations/pbkdf2-error-type.d.ts.map +1 -0
- package/src/enumerations/pbkdf2-error-type.js +7 -0
- package/src/enumerations/pbkdf2-error-type.js.map +1 -0
- package/src/enumerations/pbkdf2-profile.d.ts +6 -0
- package/src/enumerations/pbkdf2-profile.d.ts.map +1 -0
- package/src/enumerations/pbkdf2-profile.js +7 -0
- package/src/enumerations/pbkdf2-profile.js.map +1 -0
- package/src/enumerations/secure-storage-error-type.d.ts +6 -0
- package/src/enumerations/secure-storage-error-type.d.ts.map +1 -0
- package/src/enumerations/secure-storage-error-type.js +7 -0
- package/src/enumerations/secure-storage-error-type.js.map +1 -0
- package/src/errors/disposed.d.ts +22 -0
- package/src/errors/disposed.d.ts.map +1 -0
- package/src/errors/disposed.js +28 -0
- package/src/errors/disposed.js.map +1 -0
- package/src/errors/ecies.d.ts +52 -0
- package/src/errors/ecies.d.ts.map +1 -0
- package/src/errors/ecies.js +78 -0
- package/src/errors/ecies.js.map +1 -0
- package/src/errors/guid.d.ts +49 -0
- package/src/errors/guid.d.ts.map +1 -0
- package/src/errors/guid.js +96 -0
- package/src/errors/guid.js.map +1 -0
- package/src/errors/id-provider.d.ts +23 -0
- package/src/errors/id-provider.d.ts.map +1 -0
- package/src/errors/id-provider.js +29 -0
- package/src/errors/id-provider.js.map +1 -0
- package/src/errors/{index.ts → index.d.ts} +1 -0
- package/src/errors/index.d.ts.map +1 -0
- package/src/errors/index.js +10 -0
- package/src/errors/index.js.map +1 -0
- package/src/errors/invalid-email.d.ts +8 -0
- package/src/errors/invalid-email.d.ts.map +1 -0
- package/src/errors/invalid-email.js +15 -0
- package/src/errors/invalid-email.js.map +1 -0
- package/src/errors/length.d.ts +7 -0
- package/src/errors/length.d.ts.map +1 -0
- package/src/errors/length.js +11 -0
- package/src/errors/length.js.map +1 -0
- package/src/errors/member.d.ts +7 -0
- package/src/errors/member.d.ts.map +1 -0
- package/src/errors/member.js +11 -0
- package/src/errors/member.js.map +1 -0
- package/src/errors/pbkdf2.d.ts +7 -0
- package/src/errors/pbkdf2.d.ts.map +1 -0
- package/src/errors/pbkdf2.js +11 -0
- package/src/errors/pbkdf2.js.map +1 -0
- package/src/errors/secure-storage.d.ts +7 -0
- package/src/errors/secure-storage.d.ts.map +1 -0
- package/src/errors/secure-storage.js +12 -0
- package/src/errors/secure-storage.js.map +1 -0
- package/src/errors/simple-ecies.d.ts +6 -0
- package/src/errors/simple-ecies.d.ts.map +1 -0
- package/src/errors/simple-ecies.js +12 -0
- package/src/errors/simple-ecies.js.map +1 -0
- package/src/errors/simple-test-error.d.ts +4 -0
- package/src/errors/simple-test-error.d.ts.map +1 -0
- package/src/errors/simple-test-error.js +7 -0
- package/src/errors/simple-test-error.js.map +1 -0
- package/src/i18n-setup.d.ts +32 -0
- package/src/i18n-setup.d.ts.map +1 -0
- package/src/i18n-setup.js +101 -0
- package/src/i18n-setup.js.map +1 -0
- package/src/index.d.ts +80 -0
- package/src/index.d.ts.map +1 -0
- package/src/{index.ts → index.js} +7 -64
- package/src/index.js.map +1 -0
- package/src/interfaces/checksum-config.d.ts +5 -0
- package/src/interfaces/checksum-config.d.ts.map +1 -0
- package/src/interfaces/checksum-config.js +2 -0
- package/src/interfaces/checksum-config.js.map +1 -0
- package/src/interfaces/checksum-consts.d.ts +11 -0
- package/src/interfaces/checksum-consts.d.ts.map +1 -0
- package/src/interfaces/checksum-consts.js +2 -0
- package/src/interfaces/checksum-consts.js.map +1 -0
- package/src/interfaces/configuration-provenance.d.ts +43 -0
- package/src/interfaces/configuration-provenance.d.ts.map +1 -0
- package/src/interfaces/configuration-provenance.js +3 -0
- package/src/interfaces/configuration-provenance.js.map +1 -0
- package/src/interfaces/constants.d.ts +70 -0
- package/src/interfaces/constants.d.ts.map +1 -0
- package/src/interfaces/constants.js +2 -0
- package/src/interfaces/constants.js.map +1 -0
- package/src/interfaces/ecies-config.d.ts +9 -0
- package/src/interfaces/ecies-config.d.ts.map +1 -0
- package/src/interfaces/ecies-config.js +2 -0
- package/src/interfaces/ecies-config.js.map +1 -0
- package/src/interfaces/ecies-consts.d.ts +61 -0
- package/src/interfaces/ecies-consts.d.ts.map +1 -0
- package/src/interfaces/ecies-consts.js +2 -0
- package/src/interfaces/ecies-consts.js.map +1 -0
- package/src/interfaces/ecies-file-service.d.ts +7 -0
- package/src/interfaces/ecies-file-service.d.ts.map +1 -0
- package/src/interfaces/ecies-file-service.js +2 -0
- package/src/interfaces/ecies-file-service.js.map +1 -0
- package/src/interfaces/encrypted-chunk.d.ts +55 -0
- package/src/interfaces/encrypted-chunk.d.ts.map +1 -0
- package/src/interfaces/encrypted-chunk.js +12 -0
- package/src/interfaces/encrypted-chunk.js.map +1 -0
- package/src/interfaces/encryption-state.d.ts +18 -0
- package/src/interfaces/encryption-state.d.ts.map +1 -0
- package/src/interfaces/encryption-state.js +2 -0
- package/src/interfaces/encryption-state.js.map +1 -0
- package/src/interfaces/frontend-member-operational.d.ts +51 -0
- package/src/interfaces/frontend-member-operational.d.ts.map +1 -0
- package/src/interfaces/frontend-member-operational.js +2 -0
- package/src/interfaces/frontend-member-operational.js.map +1 -0
- package/src/interfaces/guid.d.ts +78 -0
- package/src/interfaces/guid.d.ts.map +1 -0
- package/src/interfaces/guid.js +2 -0
- package/src/interfaces/guid.js.map +1 -0
- package/src/interfaces/id-provider.d.ts +107 -0
- package/src/interfaces/id-provider.d.ts.map +1 -0
- package/src/interfaces/id-provider.js +52 -0
- package/src/interfaces/id-provider.js.map +1 -0
- package/src/interfaces/{index.ts → index.d.ts} +1 -0
- package/src/interfaces/index.d.ts.map +1 -0
- package/src/interfaces/index.js +13 -0
- package/src/interfaces/index.js.map +1 -0
- package/src/interfaces/invariant.d.ts +46 -0
- package/src/interfaces/invariant.d.ts.map +1 -0
- package/src/interfaces/invariant.js +18 -0
- package/src/interfaces/invariant.js.map +1 -0
- package/src/interfaces/library-error.d.ts +23 -0
- package/src/interfaces/library-error.d.ts.map +1 -0
- package/src/interfaces/library-error.js +2 -0
- package/src/interfaces/library-error.js.map +1 -0
- package/src/interfaces/{member-storage.ts → member-storage.d.ts} +10 -11
- package/src/interfaces/member-storage.d.ts.map +1 -0
- package/src/interfaces/member-storage.js +2 -0
- package/src/interfaces/member-storage.js.map +1 -0
- package/src/interfaces/{member-with-mnemonic.ts → member-with-mnemonic.d.ts} +3 -3
- package/src/interfaces/member-with-mnemonic.d.ts.map +1 -0
- package/src/interfaces/member-with-mnemonic.js +2 -0
- package/src/interfaces/member-with-mnemonic.js.map +1 -0
- package/src/interfaces/member.d.ts +55 -0
- package/src/interfaces/member.d.ts.map +1 -0
- package/src/interfaces/member.js +2 -0
- package/src/interfaces/member.js.map +1 -0
- package/src/interfaces/multi-recipient-chunk.d.ts +54 -0
- package/src/interfaces/multi-recipient-chunk.d.ts.map +1 -0
- package/src/interfaces/multi-recipient-chunk.js +11 -0
- package/src/interfaces/multi-recipient-chunk.js.map +1 -0
- package/src/interfaces/pbkdf2-config.d.ts +7 -0
- package/src/interfaces/pbkdf2-config.d.ts.map +1 -0
- package/src/interfaces/pbkdf2-config.js +2 -0
- package/src/interfaces/pbkdf2-config.js.map +1 -0
- package/src/interfaces/pbkdf2-consts.d.ts +9 -0
- package/src/interfaces/pbkdf2-consts.d.ts.map +1 -0
- package/src/interfaces/pbkdf2-consts.js +2 -0
- package/src/interfaces/pbkdf2-consts.js.map +1 -0
- package/src/interfaces/pbkdf2-result.d.ts +6 -0
- package/src/interfaces/pbkdf2-result.d.ts.map +1 -0
- package/src/interfaces/pbkdf2-result.js +2 -0
- package/src/interfaces/pbkdf2-result.js.map +1 -0
- package/src/interfaces/stream-config.d.ts +14 -0
- package/src/interfaces/stream-config.d.ts.map +1 -0
- package/src/interfaces/stream-config.js +8 -0
- package/src/interfaces/stream-config.js.map +1 -0
- package/src/interfaces/stream-header.d.ts +29 -0
- package/src/interfaces/stream-header.d.ts.map +1 -0
- package/src/interfaces/stream-header.js +9 -0
- package/src/interfaces/stream-header.js.map +1 -0
- package/src/interfaces/stream-progress.d.ts +33 -0
- package/src/interfaces/stream-progress.d.ts.map +1 -0
- package/src/interfaces/stream-progress.js +2 -0
- package/src/interfaces/stream-progress.js.map +1 -0
- package/src/lib/configuration-provenance-utils.d.ts +11 -0
- package/src/lib/configuration-provenance-utils.d.ts.map +1 -0
- package/src/lib/configuration-provenance-utils.js +26 -0
- package/src/lib/configuration-provenance-utils.js.map +1 -0
- package/src/lib/crypto-container.d.ts +25 -0
- package/src/lib/crypto-container.d.ts.map +1 -0
- package/src/lib/crypto-container.js +46 -0
- package/src/lib/crypto-container.js.map +1 -0
- package/src/lib/guid.d.ts +344 -0
- package/src/lib/guid.d.ts.map +1 -0
- package/src/lib/guid.js +914 -0
- package/src/lib/guid.js.map +1 -0
- package/src/lib/id-providers/custom-provider.d.ts +46 -0
- package/src/lib/id-providers/custom-provider.d.ts.map +1 -0
- package/src/lib/id-providers/custom-provider.js +85 -0
- package/src/lib/id-providers/custom-provider.js.map +1 -0
- package/src/lib/id-providers/guidv4-provider.d.ts +56 -0
- package/src/lib/id-providers/guidv4-provider.d.ts.map +1 -0
- package/src/lib/id-providers/guidv4-provider.js +122 -0
- package/src/lib/id-providers/guidv4-provider.js.map +1 -0
- package/src/lib/id-providers/{index.ts → index.d.ts} +5 -6
- package/src/lib/id-providers/index.d.ts.map +1 -0
- package/src/lib/id-providers/index.js +29 -0
- package/src/lib/id-providers/index.js.map +1 -0
- package/src/lib/id-providers/objectid-provider.d.ts +43 -0
- package/src/lib/id-providers/objectid-provider.d.ts.map +1 -0
- package/src/lib/id-providers/objectid-provider.js +104 -0
- package/src/lib/id-providers/objectid-provider.js.map +1 -0
- package/src/lib/id-providers/uuid-provider.d.ts +52 -0
- package/src/lib/id-providers/uuid-provider.d.ts.map +1 -0
- package/src/lib/id-providers/uuid-provider.js +110 -0
- package/src/lib/id-providers/uuid-provider.js.map +1 -0
- package/src/lib/index.d.ts +6 -0
- package/src/lib/index.d.ts.map +1 -0
- package/src/lib/{index.ts → index.js} +2 -2
- package/src/lib/index.js.map +1 -0
- package/src/lib/invariant-validator.d.ts +59 -0
- package/src/lib/invariant-validator.d.ts.map +1 -0
- package/src/lib/invariant-validator.js +97 -0
- package/src/lib/invariant-validator.js.map +1 -0
- package/src/lib/invariants/encryption-algorithm-consistency.d.ts +17 -0
- package/src/lib/invariants/encryption-algorithm-consistency.d.ts.map +1 -0
- package/src/lib/invariants/encryption-algorithm-consistency.js +49 -0
- package/src/lib/invariants/encryption-algorithm-consistency.js.map +1 -0
- package/src/lib/invariants/index.d.ts +4 -0
- package/src/lib/invariants/index.d.ts.map +1 -0
- package/src/lib/invariants/{index.ts → index.js} +1 -0
- package/src/lib/invariants/index.js.map +1 -0
- package/src/lib/invariants/pbkdf2-profiles-validity.d.ts +16 -0
- package/src/lib/invariants/pbkdf2-profiles-validity.d.ts.map +1 -0
- package/src/lib/invariants/pbkdf2-profiles-validity.js +58 -0
- package/src/lib/invariants/pbkdf2-profiles-validity.js.map +1 -0
- package/src/lib/invariants/recipient-id-consistency.d.ts +18 -0
- package/src/lib/invariants/recipient-id-consistency.d.ts.map +1 -0
- package/src/lib/invariants/recipient-id-consistency.js +31 -0
- package/src/lib/invariants/recipient-id-consistency.js.map +1 -0
- package/src/lib/multi-recipient-chunk-utils.d.ts +38 -0
- package/src/lib/multi-recipient-chunk-utils.d.ts.map +1 -0
- package/src/lib/multi-recipient-chunk-utils.js +41 -0
- package/src/lib/multi-recipient-chunk-utils.js.map +1 -0
- package/src/member.d.ts +92 -0
- package/src/member.d.ts.map +1 -0
- package/src/member.js +322 -0
- package/src/member.js.map +1 -0
- package/src/{pbkdf2-profiles.ts → pbkdf2-profiles.d.ts} +2 -2
- package/src/pbkdf2-profiles.d.ts.map +1 -0
- package/src/pbkdf2-profiles.js +2 -0
- package/src/pbkdf2-profiles.js.map +1 -0
- package/src/phone-number.d.ts +6 -0
- package/src/phone-number.d.ts.map +1 -0
- package/src/phone-number.js +18 -0
- package/src/phone-number.js.map +1 -0
- package/src/regexes.d.ts +7 -0
- package/src/regexes.d.ts.map +1 -0
- package/src/regexes.js +7 -0
- package/src/regexes.js.map +1 -0
- package/src/secure-buffer.d.ts +61 -0
- package/src/secure-buffer.d.ts.map +1 -0
- package/src/secure-buffer.js +201 -0
- package/src/secure-buffer.js.map +1 -0
- package/src/secure-string.d.ts +46 -0
- package/src/secure-string.d.ts.map +1 -0
- package/src/secure-string.js +206 -0
- package/src/secure-string.js.map +1 -0
- package/src/services/aes-gcm.d.ts +57 -0
- package/src/services/aes-gcm.d.ts.map +1 -0
- package/src/services/aes-gcm.js +142 -0
- package/src/services/aes-gcm.js.map +1 -0
- package/src/services/chunk-processor.d.ts +31 -0
- package/src/services/chunk-processor.d.ts.map +1 -0
- package/src/services/chunk-processor.js +145 -0
- package/src/services/chunk-processor.js.map +1 -0
- package/src/services/ecies/crypto-core.d.ts +72 -0
- package/src/services/ecies/crypto-core.d.ts.map +1 -0
- package/src/services/ecies/crypto-core.js +205 -0
- package/src/services/ecies/crypto-core.js.map +1 -0
- package/src/services/ecies/example.d.ts +25 -0
- package/src/services/ecies/example.d.ts.map +1 -0
- package/src/services/ecies/example.js +121 -0
- package/src/services/ecies/example.js.map +1 -0
- package/src/services/ecies/file.d.ts +18 -0
- package/src/services/ecies/file.d.ts.map +1 -0
- package/src/services/ecies/file.js +106 -0
- package/src/services/ecies/file.js.map +1 -0
- package/src/services/ecies/index.d.ts +38 -0
- package/src/services/ecies/index.d.ts.map +1 -0
- package/src/services/ecies/{index.ts → index.js} +1 -2
- package/src/services/ecies/index.js.map +1 -0
- package/src/services/ecies/integration.d.ts +59 -0
- package/src/services/ecies/integration.d.ts.map +1 -0
- package/src/services/ecies/integration.js +167 -0
- package/src/services/ecies/integration.js.map +1 -0
- package/src/services/ecies/interfaces.d.ts +54 -0
- package/src/services/ecies/interfaces.d.ts.map +1 -0
- package/src/services/ecies/interfaces.js +5 -0
- package/src/services/ecies/interfaces.js.map +1 -0
- package/src/services/ecies/manual-test.d.ts +29 -0
- package/src/services/ecies/manual-test.d.ts.map +1 -0
- package/src/services/ecies/manual-test.js +163 -0
- package/src/services/ecies/manual-test.js.map +1 -0
- package/src/services/ecies/multi-recipient.d.ts +56 -0
- package/src/services/ecies/multi-recipient.d.ts.map +1 -0
- package/src/services/ecies/multi-recipient.js +344 -0
- package/src/services/ecies/multi-recipient.js.map +1 -0
- package/src/services/ecies/service.d.ts +120 -0
- package/src/services/ecies/service.d.ts.map +1 -0
- package/src/services/ecies/service.js +210 -0
- package/src/services/ecies/service.js.map +1 -0
- package/src/services/ecies/signature.d.ts +27 -0
- package/src/services/ecies/signature.d.ts.map +1 -0
- package/src/services/ecies/signature.js +72 -0
- package/src/services/ecies/signature.js.map +1 -0
- package/src/services/ecies/single-recipient.d.ts +46 -0
- package/src/services/ecies/single-recipient.d.ts.map +1 -0
- package/src/services/ecies/single-recipient.js +322 -0
- package/src/services/ecies/single-recipient.js.map +1 -0
- package/src/services/encryption-stream.d.ts +71 -0
- package/src/services/encryption-stream.d.ts.map +1 -0
- package/src/services/encryption-stream.js +295 -0
- package/src/services/encryption-stream.js.map +1 -0
- package/src/services/index.d.ts +11 -0
- package/src/services/index.d.ts.map +1 -0
- package/src/services/{index.ts → index.js} +1 -0
- package/src/services/index.js.map +1 -0
- package/src/services/multi-recipient-processor.d.ts +35 -0
- package/src/services/multi-recipient-processor.d.ts.map +1 -0
- package/src/services/multi-recipient-processor.js +289 -0
- package/src/services/multi-recipient-processor.js.map +1 -0
- package/src/services/password-login.d.ts +47 -0
- package/src/services/password-login.d.ts.map +1 -0
- package/src/services/password-login.js +115 -0
- package/src/services/password-login.js.map +1 -0
- package/src/services/pbkdf2.d.ts +54 -0
- package/src/services/pbkdf2.d.ts.map +1 -0
- package/src/services/pbkdf2.js +108 -0
- package/src/services/pbkdf2.js.map +1 -0
- package/src/services/progress-tracker.d.ts +23 -0
- package/src/services/progress-tracker.d.ts.map +1 -0
- package/src/services/progress-tracker.js +103 -0
- package/src/services/progress-tracker.js.map +1 -0
- package/src/services/resumable-encryption.d.ts +19 -0
- package/src/services/resumable-encryption.d.ts.map +1 -0
- package/src/services/resumable-encryption.js +105 -0
- package/src/services/resumable-encryption.js.map +1 -0
- package/src/services/xor.d.ts +37 -0
- package/src/services/xor.d.ts.map +1 -0
- package/src/services/xor.js +63 -0
- package/src/services/xor.js.map +1 -0
- package/src/test-mocks/index.d.ts +2 -0
- package/src/test-mocks/index.d.ts.map +1 -0
- package/src/test-mocks/index.js +2 -0
- package/src/test-mocks/index.js.map +1 -0
- package/src/test-mocks/mock-frontend-member.d.ts +85 -0
- package/src/test-mocks/mock-frontend-member.d.ts.map +1 -0
- package/src/test-mocks/mock-frontend-member.js +190 -0
- package/src/test-mocks/mock-frontend-member.js.map +1 -0
- package/src/testing.d.ts +2 -0
- package/src/testing.d.ts.map +1 -0
- package/src/{testing.ts → testing.js} +1 -0
- package/src/testing.js.map +1 -0
- package/src/translations/de.d.ts +4 -0
- package/src/translations/de.d.ts.map +1 -0
- package/src/translations/{de.ts → de.js} +56 -112
- package/src/translations/de.js.map +1 -0
- package/src/translations/en-US.d.ts +4 -0
- package/src/translations/en-US.d.ts.map +1 -0
- package/src/translations/{en-US.ts → en-US.js} +58 -116
- package/src/translations/en-US.js.map +1 -0
- package/src/translations/es.d.ts +4 -0
- package/src/translations/es.d.ts.map +1 -0
- package/src/translations/{es.ts → es.js} +67 -134
- package/src/translations/es.js.map +1 -0
- package/src/translations/fr.d.ts +4 -0
- package/src/translations/fr.d.ts.map +1 -0
- package/src/translations/{fr.ts → fr.js} +64 -129
- package/src/translations/fr.js.map +1 -0
- package/src/translations/ja.d.ts +4 -0
- package/src/translations/ja.d.ts.map +1 -0
- package/src/translations/{ja.ts → ja.js} +55 -111
- package/src/translations/ja.js.map +1 -0
- package/src/translations/uk.d.ts +4 -0
- package/src/translations/uk.d.ts.map +1 -0
- package/src/translations/{uk.ts → uk.js} +67 -132
- package/src/translations/uk.js.map +1 -0
- package/src/translations/zh-cn.d.ts +4 -0
- package/src/translations/zh-cn.d.ts.map +1 -0
- package/src/translations/{zh-cn.ts → zh-cn.js} +29 -60
- package/src/translations/zh-cn.js.map +1 -0
- package/src/types/deep-partial.d.ts +4 -0
- package/src/types/deep-partial.d.ts.map +1 -0
- package/src/types/deep-partial.js +2 -0
- package/src/types/deep-partial.js.map +1 -0
- package/src/{types.ts → types.d.ts} +7 -15
- package/src/types.d.ts.map +1 -0
- package/src/types.js +2 -0
- package/src/types.js.map +1 -0
- package/src/utils/encryption-type-utils.d.ts +29 -0
- package/src/utils/encryption-type-utils.d.ts.map +1 -0
- package/src/utils/encryption-type-utils.js +61 -0
- package/src/utils/encryption-type-utils.js.map +1 -0
- package/src/utils.d.ts +68 -0
- package/src/utils.d.ts.map +1 -0
- package/src/utils.js +273 -0
- package/src/utils.js.map +1 -0
- package/LICENSE +0 -21
- package/src/builders/ecies-builder.ts +0 -39
- package/src/builders/member-builder.ts +0 -155
- package/src/constants.ts +0 -609
- package/src/core/errors/crypto-error.ts +0 -78
- package/src/core/types/result.ts +0 -19
- package/src/email-string.ts +0 -82
- package/src/enumerations/disposed-error-type.ts +0 -11
- package/src/enumerations/ecies-cipher-suite.ts +0 -4
- package/src/enumerations/ecies-encryption-type.ts +0 -41
- package/src/enumerations/ecies-error-type.ts +0 -43
- package/src/enumerations/ecies-string-key.ts +0 -205
- package/src/enumerations/ecies-version.ts +0 -3
- package/src/enumerations/guid-brand-type.ts +0 -26
- package/src/enumerations/guid-error-type.ts +0 -6
- package/src/enumerations/id-provider-error-type.ts +0 -50
- package/src/enumerations/invalid-email-type.ts +0 -5
- package/src/enumerations/length-encoding-type.ts +0 -6
- package/src/enumerations/length-error-type.ts +0 -5
- package/src/enumerations/member-error-type.ts +0 -106
- package/src/enumerations/password-login-error-type.ts +0 -4
- package/src/enumerations/pbkdf2-error-type.ts +0 -5
- package/src/enumerations/pbkdf2-profile.ts +0 -5
- package/src/enumerations/secure-storage-error-type.ts +0 -5
- package/src/errors/disposed.ts +0 -36
- package/src/errors/ecies.ts +0 -153
- package/src/errors/guid.ts +0 -130
- package/src/errors/id-provider.ts +0 -40
- package/src/errors/invalid-email.ts +0 -23
- package/src/errors/length.ts +0 -19
- package/src/errors/member.ts +0 -20
- package/src/errors/pbkdf2.ts +0 -20
- package/src/errors/secure-storage.ts +0 -17
- package/src/errors/simple-ecies.ts +0 -21
- package/src/errors/simple-test-error.ts +0 -6
- package/src/i18n-setup.ts +0 -130
- package/src/interfaces/checksum-config.ts +0 -4
- package/src/interfaces/checksum-consts.ts +0 -13
- package/src/interfaces/configuration-provenance.ts +0 -54
- package/src/interfaces/constants.ts +0 -75
- package/src/interfaces/ecies-config.ts +0 -8
- package/src/interfaces/ecies-consts.ts +0 -74
- package/src/interfaces/ecies-file-service.ts +0 -6
- package/src/interfaces/encrypted-chunk.ts +0 -64
- package/src/interfaces/encryption-state.ts +0 -19
- package/src/interfaces/frontend-member-operational.ts +0 -77
- package/src/interfaces/guid.ts +0 -86
- package/src/interfaces/id-provider.ts +0 -152
- package/src/interfaces/invariant.ts +0 -60
- package/src/interfaces/library-error.ts +0 -23
- package/src/interfaces/member.ts +0 -84
- package/src/interfaces/multi-recipient-chunk.ts +0 -61
- package/src/interfaces/pbkdf2-config.ts +0 -6
- package/src/interfaces/pbkdf2-consts.ts +0 -10
- package/src/interfaces/pbkdf2-result.ts +0 -5
- package/src/interfaces/stream-config.ts +0 -17
- package/src/interfaces/stream-header.ts +0 -34
- package/src/interfaces/stream-progress.ts +0 -31
- package/src/lib/configuration-provenance-utils.ts +0 -29
- package/src/lib/crypto-container.ts +0 -64
- package/src/lib/guid.ts +0 -1097
- package/src/lib/id-providers/custom-provider.ts +0 -109
- package/src/lib/id-providers/guidv4-provider.ts +0 -141
- package/src/lib/id-providers/objectid-provider.ts +0 -125
- package/src/lib/id-providers/uuid-provider.ts +0 -133
- package/src/lib/invariant-validator.ts +0 -133
- package/src/lib/invariants/encryption-algorithm-consistency.ts +0 -73
- package/src/lib/invariants/pbkdf2-profiles-validity.ts +0 -78
- package/src/lib/invariants/recipient-id-consistency.ts +0 -46
- package/src/lib/multi-recipient-chunk-utils.ts +0 -63
- package/src/member.ts +0 -495
- package/src/phone-number.ts +0 -18
- package/src/regexes.ts +0 -10
- package/src/secure-buffer.ts +0 -226
- package/src/secure-string.ts +0 -244
- package/src/services/aes-gcm.ts +0 -220
- package/src/services/chunk-processor.ts +0 -188
- package/src/services/ecies/README.md +0 -147
- package/src/services/ecies/crypto-core.ts +0 -292
- package/src/services/ecies/example.ts +0 -185
- package/src/services/ecies/file.ts +0 -167
- package/src/services/ecies/integration.ts +0 -241
- package/src/services/ecies/interfaces.ts +0 -62
- package/src/services/ecies/manual-test.ts +0 -219
- package/src/services/ecies/multi-recipient.ts +0 -545
- package/src/services/ecies/service.ts +0 -370
- package/src/services/ecies/signature.ts +0 -93
- package/src/services/ecies/single-recipient.ts +0 -476
- package/src/services/encryption-stream.ts +0 -435
- package/src/services/multi-recipient-processor.ts +0 -377
- package/src/services/password-login.ts +0 -226
- package/src/services/pbkdf2.ts +0 -169
- package/src/services/progress-tracker.ts +0 -128
- package/src/services/resumable-encryption.ts +0 -135
- package/src/services/xor.ts +0 -65
- package/src/test-mocks/index.ts +0 -1
- package/src/test-mocks/mock-frontend-member.ts +0 -276
- package/src/types/deep-partial.ts +0 -11
- package/src/utils/encryption-type-utils.ts +0 -76
- package/src/utils.ts +0 -329
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { EciesEncryptionTypeEnum, EciesEncryptionTypeEnumTypeMap, EciesEncryptionTypeStringMap, } from '../enumerations/ecies-encryption-type';
|
|
2
|
+
import { ECIESErrorTypeEnum } from '../enumerations/ecies-error-type';
|
|
3
|
+
import { ECIESError } from '../errors/ecies';
|
|
4
|
+
/**
|
|
5
|
+
* Converts an encryption type (string or enum) to its string representation
|
|
6
|
+
* @param type The encryption type to convert
|
|
7
|
+
* @returns The string representation of the encryption type
|
|
8
|
+
* @throws ECIESError if the type is invalid
|
|
9
|
+
*/
|
|
10
|
+
export function encryptionTypeToString(type) {
|
|
11
|
+
// if enum
|
|
12
|
+
let resultType;
|
|
13
|
+
if (typeof type === 'number') {
|
|
14
|
+
resultType = EciesEncryptionTypeEnumTypeMap[type];
|
|
15
|
+
if (resultType === undefined) {
|
|
16
|
+
throw new ECIESError(ECIESErrorTypeEnum.InvalidEncryptionType);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
resultType = type;
|
|
21
|
+
}
|
|
22
|
+
const result = EciesEncryptionTypeStringMap[resultType];
|
|
23
|
+
if (result === undefined) {
|
|
24
|
+
throw new ECIESError(ECIESErrorTypeEnum.InvalidEncryptionType);
|
|
25
|
+
}
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Converts an encryption type enum to its type representation
|
|
30
|
+
* @param type The encryption type enum to convert
|
|
31
|
+
* @returns The type representation of the encryption type
|
|
32
|
+
* @throws ECIESError if the type is invalid
|
|
33
|
+
*/
|
|
34
|
+
export function encryptionTypeEnumToType(type) {
|
|
35
|
+
const result = EciesEncryptionTypeEnumTypeMap[type];
|
|
36
|
+
if (result === undefined) {
|
|
37
|
+
throw new ECIESError(ECIESErrorTypeEnum.InvalidEncryptionType);
|
|
38
|
+
}
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Validates that a value is a valid EciesEncryptionTypeEnum
|
|
43
|
+
* @param type The value to validate
|
|
44
|
+
* @returns true if the value is a valid EciesEncryptionTypeEnum, false otherwise
|
|
45
|
+
*/
|
|
46
|
+
export function validateEciesEncryptionTypeEnum(type) {
|
|
47
|
+
return Object.values(EciesEncryptionTypeEnum).includes(type);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Ensures that a value is a valid EciesEncryptionTypeEnum
|
|
51
|
+
* @param type The value to validate
|
|
52
|
+
* @returns The validated EciesEncryptionTypeEnum
|
|
53
|
+
* @throws ECIESError if the type is invalid
|
|
54
|
+
*/
|
|
55
|
+
export function ensureEciesEncryptionTypeEnum(type) {
|
|
56
|
+
if (!validateEciesEncryptionTypeEnum(type)) {
|
|
57
|
+
throw new ECIESError(ECIESErrorTypeEnum.InvalidEncryptionType);
|
|
58
|
+
}
|
|
59
|
+
return type;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=encryption-type-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encryption-type-utils.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/utils/encryption-type-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,uBAAuB,EACvB,8BAA8B,EAC9B,4BAA4B,GAC7B,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CACpC,IAAmD;IAEnD,UAAU;IACV,IAAI,U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umerations/length-encoding-type';
|
|
2
|
+
/**
|
|
3
|
+
* Encodes the length of the data in the buffer
|
|
4
|
+
* @param buffer The buffer to encode
|
|
5
|
+
* @returns The encoded buffer
|
|
6
|
+
*/
|
|
7
|
+
export declare function lengthEncodeData(buffer: Uint8Array): Uint8Array;
|
|
8
|
+
export declare function decodeLengthEncodedData(buffer: Uint8Array): {
|
|
9
|
+
data: Uint8Array;
|
|
10
|
+
totalLength: number;
|
|
11
|
+
};
|
|
12
|
+
export declare function uint8ArrayToBase64(uint8Array: Uint8Array): string;
|
|
13
|
+
export declare function base64ToUint8Array(base64String: string): Uint8Array;
|
|
14
|
+
export declare function uint8ArrayToHex(uint8Array: Uint8Array): string;
|
|
15
|
+
export declare function hexToUint8Array(hexString: string): Uint8Array;
|
|
16
|
+
/**
|
|
17
|
+
* Utility functions for browser ECIES implementation
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* CRC16-CCITT implementation for data integrity checking
|
|
21
|
+
* Uses CRC16-CCITT-FALSE variant (init 0xFFFF)
|
|
22
|
+
*/
|
|
23
|
+
export declare function crc16(data: Uint8Array): Uint8Array;
|
|
24
|
+
/**
|
|
25
|
+
* Convert string to Uint8Array (UTF-8 encoding)
|
|
26
|
+
*/
|
|
27
|
+
export declare function stringToUint8Array(str: string): Uint8Array;
|
|
28
|
+
/**
|
|
29
|
+
* Convert Uint8Array to string (UTF-8 decoding)
|
|
30
|
+
*/
|
|
31
|
+
export declare function uint8ArrayToString(array: Uint8Array): string;
|
|
32
|
+
/**
|
|
33
|
+
* Secure random bytes generation
|
|
34
|
+
*/
|
|
35
|
+
export declare function randomBytes(length: number): Uint8Array;
|
|
36
|
+
/**
|
|
37
|
+
* Compare two Uint8Arrays for equality
|
|
38
|
+
*/
|
|
39
|
+
export declare function arraysEqual(a: Uint8Array, b: Uint8Array): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Concatenate multiple Uint8Arrays
|
|
42
|
+
*/
|
|
43
|
+
export declare function concatUint8Arrays(...arrays: Uint8Array[]): Uint8Array;
|
|
44
|
+
/**
|
|
45
|
+
* Get the length encoding type for a given length
|
|
46
|
+
* @param length The length to evaluate
|
|
47
|
+
* @returns The corresponding LengthEncodingType
|
|
48
|
+
*/
|
|
49
|
+
export declare function getLengthEncodingTypeForLength<TStringKey extends string, TLanguage extends string>(length: number | BigInt): LengthEncodingType;
|
|
50
|
+
/**
|
|
51
|
+
* Get the length encoding type for a given value
|
|
52
|
+
* @param value The value to evaluate
|
|
53
|
+
* @returns The corresponding LengthEncodingType
|
|
54
|
+
*/
|
|
55
|
+
export declare function getLengthEncodingTypeFromValue<TStringKey extends string, TLanguage extends string>(value: number): LengthEncodingType;
|
|
56
|
+
/**
|
|
57
|
+
* Safely converts BigInt to Number, throwing if value exceeds safe integer range
|
|
58
|
+
* @param value The BigInt value to convert
|
|
59
|
+
* @returns The number value
|
|
60
|
+
*/
|
|
61
|
+
export declare function safeBigIntToNumber(value: bigint): number;
|
|
62
|
+
/**
|
|
63
|
+
* Get the length in bytes for a given LengthEncodingType
|
|
64
|
+
* @param type The LengthEncodingType to evaluate
|
|
65
|
+
* @returns The length in bytes
|
|
66
|
+
*/
|
|
67
|
+
export declare function getLengthForLengthType<TStringKey extends string, TLanguage extends string>(type: LengthEncodingType): number;
|
|
68
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../packages/digitaldefiance-ecies-lib/src/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAKzE;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAyB/D;AAED,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,UAAU,GAAG;IAC3D,IAAI,EAAE,UAAU,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;CACrB,CAgDA;AAED,wBAAg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alC"}
|
package/src/utils.js
ADDED
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import { EciesStringKey } from './enumerations/ecies-string-key';
|
|
2
|
+
import { LengthEncodingType } from './enumerations/length-encoding-type';
|
|
3
|
+
import { LengthErrorType } from './enumerations/length-error-type';
|
|
4
|
+
import { LengthError } from './errors';
|
|
5
|
+
import { EciesComponentId, getEciesI18nEngine } from './i18n-setup';
|
|
6
|
+
/**
|
|
7
|
+
* Encodes the length of the data in the buffer
|
|
8
|
+
* @param buffer The buffer to encode
|
|
9
|
+
* @returns The encoded buffer
|
|
10
|
+
*/
|
|
11
|
+
export function lengthEncodeData(buffer) {
|
|
12
|
+
const lengthType = getLengthEncodingTypeForLength(buffer.length);
|
|
13
|
+
const lengthTypeSize = getLengthForLengthType(lengthType);
|
|
14
|
+
const result = new Uint8Array(1 + lengthTypeSize + buffer.length);
|
|
15
|
+
const view = new DataView(result.buffer);
|
|
16
|
+
view.setUint8(0, lengthType);
|
|
17
|
+
switch (lengthType) {
|
|
18
|
+
case LengthEncodingType.UInt8:
|
|
19
|
+
view.setUint8(1, buffer.length);
|
|
20
|
+
break;
|
|
21
|
+
case LengthEncodingType.UInt16:
|
|
22
|
+
view.setUint16(1, buffer.length, false); // big-endian
|
|
23
|
+
break;
|
|
24
|
+
case LengthEncodingType.UInt32:
|
|
25
|
+
view.setUint32(1, buffer.length, false); // big-endian
|
|
26
|
+
break;
|
|
27
|
+
case LengthEncodingType.UInt64:
|
|
28
|
+
view.setBigUint64(1, BigInt(buffer.length), false); // big-endian
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
result.set(buffer, 1 + lengthTypeSize);
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
export function decodeLengthEncodedData(buffer) {
|
|
35
|
+
if (buffer.length < 1) {
|
|
36
|
+
throw new LengthError(LengthErrorType.LengthIsTooShort);
|
|
37
|
+
}
|
|
38
|
+
const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
39
|
+
const lengthType = getLengthEncodingTypeFromValue(view.getUint8(0));
|
|
40
|
+
const lengthTypeSize = getLengthForLengthType(lengthType);
|
|
41
|
+
if (buffer.length < 1 + lengthTypeSize) {
|
|
42
|
+
throw new LengthError(LengthErrorType.LengthIsTooShort);
|
|
43
|
+
}
|
|
44
|
+
let length;
|
|
45
|
+
switch (lengthType) {
|
|
46
|
+
case LengthEncodingType.UInt8:
|
|
47
|
+
length = view.getUint8(1);
|
|
48
|
+
break;
|
|
49
|
+
case LengthEncodingType.UInt16:
|
|
50
|
+
length = view.getUint16(1, false); // big-endian
|
|
51
|
+
break;
|
|
52
|
+
case LengthEncodingType.UInt32:
|
|
53
|
+
length = view.getUint32(1, false); // big-endian
|
|
54
|
+
break;
|
|
55
|
+
case LengthEncodingType.UInt64:
|
|
56
|
+
length = view.getBigUint64(1, false); // big-endian
|
|
57
|
+
if (length.valueOf() > BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
58
|
+
throw new LengthError(LengthErrorType.LengthIsTooLong);
|
|
59
|
+
}
|
|
60
|
+
break;
|
|
61
|
+
default:
|
|
62
|
+
throw new LengthError(LengthErrorType.LengthIsInvalidType);
|
|
63
|
+
}
|
|
64
|
+
const totalLength = 1 + lengthTypeSize + Number(length);
|
|
65
|
+
if (totalLength > buffer.length) {
|
|
66
|
+
throw new LengthError(LengthErrorType.LengthIsTooShort);
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
data: buffer.subarray(1 + lengthTypeSize, totalLength),
|
|
70
|
+
totalLength,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
export function uint8ArrayToBase64(uint8Array) {
|
|
74
|
+
let binaryString = '';
|
|
75
|
+
for (let i = 0; i < uint8Array.length; i++) {
|
|
76
|
+
binaryString += String.fromCharCode(uint8Array[i]);
|
|
77
|
+
}
|
|
78
|
+
return btoa(binaryString);
|
|
79
|
+
}
|
|
80
|
+
export function base64ToUint8Array(base64String) {
|
|
81
|
+
const binaryString = atob(base64String);
|
|
82
|
+
const len = binaryString.length;
|
|
83
|
+
const bytes = new Uint8Array(len);
|
|
84
|
+
for (let i = 0; i < len; i++) {
|
|
85
|
+
bytes[i] = binaryString.charCodeAt(i);
|
|
86
|
+
}
|
|
87
|
+
return bytes;
|
|
88
|
+
}
|
|
89
|
+
export function uint8ArrayToHex(uint8Array) {
|
|
90
|
+
return Array.from(uint8Array)
|
|
91
|
+
.map((byte) => byte.toString(16).padStart(2, '0'))
|
|
92
|
+
.join('');
|
|
93
|
+
}
|
|
94
|
+
export function hexToUint8Array(hexString) {
|
|
95
|
+
const engine = getEciesI18nEngine();
|
|
96
|
+
if (!hexString || typeof hexString !== 'string') {
|
|
97
|
+
throw new Error(engine.translate(EciesComponentId, EciesStringKey.Error_Utils_InvalidHexString));
|
|
98
|
+
}
|
|
99
|
+
if (hexString.length % 2 !== 0) {
|
|
100
|
+
throw new Error(engine.translate(EciesComponentId, EciesStringKey.Error_Utils_HexStringMustHaveEvenLength));
|
|
101
|
+
}
|
|
102
|
+
if (!/^[0-9a-fA-F]*$/.test(hexString)) {
|
|
103
|
+
throw new Error(engine.translate(EciesComponentId, EciesStringKey.Error_Utils_HexStringContainsInvalidCharacters));
|
|
104
|
+
}
|
|
105
|
+
const len = hexString.length;
|
|
106
|
+
const bytes = new Uint8Array(len / 2);
|
|
107
|
+
for (let i = 0; i < len; i += 2) {
|
|
108
|
+
bytes[i / 2] = parseInt(hexString.substring(i, i + 2), 16);
|
|
109
|
+
}
|
|
110
|
+
return bytes;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Utility functions for browser ECIES implementation
|
|
114
|
+
*/
|
|
115
|
+
/**
|
|
116
|
+
* CRC16-CCITT implementation for data integrity checking
|
|
117
|
+
* Uses CRC16-CCITT-FALSE variant (init 0xFFFF)
|
|
118
|
+
*/
|
|
119
|
+
export function crc16(data) {
|
|
120
|
+
let crc = 0xffff; // Initial value for CRC16-CCITT-FALSE
|
|
121
|
+
const polynomial = 0x1021; // CRC16-CCITT polynomial
|
|
122
|
+
for (let i = 0; i < data.length; i++) {
|
|
123
|
+
crc ^= data[i] << 8;
|
|
124
|
+
for (let j = 0; j < 8; j++) {
|
|
125
|
+
if (crc & 0x8000) {
|
|
126
|
+
crc = (crc << 1) ^ polynomial;
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
crc = crc << 1;
|
|
130
|
+
}
|
|
131
|
+
crc &= 0xffff; // Keep it 16-bit
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
const result = new Uint8Array(2);
|
|
135
|
+
result[0] = (crc >>> 8) & 0xff; // Big-endian
|
|
136
|
+
result[1] = crc & 0xff;
|
|
137
|
+
return result;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Convert string to Uint8Array (UTF-8 encoding)
|
|
141
|
+
*/
|
|
142
|
+
export function stringToUint8Array(str) {
|
|
143
|
+
return new TextEncoder().encode(str);
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Convert Uint8Array to string (UTF-8 decoding)
|
|
147
|
+
*/
|
|
148
|
+
export function uint8ArrayToString(array) {
|
|
149
|
+
return new TextDecoder().decode(array);
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Secure random bytes generation
|
|
153
|
+
*/
|
|
154
|
+
export function randomBytes(length) {
|
|
155
|
+
return crypto.getRandomValues(new Uint8Array(length));
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Compare two Uint8Arrays for equality
|
|
159
|
+
*/
|
|
160
|
+
export function arraysEqual(a, b) {
|
|
161
|
+
if (a.length !== b.length)
|
|
162
|
+
return false;
|
|
163
|
+
let result = 0;
|
|
164
|
+
for (let i = 0; i < a.length; i++) {
|
|
165
|
+
result |= a[i] ^ b[i];
|
|
166
|
+
}
|
|
167
|
+
return result === 0;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Concatenate multiple Uint8Arrays
|
|
171
|
+
*/
|
|
172
|
+
export function concatUint8Arrays(...arrays) {
|
|
173
|
+
const totalLength = arrays.reduce((sum, arr) => sum + arr.length, 0);
|
|
174
|
+
const result = new Uint8Array(totalLength);
|
|
175
|
+
let offset = 0;
|
|
176
|
+
for (const array of arrays) {
|
|
177
|
+
result.set(array, offset);
|
|
178
|
+
offset += array.length;
|
|
179
|
+
}
|
|
180
|
+
return result;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Get the length encoding type for a given length
|
|
184
|
+
* @param length The length to evaluate
|
|
185
|
+
* @returns The corresponding LengthEncodingType
|
|
186
|
+
*/
|
|
187
|
+
export function getLengthEncodingTypeForLength(length) {
|
|
188
|
+
if (typeof length === 'number') {
|
|
189
|
+
if (length < 256) {
|
|
190
|
+
return LengthEncodingType.UInt8;
|
|
191
|
+
}
|
|
192
|
+
else if (length < 65536) {
|
|
193
|
+
return LengthEncodingType.UInt16;
|
|
194
|
+
}
|
|
195
|
+
else if (length < 4294967296) {
|
|
196
|
+
return LengthEncodingType.UInt32;
|
|
197
|
+
}
|
|
198
|
+
else if (length < Number.MAX_SAFE_INTEGER) {
|
|
199
|
+
return LengthEncodingType.UInt64;
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
throw new LengthError(LengthErrorType.LengthIsTooLong);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
else if (typeof length === 'bigint') {
|
|
206
|
+
if (length < 256n) {
|
|
207
|
+
return LengthEncodingType.UInt8;
|
|
208
|
+
}
|
|
209
|
+
else if (length < 65536n) {
|
|
210
|
+
return LengthEncodingType.UInt16;
|
|
211
|
+
}
|
|
212
|
+
else if (length < 4294967296n) {
|
|
213
|
+
return LengthEncodingType.UInt32;
|
|
214
|
+
}
|
|
215
|
+
else if (length < 18446744073709551616n) {
|
|
216
|
+
return LengthEncodingType.UInt64;
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
throw new LengthError(LengthErrorType.LengthIsTooLong);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
throw new LengthError(LengthErrorType.LengthIsInvalidType);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Get the length encoding type for a given value
|
|
228
|
+
* @param value The value to evaluate
|
|
229
|
+
* @returns The corresponding LengthEncodingType
|
|
230
|
+
*/
|
|
231
|
+
export function getLengthEncodingTypeFromValue(value) {
|
|
232
|
+
for (const length of Object.values(LengthEncodingType)) {
|
|
233
|
+
if (length === value) {
|
|
234
|
+
return length;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
throw new LengthError(LengthErrorType.LengthIsInvalidType);
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Safely converts BigInt to Number, throwing if value exceeds safe integer range
|
|
241
|
+
* @param value The BigInt value to convert
|
|
242
|
+
* @returns The number value
|
|
243
|
+
*/
|
|
244
|
+
export function safeBigIntToNumber(value) {
|
|
245
|
+
const engine = getEciesI18nEngine();
|
|
246
|
+
if (value > BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
247
|
+
throw new Error(engine.translate(EciesComponentId, EciesStringKey.Error_Utils_ValueExceedsSafeIntegerRange));
|
|
248
|
+
}
|
|
249
|
+
if (value < BigInt(Number.MIN_SAFE_INTEGER)) {
|
|
250
|
+
throw new Error(engine.translate(EciesComponentId, EciesStringKey.Error_Utils_ValueBelowSafeIntegerRange));
|
|
251
|
+
}
|
|
252
|
+
return Number(value);
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Get the length in bytes for a given LengthEncodingType
|
|
256
|
+
* @param type The LengthEncodingType to evaluate
|
|
257
|
+
* @returns The length in bytes
|
|
258
|
+
*/
|
|
259
|
+
export function getLengthForLengthType(type) {
|
|
260
|
+
switch (type) {
|
|
261
|
+
case LengthEncodingType.UInt8:
|
|
262
|
+
return 1;
|
|
263
|
+
case LengthEncodingType.UInt16:
|
|
264
|
+
return 2;
|
|
265
|
+
case LengthEncodingType.UInt32:
|
|
266
|
+
return 4;
|
|
267
|
+
case LengthEncodingType.UInt64:
|
|
268
|
+
return 8;
|
|
269
|
+
default:
|
|
270
|
+
throw new LengthError(LengthErrorType.LengthIsInvalidType);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
//# sourceMappingURL=utils.js.map
|
package/src/utils.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../packages/digitaldefiance-ecies-lib/src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEpE;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAkB;IACjD,MAAM,UAAU,GAAuB,8BAA8B,CACnE,MAAM,CAAC,MAAM,CACd,CAAC;IACF,MAAM,cAAc,GAAW,sBAAsB,CAAC,UAAU,CAAC,CAAC;IAClE,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,CAAC,GAAG,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;IAClE,MAAM,IAAI,GAAG,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAEzC,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;IAC7B,QAAQ,UAAU,EAAE,CAAC;QACnB,KAAK,kBAAkB,CAAC,KAAK;YAC3B,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;YAChC,MAAM;QACR,KAAK,kBAAkB,CAAC,MAAM;YAC5B,IAAI,CAAC,SAAS,CAAC,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3B,OAAO,CAAC,CAAC;QACX,KAAK,kBAAkB,CAAC,MAAM;YAC5B,OAAO,CAAC,CAAC;QACX,KAAK,kBAAkB,CAAC,MAAM;YAC5B,OAAO,CAAC,CAAC;QACX,KAAK,kBAAkB,CAAC,MAAM;YAC5B,OAAO,CAAC,CAAC;QACX;YACE,MAAM,IAAI,WAAW,CAAC,eAAe,CAAC,mBAAmB,CAAC,CAAC;IAC/D,CAAC;AACH,CAAC"}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Digital Defiance
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Fluent builder for ECIESService
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { PluginI18nEngine } from '@digitaldefiance/i18n-lib';
|
|
6
|
-
import { IECIESConstants } from '../interfaces/ecies-consts';
|
|
7
|
-
import { IECIESConfig } from '../interfaces/ecies-config';
|
|
8
|
-
import { Constants } from '../constants';
|
|
9
|
-
import { ECIESService } from '../services/ecies/service';
|
|
10
|
-
|
|
11
|
-
export class ECIESBuilder {
|
|
12
|
-
private serviceConfig: Partial<IECIESConfig> = {};
|
|
13
|
-
private eciesConsts: Partial<IECIESConstants> = {};
|
|
14
|
-
private i18n?: PluginI18nEngine<string>;
|
|
15
|
-
|
|
16
|
-
static create(): ECIESBuilder {
|
|
17
|
-
return new ECIESBuilder();
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
withServiceConfig(config: Partial<IECIESConfig>): this {
|
|
21
|
-
this.serviceConfig = { ...this.serviceConfig, ...config };
|
|
22
|
-
return this;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
withConstants(constants: Partial<IECIESConstants>): this {
|
|
26
|
-
this.eciesConsts = { ...this.eciesConsts, ...constants };
|
|
27
|
-
return this;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
withI18n(engine: PluginI18nEngine<string>): this {
|
|
31
|
-
this.i18n = engine;
|
|
32
|
-
return this;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
build(): ECIESService {
|
|
36
|
-
const finalConstants = { ...Constants.ECIES, ...this.eciesConsts };
|
|
37
|
-
return new ECIESService(this.serviceConfig, finalConstants);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Fluent builder for Member
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { EmailString } from '../email-string';
|
|
6
|
-
import { EciesStringKey } from '../enumerations';
|
|
7
|
-
import { MemberType } from '../enumerations/member-type';
|
|
8
|
-
import { EciesComponentId, getEciesI18nEngine } from '../i18n-setup';
|
|
9
|
-
import { IMemberWithMnemonic } from '../interfaces/member-with-mnemonic';
|
|
10
|
-
import { Member } from '../member';
|
|
11
|
-
import { SecureString } from '../secure-string';
|
|
12
|
-
import { ECIESService } from '../services/ecies/service';
|
|
13
|
-
|
|
14
|
-
export class MemberBuilder {
|
|
15
|
-
private eciesService?: ECIESService;
|
|
16
|
-
private type?: MemberType;
|
|
17
|
-
private name?: string;
|
|
18
|
-
private email?: EmailString;
|
|
19
|
-
private mnemonic?: SecureString;
|
|
20
|
-
private createdBy?: Uint8Array; // ID of the creator
|
|
21
|
-
|
|
22
|
-
static create(): MemberBuilder {
|
|
23
|
-
return new MemberBuilder();
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
withEciesService(service: ECIESService): this {
|
|
27
|
-
this.eciesService = service;
|
|
28
|
-
return this;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
withType(type: MemberType): this {
|
|
32
|
-
this.type = type;
|
|
33
|
-
return this;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
withName(name: string): this {
|
|
37
|
-
this.name = name;
|
|
38
|
-
return this;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
withEmail(email: string | EmailString): this {
|
|
42
|
-
this.email = typeof email === 'string' ? new EmailString(email) : email;
|
|
43
|
-
return this;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
withMnemonic(mnemonic: SecureString): this {
|
|
47
|
-
this.mnemonic = mnemonic;
|
|
48
|
-
return this;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
withCreatedBy(creatorId: Uint8Array): this {
|
|
52
|
-
this.createdBy = creatorId;
|
|
53
|
-
return this;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
generateMnemonic(): this {
|
|
57
|
-
if (!this.eciesService) {
|
|
58
|
-
const engine = getEciesI18nEngine();
|
|
59
|
-
throw new Error(
|
|
60
|
-
engine.translate(
|
|
61
|
-
EciesComponentId,
|
|
62
|
-
EciesStringKey.Error_Builder_ECIESServiceMustBeSetBeforeGeneratingMnemonic,
|
|
63
|
-
),
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
this.mnemonic = this.eciesService.generateNewMnemonic();
|
|
67
|
-
return this;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
build(): IMemberWithMnemonic {
|
|
71
|
-
const engine = getEciesI18nEngine();
|
|
72
|
-
if (!this.eciesService) {
|
|
73
|
-
throw new Error(
|
|
74
|
-
engine.translate(
|
|
75
|
-
EciesComponentId,
|
|
76
|
-
EciesStringKey.Error_Builder_ECIESServiceIsRequired,
|
|
77
|
-
),
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
if (!this.type || !this.name || !this.email) {
|
|
81
|
-
throw new Error(
|
|
82
|
-
engine.translate(
|
|
83
|
-
EciesComponentId,
|
|
84
|
-
EciesStringKey.Error_Builder_TypeNameAndEmailAreRequired,
|
|
85
|
-
),
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return Member.newMember(
|
|
90
|
-
this.eciesService,
|
|
91
|
-
this.type,
|
|
92
|
-
this.name,
|
|
93
|
-
this.email,
|
|
94
|
-
this.mnemonic,
|
|
95
|
-
this.createdBy,
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Convenience factory method to create a new member with default ECIESService
|
|
101
|
-
* @param type - The member type
|
|
102
|
-
* @param name - The member name
|
|
103
|
-
* @param email - The member email
|
|
104
|
-
* @param forceMnemonic - Optional mnemonic to use instead of generating a new one
|
|
105
|
-
* @param createdBy - Optional creator ID
|
|
106
|
-
* @returns Member with mnemonic
|
|
107
|
-
*/
|
|
108
|
-
static newMember(
|
|
109
|
-
type: MemberType,
|
|
110
|
-
name: string,
|
|
111
|
-
email: EmailString | string,
|
|
112
|
-
forceMnemonic?: SecureString,
|
|
113
|
-
createdBy?: Uint8Array,
|
|
114
|
-
): IMemberWithMnemonic {
|
|
115
|
-
const service = new ECIESService();
|
|
116
|
-
const emailObj = typeof email === 'string' ? new EmailString(email) : email;
|
|
117
|
-
|
|
118
|
-
return Member.newMember(
|
|
119
|
-
service,
|
|
120
|
-
type,
|
|
121
|
-
name,
|
|
122
|
-
emailObj,
|
|
123
|
-
forceMnemonic,
|
|
124
|
-
createdBy,
|
|
125
|
-
);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Convenience factory method to create a member from JSON with default ECIESService
|
|
130
|
-
* @param json - JSON string representation of member
|
|
131
|
-
* @returns Member instance
|
|
132
|
-
*/
|
|
133
|
-
static fromJson(json: string): Member {
|
|
134
|
-
const service = new ECIESService();
|
|
135
|
-
return Member.fromJson(json, service);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Convenience factory method to create a member from mnemonic with default ECIESService
|
|
140
|
-
* @param mnemonic - The mnemonic to use
|
|
141
|
-
* @param name - Optional member name (defaults to 'Test User')
|
|
142
|
-
* @param email - Optional member email (defaults to 'test@example.com')
|
|
143
|
-
* @returns Member instance
|
|
144
|
-
*/
|
|
145
|
-
static fromMnemonic(
|
|
146
|
-
mnemonic: SecureString,
|
|
147
|
-
name = 'Test User',
|
|
148
|
-
email: EmailString | string = 'test@example.com',
|
|
149
|
-
): Member {
|
|
150
|
-
const service = new ECIESService();
|
|
151
|
-
const emailObj = typeof email === 'string' ? new EmailString(email) : email;
|
|
152
|
-
|
|
153
|
-
return Member.fromMnemonic(mnemonic, service, undefined, name, emailObj);
|
|
154
|
-
}
|
|
155
|
-
}
|