@moneypot/hub 1.13.0 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -76,6 +76,10 @@ insert into hub.api_key default values returning key;
|
|
|
76
76
|
|
|
77
77
|
## Changelog
|
|
78
78
|
|
|
79
|
+
### 1.14.x
|
|
80
|
+
|
|
81
|
+
- Added `preimageHash` field to `HubHashChain` to expose the preimage hash for a hash chain if it's revealed.
|
|
82
|
+
|
|
79
83
|
### 1.13.x
|
|
80
84
|
|
|
81
85
|
- Added `hubRevealHashChain` mutation to generate a preimage hash for the chain and mark it as inactive.
|
package/dist/src/config.js
CHANGED
|
@@ -106,7 +106,7 @@ export const HASHCHAINSERVER_URL = getEnvVariable("HASHCHAINSERVER_URL", (value)
|
|
|
106
106
|
return value;
|
|
107
107
|
});
|
|
108
108
|
export const HASHCHAINSERVER_MAX_ITERATIONS = getEnvVariable("HASHCHAINSERVER_MAX_ITERATIONS", (value) => {
|
|
109
|
-
const iterations = Number.parseInt(value, 10) ||
|
|
109
|
+
const iterations = Number.parseInt(value, 10) || 100;
|
|
110
110
|
assert(iterations >= 10, "HASHCHAINSERVER_MAX_ITERATIONS must be >= 10");
|
|
111
111
|
return iterations;
|
|
112
112
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const HubPreimageHashFieldPlugin: GraphileConfig.Plugin;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { withPgClient } from "postgraphile/@dataplan/pg";
|
|
2
|
+
import { inhibitOnNull, object } from "postgraphile/grafast";
|
|
3
|
+
import { gql, makeExtendSchemaPlugin } from "postgraphile/utils";
|
|
4
|
+
import { maybeOneRow } from "../../db/util.js";
|
|
5
|
+
export const HubPreimageHashFieldPlugin = makeExtendSchemaPlugin((build) => {
|
|
6
|
+
const hashTable = build.input.pgRegistry.pgResources.hub_hash;
|
|
7
|
+
return {
|
|
8
|
+
typeDefs: gql `
|
|
9
|
+
extend type HubHashChain {
|
|
10
|
+
preimageHash: HubHash
|
|
11
|
+
}
|
|
12
|
+
`,
|
|
13
|
+
objects: {
|
|
14
|
+
HubHashChain: {
|
|
15
|
+
plans: {
|
|
16
|
+
preimageHash: ($record) => {
|
|
17
|
+
const $preimageHashId = withPgClient(hashTable.executor, object({ hashChainId: $record.get("id") }), async (pgClient, { hashChainId }) => {
|
|
18
|
+
const hash = await pgClient
|
|
19
|
+
.query({
|
|
20
|
+
text: `
|
|
21
|
+
select id
|
|
22
|
+
from hub.hash
|
|
23
|
+
where hash_chain_id = $1
|
|
24
|
+
and kind = 'PREIMAGE'
|
|
25
|
+
`,
|
|
26
|
+
values: [hashChainId],
|
|
27
|
+
})
|
|
28
|
+
.then(maybeOneRow);
|
|
29
|
+
return hash?.id ?? null;
|
|
30
|
+
});
|
|
31
|
+
return hashTable.get({ id: inhibitOnNull($preimageHashId) });
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
});
|
|
@@ -24,6 +24,7 @@ import { HubUserActiveHashChainPlugin } from "../hash-chain/plugins/hub-user-act
|
|
|
24
24
|
import { HubOutcomeInputNonNullFieldsPlugin } from "../plugins/hub-outcome-input-non-null-fields.js";
|
|
25
25
|
import { HubPutAlertPlugin } from "../plugins/hub-put-alert.js";
|
|
26
26
|
import { HubRevealHashChainPlugin } from "../hash-chain/plugins/hub-reveal-hash-chain.js";
|
|
27
|
+
import { HubPreimageHashFieldPlugin } from "../hash-chain/plugins/hub-preimage-hash-field.js";
|
|
27
28
|
export const requiredPlugins = [
|
|
28
29
|
SmartTagsPlugin,
|
|
29
30
|
IdToNodeIdPlugin,
|
|
@@ -44,6 +45,7 @@ export const defaultPlugins = [
|
|
|
44
45
|
HubCreateHashChainPlugin,
|
|
45
46
|
HubUserActiveHashChainPlugin,
|
|
46
47
|
HubRevealHashChainPlugin,
|
|
48
|
+
HubPreimageHashFieldPlugin,
|
|
47
49
|
customPgOmitArchivedPlugin("deleted"),
|
|
48
50
|
];
|
|
49
51
|
export function createPreset({ plugins, exportSchemaSDLPath, extraPgSchemas, abortSignal, context, }) {
|