Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(types): Minor Type Improvements for the ThirdParty Recipe #946

Merged
merged 4 commits into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- The `networkInterceptor` now also gets a new `params` prop in the request config.
- Adds `customFramework` util functions to minimize code required in custom frameworks like remix, astro etc.
- Replicates `fastify` types based on requirement for the SDK instead of using the original module.
- Improved type definitions for `TypeProvider`

### Breaking change

Expand Down
5 changes: 3 additions & 2 deletions lib/build/recipe/thirdparty/providers/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var __importDefault =
Object.defineProperty(exports, "__esModule", { value: true });
exports.getActualClientIdFromDevelopmentClientId = exports.isUsingDevelopmentClientId = exports.DEV_OAUTH_REDIRECT_URL = void 0;
const thirdpartyUtils_1 = require("../../../thirdpartyUtils");
const utils_1 = require("../../../utils");
const pkce_challenge_1 = __importDefault(require("pkce-challenge"));
const configUtils_1 = require("./configUtils");
const jose_1 = require("jose");
Expand Down Expand Up @@ -284,15 +285,15 @@ function NewProvider(input) {
await impl.config.validateIdTokenPayload({
idTokenPayload: rawUserInfoFromProvider.fromIdTokenPayload,
clientConfig: impl.config,
userContext,
userContext: utils_1.getUserContext(userContext),
});
}
}
if (impl.config.validateAccessToken !== undefined && accessToken !== undefined) {
await impl.config.validateAccessToken({
accessToken: accessToken,
clientConfig: impl.config,
userContext,
userContext: utils_1.getUserContext(userContext),
});
}
if (accessToken && impl.config.userInfoEndpoint !== undefined) {
Expand Down
10 changes: 5 additions & 5 deletions lib/build/recipe/thirdparty/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,24 +98,24 @@ export declare type TypeProvider = {
config: ProviderConfigForClientType;
getConfigForClientType: (input: {
clientType?: string;
userContext: UserContext;
userContext?: UserContext;
}) => Promise<ProviderConfigForClientType>;
getAuthorisationRedirectURL: (input: {
redirectURIOnProviderDashboard: string;
userContext: UserContext;
userContext?: UserContext;
}) => Promise<{
urlWithQueryParams: string;
pkceCodeVerifier?: string;
}>;
exchangeAuthCodeForOAuthTokens: (input: {
redirectURIInfo: {
redirectURIOnProviderDashboard: string;
redirectURIQueryParams: any;
redirectURIQueryParams: Record<string, string>;
pkceCodeVerifier?: string;
};
userContext: UserContext;
userContext?: UserContext;
}) => Promise<any>;
getUserInfo: (input: { oAuthTokens: any; userContext: UserContext }) => Promise<UserInfo>;
getUserInfo: (input: { oAuthTokens: any; userContext?: UserContext }) => Promise<UserInfo>;
};
export declare type ProviderConfig = CommonProviderConfig & {
clients?: ProviderClientConfig[];
Expand Down
5 changes: 3 additions & 2 deletions lib/ts/recipe/thirdparty/providers/custom.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { TypeProvider, ProviderInput, UserInfo, ProviderConfigForClientType } from "../types";
import { doGetRequest, doPostRequest, verifyIdTokenFromJWKSEndpointAndGetPayload } from "../../../thirdpartyUtils";
import { getUserContext } from "../../../utils";
import pkceChallenge from "pkce-challenge";
import { getProviderConfigForClient } from "./configUtils";
import { JWTVerifyGetKey, createRemoteJWKSet } from "jose";
Expand Down Expand Up @@ -312,7 +313,7 @@ export default function NewProvider(input: ProviderInput): TypeProvider {
await impl.config.validateIdTokenPayload({
idTokenPayload: rawUserInfoFromProvider.fromIdTokenPayload,
clientConfig: impl.config,
userContext,
userContext: getUserContext(userContext),
});
}
}
Expand All @@ -321,7 +322,7 @@ export default function NewProvider(input: ProviderInput): TypeProvider {
await impl.config.validateAccessToken({
accessToken: accessToken,
clientConfig: impl.config,
userContext,
userContext: getUserContext(userContext),
});
}

Expand Down
10 changes: 5 additions & 5 deletions lib/ts/recipe/thirdparty/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,21 +98,21 @@ export type TypeProvider = {

getConfigForClientType: (input: {
clientType?: string;
userContext: UserContext;
userContext?: UserContext;
}) => Promise<ProviderConfigForClientType>;
getAuthorisationRedirectURL: (input: {
redirectURIOnProviderDashboard: string;
userContext: UserContext;
userContext?: UserContext;
rishabhpoddar marked this conversation as resolved.
Show resolved Hide resolved
}) => Promise<{ urlWithQueryParams: string; pkceCodeVerifier?: string }>;
exchangeAuthCodeForOAuthTokens: (input: {
redirectURIInfo: {
redirectURIOnProviderDashboard: string;
redirectURIQueryParams: any;
redirectURIQueryParams: Record<string, string>;
pkceCodeVerifier?: string;
};
userContext: UserContext;
userContext?: UserContext;
}) => Promise<any>;
getUserInfo: (input: { oAuthTokens: any; userContext: UserContext }) => Promise<UserInfo>;
getUserInfo: (input: { oAuthTokens: any; userContext?: UserContext }) => Promise<UserInfo>;
};

export type ProviderConfig = CommonProviderConfig & {
Expand Down
Loading