@ibgib/node-gib 0.0.17 → 0.0.19

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 (38) hide show
  1. package/dist/email/verify/email-verify-helpers.d.mts.map +1 -1
  2. package/dist/email/verify/email-verify-helpers.mjs +12 -3
  3. package/dist/email/verify/email-verify-helpers.mjs.map +1 -1
  4. package/dist/serve-gib/handlers/api/email/email-outbound.handler.d.mts.map +1 -1
  5. package/dist/serve-gib/handlers/api/email/email-outbound.handler.mjs +2 -25
  6. package/dist/serve-gib/handlers/api/email/email-outbound.handler.mjs.map +1 -1
  7. package/dist/serve-gib/handlers/api/email/email-verification-code.handler.d.mts.map +1 -1
  8. package/dist/serve-gib/handlers/api/email/email-verification-code.handler.mjs +2 -26
  9. package/dist/serve-gib/handlers/api/email/email-verification-code.handler.mjs.map +1 -1
  10. package/dist/serve-gib/handlers/api/identity/keystone-custodian-genesis.handler.d.mts.map +1 -1
  11. package/dist/serve-gib/handlers/api/identity/keystone-custodian-genesis.handler.mjs +11 -4
  12. package/dist/serve-gib/handlers/api/identity/keystone-custodian-genesis.handler.mjs.map +1 -1
  13. package/dist/serve-gib/handlers/api/identity/keystone-custodian-register-delegate.handler.d.mts.map +1 -1
  14. package/dist/serve-gib/handlers/api/identity/keystone-custodian-register-delegate.handler.mjs +5 -3
  15. package/dist/serve-gib/handlers/api/identity/keystone-custodian-register-delegate.handler.mjs.map +1 -1
  16. package/dist/serve-gib/handlers/api/keystone/sso-login.handler.d.mts.map +1 -1
  17. package/dist/serve-gib/handlers/api/keystone/sso-login.handler.mjs +15 -6
  18. package/dist/serve-gib/handlers/api/keystone/sso-login.handler.mjs.map +1 -1
  19. package/e2e/identity-sso-lifecycle.e2e.md +9 -7
  20. package/package.json +5 -5
  21. package/src/email/verify/email-verify-helpers.mts +14 -3
  22. package/src/serve-gib/handlers/api/email/email-outbound.handler.mts +2 -23
  23. package/src/serve-gib/handlers/api/email/email-verification-code.handler.mts +2 -22
  24. package/src/serve-gib/handlers/api/identity/keystone-custodian-genesis.handler.mts +12 -4
  25. package/src/serve-gib/handlers/api/identity/keystone-custodian-register-delegate.handler.mts +5 -3
  26. package/src/serve-gib/handlers/api/identity/keystone-custodian-register-delegate.respec.mts +1 -1
  27. package/src/serve-gib/handlers/api/keystone/sso-login.handler.mts +17 -7
  28. package/data/identity_index/email/hashes/32/13/49/e64f32730f01a61ada211f29eaf0a210fc2386b668ad04d7e8a9b16766.json +0 -4
  29. package/dist/serve-gib/handlers/api/ibgib/ibgib-handler-types.d.mts +0 -41
  30. package/dist/serve-gib/handlers/api/ibgib/ibgib-handler-types.d.mts.map +0 -1
  31. package/dist/serve-gib/handlers/api/ibgib/ibgib-handler-types.mjs +0 -34
  32. package/dist/serve-gib/handlers/api/ibgib/ibgib-handler-types.mjs.map +0 -1
  33. package/dist/serve-gib/handlers/api/ibgib/ibgib.handler.d.mts +0 -26
  34. package/dist/serve-gib/handlers/api/ibgib/ibgib.handler.d.mts.map +0 -1
  35. package/dist/serve-gib/handlers/api/ibgib/ibgib.handler.mjs +0 -179
  36. package/dist/serve-gib/handlers/api/ibgib/ibgib.handler.mjs.map +0 -1
  37. package/src/serve-gib/handlers/api/ibgib/ibgib-handler-types.mts +0 -49
  38. package/src/serve-gib/handlers/api/ibgib/ibgib.handler.mts +0 -176
