mirror of
https://github.com/actualbudget/actual.git
synced 2026-03-11 12:43:09 -05:00
Compare commits
1 Commits
Transactio
...
alert-auto
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a85be7d2b7 |
@@ -310,13 +310,26 @@ function parseAccessKey(accessKey) {
|
|||||||
|
|
||||||
async function getAccessKey(base64Token) {
|
async function getAccessKey(base64Token) {
|
||||||
const token = Buffer.from(base64Token, 'base64').toString();
|
const token = Buffer.from(base64Token, 'base64').toString();
|
||||||
|
|
||||||
|
// Allowlist of trusted base URLs
|
||||||
|
const allowedBaseUrls = ['https://api.simplefin.com', 'https://secure.simplefin.com'];
|
||||||
|
let tokenUrl;
|
||||||
|
try {
|
||||||
|
tokenUrl = new URL(token);
|
||||||
|
if (!allowedBaseUrls.some(base => tokenUrl.href.startsWith(base))) {
|
||||||
|
throw new Error('Invalid token URL');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
throw new Error('Malformed or untrusted token URL');
|
||||||
|
}
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
port: 443,
|
port: 443,
|
||||||
headers: { 'Content-Length': 0 },
|
headers: { 'Content-Length': 0 },
|
||||||
};
|
};
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const req = https.request(new URL(token), options, res => {
|
const req = https.request(tokenUrl, options, res => {
|
||||||
res.on('data', d => {
|
res.on('data', d => {
|
||||||
resolve(d.toString());
|
resolve(d.toString());
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user