copyright headers
This commit is contained in:
parent
1e92093a50
commit
f3d8b44743
@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
This file is part of GNU Anastasis
|
||||||
|
(C) 2021-2022 Anastasis SARL
|
||||||
|
|
||||||
|
GNU Anastasis is free software; you can redistribute it and/or modify it under the
|
||||||
|
terms of the GNU Affero General Public License as published by the Free Software
|
||||||
|
Foundation; either version 3, or (at your option) any later version.
|
||||||
|
|
||||||
|
GNU Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License along with
|
||||||
|
GNU Anastasis; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*/
|
||||||
|
|
||||||
import {
|
import {
|
||||||
canonicalJson,
|
canonicalJson,
|
||||||
decodeCrock,
|
decodeCrock,
|
||||||
|
@ -74,6 +74,7 @@ import {
|
|||||||
DiscoveryResult,
|
DiscoveryResult,
|
||||||
PolicyMetaInfo,
|
PolicyMetaInfo,
|
||||||
ChallengeInfo,
|
ChallengeInfo,
|
||||||
|
AggregatedPolicyMetaInfo,
|
||||||
} from "./reducer-types.js";
|
} from "./reducer-types.js";
|
||||||
import fetchPonyfill from "fetch-ponyfill";
|
import fetchPonyfill from "fetch-ponyfill";
|
||||||
import {
|
import {
|
||||||
@ -1451,6 +1452,37 @@ async function updateSecretExpiration(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function mergeDiscoveryAggregate(
|
||||||
|
newPolicies: PolicyMetaInfo[],
|
||||||
|
oldAgg: AggregatedPolicyMetaInfo[],
|
||||||
|
): AggregatedPolicyMetaInfo[] {
|
||||||
|
const aggregatedPolicies: AggregatedPolicyMetaInfo[] = [...oldAgg] ?? [];
|
||||||
|
const polHashToIndex: Record<string, number> = {};
|
||||||
|
for (const pol of newPolicies) {
|
||||||
|
const oldIndex = polHashToIndex[pol.policy_hash];
|
||||||
|
if (oldIndex != null) {
|
||||||
|
aggregatedPolicies[oldIndex].providers.push({
|
||||||
|
provider_url: pol.provider_url,
|
||||||
|
version: pol.version,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
aggregatedPolicies.push({
|
||||||
|
attribute_mask: pol.attribute_mask,
|
||||||
|
policy_hash: pol.policy_hash,
|
||||||
|
providers: [
|
||||||
|
{
|
||||||
|
provider_url: pol.provider_url,
|
||||||
|
version: pol.version,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
secret_name: pol.secret_name,
|
||||||
|
});
|
||||||
|
polHashToIndex[pol.policy_hash] = aggregatedPolicies.length - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return aggregatedPolicies;
|
||||||
|
}
|
||||||
|
|
||||||
const backupTransitions: Record<
|
const backupTransitions: Record<
|
||||||
BackupStates,
|
BackupStates,
|
||||||
Transition<ReducerStateBackup>
|
Transition<ReducerStateBackup>
|
||||||
|
@ -1,7 +1,21 @@
|
|||||||
|
/*
|
||||||
|
This file is part of GNU Anastasis
|
||||||
|
(C) 2021-2022 Anastasis SARL
|
||||||
|
|
||||||
|
GNU Anastasis is free software; you can redistribute it and/or modify it under the
|
||||||
|
terms of the GNU Affero General Public License as published by the Free Software
|
||||||
|
Foundation; either version 3, or (at your option) any later version.
|
||||||
|
|
||||||
|
GNU Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License along with
|
||||||
|
GNU Anastasis; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*/
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Amounts,
|
|
||||||
AmountString,
|
AmountString,
|
||||||
TalerProtocolDuration,
|
|
||||||
TalerProtocolTimestamp,
|
TalerProtocolTimestamp,
|
||||||
} from "@gnu-taler/taler-util";
|
} from "@gnu-taler/taler-util";
|
||||||
|
|
||||||
|
@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
This file is part of GNU Anastasis
|
||||||
|
(C) 2021-2022 Anastasis SARL
|
||||||
|
|
||||||
|
GNU Anastasis is free software; you can redistribute it and/or modify it under the
|
||||||
|
terms of the GNU Affero General Public License as published by the Free Software
|
||||||
|
Foundation; either version 3, or (at your option) any later version.
|
||||||
|
|
||||||
|
GNU Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License along with
|
||||||
|
GNU Anastasis; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*/
|
||||||
|
|
||||||
import {
|
import {
|
||||||
AmountString,
|
AmountString,
|
||||||
buildCodecForObject,
|
buildCodecForObject,
|
||||||
|
@ -15,31 +15,31 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Sebastian Javier Marchano (sebasjm)
|
* @author Sebastian Javier Marchano (sebasjm)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { DefinePlugin } from 'webpack';
|
import { DefinePlugin } from "webpack";
|
||||||
|
|
||||||
import pack from './package.json';
|
import pack from "./package.json";
|
||||||
import * as cp from 'child_process';
|
import * as cp from "child_process";
|
||||||
|
|
||||||
const commitHash = cp.execSync('git rev-parse --short HEAD').toString();
|
const commitHash = cp.execSync("git rev-parse --short HEAD").toString();
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
webpack(config, env, helpers) {
|
webpack(config, env, helpers) {
|
||||||
// add __VERSION__ to be use in the html
|
// add __VERSION__ to be use in the html
|
||||||
config.plugins.push(
|
config.plugins.push(
|
||||||
new DefinePlugin({
|
new DefinePlugin({
|
||||||
'process.env.__VERSION__': JSON.stringify(env.isProd ? pack.version : `dev-${commitHash}`),
|
"process.env.__VERSION__": JSON.stringify(
|
||||||
|
env.isProd ? pack.version : `dev-${commitHash}`,
|
||||||
|
),
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
const crittersWrapper = helpers.getPluginsByName(config, 'Critters')
|
const crittersWrapper = helpers.getPluginsByName(config, "Critters");
|
||||||
if (crittersWrapper && crittersWrapper.length > 0) {
|
if (crittersWrapper && crittersWrapper.length > 0) {
|
||||||
const [{ index }] = crittersWrapper
|
const [{ index }] = crittersWrapper;
|
||||||
config.plugins.splice(index, 1)
|
config.plugins.splice(index, 1);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
}
|
};
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -51,6 +51,14 @@ export function NavigationBar({ onMobileMenu, title }: Props): VNode {
|
|||||||
>
|
>
|
||||||
Report a bug
|
Report a bug
|
||||||
</a>
|
</a>
|
||||||
|
<a
|
||||||
|
style={{
|
||||||
|
alignSelf: "center",
|
||||||
|
padding: "0.5em",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Settings
|
||||||
|
</a>
|
||||||
{/* <a
|
{/* <a
|
||||||
role="button"
|
role="button"
|
||||||
class="navbar-burger"
|
class="navbar-burger"
|
||||||
|
@ -6,6 +6,7 @@ import {
|
|||||||
DiscoveryCursor,
|
DiscoveryCursor,
|
||||||
getBackupStartState,
|
getBackupStartState,
|
||||||
getRecoveryStartState,
|
getRecoveryStartState,
|
||||||
|
mergeDiscoveryAggregate,
|
||||||
PolicyMetaInfo,
|
PolicyMetaInfo,
|
||||||
RecoveryStates,
|
RecoveryStates,
|
||||||
reduceAction,
|
reduceAction,
|
||||||
@ -255,30 +256,7 @@ export function useAnastasisReducer(): AnastasisReducerApi {
|
|||||||
},
|
},
|
||||||
async discoverStart(): Promise<void> {
|
async discoverStart(): Promise<void> {
|
||||||
const res = await discoverPolicies(this.currentReducerState!, undefined);
|
const res = await discoverPolicies(this.currentReducerState!, undefined);
|
||||||
const aggregatedPolicies: AggregatedPolicyMetaInfo[] = [];
|
const aggregatedPolicies = mergeDiscoveryAggregate(res.policies, []);
|
||||||
const polHashToIndex: Record<string, number> = {};
|
|
||||||
for (const pol of res.policies) {
|
|
||||||
const oldIndex = polHashToIndex[pol.policy_hash];
|
|
||||||
if (oldIndex != null) {
|
|
||||||
aggregatedPolicies[oldIndex].providers.push({
|
|
||||||
provider_url: pol.provider_url,
|
|
||||||
version: pol.version,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
aggregatedPolicies.push({
|
|
||||||
attribute_mask: pol.attribute_mask,
|
|
||||||
policy_hash: pol.policy_hash,
|
|
||||||
providers: [
|
|
||||||
{
|
|
||||||
provider_url: pol.provider_url,
|
|
||||||
version: pol.version,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
secret_name: pol.secret_name,
|
|
||||||
});
|
|
||||||
polHashToIndex[pol.policy_hash] = aggregatedPolicies.length - 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setAnastasisState({
|
setAnastasisState({
|
||||||
...anastasisState,
|
...anastasisState,
|
||||||
discoveryState: {
|
discoveryState: {
|
||||||
|
@ -34,14 +34,31 @@ const Context = createContext<Type>({
|
|||||||
|
|
||||||
export const useDevContext = (): Type => useContext(Context);
|
export const useDevContext = (): Type => useContext(Context);
|
||||||
|
|
||||||
export const DevContextProviderForTesting = ({ value, children }: { value: boolean, children: any }): VNode => {
|
export const DevContextProviderForTesting = ({
|
||||||
return h(Context.Provider, { value: { devMode: value, toggleDevMode: () => { null } }, children });
|
value,
|
||||||
|
children,
|
||||||
|
}: {
|
||||||
|
value: boolean;
|
||||||
|
children: any;
|
||||||
|
}): VNode => {
|
||||||
|
return h(Context.Provider, {
|
||||||
|
value: {
|
||||||
|
devMode: value,
|
||||||
|
toggleDevMode: () => {
|
||||||
|
null;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
children,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const DevContextProvider = ({ children }: { children: any }): VNode => {
|
export const DevContextProvider = ({ children }: { children: any }): VNode => {
|
||||||
const [value, setter] = useLocalStorage("devMode");
|
const [value, setter] = useLocalStorage("devMode");
|
||||||
const devMode = value === "true";
|
const devMode = value === "true";
|
||||||
const toggleDevMode = (): void => setter((v) => (!v ? "true" : undefined));
|
const toggleDevMode = (): void => setter((v) => (!v ? "true" : undefined));
|
||||||
children = children.length === 1 && typeof children === "function" ? children({ devMode }) : children;
|
children =
|
||||||
|
children.length === 1 && typeof children === "function"
|
||||||
|
? children({ devMode })
|
||||||
|
: children;
|
||||||
return h(Context.Provider, { value: { devMode, toggleDevMode }, children });
|
return h(Context.Provider, { value: { devMode, toggleDevMode }, children });
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user