Skip to content

Commit

Permalink
Merge pull request #586 from stevengill/issue-585
Browse files Browse the repository at this point in the history
passed clientOptions and authorizationUrl to @slack/oauth
  • Loading branch information
stevengill authored Aug 21, 2020
2 parents ac327a0 + 982987a commit a168252
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 30 deletions.
19 changes: 0 additions & 19 deletions .github/workflows/gh-pages.yml

This file was deleted.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"mocha": "TS_NODE_PROJECT=tsconfig.test.json nyc mocha --config .mocharc.json \"src/**/*.spec.ts\"",
"test": "npm run lint && npm run test-lint && npm run mocha && npm run test:types",
"test:types": "tsd",
"coverage": "codecov"
"coverage": "codecov",
"watch": "npx nodemon --watch 'src' --ext 'ts' --exec npm run build"
},
"repository": "slackapi/bolt",
"homepage": "https://slack.dev/bolt-js",
Expand All @@ -42,7 +43,7 @@
},
"dependencies": {
"@slack/logger": "^2.0.0",
"@slack/oauth": "^1.1.0",
"@slack/oauth": "^1.2.0",
"@slack/types": "^1.6.0",
"@slack/web-api": "^5.9.0",
"@types/express": "^4.16.1",
Expand Down
10 changes: 9 additions & 1 deletion src/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ export default class App {

private axios: AxiosInstance;

private installerOptions: ExpressReceiverOptions['installerOptions'];

constructor({
signingSecret = undefined,
endpoints = undefined,
Expand Down Expand Up @@ -220,6 +222,12 @@ export default class App {
this.middleware = [];
this.listeners = [];

// Add clientOptions to InstallerOptions to pass them to @slack/oauth
this.installerOptions = {
clientOptions: this.clientOptions,
...installerOptions,
};

// Check for required arguments of ExpressReceiver
if (receiver !== undefined) {
this.receiver = receiver;
Expand All @@ -239,8 +247,8 @@ export default class App {
clientSecret,
stateSecret,
installationStore,
installerOptions,
scopes,
installerOptions: this.installerOptions,
logger: this.logger,
});
}
Expand Down
20 changes: 12 additions & 8 deletions src/ExpressReceiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import querystring from 'querystring';
import crypto from 'crypto';
import tsscmp from 'tsscmp';
import { Logger, ConsoleLogger } from '@slack/logger';
import { InstallProvider, StateStore, InstallationStore, CallbackOptions } from '@slack/oauth';
import { InstallProvider, CallbackOptions, InstallProviderOptions, InstallURLOptions } from '@slack/oauth';
import App from './App';
import { ReceiverAuthenticityError, ReceiverMultipleAckError } from './errors';
import { AnyMiddlewareArgs, Receiver, ReceiverEvent } from './types';
Expand All @@ -25,21 +25,23 @@ export interface ExpressReceiverOptions {
processBeforeResponse?: boolean;
clientId?: string;
clientSecret?: string;
stateSecret?: string; // ClearStateStoreOptions['secret']; // required when using default stateStore
installationStore?: InstallationStore; // default MemoryInstallationStore
scopes?: string | string[];
stateSecret?: InstallProviderOptions['stateSecret']; // required when using default stateStore
installationStore?: InstallProviderOptions['installationStore']; // default MemoryInstallationStore
scopes?: InstallURLOptions['scopes'];
installerOptions?: InstallerOptions;
}

// Additional Installer Options
interface InstallerOptions {
stateStore?: StateStore; // default ClearStateStore
authVersion?: 'v1' | 'v2'; // default 'v2'
metadata?: string;
stateStore?: InstallProviderOptions['stateStore']; // default ClearStateStore
authVersion?: InstallProviderOptions['authVersion']; // default 'v2'
metadata?: InstallURLOptions['metadata'];
installPath?: string;
redirectUriPath?: string;
callbackOptions?: CallbackOptions;
userScopes?: string | string[];
userScopes?: InstallURLOptions['userScopes'];
clientOptions?: InstallProviderOptions['clientOptions'];
authorizationUrl?: InstallProviderOptions['authorizationUrl'];
}

/**
Expand Down Expand Up @@ -104,6 +106,8 @@ export default class ExpressReceiver implements Receiver {
installationStore,
stateStore: installerOptions.stateStore,
authVersion: installerOptions.authVersion!,
clientOptions: installerOptions.clientOptions,
authorizationUrl: installerOptions.authorizationUrl,
});
}

Expand Down
11 changes: 11 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,14 @@ export * from './middleware/builtin';
export * from './types';

export { ConversationStore, MemoryStore } from './conversation-store';

export {
Installation,
InstallURLOptions,
InstallationQuery,
InstallationStore,
StateStore,
InstallProviderOptions,
} from '@slack/oauth';

export * from '@slack/types';

0 comments on commit a168252

Please sign in to comment.