Remove base64-arraybuffer
This commit is contained in:
parent
afc80650e7
commit
ec03db4db6
File diff suppressed because one or more lines are too long
|
@ -54,7 +54,6 @@
|
|||
"@sindresorhus/fnv1a": "^1.0.0",
|
||||
"autolinker": "^1.7.1",
|
||||
"backo": "^1.1.0",
|
||||
"base64-arraybuffer": "^0.1.5",
|
||||
"classnames": "^2.2.6",
|
||||
"es6-promise": "^4.2.5",
|
||||
"fontfaceobserver": "^2.0.9",
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
import React, { PureComponent } from 'react';
|
||||
|
||||
export default class FileInput extends PureComponent {
|
||||
static defaultProps = {
|
||||
type: 'text'
|
||||
};
|
||||
|
||||
componentWillMount() {
|
||||
this.input = window.document.createElement('input');
|
||||
this.input.setAttribute('type', 'file');
|
||||
|
@ -8,12 +12,24 @@ export default class FileInput extends PureComponent {
|
|||
this.input.addEventListener('change', e => {
|
||||
const file = e.target.files[0];
|
||||
const reader = new FileReader();
|
||||
const { onChange, type } = this.props;
|
||||
|
||||
reader.onload = () => {
|
||||
this.props.onChange(file.name, reader.result);
|
||||
onChange(file.name, reader.result);
|
||||
};
|
||||
|
||||
switch (type) {
|
||||
case 'binary':
|
||||
reader.readAsArrayBuffer(file);
|
||||
break;
|
||||
|
||||
case 'text':
|
||||
reader.readAsText(file);
|
||||
break;
|
||||
|
||||
default:
|
||||
reader.readAsText(file);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import base64 from 'base64-arraybuffer';
|
||||
import createReducer from 'utils/createReducer';
|
||||
import * as actions from './actions';
|
||||
|
||||
|
@ -72,7 +71,7 @@ export function setCert(fileName, cert) {
|
|||
return {
|
||||
type: actions.SET_CERT,
|
||||
fileName,
|
||||
cert: base64.encode(cert)
|
||||
cert: cert
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -80,6 +79,6 @@ export function setKey(fileName, key) {
|
|||
return {
|
||||
type: actions.SET_KEY,
|
||||
fileName,
|
||||
key: base64.encode(key)
|
||||
key: key
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1652,11 +1652,6 @@ balanced-match@^1.0.0:
|
|||
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"
|
||||
integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c=
|
||||
|
||||
base64-arraybuffer@^0.1.5:
|
||||
version "0.1.5"
|
||||
resolved "https://registry.yarnpkg.com/base64-arraybuffer/-/base64-arraybuffer-0.1.5.tgz#73926771923b5a19747ad666aa5cd4bf9c6e9ce8"
|
||||
integrity sha1-c5JncZI7Whl0etZmqlzUv5xunOg=
|
||||
|
||||
base64-js@^1.0.2:
|
||||
version "1.3.0"
|
||||
resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.3.0.tgz#cab1e6118f051095e58b5281aea8c1cd22bfc0e3"
|
||||
|
|
|
@ -178,8 +178,8 @@ type SearchResult struct {
|
|||
}
|
||||
|
||||
type ClientCert struct {
|
||||
Cert []byte
|
||||
Key []byte
|
||||
Cert string
|
||||
Key string
|
||||
}
|
||||
|
||||
type FetchMessages struct {
|
||||
|
|
|
@ -2938,19 +2938,9 @@ func easyjson42239ddeDecodeGithubComKhliengDispatchServer26(in *jlexer.Lexer, ou
|
|||
}
|
||||
switch key {
|
||||
case "cert":
|
||||
if in.IsNull() {
|
||||
in.Skip()
|
||||
out.Cert = nil
|
||||
} else {
|
||||
out.Cert = in.Bytes()
|
||||
}
|
||||
out.Cert = string(in.String())
|
||||
case "key":
|
||||
if in.IsNull() {
|
||||
in.Skip()
|
||||
out.Key = nil
|
||||
} else {
|
||||
out.Key = in.Bytes()
|
||||
}
|
||||
out.Key = string(in.String())
|
||||
default:
|
||||
in.SkipRecursive()
|
||||
}
|
||||
|
@ -2965,7 +2955,7 @@ func easyjson42239ddeEncodeGithubComKhliengDispatchServer26(out *jwriter.Writer,
|
|||
out.RawByte('{')
|
||||
first := true
|
||||
_ = first
|
||||
if len(in.Cert) != 0 {
|
||||
if in.Cert != "" {
|
||||
const prefix string = ",\"cert\":"
|
||||
if first {
|
||||
first = false
|
||||
|
@ -2973,9 +2963,9 @@ func easyjson42239ddeEncodeGithubComKhliengDispatchServer26(out *jwriter.Writer,
|
|||
} else {
|
||||
out.RawString(prefix)
|
||||
}
|
||||
out.Base64Bytes(in.Cert)
|
||||
out.String(string(in.Cert))
|
||||
}
|
||||
if len(in.Key) != 0 {
|
||||
if in.Key != "" {
|
||||
const prefix string = ",\"key\":"
|
||||
if first {
|
||||
first = false
|
||||
|
@ -2983,7 +2973,7 @@ func easyjson42239ddeEncodeGithubComKhliengDispatchServer26(out *jwriter.Writer,
|
|||
} else {
|
||||
out.RawString(prefix)
|
||||
}
|
||||
out.Base64Bytes(in.Key)
|
||||
out.String(string(in.Key))
|
||||
}
|
||||
out.RawByte('}')
|
||||
}
|
||||
|
|
|
@ -249,7 +249,7 @@ func (h *wsHandler) cert(b []byte) {
|
|||
var data ClientCert
|
||||
data.UnmarshalJSON(b)
|
||||
|
||||
err := h.state.user.SetCertificate(data.Cert, data.Key)
|
||||
err := h.state.user.SetCertificate([]byte(data.Cert), []byte(data.Key))
|
||||
if err != nil {
|
||||
h.state.sendJSON("cert_fail", Error{Message: err.Error()})
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue