@turnkey/encoding
Advanced tools
Comparing version 0.1.0 to 0.2.0
@@ -17,3 +17,10 @@ 'use strict'; | ||
} | ||
// Polyfill btoa with a pure JS implementation. This is adapted from the following: | ||
const uint8ArrayFromHexString = (hexString) => { | ||
const hexRegex = /^[0-9A-Fa-f]+$/; | ||
if (!hexString || hexString.length % 2 != 0 || !hexRegex.test(hexString)) { | ||
throw new Error(`cannot create uint8array from invalid hex string: "${hexString}"`); | ||
} | ||
return new Uint8Array(hexString.match(/../g).map((h) => parseInt(h, 16))); | ||
}; | ||
// Pure JS implementation of btoa. This is adapted from the following: | ||
// https://github.com/jsdom/abab/blob/80874ae1fe1cde2e587bb6e51b6d7c9b42ca1d34/lib/btoa.js | ||
@@ -78,3 +85,4 @@ function btoa(s) { | ||
exports.stringToBase64urlString = stringToBase64urlString; | ||
exports.uint8ArrayFromHexString = uint8ArrayFromHexString; | ||
exports.uint8ArrayToHexString = uint8ArrayToHexString; | ||
//# sourceMappingURL=index.js.map |
# @turnkey/encoding | ||
## 0.2.0 | ||
### Minor Changes | ||
- fac7770: Add uint8ArrayFromHexstring and drop language saying this is an internal package | ||
## 0.1.0 | ||
Initial release |
@@ -7,2 +7,3 @@ /** | ||
export declare function uint8ArrayToHexString(input: Uint8Array): string; | ||
export declare const uint8ArrayFromHexString: (hexString: string) => Uint8Array; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -17,3 +17,10 @@ 'use strict'; | ||
} | ||
// Polyfill btoa with a pure JS implementation. This is adapted from the following: | ||
const uint8ArrayFromHexString = (hexString) => { | ||
const hexRegex = /^[0-9A-Fa-f]+$/; | ||
if (!hexString || hexString.length % 2 != 0 || !hexRegex.test(hexString)) { | ||
throw new Error(`cannot create uint8array from invalid hex string: "${hexString}"`); | ||
} | ||
return new Uint8Array(hexString.match(/../g).map((h) => parseInt(h, 16))); | ||
}; | ||
// Pure JS implementation of btoa. This is adapted from the following: | ||
// https://github.com/jsdom/abab/blob/80874ae1fe1cde2e587bb6e51b6d7c9b42ca1d34/lib/btoa.js | ||
@@ -78,3 +85,4 @@ function btoa(s) { | ||
exports.stringToBase64urlString = stringToBase64urlString; | ||
exports.uint8ArrayFromHexString = uint8ArrayFromHexString; | ||
exports.uint8ArrayToHexString = uint8ArrayToHexString; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@turnkey/encoding", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"main": "./dist/index.js", | ||
@@ -16,3 +16,3 @@ "module": "./dist/index.mjs", | ||
"license": "Apache-2.0", | ||
"description": "Encoding utility functions (internal)", | ||
"description": "Encoding utility functions", | ||
"author": { | ||
@@ -19,0 +19,0 @@ "name": "Turnkey", |
# @turnkey/encoding | ||
This is an internal package, not meant for public consumption. | ||
Temporary workaround until we can bring this as a proper internal package. See https://github.com/lmc-eu/spirit-design-system/issues/1238 for a great outline of the problem and potential ways forward. | ||
This is a package containing decoding and encoding functions. This is used by other Turnkey packages. Feel free to import exported functions into your own apps, but be aware that there may be significant interface changes in the future. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29354
255
4
1