@wix/api-client
Advanced tools
Comparing version 1.9.8 to 1.9.9
@@ -5,2 +5,4 @@ import { BuildDescriptors, Descriptors, Host } from './index.js'; | ||
}; | ||
export declare function setGlobalWixContext(wixContext: WixContext): void; | ||
export declare function setGlobalWixContext(wixContext: WixContext, options?: { | ||
dangerouslyOverride?: boolean; | ||
}): void; |
@@ -1,5 +0,5 @@ | ||
export function setGlobalWixContext(wixContext) { | ||
if (!globalThis.__wix_context__) { | ||
export function setGlobalWixContext(wixContext, options = {}) { | ||
if (!globalThis.__wix_context__ && options.dangerouslyOverride) { | ||
globalThis.__wix_context__ = wixContext; | ||
} | ||
} |
@@ -88,4 +88,4 @@ import { AuthenticationStrategy, BoundAuthenticationStrategy, BuildEventDefinition, BuildRESTFunction, EventDefinition, EventIdentity, Host, HostModule, HostModuleAPI, RESTFunctionDescriptor, ServicePluginDefinition, BuildServicePluginDefinition, ServicePluginContract } from '@wix/sdk-types'; | ||
body: string; | ||
}, componentType: string): Promise<unknown>; | ||
processRequest(request: Request, componentType: string): Promise<Response>; | ||
}): Promise<unknown>; | ||
processRequest(request: Request): Promise<Response>; | ||
}; | ||
@@ -92,0 +92,0 @@ } & BuildDescriptors<T, H>; |
@@ -46,5 +46,5 @@ import { EventDefinition, } from '@wix/sdk-types'; | ||
return buildServicePluginDefinition(modules, (servicePluginDefinition, implementation) => { | ||
const implementations = servicePluginsImplementations.get(servicePluginDefinition.componentType) ?? []; | ||
const implementations = servicePluginsImplementations.get(servicePluginDefinition.componentType.toLowerCase()) ?? []; | ||
implementations.push({ servicePluginDefinition, implementation }); | ||
servicePluginsImplementations.set(servicePluginDefinition.componentType, implementations); | ||
servicePluginsImplementations.set(servicePluginDefinition.componentType.toLowerCase(), implementations); | ||
}); | ||
@@ -143,2 +143,5 @@ } | ||
} | ||
if (typeof decoded.data !== 'string') { | ||
throw new Error(`Unexpected type of JWT data: expected string, got ${typeof decoded.data}`); | ||
} | ||
const parsedDecoded = JSON.parse(decoded.data); | ||
@@ -184,3 +187,3 @@ const eventType = parsedDecoded.eventType; | ||
getRegisteredServicePlugins: () => servicePluginsImplementations, | ||
async process(request, componentType) { | ||
async process(request) { | ||
if (!authStrategy.decodeJWT) { | ||
@@ -193,2 +196,12 @@ throw new Error('decodeJWT is not supported by the authentication strategy'); | ||
} | ||
if (typeof decoded.data !== 'object' || | ||
decoded.data === null || | ||
!('metadata' in decoded.data) || | ||
typeof decoded.data.metadata !== 'object' || | ||
decoded.data.metadata === null || | ||
!('appExtensionType' in decoded.data.metadata) || | ||
typeof decoded.data.metadata.appExtensionType !== 'string') { | ||
throw new Error('Unexpected JWT data: expected object with metadata.appExtensionType string'); | ||
} | ||
const componentType = decoded.data?.metadata.appExtensionType.toLowerCase(); | ||
const implementations = servicePluginsImplementations.get(componentType) ?? []; | ||
@@ -213,6 +226,6 @@ if (implementations.length === 0) { | ||
}, | ||
async processRequest(request, componentType) { | ||
async processRequest(request) { | ||
const url = request.url; | ||
const body = await request.text(); | ||
const implMethodResult = await this.process({ url, body }, componentType); | ||
const implMethodResult = await this.process({ url, body }); | ||
return Response.json(implMethodResult); | ||
@@ -219,0 +232,0 @@ }, |
{ | ||
"name": "@wix/api-client", | ||
"version": "1.9.8", | ||
"version": "1.9.9", | ||
"license": "UNLICENSED", | ||
@@ -25,5 +25,5 @@ "main": "build/index.js", | ||
"@wix/identity": "^1.0.78", | ||
"@wix/image-kit": "^1.68.0", | ||
"@wix/image-kit": "^1.69.0", | ||
"@wix/redirects": "^1.0.41", | ||
"@wix/sdk-types": "^1.7.2", | ||
"@wix/sdk-types": "^1.7.3", | ||
"crypto-js": "^4.2.0", | ||
@@ -37,3 +37,3 @@ "jose": "^5.2.1", | ||
"@wix/metro-runtime": "^1.1677.0", | ||
"@wix/sdk": "1.9.8" | ||
"@wix/sdk": "1.9.9" | ||
}, | ||
@@ -51,3 +51,3 @@ "wix": { | ||
}, | ||
"falconPackageHash": "325a1d5f2d986b14559dd5cf32e0c7cbb49e6a593af5ace61a685410" | ||
"falconPackageHash": "1a72d26521cf50eb31641d11420526639f65124a8d04f7815c6516dc" | ||
} |
79538
1940
Updated@wix/image-kit@^1.69.0
Updated@wix/sdk-types@^1.7.3