mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-24 16:14:01 +08:00
fix(onboarding): properly base64 encode string
This commit is contained in:
parent
81c8cd6a8b
commit
e5ca74684d
1 changed files with 10 additions and 2 deletions
|
@ -4,8 +4,16 @@ import crypto from 'crypto';
|
|||
import {EdgehillAPI, NylasAPI, AccountStore, RegExpUtils, IdentityStore} from 'nylas-exports';
|
||||
import url from 'url';
|
||||
|
||||
function base64url(buf) {
|
||||
return buf.toString('base64')
|
||||
function base64url(inBuffer) {
|
||||
let buffer;
|
||||
if (typeof inBuffer === "string") {
|
||||
buffer = new Buffer(inBuffer);
|
||||
} else if (inBuffer instanceof Buffer) {
|
||||
buffer = inBuffer;
|
||||
} else {
|
||||
throw new Error(`${inBuffer} must be a string or Buffer`)
|
||||
}
|
||||
return buffer.toString('base64')
|
||||
.replace(/\+/g, '-') // Convert '+' to '-'
|
||||
.replace(/\//g, '_'); // Convert '/' to '_'
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue