···
const allowedChannels = channelAtUriStrings.map((channel) => {
const res = stringToAtUri(channel);
36
-
if (!res.ok) return;
37
+
console.error(JSON.stringify(res.error));
const verifyJwtResult = await verifyServiceJwt(interServiceJwt);
if (!verifyJwtResult.ok) {
const { error } = verifyJwtResult;
46
+
console.log("Could not verify service JWT");
47
+
console.log(JSON.stringify(error));
···
if (!constellationResponse.ok) {
const { error } = constellationResponse;
78
+
console.log("Constellation errored out", JSON.stringify(error));
if ("fetchStatus" in error)
return newErrorResponse(error.fetchStatus, {
···
pdsChannelRecords = await Promise.all(pdsRecordFetchPromises);
111
+
console.log(JSON.stringify(err));
return newErrorResponse(500, {
"Something went wrong when fetching backlink channel records. Check the Shard logs if possible.",
···
.array(systemsGmstnDevelopmentChannelRecordSchema)
.safeParse(pdsChannelRecords);
if (!channelRecordsParseSuccess) {
127
+
console.log(JSON.stringify(z.treeifyError(channelRecordsParseError)));
return newErrorResponse(500, {
"One of the backlinks returned by Constellation did not resolve to a proper lexicon Channel record.",
···
let mismatchOrIncorrect = false;
const requestingLatticeDid = verifyJwtResult.value.issuer;
143
+
let mismatchReason = "";
channelRecordsParsed.forEach((channel) => {
if (mismatchOrIncorrect) return;
···
const storeAtRecordParseResult = stringToAtUri(storeAtRecord.uri);
if (!storeAtRecordParseResult.ok) {
mismatchOrIncorrect = true;
154
+
"could not parse store at record into at uri object," +
155
+
JSON.stringify(storeAtRecordParseResult.error);
const storeAtUri = storeAtRecordParseResult.data;
···
// we should probably just resolve this properly first but for now, i cba.
if (storeAtUri.rKey !== SERVICE_DID.slice(8)) {
mismatchOrIncorrect = true;
168
+
mismatchReason = `store at record domain did not match with this shard. this shard's domain is ${SERVICE_DID.slice(8)}, the domain on the record is ${storeAtUri.rKey ?? ""}`;
···
if (!routeThroughRecordParseResult.ok) {
177
+
"could not parse route through record into at uri object," +
178
+
JSON.stringify(routeThroughRecordParseResult.error);
mismatchOrIncorrect = true;
···
// FIXME: this also assumes that the requesting lattice's DID is a did:web
// see above for the rest of the issues.
if (routeThroughUri.rKey === requestingLatticeDid.slice(8)) {
187
+
mismatchReason = `route through record domain did not match with requesting service. the requesting service's domain is ${SERVICE_DID.slice(8)}, the domain on the record is ${storeAtUri.rKey ?? ""}`;
mismatchOrIncorrect = true;
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
177
-
if (mismatchOrIncorrect)
194
+
if (mismatchOrIncorrect) {
195
+
console.log("Channels mismatched.");
196
+
console.log(mismatchReason)
return newErrorResponse(400, {
"Channels provided during the handshake had a mismatch between the channel values. Ensure that you are only submitting exactly the channels you have access to.",
200
+
details: mismatchReason,
// yipee, it's a valid request :3