diff --git a/src/stores/useHoloStore.js b/src/stores/useHoloStore.js index 77044be..e0eb2e3 100644 --- a/src/stores/useHoloStore.js +++ b/src/stores/useHoloStore.js @@ -17,7 +17,6 @@ const makeUseHoloStore = ({ connectionArgs, MockWebSdk, addClientToWindow }) => appInfo: null, }), getters: { - // isAnonymous: state => state?.agentState?.isAnonymous === undefined ? true : state.agentState.isAnonymous, isAnonymous: state => state?.agentState?.isAnonymous, isAvailable: state => state.agentState && state.agentState.isAvailable, isLoggedIn: state => state.agentState && state.agentState.isAnonymous === false && state.agentState.isAvailable === true, diff --git a/src/stores/useHolochainStore.js b/src/stores/useHolochainStore.js index e9d402f..52a1655 100644 --- a/src/stores/useHolochainStore.js +++ b/src/stores/useHolochainStore.js @@ -86,7 +86,7 @@ const makeUseHolochainStore = ({ installed_app_id, app_ws_url, hc_admin_port }) }, // END useInterfaceStore methods - // BEGIN holo specific methods + // BEGIN holochain specific methods async holochainCallZome(args) { const { zome_name, fn_name, payload, role_name } = args diff --git a/src/utils/registration.ts b/src/utils/registration.js similarity index 78% rename from src/utils/registration.ts rename to src/utils/registration.js index e1fa882..6480fbb 100644 --- a/src/utils/registration.ts +++ b/src/utils/registration.js @@ -6,24 +6,25 @@ import * as msgpack from '@msgpack/msgpack' // In either case, the membrane_proof is assumed to be the original element, msgpack encoded and then encoded as a base64 string // Envoy expects the msgpack encoded data, so we decode the base64 string before passing it to Envoy -export type GetMembraneProofInput = { - registration_code: string, - membrane_proof_server_url?: string, // the presence or absence of the url changes the behavior of the function - membrane_proof_server_payload: string, - agent_id: string, - email: string -} +// export type GetMembraneProofInput = { +// registration_code: string, +// membrane_proof_server_url?: string, // the presence or absence of the url changes the behavior of the function +// membrane_proof_server_payload: string, +// agent_id: string, +// email: string +// } -export type MembraneProof = Buffer +// export type MembraneProof = Buffer // Mostly for internal use and testing. You probably want getMembraneProof below +// GetMembraneProofInput -> Promise export async function getBase64EncodedMembraneProof ({ registration_code, membrane_proof_server_url, membrane_proof_server_payload, agent_id, email -}: GetMembraneProofInput): Promise { +}) { if (!registration_code) { throw new Error('No registration code provided') } @@ -62,7 +63,7 @@ export async function getBase64EncodedMembraneProof ({ }) data = await resp.json() - } catch (e: any) { + } catch (e) { throw new Error(`Membrane Proof Server network error: ${e?.message}`) } @@ -73,11 +74,13 @@ export async function getBase64EncodedMembraneProof ({ return data.mem_proof } -export async function getMembraneProof (input: GetMembraneProofInput): Promise { +// GetMembraneProofInput -> Promise +export async function getMembraneProof (input) { return Buffer.from(await getBase64EncodedMembraneProof(input), 'base64') } -export function generateUnusedMemproof (): Buffer { +// () -> Buffer +export function generateUnusedMemproof () { return Buffer.from(msgpack.encode(process.env.UNUSED_MEMPROOF)) }