aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/anastasis-core/rollup.config.js28
-rw-r--r--packages/anastasis-core/src/index.ts14
-rw-r--r--packages/anastasis-core/src/reducer-types.ts5
3 files changed, 46 insertions, 1 deletions
diff --git a/packages/anastasis-core/rollup.config.js b/packages/anastasis-core/rollup.config.js
index 59998c93b..a9af1d3b5 100644
--- a/packages/anastasis-core/rollup.config.js
+++ b/packages/anastasis-core/rollup.config.js
@@ -5,7 +5,7 @@ import json from "@rollup/plugin-json";
import builtins from "builtin-modules";
import sourcemaps from "rollup-plugin-sourcemaps";
-export default {
+const cli = {
input: "lib/index.node.js",
output: {
file: "dist/anastasis-cli.js",
@@ -28,3 +28,29 @@ export default {
json(),
],
};
+
+const standalone = {
+ input: "lib/cli-entry.js",
+ output: {
+ file: "dist/anastasis-cli-standalone.js",
+ format: "es",
+ sourcemap: true,
+ },
+ external: [...builtins, "source-map-support"],
+ plugins: [
+ nodeResolve({
+ preferBuiltins: true,
+ }),
+
+ sourcemaps(),
+
+ commonjs({
+ sourceMap: true,
+ transformMixedEsModules: true,
+ }),
+
+ json(),
+ ],
+};
+
+export default [standalone, cli];
diff --git a/packages/anastasis-core/src/index.ts b/packages/anastasis-core/src/index.ts
index 53364fc08..f2b8ff1d1 100644
--- a/packages/anastasis-core/src/index.ts
+++ b/packages/anastasis-core/src/index.ts
@@ -62,6 +62,7 @@ import {
codecForActionArgsChangeVersion,
ActionArgsChangeVersion,
TruthMetaData,
+ ActionArgsUpdatePolicy,
} from "./reducer-types.js";
import fetchPonyfill from "fetch-ponyfill";
import {
@@ -1038,6 +1039,18 @@ async function deletePolicy(
};
}
+async function updatePolicy(
+ state: ReducerStateBackup,
+ args: ActionArgsUpdatePolicy,
+): Promise<ReducerStateBackup> {
+ const policies = [...(state.policies ?? [])];
+ policies[args.policy_index] = { methods: args.policy };
+ return {
+ ...state,
+ policies,
+ };
+}
+
async function addPolicy(
state: ReducerStateBackup,
args: ActionArgsAddPolicy,
@@ -1230,6 +1243,7 @@ const backupTransitions: Record<
...transitionBackupJump("next", BackupStates.SecretEditing),
...transition("add_policy", codecForActionArgsAddPolicy(), addPolicy),
...transition("delete_policy", codecForAny(), deletePolicy),
+ ...transition("update_policy", codecForAny(), updatePolicy),
},
[BackupStates.SecretEditing]: {
...transitionBackupJump("back", BackupStates.PoliciesReviewing),
diff --git a/packages/anastasis-core/src/reducer-types.ts b/packages/anastasis-core/src/reducer-types.ts
index 56b27898e..e5b0c47a4 100644
--- a/packages/anastasis-core/src/reducer-types.ts
+++ b/packages/anastasis-core/src/reducer-types.ts
@@ -418,6 +418,11 @@ export interface ActionArgsChangeVersion {
version: number;
}
+export interface ActionArgsUpdatePolicy {
+ policy_index: number;
+ policy: PolicyMember[];
+}
+
export const codecForActionArgsChangeVersion = () =>
buildCodecForObject<ActionArgsChangeVersion>()
.property("provider_url", codecForString())