@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.
- package/dist/email/verify/email-verify-helpers.d.mts.map +1 -1
- package/dist/email/verify/email-verify-helpers.mjs +12 -3
- package/dist/email/verify/email-verify-helpers.mjs.map +1 -1
- package/dist/serve-gib/handlers/api/email/email-outbound.handler.d.mts.map +1 -1
- package/dist/serve-gib/handlers/api/email/email-outbound.handler.mjs +2 -25
- package/dist/serve-gib/handlers/api/email/email-outbound.handler.mjs.map +1 -1
- package/dist/serve-gib/handlers/api/email/email-verification-code.handler.d.mts.map +1 -1
- package/dist/serve-gib/handlers/api/email/email-verification-code.handler.mjs +2 -26
- package/dist/serve-gib/handlers/api/email/email-verification-code.handler.mjs.map +1 -1
- package/dist/serve-gib/handlers/api/identity/keystone-custodian-genesis.handler.d.mts.map +1 -1
- package/dist/serve-gib/handlers/api/identity/keystone-custodian-genesis.handler.mjs +11 -4
- package/dist/serve-gib/handlers/api/identity/keystone-custodian-genesis.handler.mjs.map +1 -1
- package/dist/serve-gib/handlers/api/identity/keystone-custodian-register-delegate.handler.d.mts.map +1 -1
- package/dist/serve-gib/handlers/api/identity/keystone-custodian-register-delegate.handler.mjs +5 -3
- package/dist/serve-gib/handlers/api/identity/keystone-custodian-register-delegate.handler.mjs.map +1 -1
- package/dist/serve-gib/handlers/api/keystone/sso-login.handler.d.mts.map +1 -1
- package/dist/serve-gib/handlers/api/keystone/sso-login.handler.mjs +15 -6
- package/dist/serve-gib/handlers/api/keystone/sso-login.handler.mjs.map +1 -1
- package/e2e/identity-sso-lifecycle.e2e.md +9 -7
- package/package.json +5 -5
- package/src/email/verify/email-verify-helpers.mts +14 -3
- package/src/serve-gib/handlers/api/email/email-outbound.handler.mts +2 -23
- package/src/serve-gib/handlers/api/email/email-verification-code.handler.mts +2 -22
- package/src/serve-gib/handlers/api/identity/keystone-custodian-genesis.handler.mts +12 -4
- package/src/serve-gib/handlers/api/identity/keystone-custodian-register-delegate.handler.mts +5 -3
- package/src/serve-gib/handlers/api/identity/keystone-custodian-register-delegate.respec.mts +1 -1
- package/src/serve-gib/handlers/api/keystone/sso-login.handler.mts +17 -7
- package/data/identity_index/email/hashes/32/13/49/e64f32730f01a61ada211f29eaf0a210fc2386b668ad04d7e8a9b16766.json +0 -4
- package/dist/serve-gib/handlers/api/ibgib/ibgib-handler-types.d.mts +0 -41
- package/dist/serve-gib/handlers/api/ibgib/ibgib-handler-types.d.mts.map +0 -1
- package/dist/serve-gib/handlers/api/ibgib/ibgib-handler-types.mjs +0 -34
- package/dist/serve-gib/handlers/api/ibgib/ibgib-handler-types.mjs.map +0 -1
- package/dist/serve-gib/handlers/api/ibgib/ibgib.handler.d.mts +0 -26
- package/dist/serve-gib/handlers/api/ibgib/ibgib.handler.d.mts.map +0 -1
- package/dist/serve-gib/handlers/api/ibgib/ibgib.handler.mjs +0 -179
- package/dist/serve-gib/handlers/api/ibgib/ibgib.handler.mjs.map +0 -1
- package/src/serve-gib/handlers/api/ibgib/ibgib-handler-types.mts +0 -49
- package/src/serve-gib/handlers/api/ibgib/ibgib.handler.mts +0 -176
|
@@ -13,7 +13,7 @@ import { API_PATH_REGEXES } from '../../../path-constants.mjs';
|
|
|
13
13
|
import { RequestContext, ResponseResult, ServeGibHttpMethod } from '../../../types.mjs';
|
|
14
14
|
import { ServeGibHandlerBase } from '../../handler-base.mjs';
|
|
15
15
|
import { GLOBAL_LOG_A_LOT } from '../../../constants.mjs';
|
|
16
|
-
import { generateVerificationCode, getPendingStagingDir, getPendingTjpHash, savePendingCodeRecord, savePendingStagingKeystone } from '../../../../email/verify/email-verify-helpers.mjs';
|
|
16
|
+
import { createDefaultEmailSender, generateVerificationCode, getPendingStagingDir, getPendingTjpHash, savePendingCodeRecord, savePendingStagingKeystone } from '../../../../email/verify/email-verify-helpers.mjs';
|
|
17
17
|
import { validateEmail } from '../../../../email/email-helpers.mjs';
|
|
18
18
|
import { normalizeEmail } from '../../../identity-index/identity-index-helpers.mjs';
|
|
19
19
|
|
|
@@ -42,27 +42,7 @@ export class EmailVerificationCodeHandler extends ServeGibHandlerBase {
|
|
|
42
42
|
|
|
43
43
|
constructor(options: EmailMagicLinkHandlerOptions = {}) {
|
|
44
44
|
super();
|
|
45
|
-
|
|
46
|
-
if (options.sender) {
|
|
47
|
-
this.sender = options.sender;
|
|
48
|
-
} else {
|
|
49
|
-
const isProd = process.env.NODE_ENV === 'production';
|
|
50
|
-
const mode = (process.env.EMAIL_MODE || (isProd ? 'aws' : 'mock')).toLowerCase();
|
|
51
|
-
if (mode === 'aws') {
|
|
52
|
-
this.sender = new EmailSenderAws({
|
|
53
|
-
accessKeyId: process.env.AWS_ACCESS_KEY_ID || '',
|
|
54
|
-
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY || '',
|
|
55
|
-
region: process.env.AWS_REGION || 'us-east-1',
|
|
56
|
-
});
|
|
57
|
-
} else if (mode === 'mock') {
|
|
58
|
-
if (isProd) {
|
|
59
|
-
throw new Error('EMAIL_MODE=mock is prohibited when NODE_ENV=production. (E: 897a6b5c4d3e2f10987654321fedcba0)');
|
|
60
|
-
}
|
|
61
|
-
this.sender = new EmailSenderMock();
|
|
62
|
-
} else {
|
|
63
|
-
throw new Error(`Unsupported EMAIL_MODE '${mode}'. Must be 'aws' or 'mock'. (E: 987a6b5c4d3e2f10987654321fedcba1)`);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
45
|
+
this.sender = options.sender || createDefaultEmailSender();
|
|
66
46
|
}
|
|
67
47
|
|
|
68
48
|
protected async handleRouteImpl(reqCtx: RequestContext): Promise<ResponseResult | undefined> {
|
|
@@ -126,9 +126,12 @@ export class KeystoneCustodianGenesisHandler extends ServeGibHandlerBase<undefin
|
|
|
126
126
|
const metaspace = await bootstrapDomainMetaspace(primaryTjpAddr, reqCtx.dataDir);
|
|
127
127
|
const space = await metaspace.getLocalUserSpace({ lock: false });
|
|
128
128
|
if (space) {
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
|
|
129
|
+
const keystoneService = new KeystoneService_V1();
|
|
130
|
+
primaryKeystone = await keystoneService.getLatestKeystone({
|
|
131
|
+
addr: primaryTjpAddr,
|
|
132
|
+
metaspace,
|
|
133
|
+
space
|
|
134
|
+
});
|
|
132
135
|
}
|
|
133
136
|
} else {
|
|
134
137
|
// New custodian identity creation
|
|
@@ -136,7 +139,12 @@ export class KeystoneCustodianGenesisHandler extends ServeGibHandlerBase<undefin
|
|
|
136
139
|
console.log(`${lc} Creating new custodian primary identity for ${normEmail} (I: f123456789abcdef0123456789b0006)`);
|
|
137
140
|
|
|
138
141
|
const defaultUsername = username || normEmail.split('@')[0];
|
|
139
|
-
const
|
|
142
|
+
const primaryProfileName = process.env.KEYSTONE_PROFILE_CUSTODIAN_PRIMARY;
|
|
143
|
+
if (!primaryProfileName || !primaryProfileName.trim()) {
|
|
144
|
+
throw new Error('KEYSTONE_PROFILE_CUSTODIAN_PRIMARY environment variable is missing. Expected valid profile name like "primary-profile.dev" or "primary-profile.prod". (E: 1a2b3c4d5e6f7890123456789abcdef1)');
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const primaryBuilder = KeystoneProfileBuilder.buildKeystone(primaryProfileName.trim() as any)
|
|
140
148
|
.withUsername(defaultUsername)
|
|
141
149
|
.withDescription(`Full Custodian Primary Identity for ${normEmail}`)
|
|
142
150
|
.withDetails({
|
package/src/serve-gib/handlers/api/identity/keystone-custodian-register-delegate.handler.mts
CHANGED
|
@@ -140,9 +140,11 @@ export class KeystoneCustodianRegisterDelegateHandler extends ServeGibHandlerBas
|
|
|
140
140
|
return this.error(500, `Could not load domain space for primary identity ${custodianReqs.primaryTjpAddr}`);
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
|
|
143
|
+
const parentKeystone = await keystoneService.getLatestKeystone({
|
|
144
|
+
addr: custodianReqs.primaryTjpAddr,
|
|
145
|
+
metaspace,
|
|
146
|
+
space
|
|
147
|
+
});
|
|
146
148
|
|
|
147
149
|
if (!parentKeystone) {
|
|
148
150
|
return this.error(404, `Primary identity keystone not found for address ${custodianReqs.primaryTjpAddr}`);
|
|
@@ -59,7 +59,7 @@ await respecfully(sir, 'KeystoneCustodianRegisterDelegateHandler', async () => {
|
|
|
59
59
|
|
|
60
60
|
// Step 2: Build client delegate keystone containing custodianReqs
|
|
61
61
|
const delegateSecret = await deriveLocalCustodianDelegateSecret({ primaryTjpAddr });
|
|
62
|
-
const delegateBuilder = KeystoneProfileBuilder.buildKeystone('sync')
|
|
62
|
+
const delegateBuilder = KeystoneProfileBuilder.buildKeystone('sync-profile.dev')
|
|
63
63
|
.withUsername('bob-sync-phone')
|
|
64
64
|
.withDescription('Sync Delegate for bob on phone')
|
|
65
65
|
.withDetails({
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* generates a fresh single-turn `CustodianRequirements` payload, and returns it to the client.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { extractErrorMsg, hash, getUUID } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
11
|
+
import { extractErrorMsg, hash, getUUID, getSaferSubstring } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
12
12
|
import { getTjpAddr } from '@ibgib/core-gib/dist/common/other/ibgib-helper.mjs';
|
|
13
13
|
import { KeystoneProfileBuilder } from '@ibgib/core-gib/dist/keystone/policy/keystone-profile-builder.mjs';
|
|
14
14
|
import { KeystoneService_V1 } from '@ibgib/core-gib/dist/keystone/keystone-service-v1.mjs';
|
|
@@ -103,7 +103,9 @@ export class SsoLoginHandler extends ServeGibHandlerBase<undefined, undefined> {
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
const email = userInfo.email.trim().toLowerCase();
|
|
106
|
-
const
|
|
106
|
+
const rawSSOName = userInfo.name || '';
|
|
107
|
+
const username = getSaferSubstring({ text: rawSSOName || email.split('@')[0], length: 62, keepLiterals: ['_', '-'] })
|
|
108
|
+
;
|
|
107
109
|
|
|
108
110
|
// 2. Check if primary identity exists for this email
|
|
109
111
|
const ssoConfig = loadSsoServerConfig();
|
|
@@ -122,10 +124,12 @@ export class SsoLoginHandler extends ServeGibHandlerBase<undefined, undefined> {
|
|
|
122
124
|
primaryTjpAddr = existingLookup.primaryTjpAddr;
|
|
123
125
|
const domainMetaspace = await bootstrapDomainMetaspace(primaryTjpAddr, reqCtx.dataDir);
|
|
124
126
|
const space = await domainMetaspace.getLocalUserSpace({ lock: false });
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
const keystoneService = new KeystoneService_V1();
|
|
128
|
+
primaryKeystone = await keystoneService.getLatestKeystone({
|
|
129
|
+
addr: primaryTjpAddr,
|
|
130
|
+
metaspace: domainMetaspace,
|
|
131
|
+
space: space!
|
|
132
|
+
});
|
|
129
133
|
} else {
|
|
130
134
|
// First-time custodian identity creation
|
|
131
135
|
isNewIdentity = true;
|
|
@@ -133,13 +137,19 @@ export class SsoLoginHandler extends ServeGibHandlerBase<undefined, undefined> {
|
|
|
133
137
|
const tempDomainMetaspace = await bootstrapDomainMetaspace(`temp^${tempId}`, reqCtx.dataDir);
|
|
134
138
|
const tempSpace = await tempDomainMetaspace.getLocalUserSpace({ lock: false });
|
|
135
139
|
|
|
136
|
-
const
|
|
140
|
+
const primaryProfileName = process.env.KEYSTONE_PROFILE_CUSTODIAN_PRIMARY;
|
|
141
|
+
if (!primaryProfileName || !primaryProfileName.trim()) {
|
|
142
|
+
throw new Error('KEYSTONE_PROFILE_CUSTODIAN_PRIMARY environment variable is missing. Expected valid profile name like "primary-profile.dev" or "primary-profile.prod". (E: 2b3c4d5e6f7890123456789abcdef2)');
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const primaryBuilder = KeystoneProfileBuilder.buildKeystone(primaryProfileName.trim() as any)
|
|
137
146
|
.withUsername(username)
|
|
138
147
|
.withEmails([email])
|
|
139
148
|
.withDetails({
|
|
140
149
|
client: 'space-gib-server',
|
|
141
150
|
role: 'custodian-primary',
|
|
142
151
|
custodianProvider: providerId,
|
|
152
|
+
[`rawSSOName-${providerId}`]: rawSSOName,
|
|
143
153
|
});
|
|
144
154
|
|
|
145
155
|
const configs = await primaryBuilder.compileConfigs();
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { IbGibAddr } from "@ibgib/ts-gib/dist/types.mjs";
|
|
2
|
-
import { DomainInfo } from "../../../types.mjs";
|
|
3
|
-
export interface IbGibParams {
|
|
4
|
-
domainInfo: DomainInfo;
|
|
5
|
-
ibGibIb: string;
|
|
6
|
-
ibGibGib: string;
|
|
7
|
-
ibGibAddr: IbGibAddr;
|
|
8
|
-
}
|
|
9
|
-
export declare const DEFAULT_QUERY_PARAMS_GET_IBGIB: {
|
|
10
|
-
/**
|
|
11
|
-
* If true, will get the latest ibgib.
|
|
12
|
-
*/
|
|
13
|
-
getLatest: boolean;
|
|
14
|
-
/**
|
|
15
|
-
* If true, will get the ibgib's entire dependency graph
|
|
16
|
-
*/
|
|
17
|
-
getGraph: boolean;
|
|
18
|
-
/**
|
|
19
|
-
* If true, returns only the resolved address (addr) rather than the full
|
|
20
|
-
* ibgib or graph body. Useful for a lightweight "tip check" before initiating
|
|
21
|
-
* a full sync: client compares `latestAddr` with its locally known addr.
|
|
22
|
-
*
|
|
23
|
-
* ## notes
|
|
24
|
-
*
|
|
25
|
-
* Typically combined with `getLatest: true` to ask "what is the server's
|
|
26
|
-
* current tip for this timeline?" without paying the cost of fetching the
|
|
27
|
-
* full ibgib body or graph.
|
|
28
|
-
*
|
|
29
|
-
* When `getLatest: false` and `addrOnly: true`, returns the addr as-is
|
|
30
|
-
* (i.e., confirms the given addr exists on the server).
|
|
31
|
-
*/
|
|
32
|
-
addrOnly: boolean;
|
|
33
|
-
};
|
|
34
|
-
/**
|
|
35
|
-
* @see {@link DEFAULT_QUERY_PARAMS_GET_IBGIB} key/values for jsdocs
|
|
36
|
-
*/
|
|
37
|
-
export type IbGibGetQueryParams = Partial<typeof DEFAULT_QUERY_PARAMS_GET_IBGIB>;
|
|
38
|
-
export type KNOWN_QUERY_PARAMS_IBGIB_GET = keyof IbGibGetQueryParams;
|
|
39
|
-
export declare const KNOWN_QUERY_PARAMS_IBGIB_GET: KNOWN_QUERY_PARAMS_IBGIB_GET[];
|
|
40
|
-
export declare function isKnownQueryParamsKey_IbGibGet(key: any): key is KNOWN_QUERY_PARAMS_IBGIB_GET;
|
|
41
|
-
//# sourceMappingURL=ibgib-handler-types.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ibgib-handler-types.d.mts","sourceRoot":"","sources":["../../../../../src/serve-gib/handlers/api/ibgib/ibgib-handler-types.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAEzD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,MAAM,WAAW,WAAW;IACxB,UAAU,EAAE,UAAU,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,SAAS,CAAC;CACxB;AAGD,eAAO,MAAM,8BAA8B;IACvC;;OAEG;IACH,SAAS;IACT;;OAEG;IACH,QAAQ;IACR;;;;;;;;;;;;;OAaG;IACH,QAAQ;CACX,CAAC;AACF;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,OAAO,CAAC,OAAO,8BAA8B,CAAC,CAAC;AACjF,MAAM,MAAM,4BAA4B,GAAG,MAAM,mBAAmB,CAAC;AACrE,eAAO,MAAM,4BAA4B,EAAkD,4BAA4B,EAAE,CAAC;AAC1H,wBAAgB,8BAA8B,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,4BAA4B,CAI5F"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
// #region IbGibGetQueryParams
|
|
2
|
-
export const DEFAULT_QUERY_PARAMS_GET_IBGIB = {
|
|
3
|
-
/**
|
|
4
|
-
* If true, will get the latest ibgib.
|
|
5
|
-
*/
|
|
6
|
-
getLatest: false, // Default to false for regular ibgibs
|
|
7
|
-
/**
|
|
8
|
-
* If true, will get the ibgib's entire dependency graph
|
|
9
|
-
*/
|
|
10
|
-
getGraph: false, // Default to false for regular ibgibs
|
|
11
|
-
/**
|
|
12
|
-
* If true, returns only the resolved address (addr) rather than the full
|
|
13
|
-
* ibgib or graph body. Useful for a lightweight "tip check" before initiating
|
|
14
|
-
* a full sync: client compares `latestAddr` with its locally known addr.
|
|
15
|
-
*
|
|
16
|
-
* ## notes
|
|
17
|
-
*
|
|
18
|
-
* Typically combined with `getLatest: true` to ask "what is the server's
|
|
19
|
-
* current tip for this timeline?" without paying the cost of fetching the
|
|
20
|
-
* full ibgib body or graph.
|
|
21
|
-
*
|
|
22
|
-
* When `getLatest: false` and `addrOnly: true`, returns the addr as-is
|
|
23
|
-
* (i.e., confirms the given addr exists on the server).
|
|
24
|
-
*/
|
|
25
|
-
addrOnly: false,
|
|
26
|
-
};
|
|
27
|
-
export const KNOWN_QUERY_PARAMS_IBGIB_GET = Object.keys(DEFAULT_QUERY_PARAMS_GET_IBGIB);
|
|
28
|
-
export function isKnownQueryParamsKey_IbGibGet(key) {
|
|
29
|
-
return !!key && typeof key === 'string' ?
|
|
30
|
-
KNOWN_QUERY_PARAMS_IBGIB_GET.includes(key) :
|
|
31
|
-
false;
|
|
32
|
-
}
|
|
33
|
-
// #endregion IbGibGetQueryParams
|
|
34
|
-
//# sourceMappingURL=ibgib-handler-types.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ibgib-handler-types.mjs","sourceRoot":"","sources":["../../../../../src/serve-gib/handlers/api/ibgib/ibgib-handler-types.mts"],"names":[],"mappings":"AAWA,8BAA8B;AAC9B,MAAM,CAAC,MAAM,8BAA8B,GAAG;IAC1C;;OAEG;IACH,SAAS,EAAE,KAAK,EAAE,sCAAsC;IACxD;;OAEG;IACH,QAAQ,EAAE,KAAK,EAAE,sCAAsC;IACvD;;;;;;;;;;;;;OAaG;IACH,QAAQ,EAAE,KAAK;CAClB,CAAC;AAMF,MAAM,CAAC,MAAM,4BAA4B,GAAG,MAAM,CAAC,IAAI,CAAC,8BAA8B,CAAmC,CAAC;AAC1H,MAAM,UAAU,8BAA8B,CAAC,GAAQ;IACnD,OAAO,CAAC,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC;QACrC,4BAA4B,CAAC,QAAQ,CAAC,GAAU,CAAC,CAAC,CAAC;QACnD,KAAK,CAAC;AACd,CAAC;AACD,iCAAiC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module serve-gib/handlers/api/ibgib
|
|
3
|
-
*/
|
|
4
|
-
import { IbGib_V1 } from '@ibgib/ts-gib/dist/V1/types.mjs';
|
|
5
|
-
import { ServeGibHandlerWithMetaspaceBase } from '../../handler-base.mjs';
|
|
6
|
-
import { RequestContext, ResponseResult, ServeGibHttpMethod } from '../../../types.mjs';
|
|
7
|
-
import { IbGibGetQueryParams, IbGibParams } from './ibgib-handler-types.mjs';
|
|
8
|
-
export interface IbGibGraphResponseBody {
|
|
9
|
-
addr: string;
|
|
10
|
-
count: number;
|
|
11
|
-
graph: Record<string, IbGib_V1>;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* GET /api/ibgib/:domainAddr/:ibGibAddr
|
|
15
|
-
*/
|
|
16
|
-
export declare class IbGibHandler extends ServeGibHandlerWithMetaspaceBase<IbGibParams, IbGibGetQueryParams> {
|
|
17
|
-
protected lc: string;
|
|
18
|
-
protected method: ServeGibHttpMethod;
|
|
19
|
-
protected regex: RegExp;
|
|
20
|
-
protected parseParamsImpl(reqCtx: RequestContext<IbGibParams, IbGibGetQueryParams>): Promise<IbGibParams | undefined>;
|
|
21
|
-
protected validateQueryParams({ queryParams }: {
|
|
22
|
-
queryParams: any;
|
|
23
|
-
}): Promise<string[]>;
|
|
24
|
-
protected handleRouteImpl(reqCtx: RequestContext<IbGibParams, IbGibGetQueryParams>): Promise<ResponseResult | undefined>;
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=ibgib.handler.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ibgib.handler.d.mts","sourceRoot":"","sources":["../../../../../src/serve-gib/handlers/api/ibgib/ibgib.handler.mts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAG3D,OAAO,EAAE,gCAAgC,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAGxF,OAAO,EAC6B,mBAAmB,EAAE,WAAW,EAEnE,MAAM,2BAA2B,CAAC;AAGnC,MAAM,WAAW,sBAAsB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;CACnC;AAID;;GAEG;AACH,qBAAa,YAAa,SAAQ,gCAAgC,CAAC,WAAW,EAAE,mBAAmB,CAAC;IAChG,UAAmB,EAAE,EAAE,MAAM,CAA4B;IACzD,UAAmB,MAAM,EAAE,kBAAkB,CAAS;IACtD,UAAmB,KAAK,SAA+B;IAEvD,UAAyB,eAAe,CAAC,MAAM,EAAE,cAAc,CAAC,WAAW,EAAE,mBAAmB,CAAC,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CAsBnI;IAED,UAAyB,mBAAmB,CAAC,EAAE,WAAW,EAAE,EAAE;QAAE,WAAW,EAAE,GAAG,CAAC;KAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAmCtG;IAED,UAAgB,eAAe,CAAC,MAAM,EAAE,cAAc,CAAC,WAAW,EAAE,mBAAmB,CAAC,GAAG,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,CA8E7H;CACJ"}
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module serve-gib/handlers/api/ibgib
|
|
3
|
-
*/
|
|
4
|
-
import { extractErrorMsg } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
5
|
-
import { getIbGibAddr } from '@ibgib/ts-gib/dist/helper.mjs';
|
|
6
|
-
import { GLOBAL_LOG_A_LOT } from '../../../constants.mjs';
|
|
7
|
-
import { ServeGibHandlerWithMetaspaceBase } from '../../handler-base.mjs';
|
|
8
|
-
import { validateAddressSegment } from '../../../path-helper.mjs';
|
|
9
|
-
import { API_PATH_REGEXES } from '../../../path-constants.mjs';
|
|
10
|
-
import { DEFAULT_QUERY_PARAMS_GET_IBGIB, isKnownQueryParamsKey_IbGibGet, KNOWN_QUERY_PARAMS_IBGIB_GET } from './ibgib-handler-types.mjs';
|
|
11
|
-
import { validateAndCoerceBooleanQueryParam } from '../../../serve-gib-helpers.mjs';
|
|
12
|
-
const logalot = GLOBAL_LOG_A_LOT;
|
|
13
|
-
/**
|
|
14
|
-
* GET /api/ibgib/:domainAddr/:ibGibAddr
|
|
15
|
-
*/
|
|
16
|
-
export class IbGibHandler extends ServeGibHandlerWithMetaspaceBase {
|
|
17
|
-
lc = `[${IbGibHandler.name}]`;
|
|
18
|
-
method = 'GET';
|
|
19
|
-
regex = API_PATH_REGEXES.IBGIB_ADDR;
|
|
20
|
-
async parseParamsImpl(reqCtx) {
|
|
21
|
-
const lc = `${this.lc}[${this.parseParamsImpl.name}]`;
|
|
22
|
-
try {
|
|
23
|
-
if (logalot) {
|
|
24
|
-
console.log(`${lc} starting...`);
|
|
25
|
-
}
|
|
26
|
-
const match = reqCtx.pathname.match(this.regex);
|
|
27
|
-
if (!match) {
|
|
28
|
-
throw new Error(`(UNEXPECTED) match falsy for regex? at this point, we have passed canHandleRoute, so this should parse correctly. (E: 8ce0810a3a88f420639bf8286df1d826)`);
|
|
29
|
-
}
|
|
30
|
-
const domainIb = decodeURIComponent(match[1]);
|
|
31
|
-
const domainGib = decodeURIComponent(match[2]);
|
|
32
|
-
const domainAddr = getIbGibAddr({ ib: domainIb, gib: domainGib });
|
|
33
|
-
const ibGibIb = decodeURIComponent(match[3]);
|
|
34
|
-
const ibGibGib = decodeURIComponent(match[4]);
|
|
35
|
-
const ibGibAddr = getIbGibAddr({ ib: ibGibIb, gib: ibGibGib });
|
|
36
|
-
return {
|
|
37
|
-
ibGibIb, ibGibGib, ibGibAddr,
|
|
38
|
-
domainInfo: this.getDomainInfo({ domainAddr }),
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
catch (error) {
|
|
42
|
-
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
43
|
-
throw error;
|
|
44
|
-
}
|
|
45
|
-
finally {
|
|
46
|
-
if (logalot) {
|
|
47
|
-
console.log(`${lc} complete.`);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
async validateQueryParams({ queryParams }) {
|
|
52
|
-
const lc = `${this.lc}[${this.validateQueryParams.name}]`;
|
|
53
|
-
try {
|
|
54
|
-
if (logalot) {
|
|
55
|
-
console.log(`${lc} starting...`);
|
|
56
|
-
}
|
|
57
|
-
const errors = [];
|
|
58
|
-
// strict checking
|
|
59
|
-
const queryParamsKeys = Object.keys(queryParams);
|
|
60
|
-
const invalidKeys = queryParamsKeys.filter(x => !isKnownQueryParamsKey_IbGibGet(x));
|
|
61
|
-
if (invalidKeys.length > 0) {
|
|
62
|
-
throw new Error(`invalid query params keys: ${invalidKeys.join(', ')}. valid query params keys: ${KNOWN_QUERY_PARAMS_IBGIB_GET.join(', ')} (E: b7e8a9f2c1d34e56b89a01d4f2e7c326)`);
|
|
63
|
-
}
|
|
64
|
-
const ValidationFns = {
|
|
65
|
-
getLatest: async () => validateAndCoerceBooleanQueryParam(queryParams, 'getLatest', errors),
|
|
66
|
-
getGraph: async () => validateAndCoerceBooleanQueryParam(queryParams, 'getGraph', errors),
|
|
67
|
-
addrOnly: async () => validateAndCoerceBooleanQueryParam(queryParams, 'addrOnly', errors),
|
|
68
|
-
};
|
|
69
|
-
// execute all validation functions
|
|
70
|
-
for (const fn of Object.values(ValidationFns)) {
|
|
71
|
-
await fn();
|
|
72
|
-
}
|
|
73
|
-
return errors;
|
|
74
|
-
}
|
|
75
|
-
catch (error) {
|
|
76
|
-
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
77
|
-
throw error;
|
|
78
|
-
}
|
|
79
|
-
finally {
|
|
80
|
-
if (logalot) {
|
|
81
|
-
console.log(`${lc} complete.`);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
async handleRouteImpl(reqCtx) {
|
|
86
|
-
const lc = `${this.lc}[${this.handleRouteImpl.name}]`;
|
|
87
|
-
try {
|
|
88
|
-
if (logalot) {
|
|
89
|
-
console.log(`${lc} starting... (I: 03d6a889b1f8af879c0f7158a3b3de26)`);
|
|
90
|
-
}
|
|
91
|
-
if (logalot) {
|
|
92
|
-
console.log(`${lc} starting... (I: 03d6a889b1f8af879c0f7158a3b3de26)`);
|
|
93
|
-
}
|
|
94
|
-
if (!reqCtx.metaspace) {
|
|
95
|
-
throw new Error(`(UNEXPECTED) metaspace falsy? we should have initialized it by now since this is a domain-dependent handler (E: 864661c668d2aa1918b7ee677a7d9c26)`);
|
|
96
|
-
}
|
|
97
|
-
const { ibGibIb, ibGibGib } = reqCtx.params;
|
|
98
|
-
if (!ibGibIb || !ibGibGib) {
|
|
99
|
-
return undefined;
|
|
100
|
-
}
|
|
101
|
-
// Reconstruct addr from params
|
|
102
|
-
const rawAddr = `${ibGibIb}^${ibGibGib}`;
|
|
103
|
-
if (!validateAddressSegment(rawAddr))
|
|
104
|
-
return this.error(400, 'Invalid address format');
|
|
105
|
-
const addr = rawAddr;
|
|
106
|
-
const queryParams = {
|
|
107
|
-
...DEFAULT_QUERY_PARAMS_GET_IBGIB,
|
|
108
|
-
...(reqCtx.queryParams ?? {}),
|
|
109
|
-
};
|
|
110
|
-
const { getLatest, getGraph, addrOnly } = queryParams;
|
|
111
|
-
const space = await reqCtx.metaspace.getLocalUserSpace({ lock: false });
|
|
112
|
-
if (!space) {
|
|
113
|
-
throw new Error(`(UNEXPECTED) couldn't get default local user space? (E: ec6161ea3a08892ad8bfd1b7b0d79826)`);
|
|
114
|
-
}
|
|
115
|
-
let addr_latest = addr;
|
|
116
|
-
if (getLatest) {
|
|
117
|
-
const latestAddr = await reqCtx.metaspace.getLatestAddr({ addr, space });
|
|
118
|
-
if (latestAddr) {
|
|
119
|
-
addr_latest = latestAddr;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
// Lightweight tip-check: return only the resolved address.
|
|
123
|
-
// Client uses this to decide whether a full sync is necessary
|
|
124
|
-
// without incurring the cost of fetching the full ibgib or graph.
|
|
125
|
-
if (addrOnly && !getGraph) {
|
|
126
|
-
return this.ok({ addr: addr_latest, clientAddr: addr });
|
|
127
|
-
} /* <<<<< returns early */
|
|
128
|
-
if (getGraph) {
|
|
129
|
-
const resGraph = await reqCtx.metaspace.getDependencyGraph({
|
|
130
|
-
ibGibAddr: addr_latest,
|
|
131
|
-
space,
|
|
132
|
-
live: getLatest,
|
|
133
|
-
});
|
|
134
|
-
const addrs = Object.keys(resGraph);
|
|
135
|
-
if (addrs.length > 0) {
|
|
136
|
-
if (addrOnly) {
|
|
137
|
-
// Return only the address list for delta negotiation (smart diff):
|
|
138
|
-
// client compares these against what it already has to determine
|
|
139
|
-
// the minimal set it needs to fetch.
|
|
140
|
-
return this.ok({ addr: addr_latest, clientAddr: addr, addrs });
|
|
141
|
-
}
|
|
142
|
-
else {
|
|
143
|
-
const responseBody = {
|
|
144
|
-
addr: addr_latest,
|
|
145
|
-
count: addrs.length,
|
|
146
|
-
graph: resGraph
|
|
147
|
-
};
|
|
148
|
-
return this.ok(responseBody);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
else {
|
|
152
|
-
return this.notFound(`Graph not found for ${addr_latest} (E: 89b259f13ae5e4f0d8287f6c0475a826)`);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
const resGet = await reqCtx.metaspace.get({ space, addr: addr_latest });
|
|
157
|
-
if (resGet.success && resGet.ibGibs?.length === 1) {
|
|
158
|
-
const ibGib = resGet.ibGibs[0];
|
|
159
|
-
return this.ok(ibGib);
|
|
160
|
-
}
|
|
161
|
-
else {
|
|
162
|
-
return this.notFound(`IbGib not found for ${addr_latest} (E: 017621e0a8086832ff06cfc884b8c426)`);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
catch (error) {
|
|
167
|
-
if (logalot) {
|
|
168
|
-
console.error(extractErrorMsg(error));
|
|
169
|
-
}
|
|
170
|
-
return this.error(500, extractErrorMsg(error));
|
|
171
|
-
}
|
|
172
|
-
finally {
|
|
173
|
-
if (logalot) {
|
|
174
|
-
console.log(`${lc} complete.`);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
//# sourceMappingURL=ibgib.handler.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ibgib.handler.mjs","sourceRoot":"","sources":["../../../../../src/serve-gib/handlers/api/ibgib/ibgib.handler.mts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,iDAAiD,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAG7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,gCAAgC,EAAE,MAAM,wBAAwB,CAAC;AAE1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,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/B,OAAO,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;gBAC1B,CAAC;qBAAM,CAAC;oBACJ,OAAO,IAAI,CAAC,QAAQ,CAAC,uBAAuB,WAAW,wCAAwC,CAAC,CAAC;gBACrG,CAAC;YACL,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,IAAI,OAAO,EAAE,CAAC;gBAAC,OAAO,CAAC,KAAK,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAA;YAAC,CAAC;YACtD,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC;QACnD,CAAC;gBAAS,CAAC;YACP,IAAI,OAAO,EAAE,CAAC;gBAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;YAAC,CAAC;QACpD,CAAC;IACL,CAAC;CACJ"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { IbGibAddr } from "@ibgib/ts-gib/dist/types.mjs";
|
|
2
|
-
|
|
3
|
-
import { DomainInfo } from "../../../types.mjs";
|
|
4
|
-
|
|
5
|
-
export interface IbGibParams {
|
|
6
|
-
domainInfo: DomainInfo;
|
|
7
|
-
ibGibIb: string;
|
|
8
|
-
ibGibGib: string;
|
|
9
|
-
ibGibAddr: IbGibAddr;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
// #region IbGibGetQueryParams
|
|
13
|
-
export const DEFAULT_QUERY_PARAMS_GET_IBGIB = {
|
|
14
|
-
/**
|
|
15
|
-
* If true, will get the latest ibgib.
|
|
16
|
-
*/
|
|
17
|
-
getLatest: false, // Default to false for regular ibgibs
|
|
18
|
-
/**
|
|
19
|
-
* If true, will get the ibgib's entire dependency graph
|
|
20
|
-
*/
|
|
21
|
-
getGraph: false, // Default to false for regular ibgibs
|
|
22
|
-
/**
|
|
23
|
-
* If true, returns only the resolved address (addr) rather than the full
|
|
24
|
-
* ibgib or graph body. Useful for a lightweight "tip check" before initiating
|
|
25
|
-
* a full sync: client compares `latestAddr` with its locally known addr.
|
|
26
|
-
*
|
|
27
|
-
* ## notes
|
|
28
|
-
*
|
|
29
|
-
* Typically combined with `getLatest: true` to ask "what is the server's
|
|
30
|
-
* current tip for this timeline?" without paying the cost of fetching the
|
|
31
|
-
* full ibgib body or graph.
|
|
32
|
-
*
|
|
33
|
-
* When `getLatest: false` and `addrOnly: true`, returns the addr as-is
|
|
34
|
-
* (i.e., confirms the given addr exists on the server).
|
|
35
|
-
*/
|
|
36
|
-
addrOnly: false,
|
|
37
|
-
};
|
|
38
|
-
/**
|
|
39
|
-
* @see {@link DEFAULT_QUERY_PARAMS_GET_IBGIB} key/values for jsdocs
|
|
40
|
-
*/
|
|
41
|
-
export type IbGibGetQueryParams = Partial<typeof DEFAULT_QUERY_PARAMS_GET_IBGIB>;
|
|
42
|
-
export type KNOWN_QUERY_PARAMS_IBGIB_GET = keyof IbGibGetQueryParams;
|
|
43
|
-
export const KNOWN_QUERY_PARAMS_IBGIB_GET = Object.keys(DEFAULT_QUERY_PARAMS_GET_IBGIB) as KNOWN_QUERY_PARAMS_IBGIB_GET[];
|
|
44
|
-
export function isKnownQueryParamsKey_IbGibGet(key: any): key is KNOWN_QUERY_PARAMS_IBGIB_GET {
|
|
45
|
-
return !!key && typeof key === 'string' ?
|
|
46
|
-
KNOWN_QUERY_PARAMS_IBGIB_GET.includes(key as any) :
|
|
47
|
-
false;
|
|
48
|
-
}
|
|
49
|
-
// #endregion IbGibGetQueryParams
|