brianloveswords / base64url Goto Github PK
View Code? Open in Web Editor NEWFor encoding and decoding base64url!
License: MIT License
For encoding and decoding base64url!
License: MIT License
/home/dskrvk/workspace/wise/wise-api/node_modules/base64url/dist/base64url.js:4
function encode(input, encoding = "utf8") {
------------------------------------------^
Same in Travis: https://travis-ci.org/brianloveswords/base64url/jobs/379778757
There's no CHANGELOG.md and no info on the Releases page.
As I see the v3.0.0 has been released, but v3.0.0 tag is missing on git repo.
Hi,
Your package publishes global typings to npm. This causes conflicts with other (and more recent / acurate) definitions for Node. This module is simply unusable with full TS checks.
Since you use typings
, you shouldn't even publish your typings directory but let typings
resolve the dependencies with your typings.json
file. typings
is now deprecated in favor of @types
, I'd recommend to switch to @types
while fixing this issue.
In the README, please change the following (lines 31, 33):
### base64url(input: string | Buffer, encoding: string = "utf8"): string
### base64url.encode(input: string | Buffer, encoding: string = "utf8"): string
to:
### base64url(input: string | Buffer, {encoding: "utf8"}): string
### base64url.encode(input: string | Buffer, {encoding: "utf8"}): string
ES5 compatible modules, such as 'node-jose', use this module as one of their dependencies. Because the module has been compiled to ES6 it causes problems in browsers that are not ES6 compatible. In our use case the iOS 9 browser.
Can you change 'es6' to 'es5' in the 'tsconfig.json' in order to resolve these type of issues?
I added this to a local version of test:
test('from base64url to string', function (t) {
const b64url = 'a';
const result = base64url.encode(base64url.decode(b64url,'binary'));
t.same(result, b64url, 'should NOT be able to decode, it should throw an error');
t.end();
});
I also think there are issues with line-breaks which is outside of Base64URL
Doesnt work with Angular 7 still getting buffer is not defined, can someone else confirm?
Originally posted by @Gabb1995 in #33 (comment)
Package.json
"@angular/animations": "^7.1.4",
"@angular/cdk": "^7.3.2",
"@angular/common": "~7.1.0",
"@angular/compiler": "~7.1.0",
"@angular/core": "~7.1.0",
"@angular/flex-layout": "^7.0.0-beta.23",
"@angular/forms": "~7.1.0",
"@angular/material": "^7.3.2",
"@angular/platform-browser": "~7.1.0",
"@angular/platform-browser-dynamic": "~7.1.0",
"@angular/router": "~7.1.0",
"@fortawesome/fontawesome-free": "^5.7.2",
"@ngx-translate/core": "^11.0.1",
"@ngx-translate/http-loader": "^4.0.0",
"base64url": "^3.0.1",
"core-js": "^2.5.4",
"dayjs": "^1.8.11",
"hammerjs": "^2.0.8",
"lodash": "^4.17.11",
"ngx-color-picker": "^7.3.1",
"ngx-openlayers": "^0.8.22",
"rxjs": "^6.3.3",
"tslib": "^1.9.0",
"zone.js": "~0.8.26"
ReferenceError: "Buffer is not defined"
decode base64url.js:14
getConfigFromLegacy whitelabel.service.ts:294
load whitelabel.service.ts:45
ZoneAwarePromise Angular
load whitelabel.service.ts:44
ngOnInit app.component.ts:74
RxJS 3
app.component.ts:80:32
ngOnInit app.component.ts:80
Angular 10
I'm using your lib from npm. But when I start to compile my oun module a have TS error with duplicated node.d.ts declarations. You add folder typings
to npm lib. I think it would be better to distribute base64url via TSD. I created base64url.d.ts and made PR.
With a debug print in there:
$ ./bin/base64url -D
XXX decode false { d: true,
decode: false,
h: false,
help: false,
v: false,
version: false }
I'm guessing meow
doesn't support distinguishing uppercase vs lowercase single-char options. A quick fix would be:
diff --git a/bin/base64url b/bin/base64url
index 112e0d6..a9445b7 100755
--- a/bin/base64url
+++ b/bin/base64url
@@ -27,7 +27,7 @@ var cli = require('meow')({
],
});
-var decode = cli.flags.D || cli.flags.decode;
+var decode = cli.flags.d || cli.flags.decode;
var fn = decode && base64url.decode || base64url.encode;
function processStream(outputStream, breakLength) {
By default typescript tries to resolve declaration by searching, among other locations, in node_modules project - that leads to duplicate definition error which is not that trivial to get rid off (at least some not that well documented steps should be taken).
Here's a link to give you an idea - microsoft/TypeScript#6964
It would be very nice if typescript definitions won't be included to the final package.
After all not a big deal but those a just redundant files that a increasing package size for no reason.
By trying to build react application it comes to error:
Failed to minify the code from this file:
./node_modules/base64url/dist/base64url.js:4
Read more here: http://bit.ly/2tRViJ9
They suggest:
Open an issue on the dependency's issue tracker and ask that the package be published pre-compiled.
Note: Create React App can consume both CommonJS and ES modules. For Node.js compatibility, it is recommended that the main entry point is CommonJS. However, they can optionally provide an ES module entry point with the module field in package.json. Note that even if a library provides an ES Modules version, it should still precompile other ES6 features to ES5 if it intends to support older browsers.
base64url: 3.0.0
react-scripts: 1.1.4
This modules uses Buffer()
, causing the following warning to be displayed:
DeprecationWarning: Using Buffer without
new
will soon stop working. Usenew Buffer()
, or preferablyBuffer.from()
,Buffer.allocUnsafe()
orBuffer.alloc()
instead.
I'm trying to install gh-pages and received from npm audit the message:
=== npm audit security report ===
Moderate: Out-of-bounds Read
Package: base64url
Patched in: >=3.0.0
Dependency of: gh-pages [dev]
Path: gh-pages > base64url
More info: https://nodesecurity.io/advisories/658
[!] 1 vulnerability found - Packages audited: 47 (47 dev, 0 optional)
Severity: 1 Moderate
I'm having a hard time figuring out in what JS environment will this package work. It makes a clear mention of Node.js but no mention of browser or React Native.
After download serval npm install
fail project. I do not want to touch npm anymore... Source code in the git project should be the forever
solution for me.
For example: keithnorm/simple-webrtc-video-chat#6
I just want to copy and paste source code into my project. But I can not find javascript source code.
Please provide one in the git project or in github download.
Using [email protected] with [email protected] and Node 8.11.1
Code:
import base64url from 'base64url'
Results in the error:
Could not find a declaration file for module 'base64url'. '/Users/samu/projects/reaktor/vaana/vaana-login/node_modules/base64url/index.js' implicitly has an 'any' type.
Trynpm install @types/base64url
if it exists or add a new declaration (.d.ts) file containingdeclare module 'base64url';
Based on the instructions here: https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html#iincluding-declarations-in-your-npm-package
You need to either define the index.d.ts file explicitly using types in package.json or if your package is based on index.js as the entry point then a default of index.d.ts is used.
Adding "types": "./dist/base64url.d.ts"
to the package.json file for base64url gets rid of the error message.
Hi, I was looking through the dependency tree of my dependencies and drilled down to this module via jwa
/jws
. This module relies on meow v2 which has a lot of dependencies, but not as many as v3.
Here's the current dependency tree this module, whose only job is to encode and decode strings: http://npm.anvaka.com/#/view/2d/base64url
Going forward I think it would be ideal if this module dropped CLI support. To me a CLI is a separate concern and should be a separate module, e.g. base64url-cli
Thoughts?
we recently upgraded our application to angular 6 and RxJs 6. Now I get the following error when trying to encode/decode
Uncaught ReferenceError: Buffer is not defined
at encode (base64url.js:5)
at Observable._zoneSubscribe (file-upload-service.ts:160)
at Observable.push../node_modules/rxjs/_esm5/internal/Observable.js.Observable.subscribe [as __zone_symbol__subscribe] (Observable.js:161)
at Observable.value [as subscribe] (zone-patch-rxjs.js:95)
at CatchOperator.push../node_modules/rxjs/_esm5/internal/operators/catchError.js.CatchOperator.call (catchError.js:17)
at Observable.push../node_modules/rxjs/_esm5/internal/Observable.js.Observable.subscribe [as __zone_symbol__subscribe] (Observable.js:158)
at Observable.value [as subscribe] (zone-patch-rxjs.js:95)
at subscribeTo.js:21
at subscribeToResult (subscribeToResult.js:6)
at MergeMapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber._innerSub (mergeMap.js:127)
I'm using base64url 3.0.0 with typescript. I also needed to manually add the following to your package.json to get it to work with noImpliciteany set to true.
"typings": "./dist/base64url.d.ts"
this issue has already been reported (#29)
regards
Ramila
Getting the error - "Syntax error: Variable Buffer has already been declared" on chrome 41 and RedHat OS
Hello. I've looked through the npm packages that implement base64 url encoding, and your one seems to be the best fit. But I've got a small issue with it.
Using es6 features (such as const
) in code published to npm currently breaks environments that do not support these features, including IE10 and older (using browserify). This issue currently stops me from using this package in the app.
Would you mind if I make a PR replacing const
s with var
s?
L29 of index.js contains var buffer = Buffer(paddedStringLength);
, where it should be var buffer = new Buffer(paddedStringLength);
Doing so will give the warning (node:25634) DeprecationWarning: Using Buffer without
newwill soon stop working. Use
new Buffer(), or preferably
Buffer.from(),
Buffer.allocUnsafe()or
Buffer.alloc()instead.
in node v7
Hi, the test.jpg image cat always break my zip creations. I removed it manually but it seems corrupted or something.
Example:
Inp: fdsfdsafdsaff|https://cdsf.fdsf.fdsfsd.com/rep|https://lfdjsfjsdfj.fdskfjdsk.com/license
Outputs:
ZmRzZmRzYWZkc2FmZnxodHRwczovL2Nkc2YuZmRzZi5mZHNmc2QuY29tL3JlcHxodHRwczovL2xmZGpzZmpzZGZqLmZkc2tmamRzay5jb20vbGljZW5zZQ
Testing
Decoding:
$ echo | base64 -D
Outputs:
fdsfdsafdsaff|https://cdsf.fdsf.fdsfsd.com/rep|https://lfdjsfjsdfj.fdskfjdsk.com/licens
Expected
The common additional characters at the end of the base64 encoded string should be present, this prevents the loss of the last character when it is read by tools that aren't this library.
High severity vulnerability found on [email protected]
according to Snyk:
https://snyk.io/vuln/npm:base64url:20180511
Since this package is targeting to es6, default parameters will be omitted by ts compiler. However IE 11 doesn't support default parameters.
function decode(base64url: string, encoding: string = "utf8"): string {
return Buffer.from(toBase64(base64url), "base64").toString(encoding);
}
function encode(input: string | Buffer, encoding: string = "utf8"): string {
if (Buffer.isBuffer(input)) {
return fromBase64(input.toString("base64"));
}
return fromBase64(Buffer.from(input as string, encoding).toString("base64"));
};
Suggested solution:
change tsconfig.json to target to 'es5' or
avoid using default parameters
I don't want to install another library to decode base64 encoded string, so should I use this lib in strange way like this ?
base64url.decode(base64url.fromBase64(string))
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.