@wix/api-client
Advanced tools
Comparing version 1.9.3 to 1.9.4
@@ -1,2 +0,2 @@ | ||
import { AuthenticationStrategy, BoundAuthenticationStrategy, BuildEventDefinition, BuildRESTFunction, EventDefinition, EventIdentity, Host, HostModule, HostModuleAPI, RESTFunctionDescriptor, SPIDefinition } from '@wix/sdk-types'; | ||
import { AuthenticationStrategy, BoundAuthenticationStrategy, BuildEventDefinition, BuildRESTFunction, EventDefinition, EventIdentity, Host, HostModule, HostModuleAPI, RESTFunctionDescriptor, ServicePluginDefinition, BuildServicePluginDefinition } from '@wix/sdk-types'; | ||
import { ConditionalExcept } from 'type-fest/source/conditional-except.js'; | ||
@@ -16,3 +16,3 @@ import { EmptyObject } from 'type-fest/source/empty-object.js'; | ||
done: T; | ||
recurse: T extends AmbassadorFunctionDescriptor ? BuildAmbassadorFunction<T> : T extends RESTFunctionDescriptor ? BuildRESTFunction<T> : T extends EventDefinition ? BuildEventDefinition<T> : T extends HostModule<any, any> ? HostModuleAPI<T> : ConditionalExcept<{ | ||
recurse: T extends AmbassadorFunctionDescriptor ? BuildAmbassadorFunction<T> : T extends RESTFunctionDescriptor ? BuildRESTFunction<T> : T extends EventDefinition ? BuildEventDefinition<T> : T extends ServicePluginDefinition<any> ? BuildServicePluginDefinition<T> : T extends HostModule<any, any> ? HostModuleAPI<T> : ConditionalExcept<{ | ||
[Key in keyof T]: T[Key] extends Descriptors ? BuildDescriptors<T[Key], H, [-1, 0, 1, 2, 3, 4, 5][Depth]> : never; | ||
@@ -52,3 +52,3 @@ }, EmptyObject>; | ||
}; | ||
export type WixClient<H extends Host<any> | undefined = undefined, Z extends AuthenticationStrategy<H> = AuthenticationStrategy<H>, T extends Descriptors = Descriptors> = { | ||
export type WixClient<H extends Host<any> | undefined = undefined, Z extends AuthenticationStrategy<H> = AuthenticationStrategy<H>, T extends Descriptors = {}> = { | ||
setHeaders(headers: Headers): void; | ||
@@ -65,2 +65,3 @@ auth: Omit<Z, 'getAuthHeaders'> & BoundAuthenticationStrategy; | ||
webhooks: { | ||
getRegisteredEvents(): string[]; | ||
process<ExpectedEvents extends EventDefinition<any>[] = []>(jwt: string, opts?: { | ||
@@ -82,7 +83,2 @@ expectedEvents: ExpectedEvents; | ||
}; | ||
spi: <S extends SPIDefinition<any, any>>() => { | ||
process(jwt: string): Promise<S['__input']>; | ||
processRequest(request: Request): Promise<S['__input']>; | ||
result(result: S['__result']): S['__result']; | ||
}; | ||
} & BuildDescriptors<T, H>; | ||
@@ -89,0 +85,0 @@ type ResolvePossibleEvents<T extends EventDefinition<any>[]> = { |
@@ -9,2 +9,3 @@ import { EventDefinition, } from '@wix/sdk-types'; | ||
import { buildEventDefinition, isEventHandlerModule, runHandler, } from './event-handlers-modules.js'; | ||
import { buildServicePluginDefinition, isServicePluginModule, } from './service-plugin-modules.js'; | ||
export function createClient(config) { | ||
@@ -43,2 +44,5 @@ const _headers = config.headers || { Authorization: '' }; | ||
} | ||
else if (isServicePluginModule(modules)) { | ||
return buildServicePluginDefinition(modules, authStrategy.decodeJWT); | ||
} | ||
else if (isHostModule(modules) && config.host) { | ||
@@ -124,2 +128,3 @@ return buildHostModule(modules, config.host); | ||
webhooks: { | ||
getRegisteredEvents: () => Array.from(eventHandlers.keys()), | ||
process: async (jwt, opts = { | ||
@@ -173,24 +178,3 @@ expectedEvents: [], | ||
}, | ||
spi() { | ||
return { | ||
async process(jwt) { | ||
if (!authStrategy.decodeJWT) { | ||
throw new Error('decodeJWT is not supported by the authentication strategy'); | ||
} | ||
const { decoded, valid } = await authStrategy.decodeJWT(jwt, true); | ||
if (!valid) { | ||
throw new Error('JWT is not valid'); | ||
} | ||
return decoded.data; | ||
}, | ||
async processRequest(request) { | ||
const body = await request.text(); | ||
return this.process(body); | ||
}, | ||
result(result) { | ||
return result; | ||
}, | ||
}; | ||
}, | ||
}; | ||
} |
{ | ||
"name": "@wix/api-client", | ||
"version": "1.9.3", | ||
"version": "1.9.4", | ||
"license": "UNLICENSED", | ||
@@ -27,3 +27,3 @@ "main": "build/index.js", | ||
"@wix/redirects": "^1.0.41", | ||
"@wix/sdk-types": "^1.6.3", | ||
"@wix/sdk-types": "^1.7.0", | ||
"crypto-js": "^4.2.0", | ||
@@ -37,3 +37,3 @@ "jose": "^5.2.1", | ||
"@wix/metro-runtime": "^1.1677.0", | ||
"@wix/sdk": "1.9.3" | ||
"@wix/sdk": "1.9.4" | ||
}, | ||
@@ -51,3 +51,3 @@ "wix": { | ||
}, | ||
"falconPackageHash": "258e361f634a53da8a5bbd0435944f4e4f79a4daa3d80142fec9fd59" | ||
"falconPackageHash": "9f41930697602f1f44e580b7eb160971c8862f4e0976a59b8d5c9495" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
76015
46
1886
Updated@wix/sdk-types@^1.7.0