@feathersjs/authentication-oauth 5.0.0-pre.3 → 5.0.0-pre.31

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/lib/utils.js CHANGED
@@ -1,9 +1,94 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getDefaultSettings = void 0;
4
- const getDefaultSettings = (_app, other) => {
5
- const defaults = Object.assign({ linkStrategy: 'jwt' }, other);
6
- return defaults;
6
+ exports.getServiceOptions = exports.setKoaParams = exports.setExpressParams = exports.getGrantConfig = void 0;
7
+ require("@feathersjs/koa");
8
+ require("@feathersjs/express");
9
+ const cookie_session_1 = __importDefault(require("cookie-session"));
10
+ const koa_session_1 = __importDefault(require("koa-session"));
11
+ const lodash_1 = require("lodash");
12
+ const getGrantConfig = (service) => {
13
+ const { app, configuration: { oauth } } = service;
14
+ // Set up all the defaults
15
+ const port = app.get('port');
16
+ let host = app.get('host');
17
+ let protocol = 'https';
18
+ // Development environments commonly run on HTTP with an extended port
19
+ if (process.env.NODE_ENV !== 'production') {
20
+ protocol = 'http';
21
+ if (String(port) !== '80') {
22
+ host += `:${port}`;
23
+ }
24
+ }
25
+ const grant = (0, lodash_1.defaultsDeep)({}, (0, lodash_1.omit)(oauth, ['redirect', 'origins']), {
26
+ defaults: {
27
+ prefix: '/oauth',
28
+ origin: `${protocol}://${host}`,
29
+ transport: 'state',
30
+ response: ['tokens', 'raw', 'profile']
31
+ }
32
+ });
33
+ const getUrl = (url) => {
34
+ const { defaults } = grant;
35
+ return `${defaults.origin}${defaults.prefix}/${url}`;
36
+ };
37
+ (0, lodash_1.each)(grant, (value, name) => {
38
+ if (name !== 'defaults') {
39
+ value.redirect_uri = value.redirect_uri || getUrl(`${name}/callback`);
40
+ }
41
+ });
42
+ return grant;
43
+ };
44
+ exports.getGrantConfig = getGrantConfig;
45
+ const setExpressParams = (req, res, next) => {
46
+ var _a;
47
+ (_a = req.session).destroy || (_a.destroy = () => {
48
+ req.session = null;
49
+ });
50
+ req.feathers = {
51
+ ...req.feathers,
52
+ session: req.session,
53
+ state: res.locals
54
+ };
55
+ next();
56
+ };
57
+ exports.setExpressParams = setExpressParams;
58
+ const setKoaParams = async (ctx, next) => {
59
+ var _a;
60
+ (_a = ctx.session).destroy || (_a.destroy = () => {
61
+ ctx.session = null;
62
+ });
63
+ ctx.feathers = {
64
+ ...ctx.feathers,
65
+ session: ctx.session,
66
+ state: ctx.state
67
+ };
68
+ await next();
69
+ };
70
+ exports.setKoaParams = setKoaParams;
71
+ const getServiceOptions = (service, settings) => {
72
+ const { secret } = service.configuration;
73
+ const koaApp = service.app;
74
+ if (koaApp.context) {
75
+ koaApp.keys = [secret];
76
+ const { koaSession = (0, koa_session_1.default)({ key: 'feathers.oauth' }, koaApp) } = settings;
77
+ return {
78
+ koa: {
79
+ before: [koaSession, exports.setKoaParams]
80
+ }
81
+ };
82
+ }
83
+ const { expressSession = (0, cookie_session_1.default)({
84
+ name: 'feathers.oauth',
85
+ keys: [secret]
86
+ }) } = settings;
87
+ return {
88
+ express: {
89
+ before: [expressSession, exports.setExpressParams]
90
+ }
91
+ };
7
92
  };
8
- exports.getDefaultSettings = getDefaultSettings;
93
+ exports.getServiceOptions = getServiceOptions;
9
94
  //# sourceMappingURL=utils.js.map
package/lib/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AASO,MAAM,kBAAkB,GAAG,CAAC,IAAiB,EAAE,KAAmC,EAAE,EAAE;IAC3F,MAAM,QAAQ,mBACZ,YAAY,EAAE,KAAK,IAChB,KAAK,CACT,CAAC;IAEF,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAPW,QAAA,kBAAkB,sBAO7B"}
1
+ {"version":3,"file":"utils.js","sour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C,MAAM,MAAM,GAAG,OAAO,CAAC,GAAqB,CAAA;IAE5C,IAAI,MAAM,CAAC,OAAO,EAAE;QAClB,MAAM,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,CAAA;QAEtB,MAAM,EAAE,UAAU,GAAG,IAAA,qBAAgB,EAAC,EAAE,GAAG,EAAE,gBAAgB,EAAE,EAAE,MAAa,CAAC,EAAE,GAAG,QAAQ,CAAA;QAE5F,OAAO;YACL,GAAG,EAAE;gBACH,MAAM,EAAE,CAAC,UAAU,EAAE,oBAAY,CAAC;aACnC;SACF,CAAA;KACF;IAED,MAAM,EACJ,cAAc,GAAG,IAAA,wBAAoB,EAAC;QACpC,IAAI,EAAE,gBAAgB;QACtB,IAAI,EAAE,CAAC,MAAM,CAAC;KACf,CAAC,EACH,GAAG,QAAQ,CAAA;IAEZ,OAAO;QACL,OAAO,EAAE;YACP,MAAM,EAAE,CAAC,cAAc,EAAE,wBAAgB,CAAC;SAC3C;KACF,CAAA;AACH,CAAC,CAAA;AA/BY,QAAA,iBAAiB,qBA+B7B"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@feathersjs/authentication-oauth",
3
3
  "description": "oAuth 1 and 2 authentication for Feathers. Powered by Grant.",
4
- "version": "5.0.0-pre.3",
4
+ "version": "5.0.0-pre.31",
5
5
  "homepage": "https://feathersjs.com",
6
6
  "main": "lib/",
7
7
  "types": "lib/",
@@ -16,7 +16,8 @@
16
16
  },
17
17
  "repository": {
18
18
  "type": "git",
19
- "url": "git://github.com/feathersjs/feathers.git"
19
+ "url": "git://github.com/feathersjs/feathers.git",
20
+ "directory": "packages/authentication-oauth"
20
21
  },
21
22
  "author": {
22
23
  "name": "Feathers contributors",
@@ -42,7 +43,8 @@
42
43
  "scripts": {
43
44
  "start": "ts-node test/app",
44
45
  "prepublish": "npm run compile",
45
- "compile": "shx rm -rf lib/ && tsc",
46
+ "pack": "npm pack --pack-destination ../cli/test/build",
47
+ "compile": "shx rm -rf lib/ && tsc && npm run pack",
46
48
  "test": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts"
47
49
  },
48
50
  "directories": {
@@ -52,28 +54,34 @@
52
54
  "access": "public"
53
55
  },
54
56
  "dependencies": {
55
- "@feathersjs/authentication": "^5.0.0-pre.3",
56
- "@feathersjs/commons": "^5.0.0-pre.3",
57
- "@feathersjs/errors": "^5.0.0-pre.3",
58
- "@feathersjs/express": "^5.0.0-pre.3",
59
- "@feathersjs/feathers": "^5.0.0-pre.3",
60
- "express-session": "^1.17.1",
61
- "grant": "^5.4.13",
62
- "lodash": "^4.17.21"
57
+ "@feathersjs/authentication": "^5.0.0-pre.31",
58
+ "@feathersjs/commons": "^5.0.0-pre.31",
59
+ "@feathersjs/errors": "^5.0.0-pre.31",
60
+ "@feathersjs/express": "^5.0.0-pre.31",
61
+ "@feathersjs/feathers": "^5.0.0-pre.31",
62
+ "@feathersjs/koa": "^5.0.0-pre.31",
63
+ "@feathersjs/schema": "^5.0.0-pre.31",
64
+ "cookie-session": "^2.0.0",
65
+ "grant": "^5.4.21",
66
+ "koa-session": "^6.2.0",
67
+ "lodash": "^4.17.21",
68
+ "qs": "^6.11.0"
63
69
  },
64
70
  "devDependencies": {
65
- "@feathersjs/adapter-memory": "^5.0.0-pre.3",
66
- "@types/debug": "^4.1.5",
67
- "@types/express": "^4.17.11",
68
- "@types/express-session": "^1.17.3",
69
- "@types/lodash": "^4.14.168",
70
- "@types/mocha": "^8.2.2",
71
- "@types/node": "^14.14.41",
72
- "axios": "^0.21.1",
73
- "mocha": "^8.3.2",
74
- "shx": "^0.3.3",
75
- "ts-node": "^9.1.1",
76
- "typescript": "^4.2.4"
71
+ "@feathersjs/memory": "^5.0.0-pre.31",
72
+ "@types/cookie-session": "^2.0.44",
73
+ "@types/express": "^4.17.14",
74
+ "@types/koa-session": "^5.10.6",
75
+ "@types/lodash": "^4.14.186",
76
+ "@types/mocha": "^10.0.0",
77
+ "@types/node": "^18.8.2",
78
+ "@types/tough-cookie": "^4.0.2",
79
+ "axios": "^0.27.2",
80
+ "mocha": "^10.0.0",
81
+ "shx": "^0.3.4",
82
+ "tough-cookie": "^4.1.2",
83
+ "ts-node": "^10.9.1",
84
+ "typescript": "^4.8.4"
77
85
  },
78
- "gitHead": "d332eaca9945aab0c222413a7e46cec1c0601648"
86
+ "gitHead": "4500dbeb8cea566678cf88b3313a88efd93a2ed9"
79
87
  }
package/src/index.ts CHANGED
@@ -1,80 +1,49 @@
1
- import merge from 'lodash/merge';
2
- import each from 'lodash/each';
3
- import omit from 'lodash/omit';
4
- import { createDebug } from '@feathersjs/commons';
5
- import { Application } from '@feathersjs/feathers';
6
- import { OAuthStrategy, OAuthProfile } from './strategy';
7
- import { default as setupExpress } from './express';
8
- import { OauthSetupSettings, getDefaultSettings } from './utils';
1
+ import { Application } from '@feathersjs/feathers'
2
+ import { createDebug } from '@feathersjs/commons'
3
+ import { resolveDispatch } from '@feathersjs/schema'
9
4
 
10
- const debug = createDebug('@feathersjs/authentication-oauth');
5
+ import { OAuthStrategy, OAuthProfile } from './strategy'
6
+ import { redirectHook, OAuthService } from './service'
7
+ import { getGrantConfig, getServiceOptions, OauthSetupSettings } from './utils'
11
8
 
12
- export { OauthSetupSettings, OAuthStrategy, OAuthProfile };
9
+ const debug = createDebug('@feathersjs/authentication-oauth')
13
10
 
14
- export const setup = (options: OauthSetupSettings) => (app: Application) => {
15
- const service = app.defaultAuthentication ? app.defaultAuthentication(options.authService) : null;
11
+ export { OauthSetupSettings, OAuthStrategy, OAuthProfile }
16
12
 
17
- if (!service) {
18
- throw new Error('An authentication service must exist before registering @feathersjs/authentication-oauth');
19
- }
20
-
21
- const { oauth } = service.configuration;
22
-
23
- if (!oauth) {
24
- debug('No oauth configuration found in authentication configuration. Skipping oAuth setup.');
25
- return;
26
- }
27
-
28
- const { strategyNames } = service;
29
-
30
- // Set up all the defaults
31
- const { prefix = '/oauth' } = oauth.defaults || {};
32
- const port = app.get('port');
33
- let host = app.get('host');
34
- let protocol = 'https';
13
+ export const oauth =
14
+ (settings: Partial<OauthSetupSettings> = {}) =>
15
+ (app: Application) => {
16
+ const authService = app.defaultAuthentication ? app.defaultAuthentication(settings.authService) : null
35
17
 
36
- // Development environments commonly run on HTTP with an extended port
37
- if (app.get('env') === 'development') {
38
- protocol = 'http';
39
- if (String(port) !== '80') {
40
- host += `:${port}`;
18
+ if (!authService) {
19
+ throw new Error(
20
+ 'An authentication service must exist before registering @feathersjs/authentication-oauth'
21
+ )
41
22
  }
42
- }
43
23
 
44
- const grant = merge({
45
- defaults: {
46
- prefix,
47
- origin: `${protocol}://${host}`,
48
- transport: 'session',
49
- response: ['tokens', 'raw', 'profile']
24
+ if (!authService.configuration.oauth) {
25
+ debug('No oauth configuration found in authentication configuration. Skipping oAuth setup.')
26
+ return
50
27
  }
51
- }, omit(oauth, 'redirect'));
52
-
53
- const getUrl = (url: string) => {
54
- const { defaults } = grant;
55
- return `${defaults.origin}${prefix}/${url}`;
56
- };
57
-
58
- each(grant, (value, name) => {
59
- if (name !== 'defaults') {
60
- value.callback = value.callback || getUrl(`${name}/authenticate`);
61
- value.redirect_uri = value.redirect_uri || getUrl(`${name}/callback`);
62
28
 
63
- if (!strategyNames.includes(name)) {
64
- debug(`Registering oAuth default strategy for '${name}'`);
65
- service.register(name, new OAuthStrategy());
66
- }
29
+ const oauthOptions = {
30
+ linkStrategy: 'jwt',
31
+ ...settings
67
32
  }
68
- });
69
33
 
70
- app.set('grant', grant);
71
- };
34
+ const grantConfig = getGrantConfig(authService)
35
+ const serviceOptions = getServiceOptions(authService, oauthOptions)
36
+ const servicePath = `${grantConfig.defaults.prefix || 'oauth'}/:provider`
72
37
 
73
- export const express = (settings: Partial<OauthSetupSettings> = {}) => (app: Application) => {
74
- const options = getDefaultSettings(app, settings);
38
+ app.use(servicePath, new OAuthService(authService, oauthOptions), serviceOptions)
75
39
 
76
- app.configure(setup(options));
77
- app.configure(setupExpress(options));
78
- };
40
+ const oauthService = app.service(servicePath)
79
41
 
80
- export const expressOauth = express;
42
+ oauthService.hooks({
43
+ around: { all: [resolveDispatch(), redirectHook()] }
44
+ })
45
+
46
+ if (typeof oauthService.publish === 'function') {
47
+ app.service(servicePath).publish(() => null)
48
+ }
49
+ }
package/src/service.ts ADDED
@@ -0,0 +1,177 @@
1
+ import { createDebug } from '@feathersjs/commons'
2
+ import { HookContext, NextFunction, Params } from '@feathersjs/feathers'
3
+ import { FeathersError } from '@feathersjs/errors'
4
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
5
+ //@ts-ignore
6
+ import Grant from 'grant/lib/grant'
7
+ import { AuthenticationService } from '@feathersjs/authentication'
8
+ import { OAuthStrategy } from './strategy'
9
+ import { getGrantConfig, OauthSetupSettings } from './utils'
10
+
11
+ const debug = createDebug('@feathersjs/authentication-oauth/services')
12
+
13
+ export type GrantResponse = {
14
+ location: string
15
+ session: any
16
+ state: any
17
+ }
18
+
19
+ export type OAuthParams = Omit<Params, 'route'> & {
20
+ session: any
21
+ state: Record<string, any>
22
+ route: {
23
+ provider: string
24
+ }
25
+ }
26
+
27
+ export class OAuthError extends FeathersError {
28
+ constructor(message: string, data: any, public location: string) {
29
+ super(message, 'NotAuthenticated', 401, 'not-authenticated', data)
30
+ }
31
+ }
32
+
33
+ export const redirectHook = () => async (context: HookContext, next: NextFunction) => {
34
+ try {
35
+ await next()
36
+
37
+ const { location } = context.result
38
+
39
+ debug(`oAuth redirect to ${location}`)
40
+
41
+ if (location) {
42
+ context.http = {
43
+ ...context.http,
44
+ location
45
+ }
46
+ }
47
+ } catch (error: any) {
48
+ if (error.location) {
49
+ context.http = {
50
+ ...context.http,
51
+ location: error.location
52
+ }
53
+ context.result = typeof error.toJSON === 'function' ? error.toJSON() : error
54
+ } else {
55
+ throw error
56
+ }
57
+ }
58
+ }
59
+
60
+ export class OAuthService {
61
+ grant: any
62
+
63
+ constructor(public service: AuthenticationService, public settings: OauthSetupSettings) {
64
+ const config = getGrantConfig(service)
65
+
66
+ this.grant = Grant({ config })
67
+ }
68
+
69
+ async handler(method: string, params: OAuthParams, body?: any, override?: string): Promise<GrantResponse> {
70
+ const {
71
+ session,
72
+ state,
73
+ query,
74
+ route: { provider }
75
+ } = params
76
+
77
+ const result: GrantResponse = await this.grant({
78
+ params: { provider, override },
79
+ state: state.grant,
80
+ session: session.grant,
81
+ query,
82
+ method,
83
+ body
84
+ })
85
+
86
+ session.grant = result.session
87
+ state.grant = result.state
88
+
89
+ return result
90
+ }
91
+
92
+ async authenticate(params: OAuthParams, result: GrantResponse) {
93
+ const name = params.route.provider
94
+ const { linkStrategy, authService } = this.settings
95
+ const { accessToken, grant, query = {}, redirect } = params.session
96
+ const strategy = this.service.getStrategy(name) as OAuthStrategy
97
+ const authParams = {
98
+ ...params,
99
+ authStrategies: [name],
100
+ authentication: accessToken
101
+ ? {
102
+ strategy: linkStrategy,
103
+ accessToken
104
+ }
105
+ : null,
106
+ query,
107
+ redirect
108
+ }
109
+ const payload = grant?.response || result?.session?.response || result?.state?.response || params.query
110
+ const authentication = {
111
+ strategy: name,
112
+ ...payload
113
+ }
114
+
115
+ try {
116
+ debug(`Calling ${authService}.create authentication with strategy ${name}`)
117
+
118
+ const authResult = await this.service.create(authentication, authParams)
119
+
120
+ debug('Successful oAuth authentication, sending response')
121
+
122
+ const location = await strategy.getRedirect(authResult, authParams)
123
+
124
+ if (typeof params.session.destroy === 'function') {
125
+ await params.session.destroy()
126
+ }
127
+
128
+ return {
129
+ ...authResult,
130
+ location
131
+ }
132
+ } catch (error: any) {
133
+ const location = await strategy.getRedirect(error, authParams)
134
+ const e = new OAuthError(error.message, error.data, location)
135
+
136
+ if (typeof params.session.destroy === 'function') {
137
+ await params.session.destroy()
138
+ }
139
+
140
+ e.stack = error.stack
141
+ throw e
142
+ }
143
+ }
144
+
145
+ async find(params: OAuthParams) {
146
+ const { session, query } = params
147
+ const { feathers_token, redirect, ...restQuery } = query
148
+ const handlerParams = {
149
+ ...params,
150
+ query: restQuery
151
+ }
152
+
153
+ if (feathers_token) {
154
+ debug('Got feathers_token query parameter to link accounts', feathers_token)
155
+ session.accessToken = feathers_token
156
+ }
157
+
158
+ session.redirect = redirect
159
+ session.query = restQuery
160
+
161
+ return this.handler('GET', handlerParams, {})
162
+ }
163
+
164
+ async get(override: string, params: OAuthParams) {
165
+ const result = await this.handler('GET', params, {}, override)
166
+
167
+ if (override === 'callback') {
168
+ return this.authenticate(params, result)
169
+ }
170
+
171
+ return result
172
+ }
173
+
174
+ async create(data: any, params: OAuthParams) {
175
+ return this.handler('POST', params, data)
176
+ }
177
+ }