@ibgib/core-gib 0.1.2 → 0.1.4

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.
Files changed (94) hide show
  1. package/dist/common/other/other-helper.respec.mjs +1 -1
  2. package/dist/common/other/other-helper.respec.mjs.map +1 -1
  3. package/dist/common/pubsub/observable/observable-helper.mjs +1 -1
  4. package/dist/common/pubsub/observable/observable-helper.mjs.map +1 -1
  5. package/dist/common/pubsub/subject/subject-helper.mjs +1 -1
  6. package/dist/common/pubsub/subject/subject-helper.mjs.map +1 -1
  7. package/dist/common/pubsub/subscription/subscription-helper.mjs +1 -1
  8. package/dist/common/pubsub/subscription/subscription-helper.mjs.map +1 -1
  9. package/dist/witness/space/inner-space/inner-space-v1.respec.mjs +4 -5
  10. package/dist/witness/space/inner-space/inner-space-v1.respec.mjs.map +1 -1
  11. package/dist/witness/space/space-helper.mjs +1 -1
  12. package/dist/witness/space/space-helper.mjs.map +1 -1
  13. package/package.json +4 -4
  14. package/src/common/other/other-helper.respec.mts +1 -1
  15. package/src/common/pubsub/observable/observable-helper.mts +1 -1
  16. package/src/common/pubsub/subject/subject-helper.mts +1 -1
  17. package/src/common/pubsub/subscription/subscription-helper.mts +1 -1
  18. package/src/witness/space/inner-space/inner-space-v1.respec.mts +4 -6
  19. package/src/witness/space/space-helper.mts +1 -1
  20. package/dist/witness/keystone/keystone-base-v1.d.mts +0 -177
  21. package/dist/witness/keystone/keystone-base-v1.d.mts.map +0 -1
  22. package/dist/witness/keystone/keystone-base-v1.mjs +0 -397
  23. package/dist/witness/keystone/keystone-base-v1.mjs.map +0 -1
  24. package/dist/witness/keystone/keystone-constants.d.mts +0 -2
  25. package/dist/witness/keystone/keystone-constants.d.mts.map +0 -1
  26. package/dist/witness/keystone/keystone-constants.mjs +0 -2
  27. package/dist/witness/keystone/keystone-constants.mjs.map +0 -1
  28. package/dist/witness/keystone/keystone-helper.d.mts +0 -9
  29. package/dist/witness/keystone/keystone-helper.d.mts.map +0 -1
  30. package/dist/witness/keystone/keystone-helper.mjs +0 -53
  31. package/dist/witness/keystone/keystone-helper.mjs.map +0 -1
  32. package/dist/witness/keystone/keystone-types.d.mts +0 -164
  33. package/dist/witness/keystone/keystone-types.d.mts.map +0 -1
  34. package/dist/witness/keystone/keystone-types.mjs +0 -46
  35. package/dist/witness/keystone/keystone-types.mjs.map +0 -1
  36. package/dist/witness/keystone/keystone.d.mts +0 -2
  37. package/dist/witness/keystone/keystone.d.mts.map +0 -1
  38. package/dist/witness/keystone/keystone.mjs +0 -2
  39. package/dist/witness/keystone/keystone.mjs.map +0 -1
  40. package/dist/witness/keystone/keystone.respec.d.mts +0 -11
  41. package/dist/witness/keystone/keystone.respec.d.mts.map +0 -1
  42. package/dist/witness/keystone/keystone.respec.mjs +0 -11
  43. package/dist/witness/keystone/keystone.respec.mjs.map +0 -1
  44. package/dist/witness/keystone/math-keystone/math-keystone-constants.d.mts +0 -2
  45. package/dist/witness/keystone/math-keystone/math-keystone-constants.d.mts.map +0 -1
  46. package/dist/witness/keystone/math-keystone/math-keystone-constants.mjs +0 -2
  47. package/dist/witness/keystone/math-keystone/math-keystone-constants.mjs.map +0 -1
  48. package/dist/witness/keystone/math-keystone/math-keystone-helper.d.mts +0 -13
  49. package/dist/witness/keystone/math-keystone/math-keystone-helper.d.mts.map +0 -1
  50. package/dist/witness/keystone/math-keystone/math-keystone-helper.mjs +0 -41
  51. package/dist/witness/keystone/math-keystone/math-keystone-helper.mjs.map +0 -1
  52. package/dist/witness/keystone/math-keystone/math-keystone-types.d.mts +0 -80
  53. package/dist/witness/keystone/math-keystone/math-keystone-types.d.mts.map +0 -1
  54. package/dist/witness/keystone/math-keystone/math-keystone-types.mjs +0 -9
  55. package/dist/witness/keystone/math-keystone/math-keystone-types.mjs.map +0 -1
  56. package/dist/witness/keystone/math-keystone/math-keystone-v1.d.mts +0 -34
  57. package/dist/witness/keystone/math-keystone/math-keystone-v1.d.mts.map +0 -1
  58. package/dist/witness/keystone/math-keystone/math-keystone-v1.mjs +0 -119
  59. package/dist/witness/keystone/math-keystone/math-keystone-v1.mjs.map +0 -1
  60. package/dist/witness/keystone/math-keystone/math-keystone.respec.d.mts +0 -20
  61. package/dist/witness/keystone/math-keystone/math-keystone.respec.d.mts.map +0 -1
  62. package/dist/witness/keystone/math-keystone/math-keystone.respec.mjs +0 -76
  63. package/dist/witness/keystone/math-keystone/math-keystone.respec.mjs.map +0 -1
  64. package/dist/witness/keystone/zkp-keystone/zkp-keystone-constants.d.mts +0 -2
  65. package/dist/witness/keystone/zkp-keystone/zkp-keystone-constants.d.mts.map +0 -1
  66. package/dist/witness/keystone/zkp-keystone/zkp-keystone-constants.mjs +0 -2
  67. package/dist/witness/keystone/zkp-keystone/zkp-keystone-constants.mjs.map +0 -1
  68. package/dist/witness/keystone/zkp-keystone/zkp-keystone-helper.d.mts +0 -2
  69. package/dist/witness/keystone/zkp-keystone/zkp-keystone-helper.d.mts.map +0 -1
  70. package/dist/witness/keystone/zkp-keystone/zkp-keystone-helper.mjs +0 -2
  71. package/dist/witness/keystone/zkp-keystone/zkp-keystone-helper.mjs.map +0 -1
  72. package/dist/witness/keystone/zkp-keystone/zkp-keystone-types.d.mts +0 -2
  73. package/dist/witness/keystone/zkp-keystone/zkp-keystone-types.d.mts.map +0 -1
  74. package/dist/witness/keystone/zkp-keystone/zkp-keystone-types.mjs +0 -2
  75. package/dist/witness/keystone/zkp-keystone/zkp-keystone-types.mjs.map +0 -1
  76. package/dist/witness/keystone/zkp-keystone/zkp-keystone-v1.d.mts +0 -2
  77. package/dist/witness/keystone/zkp-keystone/zkp-keystone-v1.d.mts.map +0 -1
  78. package/dist/witness/keystone/zkp-keystone/zkp-keystone-v1.mjs +0 -2
  79. package/dist/witness/keystone/zkp-keystone/zkp-keystone-v1.mjs.map +0 -1
  80. package/src/witness/keystone/keystone-base-v1.mts +0 -450
  81. package/src/witness/keystone/keystone-constants.mts +0 -0
  82. package/src/witness/keystone/keystone-helper.mts +0 -56
  83. package/src/witness/keystone/keystone-types.mts +0 -200
  84. package/src/witness/keystone/keystone.mts +0 -0
  85. package/src/witness/keystone/keystone.respec.mts +0 -9
  86. package/src/witness/keystone/math-keystone/math-keystone-constants.mts +0 -0
  87. package/src/witness/keystone/math-keystone/math-keystone-helper.mts +0 -45
  88. package/src/witness/keystone/math-keystone/math-keystone-types.mts +0 -115
  89. package/src/witness/keystone/math-keystone/math-keystone-v1.mts +0 -139
  90. package/src/witness/keystone/math-keystone/math-keystone.respec.mts +0 -122
  91. package/src/witness/keystone/zkp-keystone/zkp-keystone-constants.mts +0 -0
  92. package/src/witness/keystone/zkp-keystone/zkp-keystone-helper.mts +0 -0
  93. package/src/witness/keystone/zkp-keystone/zkp-keystone-types.mts +0 -0
  94. package/src/witness/keystone/zkp-keystone/zkp-keystone-v1.mts +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ibgib/core-gib",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "ibgib core functionality, including base architecture for witnesses, spaces, apps, robbots, etc., as well as shared utility functions. Node v19+ needed for heavily-used isomorphic webcrypto hashing consumed in both node and browsers.",
