@mittwald/ext-bridge 0.2.0-alpha.783 → 0.2.0-alpha.785
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/js/config/getConfig.mjs +7 -7
- package/dist/js/config/getConfig.mjs.map +1 -1
- package/dist/js/config/parse.mjs +11 -10
- package/dist/js/config/parse.mjs.map +1 -1
- package/dist/js/config/schemas.mjs +16 -16
- package/dist/js/config/schemas.mjs.map +1 -1
- package/dist/js/environment.mjs +5 -7
- package/dist/js/environment.mjs.map +1 -1
- package/dist/js/error.mjs +8 -10
- package/dist/js/error.mjs.map +1 -1
- package/dist/js/getExtBridge.mjs +5 -7
- package/dist/js/getExtBridge.mjs.map +1 -1
- package/dist/js/global-browser.mjs +14 -6
- package/dist/js/global-browser.mjs.map +1 -1
- package/dist/js/i18next.mjs +2 -0
- package/dist/js/i18next.mjs.map +1 -0
- package/dist/js/index-browser.mjs +4 -4
- package/dist/js/index-browser.mjs.map +1 -0
- package/dist/js/index-node.mjs +6 -4
- package/dist/js/index-node.mjs.map +1 -0
- package/dist/js/index.mjs +2 -0
- package/dist/js/index.mjs.map +1 -0
- package/dist/js/integrations/i18next/modules/remoteLanguageDetectorModule.mjs +15 -0
- package/dist/js/integrations/i18next/modules/remoteLanguageDetectorModule.mjs.map +1 -0
- package/dist/js/lib/assertBrowserEnv.mjs +11 -8
- package/dist/js/lib/assertBrowserEnv.mjs.map +1 -1
- package/dist/js/lib/controllablePromise.mjs +16 -20
- package/dist/js/lib/controllablePromise.mjs.map +1 -1
- package/dist/js/react/hooks/useConfig.mjs +6 -7
- package/dist/js/react/hooks/useConfig.mjs.map +1 -1
- package/dist/js/react/hooks/useExtBridge.mjs +7 -8
- package/dist/js/react/hooks/useExtBridge.mjs.map +1 -1
- package/dist/js/react/hooks/useLanguage.mjs +6 -0
- package/dist/js/react/hooks/useLanguage.mjs.map +1 -0
- package/dist/js/react.mjs +4 -4
- package/dist/js/react.mjs.map +1 -0
- package/dist/js/readiness.mjs +27 -26
- package/dist/js/readiness.mjs.map +1 -1
- package/dist/js/sessionToken/decode.mjs +27 -15
- package/dist/js/sessionToken/decode.mjs.map +1 -1
- package/dist/js/sessionToken/getAccessToken.mjs +13 -16
- package/dist/js/sessionToken/getAccessToken.mjs.map +1 -1
- package/dist/js/sessionToken/getSessionToken.mjs +7 -7
- package/dist/js/sessionToken/getSessionToken.mjs.map +1 -1
- package/dist/js/sessionToken/publicKeys/fetchPublicKey.mjs +15 -15
- package/dist/js/sessionToken/publicKeys/fetchPublicKey.mjs.map +1 -1
- package/dist/js/sessionToken/publicKeys/publicKeys.mjs +15 -13
- package/dist/js/sessionToken/publicKeys/publicKeys.mjs.map +1 -1
- package/dist/js/sessionToken/schemas.mjs +17 -18
- package/dist/js/sessionToken/schemas.mjs.map +1 -1
- package/dist/js/sessionToken/verify.mjs +11 -12
- package/dist/js/sessionToken/verify.mjs.map +1 -1
- package/dist/types/config/getConfig.d.ts +1 -0
- package/dist/types/config/getConfig.d.ts.map +1 -1
- package/dist/types/config/parse.d.ts +1 -0
- package/dist/types/config/parse.d.ts.map +1 -1
- package/dist/types/config/schemas.d.ts +1 -0
- package/dist/types/config/schemas.d.ts.map +1 -1
- package/dist/types/integrations/i18next/index.d.ts +2 -0
- package/dist/types/integrations/i18next/index.d.ts.map +1 -0
- package/dist/types/integrations/i18next/modules/remoteLanguageDetectorModule.d.ts +3 -0
- package/dist/types/integrations/i18next/modules/remoteLanguageDetectorModule.d.ts.map +1 -0
- package/dist/types/react/hooks/index.d.ts +1 -0
- package/dist/types/react/hooks/index.d.ts.map +1 -1
- package/dist/types/react/hooks/useConfig.d.ts +1 -0
- package/dist/types/react/hooks/useConfig.d.ts.map +1 -1
- package/dist/types/react/hooks/useLanguage.d.ts +2 -0
- package/dist/types/react/hooks/useLanguage.d.ts.map +1 -0
- package/package.json +13 -4
- package/dist/js/react/hooks/index.mjs +0 -1
- package/dist/js/sessionToken/index.mjs +0 -2
- package/dist/js/sessionToken/publicKeys/index.mjs +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { getExtBridge } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { getExtBridge } from '../getExtBridge.mjs';
|
|
2
|
+
|
|
3
|
+
const getConfig = async () => {
|
|
4
|
+
const extBridge = await getExtBridge();
|
|
5
|
+
return extBridge.config;
|
|
5
6
|
};
|
|
6
|
-
//#endregion
|
|
7
|
-
export { getConfig };
|
|
8
7
|
|
|
9
|
-
|
|
8
|
+
export { getConfig };
|
|
9
|
+
//# sourceMappingURL=getConfig.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getConfig.mjs","
|
|
1
|
+
{"version":3,"file":"getConfig.mjs","sources":["../../../src/config/getConfig.ts"],"sourcesContent":["import { getExtBridge } from \"@/getExtBridge\";\n\nexport const getConfig = async () => {\n const extBridge = await getExtBridge();\n return extBridge.config;\n};\n"],"names":[],"mappings":";;AAEO,MAAM,YAAY,YAAY;AACnC,EAAA,MAAM,SAAA,GAAY,MAAM,YAAA,EAAa;AACrC,EAAA,OAAO,SAAA,CAAU,MAAA;AACnB;;;;"}
|
package/dist/js/config/parse.mjs
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { config } from './schemas.mjs';
|
|
2
|
+
import { ExtBridgeError } from '../error.mjs';
|
|
3
|
+
|
|
4
|
+
const parseConfig = (something) => {
|
|
5
|
+
const parsed = config.safeParse(something);
|
|
6
|
+
if (parsed.error) {
|
|
7
|
+
throw new ExtBridgeError("Invalid config: " + parsed.error.message);
|
|
8
|
+
}
|
|
9
|
+
return parsed.data;
|
|
8
10
|
};
|
|
9
|
-
//#endregion
|
|
10
|
-
export { parseConfig };
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
export { parseConfig };
|
|
13
|
+
//# sourceMappingURL=parse.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse.mjs","
|
|
1
|
+
{"version":3,"file":"parse.mjs","sources":["../../../src/config/parse.ts"],"sourcesContent":["import { config } from \"@/config/schemas\";\nimport { ExtBridgeError } from \"@/error\";\n\nexport const parseConfig = (something: unknown) => {\n const parsed = config.safeParse(something);\n if (parsed.error) {\n throw new ExtBridgeError(\"Invalid config: \" + parsed.error.message);\n }\n return parsed.data;\n};\n"],"names":[],"mappings":";;;AAGO,MAAM,WAAA,GAAc,CAAC,SAAA,KAAuB;AACjD,EAAA,MAAM,MAAA,GAAS,MAAA,CAAO,SAAA,CAAU,SAAS,CAAA;AACzC,EAAA,IAAI,OAAO,KAAA,EAAO;AAChB,IAAA,MAAM,IAAI,cAAA,CAAe,kBAAA,GAAqB,MAAA,CAAO,MAAM,OAAO,CAAA;AAAA,EACpE;AACA,EAAA,OAAO,MAAA,CAAO,IAAA;AAChB;;;;"}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { z } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
const baseConfig = z.object({
|
|
4
|
+
sessionId: z.string(),
|
|
5
|
+
userId: z.string(),
|
|
6
|
+
extensionId: z.string(),
|
|
7
|
+
extensionInstanceId: z.string(),
|
|
8
|
+
variantKey: z.string().optional().nullable(),
|
|
9
|
+
language: z.string().default("de")
|
|
9
10
|
});
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
const contextParameters = z.object({
|
|
12
|
+
appInstallationId: z.string().optional(),
|
|
13
|
+
projectId: z.string().optional(),
|
|
14
|
+
customerId: z.string().optional()
|
|
14
15
|
});
|
|
15
|
-
|
|
16
|
-
//#endregion
|
|
17
|
-
export { config };
|
|
16
|
+
const config = baseConfig.extend(contextParameters.shape).catchall(z.string().optional().nullable());
|
|
18
17
|
|
|
19
|
-
|
|
18
|
+
export { config };
|
|
19
|
+
//# sourceMappingURL=schemas.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.mjs","
|
|
1
|
+
{"version":3,"file":"schemas.mjs","sources":["../../../src/config/schemas.ts"],"sourcesContent":["import { z } from \"zod\";\n\nconst baseConfig = z.object({\n sessionId: z.string(),\n userId: z.string(),\n extensionId: z.string(),\n extensionInstanceId: z.string(),\n variantKey: z.string().optional().nullable(),\n language: z.string().default(\"de\"),\n});\n\nconst contextParameters = z.object({\n appInstallationId: z.string().optional(),\n projectId: z.string().optional(),\n customerId: z.string().optional(),\n});\n\nexport const config = baseConfig\n .extend(contextParameters.shape)\n .catchall(z.string().optional().nullable());\n"],"names":[],"mappings":";;AAEA,MAAM,UAAA,GAAa,EAAE,MAAA,CAAO;AAAA,EAC1B,SAAA,EAAW,EAAE,MAAA,EAAO;AAAA,EACpB,MAAA,EAAQ,EAAE,MAAA,EAAO;AAAA,EACjB,WAAA,EAAa,EAAE,MAAA,EAAO;AAAA,EACtB,mBAAA,EAAqB,EAAE,MAAA,EAAO;AAAA,EAC9B,YAAY,CAAA,CAAE,MAAA,EAAO,CAAE,QAAA,GAAW,QAAA,EAAS;AAAA,EAC3C,QAAA,EAAU,CAAA,CAAE,MAAA,EAAO,CAAE,QAAQ,IAAI;AACnC,CAAC,CAAA;AAED,MAAM,iBAAA,GAAoB,EAAE,MAAA,CAAO;AAAA,EACjC,iBAAA,EAAmB,CAAA,CAAE,MAAA,EAAO,CAAE,QAAA,EAAS;AAAA,EACvC,SAAA,EAAW,CAAA,CAAE,MAAA,EAAO,CAAE,QAAA,EAAS;AAAA,EAC/B,UAAA,EAAY,CAAA,CAAE,MAAA,EAAO,CAAE,QAAA;AACzB,CAAC,CAAA;AAEM,MAAM,MAAA,GAAS,UAAA,CACnB,MAAA,CAAO,iBAAA,CAAkB,KAAK,CAAA,CAC9B,QAAA,CAAS,CAAA,CAAE,MAAA,EAAO,CAAE,QAAA,EAAS,CAAE,UAAU;;;;"}
|
package/dist/js/environment.mjs
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { env } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var MW_EXT_API_URL = env["MW_EXT_API_URL"] ?? "https://api.mittwald.de";
|
|
5
|
-
//#endregion
|
|
6
|
-
export { MW_EXT_API_URL };
|
|
1
|
+
import { env } from 'std-env';
|
|
2
|
+
|
|
3
|
+
const MW_EXT_API_URL = env["MW_EXT_API_URL"] ?? "https://api.mittwald.de";
|
|
7
4
|
|
|
8
|
-
|
|
5
|
+
export { MW_EXT_API_URL };
|
|
6
|
+
//# sourceMappingURL=environment.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environment.mjs","
|
|
1
|
+
{"version":3,"file":"environment.mjs","sources":["../../src/environment.ts"],"sourcesContent":["import { env } from \"std-env\";\n\n/** @internal */\nexport const MW_EXT_API_URL =\n env[\"MW_EXT_API_URL\"] ?? \"https://api.mittwald.de\";\n"],"names":[],"mappings":";;AAGO,MAAM,cAAA,GACX,GAAA,CAAI,gBAAgB,CAAA,IAAK;;;;"}
|
package/dist/js/error.mjs
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
};
|
|
1
|
+
class ExtBridgeError extends Error {
|
|
2
|
+
constructor(message) {
|
|
3
|
+
super(message);
|
|
4
|
+
this.message = message;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
8
7
|
ExtBridgeError.prototype.name = "ExtBridgeError";
|
|
9
|
-
//#endregion
|
|
10
|
-
export { ExtBridgeError };
|
|
11
8
|
|
|
12
|
-
|
|
9
|
+
export { ExtBridgeError };
|
|
10
|
+
//# sourceMappingURL=error.mjs.map
|
package/dist/js/error.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.mjs","
|
|
1
|
+
{"version":3,"file":"error.mjs","sources":["../../src/error.ts"],"sourcesContent":["export class ExtBridgeError extends Error {\n constructor(message: string) {\n super(message);\n this.message = message;\n }\n}\n\nExtBridgeError.prototype.name = \"ExtBridgeError\";\n"],"names":[],"mappings":"AAAO,MAAM,uBAAuB,KAAA,CAAM;AAAA,EACxC,YAAY,OAAA,EAAiB;AAC3B,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,OAAA,GAAU,OAAA;AAAA,EACjB;AACF;AAEA,cAAA,CAAe,UAAU,IAAA,GAAO,gBAAA;;;;"}
|
package/dist/js/getExtBridge.mjs
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
return globalThis.mwExtBridge;
|
|
1
|
+
const getExtBridge = async () => {
|
|
2
|
+
await globalThis.mwExtBridge.readiness.isReady();
|
|
3
|
+
return globalThis.mwExtBridge;
|
|
5
4
|
};
|
|
6
|
-
//#endregion
|
|
7
|
-
export { getExtBridge };
|
|
8
5
|
|
|
9
|
-
|
|
6
|
+
export { getExtBridge };
|
|
7
|
+
//# sourceMappingURL=getExtBridge.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getExtBridge.mjs","
|
|
1
|
+
{"version":3,"file":"getExtBridge.mjs","sources":["../../src/getExtBridge.ts"],"sourcesContent":["export const getExtBridge = async () => {\n await globalThis.mwExtBridge.readiness.isReady();\n return globalThis.mwExtBridge;\n};\n"],"names":[],"mappings":"AAAO,MAAM,eAAe,YAAY;AACtC,EAAA,MAAM,UAAA,CAAW,WAAA,CAAY,SAAA,CAAU,OAAA,EAAQ;AAC/C,EAAA,OAAO,UAAA,CAAW,WAAA;AACpB;;;;"}
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
import { readinessApi } from
|
|
2
|
-
//#region src/global-browser.ts
|
|
3
|
-
if (typeof globalThis.mwExtBridge !== "undefined") console.warn("mwExtBridge is already defined. The @mittwald/ext-bridge package is probably installed multiple times.");
|
|
4
|
-
globalThis.mwExtBridge = { readiness: readinessApi };
|
|
5
|
-
//#endregion
|
|
1
|
+
import { readinessApi } from './readiness.mjs';
|
|
6
2
|
|
|
7
|
-
|
|
3
|
+
const isAlreadyDefined = typeof globalThis.mwExtBridge !== "undefined";
|
|
4
|
+
if (isAlreadyDefined) {
|
|
5
|
+
console.warn(
|
|
6
|
+
"mwExtBridge is already defined. The @mittwald/ext-bridge package is probably installed multiple times."
|
|
7
|
+
);
|
|
8
|
+
}
|
|
9
|
+
const mwExtBridge = {
|
|
10
|
+
readiness: readinessApi
|
|
11
|
+
};
|
|
12
|
+
globalThis.mwExtBridge = mwExtBridge;
|
|
13
|
+
|
|
14
|
+
export { mwExtBridge };
|
|
15
|
+
//# sourceMappingURL=global-browser.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"global-browser.mjs","
|
|
1
|
+
{"version":3,"file":"global-browser.mjs","sources":["../../src/global-browser.ts"],"sourcesContent":["import { readinessApi } from \"@/readiness\";\nimport type { ExtBridge } from \"@/types\";\n\nconst isAlreadyDefined = typeof globalThis.mwExtBridge !== \"undefined\";\n\nif (isAlreadyDefined) {\n console.warn(\n \"mwExtBridge is already defined. The @mittwald/ext-bridge package is probably installed multiple times.\",\n );\n}\n\nexport const mwExtBridge = {\n readiness: readinessApi,\n} as ExtBridge;\n\nglobalThis.mwExtBridge = mwExtBridge;\n"],"names":[],"mappings":";;AAGA,MAAM,gBAAA,GAAmB,OAAO,UAAA,CAAW,WAAA,KAAgB,WAAA;AAE3D,IAAI,gBAAA,EAAkB;AACpB,EAAA,OAAA,CAAQ,IAAA;AAAA,IACN;AAAA,GACF;AACF;AAEO,MAAM,WAAA,GAAc;AAAA,EACzB,SAAA,EAAW;AACb;AAEA,UAAA,CAAW,WAAA,GAAc,WAAA;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18next.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import './global-browser.mjs';
|
|
2
|
+
export { getConfig } from './config/getConfig.mjs';
|
|
3
|
+
export { getSessionToken } from './sessionToken/getSessionToken.mjs';
|
|
4
|
+
//# sourceMappingURL=index-browser.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-browser.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
package/dist/js/index-node.mjs
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
export {
|
|
1
|
+
import './error.mjs';
|
|
2
|
+
import './sessionToken/schemas.mjs';
|
|
3
|
+
import 'jose';
|
|
4
|
+
export { verify } from './sessionToken/verify.mjs';
|
|
5
|
+
export { getAccessToken } from './sessionToken/getAccessToken.mjs';
|
|
6
|
+
//# sourceMappingURL=index-node.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-node.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
package/dist/js/index.mjs
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import '../../../global-browser.mjs';
|
|
2
|
+
import { getConfig } from '../../../config/getConfig.mjs';
|
|
3
|
+
import 'i18next';
|
|
4
|
+
|
|
5
|
+
const remoteLanguageDetectorModule = {
|
|
6
|
+
type: "languageDetector",
|
|
7
|
+
async: true,
|
|
8
|
+
detect: async () => {
|
|
9
|
+
const config = await getConfig();
|
|
10
|
+
return config.language;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { remoteLanguageDetectorModule };
|
|
15
|
+
//# sourceMappingURL=remoteLanguageDetectorModule.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remoteLanguageDetectorModule.mjs","sources":["../../../../../src/integrations/i18next/modules/remoteLanguageDetectorModule.ts"],"sourcesContent":["import { getConfig } from \"@/index-browser\";\nimport { type LanguageDetectorAsyncModule } from \"i18next\";\n\nexport const remoteLanguageDetectorModule: LanguageDetectorAsyncModule = {\n type: \"languageDetector\",\n async: true,\n detect: async () => {\n const config = await getConfig();\n return config.language;\n },\n};\n"],"names":[],"mappings":";;;;AAGO,MAAM,4BAAA,GAA4D;AAAA,EACvE,IAAA,EAAM,kBAAA;AAAA,EACN,KAAA,EAAO,IAAA;AAAA,EACP,QAAQ,YAAY;AAClB,IAAA,MAAM,MAAA,GAAS,MAAM,SAAA,EAAU;AAC/B,IAAA,OAAO,MAAA,CAAO,QAAA;AAAA,EAChB;AACF;;;;"}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import { ExtBridgeError } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { ExtBridgeError } from '../error.mjs';
|
|
2
|
+
|
|
3
|
+
const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
4
|
+
const assertBrowserEnv = () => {
|
|
5
|
+
if (!isBrowser) {
|
|
6
|
+
throw new ExtBridgeError(
|
|
7
|
+
"Ext Bridge can only be used in a browser environment. To opt-out from SSR you can use <BrowserOnly> from '@mittwald/flow-remote-react-components'."
|
|
8
|
+
);
|
|
9
|
+
}
|
|
6
10
|
};
|
|
7
|
-
//#endregion
|
|
8
|
-
export { assertBrowserEnv };
|
|
9
11
|
|
|
10
|
-
|
|
12
|
+
export { assertBrowserEnv };
|
|
13
|
+
//# sourceMappingURL=assertBrowserEnv.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertBrowserEnv.mjs","
|
|
1
|
+
{"version":3,"file":"assertBrowserEnv.mjs","sources":["../../../src/lib/assertBrowserEnv.ts"],"sourcesContent":["import { ExtBridgeError } from \"@/error\";\n\nconst isBrowser: boolean =\n typeof window !== \"undefined\" && typeof window.document !== \"undefined\";\n\nexport const assertBrowserEnv = () => {\n if (!isBrowser) {\n throw new ExtBridgeError(\n \"Ext Bridge can only be used in a browser environment. To opt-out from SSR you can use <BrowserOnly> from '@mittwald/flow-remote-react-components'.\",\n );\n }\n};\n"],"names":[],"mappings":";;AAEA,MAAM,YACJ,OAAO,MAAA,KAAW,WAAA,IAAe,OAAO,OAAO,QAAA,KAAa,WAAA;AAEvD,MAAM,mBAAmB,MAAM;AACpC,EAAA,IAAI,CAAC,SAAA,EAAW;AACd,IAAA,MAAM,IAAI,cAAA;AAAA,MACR;AAAA,KACF;AAAA,EACF;AACF;;;;"}
|
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
import { ExtBridgeError } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
resolve,
|
|
16
|
-
reject
|
|
17
|
-
];
|
|
1
|
+
import { ExtBridgeError } from '../error.mjs';
|
|
2
|
+
|
|
3
|
+
const controllablePromise = () => {
|
|
4
|
+
let resolve = () => {
|
|
5
|
+
throw new ExtBridgeError("Unexpected call of resolve()");
|
|
6
|
+
};
|
|
7
|
+
let reject = () => {
|
|
8
|
+
throw new ExtBridgeError("Unexpected call of reject()");
|
|
9
|
+
};
|
|
10
|
+
const promise = new Promise((res, rej) => {
|
|
11
|
+
resolve = res;
|
|
12
|
+
reject = rej;
|
|
13
|
+
});
|
|
14
|
+
return [promise, resolve, reject];
|
|
18
15
|
};
|
|
19
|
-
//#endregion
|
|
20
|
-
export { controllablePromise };
|
|
21
16
|
|
|
22
|
-
|
|
17
|
+
export { controllablePromise };
|
|
18
|
+
//# sourceMappingURL=controllablePromise.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controllablePromise.mjs","
|
|
1
|
+
{"version":3,"file":"controllablePromise.mjs","sources":["../../../src/lib/controllablePromise.ts"],"sourcesContent":["import { ExtBridgeError } from \"@/error\";\n\nexport const controllablePromise = () => {\n let resolve = (): void => {\n throw new ExtBridgeError(\"Unexpected call of resolve()\");\n };\n\n let reject: (error: unknown) => void = () => {\n throw new ExtBridgeError(\"Unexpected call of reject()\");\n };\n\n const promise = new Promise<void>((res, rej) => {\n resolve = res;\n reject = rej;\n });\n\n return [promise, resolve, reject] as const;\n};\n"],"names":[],"mappings":";;AAEO,MAAM,sBAAsB,MAAM;AACvC,EAAA,IAAI,UAAU,MAAY;AACxB,IAAA,MAAM,IAAI,eAAe,8BAA8B,CAAA;AAAA,EACzD,CAAA;AAEA,EAAA,IAAI,SAAmC,MAAM;AAC3C,IAAA,MAAM,IAAI,eAAe,6BAA6B,CAAA;AAAA,EACxD,CAAA;AAEA,EAAA,MAAM,OAAA,GAAU,IAAI,OAAA,CAAc,CAAC,KAAK,GAAA,KAAQ;AAC9C,IAAA,OAAA,GAAU,GAAA;AACV,IAAA,MAAA,GAAS,GAAA;AAAA,EACX,CAAC,CAAA;AAED,EAAA,OAAO,CAAC,OAAA,EAAS,OAAA,EAAS,MAAM,CAAA;AAClC;;;;"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { useExtBridge } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { useExtBridge } from './useExtBridge.mjs';
|
|
2
|
+
|
|
3
|
+
const useConfig = () => {
|
|
4
|
+
return useExtBridge().config;
|
|
5
5
|
};
|
|
6
|
-
//#endregion
|
|
7
|
-
export { useConfig };
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
export { useConfig };
|
|
8
|
+
//# sourceMappingURL=useConfig.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useConfig.mjs","
|
|
1
|
+
{"version":3,"file":"useConfig.mjs","sources":["../../../../src/react/hooks/useConfig.ts"],"sourcesContent":["import { useExtBridge } from \"@/react/hooks/useExtBridge\";\n\nexport const useConfig = () => {\n return useExtBridge().config;\n};\n"],"names":[],"mappings":";;AAEO,MAAM,YAAY,MAAM;AAC7B,EAAA,OAAO,cAAa,CAAE,MAAA;AACxB;;;;"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { getExtBridge } from
|
|
2
|
-
import { usePromise } from
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { getExtBridge } from '../../getExtBridge.mjs';
|
|
2
|
+
import { usePromise } from '@mittwald/react-use-promise';
|
|
3
|
+
|
|
4
|
+
const useExtBridge = () => {
|
|
5
|
+
return usePromise(getExtBridge, []);
|
|
6
6
|
};
|
|
7
|
-
//#endregion
|
|
8
|
-
export { useExtBridge };
|
|
9
7
|
|
|
10
|
-
|
|
8
|
+
export { useExtBridge };
|
|
9
|
+
//# sourceMappingURL=useExtBridge.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useExtBridge.mjs","
|
|
1
|
+
{"version":3,"file":"useExtBridge.mjs","sources":["../../../../src/react/hooks/useExtBridge.ts"],"sourcesContent":["import { getExtBridge } from \"@/getExtBridge\";\nimport { usePromise } from \"@mittwald/react-use-promise\";\n\nexport const useExtBridge = () => {\n return usePromise(getExtBridge, []);\n};\n"],"names":[],"mappings":";;;AAGO,MAAM,eAAe,MAAM;AAChC,EAAA,OAAO,UAAA,CAAW,YAAA,EAAc,EAAE,CAAA;AACpC;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLanguage.mjs","sources":["../../../../src/react/hooks/useLanguage.ts"],"sourcesContent":["import { useConfig } from \"./useConfig\";\n\nexport const useLanguage = () => useConfig().language;\n"],"names":[],"mappings":";;AAEO,MAAM,WAAA,GAAc,MAAM,SAAA,EAAU,CAAE;;;;"}
|
package/dist/js/react.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import './global-browser.mjs';
|
|
2
|
+
export { useConfig } from './react/hooks/useConfig.mjs';
|
|
3
|
+
export { useLanguage } from './react/hooks/useLanguage.mjs';
|
|
4
|
+
//# sourceMappingURL=react.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
package/dist/js/readiness.mjs
CHANGED
|
@@ -1,29 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { assertBrowserEnv } from
|
|
4
|
-
import { controllablePromise } from
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { parseConfig } from './config/parse.mjs';
|
|
2
|
+
import { ExtBridgeError } from './error.mjs';
|
|
3
|
+
import { assertBrowserEnv } from './lib/assertBrowserEnv.mjs';
|
|
4
|
+
import { controllablePromise } from './lib/controllablePromise.mjs';
|
|
5
|
+
|
|
6
|
+
const timeoutMs = 7500;
|
|
7
|
+
const [readiness, resolveReadiness] = controllablePromise();
|
|
8
|
+
const [timoutPromise, , rejectOnTimeout] = controllablePromise();
|
|
9
|
+
const startTimeout = () => {
|
|
10
|
+
setTimeout(() => {
|
|
11
|
+
rejectOnTimeout(
|
|
12
|
+
new ExtBridgeError(`Ext Bridge not ready after ${timeoutMs}ms`)
|
|
13
|
+
);
|
|
14
|
+
}, timeoutMs);
|
|
15
|
+
return timoutPromise;
|
|
14
16
|
};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
const readinessApi = {
|
|
18
|
+
isReady: async () => {
|
|
19
|
+
assertBrowserEnv();
|
|
20
|
+
await Promise.race([readiness, startTimeout()]);
|
|
21
|
+
},
|
|
22
|
+
setIsReady: async () => {
|
|
23
|
+
const config = await mwExtBridge.connection.getConfig();
|
|
24
|
+
mwExtBridge.config = parseConfig(config);
|
|
25
|
+
resolveReadiness();
|
|
26
|
+
}
|
|
25
27
|
};
|
|
26
|
-
//#endregion
|
|
27
|
-
export { readinessApi };
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
export { readinessApi };
|
|
30
|
+
//# sourceMappingURL=readiness.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readiness.mjs","
|
|
1
|
+
{"version":3,"file":"readiness.mjs","sources":["../../src/readiness.ts"],"sourcesContent":["import { parseConfig } from \"@/config/parse\";\nimport { ExtBridgeError } from \"@/error\";\nimport { assertBrowserEnv } from \"@/lib/assertBrowserEnv\";\nimport { controllablePromise } from \"@/lib/controllablePromise\";\n\nconst timeoutMs = 7500;\n\nconst [readiness, resolveReadiness] = controllablePromise();\nconst [timoutPromise, , rejectOnTimeout] = controllablePromise();\n\nconst startTimeout = () => {\n setTimeout(() => {\n rejectOnTimeout(\n new ExtBridgeError(`Ext Bridge not ready after ${timeoutMs}ms`),\n );\n }, timeoutMs);\n return timoutPromise;\n};\n\nexport const readinessApi = {\n isReady: async () => {\n assertBrowserEnv();\n await Promise.race([readiness, startTimeout()]);\n },\n setIsReady: async () => {\n const config = await mwExtBridge.connection.getConfig();\n mwExtBridge.config = parseConfig(config);\n resolveReadiness();\n },\n} as const;\n"],"names":[],"mappings":";;;;;AAKA,MAAM,SAAA,GAAY,IAAA;AAElB,MAAM,CAAC,SAAA,EAAW,gBAAgB,CAAA,GAAI,mBAAA,EAAoB;AAC1D,MAAM,CAAC,aAAA,IAAiB,eAAe,IAAI,mBAAA,EAAoB;AAE/D,MAAM,eAAe,MAAM;AACzB,EAAA,UAAA,CAAW,MAAM;AACf,IAAA,eAAA;AAAA,MACE,IAAI,cAAA,CAAe,CAAA,2BAAA,EAA8B,SAAS,CAAA,EAAA,CAAI;AAAA,KAChE;AAAA,EACF,GAAG,SAAS,CAAA;AACZ,EAAA,OAAO,aAAA;AACT,CAAA;AAEO,MAAM,YAAA,GAAe;AAAA,EAC1B,SAAS,YAAY;AACnB,IAAA,gBAAA,EAAiB;AACjB,IAAA,MAAM,QAAQ,IAAA,CAAK,CAAC,SAAA,EAAW,YAAA,EAAc,CAAC,CAAA;AAAA,EAChD,CAAA;AAAA,EACA,YAAY,YAAY;AACtB,IAAA,MAAM,MAAA,GAAS,MAAM,WAAA,CAAY,UAAA,CAAW,SAAA,EAAU;AACtD,IAAA,WAAA,CAAY,MAAA,GAAS,YAAY,MAAM,CAAA;AACvC,IAAA,gBAAA,EAAiB;AAAA,EACnB;AACF;;;;"}
|
|
@@ -1,17 +1,29 @@
|
|
|
1
|
-
import { ExtBridgeError } from
|
|
2
|
-
import { sessionTokenPayload } from
|
|
3
|
-
import { decodeJwt } from
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { ExtBridgeError } from '../error.mjs';
|
|
2
|
+
import { sessionTokenPayload } from './schemas.mjs';
|
|
3
|
+
import { decodeJwt } from 'jose';
|
|
4
|
+
|
|
5
|
+
const decode = (jwt) => {
|
|
6
|
+
const {
|
|
7
|
+
sub,
|
|
8
|
+
aud: ignoredAud,
|
|
9
|
+
exp: ignoredExp,
|
|
10
|
+
iat: ignoredIat,
|
|
11
|
+
iss: ignoredIss,
|
|
12
|
+
jti: ignoredJti,
|
|
13
|
+
nbf: ignoredNbf,
|
|
14
|
+
...rest
|
|
15
|
+
} = decodeJwt(jwt);
|
|
16
|
+
const parsed = sessionTokenPayload.safeParse({
|
|
17
|
+
userId: sub,
|
|
18
|
+
...rest
|
|
19
|
+
});
|
|
20
|
+
if (parsed.error) {
|
|
21
|
+
throw new ExtBridgeError(
|
|
22
|
+
"Session token payload invalid: " + parsed.error.message
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
return parsed.data;
|
|
13
26
|
};
|
|
14
|
-
//#endregion
|
|
15
|
-
export { decode };
|
|
16
27
|
|
|
17
|
-
|
|
28
|
+
export { decode };
|
|
29
|
+
//# sourceMappingURL=decode.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decode.mjs","
|
|
1
|
+
{"version":3,"file":"decode.mjs","sources":["../../../src/sessionToken/decode.ts"],"sourcesContent":["import { ExtBridgeError } from \"@/error\";\nimport { sessionTokenPayload } from \"@/sessionToken/schemas\";\nimport type { SessionTokenPayload } from \"@/sessionToken/types\";\nimport { decodeJwt } from \"jose\";\n\ntype JwtPayloadType = Omit<SessionTokenPayload, \"userId\">;\n\nexport const decode = (jwt: string) => {\n const {\n sub,\n aud: ignoredAud,\n exp: ignoredExp,\n iat: ignoredIat,\n iss: ignoredIss,\n jti: ignoredJti,\n nbf: ignoredNbf,\n ...rest\n } = decodeJwt<JwtPayloadType>(jwt);\n\n const parsed = sessionTokenPayload.safeParse({\n userId: sub,\n ...rest,\n });\n\n if (parsed.error) {\n throw new ExtBridgeError(\n \"Session token payload invalid: \" + parsed.error.message,\n );\n }\n\n return parsed.data;\n};\n"],"names":[],"mappings":";;;;AAOO,MAAM,MAAA,GAAS,CAAC,GAAA,KAAgB;AACrC,EAAA,MAAM;AAAA,IACJ,GAAA;AAAA,IACA,GAAA,EAAK,UAAA;AAAA,IACL,GAAA,EAAK,UAAA;AAAA,IACL,GAAA,EAAK,UAAA;AAAA,IACL,GAAA,EAAK,UAAA;AAAA,IACL,GAAA,EAAK,UAAA;AAAA,IACL,GAAA,EAAK,UAAA;AAAA,IACL,GAAG;AAAA,GACL,GAAI,UAA0B,GAAG,CAAA;AAEjC,EAAA,MAAM,MAAA,GAAS,oBAAoB,SAAA,CAAU;AAAA,IAC3C,MAAA,EAAQ,GAAA;AAAA,IACR,GAAG;AAAA,GACJ,CAAA;AAED,EAAA,IAAI,OAAO,KAAA,EAAO;AAChB,IAAA,MAAM,IAAI,cAAA;AAAA,MACR,iCAAA,GAAoC,OAAO,KAAA,CAAM;AAAA,KACnD;AAAA,EACF;AAEA,EAAA,OAAO,MAAA,CAAO,IAAA;AAChB;;;;"}
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
import { MW_EXT_API_URL } from
|
|
2
|
-
import axios from
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
method: "POST"
|
|
13
|
-
})).data;
|
|
1
|
+
import { MW_EXT_API_URL } from '../environment.mjs';
|
|
2
|
+
import axios from 'axios';
|
|
3
|
+
|
|
4
|
+
const getAccessToken = async (sessionToken, extensionSecret) => {
|
|
5
|
+
const response = await axios({
|
|
6
|
+
url: `${MW_EXT_API_URL}/v2/authenticate-session-token`,
|
|
7
|
+
data: { sessionToken, extensionSecret },
|
|
8
|
+
validateStatus: (status) => status === 201,
|
|
9
|
+
method: "POST"
|
|
10
|
+
});
|
|
11
|
+
return response.data;
|
|
14
12
|
};
|
|
15
|
-
//#endregion
|
|
16
|
-
export { getAccessToken };
|
|
17
13
|
|
|
18
|
-
|
|
14
|
+
export { getAccessToken };
|
|
15
|
+
//# sourceMappingURL=getAccessToken.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getAccessToken.mjs","
|
|
1
|
+
{"version":3,"file":"getAccessToken.mjs","sources":["../../../src/sessionToken/getAccessToken.ts"],"sourcesContent":["import { MW_EXT_API_URL } from \"@/environment\";\nimport axios from \"axios\";\n\ninterface ApiResponse {\n expiry: string;\n publicToken: string;\n}\n\nexport const getAccessToken = async (\n sessionToken: string,\n extensionSecret: string,\n) => {\n const response = await axios<ApiResponse>({\n url: `${MW_EXT_API_URL}/v2/authenticate-session-token`,\n data: { sessionToken, extensionSecret },\n validateStatus: (status) => status === 201,\n method: \"POST\",\n });\n return response.data;\n};\n"],"names":[],"mappings":";;;AAQO,MAAM,cAAA,GAAiB,OAC5B,YAAA,EACA,eAAA,KACG;AACH,EAAA,MAAM,QAAA,GAAW,MAAM,KAAA,CAAmB;AAAA,IACxC,GAAA,EAAK,GAAG,cAAc,CAAA,8BAAA,CAAA;AAAA,IACtB,IAAA,EAAM,EAAE,YAAA,EAAc,eAAA,EAAgB;AAAA,IACtC,cAAA,EAAgB,CAAC,MAAA,KAAW,MAAA,KAAW,GAAA;AAAA,IACvC,MAAA,EAAQ;AAAA,GACT,CAAA;AACD,EAAA,OAAO,QAAA,CAAS,IAAA;AAClB;;;;"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { getExtBridge } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { getExtBridge } from '../getExtBridge.mjs';
|
|
2
|
+
|
|
3
|
+
const getSessionToken = async () => {
|
|
4
|
+
const bridge = await getExtBridge();
|
|
5
|
+
return bridge.connection.getSessionToken();
|
|
5
6
|
};
|
|
6
|
-
//#endregion
|
|
7
|
-
export { getSessionToken };
|
|
8
7
|
|
|
9
|
-
|
|
8
|
+
export { getSessionToken };
|
|
9
|
+
//# sourceMappingURL=getSessionToken.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSessionToken.mjs","
|
|
1
|
+
{"version":3,"file":"getSessionToken.mjs","sources":["../../../src/sessionToken/getSessionToken.ts"],"sourcesContent":["import { getExtBridge } from \"@/getExtBridge\";\n\nexport const getSessionToken = async () => {\n const bridge = await getExtBridge();\n return bridge.connection.getSessionToken();\n};\n"],"names":[],"mappings":";;AAEO,MAAM,kBAAkB,YAAY;AACzC,EAAA,MAAM,MAAA,GAAS,MAAM,YAAA,EAAa;AAClC,EAAA,OAAO,MAAA,CAAO,WAAW,eAAA,EAAgB;AAC3C;;;;"}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { MW_EXT_API_URL } from
|
|
2
|
-
import axios from
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { MW_EXT_API_URL } from '../../environment.mjs';
|
|
2
|
+
import axios from 'axios';
|
|
3
|
+
|
|
4
|
+
const fetchPublicKey = async (serial) => {
|
|
5
|
+
const response = await axios({
|
|
6
|
+
url: `${MW_EXT_API_URL}/v2/public-keys/${serial}`,
|
|
7
|
+
validateStatus: (status) => status === 200,
|
|
8
|
+
params: {
|
|
9
|
+
format: "spki",
|
|
10
|
+
purpose: "session_token"
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
return response.data.key;
|
|
13
14
|
};
|
|
14
|
-
//#endregion
|
|
15
|
-
export { fetchPublicKey };
|
|
16
15
|
|
|
17
|
-
|
|
16
|
+
export { fetchPublicKey };
|
|
17
|
+
//# sourceMappingURL=fetchPublicKey.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchPublicKey.mjs","
|
|
1
|
+
{"version":3,"file":"fetchPublicKey.mjs","sources":["../../../../src/sessionToken/publicKeys/fetchPublicKey.ts"],"sourcesContent":["import { MW_EXT_API_URL } from \"@/environment\";\nimport axios from \"axios\";\n\ninterface ApiResponse {\n algorithm: string;\n key: string;\n serial: string;\n}\n\nexport const fetchPublicKey = async (serial: string) => {\n const response = await axios<ApiResponse>({\n url: `${MW_EXT_API_URL}/v2/public-keys/${serial}`,\n validateStatus: (status) => status === 200,\n params: {\n format: \"spki\",\n purpose: \"session_token\",\n },\n });\n return response.data.key;\n};\n"],"names":[],"mappings":";;;AASO,MAAM,cAAA,GAAiB,OAAO,MAAA,KAAmB;AACtD,EAAA,MAAM,QAAA,GAAW,MAAM,KAAA,CAAmB;AAAA,IACxC,GAAA,EAAK,CAAA,EAAG,cAAc,CAAA,gBAAA,EAAmB,MAAM,CAAA,CAAA;AAAA,IAC/C,cAAA,EAAgB,CAAC,MAAA,KAAW,MAAA,KAAW,GAAA;AAAA,IACvC,MAAA,EAAQ;AAAA,MACN,MAAA,EAAQ,MAAA;AAAA,MACR,OAAA,EAAS;AAAA;AACX,GACD,CAAA;AACD,EAAA,OAAO,SAAS,IAAA,CAAK,GAAA;AACvB;;;;"}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import { fetchPublicKey } from
|
|
2
|
-
import { importSPKI } from
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { fetchPublicKey } from './fetchPublicKey.mjs';
|
|
2
|
+
import { importSPKI } from 'jose';
|
|
3
|
+
|
|
4
|
+
const cache = /* @__PURE__ */ new Map();
|
|
5
|
+
const getPublicKey = async (serial) => {
|
|
6
|
+
const cached = cache.get(serial);
|
|
7
|
+
if (cached) {
|
|
8
|
+
return cached;
|
|
9
|
+
}
|
|
10
|
+
const publicKeyFromApi = await fetchPublicKey(serial);
|
|
11
|
+
const cryptoKey = await importSPKI(publicKeyFromApi, "Ed25519");
|
|
12
|
+
cache.set(serial, cryptoKey);
|
|
13
|
+
return cryptoKey;
|
|
11
14
|
};
|
|
12
|
-
//#endregion
|
|
13
|
-
export { getPublicKey };
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
export { getPublicKey };
|
|
17
|
+
//# sourceMappingURL=publicKeys.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publicKeys.mjs","
|
|
1
|
+
{"version":3,"file":"publicKeys.mjs","sources":["../../../../src/sessionToken/publicKeys/publicKeys.ts"],"sourcesContent":["import { fetchPublicKey } from \"@/sessionToken/publicKeys/fetchPublicKey\";\nimport { importSPKI } from \"jose\";\n\nconst cache = new Map<string, CryptoKey>();\n\nexport const getPublicKey = async (serial: string): Promise<CryptoKey> => {\n const cached = cache.get(serial);\n if (cached) {\n return cached;\n }\n\n const publicKeyFromApi = await fetchPublicKey(serial);\n const cryptoKey = await importSPKI(publicKeyFromApi, \"Ed25519\");\n\n cache.set(serial, cryptoKey);\n return cryptoKey;\n};\n"],"names":[],"mappings":";;;AAGA,MAAM,KAAA,uBAAY,GAAA,EAAuB;AAElC,MAAM,YAAA,GAAe,OAAO,MAAA,KAAuC;AACxE,EAAA,MAAM,MAAA,GAAS,KAAA,CAAM,GAAA,CAAI,MAAM,CAAA;AAC/B,EAAA,IAAI,MAAA,EAAQ;AACV,IAAA,OAAO,MAAA;AAAA,EACT;AAEA,EAAA,MAAM,gBAAA,GAAmB,MAAM,cAAA,CAAe,MAAM,CAAA;AACpD,EAAA,MAAM,SAAA,GAAY,MAAM,UAAA,CAAW,gBAAA,EAAkB,SAAS,CAAA;AAE9D,EAAA,KAAA,CAAM,GAAA,CAAI,QAAQ,SAAS,CAAA;AAC3B,EAAA,OAAO,SAAA;AACT;;;;"}
|
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
import { z } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
const extensionScopes = z.string().array();
|
|
4
|
+
const extensionContext = z.enum(["project", "customer"]);
|
|
5
|
+
const sessionTokenPayload = z.object({
|
|
6
|
+
sessionId: z.string(),
|
|
7
|
+
userId: z.string(),
|
|
8
|
+
extensionId: z.string(),
|
|
9
|
+
extensionInstanceId: z.string(),
|
|
10
|
+
contextId: z.string(),
|
|
11
|
+
context: extensionContext,
|
|
12
|
+
scopes: extensionScopes,
|
|
13
|
+
authenticatableWithoutSecret: z.boolean(),
|
|
14
|
+
publicKeySerial: z.string(),
|
|
15
|
+
variantKey: z.string().optional().nullable()
|
|
16
16
|
});
|
|
17
|
-
//#endregion
|
|
18
|
-
export { sessionTokenPayload };
|
|
19
17
|
|
|
20
|
-
|
|
18
|
+
export { extensionContext, extensionScopes, sessionTokenPayload };
|
|
19
|
+
//# sourceMappingURL=schemas.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.mjs","
|
|
1
|
+
{"version":3,"file":"schemas.mjs","sources":["../../../src/sessionToken/schemas.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport const extensionScopes = z.string().array();\nexport const extensionContext = z.enum([\"project\", \"customer\"]);\n\nexport const sessionTokenPayload = z.object({\n sessionId: z.string(),\n userId: z.string(),\n extensionId: z.string(),\n extensionInstanceId: z.string(),\n contextId: z.string(),\n context: extensionContext,\n scopes: extensionScopes,\n authenticatableWithoutSecret: z.boolean(),\n publicKeySerial: z.string(),\n variantKey: z.string().optional().nullable(),\n});\n"],"names":[],"mappings":";;AAEO,MAAM,eAAA,GAAkB,CAAA,CAAE,MAAA,EAAO,CAAE,KAAA;AACnC,MAAM,mBAAmB,CAAA,CAAE,IAAA,CAAK,CAAC,SAAA,EAAW,UAAU,CAAC;AAEvD,MAAM,mBAAA,GAAsB,EAAE,MAAA,CAAO;AAAA,EAC1C,SAAA,EAAW,EAAE,MAAA,EAAO;AAAA,EACpB,MAAA,EAAQ,EAAE,MAAA,EAAO;AAAA,EACjB,WAAA,EAAa,EAAE,MAAA,EAAO;AAAA,EACtB,mBAAA,EAAqB,EAAE,MAAA,EAAO;AAAA,EAC9B,SAAA,EAAW,EAAE,MAAA,EAAO;AAAA,EACpB,OAAA,EAAS,gBAAA;AAAA,EACT,MAAA,EAAQ,eAAA;AAAA,EACR,4BAAA,EAA8B,EAAE,OAAA,EAAQ;AAAA,EACxC,eAAA,EAAiB,EAAE,MAAA,EAAO;AAAA,EAC1B,YAAY,CAAA,CAAE,MAAA,EAAO,CAAE,QAAA,GAAW,QAAA;AACpC,CAAC;;;;"}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { decode } from
|
|
2
|
-
import { getPublicKey } from
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { decode } from './decode.mjs';
|
|
2
|
+
import { getPublicKey } from './publicKeys/publicKeys.mjs';
|
|
3
|
+
import { jwtVerify } from 'jose';
|
|
4
|
+
|
|
5
|
+
const verify = async (sessionToken) => {
|
|
6
|
+
const decoded = decode(sessionToken);
|
|
7
|
+
const publicKey = await getPublicKey(decoded.publicKeySerial);
|
|
8
|
+
await jwtVerify(sessionToken, publicKey);
|
|
9
|
+
return decoded;
|
|
10
10
|
};
|
|
11
|
-
//#endregion
|
|
12
|
-
export { verify };
|
|
13
11
|
|
|
14
|
-
|
|
12
|
+
export { verify };
|
|
13
|
+
//# sourceMappingURL=verify.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verify.mjs","
|
|
1
|
+
{"version":3,"file":"verify.mjs","sources":["../../../src/sessionToken/verify.ts"],"sourcesContent":["import { decode } from \"@/sessionToken/decode\";\nimport { getPublicKey } from \"@/sessionToken/publicKeys\";\nimport { jwtVerify } from \"jose\";\n\nexport const verify = async (sessionToken: string) => {\n const decoded = decode(sessionToken);\n const publicKey = await getPublicKey(decoded.publicKeySerial);\n await jwtVerify(sessionToken, publicKey);\n return decoded;\n};\n"],"names":[],"mappings":";;;;AAIO,MAAM,MAAA,GAAS,OAAO,YAAA,KAAyB;AACpD,EAAA,MAAM,OAAA,GAAU,OAAO,YAAY,CAAA;AACnC,EAAA,MAAM,SAAA,GAAY,MAAM,YAAA,CAAa,OAAA,CAAQ,eAAe,CAAA;AAC5D,EAAA,MAAM,SAAA,CAAU,cAAc,SAAS,CAAA;AACvC,EAAA,OAAO,OAAA;AACT;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getConfig.d.ts","sourceRoot":"","sources":["../../../src/config/getConfig.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS
|
|
1
|
+
{"version":3,"file":"getConfig.d.ts","sourceRoot":"","sources":["../../../src/config/getConfig.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS;;;;;;;;;;;EAGrB,CAAC"}
|
|
@@ -4,6 +4,7 @@ export declare const parseConfig: (something: unknown) => {
|
|
|
4
4
|
userId: string;
|
|
5
5
|
extensionId: string;
|
|
6
6
|
extensionInstanceId: string;
|
|
7
|
+
language: string;
|
|
7
8
|
variantKey?: string | null | undefined;
|
|
8
9
|
appInstallationId?: string | undefined;
|
|
9
10
|
projectId?: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../../src/config/parse.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,WAAW,GAAI,WAAW,OAAO
|
|
1
|
+
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../../src/config/parse.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,WAAW,GAAI,WAAW,OAAO;;;;;;;;;;;CAM7C,CAAC"}
|
|
@@ -5,6 +5,7 @@ export declare const config: z.ZodObject<{
|
|
|
5
5
|
extensionId: z.ZodString;
|
|
6
6
|
extensionInstanceId: z.ZodString;
|
|
7
7
|
variantKey: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
8
|
+
language: z.ZodDefault<z.ZodString>;
|
|
8
9
|
appInstallationId: z.ZodOptional<z.ZodString>;
|
|
9
10
|
projectId: z.ZodOptional<z.ZodString>;
|
|
10
11
|
customerId: z.ZodOptional<z.ZodString>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/config/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/config/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAiBxB,eAAO,MAAM,MAAM;;;;;;;;;;+DAE0B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/integrations/i18next/index.ts"],"names":[],"mappings":"AAAA,cAAc,wCAAwC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remoteLanguageDetectorModule.d.ts","sourceRoot":"","sources":["../../../../../src/integrations/i18next/modules/remoteLanguageDetectorModule.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,2BAA2B,EAAE,MAAM,SAAS,CAAC;AAE3D,eAAO,MAAM,4BAA4B,EAAE,2BAO1C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/react/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/react/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useConfig.d.ts","sourceRoot":"","sources":["../../../../src/react/hooks/useConfig.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS
|
|
1
|
+
{"version":3,"file":"useConfig.d.ts","sourceRoot":"","sources":["../../../../src/react/hooks/useConfig.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS;;;;;;;;;;;CAErB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLanguage.d.ts","sourceRoot":"","sources":["../../../../src/react/hooks/useLanguage.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW,cAA6B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mittwald/ext-bridge",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
3
|
+
"version": "0.2.0-alpha.785",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Bridge for mStudio embedded frontend extensions",
|
|
6
6
|
"homepage": "https://mittwald.github.io/flow",
|
|
@@ -20,6 +20,10 @@
|
|
|
20
20
|
"./react": {
|
|
21
21
|
"types": "./dist/types/react/index.d.ts",
|
|
22
22
|
"default": "./dist/js/react.mjs"
|
|
23
|
+
},
|
|
24
|
+
"./i18next": {
|
|
25
|
+
"types": "./dist/types/integrations/i18next/index.d.ts",
|
|
26
|
+
"default": "./dist/js/integrations/i18next.mjs"
|
|
23
27
|
}
|
|
24
28
|
},
|
|
25
29
|
"files": [
|
|
@@ -45,6 +49,7 @@
|
|
|
45
49
|
"@types/node": "^24.10.9",
|
|
46
50
|
"@types/react": "^19.2",
|
|
47
51
|
"@types/react-dom": "^19.2",
|
|
52
|
+
"i18next": "^26.0.3",
|
|
48
53
|
"nx": "^22.4.4",
|
|
49
54
|
"prettier": "^3.8.1",
|
|
50
55
|
"react": "^19.2.0",
|
|
@@ -52,13 +57,14 @@
|
|
|
52
57
|
"rimraf": "^6.1.2",
|
|
53
58
|
"rollup-preserve-directives": "^1.1.3",
|
|
54
59
|
"typescript": "^5.9.3",
|
|
55
|
-
"vite": "^
|
|
60
|
+
"vite": "^7.3.1",
|
|
56
61
|
"vite-plugin-checker": "^0.12.0",
|
|
57
62
|
"vite-plugin-dts": "^4.5.4",
|
|
58
63
|
"vite-plugin-externalize-deps": "^0.10.0",
|
|
59
|
-
"vitest": "^4.
|
|
64
|
+
"vitest": "^4.0.18"
|
|
60
65
|
},
|
|
61
66
|
"peerDependencies": {
|
|
67
|
+
"i18next": "^26.0.0",
|
|
62
68
|
"react": "^19.2.0",
|
|
63
69
|
"react-dom": "^19.2.0"
|
|
64
70
|
},
|
|
@@ -68,7 +74,10 @@
|
|
|
68
74
|
},
|
|
69
75
|
"react-dom": {
|
|
70
76
|
"optional": true
|
|
77
|
+
},
|
|
78
|
+
"i18next": {
|
|
79
|
+
"optional": true
|
|
71
80
|
}
|
|
72
81
|
},
|
|
73
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "1d5c6f9e7ca4758ab179250a39ee01ce6cbfa222"
|
|
74
83
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import "./useConfig.mjs";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import "./publicKeys.mjs";
|