@wovin/core 0.0.4 → 0.0.6
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/dist/applog/applog-helpers.d.ts +4 -4
- package/dist/applog/applog-helpers.d.ts.map +1 -1
- package/dist/applog.min.js +1 -1
- package/dist/chunk-5Q6PAAMY.min.js +2 -0
- package/dist/chunk-5Q6PAAMY.min.js.map +1 -0
- package/dist/chunk-BR5DELY4.min.js +2 -0
- package/dist/chunk-BR5DELY4.min.js.map +1 -0
- package/dist/chunk-D6REGRIL.min.js +2 -0
- package/dist/chunk-D6REGRIL.min.js.map +1 -0
- package/dist/{chunk-WNS2N7XB.min.js → chunk-IVEP7DZW.min.js} +21 -21
- package/dist/{chunk-WNS2N7XB.min.js.map → chunk-IVEP7DZW.min.js.map} +1 -1
- package/dist/{chunk-UZUBJLQD.min.js → chunk-J5PGGKKW.min.js} +2 -2
- package/dist/{chunk-UZUBJLQD.min.js.map → chunk-J5PGGKKW.min.js.map} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/ipfs/car.d.ts.map +1 -1
- package/dist/ipfs.min.js +1 -1
- package/dist/mobx/mobx-utils.d.ts +6 -6
- package/dist/mobx/mobx-utils.d.ts.map +1 -1
- package/dist/pubsub/publication.d.ts +2 -2
- package/dist/pubsub/publication.d.ts.map +1 -1
- package/dist/pubsub.min.js +1 -1
- package/dist/query/basic.d.ts +19 -19
- package/dist/query/basic.d.ts.map +1 -1
- package/dist/query/divergences.d.ts +5 -5
- package/dist/query/divergences.d.ts.map +1 -1
- package/dist/query.min.js +1 -1
- package/dist/thread/basic.d.ts +36 -0
- package/dist/thread/basic.d.ts.map +1 -0
- package/dist/thread/filters.d.ts +38 -0
- package/dist/thread/filters.d.ts.map +1 -0
- package/dist/thread/mapped.d.ts +19 -0
- package/dist/thread/mapped.d.ts.map +1 -0
- package/dist/thread/writeable.d.ts +17 -0
- package/dist/thread/writeable.d.ts.map +1 -0
- package/dist/thread.d.ts +5 -0
- package/dist/thread.d.ts.map +1 -0
- package/dist/thread.min.js +2 -0
- package/dist/types/typescript-utils.d.ts +2 -2
- package/dist/types/typescript-utils.d.ts.map +1 -1
- package/dist/types.min.js +1 -1
- package/package.json +4 -4
- package/dist/chunk-2UCPKUQK.min.js +0 -1256
- package/dist/chunk-2UCPKUQK.min.js.map +0 -1
- package/dist/chunk-3HUXODLY.min.js +0 -11940
- package/dist/chunk-3HUXODLY.min.js.map +0 -1
- package/dist/chunk-KBXBNPCO.min.js +0 -2
- package/dist/chunk-KBXBNPCO.min.js.map +0 -1
- package/dist/chunk-N7GKIL5T.min.js +0 -120
- package/dist/chunk-N7GKIL5T.min.js.map +0 -1
- package/dist/chunk-PVULNVU2.min.js +0 -49
- package/dist/chunk-PVULNVU2.min.js.map +0 -1
- package/dist/chunk-VTXN7J7O.min.js +0 -66
- package/dist/chunk-VTXN7J7O.min.js.map +0 -1
- package/dist/chunk-W7B2PDHK.min.js +0 -2
- package/dist/chunk-W7B2PDHK.min.js.map +0 -1
- package/dist/chunk-WCOT2GIF.min.js +0 -2
- package/dist/chunk-WCOT2GIF.min.js.map +0 -1
- package/dist/chunk-WOD425XV.min.js +0 -4401
- package/dist/chunk-WOD425XV.min.js.map +0 -1
- package/dist/stream/basic.d.ts +0 -36
- package/dist/stream/basic.d.ts.map +0 -1
- package/dist/stream/filters.d.ts +0 -38
- package/dist/stream/filters.d.ts.map +0 -1
- package/dist/stream/mapped.d.ts +0 -19
- package/dist/stream/mapped.d.ts.map +0 -1
- package/dist/stream/writeable.d.ts +0 -17
- package/dist/stream/writeable.d.ts.map +0 -1
- package/dist/stream.d.ts +0 -5
- package/dist/stream.d.ts.map +0 -1
- package/dist/stream.min.js +0 -2
- /package/dist/{stream.min.js.map → thread.min.js.map} +0 -0
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{d as f}from"./chunk-UZUBJLQD.min.js";import{I as w,K as D,ga as x,v as I}from"./chunk-WNS2N7XB.min.js";import{c as m,l as C,q as c}from"./chunk-G3GOAFHU.min.js";var{WARN:H,LOG:W,DEBUG:i,VERBOSE:U,ERROR:h}=m.setup(m.DEBUG);async function M(t,n,e,p){let o=w(e),{sharedAgents:l,sharedKeyMap:d,sharedKey:s}=p??{},a=D(x(n),{en:t.ag,at:["agent/ecdh","agent/jwkd","agent/appAgent"]}).applogs;if(i("[preparePubForPush] agent logs:",a),!a.find(({at:r})=>r==="agent/appAgent"))throw h("[preparePubForPush] appStream missing agent/appAgent log");let u,y=async(r,P)=>{throw new Error("todo: enc")};i("[preparePubForPush] applogs ",o);let g;if(l){if(!s||!d)throw h("sharedAgents but no Keys/Map",{sharedAgents:l,sharedKeyMap:d,sharedKey:s});let r=[],P=[];for(let[A,S]of Array.from(d.entries()))P.push({ag:t.ag,en:A,at:"pub/sharedKey",vl:S});for(let A of o){U("[crypto] encrypting ",A);try{u=await y(A,s)}catch{}r.push(u)}g=r}else g=o;return K(t,g,a)}async function K(t,n,e){i("[encodePubAsCar] encoding",{agent:t,applogs:n,infoLogs:e});let{cids:p,encodedApplogs:o}=await b(e),{cids:l,encodedApplogs:d}=await b(n),s=await c({logs:p}),a=await c({logs:l}),u=await t.sign(s.bytes),y=await t.sign(a.bytes),g={info:s.cid,applogs:a.cid,infoSignature:u,applogsSignature:y};i("[encodePubAsCar] encoding root",{root:g,logCids:l,infoLogCids:p});let r=await c(g);return i("[encodePubAsCar] => root",{encodedRoot:r}),await f(r.cid,[r,s,a,...o,...d])}async function G(t){let{cids:n,encodedApplogs:e}=await b(t),o=await c({applogs:n});return i("[encodeApplogsAsCar] encoded root",{cids:n,encodedRoot:o}),await f(o.cid,[o,...e])}async function b(t){let n=t.map(o=>o instanceof Uint8Array?o:C(o)),e=await Promise.all(n.map(c));return i("[encodeApplogsAsIpld] encoded applogs",{encodedApplogs:e}),{cids:e.map(o=>{if(!o.cid)throw new h("[publish] no cid for encoded log:",o);return o.cid}),encodedApplogs:e}}function N(t){return t?.pk!==void 0&&t?.lastPush!==void 0}function V(t){return t?.lastPull!==void 0}function q(t){return I(t,31,7)}export{M as a,K as b,G as c,N as d,V as e,q as f};
|
|
2
|
-
//# sourceMappingURL=chunk-KBXBNPCO.min.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/pubsub/publication.ts","../src/pubsub/pubsub-types.ts"],"sourcesContent":["import { Logger } from 'besonders-logger'\nimport { stringify } from 'safe-stable-stringify'\nimport { cyrb53hash } from '../applog/applog-utils'\nimport { Applog, ApplogForInsert, EntityID } from '../applog/datom-types'\nimport { makeCarBlob } from '../ipfs/car'\nimport { encodeBlockOriginal, prepareForPub } from '../ipfs/ipfs-utils'\nimport { withoutHistory } from './../query/basic'\nimport { ApplogsOrStream, ApplogStream, getLogsFromStream } from '../stream'\nimport { rollingFilter } from '../stream/filters'\nimport { AppAgent, IPublication } from './pubsub-types'\n\nconst { WARN, LOG, DEBUG, VERBOSE, ERROR } = Logger.setup(Logger.DEBUG) // eslint-disable-line no-unused-vars\n\n// export const neverEncryptAttrs = [\n// \t'agent/jwkd',\n// \t'agent/appAgent',\n// \t'pub/encryptedFor',\n// \t'pub/sharedKey',\n// ]\n\nexport async function preparePubForPush(\n\tagent: AppAgent,\n\tappStream: ApplogStream,\n\tstreamToPublish: ApplogsOrStream,\n\tpublication: IPublication,\n) {\n\t// await initWasm()\n\t// const car_data = Wasm.make_car(applogs)\n\t// DEBUG('Car data:', car_data)\n\t// TODO prevent publish if there is no new info\n\tconst logsToPublish = getLogsFromStream(streamToPublish)\n\n\tconst { sharedAgents, sharedKeyMap, sharedKey } = publication ?? {}\n\t// TODO: publish all agents' info related to the logs we want to publish\n\tconst agentLogs = rollingFilter(withoutHistory(appStream), {\n\t\ten: agent.ag,\n\t\tat: ['agent/ecdh', 'agent/jwkd', 'agent/appAgent'],\n\t}).applogs\n\tDEBUG(`[preparePubForPush] agent logs:`, agentLogs)\n\tif (!agentLogs.find(({ at }) => at === 'agent/appAgent')) throw ERROR(`[preparePubForPush] appStream missing agent/appAgent log`)\n\tlet encPayload\n\tconst encryptAndTestDecrypt = async (applog: Applog, keyToUse: CryptoKey): Promise<Uint8Array> => {\n\t\tthrow new Error(`todo: enc`) // TODO: ENC\n\t\t// const eachLog = prepareForPub(applog) // without cid\n\t\t// const enc = new TextEncoder()\n\t\t// const stringified = stringify(eachLog)\n\t\t// const stringifiedEncodedAppLogPayload = enc.encode(stringified) // TODO: consider encodeToDagJson instead\n\t\t// VERBOSE('[odd]', { eachLog, stringified, stringifiedEncodedAppLogPayload })\n\n\t\t// try {\n\t\t// \tencPayload = await agent.crypto?.aes.encrypt(stringifiedEncodedAppLogPayload, keyToUse, SymmAlg.AES_GCM)\n\t\t// } catch (err) {\n\t\t// \tthrow ERROR('FAILED TO ENC payload length:', stringifiedEncodedAppLogPayload.length, { err })\n\t\t// }\n\n\t\t// const decrypted = await decryptWithAesSharedKey(encPayload, keyToUse, 'string')\n\n\t\t// VERBOSE('[odd] encrypted length:', stringifiedEncodedAppLogPayload.length, { encPayload, decrypted })\n\t\t// return encPayload\n\t}\n\tDEBUG('[preparePubForPush] applogs ', logsToPublish)\n\n\tlet maybeEncryptedApplogs: Uint8Array[] | readonly Applog[]\n\tif (sharedAgents) { // encrypt all Applogs\n\t\tif (!sharedKey || !sharedKeyMap) {\n\t\t\tthrow ERROR('sharedAgents but no Keys/Map', { sharedAgents, sharedKeyMap, sharedKey })\n\t\t}\n\t\tconst encryptedApplogs = [] as Uint8Array[]\n\t\tconst agentSharedKeyLogs = []\n\t\tfor (const [eachAgent, eachEncKey] of Array.from(sharedKeyMap.entries())) {\n\t\t\tagentSharedKeyLogs.push({\n\t\t\t\tag: agent.ag,\n\t\t\t\ten: eachAgent,\n\t\t\t\tat: 'pub/sharedKey',\n\t\t\t\tvl: eachEncKey, // these are encrypted with the derived key from the local agent private and remote agent public keys\n\t\t\t})\n\t\t}\n\t\t// const encryptedForLogs = await insertApplogs(agentSharedKeyLogs)\n\t\t// DEBUG(`[publish] adding agentSharedKeyLogs:`, encryptedForLogs)\n\n\t\t// TODO ensure that all needed keys are in\n\t\tfor (const eachLog of logsToPublish) {\n\t\t\tVERBOSE('[crypto] encrypting ', eachLog)\n\t\t\t// if (neverEncryptAttrs.includes(eachLog.at)) {\n\t\t\t// \tencryptedApplogs.push(/* prepareForPub( */ eachLog /* ) */) // ? this seemed to double the below one - @gotjoshua?\n\t\t\t// \t// continue\n\t\t\t// }\n\t\t\ttry {\n\t\t\t\tencPayload = await encryptAndTestDecrypt(eachLog, sharedKey)\n\t\t\t} catch (err) {\n\t\t\t\t// its already traced in encryptAndTestDecrypt\n\t\t\t\t// continue\n\t\t\t}\n\t\t\tencryptedApplogs.push(encPayload)\n\t\t}\n\t\tmaybeEncryptedApplogs = encryptedApplogs\n\t} else {\n\t\tmaybeEncryptedApplogs = logsToPublish // publish nonEncrypted\n\t}\n\treturn encodePubAsCar(agent, maybeEncryptedApplogs, agentLogs)\n}\n\n/**\n * @param applogs Encrypted or plain applogs\n * @returns Car file\n */\nexport async function encodePubAsCar(\n\tagent: AppAgent,\n\tapplogs: readonly Uint8Array[] | readonly Applog[],\n\tinfoLogs: readonly Applog[],\n) {\n\tDEBUG(`[encodePubAsCar] encoding`, { agent, applogs, infoLogs })\n\tconst { cids: infoLogCids, encodedApplogs: encodedInfoLogs } = await encodeApplogsAsIPLD(infoLogs)\n\tconst { cids: logCids, encodedApplogs } = await encodeApplogsAsIPLD(applogs)\n\t// We need to wrap the array to get a CID\n\tconst infoLogsWrap = await encodeBlockOriginal({ logs: infoLogCids })\n\tconst applogsWrap = await encodeBlockOriginal({ logs: logCids })\n\tconst infoSignature = await agent.sign(infoLogsWrap.bytes)\n\tconst applogsSignature = await agent.sign(applogsWrap.bytes)\n\tconst root = {\n\t\tinfo: infoLogsWrap.cid,\n\t\tapplogs: applogsWrap.cid,\n\t\tinfoSignature,\n\t\tapplogsSignature,\n\t}\n\tDEBUG('[encodePubAsCar] encoding root', { root, logCids, infoLogCids })\n\tconst encodedRoot = await encodeBlockOriginal(root)\n\tDEBUG('[encodePubAsCar] => root', { encodedRoot })\n\n\treturn await makeCarBlob(encodedRoot.cid, [encodedRoot, infoLogsWrap, applogsWrap, ...encodedInfoLogs, ...encodedApplogs]) // TODO: create CarBuilder\n}\n\n/**\n * @param applogs Encrypted or plain applogs\n * @returns Car file\n */\nexport async function encodeApplogsAsCar(\n\tapplogs: readonly Uint8Array[] | readonly Applog[],\n) {\n\tconst { cids, encodedApplogs } = await encodeApplogsAsIPLD(applogs)\n\tconst root = { applogs: cids }\n\tconst encodedRoot = await encodeBlockOriginal(root)\n\tDEBUG('[encodeApplogsAsCar] encoded root', { cids, encodedRoot })\n\n\treturn await makeCarBlob(encodedRoot.cid, [encodedRoot, ...encodedApplogs])\n}\n\nasync function encodeApplogsAsIPLD(applogs: readonly Applog[] | readonly Uint8Array[]) {\n\tconst preppedLogs = applogs.map(log => log instanceof Uint8Array ? log : prepareForPub(log as Applog))\n\tconst encodedApplogs = await Promise.all(preppedLogs.map(encodeBlockOriginal))\n\tDEBUG('[encodeApplogsAsIpld] encoded applogs', { encodedApplogs })\n\n\tconst cids = encodedApplogs.map(b => {\n\t\tif (!b.cid) throw new ERROR(`[publish] no cid for encoded log:`, b)\n\t\treturn b.cid\n\t})\n\treturn { cids, encodedApplogs }\n}\n","import { cyrb53hash } from './../applog/applog-utils'\nimport { AgentHash, AgentID } from '../applog/datom-types'\nimport { Tagged } from '../types'\n\ntype AgentString = Tagged<string, 'AgentString'>\ntype DIDString = Tagged<string, 'DID'>\nexport type { AgentHash, AgentString, DIDString }\n\nexport interface AppAgent {\n\tag: AgentHash\n\tagentString: AgentString\n\tdid: DIDString\n\n\tsign(data: Uint8Array): Promise<Uint8Array>\n}\n\nexport interface IPublication {\n\tid?: string // string hash of pub (used as unique id in IDB) `W3Name.create().toString()` starts with k51qzi5uqu5d\n\tcreatedAt: string // ISO timestamp of creation\n\tname: string // nick name for the pub\n\tisDeleted?: boolean\n\n\tpk: Uint8Array // exported privatekey - needed to create WritableName for publishing //TODO: store as non-extractable / encrypted?\n\n\tautopush: boolean\n\tlastPush: string | null\n\tlastCID?: string\n\tlatestLogTs?: string\n\n\tpublishedBy: string // local user appAgent\n\tselectors?: string[] // to be used as a filter for which applogs to pub\n\tencryptedFor?: string | null // short agentHash\n\tencryptedWith?: CryptoKey | null // AES-GCM derived key from ECDH keys (local private and remote public)\n\n\t// HACK WIP #39 - shared encryption\n\tsharedKey?: CryptoKey | null // AES-GCM derived key from ECDH keys (local private and ipns public)\n\tsharedAgents?: AgentID[] | null // array of string EntityIDs for the chosen agents (we need public jwkd atoms for each of them)\n\tsharedKeyMap?: Map<AgentID, string> | null // uses public key from each agent to derive an aes key that is used to encrypt and btoa the sharedKey that is actually used to encrypt and decrypt the applogs\n}\nexport interface ISubscription {\n\tid: string // string hash of pub (used as unique id in IDB) `W3Name.create().toString()` starts with k51qzi5uqu5d\n\tcreatedAt: string // ISO timestamp of creation\n\tname: string // nick name for the pub\n\tisDeleted: boolean\n\n\tlastPull?: string | null\n\tlastPullAttempt?: string | null\n\tautopull: boolean\n\tlastCID?: string\n\tpublishedBy?: string // remote publisher short agentHash\n\tencryptedFor?: string | undefined // short agentHash\n\tencryptedWith?: CryptoKey | undefined // AES-GCM derived key from ECDH keys (local private and remote public)\n}\nexport function isPublication(obj: any): obj is IPublication {\n\treturn obj?.pk !== undefined && obj?.lastPush !== undefined\n}\nexport function isSubscription(obj: any): obj is ISubscription {\n\treturn obj?.lastPull !== undefined\n}\n\nexport type TSubPub = IPublication | ISubscription\n\nexport function agentToShortHash(agentString: string) {\n\treturn cyrb53hash(agentString, 31, 7) as string\n}\n"],"mappings":"wKAWA,GAAM,CAAE,KAAAA,EAAM,IAAAC,EAAK,MAAAC,EAAO,QAAAC,EAAS,MAAAC,CAAM,EAAIC,EAAO,MAAMA,EAAO,KAAK,EAStE,eAAsBC,EACrBC,EACAC,EACAC,EACAC,EACC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K,CACpC,GAAI,CAACA,EAAE,IAAK,MAAM,IAAI/C,EAAM,oCAAqC+C,CAAC,EAClE,OAAOA,EAAE,GACV,CAAC,EACc,eAAAd,CAAe,CAC/B,CCxGO,SAASe,EAAcC,EAA+B,CAC5D,OAAOA,GAAK,KAAO,QAAaA,GAAK,WAAa,MACnD,CACO,SAASC,EAAeD,EAAgC,CAC9D,OAAOA,GAAK,WAAa,MAC1B,CAIO,SAASE,EAAiBC,EAAqB,CACrD,OAAOC,EAAWD,EAAa,GAAI,CAAC,CACrC","names":["WARN","LOG","DEBUG","VERBOSE","ERROR","Logger","preparePubForPush","agent","appStream","streamToPublish","publication","logsToPublish","getLogsFromStream","sharedAgents","sharedKeyMap","sharedKey","agentLogs","rollingFilter","withoutHistory","at","encPayload","encryptAndTestDecrypt","applog","keyToUse","maybeEncryptedApplogs","encryptedApplogs","agentSharedKeyLogs","eachAgent","eachEncKey","eachLog","encodePubAsCar","applogs","infoLogs","infoLogCids","encodedInfoLogs","encodeApplogsAsIPLD","logCids","encodedApplogs","infoLogsWrap","encodeBlockOriginal","applogsWrap","infoSignature","applogsSignature","root","encodedRoot","makeCarBlob","encodeApplogsAsCar","cids","preppedLogs","log","prepareForPub","b","isPublication","obj","isSubscription","agentToShortHash","agentString","cyrb53hash"]}
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
makeCarBlob
|
|
3
|
-
} from "./chunk-2UCPKUQK.min.js";
|
|
4
|
-
import {
|
|
5
|
-
cyrb53hash,
|
|
6
|
-
getLogsFromStream,
|
|
7
|
-
rollingFilter,
|
|
8
|
-
withoutHistory
|
|
9
|
-
} from "./chunk-3HUXODLY.min.js";
|
|
10
|
-
import {
|
|
11
|
-
Logger,
|
|
12
|
-
encodeBlockOriginal,
|
|
13
|
-
prepareForPub
|
|
14
|
-
} from "./chunk-WOD425XV.min.js";
|
|
15
|
-
|
|
16
|
-
// src/pubsub/publication.ts
|
|
17
|
-
var { WARN, LOG, DEBUG, VERBOSE, ERROR } = Logger.setup(Logger.DEBUG);
|
|
18
|
-
async function preparePubForPush(agent, appStream, streamToPublish, publication) {
|
|
19
|
-
const logsToPublish = getLogsFromStream(streamToPublish);
|
|
20
|
-
const { sharedAgents, sharedKeyMap, sharedKey } = publication ?? {};
|
|
21
|
-
const agentLogs = rollingFilter(withoutHistory(appStream), {
|
|
22
|
-
en: agent.ag,
|
|
23
|
-
at: ["agent/ecdh", "agent/jwkd", "agent/appAgent"]
|
|
24
|
-
}).applogs;
|
|
25
|
-
DEBUG(`[preparePubForPush] agent logs:`, agentLogs);
|
|
26
|
-
if (!agentLogs.find(({ at }) => at === "agent/appAgent"))
|
|
27
|
-
throw ERROR(`[preparePubForPush] appStream missing agent/appAgent log`);
|
|
28
|
-
let encPayload;
|
|
29
|
-
const encryptAndTestDecrypt = async (applog, keyToUse) => {
|
|
30
|
-
throw new Error(`todo: enc`);
|
|
31
|
-
};
|
|
32
|
-
DEBUG("[preparePubForPush] applogs ", logsToPublish);
|
|
33
|
-
let maybeEncryptedApplogs;
|
|
34
|
-
if (sharedAgents) {
|
|
35
|
-
if (!sharedKey || !sharedKeyMap) {
|
|
36
|
-
throw ERROR("sharedAgents but no Keys/Map", { sharedAgents, sharedKeyMap, sharedKey });
|
|
37
|
-
}
|
|
38
|
-
const encryptedApplogs = [];
|
|
39
|
-
const agentSharedKeyLogs = [];
|
|
40
|
-
for (const [eachAgent, eachEncKey] of Array.from(sharedKeyMap.entries())) {
|
|
41
|
-
agentSharedKeyLogs.push({
|
|
42
|
-
ag: agent.ag,
|
|
43
|
-
en: eachAgent,
|
|
44
|
-
at: "pub/sharedKey",
|
|
45
|
-
vl: eachEncKey
|
|
46
|
-
// these are encrypted with the derived key from the local agent private and remote agent public keys
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
for (const eachLog of logsToPublish) {
|
|
50
|
-
VERBOSE("[crypto] encrypting ", eachLog);
|
|
51
|
-
try {
|
|
52
|
-
encPayload = await encryptAndTestDecrypt(eachLog, sharedKey);
|
|
53
|
-
} catch (err) {
|
|
54
|
-
}
|
|
55
|
-
encryptedApplogs.push(encPayload);
|
|
56
|
-
}
|
|
57
|
-
maybeEncryptedApplogs = encryptedApplogs;
|
|
58
|
-
} else {
|
|
59
|
-
maybeEncryptedApplogs = logsToPublish;
|
|
60
|
-
}
|
|
61
|
-
return encodePubAsCar(agent, maybeEncryptedApplogs, agentLogs);
|
|
62
|
-
}
|
|
63
|
-
async function encodePubAsCar(agent, applogs, infoLogs) {
|
|
64
|
-
DEBUG(`[encodePubAsCar] encoding`, { agent, applogs, infoLogs });
|
|
65
|
-
const { cids: infoLogCids, encodedApplogs: encodedInfoLogs } = await encodeApplogsAsIPLD(infoLogs);
|
|
66
|
-
const { cids: logCids, encodedApplogs } = await encodeApplogsAsIPLD(applogs);
|
|
67
|
-
const infoLogsWrap = await encodeBlockOriginal({ logs: infoLogCids });
|
|
68
|
-
const applogsWrap = await encodeBlockOriginal({ logs: logCids });
|
|
69
|
-
const infoSignature = await agent.sign(infoLogsWrap.bytes);
|
|
70
|
-
const applogsSignature = await agent.sign(applogsWrap.bytes);
|
|
71
|
-
const root = {
|
|
72
|
-
info: infoLogsWrap.cid,
|
|
73
|
-
applogs: applogsWrap.cid,
|
|
74
|
-
infoSignature,
|
|
75
|
-
applogsSignature
|
|
76
|
-
};
|
|
77
|
-
DEBUG("[encodePubAsCar] encoding root", { root, logCids, infoLogCids });
|
|
78
|
-
const encodedRoot = await encodeBlockOriginal(root);
|
|
79
|
-
DEBUG("[encodePubAsCar] => root", { encodedRoot });
|
|
80
|
-
return await makeCarBlob(encodedRoot.cid, [encodedRoot, infoLogsWrap, applogsWrap, ...encodedInfoLogs, ...encodedApplogs]);
|
|
81
|
-
}
|
|
82
|
-
async function encodeApplogsAsCar(applogs) {
|
|
83
|
-
const { cids, encodedApplogs } = await encodeApplogsAsIPLD(applogs);
|
|
84
|
-
const root = { applogs: cids };
|
|
85
|
-
const encodedRoot = await encodeBlockOriginal(root);
|
|
86
|
-
DEBUG("[encodeApplogsAsCar] encoded root", { cids, encodedRoot });
|
|
87
|
-
return await makeCarBlob(encodedRoot.cid, [encodedRoot, ...encodedApplogs]);
|
|
88
|
-
}
|
|
89
|
-
async function encodeApplogsAsIPLD(applogs) {
|
|
90
|
-
const preppedLogs = applogs.map((log) => log instanceof Uint8Array ? log : prepareForPub(log));
|
|
91
|
-
const encodedApplogs = await Promise.all(preppedLogs.map(encodeBlockOriginal));
|
|
92
|
-
DEBUG("[encodeApplogsAsIpld] encoded applogs", { encodedApplogs });
|
|
93
|
-
const cids = encodedApplogs.map((b) => {
|
|
94
|
-
if (!b.cid)
|
|
95
|
-
throw new ERROR(`[publish] no cid for encoded log:`, b);
|
|
96
|
-
return b.cid;
|
|
97
|
-
});
|
|
98
|
-
return { cids, encodedApplogs };
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// src/pubsub/pubsub-types.ts
|
|
102
|
-
function isPublication(obj) {
|
|
103
|
-
return obj?.pk !== void 0 && obj?.lastPush !== void 0;
|
|
104
|
-
}
|
|
105
|
-
function isSubscription(obj) {
|
|
106
|
-
return obj?.lastPull !== void 0;
|
|
107
|
-
}
|
|
108
|
-
function agentToShortHash(agentString) {
|
|
109
|
-
return cyrb53hash(agentString, 31, 7);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export {
|
|
113
|
-
preparePubForPush,
|
|
114
|
-
encodePubAsCar,
|
|
115
|
-
encodeApplogsAsCar,
|
|
116
|
-
isPublication,
|
|
117
|
-
isSubscription,
|
|
118
|
-
agentToShortHash
|
|
119
|
-
};
|
|
120
|
-
//# sourceMappingURL=chunk-N7GKIL5T.min.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/pubsub/publication.ts","../src/pubsub/pubsub-types.ts"],"sourcesContent":["import { Logger } from 'besonders-logger'\nimport { stringify } from 'safe-stable-stringify'\nimport { cyrb53hash } from '../applog/applog-utils'\nimport { Applog, ApplogForInsert, EntityID } from '../applog/datom-types'\nimport { makeCarBlob } from '../ipfs/car'\nimport { encodeBlockOriginal, prepareForPub } from '../ipfs/ipfs-utils'\nimport { withoutHistory } from './../query/basic'\nimport { ApplogsOrStream, ApplogStream, getLogsFromStream } from '../stream'\nimport { rollingFilter } from '../stream/filters'\nimport { AppAgent, IPublication } from './pubsub-types'\n\nconst { WARN, LOG, DEBUG, VERBOSE, ERROR } = Logger.setup(Logger.DEBUG) // eslint-disable-line no-unused-vars\n\n// export const neverEncryptAttrs = [\n// \t'agent/jwkd',\n// \t'agent/appAgent',\n// \t'pub/encryptedFor',\n// \t'pub/sharedKey',\n// ]\n\nexport async function preparePubForPush(\n\tagent: AppAgent,\n\tappStream: ApplogStream,\n\tstreamToPublish: ApplogsOrStream,\n\tpublication: IPublication,\n) {\n\t// await initWasm()\n\t// const car_data = Wasm.make_car(applogs)\n\t// DEBUG('Car data:', car_data)\n\t// TODO prevent publish if there is no new info\n\tconst logsToPublish = getLogsFromStream(streamToPublish)\n\n\tconst { sharedAgents, sharedKeyMap, sharedKey } = publication ?? {}\n\t// TODO: publish all agents' info related to the logs we want to publish\n\tconst agentLogs = rollingFilter(withoutHistory(appStream), {\n\t\ten: agent.ag,\n\t\tat: ['agent/ecdh', 'agent/jwkd', 'agent/appAgent'],\n\t}).applogs\n\tDEBUG(`[preparePubForPush] agent logs:`, agentLogs)\n\tif (!agentLogs.find(({ at }) => at === 'agent/appAgent')) throw ERROR(`[preparePubForPush] appStream missing agent/appAgent log`)\n\tlet encPayload\n\tconst encryptAndTestDecrypt = async (applog: Applog, keyToUse: CryptoKey): Promise<Uint8Array> => {\n\t\tthrow new Error(`todo: enc`) // TODO: ENC\n\t\t// const eachLog = prepareForPub(applog) // without cid\n\t\t// const enc = new TextEncoder()\n\t\t// const stringified = stringify(eachLog)\n\t\t// const stringifiedEncodedAppLogPayload = enc.encode(stringified) // TODO: consider encodeToDagJson instead\n\t\t// VERBOSE('[odd]', { eachLog, stringified, stringifiedEncodedAppLogPayload })\n\n\t\t// try {\n\t\t// \tencPayload = await agent.crypto?.aes.encrypt(stringifiedEncodedAppLogPayload, keyToUse, SymmAlg.AES_GCM)\n\t\t// } catch (err) {\n\t\t// \tthrow ERROR('FAILED TO ENC payload length:', stringifiedEncodedAppLogPayload.length, { err })\n\t\t// }\n\n\t\t// const decrypted = await decryptWithAesSharedKey(encPayload, keyToUse, 'string')\n\n\t\t// VERBOSE('[odd] encrypted length:', stringifiedEncodedAppLogPayload.length, { encPayload, decrypted })\n\t\t// return encPayload\n\t}\n\tDEBUG('[preparePubForPush] applogs ', logsToPublish)\n\n\tlet maybeEncryptedApplogs: Uint8Array[] | readonly Applog[]\n\tif (sharedAgents) { // encrypt all Applogs\n\t\tif (!sharedKey || !sharedKeyMap) {\n\t\t\tthrow ERROR('sharedAgents but no Keys/Map', { sharedAgents, sharedKeyMap, sharedKey })\n\t\t}\n\t\tconst encryptedApplogs = [] as Uint8Array[]\n\t\tconst agentSharedKeyLogs = []\n\t\tfor (const [eachAgent, eachEncKey] of Array.from(sharedKeyMap.entries())) {\n\t\t\tagentSharedKeyLogs.push({\n\t\t\t\tag: agent.ag,\n\t\t\t\ten: eachAgent,\n\t\t\t\tat: 'pub/sharedKey',\n\t\t\t\tvl: eachEncKey, // these are encrypted with the derived key from the local agent private and remote agent public keys\n\t\t\t})\n\t\t}\n\t\t// const encryptedForLogs = await insertApplogs(agentSharedKeyLogs)\n\t\t// DEBUG(`[publish] adding agentSharedKeyLogs:`, encryptedForLogs)\n\n\t\t// TODO ensure that all needed keys are in\n\t\tfor (const eachLog of logsToPublish) {\n\t\t\tVERBOSE('[crypto] encrypting ', eachLog)\n\t\t\t// if (neverEncryptAttrs.includes(eachLog.at)) {\n\t\t\t// \tencryptedApplogs.push(/* prepareForPub( */ eachLog /* ) */) // ? this seemed to double the below one - @gotjoshua?\n\t\t\t// \t// continue\n\t\t\t// }\n\t\t\ttry {\n\t\t\t\tencPayload = await encryptAndTestDecrypt(eachLog, sharedKey)\n\t\t\t} catch (err) {\n\t\t\t\t// its already traced in encryptAndTestDecrypt\n\t\t\t\t// continue\n\t\t\t}\n\t\t\tencryptedApplogs.push(encPayload)\n\t\t}\n\t\tmaybeEncryptedApplogs = encryptedApplogs\n\t} else {\n\t\tmaybeEncryptedApplogs = logsToPublish // publish nonEncrypted\n\t}\n\treturn encodePubAsCar(agent, maybeEncryptedApplogs, agentLogs)\n}\n\n/**\n * @param applogs Encrypted or plain applogs\n * @returns Car file\n */\nexport async function encodePubAsCar(\n\tagent: AppAgent,\n\tapplogs: readonly Uint8Array[] | readonly Applog[],\n\tinfoLogs: readonly Applog[],\n) {\n\tDEBUG(`[encodePubAsCar] encoding`, { agent, applogs, infoLogs })\n\tconst { cids: infoLogCids, encodedApplogs: encodedInfoLogs } = await encodeApplogsAsIPLD(infoLogs)\n\tconst { cids: logCids, encodedApplogs } = await encodeApplogsAsIPLD(applogs)\n\t// We need to wrap the array to get a CID\n\tconst infoLogsWrap = await encodeBlockOriginal({ logs: infoLogCids })\n\tconst applogsWrap = await encodeBlockOriginal({ logs: logCids })\n\tconst infoSignature = await agent.sign(infoLogsWrap.bytes)\n\tconst applogsSignature = await agent.sign(applogsWrap.bytes)\n\tconst root = {\n\t\tinfo: infoLogsWrap.cid,\n\t\tapplogs: applogsWrap.cid,\n\t\tinfoSignature,\n\t\tapplogsSignature,\n\t}\n\tDEBUG('[encodePubAsCar] encoding root', { root, logCids, infoLogCids })\n\tconst encodedRoot = await encodeBlockOriginal(root)\n\tDEBUG('[encodePubAsCar] => root', { encodedRoot })\n\n\treturn await makeCarBlob(encodedRoot.cid, [encodedRoot, infoLogsWrap, applogsWrap, ...encodedInfoLogs, ...encodedApplogs]) // TODO: create CarBuilder\n}\n\n/**\n * @param applogs Encrypted or plain applogs\n * @returns Car file\n */\nexport async function encodeApplogsAsCar(\n\tapplogs: readonly Uint8Array[] | readonly Applog[],\n) {\n\tconst { cids, encodedApplogs } = await encodeApplogsAsIPLD(applogs)\n\tconst root = { applogs: cids }\n\tconst encodedRoot = await encodeBlockOriginal(root)\n\tDEBUG('[encodeApplogsAsCar] encoded root', { cids, encodedRoot })\n\n\treturn await makeCarBlob(encodedRoot.cid, [encodedRoot, ...encodedApplogs])\n}\n\nasync function encodeApplogsAsIPLD(applogs: readonly Applog[] | readonly Uint8Array[]) {\n\tconst preppedLogs = applogs.map(log => log instanceof Uint8Array ? log : prepareForPub(log as Applog))\n\tconst encodedApplogs = await Promise.all(preppedLogs.map(encodeBlockOriginal))\n\tDEBUG('[encodeApplogsAsIpld] encoded applogs', { encodedApplogs })\n\n\tconst cids = encodedApplogs.map(b => {\n\t\tif (!b.cid) throw new ERROR(`[publish] no cid for encoded log:`, b)\n\t\treturn b.cid\n\t})\n\treturn { cids, encodedApplogs }\n}\n","import { cyrb53hash } from './../applog/applog-utils'\nimport { AgentHash, AgentID } from '../applog/datom-types'\nimport { Tagged } from '../types'\n\ntype AgentString = Tagged<string, 'AgentString'>\ntype DIDString = Tagged<string, 'DID'>\nexport type { AgentHash, AgentString, DIDString }\n\nexport interface AppAgent {\n\tag: AgentHash\n\tagentString: AgentString\n\tdid: DIDString\n\n\tsign(data: Uint8Array): Promise<Uint8Array>\n}\n\nexport interface IPublication {\n\tid?: string // string hash of pub (used as unique id in IDB) `W3Name.create().toString()` starts with k51qzi5uqu5d\n\tcreatedAt: string // ISO timestamp of creation\n\tname: string // nick name for the pub\n\tisDeleted?: boolean\n\n\tpk: Uint8Array // exported privatekey - needed to create WritableName for publishing //TODO: store as non-extractable / encrypted?\n\n\tautopush: boolean\n\tlastPush: string | null\n\tlastCID?: string\n\tlatestLogTs?: string\n\n\tpublishedBy: string // local user appAgent\n\tselectors?: string[] // to be used as a filter for which applogs to pub\n\tencryptedFor?: string | null // short agentHash\n\tencryptedWith?: CryptoKey | null // AES-GCM derived key from ECDH keys (local private and remote public)\n\n\t// HACK WIP #39 - shared encryption\n\tsharedKey?: CryptoKey | null // AES-GCM derived key from ECDH keys (local private and ipns public)\n\tsharedAgents?: AgentID[] | null // array of string EntityIDs for the chosen agents (we need public jwkd atoms for each of them)\n\tsharedKeyMap?: Map<AgentID, string> | null // uses public key from each agent to derive an aes key that is used to encrypt and btoa the sharedKey that is actually used to encrypt and decrypt the applogs\n}\nexport interface ISubscription {\n\tid: string // string hash of pub (used as unique id in IDB) `W3Name.create().toString()` starts with k51qzi5uqu5d\n\tcreatedAt: string // ISO timestamp of creation\n\tname: string // nick name for the pub\n\tisDeleted: boolean\n\n\tlastPull?: string | null\n\tlastPullAttempt?: string | null\n\tautopull: boolean\n\tlastCID?: string\n\tpublishedBy?: string // remote publisher short agentHash\n\tencryptedFor?: string | undefined // short agentHash\n\tencryptedWith?: CryptoKey | undefined // AES-GCM derived key from ECDH keys (local private and remote public)\n}\nexport function isPublication(obj: any): obj is IPublication {\n\treturn obj?.pk !== undefined && obj?.lastPush !== undefined\n}\nexport function isSubscription(obj: any): obj is ISubscription {\n\treturn obj?.lastPull !== undefined\n}\n\nexport type TSubPub = IPublication | ISubscription\n\nexport function agentToShortHash(agentString: string) {\n\treturn cyrb53hash(agentString, 31, 7) as string\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAWA,IAAM,EAAE,MAAM,KAAK,OAAO,SAAS,MAAM,IAAI,OAAO,MAAM,OAAO,KAAK;AAStE,eAAsB,kBACrB,OACA,WACA,iBACA,aACC;AAKD,QAAM,gBAAgB,kBAAkB,eAAe;AAEvD,QAAM,EAAE,cAAc,cAAc,UAAU,IAAI,eAAe,CAAC;AAElE,QAAM,YAAY,cAAc,eAAe,SAAS,GAAG;AAAA,IAC1D,IAAI,MAAM;AAAA,IACV,IAAI,CAAC,cAAc,cAAc,gBAAgB;AAAA,EAClD,CAAC,EAAE;AACH,QAAM,mCAAmC,SAAS;AAClD,MAAI,CAAC,UAAU,KAAK,CAAC,EAAE,GAAG,MAAM,OAAO,gBAAgB;AAAG,UAAM,MAAM,0DAA0D;AAChI,MAAI;AACJ,QAAM,wBAAwB,OAA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
|
-
require_system,
|
|
4
|
-
require_typebox
|
|
5
|
-
} from "./chunk-3HUXODLY.min.js";
|
|
6
|
-
import {
|
|
7
|
-
__toESM
|
|
8
|
-
} from "./chunk-WOD425XV.min.js";
|
|
9
|
-
|
|
10
|
-
// src/types/typescript-utils.ts
|
|
11
|
-
var import_typebox = __toESM(require_typebox(), 1);
|
|
12
|
-
var import_system = __toESM(require_system(), 1);
|
|
13
|
-
var ApplogStreamTB = import_system.TypeSystem.Type("ApplogStream", (options, value) => {
|
|
14
|
-
return value instanceof ApplogStream;
|
|
15
|
-
})();
|
|
16
|
-
var { String: StringTB, Optional: OptionalTB, Boolean: BooleanTB, Object: ObjectTB, Number: NumberTB } = import_typebox.Type;
|
|
17
|
-
var Str = StringTB.bind(import_typebox.Type);
|
|
18
|
-
var Num = NumberTB.bind(import_typebox.Type);
|
|
19
|
-
var Obj = ObjectTB.bind(import_typebox.Type);
|
|
20
|
-
var Opt = OptionalTB.bind(import_typebox.Type);
|
|
21
|
-
var Bool = BooleanTB.bind(import_typebox.Type);
|
|
22
|
-
var STR = Str();
|
|
23
|
-
var NUM = Num();
|
|
24
|
-
var BOOL = Bool();
|
|
25
|
-
var DefaultTrue = true;
|
|
26
|
-
var DefaultFalse = false;
|
|
27
|
-
function checkParityTB() {
|
|
28
|
-
const s1 = Str();
|
|
29
|
-
const s2 = Str();
|
|
30
|
-
const n1 = Num();
|
|
31
|
-
const n2 = Num();
|
|
32
|
-
console.log({ s1, s2, n1, n2 });
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export {
|
|
36
|
-
ApplogStreamTB,
|
|
37
|
-
Str,
|
|
38
|
-
Num,
|
|
39
|
-
Obj,
|
|
40
|
-
Opt,
|
|
41
|
-
Bool,
|
|
42
|
-
STR,
|
|
43
|
-
NUM,
|
|
44
|
-
BOOL,
|
|
45
|
-
DefaultTrue,
|
|
46
|
-
DefaultFalse,
|
|
47
|
-
checkParityTB
|
|
48
|
-
};
|
|
49
|
-
//# sourceMappingURL=chunk-PVULNVU2.min.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types/typescript-utils.ts"],"sourcesContent":["import { Type as T } from '@sinclair/typebox'\nimport { TypeSystem } from '@sinclair/typebox/system'\nimport type { CID } from 'multiformats'\nimport { ApplogStream } from '../stream'\n\nexport const ApplogStreamTB = TypeSystem.Type<ApplogStream>('ApplogStream', (options, value) => {\n\treturn value instanceof ApplogStream\n})()\nconst { String: StringTB, Optional: OptionalTB, Boolean: BooleanTB, Object: ObjectTB, Number: NumberTB } = T\nexport const Str: typeof StringTB = StringTB.bind(T)\nexport const Num: typeof NumberTB = NumberTB.bind(T)\nexport const Obj: typeof ObjectTB = ObjectTB.bind(T)\nexport const Opt: typeof OptionalTB = OptionalTB.bind(T)\nexport const Bool: typeof BooleanTB = BooleanTB.bind(T)\n\nexport const STR: ReturnType<typeof T.String> = Str()\nexport const NUM: ReturnType<typeof T.Number> = Num()\nexport const BOOL: ReturnType<typeof T.Boolean> = Bool()\n\nexport type DefaultTrue = true | boolean\nexport const DefaultTrue: DefaultTrue = true\n\nexport type DefaultFalse = false | boolean\nexport const DefaultFalse: DefaultFalse = false\n\nexport type GenericObject = Record<string, any>\nexport type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>\nexport type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>\nexport type PromiseType<T extends Promise<any>> = T extends Promise<infer U> ? U : never\n\nexport type CoerceToString<T> = T extends string ? T : never\n\n/**\n * Define nominal type of U based on type of T. Similar to Opaque types in Flow\n */\nexport type Tagged<T, Tag> = T & { tag?: Tag }\n\n// export interface Service {\n// \tendpoint?: URL\n// \ttoken: string\n// \trateLimiter?: RateLimiter\n// \tfetch?: typeof _fetch\n// }\n\n// https://stackoverflow.com/a/76276541\nexport type LastElementOf<T extends readonly unknown[]> = T extends readonly [...unknown[], infer Last] ? Last : never\n\nexport function checkParityTB() {\n\t/* Most examples are constantly calling Type.*() - needed to check if its really needed\n https://github.com/sinclairzx81/typebox/issues/587#issuecomment-1712457623\n */\n\tconst s1 = Str()\n\tconst s2 = Str()\n\tconst n1 = Num()\n\tconst n2 = Num()\n\tconsole.log({ s1, s2, n1, n2 })\n}\n\n/** solidjs Setter requires returning something, which I often don't */\nexport type GenericSetter<T> = (newValue: T) => void\n"],"mappings":";;;;;;;;;;AAAA,qBAA0B;AAC1B,oBAA2B;AAIpB,IAAM,iBAAiB,yBAAW,KAAmB,gBAAgB,CAAC,SAAS,UAAU;AAC/F,SAAO,iBAAiB;AACzB,CAAC,EAAE;AACH,IAAM,EAAE,QAAQ,UAAU,UAAU,YAAY,SAAS,WAAW,QAAQ,UAAU,QAAQ,SAAS,IAAI,eAAAA;AACpG,IAAM,MAAuB,SAAS,KAAK,eAAAA,IAAC;AAC5C,IAAM,MAAuB,SAAS,KAAK,eAAAA,IAAC;AAC5C,IAAM,MAAuB,SAAS,KAAK,eAAAA,IAAC;AAC5C,IAAM,MAAyB,WAAW,KAAK,eAAAA,IAAC;AAChD,IAAM,OAAyB,UAAU,KAAK,eAAAA,IAAC;AAE/C,IAAM,MAAmC,IAAI;AAC7C,IAAM,MAAmC,IAAI;AAC7C,IAAM,OAAqC,KAAK;AAGhD,IAAM,cAA2B;AAGjC,IAAM,eAA6B;AAwBnC,SAAS,gBAAgB;AAI/B,QAAM,KAAK,IAAI;AACf,QAAM,KAAK,IAAI;AACf,QAAM,KAAK,IAAI;AACf,QAAM,KAAK,IAAI;AACf,UAAQ,IAAI,EAAE,IAAI,IAAI,IAAI,GAAG,CAAC;AAC/B;","names":["T"]}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ApplogStreamInMemory,
|
|
3
|
-
autorun,
|
|
4
|
-
comparer,
|
|
5
|
-
computedFnDeepCompare,
|
|
6
|
-
createDebugName,
|
|
7
|
-
observableArrayMap,
|
|
8
|
-
toJS
|
|
9
|
-
} from "./chunk-3HUXODLY.min.js";
|
|
10
|
-
import {
|
|
11
|
-
Logger
|
|
12
|
-
} from "./chunk-WOD425XV.min.js";
|
|
13
|
-
|
|
14
|
-
// src/query/divergences.ts
|
|
15
|
-
var { WARN, LOG, DEBUG, VERBOSE, ERROR } = Logger.setup(Logger.INFO);
|
|
16
|
-
var queryDivergencesByPrev = computedFnDeepCompare(function queryConflictingByPrev(sourceStream) {
|
|
17
|
-
DEBUG(`queryDivergencesByPrev<${sourceStream.nameAndSizeUntracked}>`);
|
|
18
|
-
if (sourceStream.filters.includes("withoutHistory"))
|
|
19
|
-
WARN(`queryDivergencesByPrev on stream withoutHistory`, sourceStream);
|
|
20
|
-
const divergences = observableArrayMap(() => {
|
|
21
|
-
const logsForNode = /* @__PURE__ */ new Map();
|
|
22
|
-
const leafs = /* @__PURE__ */ new Set();
|
|
23
|
-
VERBOSE("all applogs:", sourceStream.applogs);
|
|
24
|
-
for (const log of sourceStream.applogs) {
|
|
25
|
-
let prevLogs;
|
|
26
|
-
if (log.pv) {
|
|
27
|
-
prevLogs = log.pv && logsForNode.get(log.pv.toString());
|
|
28
|
-
leafs.delete(log.pv.toString());
|
|
29
|
-
}
|
|
30
|
-
VERBOSE("traversing log", { log, prevLogs, leafs: Array.from(leafs) });
|
|
31
|
-
logsForNode.set(log.cid, prevLogs ? [...prevLogs, log] : [log]);
|
|
32
|
-
leafs.add(log.cid);
|
|
33
|
-
}
|
|
34
|
-
return Array.from(leafs).map((leafID) => {
|
|
35
|
-
const stream = new ApplogStreamInMemory(
|
|
36
|
-
logsForNode.get(leafID),
|
|
37
|
-
sourceStream.filters,
|
|
38
|
-
createDebugName({
|
|
39
|
-
caller: "DivergenceLeaf",
|
|
40
|
-
stream: sourceStream,
|
|
41
|
-
pattern: `leaf: ${leafID}`
|
|
42
|
-
}),
|
|
43
|
-
true,
|
|
44
|
-
sourceStream
|
|
45
|
-
);
|
|
46
|
-
return { log: stream.latestLog, stream };
|
|
47
|
-
});
|
|
48
|
-
}, { name: createDebugName({ caller: "queryDivergencesByPrev", stream: sourceStream }) });
|
|
49
|
-
VERBOSE.isDisabled || autorun(() => VERBOSE(`[queryDivergencesByPrev] result:`, toJS(divergences)));
|
|
50
|
-
return divergences;
|
|
51
|
-
}, { equals: comparer.structural });
|
|
52
|
-
|
|
53
|
-
// src/query/matchers.ts
|
|
54
|
-
function includes(str) {
|
|
55
|
-
return (vl) => vl?.includes?.(str);
|
|
56
|
-
}
|
|
57
|
-
function includedIn(arr) {
|
|
58
|
-
return (vl) => arr?.includes?.(vl);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export {
|
|
62
|
-
queryDivergencesByPrev,
|
|
63
|
-
includes,
|
|
64
|
-
includedIn
|
|
65
|
-
};
|
|
66
|
-
//# sourceMappingURL=chunk-VTXN7J7O.min.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/query/divergences.ts","../src/query/matchers.ts"],"sourcesContent":["import { Logger } from 'besonders-logger'\nimport { autorun, comparer, toJS } from 'mobx'\nimport { Applog } from '../applog/datom-types'\nimport { computedFnDeepCompare, createDebugName, observableArrayMap } from '../mobx/mobx-utils'\nimport { ApplogStream } from '../stream'\nimport { ApplogStreamInMemory } from '../stream/writeable'\n\nconst { WARN, LOG, DEBUG, VERBOSE, ERROR } = Logger.setup(Logger.INFO) // eslint-disable-line no-unused-vars\n\nexport interface DivergenceLeaf {\n\tlog: Applog\n\tstream: ApplogStream\n}\n\nexport const queryDivergencesByPrev = computedFnDeepCompare(function queryConflictingByPrev(\n\tsourceStream: ApplogStream,\n) {\n\tDEBUG(`queryDivergencesByPrev<${sourceStream.nameAndSizeUntracked}>`)\n\tif (sourceStream.filters.includes('withoutHistory')) WARN(`queryDivergencesByPrev on stream withoutHistory`, sourceStream)\n\n\tconst divergences = observableArrayMap(() => {\n\t\tconst logsForNode = new Map<string, Applog[]>()\n\t\tconst leafs = new Set<string>()\n\t\tVERBOSE('all applogs:', sourceStream.applogs)\n\t\tfor (const log of sourceStream.applogs) {\n\t\t\tlet prevLogs\n\t\t\tif (log.pv) {\n\t\t\t\tprevLogs = log.pv && logsForNode.get(log.pv.toString())\n\t\t\t\tleafs.delete(log.pv.toString())\n\t\t\t}\n\t\t\tVERBOSE('traversing log', { log, prevLogs, leafs: Array.from(leafs) })\n\t\t\tlogsForNode.set(log.cid, prevLogs ? [...prevLogs, log] : [log])\n\t\t\tleafs.add(log.cid)\n\t\t}\n\t\treturn Array.from(leafs).map(leafID => {\n\t\t\t// TODO use MappedApplogStream?\n\t\t\tconst stream = new ApplogStreamInMemory(\n\t\t\t\tlogsForNode.get(leafID),\n\t\t\t\tsourceStream.filters,\n\t\t\t\tcreateDebugName({\n\t\t\t\t\tcaller: 'DivergenceLeaf',\n\t\t\t\t\tstream: sourceStream,\n\t\t\t\t\tpattern: `leaf: ${leafID}`,\n\t\t\t\t}),\n\t\t\t\ttrue,\n\t\t\t\tsourceStream,\n\t\t\t)\n\t\t\treturn ({ log: stream.latestLog, stream })\n\t\t})\n\t}, { name: createDebugName({ caller: 'queryDivergencesByPrev', stream: sourceStream }) })\n\tVERBOSE.isDisabled || autorun(() => VERBOSE(`[queryDivergencesByPrev] result:`, toJS(divergences)))\n\treturn divergences\n}, { equals: comparer.structural })\n","import { DatomPart } from '../applog/datom-types'\n\nexport function includes(str: string) {\n\treturn (vl: DatomPart) => vl?.includes?.(str)\n}\nexport function includedIn(arr: string[]) {\n\treturn (vl: DatomPart) => arr?.includes?.(vl)\n}\n"],"mappings":";;;;;;;;;;;;;;AAOA,IAAM,EAAE,MAAM,KAAK,OAAO,SAAS,MAAM,IAAI,OAAO,MAAM,OAAO,IAAI;AAO9D,IAAM,yBAAyB,sBAAsB,SAAS,uBACpE,cACC;AACD,QAAM,0BAA0B,aAAa,oBAAoB,GAAG;AACpE,MAAI,aAAa,QAAQ,SAAS,gBAAgB;AAAG,SAAK,mDAAmD,YAAY;AAEzH,QAAM,cAAc,mBAAmB,MAAM;AAC5C,UAAM,cAAc,oBAAI,IAAsB;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S2N7XB.min.js";import{c as a}from"./chunk-G3GOAFHU.min.js";var{WARN:y,LOG:B,DEBUG:d,VERBOSE:p,ERROR:q}=a.setup(a.INFO),L=u(function(e){d(`queryDivergencesByPrev<${e.nameAndSizeUntracked}>`),e.filters.includes("withoutHistory")&&y("queryDivergencesByPrev on stream withoutHistory",e);let s=c(()=>{let i=new Map,n=new Set;p("all applogs:",e.applogs);for(let r of e.applogs){let t;r.pv&&(t=r.pv&&i.get(r.pv.toString()),n.delete(r.pv.toString())),p("traversing log",{log:r,prevLogs:t,leafs:Array.from(n)}),i.set(r.cid,t?[...t,r]:[r]),n.add(r.cid)}return Array.from(n).map(r=>{let t=new v(i.get(r),e.filters,l({caller:"DivergenceLeaf",stream:e,pattern:`leaf: ${r}`}),!0,e);return{log:t.latestLog,stream:t}})},{name:l({caller:"queryDivergencesByPrev",stream:e})});return p.isDisabled||m(()=>p("[queryDivergencesByPrev] result:",f(s))),s},{equals:g.structural});function R(o){return e=>e?.includes?.(o)}function b(o){return e=>o?.includes?.(e)}export{L as a,R as b,b as c};
|
|
2
|
-
//# sourceMappingURL=chunk-W7B2PDHK.min.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/query/divergences.ts","../src/query/matchers.ts"],"sourcesContent":["import { Logger } from 'besonders-logger'\nimport { autorun, comparer, toJS } from 'mobx'\nimport { Applog } from '../applog/datom-types'\nimport { computedFnDeepCompare, createDebugName, observableArrayMap } from '../mobx/mobx-utils'\nimport { ApplogStream } from '../stream'\nimport { ApplogStreamInMemory } from '../stream/writeable'\n\nconst { WARN, LOG, DEBUG, VERBOSE, ERROR } = Logger.setup(Logger.INFO) // eslint-disable-line no-unused-vars\n\nexport interface DivergenceLeaf {\n\tlog: Applog\n\tstream: ApplogStream\n}\n\nexport const queryDivergencesByPrev = computedFnDeepCompare(function queryConflictingByPrev(\n\tsourceStream: ApplogStream,\n) {\n\tDEBUG(`queryDivergencesByPrev<${sourceStream.nameAndSizeUntracked}>`)\n\tif (sourceStream.filters.includes('withoutHistory')) WARN(`queryDivergencesByPrev on stream withoutHistory`, sourceStream)\n\n\tconst divergences = observableArrayMap(() => {\n\t\tconst logsForNode = new Map<string, Applog[]>()\n\t\tconst leafs = new Set<string>()\n\t\tVERBOSE('all applogs:', sourceStream.applogs)\n\t\tfor (const log of sourceStream.applogs) {\n\t\t\tlet prevLogs\n\t\t\tif (log.pv) {\n\t\t\t\tprevLogs = log.pv && logsForNode.get(log.pv.toString())\n\t\t\t\tleafs.delete(log.pv.toString())\n\t\t\t}\n\t\t\tVERBOSE('traversing log', { log, prevLogs, leafs: Array.from(leafs) })\n\t\t\tlogsForNode.set(log.cid, prevLogs ? [...prevLogs, log] : [log])\n\t\t\tleafs.add(log.cid)\n\t\t}\n\t\treturn Array.from(leafs).map(leafID => {\n\t\t\t// TODO use MappedApplogStream?\n\t\t\tconst stream = new ApplogStreamInMemory(\n\t\t\t\tlogsForNode.get(leafID),\n\t\t\t\tsourceStream.filters,\n\t\t\t\tcreateDebugName({\n\t\t\t\t\tcaller: 'DivergenceLeaf',\n\t\t\t\t\tstream: sourceStream,\n\t\t\t\t\tpattern: `leaf: ${leafID}`,\n\t\t\t\t}),\n\t\t\t\ttrue,\n\t\t\t\tsourceStream,\n\t\t\t)\n\t\t\treturn ({ log: stream.latestLog, stream })\n\t\t})\n\t}, { name: createDebugName({ caller: 'queryDivergencesByPrev', stream: sourceStream }) })\n\tVERBOSE.isDisabled || autorun(() => VERBOSE(`[queryDivergencesByPrev] result:`, toJS(divergences)))\n\treturn divergences\n}, { equals: comparer.structural })\n","import { DatomPart } from '../applog/datom-types'\n\nexport function includes(str: string) {\n\treturn (vl: DatomPart) => vl?.includes?.(str)\n}\nexport function includedIn(arr: string[]) {\n\treturn (vl: DatomPart) => arr?.includes?.(vl)\n}\n"],"mappings":"mIAOA,GAAM,CAAE,KAAAA,EAAM,IAAAC,EAAK,MAAAC,EAAO,QAAAC,EAAS,MAAAC,CAAM,EAAIC,E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AC7C,CACO,SAASE,EAAWC,EAAe,CACzC,OAAQF,GAAkBE,GAAK,WAAWF,CAAE,CAC7C","names":["WARN","LOG","DEBUG","VERBOSE","ERROR","Logger","queryDivergencesByPrev","computedFnDeepCompare","sourceStream","divergences","observableArrayMap","logsForNode","leafs","log","prevLogs","leafID","stream","ApplogStreamInMemory","createDebugName","autorun","toJS","comparer","includes","str","vl","includedIn","arr"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{H as T,T as y,U as l}from"./chunk-WNS2N7XB.min.js";import{b as p}from"./chunk-G3GOAFHU.min.js";var e=p(y(),1),a=p(l(),1);var g=a.TypeSystem.Type("ApplogStream",(n,t)=>t instanceof T)(),{String:c,Optional:x,Boolean:f,Object:m,Number:u}=e.Type,o=c.bind(e.Type),r=u.bind(e.Type),b=m.bind(e.Type),O=x.bind(e.Type),B=f.bind(e.Type),S=o(),k=r(),P=B(),D=!0,N=!1;function j(){let n=o(),t=o(),s=r(),i=r();console.log({s1:n,s2:t,n1:s,n2:i})}export{g as a,o as b,r as c,b as d,O as e,B as f,S as g,k as h,P as i,D as j,N as k,j as l};
|
|
2
|
-
//# sourceMappingURL=chunk-WCOT2GIF.min.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types/typescript-utils.ts"],"sourcesContent":["import { Type as T } from '@sinclair/typebox'\nimport { TypeSystem } from '@sinclair/typebox/system'\nimport type { CID } from 'multiformats'\nimport { ApplogStream } from '../stream'\n\nexport const ApplogStreamTB = TypeSystem.Type<ApplogStream>('ApplogStream', (options, value) => {\n\treturn value instanceof ApplogStream\n})()\nconst { String: StringTB, Optional: OptionalTB, Boolean: BooleanTB, Object: ObjectTB, Number: NumberTB } = T\nexport const Str: typeof StringTB = StringTB.bind(T)\nexport const Num: typeof NumberTB = NumberTB.bind(T)\nexport const Obj: typeof ObjectTB = ObjectTB.bind(T)\nexport const Opt: typeof OptionalTB = OptionalTB.bind(T)\nexport const Bool: typeof BooleanTB = BooleanTB.bind(T)\n\nexport const STR: ReturnType<typeof T.String> = Str()\nexport const NUM: ReturnType<typeof T.Number> = Num()\nexport const BOOL: ReturnType<typeof T.Boolean> = Bool()\n\nexport type DefaultTrue = true | boolean\nexport const DefaultTrue: DefaultTrue = true\n\nexport type DefaultFalse = false | boolean\nexport const DefaultFalse: DefaultFalse = false\n\nexport type GenericObject = Record<string, any>\nexport type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>\nexport type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>\nexport type PromiseType<T extends Promise<any>> = T extends Promise<infer U> ? U : never\n\nexport type CoerceToString<T> = T extends string ? T : never\n\n/**\n * Define nominal type of U based on type of T. Similar to Opaque types in Flow\n */\nexport type Tagged<T, Tag> = T & { tag?: Tag }\n\n// export interface Service {\n// \tendpoint?: URL\n// \ttoken: string\n// \trateLimiter?: RateLimiter\n// \tfetch?: typeof _fetch\n// }\n\n// https://stackoverflow.com/a/76276541\nexport type LastElementOf<T extends readonly unknown[]> = T extends readonly [...unknown[], infer Last] ? Last : never\n\nexport function checkParityTB() {\n\t/* Most examples are constantly calling Type.*() - needed to check if its really needed\n https://github.com/sinclairzx81/typebox/issues/587#issuecomment-1712457623\n */\n\tconst s1 = Str()\n\tconst s2 = Str()\n\tconst n1 = Num()\n\tconst n2 = Num()\n\tconsole.log({ s1, s2, n1, n2 })\n}\n\n/** solidjs Setter requires returning something, which I often don't */\nexport type GenericSetter<T> = (newValue: T) => void\n"],"mappings":"sGAAA,IAAAA,EAA0B,SAC1BC,EAA2B,SAIpB,IAAMC,EAAiB,aAAW,KAAmB,eAAgB,CAACC,EAASC,IAC9EA,aAAiBC,CACxB,EAAE,EACG,CAAE,OAAQC,EAAU,SAAUC,EAAY,QAASC,EAAW,OAAQC,EAAU,OAAQC,CAAS,EAAI,EAAAC,KAC9FC,EAAuBN,EAAS,KAAK,EAAAK,IAAC,EACtCE,EAAuBH,EAAS,KAAK,EAAAC,IAAC,EACtCG,EAAuBL,EAAS,KAAK,EAAAE,IAAC,EACtCI,EAAyBR,EAAW,KAAK,EAAAI,IAAC,EAC1CK,EAAyBR,EAAU,KAAK,EAAAG,IAAC,EAEzCM,EAAmCL,EAAI,EACvCM,EAAmCL,EAAI,EACvCM,EAAqCH,EAAK,EAG1CI,EAA2B,GAG3BC,EAA6B,GAwBnC,SAASC,GAAgB,CAI/B,IAAMC,EAAKX,EAAI,EACTY,EAAKZ,EAAI,EACTa,EAAKZ,EAAI,EACTa,EAAKb,EAAI,EACf,QAAQ,IAAI,CAAE,GAAAU,EAAI,GAAAC,EAAI,GAAAC,EAAI,GAAAC,CAAG,CAAC,CAC/B","names":["import_typebox","import_system","ApplogStreamTB","options","value","ApplogStream","StringTB","OptionalTB","BooleanTB","ObjectTB","NumberTB","T","Str","Num","Obj","Opt","Bool","STR","NUM","BOOL","DefaultTrue","DefaultFalse","checkParityTB","s1","s2","n1","n2"]}
|