@digitaldefiance/node-ecies-lib 4.4.9 → 4.4.12
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 -5
- package/src/builders/ecies-builder.d.ts +11 -0
- package/src/builders/ecies-builder.d.ts.map +1 -0
- package/src/builders/ecies-builder.js +26 -0
- package/src/builders/ecies-builder.js.map +1 -0
- package/src/builders/{index.ts → index.d.ts} +1 -0
- package/src/builders/index.d.ts.map +1 -0
- package/src/builders/index.js +6 -0
- package/src/builders/index.js.map +1 -0
- package/src/builders/member-builder.d.ts +47 -0
- package/src/builders/member-builder.d.ts.map +1 -0
- package/src/builders/member-builder.js +99 -0
- package/src/builders/member-builder.js.map +1 -0
- package/src/constants.d.ts +38 -0
- package/src/constants.d.ts.map +1 -0
- package/src/constants.js +191 -0
- package/src/constants.js.map +1 -0
- package/src/core/errors/crypto-error.d.ts +6 -0
- package/src/core/errors/crypto-error.d.ts.map +1 -0
- package/src/core/errors/crypto-error.js +15 -0
- package/src/core/errors/crypto-error.js.map +1 -0
- package/src/core/{index.ts → index.d.ts} +1 -0
- package/src/core/index.d.ts.map +1 -0
- package/src/core/index.js +6 -0
- package/src/core/index.js.map +1 -0
- package/src/core/types/result.d.ts +8 -0
- package/src/core/types/result.d.ts.map +1 -0
- package/src/core/types/result.js +3 -0
- package/src/core/types/result.js.map +1 -0
- package/src/enumerations/index.d.ts +2 -0
- package/src/enumerations/index.d.ts.map +1 -0
- package/src/enumerations/index.js +5 -0
- package/src/enumerations/index.js.map +1 -0
- package/src/enumerations/pbkdf2-profile.d.ts +9 -0
- package/src/enumerations/pbkdf2-profile.d.ts.map +1 -0
- package/src/enumerations/pbkdf2-profile.js +13 -0
- package/src/enumerations/pbkdf2-profile.js.map +1 -0
- package/src/i18n/ecies-i18n-factory.d.ts +28 -0
- package/src/i18n/ecies-i18n-factory.d.ts.map +1 -0
- package/src/i18n/ecies-i18n-factory.js +89 -0
- package/src/i18n/ecies-i18n-factory.js.map +1 -0
- package/src/i18n/{index.ts → index.d.ts} +1 -3
- package/src/i18n/index.d.ts.map +1 -0
- package/src/i18n/index.js +8 -0
- package/src/i18n/index.js.map +1 -0
- package/src/i18n/node-ecies-i18n-setup.d.ts +5 -0
- package/src/i18n/node-ecies-i18n-setup.d.ts.map +1 -0
- package/src/i18n/node-ecies-i18n-setup.js +46 -0
- package/src/i18n/node-ecies-i18n-setup.js.map +1 -0
- package/src/i18n/node-keys.d.ts +57 -0
- package/src/i18n/node-keys.d.ts.map +1 -0
- package/src/i18n/node-keys.js +67 -0
- package/src/i18n/node-keys.js.map +1 -0
- package/src/i18n/translations/de.d.ts +3 -0
- package/src/i18n/translations/de.d.ts.map +1 -0
- package/src/i18n/translations/de.js +57 -0
- package/src/i18n/translations/de.js.map +1 -0
- package/src/i18n/translations/en-GB.d.ts +3 -0
- package/src/i18n/translations/en-GB.d.ts.map +1 -0
- package/src/i18n/translations/en-GB.js +61 -0
- package/src/i18n/translations/en-GB.js.map +1 -0
- package/src/i18n/translations/en-US.d.ts +6 -0
- package/src/i18n/translations/en-US.d.ts.map +1 -0
- package/src/i18n/translations/en-US.js +65 -0
- package/src/i18n/translations/en-US.js.map +1 -0
- package/src/i18n/translations/es.d.ts +3 -0
- package/src/i18n/translations/es.d.ts.map +1 -0
- package/src/i18n/translations/es.js +57 -0
- package/src/i18n/translations/es.js.map +1 -0
- package/src/i18n/translations/fr.d.ts +3 -0
- package/src/i18n/translations/fr.d.ts.map +1 -0
- package/src/i18n/translations/fr.js +57 -0
- package/src/i18n/translations/fr.js.map +1 -0
- package/src/i18n/translations/{index.ts → index.d.ts} +1 -0
- package/src/i18n/translations/index.d.ts.map +1 -0
- package/src/i18n/translations/index.js +20 -0
- package/src/i18n/translations/index.js.map +1 -0
- package/src/i18n/translations/ja.d.ts +3 -0
- package/src/i18n/translations/ja.d.ts.map +1 -0
- package/src/i18n/translations/ja.js +57 -0
- package/src/i18n/translations/ja.js.map +1 -0
- package/src/i18n/translations/uk.d.ts +3 -0
- package/src/i18n/translations/uk.d.ts.map +1 -0
- package/src/i18n/translations/uk.js +57 -0
- package/src/i18n/translations/uk.js.map +1 -0
- package/src/i18n/translations/zh-cn.d.ts +3 -0
- package/src/i18n/translations/zh-cn.d.ts.map +1 -0
- package/src/i18n/translations/zh-cn.js +57 -0
- package/src/i18n/translations/zh-cn.js.map +1 -0
- package/src/{index.ts → index.d.ts} +1 -5
- package/src/index.d.ts.map +1 -0
- package/src/index.js +31 -0
- package/src/index.js.map +1 -0
- package/src/interfaces/authenticated-cipher.d.ts +12 -0
- package/src/interfaces/authenticated-cipher.d.ts.map +1 -0
- package/src/interfaces/authenticated-cipher.js +3 -0
- package/src/interfaces/authenticated-cipher.js.map +1 -0
- package/src/interfaces/authenticated-decipher.d.ts +11 -0
- package/src/interfaces/authenticated-decipher.d.ts.map +1 -0
- package/src/interfaces/authenticated-decipher.js +3 -0
- package/src/interfaces/authenticated-decipher.js.map +1 -0
- package/src/interfaces/backend-member-operational.d.ts +48 -0
- package/src/interfaces/backend-member-operational.d.ts.map +1 -0
- package/src/interfaces/backend-member-operational.js +3 -0
- package/src/interfaces/backend-member-operational.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 +3 -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 +3 -0
- package/src/interfaces/checksum-consts.js.map +1 -0
- package/src/interfaces/constants.d.ts +52 -0
- package/src/interfaces/constants.d.ts.map +1 -0
- package/src/interfaces/constants.js +3 -0
- package/src/interfaces/constants.js.map +1 -0
- package/src/interfaces/ecies-consts.d.ts +88 -0
- package/src/interfaces/ecies-consts.d.ts.map +1 -0
- package/src/interfaces/ecies-consts.js +3 -0
- package/src/interfaces/ecies-consts.js.map +1 -0
- package/src/interfaces/encrypted-chunk.d.ts +12 -0
- package/src/interfaces/encrypted-chunk.d.ts.map +1 -0
- package/src/interfaces/encrypted-chunk.js +3 -0
- package/src/interfaces/encrypted-chunk.js.map +1 -0
- package/src/interfaces/encryption-consts.d.ts +11 -0
- package/src/interfaces/encryption-consts.d.ts.map +1 -0
- package/src/interfaces/encryption-consts.js +3 -0
- package/src/interfaces/encryption-consts.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 +30 -0
- package/src/interfaces/index.js.map +1 -0
- package/src/interfaces/keypair-buffer-with-un-encrypted-private-key.d.ts +6 -0
- package/src/interfaces/keypair-buffer-with-un-encrypted-private-key.d.ts.map +1 -0
- package/src/interfaces/keypair-buffer-with-un-encrypted-private-key.js +3 -0
- package/src/interfaces/keypair-buffer-with-un-encrypted-private-key.js.map +1 -0
- package/src/interfaces/keyring-consts.d.ts +6 -0
- package/src/interfaces/keyring-consts.d.ts.map +1 -0
- package/src/interfaces/keyring-consts.js +3 -0
- package/src/interfaces/keyring-consts.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 +3 -0
- package/src/interfaces/member-with-mnemonic.js.map +1 -0
- package/src/interfaces/member.d.ts +47 -0
- package/src/interfaces/member.d.ts.map +1 -0
- package/src/interfaces/member.js +3 -0
- package/src/interfaces/member.js.map +1 -0
- package/src/interfaces/{multi-encrypted-message.ts → multi-encrypted-message.d.ts} +5 -5
- package/src/interfaces/multi-encrypted-message.d.ts.map +1 -0
- package/src/interfaces/multi-encrypted-message.js +3 -0
- package/src/interfaces/multi-encrypted-message.js.map +1 -0
- package/src/interfaces/multi-encrypted-parsed-header.d.ts +27 -0
- package/src/interfaces/multi-encrypted-parsed-header.d.ts.map +1 -0
- package/src/interfaces/multi-encrypted-parsed-header.js +3 -0
- package/src/interfaces/multi-encrypted-parsed-header.js.map +1 -0
- package/src/interfaces/multi-recipient-chunk.d.ts +26 -0
- package/src/interfaces/multi-recipient-chunk.d.ts.map +1 -0
- package/src/interfaces/multi-recipient-chunk.js +13 -0
- package/src/interfaces/multi-recipient-chunk.js.map +1 -0
- package/src/interfaces/{pbkdf-profiles.ts → pbkdf-profiles.d.ts} +2 -2
- package/src/interfaces/pbkdf-profiles.d.ts.map +1 -0
- package/src/interfaces/pbkdf-profiles.js +3 -0
- package/src/interfaces/pbkdf-profiles.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 +3 -0
- package/src/interfaces/pbkdf2-result.js.map +1 -0
- package/src/interfaces/signing-key-private-key-info.d.ts +11 -0
- package/src/interfaces/signing-key-private-key-info.d.ts.map +1 -0
- package/src/interfaces/signing-key-private-key-info.js +3 -0
- package/src/interfaces/signing-key-private-key-info.js.map +1 -0
- package/src/interfaces/{simple-keypair-buffer.ts → simple-keypair-buffer.d.ts} +3 -3
- package/src/interfaces/simple-keypair-buffer.d.ts.map +1 -0
- package/src/interfaces/simple-keypair-buffer.js +3 -0
- package/src/interfaces/simple-keypair-buffer.js.map +1 -0
- package/src/interfaces/{simple-keypair.ts → simple-keypair.d.ts} +3 -3
- package/src/interfaces/simple-keypair.d.ts.map +1 -0
- package/src/interfaces/simple-keypair.js +3 -0
- package/src/interfaces/simple-keypair.js.map +1 -0
- package/src/interfaces/simple-public-key-only-buffer.d.ts +4 -0
- package/src/interfaces/simple-public-key-only-buffer.d.ts.map +1 -0
- package/src/interfaces/simple-public-key-only-buffer.js +3 -0
- package/src/interfaces/simple-public-key-only-buffer.js.map +1 -0
- package/src/interfaces/simple-public-key-only.d.ts +4 -0
- package/src/interfaces/simple-public-key-only.d.ts.map +1 -0
- package/src/interfaces/simple-public-key-only.js +3 -0
- package/src/interfaces/simple-public-key-only.js.map +1 -0
- package/src/interfaces/single-encrypted-parsed-header.d.ts +35 -0
- package/src/interfaces/single-encrypted-parsed-header.d.ts.map +1 -0
- package/src/interfaces/single-encrypted-parsed-header.js +3 -0
- package/src/interfaces/single-encrypted-parsed-header.js.map +1 -0
- package/src/interfaces/stream-config.d.ts +6 -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-progress.d.ts +8 -0
- package/src/interfaces/stream-progress.d.ts.map +1 -0
- package/src/interfaces/stream-progress.js +3 -0
- package/src/interfaces/stream-progress.js.map +1 -0
- package/src/interfaces/{wallet-seed.ts → wallet-seed.d.ts} +3 -3
- package/src/interfaces/wallet-seed.d.ts.map +1 -0
- package/src/interfaces/wallet-seed.js +3 -0
- package/src/interfaces/wallet-seed.js.map +1 -0
- package/src/interfaces/wrapped-key-consts.d.ts +7 -0
- package/src/interfaces/wrapped-key-consts.d.ts.map +1 -0
- package/src/interfaces/wrapped-key-consts.js +3 -0
- package/src/interfaces/wrapped-key-consts.js.map +1 -0
- package/src/lib/crypto-container.d.ts +13 -0
- package/src/lib/crypto-container.d.ts.map +1 -0
- package/src/lib/crypto-container.js +29 -0
- package/src/lib/crypto-container.js.map +1 -0
- package/src/lib/{index.ts → index.d.ts} +1 -0
- package/src/lib/index.d.ts.map +1 -0
- package/src/lib/index.js +7 -0
- package/src/lib/index.js.map +1 -0
- package/src/lib/invariant-validator.d.ts +62 -0
- package/src/lib/invariant-validator.d.ts.map +1 -0
- package/src/lib/invariant-validator.js +108 -0
- package/src/lib/invariant-validator.js.map +1 -0
- package/src/lib/invariants/{index.ts → index.d.ts} +2 -2
- package/src/lib/invariants/index.d.ts.map +1 -0
- package/src/lib/invariants/index.js +12 -0
- package/src/lib/invariants/index.js.map +1 -0
- package/src/lib/invariants/recipient-id-consistency.d.ts +22 -0
- package/src/lib/invariants/recipient-id-consistency.d.ts.map +1 -0
- package/src/lib/invariants/recipient-id-consistency.js +62 -0
- package/src/lib/invariants/recipient-id-consistency.js.map +1 -0
- package/src/member.d.ts +81 -0
- package/src/member.d.ts.map +1 -0
- package/src/member.js +285 -0
- package/src/member.js.map +1 -0
- package/src/services/aes-gcm.d.ts +66 -0
- package/src/services/aes-gcm.d.ts.map +1 -0
- package/src/services/aes-gcm.js +158 -0
- package/src/services/aes-gcm.js.map +1 -0
- package/src/services/chunk-processor.d.ts +15 -0
- package/src/services/chunk-processor.d.ts.map +1 -0
- package/src/services/chunk-processor.js +36 -0
- package/src/services/chunk-processor.js.map +1 -0
- package/src/services/ecies/crypto-core.d.ts +104 -0
- package/src/services/ecies/crypto-core.d.ts.map +1 -0
- package/src/services/ecies/crypto-core.js +237 -0
- package/src/services/ecies/crypto-core.js.map +1 -0
- package/src/services/ecies/file.d.ts +30 -0
- package/src/services/ecies/file.d.ts.map +1 -0
- package/src/services/ecies/file.js +112 -0
- package/src/services/ecies/file.js.map +1 -0
- package/src/services/ecies/{index.ts → index.d.ts} +1 -0
- package/src/services/ecies/index.d.ts.map +1 -0
- package/src/services/ecies/index.js +11 -0
- package/src/services/ecies/index.js.map +1 -0
- package/src/services/ecies/multi-recipient.d.ts +84 -0
- package/src/services/ecies/multi-recipient.d.ts.map +1 -0
- package/src/services/ecies/multi-recipient.js +496 -0
- package/src/services/ecies/multi-recipient.js.map +1 -0
- package/src/services/ecies/service.d.ts +69 -0
- package/src/services/ecies/service.d.ts.map +1 -0
- package/src/services/ecies/service.js +144 -0
- package/src/services/ecies/service.js.map +1 -0
- package/src/services/ecies/signature.d.ts +38 -0
- package/src/services/ecies/signature.d.ts.map +1 -0
- package/src/services/ecies/signature.js +69 -0
- package/src/services/ecies/signature.js.map +1 -0
- package/src/services/ecies/single-recipient.d.ts +83 -0
- package/src/services/ecies/single-recipient.d.ts.map +1 -0
- package/src/services/ecies/single-recipient.js +447 -0
- package/src/services/ecies/single-recipient.js.map +1 -0
- package/src/services/ecies/utilities.d.ts +33 -0
- package/src/services/ecies/utilities.d.ts.map +1 -0
- package/src/services/ecies/utilities.js +91 -0
- package/src/services/ecies/utilities.js.map +1 -0
- package/src/services/encryption-stream.d.ts +33 -0
- package/src/services/encryption-stream.d.ts.map +1 -0
- package/src/services/encryption-stream.js +207 -0
- package/src/services/encryption-stream.js.map +1 -0
- package/src/services/{index.ts → index.d.ts} +1 -0
- package/src/services/index.d.ts.map +1 -0
- package/src/services/index.js +11 -0
- package/src/services/index.js.map +1 -0
- package/src/services/multi-recipient-processor.d.ts +72 -0
- package/src/services/multi-recipient-processor.d.ts.map +1 -0
- package/src/services/multi-recipient-processor.js +322 -0
- package/src/services/multi-recipient-processor.js.map +1 -0
- package/src/services/pbkdf2.d.ts +105 -0
- package/src/services/pbkdf2.d.ts.map +1 -0
- package/src/services/pbkdf2.js +189 -0
- package/src/services/pbkdf2.js.map +1 -0
- package/src/services/progress-tracker.d.ts +9 -0
- package/src/services/progress-tracker.d.ts.map +1 -0
- package/src/services/progress-tracker.js +41 -0
- package/src/services/progress-tracker.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 +5 -0
- package/src/test-mocks/index.js.map +1 -0
- package/src/test-mocks/mock-backend-member.d.ts +71 -0
- package/src/test-mocks/mock-backend-member.d.ts.map +1 -0
- package/src/test-mocks/mock-backend-member.js +133 -0
- package/src/test-mocks/mock-backend-member.js.map +1 -0
- package/src/testing.d.ts +2 -0
- package/src/testing.d.ts.map +1 -0
- package/src/testing.js +6 -0
- package/src/testing.js.map +1 -0
- package/src/types/id-guards.d.ts +39 -0
- package/src/types/id-guards.d.ts.map +1 -0
- package/src/types/id-guards.js +91 -0
- package/src/types/id-guards.js.map +1 -0
- package/src/types/index.d.ts +2 -0
- package/src/types/index.d.ts.map +1 -0
- package/src/types/index.js +5 -0
- package/src/types/index.js.map +1 -0
- package/src/{types.ts → types.d.ts} +9 -28
- package/src/types.d.ts.map +1 -0
- package/src/types.js +6 -0
- package/src/types.js.map +1 -0
- package/src/utils.d.ts +11 -0
- package/src/utils.d.ts.map +1 -0
- package/src/utils.js +82 -0
- package/src/utils.js.map +1 -0
- package/LICENSE +0 -21
- package/src/builders/ecies-builder.ts +0 -27
- package/src/builders/member-builder.ts +0 -158
- package/src/constants.ts +0 -251
- package/src/core/errors/crypto-error.ts +0 -10
- package/src/core/types/result.ts +0 -3
- package/src/enumerations/index.ts +0 -2
- package/src/enumerations/pbkdf2-profile.ts +0 -8
- package/src/i18n/ecies-i18n-factory.ts +0 -111
- package/src/i18n/node-ecies-i18n-setup.ts +0 -56
- package/src/i18n/node-keys.ts +0 -69
- package/src/i18n/translations/de.ts +0 -54
- package/src/i18n/translations/en-GB.ts +0 -83
- package/src/i18n/translations/en-US.ts +0 -88
- package/src/i18n/translations/es.ts +0 -54
- package/src/i18n/translations/fr.ts +0 -54
- package/src/i18n/translations/ja.ts +0 -54
- package/src/i18n/translations/uk.ts +0 -54
- package/src/i18n/translations/zh-cn.ts +0 -54
- package/src/interfaces/authenticated-cipher.ts +0 -10
- package/src/interfaces/authenticated-decipher.ts +0 -9
- package/src/interfaces/backend-member-operational.ts +0 -75
- package/src/interfaces/checksum-config.ts +0 -4
- package/src/interfaces/checksum-consts.ts +0 -13
- package/src/interfaces/constants.ts +0 -54
- package/src/interfaces/ecies-consts.ts +0 -99
- package/src/interfaces/encrypted-chunk.ts +0 -12
- package/src/interfaces/encryption-consts.ts +0 -10
- package/src/interfaces/keypair-buffer-with-un-encrypted-private-key.ts +0 -7
- package/src/interfaces/keyring-consts.ts +0 -5
- package/src/interfaces/member.ts +0 -76
- package/src/interfaces/multi-encrypted-parsed-header.ts +0 -28
- package/src/interfaces/multi-recipient-chunk.ts +0 -35
- package/src/interfaces/pbkdf2-result.ts +0 -5
- package/src/interfaces/signing-key-private-key-info.ts +0 -12
- package/src/interfaces/simple-public-key-only-buffer.ts +0 -3
- package/src/interfaces/simple-public-key-only.ts +0 -3
- package/src/interfaces/single-encrypted-parsed-header.ts +0 -35
- package/src/interfaces/stream-config.ts +0 -9
- package/src/interfaces/stream-progress.ts +0 -7
- package/src/interfaces/wrapped-key-consts.ts +0 -6
- package/src/lib/crypto-container.ts +0 -32
- package/src/lib/invariant-validator.ts +0 -124
- package/src/lib/invariants/recipient-id-consistency.ts +0 -77
- package/src/member.ts +0 -511
- package/src/services/aes-gcm.ts +0 -260
- package/src/services/chunk-processor.ts +0 -47
- package/src/services/ecies/crypto-core.ts +0 -319
- package/src/services/ecies/file.ts +0 -171
- package/src/services/ecies/multi-recipient.ts +0 -782
- package/src/services/ecies/service.ts +0 -316
- package/src/services/ecies/signature.ts +0 -91
- package/src/services/ecies/single-recipient.ts +0 -743
- package/src/services/ecies/utilities.ts +0 -128
- package/src/services/encryption-stream.ts +0 -432
- package/src/services/multi-recipient-processor.ts +0 -505
- package/src/services/pbkdf2.ts +0 -304
- package/src/services/progress-tracker.ts +0 -43
- package/src/test-mocks/index.ts +0 -1
- package/src/test-mocks/mock-backend-member.ts +0 -195
- package/src/testing.ts +0 -2
- package/src/types/id-guards.ts +0 -91
- package/src/types/index.ts +0 -1
- package/src/utils.ts +0 -124
package/src/testing.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
// Test utilities entry point - import from '@digitaldefiance/node-ecies-lib/testing'
|
|
5
|
+
tslib_1.__exportStar(require("./test-mocks"), exports);
|
|
6
|
+
//# sourceMappingURL=testing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testing.js","sourceRoot":"","sources":["../../../../packages/digitaldefiance-node-ecies-lib/src/testing.ts"],"names":[],"mappings":";;;AAAA,qFAAqF;AACrF,uDAA6B"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type guards and converters for ID types
|
|
3
|
+
* Used to safely convert between Buffer and Uint8Array without unsafe type casts
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Type guard to check if a value is a Buffer
|
|
7
|
+
* @param value - The value to check
|
|
8
|
+
* @returns True if the value is a Buffer
|
|
9
|
+
*/
|
|
10
|
+
export declare function isBuffer(value: unknown): value is Buffer;
|
|
11
|
+
/**
|
|
12
|
+
* Type guard to check if a value is a Uint8Array
|
|
13
|
+
* @param value - The value to check
|
|
14
|
+
* @returns True if the value is a Uint8Array
|
|
15
|
+
*/
|
|
16
|
+
export declare function isUint8Array(value: unknown): value is Uint8Array;
|
|
17
|
+
/**
|
|
18
|
+
* Safely converts an ID value to Buffer
|
|
19
|
+
* @param id - The ID to convert (Buffer, Uint8Array, or string)
|
|
20
|
+
* @returns The ID as a Buffer
|
|
21
|
+
* @throws Error if the ID type is not supported
|
|
22
|
+
*/
|
|
23
|
+
export declare function toBuffer(id: Buffer | Uint8Array | string): Buffer;
|
|
24
|
+
/**
|
|
25
|
+
* Safely converts an ID value to Uint8Array
|
|
26
|
+
* @param id - The ID to convert (Buffer, Uint8Array, or string)
|
|
27
|
+
* @returns The ID as a Uint8Array
|
|
28
|
+
* @throws Error if the ID type is not supported
|
|
29
|
+
*/
|
|
30
|
+
export declare function toUint8Array(id: Buffer | Uint8Array | string): Uint8Array;
|
|
31
|
+
/**
|
|
32
|
+
* Generic ID converter that can convert between Buffer, Uint8Array, and string
|
|
33
|
+
* @param id - The ID to convert
|
|
34
|
+
* @param toType - The target type ('Buffer', 'Uint8Array', or 'string')
|
|
35
|
+
* @returns The converted ID
|
|
36
|
+
* @throws Error if the conversion is not supported
|
|
37
|
+
*/
|
|
38
|
+
export declare function convertId<T extends 'Buffer' | 'Uint8Array' | 'string'>(id: Buffer | Uint8Array | string, toType: T): T extends 'Buffer' ? Buffer : T extends 'Uint8Array' ? Uint8Array : string;
|
|
39
|
+
//# sourceMappingURL=id-guards.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"id-guards.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-node-ecies-lib/src/types/id-guards.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAExD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU,CAEhE;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,CAWjE;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM,GAAG,UAAU,CAWzE;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,QAAQ,GAAG,YAAY,GAAG,QAAQ,EACpE,EAAE,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM,EAChC,MAAM,EAAE,CAAC,GACR,CAAC,SAAS,QAAQ,GAAG,MAAM,GAAG,CAAC,SAAS,YAAY,GAAG,UAAU,GAAG,MAAM,CAmB5E"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Type guards and converters for ID types
|
|
4
|
+
* Used to safely convert between Buffer and Uint8Array without unsafe type casts
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.isBuffer = isBuffer;
|
|
8
|
+
exports.isUint8Array = isUint8Array;
|
|
9
|
+
exports.toBuffer = toBuffer;
|
|
10
|
+
exports.toUint8Array = toUint8Array;
|
|
11
|
+
exports.convertId = convertId;
|
|
12
|
+
/**
|
|
13
|
+
* Type guard to check if a value is a Buffer
|
|
14
|
+
* @param value - The value to check
|
|
15
|
+
* @returns True if the value is a Buffer
|
|
16
|
+
*/
|
|
17
|
+
function isBuffer(value) {
|
|
18
|
+
return Buffer.isBuffer(value);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Type guard to check if a value is a Uint8Array
|
|
22
|
+
* @param value - The value to check
|
|
23
|
+
* @returns True if the value is a Uint8Array
|
|
24
|
+
*/
|
|
25
|
+
function isUint8Array(value) {
|
|
26
|
+
return value instanceof Uint8Array;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Safely converts an ID value to Buffer
|
|
30
|
+
* @param id - The ID to convert (Buffer, Uint8Array, or string)
|
|
31
|
+
* @returns The ID as a Buffer
|
|
32
|
+
* @throws Error if the ID type is not supported
|
|
33
|
+
*/
|
|
34
|
+
function toBuffer(id) {
|
|
35
|
+
if (isBuffer(id)) {
|
|
36
|
+
return id;
|
|
37
|
+
}
|
|
38
|
+
if (isUint8Array(id)) {
|
|
39
|
+
return Buffer.from(id);
|
|
40
|
+
}
|
|
41
|
+
if (typeof id === 'string') {
|
|
42
|
+
return Buffer.from(id, 'hex');
|
|
43
|
+
}
|
|
44
|
+
throw new Error(`Cannot convert ID of type ${typeof id} to Buffer`);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Safely converts an ID value to Uint8Array
|
|
48
|
+
* @param id - The ID to convert (Buffer, Uint8Array, or string)
|
|
49
|
+
* @returns The ID as a Uint8Array
|
|
50
|
+
* @throws Error if the ID type is not supported
|
|
51
|
+
*/
|
|
52
|
+
function toUint8Array(id) {
|
|
53
|
+
if (isUint8Array(id)) {
|
|
54
|
+
return id;
|
|
55
|
+
}
|
|
56
|
+
if (isBuffer(id)) {
|
|
57
|
+
return new Uint8Array(id);
|
|
58
|
+
}
|
|
59
|
+
if (typeof id === 'string') {
|
|
60
|
+
return new Uint8Array(Buffer.from(id, 'hex'));
|
|
61
|
+
}
|
|
62
|
+
throw new Error(`Cannot convert ID of type ${typeof id} to Uint8Array`);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Generic ID converter that can convert between Buffer, Uint8Array, and string
|
|
66
|
+
* @param id - The ID to convert
|
|
67
|
+
* @param toType - The target type ('Buffer', 'Uint8Array', or 'string')
|
|
68
|
+
* @returns The converted ID
|
|
69
|
+
* @throws Error if the conversion is not supported
|
|
70
|
+
*/
|
|
71
|
+
function convertId(id, toType) {
|
|
72
|
+
if (toType === 'Buffer') {
|
|
73
|
+
return toBuffer(id);
|
|
74
|
+
}
|
|
75
|
+
if (toType === 'Uint8Array') {
|
|
76
|
+
return toUint8Array(id);
|
|
77
|
+
}
|
|
78
|
+
if (toType === 'string') {
|
|
79
|
+
if (typeof id === 'string') {
|
|
80
|
+
return id;
|
|
81
|
+
}
|
|
82
|
+
if (isBuffer(id)) {
|
|
83
|
+
return id.toString('hex');
|
|
84
|
+
}
|
|
85
|
+
if (isUint8Array(id)) {
|
|
86
|
+
return Buffer.from(id).toString('hex');
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
throw new Error(`Cannot convert ID to type ${toType}`);
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=id-guards.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"id-guards.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-node-ecies-lib/src/types/id-guards.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAOH,4BAEC;AAOD,oCAEC;AAQD,4BAWC;AAQD,oCAWC;AASD,8BAsBC;AArFD;;;;GAIG;AACH,SAAgB,QAAQ,CAAC,KAAc;IACrC,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAChC,CAAC;AAED;;;;GAIG;AACH,SAAgB,YAAY,CAAC,KAAc;IACzC,OAAO,KAAK,YAAY,UAAU,CAAC;AACrC,CAAC;AAED;;;;;GAKG;AACH,SAAgB,QAAQ,CAAC,EAAgC;IACvD,IAAI,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;QACjB,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,IAAI,YAAY,CAAC,EAAE,CAAC,EAAE,CAAC;QACrB,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACzB,CAAC;IACD,IAAI,OAAO,EAAE,KAAK,QAAQ,EAAE,CAAC;QAC3B,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;IAChC,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,6BAA6B,OAAO,EAAE,YAAY,CAAC,CAAC;AACtE,CAAC;AAED;;;;;GAKG;AACH,SAAgB,YAAY,CAAC,EAAgC;IAC3D,IAAI,YAAY,CAAC,EAAE,CAAC,EAAE,CAAC;QACrB,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,IAAI,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;QACjB,OAAO,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;IAC5B,CAAC;IACD,IAAI,OAAO,EAAE,KAAK,QAAQ,EAAE,CAAC;QAC3B,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC;IAChD,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,6BAA6B,OAAO,EAAE,gBAAgB,CAAC,CAAC;AAC1E,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,SAAS,CACvB,EAAgC,EAChC,MAAS;IAET,IAAI,MAAM,KAAK,QAAQ,EAAE,CAAC;QACxB,OAAO,QAAQ,CAAC,EAAE,CAAQ,CAAC;IAC7B,CAAC;IACD,IAAI,MAAM,KAAK,YAAY,EAAE,CAAC;QAC5B,OAAO,YAAY,CAAC,EAAE,CAAQ,CAAC;IACjC,CAAC;IACD,IAAI,MAAM,KAAK,QAAQ,EAAE,CAAC;QACxB,IAAI,OAAO,EAAE,KAAK,QAAQ,EAAE,CAAC;YAC3B,OAAO,EAAS,CAAC;QACnB,CAAC;QACD,IAAI,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;YACjB,OAAO,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAQ,CAAC;QACnC,CAAC;QACD,IAAI,YAAY,CAAC,EAAE,CAAC,EAAE,CAAC;YACrB,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAQ,CAAC;QAChD,CAAC;IACH,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,6BAA6B,MAAM,EAAE,CAAC,CAAC;AACzD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-node-ecies-lib/src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-node-ecies-lib/src/types/index.ts"],"names":[],"mappings":";;;AAAA,sDAA4B"}
|
|
@@ -5,41 +5,22 @@ import { ISigningKeyPrivateKeyInfo } from './interfaces/signing-key-private-key-
|
|
|
5
5
|
import { ISimpleKeyPairBuffer } from './interfaces/simple-keypair-buffer';
|
|
6
6
|
import { ISimplePublicKeyOnly } from './interfaces/simple-public-key-only';
|
|
7
7
|
import { ISimplePublicKeyOnlyBuffer } from './interfaces/simple-public-key-only-buffer';
|
|
8
|
-
|
|
9
|
-
export type
|
|
10
|
-
IKeyPairBufferWithUnEncryptedPrivateKey,
|
|
11
|
-
'KeyPairBufferWithUnEncryptedPrivateKey'
|
|
12
|
-
>;
|
|
13
|
-
export type SigningKeyPrivateKeyInfo = Brand<
|
|
14
|
-
ISigningKeyPrivateKeyInfo,
|
|
15
|
-
'SigningKeyPrivateKeyInfo'
|
|
16
|
-
>;
|
|
8
|
+
export type KeyPairBufferWithUnEncryptedPrivateKey = Brand<IKeyPairBufferWithUnEncryptedPrivateKey, 'KeyPairBufferWithUnEncryptedPrivateKey'>;
|
|
9
|
+
export type SigningKeyPrivateKeyInfo = Brand<ISigningKeyPrivateKeyInfo, 'SigningKeyPrivateKeyInfo'>;
|
|
17
10
|
export type SimpleKeyPair = Brand<SimplePublicKeyOnly, 'SimpleKeyPair'>;
|
|
18
|
-
export type SimplePublicKeyOnly = Brand<
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
>;
|
|
22
|
-
export type SimpleKeyPairBuffer = Brand<
|
|
23
|
-
ISimpleKeyPairBuffer,
|
|
24
|
-
'SimpleKeyPairBuffer'
|
|
25
|
-
>;
|
|
26
|
-
export type SimplePublicKeyOnlyBuffer = Brand<
|
|
27
|
-
ISimplePublicKeyOnlyBuffer,
|
|
28
|
-
'SimplePublicKeyOnlyBuffer'
|
|
29
|
-
>;
|
|
11
|
+
export type SimplePublicKeyOnly = Brand<ISimplePublicKeyOnly, 'SimplePublicKeyOnly'>;
|
|
12
|
+
export type SimpleKeyPairBuffer = Brand<ISimpleKeyPairBuffer, 'SimpleKeyPairBuffer'>;
|
|
13
|
+
export type SimplePublicKeyOnlyBuffer = Brand<ISimplePublicKeyOnlyBuffer, 'SimplePublicKeyOnlyBuffer'>;
|
|
30
14
|
export type SignatureString = Brand<HexString, 'SignatureString'>;
|
|
31
15
|
export type SignatureBuffer = Buffer & Brand<Buffer, 'SignatureBuffer'>;
|
|
32
|
-
export type ChecksumBuffer = Buffer &
|
|
33
|
-
Brand<Buffer, 'Sha3Checksum', 'ChecksumBuffer'>;
|
|
16
|
+
export type ChecksumBuffer = Buffer & Brand<Buffer, 'Sha3Checksum', 'ChecksumBuffer'>;
|
|
34
17
|
export type ChecksumString = Brand<HexString, 'Sha3Checksum', 'ChecksumString'>;
|
|
35
|
-
|
|
36
18
|
/**
|
|
37
19
|
* Extended Buffer type for data
|
|
38
20
|
*/
|
|
39
21
|
export type DataBuffer = Buffer & {
|
|
40
|
-
|
|
41
|
-
|
|
22
|
+
toBuffer(): Buffer;
|
|
23
|
+
toHex(): string;
|
|
42
24
|
};
|
|
43
|
-
|
|
44
|
-
// Export ID type guards and converters
|
|
45
25
|
export * from './types/id-guards';
|
|
26
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../packages/digitaldefiance-node-ecies-lib/src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,uCAAuC,EAAE,MAAM,2DAA2D,CAAC;AACpH,OAAO,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AACtF,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,EAAE,0BAA0B,EAAE,MAAM,4CAA4C,CAAC;AAExF,MAAM,MAAM,sCAAsC,GAAG,KAAK,CACxD,uCAAuC,EACvC,wCAAwC,CACzC,CAAC;AACF,MAAM,MAAM,wBAAwB,GAAG,KAAK,CAC1C,yBAAyB,EACzB,0BAA0B,CAC3B,CAAC;AACF,MAAM,MAAM,aAAa,GAAG,KAAK,CAAC,mBAAmB,EAAE,eAAe,CAAC,CAAC;AACxE,MAAM,MAAM,mBAAmB,GAAG,KAAK,CACrC,oBAAoB,EACpB,qBAAqB,CACtB,CAAC;AACF,MAAM,MAAM,mBAAmB,GAAG,KAAK,CACrC,oBAAoB,EACpB,qBAAqB,CACtB,CAAC;AACF,MAAM,MAAM,yBAAyB,GAAG,KAAK,CAC3C,0BAA0B,EAC1B,2BAA2B,CAC5B,CAAC;AACF,MAAM,MAAM,eAAe,GAAG,KAAK,CAAC,SAAS,EAAE,iBAAiB,CAAC,CAAC;AAClE,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;AACxE,MAAM,MAAM,cAAc,GAAG,MAAM,GACjC,KAAK,CAAC,MAAM,EAAE,cAAc,EAAE,gBAAgB,CAAC,CAAC;AAClD,MAAM,MAAM,cAAc,GAAG,KAAK,CAAC,SAAS,EAAE,cAAc,EAAE,gBAAgB,CAAC,CAAC;AAEhF;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG;IAChC,QAAQ,IAAI,MAAM,CAAC;IACnB,KAAK,IAAI,MAAM,CAAC;CACjB,CAAC;AAGF,cAAc,mBAAmB,CAAC"}
|
package/src/types.js
ADDED
package/src/types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../packages/digitaldefiance-node-ecies-lib/src/types.ts"],"names":[],"mappings":";;;AA2CA,uCAAuC;AACvC,4DAAkC"}
|
package/src/utils.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Encodes the length of the data in the buffer
|
|
3
|
+
* @param buffer The buffer to encode
|
|
4
|
+
* @returns The encoded buffer
|
|
5
|
+
*/
|
|
6
|
+
export declare function lengthEncodeData(buffer: Buffer): Buffer;
|
|
7
|
+
export declare function decodeLengthEncodedData(buffer: Buffer): {
|
|
8
|
+
data: Buffer;
|
|
9
|
+
totalLength: number;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../packages/digitaldefiance-node-ecies-lib/src/utils.ts"],"names":[],"mappings":"AAuBA;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAuBvD;AAED,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG;IACvD,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB,CAmEA"}
|
package/src/utils.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.lengthEncodeData = lengthEncodeData;
|
|
4
|
+
exports.decodeLengthEncodedData = decodeLengthEncodedData;
|
|
5
|
+
const ecies_lib_1 = require("@digitaldefiance/ecies-lib");
|
|
6
|
+
const ecies_i18n_factory_1 = require("./i18n/ecies-i18n-factory");
|
|
7
|
+
/**
|
|
8
|
+
* Custom error class for length encoding errors
|
|
9
|
+
*/
|
|
10
|
+
class LengthEncodingError extends Error {
|
|
11
|
+
constructor(message) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.name = 'LengthEncodingError';
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Encodes the length of the data in the buffer
|
|
18
|
+
* @param buffer The buffer to encode
|
|
19
|
+
* @returns The encoded buffer
|
|
20
|
+
*/
|
|
21
|
+
function lengthEncodeData(buffer) {
|
|
22
|
+
const lengthType = (0, ecies_lib_1.getLengthEncodingTypeForLength)(buffer.length);
|
|
23
|
+
const lengthTypeSize = (0, ecies_lib_1.getLengthForLengthType)(lengthType);
|
|
24
|
+
const result = Buffer.alloc(1 + lengthTypeSize + buffer.length);
|
|
25
|
+
result.writeUInt8(lengthType, 0);
|
|
26
|
+
switch (lengthType) {
|
|
27
|
+
case ecies_lib_1.LengthEncodingType.UInt8:
|
|
28
|
+
result.writeUInt8(buffer.length, 1);
|
|
29
|
+
break;
|
|
30
|
+
case ecies_lib_1.LengthEncodingType.UInt16:
|
|
31
|
+
result.writeUInt16BE(buffer.length, 1);
|
|
32
|
+
break;
|
|
33
|
+
case ecies_lib_1.LengthEncodingType.UInt32:
|
|
34
|
+
result.writeUInt32BE(buffer.length, 1);
|
|
35
|
+
break;
|
|
36
|
+
case ecies_lib_1.LengthEncodingType.UInt64:
|
|
37
|
+
result.writeBigUInt64BE(BigInt(buffer.length), 1);
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
buffer.copy(result, 1 + lengthTypeSize);
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
43
|
+
function decodeLengthEncodedData(buffer) {
|
|
44
|
+
const pluginEngine = (0, ecies_i18n_factory_1.getEciesPluginI18nEngine)();
|
|
45
|
+
if (buffer.length < 1) {
|
|
46
|
+
throw new RangeError(pluginEngine.translate(ecies_i18n_factory_1.NodeEciesComponentId, ecies_i18n_factory_1.NodeEciesStringKey.Error_BufferIsTooShort));
|
|
47
|
+
}
|
|
48
|
+
const lengthType = (0, ecies_lib_1.getLengthEncodingTypeFromValue)(buffer.readUint8(0));
|
|
49
|
+
const lengthTypeSize = (0, ecies_lib_1.getLengthForLengthType)(lengthType);
|
|
50
|
+
if (buffer.length < 1 + lengthTypeSize) {
|
|
51
|
+
throw new RangeError(pluginEngine.translate(ecies_i18n_factory_1.NodeEciesComponentId, ecies_i18n_factory_1.NodeEciesStringKey.Error_BufferIsTooShortToReadFullLengthValue));
|
|
52
|
+
}
|
|
53
|
+
let length;
|
|
54
|
+
switch (lengthType) {
|
|
55
|
+
case ecies_lib_1.LengthEncodingType.UInt8:
|
|
56
|
+
length = buffer.readUint8(1);
|
|
57
|
+
break;
|
|
58
|
+
case ecies_lib_1.LengthEncodingType.UInt16:
|
|
59
|
+
length = buffer.readUint16BE(1);
|
|
60
|
+
break;
|
|
61
|
+
case ecies_lib_1.LengthEncodingType.UInt32:
|
|
62
|
+
length = buffer.readUint32BE(1);
|
|
63
|
+
break;
|
|
64
|
+
case ecies_lib_1.LengthEncodingType.UInt64:
|
|
65
|
+
length = buffer.readBigUInt64BE(1);
|
|
66
|
+
if (Number(length) > Number.MAX_SAFE_INTEGER) {
|
|
67
|
+
throw new RangeError(pluginEngine.translate(ecies_i18n_factory_1.NodeEciesComponentId, ecies_i18n_factory_1.NodeEciesStringKey.Error_LengthExceedsMaximumSafeInteger));
|
|
68
|
+
}
|
|
69
|
+
break;
|
|
70
|
+
default:
|
|
71
|
+
throw new LengthEncodingError((0, ecies_i18n_factory_1.getNodeEciesTranslation)(ecies_i18n_factory_1.NodeEciesStringKey.Error_LengthError_LengthIsInvalidType));
|
|
72
|
+
}
|
|
73
|
+
const totalLength = 1 + lengthTypeSize + Number(length);
|
|
74
|
+
if (totalLength > buffer.length) {
|
|
75
|
+
throw new RangeError(pluginEngine.translate(ecies_i18n_factory_1.NodeEciesComponentId, ecies_i18n_factory_1.NodeEciesStringKey.Error_BufferIsTooShortForDeclaredDataLength));
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
data: buffer.subarray(1 + lengthTypeSize, totalLength),
|
|
79
|
+
totalLength,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=utils.js.map
|
package/src/utils.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../packages/digitaldefiance-node-ecies-lib/src/utils.ts"],"names":[],"mappings":"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"}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Digital Defiance, Jessica Mulein, All Rights Reserved.
|
|
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,27 +0,0 @@
|
|
|
1
|
-
import { ECIESService } from '../services/ecies';
|
|
2
|
-
import { IECIESConstants, IECIESConfig } from '@digitaldefiance/ecies-lib';
|
|
3
|
-
import { Constants } from '../constants';
|
|
4
|
-
|
|
5
|
-
export class ECIESBuilder {
|
|
6
|
-
private serviceConfig: Partial<IECIESConfig> = {};
|
|
7
|
-
private eciesConsts: Partial<IECIESConstants> = {};
|
|
8
|
-
|
|
9
|
-
static create(): ECIESBuilder {
|
|
10
|
-
return new ECIESBuilder();
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
withServiceConfig(config: Partial<IECIESConfig>): this {
|
|
14
|
-
this.serviceConfig = { ...this.serviceConfig, ...config };
|
|
15
|
-
return this;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
withConstants(constants: Partial<IECIESConstants>): this {
|
|
19
|
-
this.eciesConsts = { ...this.eciesConsts, ...constants };
|
|
20
|
-
return this;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
build(): ECIESService {
|
|
24
|
-
const finalConstants = { ...Constants.ECIES, ...this.eciesConsts };
|
|
25
|
-
return new ECIESService(this.serviceConfig, finalConstants);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
EmailString,
|
|
3
|
-
MemberType,
|
|
4
|
-
SecureString,
|
|
5
|
-
} from '@digitaldefiance/ecies-lib';
|
|
6
|
-
import {
|
|
7
|
-
NodeEciesComponentId,
|
|
8
|
-
NodeEciesStringKey,
|
|
9
|
-
} from '../i18n/ecies-i18n-factory';
|
|
10
|
-
import { getNodeEciesI18nEngine } from '../i18n/node-ecies-i18n-setup';
|
|
11
|
-
import { IBackendMemberWithMnemonic } from '../interfaces/member-with-mnemonic';
|
|
12
|
-
import { Member } from '../member';
|
|
13
|
-
import { ECIESService } from '../services/ecies';
|
|
14
|
-
|
|
15
|
-
export class MemberBuilder {
|
|
16
|
-
private eciesService?: ECIESService;
|
|
17
|
-
private type?: MemberType;
|
|
18
|
-
private name?: string;
|
|
19
|
-
private email?: EmailString;
|
|
20
|
-
private mnemonic?: SecureString;
|
|
21
|
-
private createdBy?: Buffer;
|
|
22
|
-
|
|
23
|
-
static create(): MemberBuilder {
|
|
24
|
-
return new MemberBuilder();
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
withEciesService(service: ECIESService): this {
|
|
28
|
-
this.eciesService = service;
|
|
29
|
-
return this;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
withType(type: MemberType): this {
|
|
33
|
-
this.type = type;
|
|
34
|
-
return this;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
withName(name: string): this {
|
|
38
|
-
this.name = name;
|
|
39
|
-
return this;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
withEmail(email: string | EmailString): this {
|
|
43
|
-
this.email = typeof email === 'string' ? new EmailString(email) : email;
|
|
44
|
-
return this;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
withMnemonic(mnemonic: SecureString): this {
|
|
48
|
-
this.mnemonic = mnemonic;
|
|
49
|
-
return this;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
withCreatedBy(creatorId: Buffer): this {
|
|
53
|
-
this.createdBy = creatorId;
|
|
54
|
-
return this;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
generateMnemonic(): this {
|
|
58
|
-
if (!this.eciesService) {
|
|
59
|
-
const engine = getNodeEciesI18nEngine();
|
|
60
|
-
throw new Error(
|
|
61
|
-
engine.translate(
|
|
62
|
-
NodeEciesComponentId,
|
|
63
|
-
NodeEciesStringKey.Error_Builder_ECIESServiceMustBeSetBeforeGeneratingMnemonic
|
|
64
|
-
)
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
this.mnemonic = this.eciesService.generateNewMnemonic();
|
|
68
|
-
return this;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
build(): IBackendMemberWithMnemonic {
|
|
72
|
-
const engine = getNodeEciesI18nEngine();
|
|
73
|
-
if (!this.eciesService) {
|
|
74
|
-
throw new Error(
|
|
75
|
-
engine.translate(
|
|
76
|
-
NodeEciesComponentId,
|
|
77
|
-
NodeEciesStringKey.Error_Builder_ECIESServiceIsRequired
|
|
78
|
-
)
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
if (!this.type || !this.name || !this.email) {
|
|
82
|
-
throw new Error(
|
|
83
|
-
engine.translate(
|
|
84
|
-
NodeEciesComponentId,
|
|
85
|
-
NodeEciesStringKey.Error_Builder_TypeNameAndEmailAreRequired
|
|
86
|
-
)
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return Member.newMember(
|
|
91
|
-
this.eciesService,
|
|
92
|
-
this.type,
|
|
93
|
-
this.name,
|
|
94
|
-
this.email,
|
|
95
|
-
this.mnemonic,
|
|
96
|
-
this.createdBy
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Convenience factory method to create a new member with default ECIESService
|
|
102
|
-
* @param type - The member type
|
|
103
|
-
* @param name - The member name
|
|
104
|
-
* @param email - The member email
|
|
105
|
-
* @param forceMnemonic - Optional mnemonic to use instead of generating a new one
|
|
106
|
-
* @param createdBy - Optional creator ID
|
|
107
|
-
* @returns Member with mnemonic
|
|
108
|
-
*/
|
|
109
|
-
static newMember(
|
|
110
|
-
type: MemberType,
|
|
111
|
-
name: string,
|
|
112
|
-
email: EmailString | string,
|
|
113
|
-
forceMnemonic?: SecureString,
|
|
114
|
-
createdBy?: Buffer
|
|
115
|
-
): IBackendMemberWithMnemonic {
|
|
116
|
-
const service = new ECIESService();
|
|
117
|
-
const emailObj = typeof email === 'string' ? new EmailString(email) : email;
|
|
118
|
-
|
|
119
|
-
return Member.newMember(
|
|
120
|
-
service,
|
|
121
|
-
type,
|
|
122
|
-
name,
|
|
123
|
-
emailObj,
|
|
124
|
-
forceMnemonic,
|
|
125
|
-
createdBy
|
|
126
|
-
);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Convenience factory method to create a member from JSON with default ECIESService
|
|
131
|
-
* @param json - JSON string representation of member
|
|
132
|
-
* @returns Member instance
|
|
133
|
-
*/
|
|
134
|
-
static fromJson(json: string): Member {
|
|
135
|
-
const service = new ECIESService();
|
|
136
|
-
return Member.fromJson(json, service);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Convenience factory method to create a member from mnemonic with default ECIESService
|
|
141
|
-
* @param mnemonic - The mnemonic to use
|
|
142
|
-
* @param memberType - Optional member type (defaults to MemberType.User)
|
|
143
|
-
* @param name - Optional member name (defaults to 'Test User')
|
|
144
|
-
* @param email - Optional member email (defaults to 'test@example.com')
|
|
145
|
-
* @returns Member instance
|
|
146
|
-
*/
|
|
147
|
-
static fromMnemonic(
|
|
148
|
-
mnemonic: SecureString,
|
|
149
|
-
memberType = MemberType.User,
|
|
150
|
-
name = 'Test User',
|
|
151
|
-
email: EmailString | string = 'test@example.com'
|
|
152
|
-
): Member {
|
|
153
|
-
const service = new ECIESService();
|
|
154
|
-
const emailObj = typeof email === 'string' ? new EmailString(email) : email;
|
|
155
|
-
|
|
156
|
-
return Member.fromMnemonic(mnemonic, service, memberType, name, emailObj);
|
|
157
|
-
}
|
|
158
|
-
}
|