5
5
  "funding": {
6
6
  "type": "individual",
@@ -47,9 +47,9 @@
47
47
  "author": "William Raiford",
48
48
  "license": "ISC",
49
49
  "dependencies": {
50
- "@ibgib/encrypt-gib": "^0.2.32",
51
- "@ibgib/helper-gib": "^0.0.31",
52
- "@ibgib/ts-gib": "^0.5.24"
50
+ "@ibgib/encrypt-gib": "^0.2.33",
51
+ "@ibgib/helper-gib": "^0.0.32",
52
+ "@ibgib/ts-gib": "^0.5.25"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@types/node": "^20.2.1"
@@ -28,7 +28,7 @@
28
28
  // /**
29
29
  // * for verbose logging
30
30
  // */
31
- // const logalot = GLOBAL_LOG_A_LOT || true; // change this when you want to turn off verbose logging
31
+ // const logalot = GLOBAL_LOG_A_LOT; // change this when you want to turn off verbose logging
32
32
 
33
33
  // const lcFile: string = `[${pathUtils.basename(import.meta.url)}]`;
34
34
 
@@ -34,7 +34,7 @@ import { SUBJECT_ATOM } from '../subject/subject-constants.mjs';
34
34
  /**
35
35
  * for logging. import this constant from your project.
36
36
  */
37
- const logalot = GLOBAL_LOG_A_LOT; // remove the true to "turn off" verbose logging
37
+ const logalot = GLOBAL_LOG_A_LOT;
38
38
 
39
39
  export function validateCommonObservableData({
40
40
  data,
@@ -36,7 +36,7 @@ import { Subject_V1_Factory } from './subject-v1.mjs';
36
36
  /**
37
37
  * for logging. import this constant from your project.
38
38
  */
39
- const logalot = GLOBAL_LOG_A_LOT; // remove the true to "turn off" verbose logging
39
+ const logalot = GLOBAL_LOG_A_LOT;
40
40
 
41
41
  export function validateCommonSubjectData({
42
42
  data,
@@ -32,7 +32,7 @@ import { Subscription_V1, Subscription_V1_Factory } from './subscription-v1.mjs'
32
32
  /**
33
33
  * for logging. import this constant from your project.
34
34
  */
35
- const logalot = GLOBAL_LOG_A_LOT; // remove the true to "turn off" verbose logging
35
+ const logalot = GLOBAL_LOG_A_LOT;
36
36
 
37
37
  export function validateCommonSubscriptionData({
38
38
  data,
@@ -16,14 +16,12 @@ import {
16
16
  testSpace_putGetDelete,
17
17
  testSpace_registerNewIbGib_GetLatest,
18
18
  } from '../space-respec-helper.mjs';
19
- import { InnerSpace_V1, } from './inner-space-v1.mjs';
19
+ import { InnerSpace_V1, } from './inner-space-v1.mjs';
20
20
  import { createTimeline, getHistory, mut8Timeline } from '../../../timeline/timeline-api.mjs';
21
21
  import { MetaspaceService } from '../metaspace/metaspace-types.mjs';
22
22
  import { Metaspace_Innerspace } from '../metaspace/metaspace-innerspace/metaspace-innerspace.mjs';
23
23
  // import { getLatestAddrs, putInSpace } from '../space-helper.mjs';
24
24
 
25
- // ifWeMight() // don't remove this line while we're actively testing on this file. it is a limitation of my shortcut discovery script that it looks for a regex that matches ifWeMight/respecfullyDear followed by an open paren
26
-
27
25
  const logalot = true;
28
26
  /**
29
27
  * not sure where to put this, but we probably will want to reuse this in the
@@ -71,8 +69,8 @@ async function getNewInitializedInMemoryMetaspaceForTesting({
71
69
  }
72
70
  }
73
71
 
74
- await respecfullyDear(sir, 'metaspace setup itself', async () => {
75
- await ifWeMight(sir, 'should init a metaspace', async () => {
72
+ await respecfully(sir, 'metaspace setup itself', async () => {
73
+ await ifWe(sir, 'should init a metaspace', async () => {
76
74
  const testSpaceName = 'TestSpaceName';
77
75
 
78
76
  const metaspace = await getNewInitializedInMemoryMetaspaceForTesting({
@@ -83,7 +81,7 @@ await respecfullyDear(sir, 'metaspace setup itself', async () => {
83
81
  });
84
82
  });
85
83
 
86
- // await respecfullyDear(sir, `[${InnerSpace_V1.name} specs]`, async () => {
84
+ // await respecfully(sir, `[${InnerSpace_V1.name} specs]`, async () => {
87
85
 
88
86
  // await testSpace_createAndInit({
89
87
  // respecfulTitle: sir,
@@ -53,7 +53,7 @@ import { newUpMetaStone } from '../../common/meta-stone/meta-stone-helper.mjs';
53
53
  import { WITNESS_ATOM } from '../witness-constants.mjs';
54
54
  import { SyncSpaceIbGib } from './outer-space/outer-space-types.mjs';
55
55
 
56
- let logalot = GLOBAL_LOG_A_LOT || true;
56
+ let logalot = GLOBAL_LOG_A_LOT;
57
57
 
58
58
 
59
59
  /**
@@ -1,177 +0,0 @@
1
- import { IbGib_V1 } from '@ibgib/ts-gib/dist/V1/index.mjs';
2
- import { WitnessWithContextBase_V1 } from '../witness-with-context/witness-with-context-base-v1.mjs';
3
- import { ErrorIbGib_V1 } from '../../common/error/error-types.mjs';
4
- import { KeystoneData_V1, KeystoneRel8ns_V1, KeystoneIbGib_V1, KeystoneOptionsIbGib, KeystoneOptionsData, KeystoneOptionsRel8ns, KeystoneResultIbGib, KeystoneResultData, KeystoneResultRel8ns } from './keystone-types.mjs';
5
- import { PicIbGib_V1 } from '../../common/pic/pic-types.mjs';
6
- import { CommentIbGib_V1 } from '../../common/comment/comment-types.mjs';
7
- /**
8
- * Keystone is the last major piece of the ibgib architecture. This is used to
9
- * implement distributed identity that gets added on-chain alongside other data
10
- * and metadata, instead of only relying solely upon asymmetric crypto for e.g.
11
- * signatures.
12
- *
13
- * Override this class with specific concrete implementations of keystones,
14
- * which atow I believe will differ mainly in their specific challenge
15
- * implementations.
16
- *
17
- * ## notes
18
- *
19
- * ### composite keystones
20
- *
21
- * At first I was thinking I was going to make keystones composite (super
22
- * keystones with rel8ns pointing to other keystones), but at least to start
23
- * with, I will have a specific concrete implementation class that covers
24
- * multiple keystone composition.
25
- */
26
- export declare abstract class KeystoneBase_V1<TChallenges, TSolutions, TOptionsData extends KeystoneOptionsData, TOptionsRel8ns extends KeystoneOptionsRel8ns, TOptionsIbGib extends KeystoneOptionsIbGib<IbGib_V1, TOptionsData, TOptionsRel8ns>, TResultData extends KeystoneResultData, TResultRel8ns extends KeystoneResultRel8ns, TResultIbGib extends KeystoneResultIbGib<IbGib_V1, TResultData, TResultRel8ns> | ErrorIbGib_V1, TData extends KeystoneData_V1<TChallenges, TSolutions>, TRel8ns extends KeystoneRel8ns_V1> extends WitnessWithContextBase_V1<TOptionsData, TOptionsRel8ns, TOptionsIbGib, TResultData, TResultRel8ns, TResultIbGib, TData, TRel8ns> implements KeystoneIbGib_V1<TData, TRel8ns> {
27
- /**
28
- * Log context for convenience with logging. (Ignore if you don't want to use this.)
29
- */
30
- protected lc: string;
31
- constructor(initialData?: TData, initialRel8ns?: TRel8ns);
32
- /**
33
- * At this point in time, the arg has already been intrinsically validated,
34
- * as well as the internal state of this keystone.
35
- */
36
- protected witnessImpl(arg: TOptionsIbGib): Promise<TResultIbGib | undefined>;
37
- /**
38
- * Base routing executes different if incoming is a cmd options arg, i.e.,
39
- * if the `data.cmd` is truthy (atow). {@link isArg} is expected to be true
40
- * at this point. If not, logs an error, **but does not throw**, and returns
41
- * undefined.
42
- *
43
- * Default routing checks arg for command, or if not, checks if comment/pic.
44
- * If neither of those, then returns undefined atow.
45
- *
46
- * Override this function to create more advanced custom routing.
47
- *
48
- * ## notes
49
- *
50
- * In general, an app ibgib acts more like a normal application in that it
51
- * accepts commands and not requests. Robbots are more geared to requests,
52
- * handled semantically.
53
- *
54
- * @see {@link isArg}
55
- * @see {@link doCmdArg}
56
- * @see {@link doDefault}.
57
- */
58
- protected routeAndDoArg({ arg, }: {
59
- arg: TOptionsIbGib;
60
- }): Promise<TResultIbGib | undefined>;
61
- /**
62
- * By default, this routes to {@link doCmdIb}, {@link doCmdGib} & {@link
63
- * doCmdIbgib}. This is largely to limit scope of responsibility of app to
64
- * basic functions. But this is not a concrete rule written in stone.
65
- *
66
- * You can always override this and route to other commands before calling
67
- * this with `super.doCmdArg` as a fallback (if you still want to use this
68
- * function.)
69
- *
70
- * Note that this @throws an error if the data.cmd is not recognized. In this
71
- * implementation, this occurs if it isn't an ib/gib/ibgib _command_.
72
- *
73
- * ## commands
74
- *
75
- * ### confirm
76
- *
77
- * confirm possession of the keystone via the keystone's challenges as set
78
- * out in the keystone's metadata.
79
- *
80
- * ### confirm final
81
- *
82
- * final confirmation of a secret of the stone. "kills" the stone once used.
83
- * The point is to verify if a participant has the full secret of the stone,
84
- * and not just mimicked part of the stone's ownership.
85
- *
86
- * ### revoke
87
- *
88
- * revoke due to being broken.
89
- * maybe is a flavor of the confirm final?
90
- */
91
- protected doCmdArg({ arg, }: {
92
- arg: TOptionsIbGib;
93
- }): Promise<TResultIbGib>;
94
- protected doCmdIb({ arg, }: {
95
- arg: TOptionsIbGib;
96
- }): Promise<TResultIbGib>;
97
- /**
98
- * this is the primary command handler when extending a keystone, i.e. when
99
- * signing some payload.
100
- */
101
- protected abstract extend({ arg }: {
102
- arg: TOptionsIbGib;
103
- }): Promise<TResultIbGib>;
104
- protected doCmdGib({ arg, }: {
105
- arg: TOptionsIbGib;
106
- }): Promise<TResultIbGib>;
107
- protected doCmdIbgib({ arg, }: {
108
- arg: TOptionsIbGib;
109
- }): Promise<TResultIbGib>;
110
- /**
111
- * Stubbed in base class for convenience. Doesn't have to be implemented.
112
- *
113
- * in the future, this may be able to be used for physical object
114
- * verification via picture.
115
- */
116
- protected doPic({ ibGib, }: {
117
- ibGib: PicIbGib_V1;
118
- }): Promise<TResultIbGib | undefined>;
119
- /**
120
- * Stubbed in base class for convenience. Doesn't have to be implemented.
121
- *
122
- * in the future, this may be able to handle natural language and route
123
- * accordingly.
124
- */
125
- protected doComment({ ibGib, }: {
126
- ibGib: CommentIbGib_V1;
127
- }): Promise<TResultIbGib | undefined>;
128
- protected doNonArg({ ibGib, }: {
129
- ibGib: TOptionsIbGib;
130
- }): Promise<TResultIbGib | undefined>;
131
- /**
132
- * Stubbed in base class for convenience. Doesn't have to be implemented.
133
- */
134
- protected doDefault({ ibGib, }: {
135
- ibGib: TOptionsIbGib;
136
- }): Promise<TResultIbGib | undefined>;
137
- /**
138
- * validates against common app qualities.
139
- *
140
- * Override this with a call to `super.validateThis` for custom validation
141
- * for descending app classes.
142
- *
143
- * @returns validation errors common to all apps, if any errors exist.
144
- */
145
- protected validateThis(): Promise<string[]>;
146
- /**
147
- * builds an arg ibGib.
148
- *
149
- * wrapper convenience to avoid long generic calls.
150
- */
151
- argy<TOptionsData extends KeystoneOptionsData = KeystoneOptionsData, TOptionsRel8ns extends KeystoneOptionsRel8ns = KeystoneOptionsRel8ns, TOptionsIbGib extends KeystoneOptionsIbGib<IbGib_V1, TOptionsData, TOptionsRel8ns> = KeystoneOptionsIbGib<IbGib_V1, TOptionsData, TOptionsRel8ns>>({ argData, ibMetadata, noTimestamp, ibGibs, }: {
152
- argData: TOptionsData;
153
- ibMetadata?: string;
154
- noTimestamp?: boolean;
155
- ibGibs?: IbGib_V1[];
156
- }): Promise<TOptionsIbGib>;
157
- /**
158
- * builds a result ibGib, if indeed a result ibgib is required.
159
- *
160
- * This is only useful in apps that have more structured inputs/outputs.
161
- * For those that simply accept any ibgib incoming and return a
162
- * primitive like ib^gib or whatever, then this is unnecessary.
163
- *
164
- * wrapper convenience to avoid long generic calls.
165
- */
166
- resulty<TResultData extends KeystoneResultData = KeystoneResultData, TResultRel8ns extends KeystoneResultRel8ns = KeystoneResultRel8ns, TResultIbGib extends KeystoneResultIbGib<IbGib_V1, TResultData, TResultRel8ns> = KeystoneResultIbGib<IbGib_V1, TResultData, TResultRel8ns>>({ resultData, ibGibs, }: {
167
- resultData: TResultData;
168
- ibGibs?: IbGib_V1[];
169
- }): Promise<TResultIbGib>;
170
- }
171
- /**
172
- * useful for when passing around instances of keystones where implementation
173
- * details are not important.
174
- */
175
- export interface IbGibKeystoneAny extends KeystoneBase_V1<any, any, any, any, any, any, any, any, any, any> {
176
- }
177
- //# sourceMappingURL=keystone-base-v1.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"keystone-base-v1.d.mts","sourceRoot":"","sources":["../../../src/witness/keystone/keystone-base-v1.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAmB,MAAM,iCAAiC,CAAC;AAI5E,OAAO,EAAE,yBAAyB,EAAE,MAAM,0DAA0D,CAAC;AACrG,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAGnE,OAAO,EACH,eAAe,EAAE,iBAAiB,EAAE,gBAAgB,EACpD,oBAAoB,EAAE,mBAAmB,EAAE,qBAAqB,EAChE,mBAAmB,EAAE,kBAAkB,EAAE,oBAAoB,EAKhE,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AAMzE;;;;;;;;;;;;;;;;;;GAkBG;AACH,8BAAsB,eAAe,CACjC,WAAW,EAAE,UAAU,EACvB,YAAY,SAAS,mBAAmB,EACxC,cAAc,SAAS,qBAAqB,EAC5C,aAAa,SAAS,oBAAoB,CAAC,QAAQ,EAAE,YAAY,EAAE,cAAc,CAAC,EAClF,WAAW,SAAS,kBAAkB,EACtC,aAAa,SAAS,oBAAoB,EAC1C,YAAY,SAAS,mBAAmB,CAAC,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B;;;;;;;;OAQG;IACG,OAAO,CACT,WAAW,SAAS,kBAAkB,GAAG,kBAAkB,EAC3D,aAAa,SAAS,oBAAoB,GAAG,oBAAoB,EACjE,YAAY,SAAS,mBAAmB,CAAC,QAAQ,EAAE,WAAW,EAAE,aAAa,CAAC,GAC9E,mBAAmB,CAAC,QAAQ,EAAE,WAAW,EAAE,aAAa,CAAC,EAC3D,EACE,UAAU,EACV,MAAM,GACT,EAAE;QACC,UAAU,EAAE,WAAW,CAAC;QACxB,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC;KACvB,GAAG,OAAO,CAAC,YAAY,CAAC;CAS5B;AAED;;;GAGG;AACH,MAAM,WAAW,gBACb,SAAQ,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;CAC5E"}
@@ -1,397 +0,0 @@
1
- import { argy_, isArg, isCommand, resulty_ } from '../witness-helper.mjs';
2
- import { WitnessWithContextBase_V1 } from '../witness-with-context/witness-with-context-base-v1.mjs';
3
- import { getErrorIbGib } from '../../common/error/error-helper.mjs';
4
- import { KeystoneCmd,
5
- // KeystoneCmd,
6
- // KeystoneCmdData, KeystoneCmdRel8ns, KeystoneCmdIbGib,
7
- // KeystoneResultData, KeystoneResultRel8ns, KeystoneResultIbGib,
8
- } from './keystone-types.mjs';
9
- import { validateCommonKeystoneData } from './keystone-helper.mjs';
10
- import { GLOBAL_LOG_A_LOT } from '../../core-constants.mjs';
11
- const logalot = GLOBAL_LOG_A_LOT;
12
- /**
13
- * Keystone is the last major piece of the ibgib architecture. This is used to
14
- * implement distributed identity that gets added on-chain alongside other data
15
- * and metadata, instead of only relying solely upon asymmetric crypto for e.g.
16
- * signatures.
17
- *
18
- * Override this class with specific concrete implementations of keystones,
19
- * which atow I believe will differ mainly in their specific challenge
20
- * implementations.
21
- *
22
- * ## notes
23
- *
24
- * ### composite keystones
25
- *
26
- * At first I was thinking I was going to make keystones composite (super
27
- * keystones with rel8ns pointing to other keystones), but at least to start
28
- * with, I will have a specific concrete implementation class that covers
29
- * multiple keystone composition.
30
- */
31
- export class KeystoneBase_V1 extends WitnessWithContextBase_V1 {
32
- /**
33
- * Log context for convenience with logging. (Ignore if you don't want to use this.)
34
- */
35
- lc = `[${KeystoneBase_V1.name}]`;
36
- // /**
37
- // * Reference to the local ibgibs service, which is one way at getting at the
38
- // * local user space.
39
- // */
40
- // metaspace: MetaspaceService | undefined;
41
- constructor(initialData, initialRel8ns) {
42
- super(initialData, initialRel8ns);
43
- }
44
- /**
45
- * At this point in time, the arg has already been intrinsically validated,
46
- * as well as the internal state of this keystone.
47
- */
48
- async witnessImpl(arg) {
49
- const lc = `${this.lc}[${this.witnessImpl.name}]`;
50
- try {
51
- if (logalot) {
52
- console.log(`${lc} starting...`);
53
- }
54
- await this.loadNewerSelfIfAvailable();
55
- let result = undefined;
56
- if (isArg({ ibGib: arg })) {
57
- result = await this.routeAndDoArg({ arg });
58
- }
59
- else {
60
- result = await this.doNonArg({ ibGib: arg });
61
- }
62
- // if we didn't get a result, try the default.
63
- if (!result) {
64
- console.warn(`${lc} result still falsy. doing default handler. (W: 924d1fc93ad5464e81f71f2783d778a8)`);
65
- result = await this.doDefault({ ibGib: arg });
66
- }
67
- if (!result) {
68
- console.warn(`${lc} result falsy...Could not produce result? Was doDefault implemented in concrete class? (W: 78861cb3c37546fa8f0b2bee4c50f832)`);
69
- }
70
- return result;
71
- }
72
- catch (error) {
73
- console.error(`${lc} ${error.message}`);
74
- throw error;
75
- }
76
- finally {
77
- if (logalot) {
78
- console.log(`${lc} complete.`);
79
- }
80
- }
81
- }
82
- /**
83
- * Base routing executes different if incoming is a cmd options arg, i.e.,
84
- * if the `data.cmd` is truthy (atow). {@link isArg} is expected to be true
85
- * at this point. If not, logs an error, **but does not throw**, and returns
86
- * undefined.
87
- *
88
- * Default routing checks arg for command, or if not, checks if comment/pic.
89
- * If neither of those, then returns undefined atow.
90
- *
91
- * Override this function to create more advanced custom routing.
92
- *
93
- * ## notes
94
- *
95
- * In general, an app ibgib acts more like a normal application in that it
96
- * accepts commands and not requests. Robbots are more geared to requests,
97
- * handled semantically.
98
- *
99
- * @see {@link isArg}
100
- * @see {@link doCmdArg}
101
- * @see {@link doDefault}.
102
- */
103
- async routeAndDoArg({ arg, }) {
104
- const lc = `${this.lc}[${this.routeAndDoArg.name}]`;
105
- try {
106
- if (logalot) {
107
- console.log(`${lc} starting...`);
108
- }
109
- const ibGib = arg;
110
- if (!isArg({ ibGib })) {
111
- throw new Error(`ibGib is not an arg (E: 7e5ed6e3be45480e992c75a1c21f1b4e)`);
112
- }
113
- if (isCommand({ ibGib })) {
114
- return this.doCmdArg({ arg });
115
- }
116
- else {
117
- return undefined;
118
- }
119
- }
120
- catch (error) {
121
- console.error(`${lc} ${error.message}`);
122
- if (this.data?.catchAllErrors) {
123
- return (await getErrorIbGib({ rawMsg: error.message }));
124
- }
125
- else {
126
- throw error;
127
- }
128
- }
129
- finally {
130
- if (logalot) {
131
- console.log(`${lc} complete.`);
132
- }
133
- }
134
- }
135
- // #region do cmd args
136
- /**
137
- * By default, this routes to {@link doCmdIb}, {@link doCmdGib} & {@link
138
- * doCmdIbgib}. This is largely to limit scope of responsibility of app to
139
- * basic functions. But this is not a concrete rule written in stone.
140
- *
141
- * You can always override this and route to other commands before calling
142
- * this with `super.doCmdArg` as a fallback (if you still want to use this
143
- * function.)
144
- *
145
- * Note that this @throws an error if the data.cmd is not recognized. In this
146
- * implementation, this occurs if it isn't an ib/gib/ibgib _command_.
147
- *
148
- * ## commands
149
- *
150
- * ### confirm
151
- *
152
- * confirm possession of the keystone via the keystone's challenges as set
153
- * out in the keystone's metadata.
154
- *
155
- * ### confirm final
156
- *
157
- * final confirmation of a secret of the stone. "kills" the stone once used.
158
- * The point is to verify if a participant has the full secret of the stone,
159
- * and not just mimicked part of the stone's ownership.
160
- *
161
- * ### revoke
162
- *
163
- * revoke due to being broken.
164
- * maybe is a flavor of the confirm final?
165
- */
166
- doCmdArg({ arg, }) {
167
- const lc = `${this.lc}[${this.doCmdArg.name}]`;
168
- try {
169
- if (logalot) {
170
- console.log(`${lc} starting...`);
171
- }
172
- if (!arg.data?.cmd) {
173
- throw new Error(`invalid cmd arg. arg.data.cmd required. (E: 470aabf26ca6406b84dbae3b9b39639d)`);
174
- }
175
- if (arg.data.cmd === KeystoneCmd.ib) {
176
- return this.doCmdIb({ arg: arg });
177
- }
178
- else if (arg.data.cmd === KeystoneCmd.gib) {
179
- return this.doCmdGib({ arg: arg });
180
- }
181
- else if (arg.data.cmd === KeystoneCmd.ibgib) {
182
- return this.doCmdIbgib({ arg: arg });
183
- }
184
- else {
185
- throw new Error(`unknown arg.data.cmd: ${arg.data.cmd} (E: 0eb81ae8c3834f47865af0ac7b7a9fd6)`);
186
- }
187
- }
188
- catch (error) {
189
- console.error(`${lc} ${error.message}`);
190
- throw error;
191
- }
192
- finally {
193
- if (logalot) {
194
- console.log(`${lc} complete.`);
195
- }
196
- }
197
- }
198
- doCmdIb({ arg, }) {
199
- return this.extend({ arg });
200
- }
201
- doCmdGib({ arg, }) {
202
- const lc = `${this.lc}[${this.doCmdGib.name}]`;
203
- try {
204
- if (logalot) {
205
- console.log(`${lc} starting...`);
206
- }
207
- throw new Error(`not implemented in base class (E: bb16814f46984a9dafac5b85d8ec1f74)`);
208
- }
209
- catch (error) {
210
- console.error(`${lc} ${error.message}`);
211
- throw error;
212
- }
213
- finally {
214
- if (logalot) {
215
- console.log(`${lc} complete.`);
216
- }
217
- }
218
- }
219
- doCmdIbgib({ arg, }) {
220
- const lc = `${this.lc}[${this.doCmdIbgib.name}]`;
221
- try {
222
- if (logalot) {
223
- console.log(`${lc} starting...`);
224
- }
225
- throw new Error(`not implemented in base class (E: 6f3ed691d16a43f49145b2ed46fb28ba)`);
226
- }
227
- catch (error) {
228
- console.error(`${lc} ${error.message}`);
229
- throw error;
230
- }
231
- finally {
232
- if (logalot) {
233
- console.log(`${lc} complete.`);
234
- }
235
- }
236
- }
237
- // #endregion do cmd args
238
- // #region other stubbed do functions (doPic, doComment, doDefault)
239
- /**
240
- * Stubbed in base class for convenience. Doesn't have to be implemented.
241
- *
242
- * in the future, this may be able to be used for physical object
243
- * verification via picture.
244
- */
245
- doPic({ ibGib, }) {
246
- const lc = `${this.lc}[${this.doPic.name}]`;
247
- try {
248
- if (logalot) {
249
- console.log(`${lc} starting...`);
250
- }
251
- throw new Error(`not implemented in base class (E: ce5c9b30622f4b3bab198dde04de75e7)`);
252
- }
253
- catch (error) {
254
- console.error(`${lc} ${error.message}`);
255
- throw error;
256
- }
257
- finally {
258
- if (logalot) {
259
- console.log(`${lc} complete.`);
260
- }
261
- }
262
- }
263
- /**
264
- * Stubbed in base class for convenience. Doesn't have to be implemented.
265
- *
266
- * in the future, this may be able to handle natural language and route
267
- * accordingly.
268
- */
269
- doComment({ ibGib, }) {
270
- const lc = `${this.lc}[${this.doComment.name}]`;
271
- try {
272
- if (logalot) {
273
- console.log(`${lc} starting...`);
274
- }
275
- throw new Error(`not implemented in base class (E: c90f5bddaa58446fb4de638816974b6c)`);
276
- }
277
- catch (error) {
278
- console.error(`${lc} ${error.message}`);
279
- throw error;
280
- }
281
- finally {
282
- if (logalot) {
283
- console.log(`${lc} complete.`);
284
- }
285
- }
286
- }
287
- doNonArg({ ibGib, }) {
288
- const lc = `${this.lc}[${this.doNonArg.name}]`;
289
- try {
290
- if (logalot) {
291
- console.log(`${lc} starting...`);
292
- }
293
- return this.doDefault({ ibGib });
294
- }
295
- catch (error) {
296
- console.error(`${lc} ${error.message}`);
297
- throw error;
298
- }
299
- finally {
300
- if (logalot) {
301
- console.log(`${lc} complete.`);
302
- }
303
- }
304
- }
305
- /**
306
- * Stubbed in base class for convenience. Doesn't have to be implemented.
307
- */
308
- doDefault({ ibGib, }) {
309
- const lc = `${this.lc}[${this.doDefault.name}]`;
310
- try {
311
- if (logalot) {
312
- console.log(`${lc} starting...`);
313
- }
314
- throw new Error(`not implemented in base class (E: bee031bb4c974a71bae82df7cff2b4e1)`);
315
- // return this.doDefaultImpl({ibGib});
316
- }
317
- catch (error) {
318
- console.error(`${lc} ${error.message}`);
319
- throw error;
320
- }
321
- finally {
322
- if (logalot) {
323
- console.log(`${lc} complete.`);
324
- }
325
- }
326
- }
327
- // #endregion other stubbed do functions (doPic, doComment, doDefault)
328
- /**
329
- * validates against common app qualities.
330
- *
331
- * Override this with a call to `super.validateThis` for custom validation
332
- * for descending app classes.
333
- *
334
- * @returns validation errors common to all apps, if any errors exist.
335
- */
336
- async validateThis() {
337
- const lc = `${this.lc}[${this.validateThis.name}]`;
338
- try {
339
- if (logalot) {
340
- console.log(`${lc} starting...`);
341
- }
342
- if (!this.data) {
343
- throw new Error(`(UNEXPECTED) this.data falsy? (E: bd4b0fc836774eb288b8b07ec79cb4af)`);
344
- }
345
- const errors = [
346
- // ...await super.validateThis(),
347
- ...validateCommonKeystoneData({ appData: this.data }),
348
- ];
349
- return errors;
350
- }
351
- catch (error) {
352
- console.error(`${lc} ${error.message}`);
353
- throw error;
354
- }
355
- finally {
356
- if (logalot) {
357
- console.log(`${lc} complete.`);
358
- }
359
- }
360
- }
361
- /**
362
- * builds an arg ibGib.
363
- *
364
- * wrapper convenience to avoid long generic calls.
365
- */
366
- async argy({ argData, ibMetadata, noTimestamp, ibGibs, }) {
367
- const arg = await argy_({
368
- argData,
369
- ibMetadata,
370
- noTimestamp
371
- });
372
- if (ibGibs) {
373
- arg.ibGibs = ibGibs;
374
- }
375
- return arg;
376
- }
377
- /**
378
- * builds a result ibGib, if indeed a result ibgib is required.
379
- *
380
- * This is only useful in apps that have more structured inputs/outputs.
381
- * For those that simply accept any ibgib incoming and return a
382
- * primitive like ib^gib or whatever, then this is unnecessary.
383
- *
384
- * wrapper convenience to avoid long generic calls.
385
- */
386
- async resulty({ resultData, ibGibs, }) {
387
- const result = await resulty_({
388
- // ibMetadata: getKeystoneResultMetadata({space: this}),
389
- resultData,
390
- });
391
- if (ibGibs) {
392
- result.ibGibs = ibGibs;
393
- }
394
- return result;
395
- }
396
- }
397
- //# sourceMappingURL=keystone-base-v1.mjs.map