Fix: "The provided app JSON does not match the configuration"

This commit is contained in:
Stan Wohlwend 2024-04-13 17:52:33 +02:00
parent 2995d9662a
commit 23db888c90
3 changed files with 16 additions and 5 deletions

View File

@ -66,3 +66,12 @@ export function typedAssign<T extends {}, U extends {}>(target: T, source: U): a
export function filterUndefined<T extends {}>(obj: T): { [k in keyof T]+?: T[k] & ({} | null) } {
return Object.fromEntries(Object.entries(obj).filter(([, v]) => v !== undefined)) as any;
}
export function pick<T extends {}, K extends keyof T>(obj: T, keys: K[]): Pick<T, K> {
return Object.fromEntries(Object.entries(obj).filter(([k]) => keys.includes(k as K))) as any;
}
export function omit<T extends {}, K extends keyof T>(obj: T, keys: K[]): Omit<T, K> {
return Object.fromEntries(Object.entries(obj).filter(([k]) => !keys.includes(k as K))) as any;
}

View File

@ -1,6 +1,6 @@
'use client';
import { Input } from "../components-core";;
import { Input } from "../components-core";
import { forwardRef, useRef, useState } from 'react';
import { HiEye, HiEyeOff } from 'react-icons/hi';
import { useDesign } from "..";

View File

@ -12,7 +12,7 @@ import { callOAuthCallback, signInWithOAuth } from "./auth";
import { RedirectType, redirect, useRouter } from "next/navigation";
import { ReadonlyJson } from "@stackframe/stack-shared/dist/utils/json";
import { constructRedirectUrl } from "../utils/url";
import { filterUndefined } from "@stackframe/stack-shared/dist/utils/objects";
import { filterUndefined, omit, pick } from "@stackframe/stack-shared/dist/utils/objects";
import { neverResolve, resolved, runAsynchronously } from "@stackframe/stack-shared/dist/utils/promises";
import { AsyncCache } from "@stackframe/stack-shared/dist/utils/caches";
import { ApiKeySetBaseJson, ApiKeySetCreateOptions, ApiKeySetFirstViewJson, ApiKeySetJson, ProjectUpdateOptions } from "@stackframe/stack-shared/dist/interface/adminInterface";
@ -708,10 +708,12 @@ class _StackClientAppImpl<HasTokenStore extends boolean, ProjectId extends strin
fromClientJson: <HasTokenStore extends boolean, ProjectId extends string>(
json: StackClientAppJson<HasTokenStore, ProjectId>
): StackClientApp<HasTokenStore, ProjectId> => {
const providedCheckString = JSON.stringify(omit(json, ["currentClientUserJson", "currentProjectJson"]));
const existing = allClientApps.get(json.uniqueIdentifier);
if (existing) {
const [checkString, clientApp] = existing;
if (checkString !== JSON.stringify(json)) {
const [existingCheckString, clientApp] = existing;
if (existingCheckString !== providedCheckString) {
console.error("The provided app JSON does not match the configuration of the existing client app with the same unique identifier", { providedObj: json, existingString: existingCheckString });
throw new Error("The provided app JSON does not match the configuration of the existing client app with the same unique identifier");
}
return clientApp as any;
@ -719,7 +721,7 @@ class _StackClientAppImpl<HasTokenStore extends boolean, ProjectId extends strin
return new _StackClientAppImpl<HasTokenStore, ProjectId>({
...json,
checkString: JSON.stringify(json),
checkString: providedCheckString,
});
}
};