@whook/oauth2 8.5.1 → 9.0.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/README.md +21 -7
- package/dist/handlers/getOAuth2Authorize.d.ts +5 -3
- package/dist/handlers/getOAuth2Authorize.js +1 -1
- package/dist/handlers/getOAuth2Authorize.js.map +1 -1
- package/dist/handlers/getOAuth2Authorize.mjs +1 -1
- package/dist/handlers/getOAuth2Authorize.mjs.map +1 -1
- package/dist/handlers/getOAuth2Authorize.test.js.map +1 -1
- package/dist/handlers/getOAuth2Authorize.test.mjs.map +1 -1
- package/dist/handlers/postAuthLogin.d.ts +2 -2
- package/dist/handlers/postAuthLogin.js +1 -0
- package/dist/handlers/postAuthLogin.js.map +1 -1
- package/dist/handlers/postAuthLogin.mjs +1 -0
- package/dist/handlers/postAuthLogin.mjs.map +1 -1
- package/dist/handlers/postAuthLogin.test.js.map +1 -1
- package/dist/handlers/postAuthLogin.test.mjs.map +1 -1
- package/dist/handlers/postAuthLogout.js.map +1 -1
- package/dist/handlers/postAuthLogout.mjs.map +1 -1
- package/dist/handlers/postAuthLogout.test.js.map +1 -1
- package/dist/handlers/postAuthLogout.test.mjs.map +1 -1
- package/dist/handlers/postAuthRefresh.d.ts +3 -3
- package/dist/handlers/postAuthRefresh.js +1 -0
- package/dist/handlers/postAuthRefresh.js.map +1 -1
- package/dist/handlers/postAuthRefresh.mjs +1 -0
- package/dist/handlers/postAuthRefresh.mjs.map +1 -1
- package/dist/handlers/postAuthRefresh.test.js.map +1 -1
- package/dist/handlers/postAuthRefresh.test.mjs.map +1 -1
- package/dist/handlers/postOAuth2Acknowledge.d.ts +10 -7
- package/dist/handlers/postOAuth2Acknowledge.js +2 -2
- package/dist/handlers/postOAuth2Acknowledge.js.map +1 -1
- package/dist/handlers/postOAuth2Acknowledge.mjs +2 -2
- package/dist/handlers/postOAuth2Acknowledge.mjs.map +1 -1
- package/dist/handlers/postOAuth2Acknowledge.test.js.map +1 -1
- package/dist/handlers/postOAuth2Acknowledge.test.mjs.map +1 -1
- package/dist/handlers/postOAuth2Token.d.ts +3 -3
- package/dist/handlers/postOAuth2Token.js +2 -2
- package/dist/handlers/postOAuth2Token.js.map +1 -1
- package/dist/handlers/postOAuth2Token.mjs +2 -2
- package/dist/handlers/postOAuth2Token.mjs.map +1 -1
- package/dist/handlers/postOAuth2Token.test.js.map +1 -1
- package/dist/handlers/postOAuth2Token.test.mjs.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/index.test.js +6 -7
- package/dist/index.test.js.map +1 -1
- package/dist/index.test.mjs +6 -7
- package/dist/index.test.mjs.map +1 -1
- package/dist/services/authCookies.js.map +1 -1
- package/dist/services/authCookies.mjs.map +1 -1
- package/dist/services/authCookies.test.js.map +1 -1
- package/dist/services/authCookies.test.mjs.map +1 -1
- package/dist/services/oAuth2ClientCredentialsGranter.js.map +1 -1
- package/dist/services/oAuth2ClientCredentialsGranter.mjs.map +1 -1
- package/dist/services/oAuth2CodeGranter.js.map +1 -1
- package/dist/services/oAuth2CodeGranter.mjs.map +1 -1
- package/dist/services/oAuth2CodeGranter.test.js +8 -6
- package/dist/services/oAuth2CodeGranter.test.js.map +1 -1
- package/dist/services/oAuth2CodeGranter.test.mjs +8 -6
- package/dist/services/oAuth2CodeGranter.test.mjs.map +1 -1
- package/dist/services/oAuth2Granters.d.ts +22 -19
- package/dist/services/oAuth2Granters.js.map +1 -1
- package/dist/services/oAuth2Granters.mjs.map +1 -1
- package/dist/services/oAuth2PasswordGranter.js.map +1 -1
- package/dist/services/oAuth2PasswordGranter.mjs.map +1 -1
- package/dist/services/oAuth2RefreshTokenGranter.js +1 -1
- package/dist/services/oAuth2RefreshTokenGranter.js.map +1 -1
- package/dist/services/oAuth2RefreshTokenGranter.mjs +1 -1
- package/dist/services/oAuth2RefreshTokenGranter.mjs.map +1 -1
- package/dist/services/oAuth2TokenGranter.js.map +1 -1
- package/dist/services/oAuth2TokenGranter.mjs.map +1 -1
- package/package.json +34 -35
- package/src/handlers/getOAuth2Authorize.ts +15 -14
- package/src/handlers/postAuthLogin.ts +4 -3
- package/src/handlers/postAuthRefresh.ts +4 -3
- package/src/handlers/postOAuth2Acknowledge.ts +34 -26
- package/src/handlers/postOAuth2Token.test.ts +2 -2
- package/src/handlers/postOAuth2Token.ts +4 -4
- package/src/index.test.ts +8 -9
- package/src/services/oAuth2ClientCredentialsGranter.ts +25 -21
- package/src/services/oAuth2CodeGranter.test.ts +15 -14
- package/src/services/oAuth2CodeGranter.ts +66 -60
- package/src/services/oAuth2Granters.ts +59 -29
- package/src/services/oAuth2PasswordGranter.ts +23 -22
- package/src/services/oAuth2RefreshTokenGranter.ts +28 -24
- package/src/services/oAuth2TokenGranter.ts +44 -42
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"oAuth2CodeGranter.test.js","names":["describe","oAuth2Code","create","jest","fn","check","checkApplication","log","beforeEach","mockReset","it","oAuth2CodeGranter","initOAuth2CodeGranter","mockResolvedValue","redirectURI","mockResolvedValueOnce","applicationId","scope","authorizerResult","authorizer","authorize","clientId","acknowledgerResult","acknowledger","acknowledge","authenticatorResult","authenticator","authenticate","code","expect","toMatchInlineSnapshot","oAuth2CodeCreateCalls","mock","calls","oAuth2CodeCheckCalls","checkApplicationCalls","logCalls","toMatchSnapshot"],"sources":["../../src/services/oAuth2CodeGranter.test.ts"],"sourcesContent":["import initOAuth2CodeGranter from './oAuth2CodeGranter';\n\ndescribe('OAuth2CodeGranter', () => {\n const oAuth2Code = {\n create: jest.fn(),\n check: jest.fn(),\n };\n const checkApplication = jest.fn();\n const log = jest.fn();\n\n beforeEach(() => {\n oAuth2Code.create.mockReset();\n oAuth2Code.check.mockReset();\n checkApplication.mockReset();\n log.mockReset();\n });\n\n it('should work with a complete valid flow', async () => {\n const oAuth2CodeGranter = await initOAuth2CodeGranter({\n checkApplication,\n oAuth2Code,\n log,\n });\n\n checkApplication.mockResolvedValue({\n redirectURI: 'https://www.example.com',\n });\n oAuth2Code.create.mockResolvedValueOnce('yolo');\n oAuth2Code.check.mockResolvedValueOnce({\n applicationId: 'abbacaca-abba-caca-abba-cacaabbacaca',\n scope: 'user',\n });\n\n const authorizerResult = await oAuth2CodeGranter.authorizer?.authorize({\n clientId: 'abbacaca-abba-caca-abba-cacaabbacaca',\n redirectURI: 'https://www.example.com/oauth2/code',\n scope: 'user',\n });\n const acknowledgerResult =\n await oAuth2CodeGranter.acknowledger?.acknowledge(\n {\n applicationId: 'abbacaca-abba-caca-abba-cacaabbacaca',\n scope: 'user, admin',\n },\n {\n clientId: 'abbacaca-abba-caca-abba-cacaabbacaca',\n redirectURI: 'https://www.example.com/oauth2/code',\n scope: 'user',\n },\n {},\n );\n const authenticatorResult =\n await oAuth2CodeGranter.authenticator?.authenticate(\n {\n clientId: 'abbacaca-abba-caca-abba-cacaabbacaca',\n redirectURI: 'https://www.example.com/oauth2/code',\n code: 'yolo',\n },\n {\n applicationId: 'abbacaca-abba-caca-abba-cacaabbacaca',\n scope: 'user',\n },\n );\n\n expect({\n authorizerResult,\n acknowledgerResult,\n authenticatorResult,\n }).toMatchInlineSnapshot(`\n Object {\n \"acknowledgerResult\": Object {\n \"applicationId\": \"abbacaca-abba-caca-abba-cacaabbacaca\",\n \"code\": \"yolo\",\n \"redirectURI\": \"https://www.example.com/oauth2/code\",\n \"scope\": \"user\",\n },\n \"authenticatorResult\": Object {\n \"applicationId\": \"abbacaca-abba-caca-abba-cacaabbacaca\",\n \"scope\": \"user\",\n },\n \"authorizerResult\": Object {\n \"applicationId\": \"abbacaca-abba-caca-abba-cacaabbacaca\",\n \"redirectURI\": \"https://www.example.com\",\n \"scope\": \"user\",\n },\n }\n `);\n expect({\n oAuth2CodeCreateCalls: oAuth2Code.create.mock.calls,\n oAuth2CodeCheckCalls: oAuth2Code.check.mock.calls,\n checkApplicationCalls: checkApplication.mock.calls,\n logCalls: log.mock.calls,\n }).to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Q,EAAE,sCADZ;MAEEP,WAAW,EAAE,qCAFf;MAGEG,KAAK,EAAE;IAHT,CALI,EAUJ,EAVI,CAAN,CADF;IAaA,MAAMQ,mBAAmB,GACvB,iCAAMd,iBAAiB,CAACe,aAAxB,2DAAM,uBAAiCC,YAAjC,CACJ;MACEN,QAAQ,EAAE,sCADZ;MAEEP,WAAW,EAAE,qCAFf;MAGEc,IAAI,EAAE;IAHR,CADI,EAMJ;MACEZ,aAAa,EAAE,sCADjB;MAEEC,KAAK,EAAE;IAFT,CANI,CAAN,CADF;IAaAY,MAAM,CAAC;MACLX,gBADK;MAELI,kBAFK;MAGLG;IAHK,CAAD,CAAN,CAIGK,qBAJH,CAI0B;AAC9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAtBI;IAuBAD,MAAM,CAAC;MACLE,qBAAqB,EAAE9B,UAAU,CAACC,MAAX,CAAkB8B,IAAlB,CAAuBC,KADzC;MAELC,oBAAoB,EAAEjC,UAAU,CAACI,KAAX,CAAiB2B,IAAjB,CAAsBC,KAFvC;MAGLE,qBAAqB,EAAE7B,gBAAgB,CAAC0B,IAAjB,CAAsBC,KAHxC;MAILG,QAAQ,EAAE7B,GAAG,CAACyB,IAAJ,CAASC;IAJd,CAAD,CAAN,CAKGI,eALH;EAMD,CA5EC,CAAF;AA6ED,CA5FO,CAAR"}
|
|
@@ -13,6 +13,8 @@ describe('OAuth2CodeGranter', () => {
|
|
|
13
13
|
log.mockReset();
|
|
14
14
|
});
|
|
15
15
|
it('should work with a complete valid flow', async () => {
|
|
16
|
+
var _oAuth2CodeGranter$au, _oAuth2CodeGranter$ac, _oAuth2CodeGranter$au2;
|
|
17
|
+
|
|
16
18
|
const oAuth2CodeGranter = await initOAuth2CodeGranter({
|
|
17
19
|
checkApplication,
|
|
18
20
|
oAuth2Code,
|
|
@@ -26,27 +28,27 @@ describe('OAuth2CodeGranter', () => {
|
|
|
26
28
|
applicationId: 'abbacaca-abba-caca-abba-cacaabbacaca',
|
|
27
29
|
scope: 'user'
|
|
28
30
|
});
|
|
29
|
-
const authorizerResult = await oAuth2CodeGranter.authorizer.authorize({
|
|
31
|
+
const authorizerResult = await ((_oAuth2CodeGranter$au = oAuth2CodeGranter.authorizer) === null || _oAuth2CodeGranter$au === void 0 ? void 0 : _oAuth2CodeGranter$au.authorize({
|
|
30
32
|
clientId: 'abbacaca-abba-caca-abba-cacaabbacaca',
|
|
31
33
|
redirectURI: 'https://www.example.com/oauth2/code',
|
|
32
34
|
scope: 'user'
|
|
33
|
-
});
|
|
34
|
-
const acknowledgerResult = await oAuth2CodeGranter.acknowledger.acknowledge({
|
|
35
|
+
}));
|
|
36
|
+
const acknowledgerResult = await ((_oAuth2CodeGranter$ac = oAuth2CodeGranter.acknowledger) === null || _oAuth2CodeGranter$ac === void 0 ? void 0 : _oAuth2CodeGranter$ac.acknowledge({
|
|
35
37
|
applicationId: 'abbacaca-abba-caca-abba-cacaabbacaca',
|
|
36
38
|
scope: 'user, admin'
|
|
37
39
|
}, {
|
|
38
40
|
clientId: 'abbacaca-abba-caca-abba-cacaabbacaca',
|
|
39
41
|
redirectURI: 'https://www.example.com/oauth2/code',
|
|
40
42
|
scope: 'user'
|
|
41
|
-
}, {});
|
|
42
|
-
const authenticatorResult = await oAuth2CodeGranter.authenticator.authenticate({
|
|
43
|
+
}, {}));
|
|
44
|
+
const authenticatorResult = await ((_oAuth2CodeGranter$au2 = oAuth2CodeGranter.authenticator) === null || _oAuth2CodeGranter$au2 === void 0 ? void 0 : _oAuth2CodeGranter$au2.authenticate({
|
|
43
45
|
clientId: 'abbacaca-abba-caca-abba-cacaabbacaca',
|
|
44
46
|
redirectURI: 'https://www.example.com/oauth2/code',
|
|
45
47
|
code: 'yolo'
|
|
46
48
|
}, {
|
|
47
49
|
applicationId: 'abbacaca-abba-caca-abba-cacaabbacaca',
|
|
48
50
|
scope: 'user'
|
|
49
|
-
});
|
|
51
|
+
}));
|
|
50
52
|
expect({
|
|
51
53
|
authorizerResult,
|
|
52
54
|
acknowledgerResult,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"oAuth2CodeGranter.test.mjs","names":["initOAuth2CodeGranter","describe","oAuth2Code","create","jest","fn","check","checkApplication","log","beforeEach","mockReset","it","oAuth2CodeGranter","mockResolvedValue","redirectURI","mockResolvedValueOnce","applicationId","scope","authorizerResult","authorizer","authorize","clientId","acknowledgerResult","acknowledger","acknowledge","authenticatorResult","authenticator","authenticate","code","expect","toMatchInlineSnapshot","oAuth2CodeCreateCalls","mock","calls","oAuth2CodeCheckCalls","checkApplicationCalls","logCalls","toMatchSnapshot"],"sources":["../../src/services/oAuth2CodeGranter.test.ts"],"sourcesContent":["import initOAuth2CodeGranter from './oAuth2CodeGranter';\n\ndescribe('OAuth2CodeGranter', () => {\n const oAuth2Code = {\n create: jest.fn(),\n check: jest.fn(),\n };\n const checkApplication = jest.fn();\n const log = jest.fn();\n\n beforeEach(() => {\n oAuth2Code.create.mockReset();\n oAuth2Code.check.mockReset();\n checkApplication.mockReset();\n log.mockReset();\n });\n\n it('should work with a complete valid flow', async () => {\n const oAuth2CodeGranter = await initOAuth2CodeGranter({\n checkApplication,\n oAuth2Code,\n log,\n });\n\n checkApplication.mockResolvedValue({\n redirectURI: 'https://www.example.com',\n });\n oAuth2Code.create.mockResolvedValueOnce('yolo');\n oAuth2Code.check.mockResolvedValueOnce({\n applicationId: 'abbacaca-abba-caca-abba-cacaabbacaca',\n scope: 'user',\n });\n\n const authorizerResult = await oAuth2CodeGranter.authorizer?.authorize({\n clientId: 'abbacaca-abba-caca-abba-cacaabbacaca',\n redirectURI: 'https://www.example.com/oauth2/code',\n scope: 'user',\n });\n const acknowledgerResult =\n await oAuth2CodeGranter.acknowledger?.acknowledge(\n {\n applicationId: 'abbacaca-abba-caca-abba-cacaabbacaca',\n scope: 'user, admin',\n },\n {\n clientId: 'abbacaca-abba-caca-abba-cacaabbacaca',\n redirectURI: 'https://www.example.com/oauth2/code',\n scope: 'user',\n },\n {},\n );\n const authenticatorResult =\n await oAuth2CodeGranter.authenticator?.authenticate(\n {\n clientId: 'abbacaca-abba-caca-abba-cacaabbacaca',\n redirectURI: 'https://www.example.com/oauth2/code',\n code: 'yolo',\n },\n {\n applicationId: 'abbacaca-abba-caca-abba-cacaabbacaca',\n scope: 'user',\n },\n );\n\n expect({\n authorizerResult,\n acknowledgerResult,\n authenticatorResult,\n }).toMatchInlineSnapshot(`\n Object {\n \"acknowledgerResult\": Object {\n \"applicationId\": \"abbacaca-abba-caca-abba-cacaabbacaca\",\n \"code\": \"yolo\",\n \"redirectURI\": \"https://www.example.com/oauth2/code\",\n \"scope\": \"user\",\n },\n \"authenticatorResult\": Object {\n \"applicationId\": \"abbacaca-abba-caca-abba-cacaabbacaca\",\n \"scope\": \"user\",\n },\n \"authorizerResult\": Object {\n \"applicationId\": \"abbacaca-abba-caca-abba-cacaabbacaca\",\n \"redirectURI\": \"https://www.example.com\",\n \"scope\": \"user\",\n },\n }\n `);\n expect({\n oAuth2CodeCreateCalls: oAuth2Code.create.mock.calls,\n oAuth2CodeCheckCalls: oAuth2Code.check.mock.calls,\n checkApplicationCalls: checkApplication.mock.calls,\n logCalls: log.mock.calls,\n }).toMatchSnapshot();\n });\n});\n"],"mappings":"AAAA,OAAOA,qBAAP,MAAkC,qBAAlC;AAEAC,QAAQ,CAAC,mBAAD,EAAsB,MAAM;EAClC,MAAMC,UAAU,GAAG;IACjBC,MAAM,EAAEC,IAAI,CAACC,EAAL,EADS;IAEjBC,KAAK,EAAEF,IAAI,CAACC,EAAL;EAFU,CAAnB;EAIA,MAAME,gBAAgB,GAAGH,IAAI,CAACC,EAAL,EAAzB;EACA,MAAMG,GAAG,GAAGJ,IAAI,CAACC,EAAL,EAAZ;EAEAI,UAAU,CAAC,MAAM;IACfP,UAAU,CAACC,MAAX,CAAkBO,SAAlB;IACAR,UAAU,CAACI,KAAX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AAD,CAAN,CAIGK,qBAJH,CAI0B;AAC9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAtBI;IAuBAD,MAAM,CAAC;MACLE,qBAAqB,EAAE7B,UAAU,CAACC,MAAX,CAAkB6B,IAAlB,CAAuBC,KADzC;MAELC,oBAAoB,EAAEhC,UAAU,CAACI,KAAX,CAAiB0B,IAAjB,CAAsBC,KAFvC;MAGLE,qBAAqB,EAAE5B,gBAAgB,CAACyB,IAAjB,CAAsBC,KAHxC;MAILG,QAAQ,EAAE5B,GAAG,CAACwB,IAAJ,CAASC;IAJd,CAAD,CAAN,CAKGI,eALH;EAMD,CA5EC,CAAF;AA6ED,CA5FO,CAAR"}
|
|
@@ -37,34 +37,37 @@ export declare type CheckApplicationService = {
|
|
|
37
37
|
redirectURI: string;
|
|
38
38
|
}>;
|
|
39
39
|
};
|
|
40
|
+
export declare type OAuth2GranterAuthorize<AUTHORIZE_PARAMETERS extends Record<string, unknown> = Record<string, unknown>, AUTHENTICATION_DATA extends BaseAuthenticationData = BaseAuthenticationData> = (context: {
|
|
41
|
+
clientId: AUTHENTICATION_DATA['applicationId'];
|
|
42
|
+
redirectURI: string;
|
|
43
|
+
scope: AUTHENTICATION_DATA['scope'];
|
|
44
|
+
}, authorizeParameters?: AUTHORIZE_PARAMETERS) => Promise<{
|
|
45
|
+
applicationId: AUTHENTICATION_DATA['applicationId'];
|
|
46
|
+
redirectURI: string;
|
|
47
|
+
scope: AUTHENTICATION_DATA['scope'];
|
|
48
|
+
}>;
|
|
49
|
+
export declare type Oauth2GranterAuthenticate<GRANT_PARAMETERS extends Record<string, unknown> = Record<string, unknown>, AUTHENTICATION_DATA extends BaseAuthenticationData = BaseAuthenticationData> = (grantParameters: GRANT_PARAMETERS, authenticationData: AUTHENTICATION_DATA) => Promise<AUTHENTICATION_DATA>;
|
|
50
|
+
export declare type OAuth2GranterAcknowledge<ACKNOWLEDGE_PARAMETERS extends Record<string, unknown> = Record<string, unknown>, AUTHENTICATION_DATA extends BaseAuthenticationData = BaseAuthenticationData> = (authenticationData: AUTHENTICATION_DATA, acknowledgeParameters: {
|
|
51
|
+
clientId: AUTHENTICATION_DATA['applicationId'];
|
|
52
|
+
redirectURI: string;
|
|
53
|
+
scope: AUTHENTICATION_DATA['applicationId'];
|
|
54
|
+
}, additionalParameters: ACKNOWLEDGE_PARAMETERS) => Promise<AUTHENTICATION_DATA & {
|
|
55
|
+
redirectURI: string;
|
|
56
|
+
[name: string]: unknown;
|
|
57
|
+
}>;
|
|
40
58
|
export declare type OAuth2GranterService<AUTHORIZE_PARAMETERS extends Record<string, unknown> = Record<string, unknown>, ACKNOWLEDGE_PARAMETERS extends Record<string, unknown> = Record<string, unknown>, GRANT_PARAMETERS extends Record<string, unknown> = Record<string, unknown>, AUTHENTICATION_DATA extends BaseAuthenticationData = BaseAuthenticationData> = {
|
|
41
59
|
type: string;
|
|
42
60
|
authorizer?: {
|
|
43
61
|
responseType: string;
|
|
44
|
-
authorize:
|
|
45
|
-
clientId: AUTHENTICATION_DATA['applicationId'];
|
|
46
|
-
redirectURI: string;
|
|
47
|
-
scope: AUTHENTICATION_DATA['scope'];
|
|
48
|
-
}, authorizeParameters?: AUTHORIZE_PARAMETERS) => Promise<{
|
|
49
|
-
applicationId: AUTHENTICATION_DATA['applicationId'];
|
|
50
|
-
redirectURI: string;
|
|
51
|
-
scope: AUTHENTICATION_DATA['scope'];
|
|
52
|
-
}>;
|
|
62
|
+
authorize: OAuth2GranterAuthorize<AUTHORIZE_PARAMETERS, AUTHENTICATION_DATA>;
|
|
53
63
|
};
|
|
54
64
|
acknowledger?: {
|
|
55
65
|
acknowledgmentType: string;
|
|
56
|
-
acknowledge:
|
|
57
|
-
clientId: AUTHENTICATION_DATA['applicationId'];
|
|
58
|
-
redirectURI: string;
|
|
59
|
-
scope: AUTHENTICATION_DATA['applicationId'];
|
|
60
|
-
}, additionalParameters: ACKNOWLEDGE_PARAMETERS) => Promise<AUTHENTICATION_DATA & {
|
|
61
|
-
redirectURI: string;
|
|
62
|
-
[name: string]: unknown;
|
|
63
|
-
}>;
|
|
66
|
+
acknowledge: OAuth2GranterAcknowledge<ACKNOWLEDGE_PARAMETERS, AUTHENTICATION_DATA>;
|
|
64
67
|
};
|
|
65
68
|
authenticator?: {
|
|
66
69
|
grantType: string;
|
|
67
|
-
authenticate:
|
|
70
|
+
authenticate: Oauth2GranterAuthenticate<GRANT_PARAMETERS, AUTHENTICATION_DATA>;
|
|
68
71
|
};
|
|
69
72
|
};
|
|
70
73
|
export declare type OAuth2Options = {
|
|
@@ -75,5 +78,5 @@ export declare type OAuth2Config = {
|
|
|
75
78
|
OAUTH2: OAuth2Options;
|
|
76
79
|
ERRORS_DESCRIPTORS: WhookErrorsDescriptors;
|
|
77
80
|
};
|
|
78
|
-
declare const _default: import("knifecycle").ServiceInitializer<
|
|
81
|
+
declare const _default: import("knifecycle").ServiceInitializer<any, any[]>;
|
|
79
82
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/services/oAuth2Granters.ts"],"names":["OAUTH2_ERRORS_DESCRIPTORS","E_UNKNOWN_AUTHORIZER_TYPE","code","status","description","uri","DEFAULT_ERROR_URI","help","DEFAULT_HELP_URI","E_UNKNOWN_APPLICATION_ID","E_UNAUTHORIZED_APPLICATION_ID","E_APPLICATION_DISABLED","E_BAD_REDIRECT_URI","E_UNAUTHORIZED_SCOPE","E_UNAUTHORIZED_GRANT_TYPE","E_UNAUTHORIZED_CLIENT","E_BAD_USERNAME","E_BAD_PASSWORD","E_BAD_REFRESH_TOKEN","E_BAD_AUTHORIZATION_CODE","E_UNKNOWN_ACKNOWLEDGOR_TYPE","E_ACCESS_DENIED","E_UNKNOWN_AUTHENTICATION_TYPE","E_OAUTH2","E_REFRESH_COOKIE","name","type","inject","singleton","services","Object","keys","map","key"],"mappings":";;;;;;;AAAA;;AACA;;AAIO,MAAMA,yBAA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AS,EAAE;AAVb,CADa,EAab,MAAOC,QAAP,IAAoBC,MAAM,CAACC,IAAP,CAAYF,QAAZ,EAAsBG,GAAtB,CAA2BC,GAAD,IAASJ,QAAQ,CAACI,GAAD,CAA3C,CAbP,C","sourcesContent":["import { initializer } from 'knifecycle';\nimport { DEFAULT_ERROR_URI, DEFAULT_HELP_URI } from '@whook/whook';\nimport type { WhookErrorsDescriptors } from '@whook/whook';\nimport type { BaseAuthenticationData } from '@whook/authorization';\n\nexport const OAUTH2_ERRORS_DESCRIPTORS: WhookErrorsDescriptors = {\n E_UNKNOWN_AUTHORIZER_TYPE: {\n code: 'unsupported_response_type',\n status: 400,\n description: `The type \"$0\" is not supported.`,\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_UNKNOWN_APPLICATION_ID: {\n code: 'unauthorized_client',\n status: 400,\n description: `The client id \"$0\" is unknown.`,\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_UNAUTHORIZED_APPLICATION_ID: {\n code: 'unauthorized_client',\n status: 401,\n description: `The client id \"$0\" is not allowed.`,\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_APPLICATION_DISABLED: {\n code: 'unauthorized_client',\n status: 401,\n description: `The client id \"$0\" is disabled.`,\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_BAD_REDIRECT_URI: {\n code: 'invalid_request',\n status: 400,\n description: `The redirect uri \"$0\" is not allowed.`,\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_UNAUTHORIZED_SCOPE: {\n code: 'invalid_scope',\n status: 403,\n description: `The scope \"$0\" is not allowed.`,\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_UNAUTHORIZED_GRANT_TYPE: {\n code: 'invalid_request',\n status: 403,\n description: `The response type \"$0\" is not allowed for this application.`,\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_UNAUTHORIZED_CLIENT: {\n code: 'invalid_client',\n status: 401,\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_BAD_USERNAME: {\n code: 'invalid_request',\n status: 400,\n description: 'User does not exists.',\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_BAD_PASSWORD: {\n code: 'invalid_request',\n status: 400,\n description: 'Bad password sent for that user.',\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_BAD_REFRESH_TOKEN: {\n code: 'invalid_request',\n status: 400,\n description: 'The refresh token is expired/invalid.',\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_BAD_AUTHORIZATION_CODE: {\n code: 'invalid_request',\n status: 400,\n description: 'The authorization code is invalid or expired.',\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_UNKNOWN_ACKNOWLEDGOR_TYPE: {\n code: 'unsupported_response_type',\n status: 400,\n description: `Type \"$0\" not supported.`,\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_ACCESS_DENIED: {\n code: 'access_denied',\n status: 403,\n description: 'The user denied access to your application.',\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_UNKNOWN_AUTHENTICATION_TYPE: {\n code: 'unsupported_grant_type',\n status: 400,\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_OAUTH2: {\n code: 'server_error',\n status: 500,\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_REFRESH_COOKIE: {\n code: 'invalid_request',\n status: 400,\n description: `Could not find any refresh_token value in the cookie header ($0).`,\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n};\n\nexport type OAuth2CodeService<\n AUTHENTICATION_DATA extends BaseAuthenticationData = BaseAuthenticationData,\n CODE = string,\n> = {\n create: (\n authenticationData: AUTHENTICATION_DATA,\n redirectURI: string,\n additionalParameters: { [name: string]: unknown },\n ) => Promise<CODE>;\n check: (\n authenticationData: AUTHENTICATION_DATA,\n code: CODE,\n redirectURI: string,\n ) => Promise<\n AUTHENTICATION_DATA & {\n redirectURI: string;\n } & { [name: string]: unknown }\n >;\n};\n\nexport type OAuth2PasswordService<\n AUTHENTICATION_DATA extends BaseAuthenticationData = BaseAuthenticationData,\n USERNAME = string,\n PASSWORD = string,\n> = {\n check: (\n authenticationData: AUTHENTICATION_DATA,\n username: USERNAME,\n password: PASSWORD,\n demandedScope: AUTHENTICATION_DATA['scope'],\n ) => Promise<AUTHENTICATION_DATA>;\n};\n\nexport type OAuth2AccessTokenService<\n AUTHENTICATION_DATA extends BaseAuthenticationData = BaseAuthenticationData,\n TOKEN = string,\n> = {\n create: (\n authenticationData: AUTHENTICATION_DATA,\n tokenAuthenticationData: AUTHENTICATION_DATA,\n additionalParameters?: { [name: string]: unknown },\n ) => Promise<{\n token: TOKEN;\n expiresAt: number;\n }>;\n check: (\n authenticationData: AUTHENTICATION_DATA,\n token: TOKEN,\n scope?: AUTHENTICATION_DATA['scope'],\n ) => Promise<AUTHENTICATION_DATA>;\n};\n\nexport type OAuth2RefreshTokenService<\n AUTHENTICATION_DATA extends BaseAuthenticationData = BaseAuthenticationData,\n TOKEN = string,\n> = OAuth2AccessTokenService<AUTHENTICATION_DATA, TOKEN>;\n\nexport type CheckApplicationService = {\n (context: {\n applicationId: string;\n type: string;\n scope: string;\n redirectURI?: string;\n }): Promise<{\n applicationId: string;\n type: string;\n scope: string;\n redirectURI: string;\n }>;\n};\n\nexport type OAuth2GranterService<\n AUTHORIZE_PARAMETERS extends Record<string, unknown> = Record<\n string,\n unknown\n >,\n ACKNOWLEDGE_PARAMETERS extends Record<string, unknown> = Record<\n string,\n unknown\n >,\n GRANT_PARAMETERS extends Record<string, unknown> = Record<string, unknown>,\n AUTHENTICATION_DATA extends BaseAuthenticationData = BaseAuthenticationData,\n> = {\n type: string;\n authorizer?: {\n responseType: string;\n authorize: (\n context: {\n clientId: AUTHENTICATION_DATA['applicationId'];\n redirectURI: string;\n scope: AUTHENTICATION_DATA['scope'];\n },\n authorizeParameters?: AUTHORIZE_PARAMETERS,\n ) => Promise<{\n applicationId: AUTHENTICATION_DATA['applicationId'];\n redirectURI: string;\n scope: AUTHENTICATION_DATA['scope'];\n }>;\n };\n acknowledger?: {\n acknowledgmentType: string;\n acknowledge: (\n authenticationData: AUTHENTICATION_DATA,\n acknowledgeParameters: {\n clientId: AUTHENTICATION_DATA['applicationId'];\n redirectURI: string;\n scope: AUTHENTICATION_DATA['applicationId'];\n },\n additionalParameters: ACKNOWLEDGE_PARAMETERS,\n ) => Promise<\n AUTHENTICATION_DATA & {\n redirectURI: string;\n [name: string]: unknown;\n }\n >;\n };\n authenticator?: {\n grantType: string;\n authenticate: (\n grantParameters: GRANT_PARAMETERS,\n authenticationData: AUTHENTICATION_DATA,\n ) => Promise<AUTHENTICATION_DATA>;\n };\n};\n\nexport type OAuth2Options = {\n authenticateURL: string;\n defaultToClientScope?: boolean;\n};\n\nexport type OAuth2Config = {\n OAUTH2: OAuth2Options;\n ERRORS_DESCRIPTORS: WhookErrorsDescriptors;\n};\n\nexport default initializer(\n {\n name: 'oAuth2Granters',\n type: 'service',\n inject: [\n 'oAuth2ClientCredentialsGranter',\n 'oAuth2CodeGranter',\n 'oAuth2PasswordGranter',\n 'oAuth2RefreshTokenGranter',\n 'oAuth2TokenGranter',\n ],\n singleton: true,\n },\n async (services) => Object.keys(services).map((key) => services[key]),\n);\n"],"file":"oAuth2Granters.js"}
|
|
1
|
+
{"version":3,"file":"oAuth2Granters.js","names":["OAUTH2_ERRORS_DESCRIPTORS","E_UNKNOWN_AUTHORIZER_TYPE","code","status","description","uri","DEFAULT_ERROR_URI","help","DEFAULT_HELP_URI","E_UNKNOWN_APPLICATION_ID","E_UNAUTHORIZED_APPLICATION_ID","E_APPLICATION_DISABLED","E_BAD_REDIRECT_URI","E_UNAUTHORIZED_SCOPE","E_UNAUTHORIZED_GRANT_TYPE","E_UNAUTHORIZED_CLIENT","E_BAD_USERNAME","E_BAD_PASSWORD","E_BAD_REFRESH_TOKEN","E_BAD_AUTHORIZATION_CODE","E_UNKNOWN_ACKNOWLEDGOR_TYPE","E_ACCESS_DENIED","E_UNKNOWN_AUTHENTICATION_TYPE","E_OAUTH2","E_REFRESH_COOKIE","initializer","name","type","inject","singleton","services","Object","keys","map","key"],"sources":["../../src/services/oAuth2Granters.ts"],"sourcesContent":["import { initializer } from 'knifecycle';\nimport { DEFAULT_ERROR_URI, DEFAULT_HELP_URI } from '@whook/whook';\nimport type { WhookErrorsDescriptors } from '@whook/whook';\nimport type { BaseAuthenticationData } from '@whook/authorization';\n\nexport const OAUTH2_ERRORS_DESCRIPTORS: WhookErrorsDescriptors = {\n E_UNKNOWN_AUTHORIZER_TYPE: {\n code: 'unsupported_response_type',\n status: 400,\n description: `The type \"$0\" is not supported.`,\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_UNKNOWN_APPLICATION_ID: {\n code: 'unauthorized_client',\n status: 400,\n description: `The client id \"$0\" is unknown.`,\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_UNAUTHORIZED_APPLICATION_ID: {\n code: 'unauthorized_client',\n status: 401,\n description: `The client id \"$0\" is not allowed.`,\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_APPLICATION_DISABLED: {\n code: 'unauthorized_client',\n status: 401,\n description: `The client id \"$0\" is disabled.`,\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_BAD_REDIRECT_URI: {\n code: 'invalid_request',\n status: 400,\n description: `The redirect uri \"$0\" is not allowed.`,\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_UNAUTHORIZED_SCOPE: {\n code: 'invalid_scope',\n status: 403,\n description: `The scope \"$0\" is not allowed.`,\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_UNAUTHORIZED_GRANT_TYPE: {\n code: 'invalid_request',\n status: 403,\n description: `The response type \"$0\" is not allowed for this application.`,\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_UNAUTHORIZED_CLIENT: {\n code: 'invalid_client',\n status: 401,\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_BAD_USERNAME: {\n code: 'invalid_request',\n status: 400,\n description: 'User does not exists.',\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_BAD_PASSWORD: {\n code: 'invalid_request',\n status: 400,\n description: 'Bad password sent for that user.',\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_BAD_REFRESH_TOKEN: {\n code: 'invalid_request',\n status: 400,\n description: 'The refresh token is expired/invalid.',\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_BAD_AUTHORIZATION_CODE: {\n code: 'invalid_request',\n status: 400,\n description: 'The authorization code is invalid or expired.',\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_UNKNOWN_ACKNOWLEDGOR_TYPE: {\n code: 'unsupported_response_type',\n status: 400,\n description: `Type \"$0\" not supported.`,\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_ACCESS_DENIED: {\n code: 'access_denied',\n status: 403,\n description: 'The user denied access to your application.',\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_UNKNOWN_AUTHENTICATION_TYPE: {\n code: 'unsupported_grant_type',\n status: 400,\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_OAUTH2: {\n code: 'server_error',\n status: 500,\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_REFRESH_COOKIE: {\n code: 'invalid_request',\n status: 400,\n description: `Could not find any refresh_token value in the cookie header ($0).`,\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n};\n\nexport type OAuth2CodeService<\n AUTHENTICATION_DATA extends BaseAuthenticationData = BaseAuthenticationData,\n CODE = string,\n> = {\n create: (\n authenticationData: AUTHENTICATION_DATA,\n redirectURI: string,\n additionalParameters: { [name: string]: unknown },\n ) => Promise<CODE>;\n check: (\n authenticationData: AUTHENTICATION_DATA,\n code: CODE,\n redirectURI: string,\n ) => Promise<\n AUTHENTICATION_DATA & {\n redirectURI: string;\n } & { [name: string]: unknown }\n >;\n};\n\nexport type OAuth2PasswordService<\n AUTHENTICATION_DATA extends BaseAuthenticationData = BaseAuthenticationData,\n USERNAME = string,\n PASSWORD = string,\n> = {\n check: (\n authenticationData: AUTHENTICATION_DATA,\n username: USERNAME,\n password: PASSWORD,\n demandedScope: AUTHENTICATION_DATA['scope'],\n ) => Promise<AUTHENTICATION_DATA>;\n};\n\nexport type OAuth2AccessTokenService<\n AUTHENTICATION_DATA extends BaseAuthenticationData = BaseAuthenticationData,\n TOKEN = string,\n> = {\n create: (\n authenticationData: AUTHENTICATION_DATA,\n tokenAuthenticationData: AUTHENTICATION_DATA,\n additionalParameters?: { [name: string]: unknown },\n ) => Promise<{\n token: TOKEN;\n expiresAt: number;\n }>;\n check: (\n authenticationData: AUTHENTICATION_DATA,\n token: TOKEN,\n scope?: AUTHENTICATION_DATA['scope'],\n ) => Promise<AUTHENTICATION_DATA>;\n};\n\nexport type OAuth2RefreshTokenService<\n AUTHENTICATION_DATA extends BaseAuthenticationData = BaseAuthenticationData,\n TOKEN = string,\n> = OAuth2AccessTokenService<AUTHENTICATION_DATA, TOKEN>;\n\nexport type CheckApplicationService = {\n (context: {\n applicationId: string;\n type: string;\n scope: string;\n redirectURI?: string;\n }): Promise<{\n applicationId: string;\n type: string;\n scope: string;\n redirectURI: string;\n }>;\n};\n\nexport type OAuth2GranterAuthorize<\n AUTHORIZE_PARAMETERS extends Record<string, unknown> = Record<\n string,\n unknown\n >,\n AUTHENTICATION_DATA extends BaseAuthenticationData = BaseAuthenticationData,\n> = (\n context: {\n clientId: AUTHENTICATION_DATA['applicationId'];\n redirectURI: string;\n scope: AUTHENTICATION_DATA['scope'];\n },\n authorizeParameters?: AUTHORIZE_PARAMETERS,\n) => Promise<{\n applicationId: AUTHENTICATION_DATA['applicationId'];\n redirectURI: string;\n scope: AUTHENTICATION_DATA['scope'];\n}>;\n\nexport type Oauth2GranterAuthenticate<\n GRANT_PARAMETERS extends Record<string, unknown> = Record<string, unknown>,\n AUTHENTICATION_DATA extends BaseAuthenticationData = BaseAuthenticationData,\n> = (\n grantParameters: GRANT_PARAMETERS,\n authenticationData: AUTHENTICATION_DATA,\n) => Promise<AUTHENTICATION_DATA>;\n\nexport type OAuth2GranterAcknowledge<\n ACKNOWLEDGE_PARAMETERS extends Record<string, unknown> = Record<\n string,\n unknown\n >,\n AUTHENTICATION_DATA extends BaseAuthenticationData = BaseAuthenticationData,\n> = (\n authenticationData: AUTHENTICATION_DATA,\n acknowledgeParameters: {\n clientId: AUTHENTICATION_DATA['applicationId'];\n redirectURI: string;\n scope: AUTHENTICATION_DATA['applicationId'];\n },\n additionalParameters: ACKNOWLEDGE_PARAMETERS,\n) => Promise<\n AUTHENTICATION_DATA & {\n redirectURI: string;\n [name: string]: unknown;\n }\n>;\n\nexport type OAuth2GranterService<\n AUTHORIZE_PARAMETERS extends Record<string, unknown> = Record<\n string,\n unknown\n >,\n ACKNOWLEDGE_PARAMETERS extends Record<string, unknown> = Record<\n string,\n unknown\n >,\n GRANT_PARAMETERS extends Record<string, unknown> = Record<string, unknown>,\n AUTHENTICATION_DATA extends BaseAuthenticationData = BaseAuthenticationData,\n> = {\n type: string;\n authorizer?: {\n responseType: string;\n authorize: OAuth2GranterAuthorize<\n AUTHORIZE_PARAMETERS,\n AUTHENTICATION_DATA\n >;\n };\n acknowledger?: {\n acknowledgmentType: string;\n acknowledge: OAuth2GranterAcknowledge<\n ACKNOWLEDGE_PARAMETERS,\n AUTHENTICATION_DATA\n >;\n };\n authenticator?: {\n grantType: string;\n authenticate: Oauth2GranterAuthenticate<\n GRANT_PARAMETERS,\n AUTHENTICATION_DATA\n >;\n };\n};\n\nexport type OAuth2Options = {\n authenticateURL: string;\n defaultToClientScope?: boolean;\n};\n\nexport type OAuth2Config = {\n OAUTH2: OAuth2Options;\n ERRORS_DESCRIPTORS: WhookErrorsDescriptors;\n};\n\nexport default initializer(\n {\n name: 'oAuth2Granters',\n type: 'service',\n inject: [\n 'oAuth2ClientCredentialsGranter',\n 'oAuth2CodeGranter',\n 'oAuth2PasswordGranter',\n 'oAuth2RefreshTokenGranter',\n 'oAuth2TokenGranter',\n ],\n singleton: true,\n },\n async (services) => Object.keys(services).map((key) => services[key]),\n);\n"],"mappings":";;;;;;;AAAA;;AACA;;AAIO,MAAMA,yBAAiD,GAAG;EAC/DC,yBAAyB,EAAE;IACzBC,IAAI,EAAE,2BADmB;IAEzBC,MAAM,EAAE,GAFiB;IAGzBC,WAAW,EAAG,iCAHW;IAIzBC,GAAG,EAAEC,wBAJoB;IAKzBC,IAAI,EAAEC;EALmB,CADoC;EAQ/DC,wBAAwB,EAAE;IACxBP,IAAI,EAAE,qBADkB;IAExBC,MAAM,EAAE,GAFgB;IAGxBC,WAAW,EAAG,gCAHU;IAIxBC,GAAG,EAAEC,wBAJmB;IAKxBC,IAAI,EAAEC;EALkB,CARqC;EAe/DE,6BAA6B,EAAE;IAC7BR,IAAI,EAAE,qBADuB;IAE7BC,MAAM,EAAE,GAFqB;IAG7BC,WAAW,EAAG,oCAHe;IAI7BC,GAAG,EAAEC,wBAJwB;IAK7BC,IAAI,EAAEC;EALuB,CAfgC;EAsB/DG,sBAAsB,EAAE;IACtBT,IAAI,EAAE,qBADgB;IAEtBC,MAAM,EAAE,GAFc;IAGtBC,WAAW,EAAG,iCAHQ;IAItBC,GAAG,EAAEC,wBAJiB;IAKtBC,IAAI,EAA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 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/services/oAuth2Granters.ts"],"names":["initializer","DEFAULT_ERROR_URI","DEFAULT_HELP_URI","OAUTH2_ERRORS_DESCRIPTORS","E_UNKNOWN_AUTHORIZER_TYPE","code","status","description","uri","help","E_UNKNOWN_APPLICATION_ID","E_UNAUTHORIZED_APPLICATION_ID","E_APPLICATION_DISABLED","E_BAD_REDIRECT_URI","E_UNAUTHORIZED_SCOPE","E_UNAUTHORIZED_GRANT_TYPE","E_UNAUTHORIZED_CLIENT","E_BAD_USERNAME","E_BAD_PASSWORD","E_BAD_REFRESH_TOKEN","E_BAD_AUTHORIZATION_CODE","E_UNKNOWN_ACKNOWLEDGOR_TYPE","E_ACCESS_DENIED","E_UNKNOWN_AUTHENTICATION_TYPE","E_OAUTH2","E_REFRESH_COOKIE","name","type","inject","singleton","services","Object","keys","map","key"],"mappings":"AAAA,SAASA,WAAT,QAA4B,YAA5B;AACA,SAASC,iBAAT,EAA4BC,gBAA5B,QAAoD,cAApD;AAIA,OAAO,MAAMC,yBAAiD,GAAG;AAC/DC,EAAAA,yBAAyB,EAAE;AACzBC,IAAAA,IAAI,EAAE,2BADmB;AAEzBC,IAAAA,MAAM,EAAE,GAFiB;AAGzBC,IAAAA,WAAW,EAAG,iCAHW;AAIzBC,IAAAA,GAAG,EAAEP,iBAJoB;AAKzBQ,IAAAA,IAAI,EAAEP;AALmB,GADoC;AAQ/DQ,EAAAA,wBAAwB,EAAE;AACxBL,IAAAA,IAAI,EAAE,qBADkB;AAExBC,IAAAA,MAAM,EAAE,GAFgB;AAGxBC,IAAAA,WAAW,EAAG,gCAHU;AAIxBC,IAAAA,GAAG,EAAEP,iBAJmB;AAKxBQ,IAAAA,IAAI,EAAEP;AALkB,GARqC;AAe/DS,EAAAA,6BAA6B,EAAE;AAC7BN,IAAAA,IAAI,EAAE,qBADuB;AAE7BC,IAAAA,MAAM,EAAE,GAFqB;AAG7BC,IAAAA,WAAW,EAAG,oCAHe;AAI7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AE,GAFqB;AAG7BE,IAAAA,GAAG,EAAEP,iBAHwB;AAI7BQ,IAAAA,IAAI,EAAEP;AAJuB,GAlGgC;AAwG/DsB,EAAAA,QAAQ,EAAE;AACRnB,IAAAA,IAAI,EAAE,cADE;AAERC,IAAAA,MAAM,EAAE,GAFA;AAGRE,IAAAA,GAAG,EAAEP,iBAHG;AAIRQ,IAAAA,IAAI,EAAEP;AAJE,GAxGqD;AA8G/DuB,EAAAA,gBAAgB,EAAE;AAChBpB,IAAAA,IAAI,EAAE,iBADU;AAEhBC,IAAAA,MAAM,EAAE,GAFQ;AAGhBC,IAAAA,WAAW,EAAG,mEAHE;AAIhBC,IAAAA,GAAG,EAAEP,iBAJW;AAKhBQ,IAAAA,IAAI,EAAEP;AALU;AA9G6C,CAA1D;AA8PP,eAAeF,WAAW,CACxB;AACE0B,EAAAA,IAAI,EAAE,gBADR;AAEEC,EAAAA,IAAI,EAAE,SAFR;AAGEC,EAAAA,MAAM,EAAE,CACN,gCADM,EAEN,mBAFM,EAGN,uBAHM,EAIN,2BAJM,EAKN,oBALM,CAHV;AAUEC,EAAAA,SAAS,EAAE;AAVb,CADwB,EAaxB,MAAOC,QAAP,IAAoBC,MAAM,CAACC,IAAP,CAAYF,QAAZ,EAAsBG,GAAtB,CAA2BC,GAAD,IAASJ,QAAQ,CAACI,GAAD,CAA3C,CAbI,CAA1B","sourcesContent":["import { initializer } from 'knifecycle';\nimport { DEFAULT_ERROR_URI, DEFAULT_HELP_URI } from '@whook/whook';\nimport type { WhookErrorsDescriptors } from '@whook/whook';\nimport type { BaseAuthenticationData } from '@whook/authorization';\n\nexport const OAUTH2_ERRORS_DESCRIPTORS: WhookErrorsDescriptors = {\n E_UNKNOWN_AUTHORIZER_TYPE: {\n code: 'unsupported_response_type',\n status: 400,\n description: `The type \"$0\" is not supported.`,\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_UNKNOWN_APPLICATION_ID: {\n code: 'unauthorized_client',\n status: 400,\n description: `The client id \"$0\" is unknown.`,\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_UNAUTHORIZED_APPLICATION_ID: {\n code: 'unauthorized_client',\n status: 401,\n description: `The client id \"$0\" is not allowed.`,\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_APPLICATION_DISABLED: {\n code: 'unauthorized_client',\n status: 401,\n description: `The client id \"$0\" is disabled.`,\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_BAD_REDIRECT_URI: {\n code: 'invalid_request',\n status: 400,\n description: `The redirect uri \"$0\" is not allowed.`,\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_UNAUTHORIZED_SCOPE: {\n code: 'invalid_scope',\n status: 403,\n description: `The scope \"$0\" is not allowed.`,\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_UNAUTHORIZED_GRANT_TYPE: {\n code: 'invalid_request',\n status: 403,\n description: `The response type \"$0\" is not allowed for this application.`,\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_UNAUTHORIZED_CLIENT: {\n code: 'invalid_client',\n status: 401,\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_BAD_USERNAME: {\n code: 'invalid_request',\n status: 400,\n description: 'User does not exists.',\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_BAD_PASSWORD: {\n code: 'invalid_request',\n status: 400,\n description: 'Bad password sent for that user.',\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_BAD_REFRESH_TOKEN: {\n code: 'invalid_request',\n status: 400,\n description: 'The refresh token is expired/invalid.',\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_BAD_AUTHORIZATION_CODE: {\n code: 'invalid_request',\n status: 400,\n description: 'The authorization code is invalid or expired.',\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_UNKNOWN_ACKNOWLEDGOR_TYPE: {\n code: 'unsupported_response_type',\n status: 400,\n description: `Type \"$0\" not supported.`,\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_ACCESS_DENIED: {\n code: 'access_denied',\n status: 403,\n description: 'The user denied access to your application.',\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_UNKNOWN_AUTHENTICATION_TYPE: {\n code: 'unsupported_grant_type',\n status: 400,\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_OAUTH2: {\n code: 'server_error',\n status: 500,\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_REFRESH_COOKIE: {\n code: 'invalid_request',\n status: 400,\n description: `Could not find any refresh_token value in the cookie header ($0).`,\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n};\n\nexport type OAuth2CodeService<\n AUTHENTICATION_DATA extends BaseAuthenticationData = BaseAuthenticationData,\n CODE = string,\n> = {\n create: (\n authenticationData: AUTHENTICATION_DATA,\n redirectURI: string,\n additionalParameters: { [name: string]: unknown },\n ) => Promise<CODE>;\n check: (\n authenticationData: AUTHENTICATION_DATA,\n code: CODE,\n redirectURI: string,\n ) => Promise<\n AUTHENTICATION_DATA & {\n redirectURI: string;\n } & { [name: string]: unknown }\n >;\n};\n\nexport type OAuth2PasswordService<\n AUTHENTICATION_DATA extends BaseAuthenticationData = BaseAuthenticationData,\n USERNAME = string,\n PASSWORD = string,\n> = {\n check: (\n authenticationData: AUTHENTICATION_DATA,\n username: USERNAME,\n password: PASSWORD,\n demandedScope: AUTHENTICATION_DATA['scope'],\n ) => Promise<AUTHENTICATION_DATA>;\n};\n\nexport type OAuth2AccessTokenService<\n AUTHENTICATION_DATA extends BaseAuthenticationData = BaseAuthenticationData,\n TOKEN = string,\n> = {\n create: (\n authenticationData: AUTHENTICATION_DATA,\n tokenAuthenticationData: AUTHENTICATION_DATA,\n additionalParameters?: { [name: string]: unknown },\n ) => Promise<{\n token: TOKEN;\n expiresAt: number;\n }>;\n check: (\n authenticationData: AUTHENTICATION_DATA,\n token: TOKEN,\n scope?: AUTHENTICATION_DATA['scope'],\n ) => Promise<AUTHENTICATION_DATA>;\n};\n\nexport type OAuth2RefreshTokenService<\n AUTHENTICATION_DATA extends BaseAuthenticationData = BaseAuthenticationData,\n TOKEN = string,\n> = OAuth2AccessTokenService<AUTHENTICATION_DATA, TOKEN>;\n\nexport type CheckApplicationService = {\n (context: {\n applicationId: string;\n type: string;\n scope: string;\n redirectURI?: string;\n }): Promise<{\n applicationId: string;\n type: string;\n scope: string;\n redirectURI: string;\n }>;\n};\n\nexport type OAuth2GranterService<\n AUTHORIZE_PARAMETERS extends Record<string, unknown> = Record<\n string,\n unknown\n >,\n ACKNOWLEDGE_PARAMETERS extends Record<string, unknown> = Record<\n string,\n unknown\n >,\n GRANT_PARAMETERS extends Record<string, unknown> = Record<string, unknown>,\n AUTHENTICATION_DATA extends BaseAuthenticationData = BaseAuthenticationData,\n> = {\n type: string;\n authorizer?: {\n responseType: string;\n authorize: (\n context: {\n clientId: AUTHENTICATION_DATA['applicationId'];\n redirectURI: string;\n scope: AUTHENTICATION_DATA['scope'];\n },\n authorizeParameters?: AUTHORIZE_PARAMETERS,\n ) => Promise<{\n applicationId: AUTHENTICATION_DATA['applicationId'];\n redirectURI: string;\n scope: AUTHENTICATION_DATA['scope'];\n }>;\n };\n acknowledger?: {\n acknowledgmentType: string;\n acknowledge: (\n authenticationData: AUTHENTICATION_DATA,\n acknowledgeParameters: {\n clientId: AUTHENTICATION_DATA['applicationId'];\n redirectURI: string;\n scope: AUTHENTICATION_DATA['applicationId'];\n },\n additionalParameters: ACKNOWLEDGE_PARAMETERS,\n ) => Promise<\n AUTHENTICATION_DATA & {\n redirectURI: string;\n [name: string]: unknown;\n }\n >;\n };\n authenticator?: {\n grantType: string;\n authenticate: (\n grantParameters: GRANT_PARAMETERS,\n authenticationData: AUTHENTICATION_DATA,\n ) => Promise<AUTHENTICATION_DATA>;\n };\n};\n\nexport type OAuth2Options = {\n authenticateURL: string;\n defaultToClientScope?: boolean;\n};\n\nexport type OAuth2Config = {\n OAUTH2: OAuth2Options;\n ERRORS_DESCRIPTORS: WhookErrorsDescriptors;\n};\n\nexport default initializer(\n {\n name: 'oAuth2Granters',\n type: 'service',\n inject: [\n 'oAuth2ClientCredentialsGranter',\n 'oAuth2CodeGranter',\n 'oAuth2PasswordGranter',\n 'oAuth2RefreshTokenGranter',\n 'oAuth2TokenGranter',\n ],\n singleton: true,\n },\n async (services) => Object.keys(services).map((key) => services[key]),\n);\n"],"file":"oAuth2Granters.mjs"}
|
|
1
|
+
{"version":3,"file":"oAuth2Granters.mjs","names":["initializer","DEFAULT_ERROR_URI","DEFAULT_HELP_URI","OAUTH2_ERRORS_DESCRIPTORS","E_UNKNOWN_AUTHORIZER_TYPE","code","status","description","uri","help","E_UNKNOWN_APPLICATION_ID","E_UNAUTHORIZED_APPLICATION_ID","E_APPLICATION_DISABLED","E_BAD_REDIRECT_URI","E_UNAUTHORIZED_SCOPE","E_UNAUTHORIZED_GRANT_TYPE","E_UNAUTHORIZED_CLIENT","E_BAD_USERNAME","E_BAD_PASSWORD","E_BAD_REFRESH_TOKEN","E_BAD_AUTHORIZATION_CODE","E_UNKNOWN_ACKNOWLEDGOR_TYPE","E_ACCESS_DENIED","E_UNKNOWN_AUTHENTICATION_TYPE","E_OAUTH2","E_REFRESH_COOKIE","name","type","inject","singleton","services","Object","keys","map","key"],"sources":["../../src/services/oAuth2Granters.ts"],"sourcesContent":["import { initializer } from 'knifecycle';\nimport { DEFAULT_ERROR_URI, DEFAULT_HELP_URI } from '@whook/whook';\nimport type { WhookErrorsDescriptors } from '@whook/whook';\nimport type { BaseAuthenticationData } from '@whook/authorization';\n\nexport const OAUTH2_ERRORS_DESCRIPTORS: WhookErrorsDescriptors = {\n E_UNKNOWN_AUTHORIZER_TYPE: {\n code: 'unsupported_response_type',\n status: 400,\n description: `The type \"$0\" is not supported.`,\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_UNKNOWN_APPLICATION_ID: {\n code: 'unauthorized_client',\n status: 400,\n description: `The client id \"$0\" is unknown.`,\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_UNAUTHORIZED_APPLICATION_ID: {\n code: 'unauthorized_client',\n status: 401,\n description: `The client id \"$0\" is not allowed.`,\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_APPLICATION_DISABLED: {\n code: 'unauthorized_client',\n status: 401,\n description: `The client id \"$0\" is disabled.`,\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_BAD_REDIRECT_URI: {\n code: 'invalid_request',\n status: 400,\n description: `The redirect uri \"$0\" is not allowed.`,\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_UNAUTHORIZED_SCOPE: {\n code: 'invalid_scope',\n status: 403,\n description: `The scope \"$0\" is not allowed.`,\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_UNAUTHORIZED_GRANT_TYPE: {\n code: 'invalid_request',\n status: 403,\n description: `The response type \"$0\" is not allowed for this application.`,\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_UNAUTHORIZED_CLIENT: {\n code: 'invalid_client',\n status: 401,\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_BAD_USERNAME: {\n code: 'invalid_request',\n status: 400,\n description: 'User does not exists.',\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_BAD_PASSWORD: {\n code: 'invalid_request',\n status: 400,\n description: 'Bad password sent for that user.',\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_BAD_REFRESH_TOKEN: {\n code: 'invalid_request',\n status: 400,\n description: 'The refresh token is expired/invalid.',\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_BAD_AUTHORIZATION_CODE: {\n code: 'invalid_request',\n status: 400,\n description: 'The authorization code is invalid or expired.',\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_UNKNOWN_ACKNOWLEDGOR_TYPE: {\n code: 'unsupported_response_type',\n status: 400,\n description: `Type \"$0\" not supported.`,\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_ACCESS_DENIED: {\n code: 'access_denied',\n status: 403,\n description: 'The user denied access to your application.',\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_UNKNOWN_AUTHENTICATION_TYPE: {\n code: 'unsupported_grant_type',\n status: 400,\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_OAUTH2: {\n code: 'server_error',\n status: 500,\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n E_REFRESH_COOKIE: {\n code: 'invalid_request',\n status: 400,\n description: `Could not find any refresh_token value in the cookie header ($0).`,\n uri: DEFAULT_ERROR_URI,\n help: DEFAULT_HELP_URI,\n },\n};\n\nexport type OAuth2CodeService<\n AUTHENTICATION_DATA extends BaseAuthenticationData = BaseAuthenticationData,\n CODE = string,\n> = {\n create: (\n authenticationData: AUTHENTICATION_DATA,\n redirectURI: string,\n additionalParameters: { [name: string]: unknown },\n ) => Promise<CODE>;\n check: (\n authenticationData: AUTHENTICATION_DATA,\n code: CODE,\n redirectURI: string,\n ) => Promise<\n AUTHENTICATION_DATA & {\n redirectURI: string;\n } & { [name: string]: unknown }\n >;\n};\n\nexport type OAuth2PasswordService<\n AUTHENTICATION_DATA extends BaseAuthenticationData = BaseAuthenticationData,\n USERNAME = string,\n PASSWORD = string,\n> = {\n check: (\n authenticationData: AUTHENTICATION_DATA,\n username: USERNAME,\n password: PASSWORD,\n demandedScope: AUTHENTICATION_DATA['scope'],\n ) => Promise<AUTHENTICATION_DATA>;\n};\n\nexport type OAuth2AccessTokenService<\n AUTHENTICATION_DATA extends BaseAuthenticationData = BaseAuthenticationData,\n TOKEN = string,\n> = {\n create: (\n authenticationData: AUTHENTICATION_DATA,\n tokenAuthenticationData: AUTHENTICATION_DATA,\n additionalParameters?: { [name: string]: unknown },\n ) => Promise<{\n token: TOKEN;\n expiresAt: number;\n }>;\n check: (\n authenticationData: AUTHENTICATION_DATA,\n token: TOKEN,\n scope?: AUTHENTICATION_DATA['scope'],\n ) => Promise<AUTHENTICATION_DATA>;\n};\n\nexport type OAuth2RefreshTokenService<\n AUTHENTICATION_DATA extends BaseAuthenticationData = BaseAuthenticationData,\n TOKEN = string,\n> = OAuth2AccessTokenService<AUTHENTICATION_DATA, TOKEN>;\n\nexport type CheckApplicationService = {\n (context: {\n applicationId: string;\n type: string;\n scope: string;\n redirectURI?: string;\n }): Promise<{\n applicationId: string;\n type: string;\n scope: string;\n redirectURI: string;\n }>;\n};\n\nexport type OAuth2GranterAuthorize<\n AUTHORIZE_PARAMETERS extends Record<string, unknown> = Record<\n string,\n unknown\n >,\n AUTHENTICATION_DATA extends BaseAuthenticationData = BaseAuthenticationData,\n> = (\n context: {\n clientId: AUTHENTICATION_DATA['applicationId'];\n redirectURI: string;\n scope: AUTHENTICATION_DATA['scope'];\n },\n authorizeParameters?: AUTHORIZE_PARAMETERS,\n) => Promise<{\n applicationId: AUTHENTICATION_DATA['applicationId'];\n redirectURI: string;\n scope: AUTHENTICATION_DATA['scope'];\n}>;\n\nexport type Oauth2GranterAuthenticate<\n GRANT_PARAMETERS extends Record<string, unknown> = Record<string, unknown>,\n AUTHENTICATION_DATA extends BaseAuthenticationData = BaseAuthenticationData,\n> = (\n grantParameters: GRANT_PARAMETERS,\n authenticationData: AUTHENTICATION_DATA,\n) => Promise<AUTHENTICATION_DATA>;\n\nexport type OAuth2GranterAcknowledge<\n ACKNOWLEDGE_PARAMETERS extends Record<string, unknown> = Record<\n string,\n unknown\n >,\n AUTHENTICATION_DATA extends BaseAuthenticationData = BaseAuthenticationData,\n> = (\n authenticationData: AUTHENTICATION_DATA,\n acknowledgeParameters: {\n clientId: AUTHENTICATION_DATA['applicationId'];\n redirectURI: string;\n scope: AUTHENTICATION_DATA['applicationId'];\n },\n additionalParameters: ACKNOWLEDGE_PARAMETERS,\n) => Promise<\n AUTHENTICATION_DATA & {\n redirectURI: string;\n [name: string]: unknown;\n }\n>;\n\nexport type OAuth2GranterService<\n AUTHORIZE_PARAMETERS extends Record<string, unknown> = Record<\n string,\n unknown\n >,\n ACKNOWLEDGE_PARAMETERS extends Record<string, unknown> = Record<\n string,\n unknown\n >,\n GRANT_PARAMETERS extends Record<string, unknown> = Record<string, unknown>,\n AUTHENTICATION_DATA extends BaseAuthenticationData = BaseAuthenticationData,\n> = {\n type: string;\n authorizer?: {\n responseType: string;\n authorize: OAuth2GranterAuthorize<\n AUTHORIZE_PARAMETERS,\n AUTHENTICATION_DATA\n >;\n };\n acknowledger?: {\n acknowledgmentType: string;\n acknowledge: OAuth2GranterAcknowledge<\n ACKNOWLEDGE_PARAMETERS,\n AUTHENTICATION_DATA\n >;\n };\n authenticator?: {\n grantType: string;\n authenticate: Oauth2GranterAuthenticate<\n GRANT_PARAMETERS,\n AUTHENTICATION_DATA\n >;\n };\n};\n\nexport type OAuth2Options = {\n authenticateURL: string;\n defaultToClientScope?: boolean;\n};\n\nexport type OAuth2Config = {\n OAUTH2: OAuth2Options;\n ERRORS_DESCRIPTORS: WhookErrorsDescriptors;\n};\n\nexport default initializer(\n {\n name: 'oAuth2Granters',\n type: 'service',\n inject: [\n 'oAuth2ClientCredentialsGranter',\n 'oAuth2CodeGranter',\n 'oAuth2PasswordGranter',\n 'oAuth2RefreshTokenGranter',\n 'oAuth2TokenGranter',\n ],\n singleton: true,\n },\n async (services) => Object.keys(services).map((key) => services[key]),\n);\n"],"mappings":"AAA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A6B,EAAE;IAC7BlB,IAAI,EAAE,wBADuB;IAE7BC,MAAM,EAAE,GAFqB;IAG7BE,GAAG,EAAEP,iBAHwB;IAI7BQ,IAAI,EAAEP;EAJuB,CAlGgC;EAwG/DsB,QAAQ,EAAE;IACRnB,IAAI,EAAE,cADE;IAERC,MAAM,EAAE,GAFA;IAGRE,GAAG,EAAEP,iBAHG;IAIRQ,IAAI,EAAEP;EAJE,CAxGqD;EA8G/DuB,gBAAgB,EAAE;IAChBpB,IAAI,EAAE,iBADU;IAEhBC,MAAM,EAAE,GAFQ;IAGhBC,WAAW,EAAG,mEAHE;IAIhBC,GAAG,EAAEP,iBAJW;IAKhBQ,IAAI,EAAEP;EALU;AA9G6C,CAA1D;AA4RP,eAAeF,WAAW,CACxB;EACE0B,IAAI,EAAE,gBADR;EAEEC,IAAI,EAAE,SAFR;EAGEC,MAAM,EAAE,CACN,gCADM,EAEN,mBAFM,EAGN,uBAHM,EAIN,2BAJM,EAKN,oBALM,CAHV;EAUEC,SAAS,EAAE;AAVb,CADwB,EAaxB,MAAOC,QAAP,IAAoBC,MAAM,CAACC,IAAP,CAAYF,QAAZ,EAAsBG,GAAtB,CAA2BC,GAAD,IAASJ,QAAQ,CAACI,GAAD,CAA3C,CAbI,CAA1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"oAuth2PasswordGranter.js","names":["autoService","initOAuth2PasswordGranter","oAuth2Password","checkApplication","log","noop","authenticateWithPassword","username","password","scope","demandedScope","authenticationData","YError","applicationId","type","finalAuthenticationData","check","authenticator","grantType","authenticate"],"sources":["../../src/services/oAuth2PasswordGranter.ts"],"sourcesContent":["import { autoService } from 'knifecycle';\nimport { noop } from '@whook/whook';\nimport YError from 'yerror';\nimport type { LogService } from 'common-services';\nimport type {\n OAuth2GranterService,\n OAuth2PasswordService,\n CheckApplicationService,\n} from './oAuth2Granters';\nimport type { BaseAuthenticationData } from '@whook/authorization';\n\nexport type OAuth2PasswordGranterDependencies = {\n oAuth2Password: OAuth2PasswordService;\n checkApplication: CheckApplicationService;\n log?: LogService;\n};\nexport type OAuth2PasswordGranterParameters = {\n username: string;\n password: string;\n scope?: string;\n};\nexport type OAuth2PasswordGranterService<\n AUTHENTICATION_DATA extends BaseAuthenticationData = BaseAuthenticationData,\n> = OAuth2GranterService<\n Record<string, unknown>,\n Record<string, unknown>,\n OAuth2PasswordGranterParameters,\n AUTHENTICATION_DATA\n>;\n\nexport default autoService(initOAuth2PasswordGranter);\n\n// Resource Owner Password Credentials Grant\n// https://tools.ietf.org/html/rfc6749#section-4.3\nasync function initOAuth2PasswordGranter({\n oAuth2Password,\n checkApplication,\n log = noop,\n}: OAuth2PasswordGranterDependencies): Promise<OAuth2PasswordGranterService> {\n const authenticateWithPassword: NonNullable<\n OAuth2PasswordGranterService['authenticator']\n >['authenticate'] = async (\n { username, password, scope: demandedScope = '' },\n authenticationData,\n ) => {\n // The client must be authenticated\n if (!authenticationData) {\n throw new YError('E_UNAUTHORIZED');\n }\n\n await checkApplication({\n applicationId: authenticationData.applicationId,\n type: 'password',\n scope: demandedScope,\n });\n\n const finalAuthenticationData = await oAuth2Password.check(\n authenticationData,\n username,\n password,\n demandedScope,\n );\n\n return finalAuthenticationData;\n };\n\n log('debug', '👫 - OAuth2PasswordGranter Service Initialized!');\n\n return {\n type: 'password',\n authenticator: {\n grantType: 'password',\n authenticate: authenticateWithPassword,\n },\n };\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;eA4Be,IAAAA,mBAAA,EAAYC,yBAAZ,0E,EAEf;AACA;;;;;AACA,eAAeA,yBAAf,CAAyC;EACvCC,cADuC;EAEvCC,gBAFuC;EAGvCC,GAAG,GAAGC;AAHiC,CAAzC,EAI6E;EAC3E,MAAMC,wBAEW,GAAG,OAClB;IAAEC,QAAF;IAAYC,QAAZ;IAAsBC,KAAK,EAAEC,aAAa,GAAG;EAA7C,CADkB,EAElBC,kBAFkB,KAGf;IACH;IACA,IAAI,CAACA,kBAAL,EAAyB;MACvB,MAAM,IAAIC,eAAJ,CAAW,gBAAX,CAAN;IACD;;IAED,MAAMT,gBAAgB,CAAC;MACrBU,aAAa,EAAEF,kBAAkB,CAACE,aADb;MAErBC,IAAI,EAAE,UAFe;MAGrBL,KAAK,EAAEC;IAHc,CAAD,CAAtB;IAMA,MAAMK,uBAAuB,GAAG,MAAMb,cAAc,CAACc,KAAf,CACpCL,kBADoC,EAEpCJ,QAFoC,EAGpCC,QAHoC,EAIpCE,aAJoC,CAAtC;IAOA,OAAOK,uBAAP;EACD,CAzBD;;EA2BAX,GAAG,CAAC,OAAD,EAAU,iDAAV,CAAH;EAEA,OAAO;IACLU,IAAI,EAAE,UADD;IAELG,aAAa,EAAE;MACbC,SAAS,EAAE,UADE;MAEbC,YAAY,EAAEb;IAFD;EAFV,CAAP;AAOD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"oAuth2PasswordGranter.mjs","names":["autoService","noop","YError","initOAuth2PasswordGranter","oAuth2Password","checkApplication","log","authenticateWithPassword","username","password","scope","demandedScope","authenticationData","applicationId","type","finalAuthenticationData","check","authenticator","grantType","authenticate"],"sources":["../../src/services/oAuth2PasswordGranter.ts"],"sourcesContent":["import { autoService } from 'knifecycle';\nimport { noop } from '@whook/whook';\nimport YError from 'yerror';\nimport type { LogService } from 'common-services';\nimport type {\n OAuth2GranterService,\n OAuth2PasswordService,\n CheckApplicationService,\n} from './oAuth2Granters';\nimport type { BaseAuthenticationData } from '@whook/authorization';\n\nexport type OAuth2PasswordGranterDependencies = {\n oAuth2Password: OAuth2PasswordService;\n checkApplication: CheckApplicationService;\n log?: LogService;\n};\nexport type OAuth2PasswordGranterParameters = {\n username: string;\n password: string;\n scope?: string;\n};\nexport type OAuth2PasswordGranterService<\n AUTHENTICATION_DATA extends BaseAuthenticationData = BaseAuthenticationData,\n> = OAuth2GranterService<\n Record<string, unknown>,\n Record<string, unknown>,\n OAuth2PasswordGranterParameters,\n AUTHENTICATION_DATA\n>;\n\nexport default autoService(initOAuth2PasswordGranter);\n\n// Resource Owner Password Credentials Grant\n// https://tools.ietf.org/html/rfc6749#section-4.3\nasync function initOAuth2PasswordGranter({\n oAuth2Password,\n checkApplication,\n log = noop,\n}: OAuth2PasswordGranterDependencies): Promise<OAuth2PasswordGranterService> {\n const authenticateWithPassword: NonNullable<\n OAuth2PasswordGranterService['authenticator']\n >['authenticate'] = async (\n { username, password, scope: demandedScope = '' },\n authenticationData,\n ) => {\n // The client must be authenticated\n if (!authenticationData) {\n throw new YError('E_UNAUTHORIZED');\n }\n\n await checkApplication({\n applicationId: authenticationData.applicationId,\n type: 'password',\n scope: demandedScope,\n });\n\n const finalAuthenticationData = await oAuth2Password.check(\n authenticationData,\n username,\n password,\n demandedScope,\n );\n\n return finalAuthenticationData;\n };\n\n log('debug', '👫 - OAuth2PasswordGranter Service Initialized!');\n\n return {\n type: 'password',\n authenticator: {\n grantType: 'password',\n authenticate: authenticateWithPassword,\n },\n };\n}\n"],"mappings":"AAAA,SAASA,OAAW,IAAXA,QAAT,QAA4B,YAA5B;AACA,SAASC,IAAT,QAAqB,cAArB;AACA,OAAOC,MAAP,MAAmB,QAAnB;AA4BA,eAAeF,QAAW,CAACG,yBAAD,0EAA1B,C,CAEA;AACA;;AACA,eAAeA,yBAAf,CAAyC;EACvCC,cADuC;EAEvCC,gBAFuC;EAGvCC,GAAG,GAAGL;AAHiC,CAAzC,EAI6E;EAC3E,MAAMM,wBAEW,GAAG,OAClB;IAAEC,QAAF;IAAYC,QAAZ;IAAsBC,KAAK,EAAEC,aAAa,GAAG;EAA7C,CADkB,EAElBC,kBAFkB,KAGf;IACH;IACA,IAAI,CAACA,kBAAL,EAAyB;MACvB,MAAM,IAAIV,MAAJ,CAAW,gBAAX,CAAN;IACD;;IAED,MAAMG,gBAAgB,CAAC;MACrBQ,aAAa,EAAED,kBAAkB,CAACC,aADb;MAErBC,IAAI,EAAE,UAFe;MAGrBJ,KAAK,EAAEC;IAHc,CAAD,CAAtB;IAMA,MAAMI,uBAAuB,GAAG,MAAMX,cAAc,CAACY,KAAf,CACpCJ,kBADoC,EAEpCJ,QAFoC,EAGpCC,QAHoC,EAIpCE,aAJoC,CAAtC;IAOA,OAAOI,uBAAP;EACD,CAzBD;;EA2BAT,GAAG,CAAC,OAAD,EAAU,iDAAV,CAAH;EAEA,OAAO;IACLQ,IAAI,EAAE,UADD;IAELG,aAAa,EAAE;MACbC,SAAS,EAAE,UADE;MAEbC,YAAY,EAAEZ;IAFD;EAFV,CAAP;AAOD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"oAuth2RefreshTokenGranter.js","names":["autoService","initOAuth2RefreshTokenGranter","checkApplication","oAuth2RefreshToken","log","noop","authenticateWithRefreshToken","refreshToken","scope","demandedScope","authenticationData","YError","applicationId","type","newAuthenticationData","check","err","code","wrap","authenticator","grantType","authenticate"],"sources":["../../src/services/oAuth2RefreshTokenGranter.ts"],"sourcesContent":["import { autoService } from 'knifecycle';\nimport { noop } from '@whook/whook';\nimport YError from 'yerror';\nimport type { LogService } from 'common-services';\nimport type {\n OAuth2GranterService,\n CheckApplicationService,\n OAuth2RefreshTokenService,\n} from './oAuth2Granters';\nimport type { BaseAuthenticationData } from '@whook/authorization';\n\nexport type OAuth2RefreshTokenGranterDependencies = {\n checkApplication: CheckApplicationService;\n oAuth2RefreshToken: OAuth2RefreshTokenService;\n log?: LogService;\n};\nexport type OAuth2RefreshTokenGranterParameters = {\n refreshToken: string;\n scope?: string;\n};\nexport type OAuth2RefreshTokenGranterService<\n AUTHENTICATION_DATA extends BaseAuthenticationData = BaseAuthenticationData,\n> = OAuth2GranterService<\n Record<string, unknown>,\n Record<string, unknown>,\n OAuth2RefreshTokenGranterParameters,\n AUTHENTICATION_DATA\n>;\n\nexport default autoService(initOAuth2RefreshTokenGranter);\n\n// Refresh Token Grant\n// https://tools.ietf.org/html/rfc6749#page-47\nasync function initOAuth2RefreshTokenGranter({\n checkApplication,\n oAuth2RefreshToken,\n log = noop,\n}: OAuth2RefreshTokenGranterDependencies): Promise<OAuth2RefreshTokenGranterService> {\n const authenticateWithRefreshToken: NonNullable<\n OAuth2RefreshTokenGranterService['authenticator']\n >['authenticate'] = async (\n { refreshToken, scope: demandedScope = '' },\n authenticationData,\n ) => {\n try {\n // The client must be authenticated\n if (!authenticationData) {\n throw new YError('E_UNAUTHORIZED');\n }\n\n await checkApplication({\n applicationId: authenticationData.applicationId,\n type: 'refresh',\n scope: demandedScope,\n });\n\n const newAuthenticationData = await oAuth2RefreshToken.check(\n authenticationData,\n refreshToken,\n demandedScope,\n );\n\n return newAuthenticationData;\n } catch (err) {\n if ((err as YError).code === 'E_BAD_TOKEN') {\n throw YError.wrap(err as Error, 'E_BAD_REFRESH_TOKEN');\n }\n throw err;\n }\n };\n\n log('debug', '👫 - OAuth2RefreshTokenGranter Service Initialized!');\n\n return {\n type: 'refresh',\n authenticator: {\n grantType: 'refresh_token',\n authenticate: authenticateWithRefreshToken,\n },\n };\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;eA2Be,IAAAA,mBAAA,EAAYC,6BAAZ,kF,EAEf;AACA;;;;;AACA,eAAeA,6BAAf,CAA6C;EAC3CC,gBAD2C;EAE3CC,kBAF2C;EAG3CC,GAAG,GAAGC;AAHqC,CAA7C,EAIqF;EACnF,MAAMC,4BAEW,GAAG,OAClB;IAAEC,YAAF;IAAgBC,KAAK,EAAEC,aAAa,GAAG;EAAvC,CADkB,EAElBC,kBAFkB,KAGf;IACH,IAAI;MACF;MACA,IAAI,CAACA,kBAAL,EAAyB;QACvB,MAAM,IAAIC,eAAJ,CAAW,gBAAX,CAAN;MACD;;MAED,MAAMT,gBAAgB,CAAC;QACrBU,aAAa,EAAEF,kBAAkB,CAACE,aADb;QAErBC,IAAI,EAAE,SAFe;QAGrBL,KAAK,EAAEC;MAHc,CAAD,CAAtB;MAMA,MAAMK,qBAAqB,GAAG,MAAMX,kBAAkB,CAACY,KAAnB,CAClCL,kBADkC,EAElCH,YAFkC,EAGlCE,aAHkC,CAApC;MAMA,OAAOK,qBAAP;IACD,CAnBD,CAmBE,OAAOE,GAAP,EAAY;MACZ,IAAKA,GAAD,CAAgBC,IAAhB,KAAyB,aAA7B,EAA4C;QAC1C,MAAMN,eAAA,CAAOO,IAAP,CAAYF,GAAZ,EAA0B,qBAA1B,CAAN;MACD;;MACD,MAAMA,GAAN;IACD;EACF,CA/BD;;EAiCAZ,GAAG,CAAC,OAAD,EAAU,qDAAV,CAAH;EAEA,OAAO;IACLS,IAAI,EAAE,SADD;IAELM,aAAa,EAAE;MACbC,SAAS,EAAE,eADE;MAEbC,YAAY,EAAEf;IAFD;EAFV,CAAP;AAOD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"oAuth2RefreshTokenGranter.mjs","names":["autoService","noop","YError","initOAuth2RefreshTokenGranter","checkApplication","oAuth2RefreshToken","log","authenticateWithRefreshToken","refreshToken","scope","demandedScope","authenticationData","applicationId","type","newAuthenticationData","check","err","code","wrap","authenticator","grantType","authenticate"],"sources":["../../src/services/oAuth2RefreshTokenGranter.ts"],"sourcesContent":["import { autoService } from 'knifecycle';\nimport { noop } from '@whook/whook';\nimport YError from 'yerror';\nimport type { LogService } from 'common-services';\nimport type {\n OAuth2GranterService,\n CheckApplicationService,\n OAuth2RefreshTokenService,\n} from './oAuth2Granters';\nimport type { BaseAuthenticationData } from '@whook/authorization';\n\nexport type OAuth2RefreshTokenGranterDependencies = {\n checkApplication: CheckApplicationService;\n oAuth2RefreshToken: OAuth2RefreshTokenService;\n log?: LogService;\n};\nexport type OAuth2RefreshTokenGranterParameters = {\n refreshToken: string;\n scope?: string;\n};\nexport type OAuth2RefreshTokenGranterService<\n AUTHENTICATION_DATA extends BaseAuthenticationData = BaseAuthenticationData,\n> = OAuth2GranterService<\n Record<string, unknown>,\n Record<string, unknown>,\n OAuth2RefreshTokenGranterParameters,\n AUTHENTICATION_DATA\n>;\n\nexport default autoService(initOAuth2RefreshTokenGranter);\n\n// Refresh Token Grant\n// https://tools.ietf.org/html/rfc6749#page-47\nasync function initOAuth2RefreshTokenGranter({\n checkApplication,\n oAuth2RefreshToken,\n log = noop,\n}: OAuth2RefreshTokenGranterDependencies): Promise<OAuth2RefreshTokenGranterService> {\n const authenticateWithRefreshToken: NonNullable<\n OAuth2RefreshTokenGranterService['authenticator']\n >['authenticate'] = async (\n { refreshToken, scope: demandedScope = '' },\n authenticationData,\n ) => {\n try {\n // The client must be authenticated\n if (!authenticationData) {\n throw new YError('E_UNAUTHORIZED');\n }\n\n await checkApplication({\n applicationId: authenticationData.applicationId,\n type: 'refresh',\n scope: demandedScope,\n });\n\n const newAuthenticationData = await oAuth2RefreshToken.check(\n authenticationData,\n refreshToken,\n demandedScope,\n );\n\n return newAuthenticationData;\n } catch (err) {\n if ((err as YError).code === 'E_BAD_TOKEN') {\n throw YError.wrap(err as Error, 'E_BAD_REFRESH_TOKEN');\n }\n throw err;\n }\n };\n\n log('debug', '👫 - OAuth2RefreshTokenGranter Service Initialized!');\n\n return {\n type: 'refresh',\n authenticator: {\n grantType: 'refresh_token',\n authenticate: authenticateWithRefreshToken,\n },\n };\n}\n"],"mappings":"AAAA,SAASA,OAAW,IAAXA,QAAT,QAA4B,YAA5B;AACA,SAASC,IAAT,QAAqB,cAArB;AACA,OAAOC,MAAP,MAAmB,QAAnB;AA2BA,eAAeF,QAAW,CAACG,6BAAD,kFAA1B,C,CAEA;AACA;;AACA,eAAeA,6BAAf,CAA6C;EAC3CC,gBAD2C;EAE3CC,kBAF2C;EAG3CC,GAAG,GAAGL;AAHqC,CAA7C,EAIqF;EACnF,MAAMM,4BAEW,GAAG,OAClB;IAAEC,YAAF;IAAgBC,KAAK,EAAEC,aAAa,GAAG;EAAvC,CADkB,EAElBC,kBAFkB,KAGf;IACH,IAAI;MACF;MACA,IAAI,CAACA,kBAAL,EAAyB;QACvB,MAAM,IAAIT,MAAJ,CAAW,gBAAX,CAAN;MACD;;MAED,MAAME,gBAAgB,CAAC;QACrBQ,aAAa,EAAED,kBAAkB,CAACC,aADb;QAErBC,IAAI,EAAE,SAFe;QAGrBJ,KAAK,EAAEC;MAHc,CAAD,CAAtB;MAMA,MAAMI,qBAAqB,GAAG,MAAMT,kBAAkB,CAACU,KAAnB,CAClCJ,kBADkC,EAElCH,YAFkC,EAGlCE,aAHkC,CAApC;MAMA,OAAOI,qBAAP;IACD,CAnBD,CAmBE,OAAOE,GAAP,EAAY;MACZ,IAAKA,GAAD,CAAgBC,IAAhB,KAAyB,aAA7B,EAA4C;QAC1C,MAAMf,MAAM,CAACgB,IAAP,CAAYF,GAAZ,EAA0B,qBAA1B,CAAN;MACD;;MACD,MAAMA,GAAN;IACD;EACF,CA/BD;;EAiCAV,GAAG,CAAC,OAAD,EAAU,qDAAV,CAAH;EAEA,OAAO;IACLO,IAAI,EAAE,SADD;IAELM,aAAa,EAAE;MACbC,SAAS,EAAE,eADE;MAEbC,YAAY,EAAEd;IAFD;EAFV,CAAP;AAOD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"oAuth2TokenGranter.js","names":["IMPLICIT_GRANTER_TYPE","autoService","initOAuth2TokenGranter","checkApplication","oAuth2AccessToken","time","Date","now","bind","log","noop","authorizeWithToken","clientId","redirectURI","scope","finalRedirectURI","applicationId","type","acknowledgeWithToken","authenticationData","providedScope","additionalParameters","token","accessToken","expiresAt","accessTokenExpiresAt","create","tokenType","expiresIn","Math","round","authorizer","responseType","authorize","acknowledger","acknowledgmentType","acknowledge"],"sources":["../../src/services/oAuth2TokenGranter.ts"],"sourcesContent":["import { autoService } from 'knifecycle';\nimport { noop } from '@whook/whook';\nimport type { LogService, TimeService } from 'common-services';\nimport type {\n OAuth2GranterService,\n OAuth2AccessTokenService,\n CheckApplicationService,\n OAuth2CodeService,\n} from './oAuth2Granters';\nimport type { BaseAuthenticationData } from '@whook/authorization';\n\nexport const IMPLICIT_GRANTER_TYPE = 'token';\n\nexport type OAuth2TokenGranterDependencies = {\n oAuth2Code: OAuth2CodeService;\n checkApplication: CheckApplicationService;\n oAuth2AccessToken: OAuth2AccessTokenService;\n time?: TimeService;\n log?: LogService;\n};\nexport type OAuth2TokenGranterParameters = Record<string, unknown>;\nexport type OAuth2TokenGranterService<\n AUTHENTICATION_DATA extends BaseAuthenticationData = BaseAuthenticationData,\n> = OAuth2GranterService<\n Record<string, unknown>,\n Record<string, unknown>,\n OAuth2TokenGranterParameters,\n AUTHENTICATION_DATA\n>;\n\nexport default autoService(initOAuth2TokenGranter);\n\n// Implicit Grant\n// https://tools.ietf.org/html/rfc6749#section-4.2\nasync function initOAuth2TokenGranter({\n checkApplication,\n oAuth2AccessToken,\n time = Date.now.bind(Date),\n log = noop,\n}: OAuth2TokenGranterDependencies): Promise<OAuth2TokenGranterService> {\n const authorizeWithToken: NonNullable<\n OAuth2TokenGranterService['authorizer']\n >['authorize'] = async ({ clientId, redirectURI, scope }) => {\n const { redirectURI: finalRedirectURI } = await checkApplication({\n applicationId: clientId,\n type: IMPLICIT_GRANTER_TYPE,\n redirectURI,\n scope,\n });\n\n return {\n applicationId: clientId,\n redirectURI: finalRedirectURI,\n scope,\n };\n };\n\n // Access Token Response:\n // https://tools.ietf.org/html/rfc6749#section-4.2.2\n const acknowledgeWithToken: NonNullable<\n OAuth2GranterService<OAuth2TokenGranterParameters>['acknowledger']\n >['acknowledge'] = async (\n authenticationData,\n { clientId, redirectURI, scope: providedScope },\n additionalParameters,\n ) => {\n const { redirectURI: finalRedirectURI } = await checkApplication({\n applicationId: clientId,\n redirectURI,\n scope: providedScope,\n type: IMPLICIT_GRANTER_TYPE,\n });\n\n const { token: accessToken, expiresAt: accessTokenExpiresAt } =\n await oAuth2AccessToken.create(\n authenticationData,\n {\n applicationId: clientId,\n scope: providedScope,\n },\n additionalParameters,\n );\n\n return {\n applicationId: clientId,\n redirectURI: finalRedirectURI,\n scope: providedScope,\n accessToken,\n tokenType: 'bearer',\n expiresIn: Math.round((accessTokenExpiresAt - time()) / 1000),\n };\n };\n\n log('debug', '👫 - OAuth2TokenGranter Service Initialized!');\n\n return {\n type: IMPLICIT_GRANTER_TYPE,\n authorizer: {\n responseType: 'token',\n authorize: authorizeWithToken,\n },\n acknowledger: {\n acknowledgmentType: 'token',\n acknowledge: acknowledgeWithToken,\n },\n };\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AAUO,MAAMA,qBAAqB,GAAG,OAA9B;;;eAmBQ,IAAAC,mBAAA,EAAYC,sBAAZ,mF,EAEf;AACA;;;;;AACA,eAAeA,sBAAf,CAAsC;EACpCC,gBADoC;EAEpCC,iBAFoC;EAGpCC,IAAI,GAAGC,IAAI,CAACC,GAAL,CAASC,IAAT,CAAcF,IAAd,CAH6B;EAIpCG,GAAG,GAAGC;AAJ8B,CAAtC,EAKuE;EACrE,MAAMC,kBAEQ,GAAG,OAAO;IAAEC,QAAF;IAAYC,WAAZ;IAAyBC;EAAzB,CAAP,KAA4C;IAC3D,MAAM;MAAED,WAAW,EAAEE;IAAf,IAAoC,MAAMZ,gBAAgB,CAAC;MAC/Da,aAAa,EAAEJ,QADgD;MAE/DK,IAAI,EAAEjB,qBAFyD;MAG/Da,WAH+D;MAI/DC;IAJ+D,CAAD,CAAhE;IAOA,OAAO;MACLE,aAAa,EAAEJ,QADV;MAELC,WAAW,EAAEE,gBAFR;MAGLD;IAHK,CAAP;EAKD,CAfD,CADqE,CAkBrE;EACA;;;EACA,MAAMI,oBAEU,GAAG,OACjBC,kBADiB,EAEjB;IAAEP,QAAF;IAAYC,WAAZ;IAAyBC,KAAK,EAAEM;EAAhC,CAFiB,EAGjBC,oBAHiB,KAId;IACH,MAAM;MAAER,WAAW,EAAEE;IAAf,IAAoC,MAAMZ,gBAAgB,CAAC;MAC/Da,aAAa,EAAEJ,QADgD;MAE/DC,WAF+D;MAG/DC,KAAK,EAAEM,aAHwD;MAI/DH,IAAI,EAAEjB;IAJyD,CAAD,CAAhE;IAOA,MAAM;MAAEsB,KAAK,EAAEC,WAAT;MAAsBC,SAAS,EAAEC;IAAjC,IACJ,MAAMrB,iBAAiB,CAACsB,MAAlB,CACJP,kBADI,EAEJ;MACEH,aAAa,EAAEJ,QADjB;MAEEE,KAAK,EAAEM;IAFT,CAFI,EAMJC,oBANI,CADR;IAUA,OAAO;MACLL,aAAa,EAAEJ,QADV;MAELC,WAAW,EAAEE,gBAFR;MAGLD,KAAK,EAAEM,aAHF;MAILG,WAJK;MAKLI,SAAS,EAAE,QALN;MAMLC,SAAS,EAAEC,IAAI,CAACC,KAAL,CAAW,CAACL,oBAAoB,GAAGpB,IAAI,EAA5B,IAAkC,IAA7C;IANN,CAAP;EAQD,CAhCD;;EAkCAI,GAAG,CAAC,OAAD,EAAU,8CAAV,CAAH;EAEA,OAAO;IACLQ,IAAI,EAAEjB,qBADD;IAEL+B,UAAU,EAAE;MACVC,YAAY,EAAE,OADJ;MAEVC,SAAS,EAAEtB;IAFD,CAFP;IAMLuB,YAAY,EAAE;MACZC,kBAAkB,EAAE,OADR;MAEZC,WAAW,EAAElB;IAFD;EANT,CAAP;AAWD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"oAuth2TokenGranter.mjs","names":["autoService","noop","IMPLICIT_GRANTER_TYPE","initOAuth2TokenGranter","checkApplication","oAuth2AccessToken","time","Date","now","bind","log","authorizeWithToken","clientId","redirectURI","scope","finalRedirectURI","applicationId","type","acknowledgeWithToken","authenticationData","providedScope","additionalParameters","token","accessToken","expiresAt","accessTokenExpiresAt","create","tokenType","expiresIn","Math","round","authorizer","responseType","authorize","acknowledger","acknowledgmentType","acknowledge"],"sources":["../../src/services/oAuth2TokenGranter.ts"],"sourcesContent":["import { autoService } from 'knifecycle';\nimport { noop } from '@whook/whook';\nimport type { LogService, TimeService } from 'common-services';\nimport type {\n OAuth2GranterService,\n OAuth2AccessTokenService,\n CheckApplicationService,\n OAuth2CodeService,\n} from './oAuth2Granters';\nimport type { BaseAuthenticationData } from '@whook/authorization';\n\nexport const IMPLICIT_GRANTER_TYPE = 'token';\n\nexport type OAuth2TokenGranterDependencies = {\n oAuth2Code: OAuth2CodeService;\n checkApplication: CheckApplicationService;\n oAuth2AccessToken: OAuth2AccessTokenService;\n time?: TimeService;\n log?: LogService;\n};\nexport type OAuth2TokenGranterParameters = Record<string, unknown>;\nexport type OAuth2TokenGranterService<\n AUTHENTICATION_DATA extends BaseAuthenticationData = BaseAuthenticationData,\n> = OAuth2GranterService<\n Record<string, unknown>,\n Record<string, unknown>,\n OAuth2TokenGranterParameters,\n AUTHENTICATION_DATA\n>;\n\nexport default autoService(initOAuth2TokenGranter);\n\n// Implicit Grant\n// https://tools.ietf.org/html/rfc6749#section-4.2\nasync function initOAuth2TokenGranter({\n checkApplication,\n oAuth2AccessToken,\n time = Date.now.bind(Date),\n log = noop,\n}: OAuth2TokenGranterDependencies): Promise<OAuth2TokenGranterService> {\n const authorizeWithToken: NonNullable<\n OAuth2TokenGranterService['authorizer']\n >['authorize'] = async ({ clientId, redirectURI, scope }) => {\n const { redirectURI: finalRedirectURI } = await checkApplication({\n applicationId: clientId,\n type: IMPLICIT_GRANTER_TYPE,\n redirectURI,\n scope,\n });\n\n return {\n applicationId: clientId,\n redirectURI: finalRedirectURI,\n scope,\n };\n };\n\n // Access Token Response:\n // https://tools.ietf.org/html/rfc6749#section-4.2.2\n const acknowledgeWithToken: NonNullable<\n OAuth2GranterService<OAuth2TokenGranterParameters>['acknowledger']\n >['acknowledge'] = async (\n authenticationData,\n { clientId, redirectURI, scope: providedScope },\n additionalParameters,\n ) => {\n const { redirectURI: finalRedirectURI } = await checkApplication({\n applicationId: clientId,\n redirectURI,\n scope: providedScope,\n type: IMPLICIT_GRANTER_TYPE,\n });\n\n const { token: accessToken, expiresAt: accessTokenExpiresAt } =\n await oAuth2AccessToken.create(\n authenticationData,\n {\n applicationId: clientId,\n scope: providedScope,\n },\n additionalParameters,\n );\n\n return {\n applicationId: clientId,\n redirectURI: finalRedirectURI,\n scope: providedScope,\n accessToken,\n tokenType: 'bearer',\n expiresIn: Math.round((accessTokenExpiresAt - time()) / 1000),\n };\n };\n\n log('debug', '👫 - OAuth2TokenGranter Service Initialized!');\n\n return {\n type: IMPLICIT_GRANTER_TYPE,\n authorizer: {\n responseType: 'token',\n authorize: authorizeWithToken,\n },\n acknowledger: {\n acknowledgmentType: 'token',\n acknowledge: acknowledgeWithToken,\n },\n };\n}\n"],"mappings":"AAAA,SAASA,OAAW,IAAXA,QAAT,QAA4B,YAA5B;AACA,SAASC,IAAT,QAAqB,cAArB;AAUA,OAAO,MAAMC,qBAAqB,GAAG,OAA9B;AAmBP,eAAeF,QAAW,CAACG,sBAAD,mFAA1B,C,CAEA;AACA;;AACA,eAAeA,sBAAf,CAAsC;EACpCC,gBADoC;EAEpCC,iBAFoC;EAGpCC,IAAI,GAAGC,IAAI,CAACC,GAAL,CAASC,IAAT,CAAcF,IAAd,CAH6B;EAIpCG,GAAG,GAAGT;AAJ8B,CAAtC,EAKuE;EACrE,MAAMU,kBAEQ,GAAG,OAAO;IAAEC,QAAF;IAAYC,WAAZ;IAAyBC;EAAzB,CAAP,KAA4C;IAC3D,MAAM;MAAED,WAAW,EAAEE;IAAf,IAAoC,MAAMX,gBAAgB,CAAC;MAC/DY,aAAa,EAAEJ,QADgD;MAE/DK,IAAI,EAAEf,qBAFyD;MAG/DW,WAH+D;MAI/DC;IAJ+D,CAAD,CAAhE;IAOA,OAAO;MACLE,aAAa,EAAEJ,QADV;MAELC,WAAW,EAAEE,gBAFR;MAGLD;IAHK,CAAP;EAKD,CAfD,CADqE,CAkBrE;EACA;;;EACA,MAAMI,oBAEU,GAAG,OACjBC,kBADiB,EAEjB;IAAEP,QAAF;IAAYC,WAAZ;IAAyBC,KAAK,EAAEM;EAAhC,CAFiB,EAGjBC,oBAHiB,KAId;IACH,MAAM;MAAER,WAAW,EAAEE;IAAf,IAAoC,MAAMX,gBAAgB,CAAC;MAC/DY,aAAa,EAAEJ,QADgD;MAE/DC,WAF+D;MAG/DC,KAAK,EAAEM,aAHwD;MAI/DH,IAAI,EAAEf;IAJyD,CAAD,CAAhE;IAOA,MAAM;MAAEoB,KAAK,EAAEC,WAAT;MAAsBC,SAAS,EAAEC;IAAjC,IACJ,MAAMpB,iBAAiB,CAACqB,MAAlB,CACJP,kBADI,EAEJ;MACEH,aAAa,EAAEJ,QADjB;MAEEE,KAAK,EAAEM;IAFT,CAFI,EAMJC,oBANI,CADR;IAUA,OAAO;MACLL,aAAa,EAAEJ,QADV;MAELC,WAAW,EAAEE,gBAFR;MAGLD,KAAK,EAAEM,aAHF;MAILG,WAJK;MAKLI,SAAS,EAAE,QALN;MAMLC,SAAS,EAAEC,IAAI,CAACC,KAAL,CAAW,CAACL,oBAAoB,GAAGnB,IAAI,EAA5B,IAAkC,IAA7C;IANN,CAAP;EAQD,CAhCD;;EAkCAI,GAAG,CAAC,OAAD,EAAU,8CAAV,CAAH;EAEA,OAAO;IACLO,IAAI,EAAEf,qBADD;IAEL6B,UAAU,EAAE;MACVC,YAAY,EAAE,OADJ;MAEVC,SAAS,EAAEtB;IAFD,CAFP;IAMLuB,YAAY,EAAE;MACZC,kBAAkB,EAAE,OADR;MAEZC,WAAW,EAAElB;IAFD;EANT,CAAP;AAWD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@whook/oauth2",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0",
|
|
4
4
|
"description": "OAuth2 implementation for Whook servers",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -44,43 +44,43 @@
|
|
|
44
44
|
},
|
|
45
45
|
"homepage": "https://github.com/nfroidure/whook",
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@types/
|
|
48
|
-
"@whook/authorization": "^
|
|
49
|
-
"@whook/whook": "^
|
|
50
|
-
"camelcase": "^6.
|
|
51
|
-
"common-services": "^
|
|
52
|
-
"cookie": "^0.
|
|
53
|
-
"knifecycle": "^
|
|
54
|
-
"openapi-types": "^
|
|
55
|
-
"type-fest": "^2.
|
|
56
|
-
"yerror": "^6.0.
|
|
57
|
-
"yhttperror": "^6.0.
|
|
47
|
+
"@types/cookie": "^0.5.1",
|
|
48
|
+
"@whook/authorization": "^9.0.0",
|
|
49
|
+
"@whook/whook": "^9.0.0",
|
|
50
|
+
"camelcase": "^6.3.0",
|
|
51
|
+
"common-services": "^10.0.2",
|
|
52
|
+
"cookie": "^0.5.0",
|
|
53
|
+
"knifecycle": "^12.0.4",
|
|
54
|
+
"openapi-types": "^11.0.1",
|
|
55
|
+
"type-fest": "^2.13.0",
|
|
56
|
+
"yerror": "^6.0.2",
|
|
57
|
+
"yhttperror": "^6.0.3"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@babel/cli": "^7.
|
|
61
|
-
"@babel/core": "^7.
|
|
62
|
-
"@babel/eslint-parser": "^7.
|
|
63
|
-
"@babel/plugin-proposal-class-properties": "^7.
|
|
64
|
-
"@babel/plugin-proposal-object-rest-spread": "^7.
|
|
60
|
+
"@babel/cli": "^7.17.10",
|
|
61
|
+
"@babel/core": "^7.18.2",
|
|
62
|
+
"@babel/eslint-parser": "^7.18.2",
|
|
63
|
+
"@babel/plugin-proposal-class-properties": "^7.17.12",
|
|
64
|
+
"@babel/plugin-proposal-object-rest-spread": "^7.18.0",
|
|
65
65
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
66
66
|
"@babel/plugin-syntax-import-meta": "^7.10.4",
|
|
67
|
-
"@babel/preset-env": "^7.
|
|
68
|
-
"@babel/preset-typescript": "^7.
|
|
69
|
-
"@babel/register": "^7.
|
|
70
|
-
"@types/jest": "^
|
|
71
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
72
|
-
"@typescript-eslint/parser": "^
|
|
73
|
-
"babel-plugin-knifecycle": "^5.0.
|
|
74
|
-
"eslint": "^
|
|
75
|
-
"eslint-plugin-prettier": "^
|
|
76
|
-
"http-auth-utils": "^3.0.
|
|
77
|
-
"jest": "^
|
|
78
|
-
"jsdoc-to-markdown": "^7.
|
|
79
|
-
"metapak": "^4.0.
|
|
80
|
-
"metapak-nfroidure": "11.
|
|
81
|
-
"prettier": "^2.2
|
|
67
|
+
"@babel/preset-env": "^7.18.2",
|
|
68
|
+
"@babel/preset-typescript": "^7.17.12",
|
|
69
|
+
"@babel/register": "^7.17.7",
|
|
70
|
+
"@types/jest": "^27.0.2",
|
|
71
|
+
"@typescript-eslint/eslint-plugin": "^5.26.0",
|
|
72
|
+
"@typescript-eslint/parser": "^5.26.0",
|
|
73
|
+
"babel-plugin-knifecycle": "^5.0.3",
|
|
74
|
+
"eslint": "^8.16.0",
|
|
75
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
76
|
+
"http-auth-utils": "^3.0.3",
|
|
77
|
+
"jest": "^28.1.0",
|
|
78
|
+
"jsdoc-to-markdown": "^7.1.1",
|
|
79
|
+
"metapak": "^4.0.3",
|
|
80
|
+
"metapak-nfroidure": "11.2.1",
|
|
81
|
+
"prettier": "^2.6.2",
|
|
82
82
|
"rimraf": "^3.0.2",
|
|
83
|
-
"typescript": "^4.2
|
|
83
|
+
"typescript": "^4.7.2"
|
|
84
84
|
},
|
|
85
85
|
"contributors": [],
|
|
86
86
|
"engines": {
|
|
@@ -201,6 +201,5 @@
|
|
|
201
201
|
"prettier": "prettier --write 'src/**/*.ts'",
|
|
202
202
|
"test": "npm run jest",
|
|
203
203
|
"types": "rimraf -f 'dist/**/*.d.ts' && tsc --project . --declaration --emitDeclarationOnly --outDir dist"
|
|
204
|
-
}
|
|
205
|
-
"gitHead": "0dcba31dc8a35d209dd0129675b527502dc9895c"
|
|
204
|
+
}
|
|
206
205
|
}
|