You've already forked hotpocket
BTHLABS-50: Safari Web Extension: Reloaded
Turns out, getting this thing out into the wild isn't as simple as I thought :D Co-authored-by: Tomek Wójcik <labs@tomekwojcik.pl> Co-committed-by: Tomek Wójcik <labs@tomekwojcik.pl>
This commit is contained in:
@@ -66,6 +66,10 @@ const manifestJsonOutputPlugin = () => {
|
||||
|
||||
result.version = packageJSON.version;
|
||||
|
||||
if (IS_PRODUCTION === false) {
|
||||
result.name = 'HotPocket Development';
|
||||
}
|
||||
|
||||
return JSON.stringify(result, null, 2);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -29,9 +29,12 @@ const executeJSONRPCCall = async (url, call, {accessToken}) => {
|
||||
let result = null;
|
||||
let error = null;
|
||||
|
||||
const effectiveURL = new URL(url);
|
||||
effectiveURL.searchParams.append('method', call.method);
|
||||
|
||||
try {
|
||||
const response = await fetch(
|
||||
url,
|
||||
effectiveURL.toString(),
|
||||
{
|
||||
body: JSON.stringify(call),
|
||||
credentials: 'include',
|
||||
@@ -78,6 +81,13 @@ const executeJSONRPCCall = async (url, call, {accessToken}) => {
|
||||
return [result, error];
|
||||
};
|
||||
|
||||
const getAccessTokenMeta = () => {
|
||||
return {
|
||||
platform: navigator.platform,
|
||||
version: HotPocketExtension.version,
|
||||
};
|
||||
};
|
||||
|
||||
const doSave = async (accessToken, tab) => {
|
||||
const call = makeJSONRPCCall('saves.create', [tab.url]);
|
||||
const [result, error] = await executeJSONRPCCall(RPC_URL, call, {accessToken});
|
||||
@@ -97,10 +107,7 @@ const doCreateAndStoreAccessToken = async (authKey) => {
|
||||
'accounts.access_tokens.create',
|
||||
[
|
||||
authKey,
|
||||
{
|
||||
platform: navigator.platform,
|
||||
version: HotPocketExtension.version,
|
||||
},
|
||||
getAccessTokenMeta(),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -163,7 +170,10 @@ const doCheckAuth = async (accessToken) => {
|
||||
return null;
|
||||
}
|
||||
|
||||
const call = makeJSONRPCCall('accounts.auth.check');
|
||||
const call = makeJSONRPCCall(
|
||||
'accounts.auth.check_access_token',
|
||||
[accessToken, getAccessTokenMeta()],
|
||||
);
|
||||
|
||||
const [result, error] = await executeJSONRPCCall(RPC_URL, call, {
|
||||
accessToken,
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
"scripts": [
|
||||
"background-bundle.js"
|
||||
],
|
||||
"type": "module"
|
||||
"type": "module",
|
||||
"persistent": false
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user