Send appId with WikiTree requests

This commit is contained in:
Przemek Więch 2023-05-01 00:33:33 +02:00
parent 9f673a1472
commit cbe0d0f393
3 changed files with 20 additions and 16 deletions

14
package-lock.json generated
View File

@ -40,7 +40,7 @@
"topola": "^3.6.1",
"turbocommons-ts": "^3.8.0",
"unified": "^10.1.0",
"wikitree-js": "^0.1.0"
"wikitree-js": "^0.4.0"
},
"devDependencies": {
"@types/array.prototype.flatmap": "^1.2.2",
@ -25403,9 +25403,9 @@
"dev": true
},
"node_modules/wikitree-js": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/wikitree-js/-/wikitree-js-0.1.0.tgz",
"integrity": "sha512-ztMf+tAAO6/4GofAqhBYL3iMlMqYraI3/pYn8qWpaa2feLYJU5rjMJaIPACaJaBHjXOUTaOR0NSQ46drObjzhA==",
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/wikitree-js/-/wikitree-js-0.4.0.tgz",
"integrity": "sha512-ZNlXbm9RiLQ0oZ7m4CotsYafeQ4YKJuRdxC/OcjjSvhVf16nAhocw5fTjhMBq9EKnXvK5+F7+k+nULdQFXDyIg==",
"dependencies": {
"cross-fetch": "^3.1.5",
"form-data": "^4.0.0",
@ -46170,9 +46170,9 @@
"dev": true
},
"wikitree-js": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/wikitree-js/-/wikitree-js-0.1.0.tgz",
"integrity": "sha512-ztMf+tAAO6/4GofAqhBYL3iMlMqYraI3/pYn8qWpaa2feLYJU5rjMJaIPACaJaBHjXOUTaOR0NSQ46drObjzhA==",
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/wikitree-js/-/wikitree-js-0.4.0.tgz",
"integrity": "sha512-ZNlXbm9RiLQ0oZ7m4CotsYafeQ4YKJuRdxC/OcjjSvhVf16nAhocw5fTjhMBq9EKnXvK5+F7+k+nULdQFXDyIg==",
"requires": {
"cross-fetch": "^3.1.5",
"form-data": "^4.0.0",

View File

@ -35,7 +35,7 @@
"topola": "^3.6.1",
"turbocommons-ts": "^3.8.0",
"unified": "^10.1.0",
"wikitree-js": "^0.1.0"
"wikitree-js": "^0.4.0"
},
"devDependencies": {
"@types/array.prototype.flatmap": "^1.2.2",

View File

@ -23,6 +23,8 @@ import {
Person,
} from 'wikitree-js';
const WIKITREE_APP_ID = 'topola-viewer';
/** Prefix for IDs of private individuals. */
export const PRIVATE_ID_PREFIX = '~Private';
@ -46,12 +48,15 @@ function setSessionStorageItem(key: string, value: string) {
}
function getApiOptions(handleCors: boolean) {
return handleCors
return Object.assign(
{appId: WIKITREE_APP_ID},
handleCors
? {
apiUrl:
'https://topola-cors-server.up.railway.app/https://api.wikitree.com/api.php',
}
: {};
: {},
);
}
/**
@ -128,7 +133,7 @@ export async function loadWikiTree(
const handleCors = window.location.hostname !== 'apps.wikitree.com';
if (!handleCors && !getLoggedInUserName() && authcode) {
const loginResult = await clientLogin(authcode);
const loginResult = await clientLogin(authcode, {appId: WIKITREE_APP_ID});
if (loginResult.result === 'Success') {
sessionStorage.clear();
}
@ -826,4 +831,3 @@ export class WikiTreeDataSource implements DataSource<WikiTreeSourceSpec> {
}
}
}