@wix/api-client
Advanced tools
Comparing version 1.12.0 to 1.12.1
import { AuthenticationStrategy } from '@wix/sdk-types'; | ||
export type AppStrategy = AuthenticationStrategy<undefined, (opts: { | ||
instanceId: string; | ||
} | { | ||
refreshToken: string; | ||
} | { | ||
fromRequest: Request; | ||
}) => AppStrategy> & { | ||
export type AppStrategy = AuthenticationStrategy<undefined> & { | ||
getInstallUrl(opts: { | ||
@@ -10,0 +4,0 @@ redirectUrl: string; |
@@ -56,35 +56,2 @@ import { parsePublicKeyIfEncoded } from '../helpers.js'; | ||
}, | ||
withAuth(params) { | ||
if ('instanceId' in params) { | ||
return AppStrategy({ | ||
appId: opts.appId, | ||
appSecret: opts.appSecret, | ||
publicKey: opts.publicKey, | ||
instanceId: params.instanceId, | ||
}); | ||
} | ||
else if ('refreshToken' in params) { | ||
return AppStrategy({ | ||
appId: opts.appId, | ||
appSecret: opts.appSecret, | ||
publicKey: opts.publicKey, | ||
refreshToken: params.refreshToken, | ||
}); | ||
} | ||
else if ('fromRequest' in params) { | ||
const authFromRequest = params.fromRequest.headers.get('Authorization'); | ||
if (!authFromRequest) { | ||
throw new Error('Missing Authorization header in the request'); | ||
} | ||
return AppStrategy({ | ||
appId: opts.appId, | ||
appSecret: opts.appSecret, | ||
publicKey: opts.publicKey, | ||
accessToken: authFromRequest, | ||
}); | ||
} | ||
else { | ||
throw new Error('Invalid parameters for withAuth'); | ||
} | ||
}, | ||
async handleOAuthCallback(url, oauthOpts) { | ||
@@ -91,0 +58,0 @@ if (!opts.appSecret) { |
@@ -32,3 +32,2 @@ import { AuthenticationStrategy, BoundAuthenticationStrategy, BuildDescriptors, Descriptors, EventDefinition, EventIdentity, Host, HostModule, RESTFunctionDescriptor, ServicePluginContract, ServicePluginDefinition } from '@wix/sdk-types'; | ||
auth: Omit<Z, 'getAuthHeaders'> & BoundAuthenticationStrategy; | ||
withAuth: Z['withAuth'] extends undefined ? never : (...args: Parameters<NonNullable<Z['withAuth']>>) => WixClient<H, Z, T>; | ||
fetch(relativeUrl: string, options: RequestInit): Promise<Response>; | ||
@@ -93,3 +92,3 @@ fetchWithAuth: typeof fetch; | ||
} : ResolvePossibleEvents<T>); | ||
export declare function createClient<H extends Host<any> | undefined = undefined, Z extends AuthenticationStrategy<H, any> = AuthenticationStrategy<H>, T extends Descriptors = EmptyObject>(config: { | ||
export declare function createClient<H extends Host<any> | undefined = undefined, Z extends AuthenticationStrategy<H> = AuthenticationStrategy<H>, T extends Descriptors = EmptyObject>(config: { | ||
modules?: H extends Host<any> ? AssertHostMatches<T, H> : T; | ||
@@ -96,0 +95,0 @@ auth?: Z; |
@@ -90,8 +90,2 @@ import { wixContext } from '@wix/sdk-context'; | ||
auth: authStrategy, | ||
withAuth: (authStrategy.withAuth | ||
? (...args) => createClient({ | ||
...config, | ||
auth: authStrategy.withAuth(...args), | ||
}) | ||
: undefined), | ||
setHeaders, | ||
@@ -98,0 +92,0 @@ use, |
{ | ||
"name": "@wix/api-client", | ||
"version": "1.12.0", | ||
"version": "1.12.1", | ||
"license": "UNLICENSED", | ||
@@ -28,4 +28,4 @@ "main": "build/index.js", | ||
"@wix/sdk-context": "^0.0.1", | ||
"@wix/sdk-runtime": "0.3.2", | ||
"@wix/sdk-types": "^1.9.0", | ||
"@wix/sdk-runtime": "0.3.3", | ||
"@wix/sdk-types": "^1.9.1", | ||
"crypto-js": "^4.2.0", | ||
@@ -39,3 +39,3 @@ "jose": "^5.2.1", | ||
"@wix/metro-runtime": "^1.1677.0", | ||
"@wix/sdk": "1.12.0" | ||
"@wix/sdk": "1.12.1" | ||
}, | ||
@@ -53,3 +53,3 @@ "wix": { | ||
}, | ||
"falconPackageHash": "f33e506f0b9bcffbbafe855edba84ab7fad9b84a35450512d0e9357a" | ||
"falconPackageHash": "912c6ebcb7acbf759d13a89d2a68397d62c5bf0c8077b7e0bd1db925" | ||
} |
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
82088
2000
+ Added@wix/sdk-runtime@0.3.3(transitive)
- Removed@wix/sdk-runtime@0.3.2(transitive)
Updated@wix/sdk-runtime@0.3.3
Updated@wix/sdk-types@^1.9.1