@aptly-as/sdk-app-express 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/install.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Response, Request, NextFunction } from 'express';
2
2
  export declare function install(req: Request, res: Response, next: NextFunction): void;
3
3
  export declare function installCallback(req: Request, res: Response, next: NextFunction): Promise<void>;
4
+ export declare function installCallbackMiddleware(req: Request, _res: Response, next: NextFunction): Promise<void>;
4
5
  export declare function reinstall(req: Request, res: Response, next: NextFunction): Promise<void>;
package/dist/install.js CHANGED
@@ -14,7 +14,7 @@ export async function installCallback(req, res, next) {
14
14
  try {
15
15
  const { code, redirect_uri } = req.aptly.auth.verifyInstallCallback(req.originalUrl, req.query);
16
16
  const tokenData = await req.aptly.auth.installAppCode(code);
17
- await req.aptly.onInstall(req, tokenData);
17
+ await req.aptly.onInstall(req, tokenData, { code, redirect_uri });
18
18
  const redirect = req.cookies[req.aptly.redirectCookie.name];
19
19
  if (redirect) {
20
20
  res.clearCookie(req.aptly.redirectCookie.name);
@@ -27,6 +27,17 @@ export async function installCallback(req, res, next) {
27
27
  next(e);
28
28
  }
29
29
  }
30
+ export async function installCallbackMiddleware(req, _res, next) {
31
+ try {
32
+ const { code, redirect_uri } = req.aptly.auth.verifyInstallCallback(req.originalUrl, req.query);
33
+ const tokenData = await req.aptly.auth.installAppCode(code);
34
+ await req.aptly.onInstall(req, tokenData, { code, redirect_uri });
35
+ next();
36
+ }
37
+ catch (e) {
38
+ next(e);
39
+ }
40
+ }
30
41
  export async function reinstall(req, res, next) {
31
42
  try {
32
43
  const { redirect_uri } = req.query;
package/dist/types.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { IAptlyAppRedirectSuccessProps } from '@aptly-as/sdk-app/dist/AptlyOAuth2.js';
1
2
  import type { AptlyAppAuthorizeToken } from '@aptly-as/types';
2
3
  import { Request } from 'express';
3
4
  import { Aptly, AptlyApiOAuth2Response, AptlyOAuth2 } from '@aptly-as/sdk-app';
@@ -16,7 +17,7 @@ export interface AppExpressContext<T extends AptlyAppConfig> {
16
17
  token?: AptlyAppAuthorizeToken;
17
18
  tokenCookie: AppCookie;
18
19
  redirectCookie: AppCookie;
19
- onInstall: (req: Request, code: AptlyApiOAuth2Response) => Promise<void>;
20
+ onInstall: (req: Request, code: AptlyApiOAuth2Response, redirect: IAptlyAppRedirectSuccessProps) => Promise<void>;
20
21
  getConfig: (req: Request, organization: string) => Promise<T>;
21
22
  development?: boolean;
22
23
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aptly-as/sdk-app-express",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Aptly App SDK Express wrapper",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",