@mavogel/awscdk-rootmail 0.1.24 → 0.1.26
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/.jsii +9 -9
- package/lib/rootmail.js +1 -1
- package/lib/ses-receive.js +1 -1
- package/lib/ses-receive.ops-santa-handler.js +2 -2
- package/node_modules/@aws-sdk/checksums/package.json +3 -3
- package/node_modules/@aws-sdk/client-cloudwatch-logs/dist-cjs/index.js +9 -7
- package/node_modules/@aws-sdk/client-cloudwatch-logs/dist-es/schemas/schemas_0.js +11 -6
- package/node_modules/@aws-sdk/client-cloudwatch-logs/dist-types/commands/DescribeDeliveriesCommand.d.ts +3 -0
- package/node_modules/@aws-sdk/client-cloudwatch-logs/dist-types/commands/DescribeDeliveryDestinationsCommand.d.ts +3 -0
- package/node_modules/@aws-sdk/client-cloudwatch-logs/dist-types/commands/DescribeDeliverySourcesCommand.d.ts +3 -0
- package/node_modules/@aws-sdk/client-cloudwatch-logs/dist-types/commands/PutResourcePolicyCommand.d.ts +1 -1
- package/node_modules/@aws-sdk/client-cloudwatch-logs/dist-types/models/models_0.d.ts +27 -1
- package/node_modules/@aws-sdk/client-cloudwatch-logs/dist-types/ts3.4/models/models_0.d.ts +3 -0
- package/node_modules/@aws-sdk/client-cloudwatch-logs/package.json +4 -4
- package/node_modules/@aws-sdk/client-route-53/dist-cjs/index.js +1 -1
- package/node_modules/@aws-sdk/client-route-53/package.json +4 -4
- package/node_modules/@aws-sdk/client-s3/dist-cjs/index.js +1 -1
- package/node_modules/@aws-sdk/client-s3/package.json +7 -7
- package/node_modules/@aws-sdk/client-ses/dist-cjs/index.js +1 -1
- package/node_modules/@aws-sdk/client-ses/package.json +4 -4
- package/node_modules/@aws-sdk/client-ssm/dist-cjs/index.js +1 -1
- package/node_modules/@aws-sdk/client-ssm/package.json +4 -4
- package/node_modules/@aws-sdk/core/dist-cjs/submodules/protocols/index.js +94 -1589
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/index.js +1 -7
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/AwsJsonRpcProtocol.js +1 -3
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/AwsRestJsonProtocol.js +1 -3
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/index.d.ts +2 -8
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/AwsJson1_0Protocol.d.ts +1 -2
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/AwsJson1_1Protocol.d.ts +1 -2
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/AwsJsonRpcProtocol.d.ts +2 -3
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/AwsRestJsonProtocol.d.ts +2 -3
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/index.d.ts +10 -10
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/AwsJson1_0Protocol.d.ts +1 -2
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/AwsJson1_1Protocol.d.ts +1 -2
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/AwsJsonRpcProtocol.d.ts +2 -3
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/AwsRestJsonProtocol.d.ts +2 -3
- package/node_modules/@aws-sdk/core/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-env/package.json +3 -3
- package/node_modules/@aws-sdk/credential-provider-http/package.json +3 -3
- package/node_modules/@aws-sdk/credential-provider-ini/package.json +10 -10
- package/node_modules/@aws-sdk/credential-provider-login/package.json +4 -4
- package/node_modules/@aws-sdk/credential-provider-node/package.json +8 -8
- package/node_modules/@aws-sdk/credential-provider-process/package.json +3 -3
- package/node_modules/@aws-sdk/credential-provider-sso/package.json +5 -5
- package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +4 -4
- package/node_modules/@aws-sdk/middleware-sdk-s3/package.json +3 -3
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/cognito-identity/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/signin/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso-oidc/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/package.json +3 -3
- package/node_modules/@aws-sdk/token-providers/dist-cjs/index.js +37 -19
- package/node_modules/@aws-sdk/token-providers/dist-es/fromSso.js +37 -19
- package/node_modules/@aws-sdk/token-providers/package.json +4 -4
- package/node_modules/@smithy/core/dist-cjs/submodules/protocols/index.js +1695 -3
- package/node_modules/@smithy/core/dist-es/submodules/protocols/ConfigurableSerdeContext.js +6 -0
- package/node_modules/@smithy/core/dist-es/submodules/protocols/UnionSerde.js +26 -0
- package/node_modules/@smithy/core/dist-es/submodules/protocols/common.js +3 -0
- package/node_modules/@smithy/core/dist-es/submodules/protocols/index.js +8 -0
- package/node_modules/@smithy/core/dist-es/submodules/protocols/json/SmithyRpcV2JsonProtocol.js +102 -0
- package/node_modules/{@aws-sdk → @smithy}/core/dist-es/submodules/protocols/json/codec-v1/JsonShapeDeserializer.js +8 -1
- package/node_modules/{@aws-sdk → @smithy}/core/dist-es/submodules/protocols/json/codec-v1/JsonShapeSerializer.js +8 -1
- package/node_modules/{@aws-sdk → @smithy}/core/dist-es/submodules/protocols/json/codec-v2/JsonShapeDeserializer2.js +13 -2
- package/node_modules/{@aws-sdk → @smithy}/core/dist-es/submodules/protocols/json/codec-v2/JsonShapeSerializer2.js +11 -1
- package/node_modules/{@aws-sdk → @smithy}/core/dist-es/submodules/protocols/json/parseJsonBody.js +16 -1
- package/node_modules/@smithy/core/dist-es/submodules/protocols/writeKey.js +3 -0
- package/node_modules/@smithy/core/dist-types/submodules/protocols/ConfigurableSerdeContext.d.ts +8 -0
- package/node_modules/@smithy/core/dist-types/submodules/protocols/UnionSerde.d.ts +24 -0
- package/node_modules/@smithy/core/dist-types/submodules/protocols/common.d.ts +2 -0
- package/node_modules/@smithy/core/dist-types/submodules/protocols/index.d.ts +9 -0
- package/node_modules/@smithy/core/dist-types/submodules/protocols/json/JsonSettings.d.ts +13 -0
- package/node_modules/@smithy/core/dist-types/submodules/protocols/json/SmithyRpcV2JsonProtocol.d.ts +28 -0
- package/node_modules/{@aws-sdk → @smithy}/core/dist-types/submodules/protocols/json/parseJsonBody.d.ts +16 -0
- package/node_modules/@smithy/core/dist-types/submodules/protocols/writeKey.d.ts +4 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/ConfigurableSerdeContext.d.ts +8 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/UnionSerde.d.ts +24 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/common.d.ts +2 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/index.d.ts +9 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/JsonSettings.d.ts +13 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/SmithyRpcV2JsonProtocol.d.ts +28 -0
- package/node_modules/{@aws-sdk → @smithy}/core/dist-types/ts3.4/submodules/protocols/json/codec-v1/JsonCodec.d.ts +15 -11
- package/node_modules/{@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json → @smithy/core/dist-types/ts3.4/submodules/protocols/json/codec-v1}/JsonSettings.d.ts +7 -4
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/codec-v1/JsonShapeDeserializer.d.ts +14 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/codec-v1/JsonShapeSerializer.d.ts +29 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/codec-v2/JsonBytesStringAdapter.d.ts +51 -0
- package/node_modules/{@aws-sdk → @smithy}/core/dist-types/ts3.4/submodules/protocols/json/codec-v2/JsonCodec2.d.ts +13 -9
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/codec-v2/JsonShapeDeserializer2.d.ts +30 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/codec-v2/JsonShapeSerializer2.d.ts +60 -0
- package/node_modules/{@aws-sdk → @smithy}/core/dist-types/ts3.4/submodules/protocols/json/detectBufferParsing.d.ts +1 -1
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/jsonReplacer.d.ts +21 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/jsonReviver.d.ts +15 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/needsReviver.d.ts +11 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/parseJsonBody.d.ts +38 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/writeKey.d.ts +4 -0
- package/node_modules/@smithy/core/package.json +2 -1
- package/node_modules/@zone-eu/mailsplit/README.md +43 -54
- package/node_modules/@zone-eu/mailsplit/lib/headers.js +10 -4
- package/node_modules/@zone-eu/mailsplit/lib/message-splitter.js +5 -4
- package/node_modules/@zone-eu/mailsplit/lib/mime-node.d.ts +4 -1
- package/node_modules/@zone-eu/mailsplit/lib/mime-node.js +30 -5
- package/node_modules/@zone-eu/mailsplit/lib/types.d.ts +3 -1
- package/node_modules/@zone-eu/mailsplit/package.json +22 -17
- package/node_modules/libbase64/CHANGELOG.md +20 -0
- package/node_modules/libbase64/README.md +40 -13
- package/node_modules/libbase64/dist/cjs/libbase64.d.ts +80 -0
- package/node_modules/libbase64/dist/cjs/libbase64.js +310 -0
- package/node_modules/libbase64/dist/cjs/package.json +3 -0
- package/node_modules/libbase64/dist/esm/libbase64.d.ts +80 -0
- package/node_modules/libbase64/{lib → dist/esm}/libbase64.js +74 -117
- package/node_modules/libbase64/dist/esm/package.json +3 -0
- package/node_modules/libbase64/package.json +59 -13
- package/node_modules/libmime/CHANGELOG.md +38 -0
- package/node_modules/libmime/README.md +55 -26
- package/node_modules/libmime/SECURITY.md +152 -0
- package/node_modules/libmime/dist/cjs/charset.d.ts +43 -0
- package/node_modules/libmime/dist/cjs/charset.js +135 -0
- package/node_modules/libmime/dist/cjs/charsets.d.ts +2 -0
- package/node_modules/libmime/dist/cjs/charsets.js +213 -0
- package/node_modules/libmime/dist/cjs/get-charset-name.d.ts +1 -0
- package/node_modules/libmime/dist/cjs/get-charset-name.js +224 -0
- package/node_modules/libmime/dist/cjs/libmime.d.ts +218 -0
- package/node_modules/libmime/dist/cjs/libmime.js +1027 -0
- package/node_modules/libmime/dist/cjs/mimetypes.d.ts +7 -0
- package/node_modules/libmime/dist/cjs/mimetypes.js +2072 -0
- package/node_modules/libmime/dist/cjs/package.json +3 -0
- package/node_modules/libmime/dist/cjs/types.d.ts +59 -0
- package/node_modules/libmime/dist/cjs/types.js +4 -0
- package/node_modules/libmime/dist/esm/charset.d.ts +43 -0
- package/node_modules/libmime/dist/esm/charset.js +125 -0
- package/node_modules/libmime/dist/esm/charsets.d.ts +2 -0
- package/node_modules/libmime/{lib → dist/esm}/charsets.js +3 -5
- package/node_modules/libmime/dist/esm/get-charset-name.d.ts +1 -0
- package/node_modules/libmime/{lib → dist/esm}/get-charset-name.js +1 -8
- package/node_modules/libmime/dist/esm/libmime.d.ts +219 -0
- package/node_modules/libmime/{lib → dist/esm}/libmime.js +275 -334
- package/node_modules/libmime/dist/esm/mimetypes.d.ts +7 -0
- package/node_modules/libmime/dist/esm/mimetypes.js +2068 -0
- package/node_modules/libmime/dist/esm/package.json +3 -0
- package/node_modules/libmime/dist/esm/types.d.ts +59 -0
- package/node_modules/libmime/dist/esm/types.js +3 -0
- package/node_modules/libmime/package.json +60 -15
- package/node_modules/libqp/CHANGELOG.md +18 -0
- package/node_modules/libqp/README.md +50 -19
- package/node_modules/libqp/dist/cjs/libqp.d.ts +74 -0
- package/node_modules/libqp/dist/cjs/libqp.js +378 -0
- package/node_modules/libqp/dist/cjs/package.json +3 -0
- package/node_modules/libqp/dist/esm/libqp.d.ts +74 -0
- package/node_modules/libqp/dist/esm/libqp.js +369 -0
- package/node_modules/libqp/dist/esm/package.json +3 -0
- package/node_modules/libqp/lib/libqp.js +4 -383
- package/node_modules/libqp/lib/package.json +3 -0
- package/node_modules/libqp/package.json +62 -6
- package/node_modules/mailparser/CHANGELOG.md +56 -0
- package/node_modules/mailparser/README.md +6 -0
- package/node_modules/mailparser/dist/cjs/index.d.ts +10 -0
- package/node_modules/mailparser/dist/cjs/index.js +12 -0
- package/node_modules/mailparser/dist/cjs/mail-parser.d.ts +98 -0
- package/node_modules/mailparser/dist/cjs/mail-parser.js +1419 -0
- package/node_modules/mailparser/dist/cjs/package.json +3 -0
- package/node_modules/mailparser/dist/cjs/simple-parser.d.ts +17 -0
- package/node_modules/mailparser/dist/cjs/simple-parser.js +133 -0
- package/node_modules/mailparser/dist/cjs/stream-hash.d.ts +24 -0
- package/node_modules/mailparser/dist/cjs/stream-hash.js +33 -0
- package/node_modules/mailparser/dist/cjs/tlds.cjs +8 -0
- package/node_modules/mailparser/dist/cjs/types.d.ts +309 -0
- package/node_modules/mailparser/dist/cjs/types.js +2 -0
- package/node_modules/mailparser/dist/esm/index.d.ts +10 -0
- package/node_modules/mailparser/dist/esm/index.js +4 -0
- package/node_modules/mailparser/dist/esm/mail-parser.d.ts +98 -0
- package/node_modules/mailparser/{lib → dist/esm}/mail-parser.js +302 -368
- package/node_modules/mailparser/dist/esm/package.json +3 -0
- package/node_modules/mailparser/dist/esm/simple-parser.d.ts +17 -0
- package/node_modules/mailparser/{lib → dist/esm}/simple-parser.js +45 -68
- package/node_modules/mailparser/dist/esm/stream-hash.d.ts +24 -0
- package/node_modules/mailparser/{lib → dist/esm}/stream-hash.js +7 -9
- package/node_modules/mailparser/dist/esm/tlds.cjs +8 -0
- package/node_modules/mailparser/dist/esm/types.d.ts +309 -0
- package/node_modules/mailparser/dist/esm/types.js +1 -0
- package/node_modules/mailparser/package.json +88 -17
- package/node_modules/nodemailer/CHANGELOG.md +44 -0
- package/node_modules/nodemailer/dist/cjs/addressparser/index.js +695 -267
- package/node_modules/nodemailer/dist/cjs/mailer/mail-message.js +4 -1
- package/node_modules/nodemailer/dist/cjs/mime-funcs/index.js +8 -2
- package/node_modules/nodemailer/dist/cjs/mime-node/index.js +48 -16
- package/node_modules/nodemailer/dist/cjs/package-info.d.ts +1 -1
- package/node_modules/nodemailer/dist/cjs/package-info.js +1 -1
- package/node_modules/nodemailer/dist/cjs/shared/url.js +22 -5
- package/node_modules/nodemailer/dist/esm/addressparser/index.js +695 -267
- package/node_modules/nodemailer/dist/esm/mailer/mail-message.js +4 -1
- package/node_modules/nodemailer/dist/esm/mime-funcs/index.js +8 -2
- package/node_modules/nodemailer/dist/esm/mime-node/index.js +48 -16
- package/node_modules/nodemailer/dist/esm/package-info.d.ts +1 -1
- package/node_modules/nodemailer/dist/esm/package-info.js +1 -1
- package/node_modules/nodemailer/dist/esm/shared/url.js +22 -5
- package/node_modules/nodemailer/package.json +1 -1
- package/package.json +9 -9
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/codec-v1/JsonSettings.d.ts +0 -7
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/codec-v1/JsonSettings.d.ts +0 -4
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/codec-v1/JsonShapeDeserializer.d.ts +0 -13
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/codec-v1/JsonShapeSerializer.d.ts +0 -18
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/codec-v2/JsonBytesStringAdapter.d.ts +0 -27
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/codec-v2/JsonShapeDeserializer2.d.ts +0 -15
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/codec-v2/JsonShapeSerializer2.d.ts +0 -39
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/jsonReplacer.d.ts +0 -7
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/jsonReviver.d.ts +0 -7
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/needsReviver.d.ts +0 -2
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/parseJsonBody.d.ts +0 -14
- package/node_modules/libbase64/.eslintrc +0 -11
- package/node_modules/libbase64/.github/FUNDING.yml +0 -4
- package/node_modules/libbase64/.github/VULNERABILITY_REPORT.yml +0 -75
- package/node_modules/libbase64/.github/workflows/release.yaml +0 -39
- package/node_modules/libbase64/.github/workflows/test.yml +0 -21
- package/node_modules/libbase64/.ncurc.js +0 -13
- package/node_modules/libbase64/.prettierrc.js +0 -8
- package/node_modules/libmime/lib/charset.js +0 -131
- package/node_modules/libmime/lib/mimetypes.js +0 -2049
- package/node_modules/libqp/.eslintrc +0 -15
- package/node_modules/libqp/.github/FUNDING.yml +0 -4
- package/node_modules/libqp/.github/VULNERABILITY_REPORT.yml +0 -75
- package/node_modules/libqp/.github/workflows/release.yaml +0 -39
- package/node_modules/libqp/.github/workflows/test.yml +0 -21
- package/node_modules/libqp/.prettierrc.js +0 -8
- package/node_modules/libqp/test/libqp-test.js +0 -366
- package/node_modules/mailparser/.gitattributes +0 -1
- package/node_modules/mailparser/.prettierignore +0 -3
- package/node_modules/mailparser/.prettierrc.js +0 -10
- package/node_modules/mailparser/.release-please-manifest.json +0 -3
- package/node_modules/mailparser/eslint.config.js +0 -33
- package/node_modules/mailparser/index.js +0 -9
- package/node_modules/mailparser/release-please-config.json +0 -10
- /package/node_modules/{@aws-sdk → @smithy}/core/dist-es/submodules/protocols/json/JsonSettings.js +0 -0
- /package/node_modules/{@aws-sdk → @smithy}/core/dist-es/submodules/protocols/json/codec-v1/JsonCodec.js +0 -0
- /package/node_modules/{@aws-sdk → @smithy}/core/dist-es/submodules/protocols/json/codec-v1/JsonSettings.js +0 -0
- /package/node_modules/{@aws-sdk → @smithy}/core/dist-es/submodules/protocols/json/codec-v2/JsonBytesStringAdapter.js +0 -0
- /package/node_modules/{@aws-sdk → @smithy}/core/dist-es/submodules/protocols/json/codec-v2/JsonCodec2.js +0 -0
- /package/node_modules/{@aws-sdk → @smithy}/core/dist-es/submodules/protocols/json/detectBufferParsing.js +0 -0
- /package/node_modules/{@aws-sdk → @smithy}/core/dist-es/submodules/protocols/json/jsonReplacer.js +0 -0
- /package/node_modules/{@aws-sdk → @smithy}/core/dist-es/submodules/protocols/json/jsonReviver.js +0 -0
- /package/node_modules/{@aws-sdk → @smithy}/core/dist-es/submodules/protocols/json/needsReviver.js +0 -0
- /package/node_modules/{@aws-sdk → @smithy}/core/dist-types/submodules/protocols/json/codec-v1/JsonCodec.d.ts +0 -0
- /package/node_modules/{@aws-sdk/core/dist-types/submodules/protocols/json → @smithy/core/dist-types/submodules/protocols/json/codec-v1}/JsonSettings.d.ts +0 -0
- /package/node_modules/{@aws-sdk → @smithy}/core/dist-types/submodules/protocols/json/codec-v1/JsonShapeDeserializer.d.ts +0 -0
- /package/node_modules/{@aws-sdk → @smithy}/core/dist-types/submodules/protocols/json/codec-v1/JsonShapeSerializer.d.ts +0 -0
- /package/node_modules/{@aws-sdk → @smithy}/core/dist-types/submodules/protocols/json/codec-v2/JsonBytesStringAdapter.d.ts +0 -0
- /package/node_modules/{@aws-sdk → @smithy}/core/dist-types/submodules/protocols/json/codec-v2/JsonCodec2.d.ts +0 -0
- /package/node_modules/{@aws-sdk → @smithy}/core/dist-types/submodules/protocols/json/codec-v2/JsonShapeDeserializer2.d.ts +0 -0
- /package/node_modules/{@aws-sdk → @smithy}/core/dist-types/submodules/protocols/json/codec-v2/JsonShapeSerializer2.d.ts +0 -0
- /package/node_modules/{@aws-sdk → @smithy}/core/dist-types/submodules/protocols/json/detectBufferParsing.d.ts +0 -0
- /package/node_modules/{@aws-sdk → @smithy}/core/dist-types/submodules/protocols/json/jsonReplacer.d.ts +0 -0
- /package/node_modules/{@aws-sdk → @smithy}/core/dist-types/submodules/protocols/json/jsonReviver.d.ts +0 -0
- /package/node_modules/{@aws-sdk → @smithy}/core/dist-types/submodules/protocols/json/needsReviver.d.ts +0 -0
|
@@ -10,7 +10,36 @@
|
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
libmime is written in TypeScript and ships both an ES module and a CommonJS build, each with type declarations. Node.js 20 or newer is required.
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
// ES modules
|
|
17
|
+
import libmime from 'libmime';
|
|
18
|
+
|
|
19
|
+
// CommonJS
|
|
20
|
+
const libmime = require('libmime');
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
The default export is a shared `Libmime` instance. The class itself is available as `Libmime` for creating instances of your own:
|
|
24
|
+
|
|
25
|
+
```js
|
|
26
|
+
import { Libmime } from 'libmime';
|
|
27
|
+
// or: const { Libmime } = require('libmime');
|
|
28
|
+
|
|
29
|
+
const mime = new Libmime();
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
The helper modules can be loaded directly as well, for example `libmime/lib/charset` (`encode`, `decode`, `convert`, `normalizeCharset`) and `libmime/lib/mimetypes` (`list`, `extensions`).
|
|
33
|
+
|
|
34
|
+
### TypeScript
|
|
35
|
+
|
|
36
|
+
The bundled declarations replace `@types/libmime`, which can be removed. The type names it used keep working: `libmime.StructuredHeader` and `libmime.MimeWordEncoding` are available through the default export, next to the other public types (`ParsedHeaderValue`, `StructuredHeaderValue`, `HeaderParam`, `HeaderLine`, `HeaderObject`), which can also be imported by name:
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
import libmime, { type ParsedHeaderValue } from 'libmime';
|
|
40
|
+
|
|
41
|
+
const parsed: ParsedHeaderValue = libmime.parseHeaderValue('text/plain; charset=utf-8');
|
|
42
|
+
```
|
|
14
43
|
|
|
15
44
|
## Methods
|
|
16
45
|
|
|
@@ -22,9 +51,9 @@ Encodes a string into mime [encoded word](http://en.wikipedia.org/wiki/MIME#Enco
|
|
|
22
51
|
|
|
23
52
|
libmime.encodeWord(str [, mimeWordEncoding[, maxLength]]) → String
|
|
24
53
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
54
|
+
- **str** - String or Buffer to be encoded
|
|
55
|
+
- **mimeWordEncoding** - Encoding for the mime word, either Q or B (default is 'Q')
|
|
56
|
+
- **maxLength** - If set, split mime words into several chunks if needed
|
|
28
57
|
|
|
29
58
|
**Example**
|
|
30
59
|
|
|
@@ -40,10 +69,10 @@ Encodes non ascii sequences in a string to mime words.
|
|
|
40
69
|
|
|
41
70
|
libmime.encodeWords(str [, mimeWordEncoding[, maxLength[, fromCharset]]]) → String
|
|
42
71
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
72
|
+
- **str** - String or Buffer to be encoded
|
|
73
|
+
- **mimeWordEncoding** - Encoding for the mime word, either Q or B (default is 'Q')
|
|
74
|
+
- **maxLength** - If set, split mime words into several chunks if needed
|
|
75
|
+
- **fromCharset** - Source character set of `str` (defaults to `'UTF-8'`)
|
|
47
76
|
|
|
48
77
|
#### #decodeWords
|
|
49
78
|
|
|
@@ -51,7 +80,7 @@ Decodes a string that might include one or several mime words. If no mime words
|
|
|
51
80
|
|
|
52
81
|
libmime.decodeWords(str) → String
|
|
53
82
|
|
|
54
|
-
|
|
83
|
+
- **str** - String to be decoded
|
|
55
84
|
|
|
56
85
|
### Folding
|
|
57
86
|
|
|
@@ -61,9 +90,9 @@ Folds a long line according to the [RFC 5322](http://tools.ietf.org/html/rfc5322
|
|
|
61
90
|
|
|
62
91
|
libmime.foldLines(str [, lineLength[, afterSpace]]) → String
|
|
63
92
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
93
|
+
- **str** - String to be folded
|
|
94
|
+
- **lineLength** - Maximum length of a line (defaults to 76)
|
|
95
|
+
- **afterSpace** - If true, leave a space in the end of a line
|
|
67
96
|
|
|
68
97
|
**Example**
|
|
69
98
|
|
|
@@ -80,8 +109,8 @@ Adds soft line breaks to content marked with `format=flowed` options to ensure t
|
|
|
80
109
|
|
|
81
110
|
libmime.encodeFlowed(str [, lineLength]) → String
|
|
82
111
|
|
|
83
|
-
|
|
84
|
-
|
|
112
|
+
- **str** Plaintext string that requires wrapping
|
|
113
|
+
- **lineLength** (defaults to 76) Maximum length of a line
|
|
85
114
|
|
|
86
115
|
#### #decodeFlowed
|
|
87
116
|
|
|
@@ -89,8 +118,8 @@ Unwraps a plaintext string in format=flowed wrapping.
|
|
|
89
118
|
|
|
90
119
|
libmime.decodeFlowed(str [, delSp]) → String
|
|
91
120
|
|
|
92
|
-
|
|
93
|
-
|
|
121
|
+
- **str** Plaintext string with format=flowed to decode
|
|
122
|
+
- **delSp** If true, delete leading spaces (delsp=yes)
|
|
94
123
|
|
|
95
124
|
### Headers
|
|
96
125
|
|
|
@@ -100,7 +129,7 @@ Unfolds a header line and splits it to key and value pair. The return value is i
|
|
|
100
129
|
|
|
101
130
|
libmime.decodeHeader(headerLine) → Object
|
|
102
131
|
|
|
103
|
-
|
|
132
|
+
- **headerLine** - Single header line, might include linebreaks as well if folded
|
|
104
133
|
|
|
105
134
|
#### #decodeHeaders
|
|
106
135
|
|
|
@@ -110,7 +139,7 @@ Return value is an object of headers, where header keys are object keys and valu
|
|
|
110
139
|
|
|
111
140
|
libmime.decodeHeaders(headers) → Object
|
|
112
141
|
|
|
113
|
-
|
|
142
|
+
- **headers** - Headers string
|
|
114
143
|
|
|
115
144
|
#### #parseHeaderValue
|
|
116
145
|
|
|
@@ -119,7 +148,7 @@ Parses a header value with `key=value` arguments into a structured object. Usefu
|
|
|
119
148
|
|
|
120
149
|
parseHeaderValue(valueString) → Object
|
|
121
150
|
|
|
122
|
-
|
|
151
|
+
- **valueString** - a header value without the key
|
|
123
152
|
|
|
124
153
|
**Example**
|
|
125
154
|
|
|
@@ -144,7 +173,7 @@ Joins structured header value together as 'value; param1=value1; param2=value2'
|
|
|
144
173
|
|
|
145
174
|
buildHeaderValue(structuredHeader) → String
|
|
146
175
|
|
|
147
|
-
|
|
176
|
+
- **structuredHeader** - a header value formatted with `parseHeaderValue`
|
|
148
177
|
|
|
149
178
|
`filename` argument is encoded with continuation encoding if needed
|
|
150
179
|
|
|
@@ -154,10 +183,10 @@ Encodes and splits a header param value according to [RFC2231](https://tools.iet
|
|
|
154
183
|
|
|
155
184
|
libmime.buildHeaderParam(key, str [, maxLength[, fromCharset]]) → Array
|
|
156
185
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
186
|
+
- **key** - Parameter key (eg. `filename`)
|
|
187
|
+
- **str** - String or a Buffer value to encode
|
|
188
|
+
- **maxLength** - Maximum length of the encoded string part (not line length). Defaults to 50
|
|
189
|
+
- **fromCharset** - Source character set of `str` when it is a Buffer (defaults to `'UTF-8'`)
|
|
161
190
|
|
|
162
191
|
The method returns an array of encoded parts with the following structure: `[{key:'...', value: '...'}]`
|
|
163
192
|
|
|
@@ -186,7 +215,7 @@ Returns file extension for a content type string. If no suitable extensions are
|
|
|
186
215
|
|
|
187
216
|
libmime.detectExtension(mimeType) → String
|
|
188
217
|
|
|
189
|
-
|
|
218
|
+
- **mimeType** - Content type to be checked for
|
|
190
219
|
|
|
191
220
|
**Example**
|
|
192
221
|
|
|
@@ -198,7 +227,7 @@ Returns content type for a file extension. If no suitable content types are foun
|
|
|
198
227
|
|
|
199
228
|
libmime.detectMimeType(extension) → String
|
|
200
229
|
|
|
201
|
-
|
|
230
|
+
- **extension** Extension (or filename) to be checked for
|
|
202
231
|
|
|
203
232
|
**Example**
|
|
204
233
|
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
libmime encodes and decodes MIME encoded words, headers, and header parameters,
|
|
4
|
+
and converts between character sets. It is used to parse headers of untrusted
|
|
5
|
+
email messages. We welcome responsible reports of vulnerabilities that present a
|
|
6
|
+
credible security risk to users. Please distinguish security vulnerabilities
|
|
7
|
+
from ordinary bugs, unusual edge cases, and hardening suggestions.
|
|
8
|
+
|
|
9
|
+
## Supported Versions
|
|
10
|
+
|
|
11
|
+
Security fixes are released only against the latest major version. We do not
|
|
12
|
+
backport patches to older majors, so upgrading to the current release line is
|
|
13
|
+
the supported way to receive security updates.
|
|
14
|
+
|
|
15
|
+
| Version | Supported |
|
|
16
|
+
| ------- | ------------------ |
|
|
17
|
+
| 5.x | :white_check_mark: |
|
|
18
|
+
| < 5.0 | :x: |
|
|
19
|
+
|
|
20
|
+
If you are on an older major, please upgrade. See [CHANGELOG.md](CHANGELOG.md)
|
|
21
|
+
before updating.
|
|
22
|
+
|
|
23
|
+
## What Qualifies as a Security Vulnerability
|
|
24
|
+
|
|
25
|
+
A security report should identify a realistic way for an attacker to cross a
|
|
26
|
+
security boundary in a supported version of libmime. Unexpected behavior, a
|
|
27
|
+
failing test, or a technically correct proof of concept is not sufficient on its
|
|
28
|
+
own to establish security impact.
|
|
29
|
+
|
|
30
|
+
In particular, explain:
|
|
31
|
+
|
|
32
|
+
- **Attacker capabilities:** Who is the attacker, and what inputs, systems, or
|
|
33
|
+
responses can they control _without_ already having the privileges or secrets
|
|
34
|
+
they are trying to gain?
|
|
35
|
+
- **Attack path:** How does attacker-controlled input reach the affected code
|
|
36
|
+
through a supported public API or a realistic application integration?
|
|
37
|
+
- **Prerequisites:** What configuration and user actions are required? If the
|
|
38
|
+
attack depends on unusual options or deliberately malformed input, explain why
|
|
39
|
+
those conditions could arise in a real application.
|
|
40
|
+
- **Impact:** What confidentiality, integrity, or availability boundary is
|
|
41
|
+
crossed, and what can the attacker achieve as a result?
|
|
42
|
+
|
|
43
|
+
A vulnerability involving an optional or less common feature can still qualify
|
|
44
|
+
if these conditions are met. Conversely, the existence of a defensive check in
|
|
45
|
+
the code does not, by itself, establish that every bypass of that check has a
|
|
46
|
+
realistic security impact.
|
|
47
|
+
|
|
48
|
+
## Reporting a Vulnerability
|
|
49
|
+
|
|
50
|
+
**Do not disclose suspected exploitable vulnerabilities through public GitHub
|
|
51
|
+
issues, pull requests, or discussions before coordinating with the
|
|
52
|
+
maintainers.**
|
|
53
|
+
|
|
54
|
+
Report privately through one of the following channels:
|
|
55
|
+
|
|
56
|
+
1. **GitHub Security Advisories (preferred):**
|
|
57
|
+
<https://github.com/nodemailer/libmime/security/advisories/new>.
|
|
58
|
+
2. **Email:** **andris@reinman.eu**. Encrypt sensitive details if possible (PGP
|
|
59
|
+
key fingerprint `5D952A46E1D8C931F6364E01DC6C83F4D584D364`).
|
|
60
|
+
|
|
61
|
+
### Required Information
|
|
62
|
+
|
|
63
|
+
Please provide enough information to evaluate both the defect and its security
|
|
64
|
+
impact. Reports should include:
|
|
65
|
+
|
|
66
|
+
1. The affected libmime version or commit, Node.js version, and relevant
|
|
67
|
+
configuration.
|
|
68
|
+
2. A concise description of the issue and the affected public API or code path
|
|
69
|
+
(for example encoded-word decoding, header parameter (RFC 2231) parsing,
|
|
70
|
+
header folding, or charset conversion).
|
|
71
|
+
3. A minimal, tested reproduction, including steps to run it, expected behavior,
|
|
72
|
+
and observed behavior.
|
|
73
|
+
4. A concrete threat model: attacker control, prerequisites, trust boundary, and
|
|
74
|
+
resulting impact. Clearly distinguish what your reproduction proves from what
|
|
75
|
+
you believe might be possible.
|
|
76
|
+
5. An explanation of why the issue affects real deployments beyond a
|
|
77
|
+
deliberately constructed test setup, where this is not obvious.
|
|
78
|
+
|
|
79
|
+
A suggested fix is welcome but does not replace an explanation of
|
|
80
|
+
exploitability. A complete real-world exploit is not always necessary, but the
|
|
81
|
+
report must make a credible security impact clear.
|
|
82
|
+
|
|
83
|
+
### Reports That May Be Treated as Ordinary Bugs
|
|
84
|
+
|
|
85
|
+
The following generally do **not** qualify for private security handling unless
|
|
86
|
+
you can demonstrate an additional, meaningful security boundary crossing:
|
|
87
|
+
|
|
88
|
+
- Issues that require the attacker to control trusted application code,
|
|
89
|
+
administrator-only configuration, or the secret they supposedly extract.
|
|
90
|
+
- Problems caused solely by application-level misuse, exposed credentials, or
|
|
91
|
+
insecure deployment choices outside libmime's control.
|
|
92
|
+
- Contrived proof-of-concept setups where the tester controls both sides of a
|
|
93
|
+
request, without explaining how a separate attacker could trigger the issue.
|
|
94
|
+
- Parser quirks, unexpected behavior, and bypasses of internal checks with no
|
|
95
|
+
demonstrated security impact.
|
|
96
|
+
- Speculative findings based only on static analysis or an automated tool's
|
|
97
|
+
assessment, without a verified reproduction and credible attack scenario.
|
|
98
|
+
|
|
99
|
+
These may still be valid bugs and may be considered through the normal issue
|
|
100
|
+
tracker. Please coordinate before making any potentially exploitable details
|
|
101
|
+
public. Classification as a bug does not guarantee a fix or a particular
|
|
102
|
+
priority.
|
|
103
|
+
|
|
104
|
+
### Automated and AI-Assisted Reports
|
|
105
|
+
|
|
106
|
+
Automated analysis and AI tools are welcome as research aids, but the person
|
|
107
|
+
submitting a report is responsible for verifying its claims. **Do not submit
|
|
108
|
+
bulk, unverified, or speculative AI-generated findings.** Test each finding
|
|
109
|
+
against a supported release and establish the actual security impact. Reports
|
|
110
|
+
that do not meet the requirements above may be closed without further
|
|
111
|
+
investigation or individual feedback; they can be resubmitted with stronger
|
|
112
|
+
evidence.
|
|
113
|
+
|
|
114
|
+
## Triage and Disclosure
|
|
115
|
+
|
|
116
|
+
libmime is maintained by a single person, and there is **no guaranteed response
|
|
117
|
+
or resolution time**. Reports are prioritized based on demonstrated impact,
|
|
118
|
+
exploitability, affected usage, and available maintenance resources.
|
|
119
|
+
|
|
120
|
+
A private report does not automatically become a security advisory. Confirmed
|
|
121
|
+
vulnerabilities may be fixed and disclosed through GitHub Security Advisories;
|
|
122
|
+
other findings may be closed, deferred, or handled as ordinary bugs. Please do
|
|
123
|
+
not disclose details of an unresolved, potentially exploitable issue publicly
|
|
124
|
+
without coordinating with the maintainers.
|
|
125
|
+
|
|
126
|
+
## CVEs and Credit
|
|
127
|
+
|
|
128
|
+
We do not request or manage CVE identifiers. A report being acknowledged, a bug
|
|
129
|
+
being fixed, or a pull request being merged does **not** mean that libmime has
|
|
130
|
+
confirmed a security vulnerability or endorsed a CVE assignment. We do not
|
|
131
|
+
guarantee advisories, CVE identifiers, or public credit for reports. For
|
|
132
|
+
confirmed vulnerabilities disclosed through an advisory, substantive reporters
|
|
133
|
+
may be credited if they wish.
|
|
134
|
+
|
|
135
|
+
## Scope
|
|
136
|
+
|
|
137
|
+
In scope: the libmime source in this repository: encoded-word encoding and
|
|
138
|
+
decoding, header parsing and folding, header parameter handling, charset
|
|
139
|
+
conversion, and MIME type detection. Of particular interest are crafted headers
|
|
140
|
+
that crash the process, cause catastrophic regular-expression backtracking,
|
|
141
|
+
pollute prototypes, or consume resources out of proportion to their size.
|
|
142
|
+
|
|
143
|
+
Out of scope:
|
|
144
|
+
|
|
145
|
+
- Resource consumption that is proportional to a legitimately large input.
|
|
146
|
+
- Bugs in iconv-lite or other third-party dependencies (please report those
|
|
147
|
+
upstream).
|
|
148
|
+
- Vulnerabilities in your own application code, including how it renders decoded
|
|
149
|
+
header values.
|
|
150
|
+
- Social-engineering reports.
|
|
151
|
+
|
|
152
|
+
Thank you for helping keep libmime and its users safe.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Buffer } from 'node:buffer';
|
|
2
|
+
/**
|
|
3
|
+
* Encodes an unicode string into an Buffer object as UTF-8
|
|
4
|
+
*
|
|
5
|
+
* We force UTF-8 here, no strange encodings allowed.
|
|
6
|
+
*
|
|
7
|
+
* @param str String to be encoded
|
|
8
|
+
* @return UTF-8 encoded typed array
|
|
9
|
+
*/
|
|
10
|
+
export declare function encode(str: string): Buffer;
|
|
11
|
+
/**
|
|
12
|
+
* Decodes a string from Buffer to an unicode string using specified encoding.
|
|
13
|
+
* An unknown charset falls back to UTF-8
|
|
14
|
+
*
|
|
15
|
+
* @param buf Binary data to be decoded
|
|
16
|
+
* @param [fromCharset='UTF-8'] Binary data is decoded into string using this charset
|
|
17
|
+
* @return Decoded string
|
|
18
|
+
*/
|
|
19
|
+
export declare function decode(buf: Buffer | string, fromCharset?: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* Convert a string from specific encoding to UTF-8 Buffer
|
|
22
|
+
*
|
|
23
|
+
* @param data String or Buffer to be encoded
|
|
24
|
+
* @param [fromCharset='UTF-8'] Source encoding for the string
|
|
25
|
+
* @return UTF-8 encoded typed array
|
|
26
|
+
*/
|
|
27
|
+
export declare function convert(data: string | Buffer, fromCharset?: string): Buffer;
|
|
28
|
+
/**
|
|
29
|
+
* Converts well known invalid character set names to proper names.
|
|
30
|
+
* eg. win-1257 will be converted to windows-1257. Missing or non-string
|
|
31
|
+
* input defaults to UTF-8.
|
|
32
|
+
*
|
|
33
|
+
* @param charset Charset name to convert
|
|
34
|
+
* @return Canonicalized charset name
|
|
35
|
+
*/
|
|
36
|
+
export declare function normalizeCharset(charset?: unknown): string;
|
|
37
|
+
declare const _default: {
|
|
38
|
+
encode: typeof encode;
|
|
39
|
+
decode: typeof decode;
|
|
40
|
+
convert: typeof convert;
|
|
41
|
+
normalizeCharset: typeof normalizeCharset;
|
|
42
|
+
};
|
|
43
|
+
export default _default;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.encode = encode;
|
|
7
|
+
exports.decode = decode;
|
|
8
|
+
exports.convert = convert;
|
|
9
|
+
exports.normalizeCharset = normalizeCharset;
|
|
10
|
+
const node_buffer_1 = require("node:buffer");
|
|
11
|
+
const iconv_lite_1 = __importDefault(require("iconv-lite"));
|
|
12
|
+
const encoding_japanese_1 = __importDefault(require("encoding-japanese"));
|
|
13
|
+
const charsets_js_1 = __importDefault(require("./charsets.js"));
|
|
14
|
+
/**
|
|
15
|
+
* Character set encoding and decoding functions
|
|
16
|
+
*/
|
|
17
|
+
// Names that are decoded as UTF-8 without going through iconv-lite
|
|
18
|
+
const UTF8_COMPATIBLE = /^(?:(?:us-)?ascii|utf-8|7bit)$/i;
|
|
19
|
+
// iconv-lite codecs that are not character sets a message could be written in. UTF-7 is a known
|
|
20
|
+
// way to smuggle markup past filters (=?utf-7?Q?+ADw-script+AD4-?= decodes to "<script>"), base64
|
|
21
|
+
// and hex are transfer encodings. A name resolving to one of them is treated like a charset
|
|
22
|
+
// iconv-lite does not know. iconv-lite resolves the name itself and returns one cached codec per
|
|
23
|
+
// encoding, so every alias it knows (unicode-1-1-utf-7 is utf7 too) is caught by identity
|
|
24
|
+
const UNSUPPORTED_CODECS = new Set(['utf7', 'utf7imap', 'base64', 'hex'].map(name => iconv_lite_1.default.getCodec(name)));
|
|
25
|
+
const isUnsupportedCodec = (name) => {
|
|
26
|
+
try {
|
|
27
|
+
return UNSUPPORTED_CODECS.has(iconv_lite_1.default.getCodec(name));
|
|
28
|
+
}
|
|
29
|
+
catch (_err) {
|
|
30
|
+
// a charset iconv-lite does not know at all
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
// Own entries only, so that a name such as '__proto__' or 'constructor' does not resolve to an
|
|
35
|
+
// inherited Object.prototype member
|
|
36
|
+
const CHARSET_ALIASES = new Map(Object.entries(charsets_js_1.default));
|
|
37
|
+
/**
|
|
38
|
+
* Encodes an unicode string into an Buffer object as UTF-8
|
|
39
|
+
*
|
|
40
|
+
* We force UTF-8 here, no strange encodings allowed.
|
|
41
|
+
*
|
|
42
|
+
* @param str String to be encoded
|
|
43
|
+
* @return UTF-8 encoded typed array
|
|
44
|
+
*/
|
|
45
|
+
function encode(str) {
|
|
46
|
+
return node_buffer_1.Buffer.from(str, 'utf-8');
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Decodes a string from Buffer to an unicode string using specified encoding.
|
|
50
|
+
* An unknown charset falls back to UTF-8
|
|
51
|
+
*
|
|
52
|
+
* @param buf Binary data to be decoded
|
|
53
|
+
* @param [fromCharset='UTF-8'] Binary data is decoded into string using this charset
|
|
54
|
+
* @return Decoded string
|
|
55
|
+
*/
|
|
56
|
+
function decode(buf, fromCharset) {
|
|
57
|
+
fromCharset = normalizeCharset(fromCharset || 'UTF-8');
|
|
58
|
+
if (UTF8_COMPATIBLE.test(fromCharset)) {
|
|
59
|
+
return buf.toString('utf-8');
|
|
60
|
+
}
|
|
61
|
+
if (isUnsupportedCodec(fromCharset)) {
|
|
62
|
+
// enforce utf-8, the same as for a charset iconv-lite does not know
|
|
63
|
+
return buf.toString();
|
|
64
|
+
}
|
|
65
|
+
try {
|
|
66
|
+
if (/^jis|^iso-?2022-?jp|^EUCJP/i.test(fromCharset)) {
|
|
67
|
+
if (typeof buf === 'string') {
|
|
68
|
+
buf = node_buffer_1.Buffer.from(buf);
|
|
69
|
+
}
|
|
70
|
+
try {
|
|
71
|
+
let output = encoding_japanese_1.default.convert(buf, {
|
|
72
|
+
to: 'UNICODE',
|
|
73
|
+
from: fromCharset,
|
|
74
|
+
type: 'string'
|
|
75
|
+
});
|
|
76
|
+
if (typeof output === 'string') {
|
|
77
|
+
return output;
|
|
78
|
+
}
|
|
79
|
+
// fall through to iconv-lite if convert returned something unexpected
|
|
80
|
+
}
|
|
81
|
+
catch (_err) {
|
|
82
|
+
// ignore, defaults to iconv-lite on error
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// iconv-lite reads a string as binary, kept as it always was
|
|
86
|
+
return iconv_lite_1.default.decode(buf, fromCharset);
|
|
87
|
+
}
|
|
88
|
+
catch (_err) {
|
|
89
|
+
// enforce utf-8, data loss might occur
|
|
90
|
+
return buf.toString();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Convert a string from specific encoding to UTF-8 Buffer
|
|
95
|
+
*
|
|
96
|
+
* @param data String or Buffer to be encoded
|
|
97
|
+
* @param [fromCharset='UTF-8'] Source encoding for the string
|
|
98
|
+
* @return UTF-8 encoded typed array
|
|
99
|
+
*/
|
|
100
|
+
function convert(data, fromCharset) {
|
|
101
|
+
fromCharset = normalizeCharset(fromCharset || 'UTF-8');
|
|
102
|
+
if (typeof data !== 'string') {
|
|
103
|
+
if (UTF8_COMPATIBLE.test(fromCharset)) {
|
|
104
|
+
return data;
|
|
105
|
+
}
|
|
106
|
+
return encode(decode(data, fromCharset));
|
|
107
|
+
}
|
|
108
|
+
return encode(data);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Converts well known invalid character set names to proper names.
|
|
112
|
+
* eg. win-1257 will be converted to windows-1257. Missing or non-string
|
|
113
|
+
* input defaults to UTF-8.
|
|
114
|
+
*
|
|
115
|
+
* @param charset Charset name to convert
|
|
116
|
+
* @return Canonicalized charset name
|
|
117
|
+
*/
|
|
118
|
+
function normalizeCharset(charset) {
|
|
119
|
+
let name = (charset || 'UTF-8').toString().toLowerCase().trim();
|
|
120
|
+
// first pass
|
|
121
|
+
let canonical = CHARSET_ALIASES.get(name);
|
|
122
|
+
if (canonical) {
|
|
123
|
+
return canonical;
|
|
124
|
+
}
|
|
125
|
+
name = name
|
|
126
|
+
.replace(/^utf[-_]?(\d+)/, 'utf-$1')
|
|
127
|
+
.replace(/^(?:us[-_]?)ascii/, 'windows-1252')
|
|
128
|
+
.replace(/^win(?:dows)?[-_]?(\d+)/, 'windows-$1')
|
|
129
|
+
.replace(/^(?:latin|iso[-_]?8859)?[-_]?(\d+)/, 'iso-8859-$1')
|
|
130
|
+
.replace(/^l[-_]?(\d+)/, 'iso-8859-$1');
|
|
131
|
+
// updated pass
|
|
132
|
+
return CHARSET_ALIASES.get(name) || name.toUpperCase();
|
|
133
|
+
}
|
|
134
|
+
exports.default = { encode, decode, convert, normalizeCharset };
|
|
135
|
+
Object.defineProperty(exports, 'default', { value: exports, enumerable: false, writable: true, configurable: true });
|