@@ -1,176 +0,0 @@
1
- /**
2
- * @module serve-gib/handlers/api/ibgib
3
- */
4
-
5
- import { extractErrorMsg } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
6
- import { getIbGibAddr } from '@ibgib/ts-gib/dist/helper.mjs';
7
- import { IbGib_V1 } from '@ibgib/ts-gib/dist/V1/types.mjs';
8
-
9
- import { GLOBAL_LOG_A_LOT } from '../../../constants.mjs';
10
- import { ServeGibHandlerWithMetaspaceBase } from '../../handler-base.mjs';
11
- import { RequestContext, ResponseResult, ServeGibHttpMethod } from '../../../types.mjs';
12
- import { validateAddressSegment } from '../../../path-helper.mjs';
13
- import { API_PATH_REGEXES } from '../../../path-constants.mjs';
14
- import {
15
- DEFAULT_QUERY_PARAMS_GET_IBGIB, IbGibGetQueryParams, IbGibParams,
16
- isKnownQueryParamsKey_IbGibGet, KNOWN_QUERY_PARAMS_IBGIB_GET
17
- } from './ibgib-handler-types.mjs';
18
- import { validateAndCoerceBooleanQueryParam } from '../../../serve-gib-helpers.mjs';
19
-
20
- export interface IbGibGraphResponseBody {
21
- addr: string;
22
- count: number;
23
- graph: Record<string, IbGib_V1>;
24
- }
25
-
26
- const logalot = GLOBAL_LOG_A_LOT;
27
-
28
- /**
29
- * GET /api/ibgib/:domainAddr/:ibGibAddr
30
- */
31
- export class IbGibHandler extends ServeGibHandlerWithMetaspaceBase<IbGibParams, IbGibGetQueryParams> {
32
- protected override lc: string = `[${IbGibHandler.name}]`;
33
- protected override method: ServeGibHttpMethod = 'GET';
34
- protected override regex = API_PATH_REGEXES.IBGIB_ADDR;
35
-
36
- protected override async parseParamsImpl(reqCtx: RequestContext<IbGibParams, IbGibGetQueryParams>): Promise<IbGibParams | undefined> {
37
- const lc = `${this.lc}[${this.parseParamsImpl.name}]`;
38
- try {
39
- if (logalot) { console.log(`${lc} starting...`); }
40
- const match = reqCtx.pathname.match(this.regex);
41
- if (!match) { throw new Error(`(UNEXPECTED) match falsy for regex? at this point, we have passed canHandleRoute, so this should parse correctly. (E: 8ce0810a3a88f420639bf8286df1d826)`); }
42
- const domainIb = decodeURIComponent(match[1]);
43
- const domainGib = decodeURIComponent(match[2]);
44
- const domainAddr = getIbGibAddr({ ib: domainIb, gib: domainGib });
45
- const ibGibIb = decodeURIComponent(match[3]);
46
- const ibGibGib = decodeURIComponent(match[4]);
47
- const ibGibAddr = getIbGibAddr({ ib: ibGibIb, gib: ibGibGib });
48
- return {
49
- ibGibIb, ibGibGib, ibGibAddr,
50
- domainInfo: this.getDomainInfo({ domainAddr }),
51
- };
52
- } catch (error) {
53
- console.error(`${lc} ${extractErrorMsg(error)}`);
54
- throw error;
55
- } finally {
56
- if (logalot) { console.log(`${lc} complete.`); }
57
- }
58
- }
59
-
60
- protected override async validateQueryParams({ queryParams }: { queryParams: any; }): Promise<string[]> {
61
- const lc = `${this.lc}[${this.validateQueryParams.name}]`;
62
- try {
63
- if (logalot) { console.log(`${lc} starting...`); }
64
-
65
- const errors: string[] = [];
66
-
67
- // strict checking
68
- const queryParamsKeys = Object.keys(queryParams);
69
- const invalidKeys: string[] = queryParamsKeys.filter(x => !isKnownQueryParamsKey_IbGibGet(x));
70
- if (invalidKeys.length > 0) {
71
- throw new Error(`invalid query params keys: ${invalidKeys.join(', ')}. valid query params keys: ${KNOWN_QUERY_PARAMS_IBGIB_GET.join(', ')} (E: b7e8a9f2c1d34e56b89a01d4f2e7c326)`);
72
- }
73
-
74
- // Enforce that EVERY key must have a validation function mapping
75
- type ValidationFn = () => Promise<void>;
76
- const ValidationFns: Record<KNOWN_QUERY_PARAMS_IBGIB_GET, ValidationFn> = {
77
- getLatest: async () => validateAndCoerceBooleanQueryParam(queryParams, 'getLatest', errors),
78
- getGraph: async () => validateAndCoerceBooleanQueryParam(queryParams, 'getGraph', errors),
79
- addrOnly: async () => validateAndCoerceBooleanQueryParam(queryParams, 'addrOnly', errors),
80
- };
81
-
82
- // execute all validation functions
83
- for (const fn of Object.values(ValidationFns)) {
84
- await fn();
85
- }
86
-
87
- return errors;
88
-
89
- } catch (error) {
90
- console.error(`${lc} ${extractErrorMsg(error)}`);
91
- throw error;
92
- } finally {
93
- if (logalot) { console.log(`${lc} complete.`); }
94
- }
95
- }
96
-
97
- protected async handleRouteImpl(reqCtx: RequestContext<IbGibParams, IbGibGetQueryParams>): Promise<ResponseResult | undefined> {
98
- const lc = `${this.lc}[${this.handleRouteImpl.name}]`;
99
- try {
100
- if (logalot) { console.log(`${lc} starting... (I: 03d6a889b1f8af879c0f7158a3b3de26)`); }
101
-
102
- if (logalot) { console.log(`${lc} starting... (I: 03d6a889b1f8af879c0f7158a3b3de26)`); }
103
- if (!reqCtx.metaspace) { throw new Error(`(UNEXPECTED) metaspace falsy? we should have initialized it by now since this is a domain-dependent handler (E: 864661c668d2aa1918b7ee677a7d9c26)`); }
104
-
105
- const { ibGibIb, ibGibGib } = reqCtx.params as IbGibParams;
106
- if (!ibGibIb || !ibGibGib) { return undefined; }
107
-
108
- // Reconstruct addr from params
109
- const rawAddr = `${ibGibIb}^${ibGibGib}`;
110
- if (!validateAddressSegment(rawAddr)) return this.error(400, 'Invalid address format');
111
- const addr = rawAddr;
112
-
113
- const queryParams = {
114
- ...DEFAULT_QUERY_PARAMS_GET_IBGIB,
115
- ...(reqCtx.queryParams ?? {}),
116
- };
117
-
118
- const { getLatest, getGraph, addrOnly } = queryParams;
119
-
120
- const space = await reqCtx.metaspace.getLocalUserSpace({ lock: false });
121
- if (!space) { throw new Error(`(UNEXPECTED) couldn't get default local user space? (E: ec6161ea3a08892ad8bfd1b7b0d79826)`); }
122
-
123
- let addr_latest: string = addr;
124
- if (getLatest) {
125
- const latestAddr = await reqCtx.metaspace.getLatestAddr({ addr, space });
126
- if (latestAddr) { addr_latest = latestAddr; }
127
- }
128
-
129
- // Lightweight tip-check: return only the resolved address.
130
- // Client uses this to decide whether a full sync is necessary
131
- // without incurring the cost of fetching the full ibgib or graph.
132
- if (addrOnly && !getGraph) {
133
- return this.ok({ addr: addr_latest, clientAddr: addr });
134
- } /* <<<<< returns early */
135
-
136
- if (getGraph) {
137
- const resGraph = await reqCtx.metaspace.getDependencyGraph({
138
- ibGibAddr: addr_latest,
139
- space,
140
- live: getLatest,
141
- });
142
- const addrs = Object.keys(resGraph);
143
- if (addrs.length > 0) {
144
- if (addrOnly) {
145
- // Return only the address list for delta negotiation (smart diff):
146
- // client compares these against what it already has to determine
147
- // the minimal set it needs to fetch.
148
- return this.ok({ addr: addr_latest, clientAddr: addr, addrs });
149
- } else {
150
- const responseBody: IbGibGraphResponseBody = {
151
- addr: addr_latest,
152
- count: addrs.length,
153
- graph: resGraph
154
- };
155
- return this.ok(responseBody);
156
- }
157
- } else {
158
- return this.notFound(`Graph not found for ${addr_latest} (E: 89b259f13ae5e4f0d8287f6c0475a826)`);
159
- }
160
- } else {
161
- const resGet = await reqCtx.metaspace.get({ space, addr: addr_latest });
162
- if (resGet.success && resGet.ibGibs?.length === 1) {
163
- const ibGib = resGet.ibGibs[0];
164
- return this.ok(ibGib);
165
- } else {
166
- return this.notFound(`IbGib not found for ${addr_latest} (E: 017621e0a8086832ff06cfc884b8c426)`);
167
- }
168
- }
169
- } catch (error) {
170
- if (logalot) { console.error(extractErrorMsg(error)) }
171
- return this.error(500, extractErrorMsg(error));
172
- } finally {
173
- if (logalot) { console.log(`${lc} complete.`); }
174
- }
175
- }
176
- }