Skip to content

Commit

Permalink
Add AuthorizationStrategy interface to ensure proper class types
Browse files Browse the repository at this point in the history
  • Loading branch information
rezaansyed committed Nov 14, 2023
1 parent 997891e commit 52ce982
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {
redirectFactory,
redirectToShopifyOrAppRoot,
} from './helpers';
import {AuthCodeFlowStrategy} from './strategies/auth-code-flow';
import {AuthorizationStrategy} from './strategies/types';

const SESSION_TOKEN_PARAM = 'id_token';

Expand All @@ -45,14 +45,14 @@ interface ShopWithSessionContext {
}

interface AuthStrategyParams extends BasicParams {
strategy: AuthCodeFlowStrategy;
strategy: AuthorizationStrategy;
}

export class AuthStrategy<
Config extends AppConfigArg,
Resources extends ShopifyRestResources = ShopifyRestResources,
> {
protected strategy: AuthCodeFlowStrategy;
protected strategy: AuthorizationStrategy;
protected api: Shopify;
protected config: AppConfig;
protected logger: Shopify['logger'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@ import {
import {SessionContext} from '../types';
import {AppConfig} from '../../../config-types';

import {AuthorizationStrategy} from './types';

export class AuthCodeFlowStrategy<
Resources extends ShopifyRestResources = ShopifyRestResources,
> {
> implements AuthorizationStrategy
{
protected api: Shopify;
protected config: AppConfig;
protected logger: Shopify['logger'];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {SessionContext} from '../types';

export interface AuthorizationStrategy {
handleRoutes: (request: Request) => void;
manageAccessToken: (
sessionContext: SessionContext | undefined,
shop: string,
request: Request,
) => Promise<SessionContext>;
ensureInstalledOnShop: (request: Request) => void;
}

0 comments on commit 52ce982

Please sign in to comment.