@smg-automotive/auth 7.1.0-auth0-update-tweaks.2 → 7.1.0-auth0-update-tweaks.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/lib/enrichUser/auth0.js +2 -2
- package/dist/cjs/lib/enrichUser/auth0.js.map +1 -1
- package/dist/cjs/server/helpers/getAuthProps.d.ts +6 -3
- package/dist/cjs/server/helpers/getAuthProps.js.map +1 -1
- package/dist/cjs/server/helpers/getUser.d.ts +7 -4
- package/dist/cjs/server/helpers/getUser.js +9 -6
- package/dist/cjs/server/helpers/getUser.js.map +1 -1
- package/dist/cjs/server/hooks/onCallbackFactory.js +2 -2
- package/dist/cjs/server/hooks/onCallbackFactory.js.map +1 -1
- package/dist/esm/lib/enrichUser/auth0.js +1 -1
- package/dist/esm/server/helpers/getAuthProps.d.ts +6 -3
- package/dist/esm/server/helpers/getAuthProps.js.map +1 -1
- package/dist/esm/server/helpers/getUser.d.ts +7 -4
- package/dist/esm/server/helpers/getUser.js +9 -6
- package/dist/esm/server/helpers/getUser.js.map +1 -1
- package/dist/esm/server/hooks/onCallbackFactory.js +1 -1
- package/dist/server.d.ts +6 -3
- package/package.json +3 -2
- package/dist/cjs/node_modules/jose/dist/webapi/lib/base64.js +0 -16
- package/dist/cjs/node_modules/jose/dist/webapi/lib/base64.js.map +0 -1
- package/dist/cjs/node_modules/jose/dist/webapi/lib/buffer_utils.js +0 -7
- package/dist/cjs/node_modules/jose/dist/webapi/lib/buffer_utils.js.map +0 -1
- package/dist/cjs/node_modules/jose/dist/webapi/lib/is_object.js +0 -21
- package/dist/cjs/node_modules/jose/dist/webapi/lib/is_object.js.map +0 -1
- package/dist/cjs/node_modules/jose/dist/webapi/util/base64url.js +0 -26
- package/dist/cjs/node_modules/jose/dist/webapi/util/base64url.js.map +0 -1
- package/dist/cjs/node_modules/jose/dist/webapi/util/decode_jwt.js +0 -38
- package/dist/cjs/node_modules/jose/dist/webapi/util/decode_jwt.js.map +0 -1
- package/dist/cjs/node_modules/jose/dist/webapi/util/errors.js +0 -19
- package/dist/cjs/node_modules/jose/dist/webapi/util/errors.js.map +0 -1
- package/dist/esm/node_modules/jose/dist/webapi/lib/base64.js +0 -14
- package/dist/esm/node_modules/jose/dist/webapi/lib/base64.js.map +0 -1
- package/dist/esm/node_modules/jose/dist/webapi/lib/buffer_utils.js +0 -5
- package/dist/esm/node_modules/jose/dist/webapi/lib/buffer_utils.js.map +0 -1
- package/dist/esm/node_modules/jose/dist/webapi/lib/is_object.js +0 -19
- package/dist/esm/node_modules/jose/dist/webapi/lib/is_object.js.map +0 -1
- package/dist/esm/node_modules/jose/dist/webapi/util/base64url.js +0 -24
- package/dist/esm/node_modules/jose/dist/webapi/util/base64url.js.map +0 -1
- package/dist/esm/node_modules/jose/dist/webapi/util/decode_jwt.js +0 -36
- package/dist/esm/node_modules/jose/dist/webapi/util/decode_jwt.js.map +0 -1
- package/dist/esm/node_modules/jose/dist/webapi/util/errors.js +0 -16
- package/dist/esm/node_modules/jose/dist/webapi/util/errors.js.map +0 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var jose = require('jose');
|
|
3
4
|
var user = require('../../types/auth0/user.js');
|
|
4
5
|
var getSeller = require('../../api/seller/getSeller.js');
|
|
5
6
|
require('../../api/seller/client.js');
|
|
6
|
-
var decode_jwt = require('../../node_modules/jose/dist/webapi/util/decode_jwt.js');
|
|
7
7
|
|
|
8
8
|
const enrichUser = async ({ auth0User, accessToken, userHasSelectedSeller = false, }) => {
|
|
9
9
|
if (!accessToken) {
|
|
10
10
|
throw new Error('Please provide an access token to enrich the user');
|
|
11
11
|
}
|
|
12
|
-
const decodedToken =
|
|
12
|
+
const decodedToken = jose.decodeJwt(accessToken);
|
|
13
13
|
const isMultiTenantUser = !!decodedToken.isMultiTenantUser;
|
|
14
14
|
const forceTenantSelection = isMultiTenantUser && !userHasSelectedSeller;
|
|
15
15
|
const sellerId = parseInt(decodedToken.sellerIds[0], 10);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth0.js","sources":["../../../../../src/lib/enrichUser/auth0.ts"],"sourcesContent":[null],"names":["decodeJwt","getSeller","Auth0UserType"],"mappings":";;;;;;;AAWO,MAAM,UAAU,GAAG,OAAO,EAC/B,SAAS,EACT,WAAW,EACX,qBAAqB,GAAG,KAAK,GAK9B,KAAkD;IACjD,IAAI,CAAC,WAAW,EAAE;AAChB,QAAA,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC;IACtE;AAEA,IAAA,MAAM,YAAY,GAAGA,
|
|
1
|
+
{"version":3,"file":"auth0.js","sources":["../../../../../src/lib/enrichUser/auth0.ts"],"sourcesContent":[null],"names":["decodeJwt","getSeller","Auth0UserType"],"mappings":";;;;;;;AAWO,MAAM,UAAU,GAAG,OAAO,EAC/B,SAAS,EACT,WAAW,EACX,qBAAqB,GAAG,KAAK,GAK9B,KAAkD;IACjD,IAAI,CAAC,WAAW,EAAE;AAChB,QAAA,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC;IACtE;AAEA,IAAA,MAAM,YAAY,GAAGA,cAAS,CAAkB,WAAW,CAAC;AAC5D,IAAA,MAAM,iBAAiB,GAAG,CAAC,CAAC,YAAY,CAAC,iBAAiB;AAC1D,IAAA,MAAM,oBAAoB,GAAG,iBAAiB,IAAI,CAAC,qBAAqB;AACxE,IAAA,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;AACxD,IAAA,MAAM,UAAU,GAA0B;AACxC,QAAA,GAAG,SAAS;AACZ,QAAA,cAAc,EAAE,CAAC,CAAC,YAAY,CAAC,cAAc;AAC7C,QAAA,MAAM,EAAE,YAAY,CAAC,OAAO,CAAC,QAAQ,EAAE;QACvC,oBAAoB;QACpB,iBAAiB;KAClB;AAED,IAAA,MAAM,MAAM,GAAG,MAAMC,mBAAS,CAAC;AAC7B,QAAA,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC;AAC3B,KAAA,CAAC;IAEF,IAAI,CAAC,MAAM,EAAE;;AAEX,QAAA,OAAO,CAAC,IAAI,CACV,qDAAqD,QAAQ,CAAA,CAAE,CAChE;IACH;AAEA,IAAA,MAAM,YAAY,GAAgB;AAChC,QAAA,GAAG,UAAU;AACb,QAAA,QAAQ,EAAE,MAAM,EAAE,IAAI,IAAIC,kBAAa,CAAC,OAAO;AAC/C,QAAA,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAAE;KAC9B;AACD,IAAA,OAAO,YAAY;AACrB;;;;"}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { NextApiRequest } from 'next';
|
|
2
|
-
import { IncomingMessage } from 'http';
|
|
1
|
+
import { NextApiRequest, NextApiResponse } from 'next';
|
|
2
|
+
import { IncomingMessage, ServerResponse } from 'http';
|
|
3
3
|
import { Brand } from 'src/types/brand';
|
|
4
4
|
import { AuthProviderProps } from 'src/client/contexts/Auth';
|
|
5
5
|
import { GetAuth0InstanceContext } from '../getAuth0Instance';
|
|
6
6
|
export declare const getAuthProps: (context: GetAuth0InstanceContext & {
|
|
7
7
|
brand: Brand;
|
|
8
|
-
|
|
8
|
+
context?: {
|
|
9
|
+
request: NextApiRequest | IncomingMessage;
|
|
10
|
+
response: NextApiResponse | ServerResponse<IncomingMessage>;
|
|
11
|
+
};
|
|
9
12
|
}) => Promise<AuthProviderProps>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getAuthProps.js","sources":["../../../../../src/server/helpers/getAuthProps.ts"],"sourcesContent":[null],"names":["getAuth0Config","getEnrichedUser"],"mappings":";;;;;MAWa,YAAY,GAAG,OAC1B,
|
|
1
|
+
{"version":3,"file":"getAuthProps.js","sources":["../../../../../src/server/helpers/getAuthProps.ts"],"sourcesContent":[null],"names":["getAuth0Config","getEnrichedUser"],"mappings":";;;;;MAWa,YAAY,GAAG,OAC1B,OAMC,KAC6B;AAC9B,IAAA,MAAM,MAAM,GAAGA,oBAAc,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC;AAC/D,IAAA,MAAM,IAAI,GAAG,MAAMC,uBAAe,CAAC,OAAO,CAAC;AAE3C,IAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE;AACzB;;;;"}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import { NextApiRequest } from 'next';
|
|
2
|
-
import { IncomingMessage } from 'http';
|
|
1
|
+
import { NextApiRequest, NextApiResponse } from 'next';
|
|
2
|
+
import { IncomingMessage, ServerResponse } from 'http';
|
|
3
3
|
import { Brand } from 'src/types/brand';
|
|
4
4
|
import { EnrichedSessionUser, SessionUser } from 'src/types';
|
|
5
5
|
import { GetAuth0InstanceContext } from '../getAuth0Instance';
|
|
6
6
|
export declare const getUser: (context: GetAuth0InstanceContext) => Promise<SessionUser | null>;
|
|
7
|
-
export declare const getEnrichedUser: ({ brand,
|
|
7
|
+
export declare const getEnrichedUser: ({ brand, context, ...auth0context }: GetAuth0InstanceContext & {
|
|
8
8
|
brand: Brand;
|
|
9
|
-
|
|
9
|
+
context?: {
|
|
10
|
+
request: NextApiRequest | IncomingMessage;
|
|
11
|
+
response: NextApiResponse | ServerResponse<IncomingMessage>;
|
|
12
|
+
};
|
|
10
13
|
}) => Promise<EnrichedSessionUser | null>;
|
|
@@ -10,17 +10,20 @@ const getUser = async (context) => {
|
|
|
10
10
|
return null;
|
|
11
11
|
return sessionData.user;
|
|
12
12
|
};
|
|
13
|
-
const getEnrichedUser = async ({ brand,
|
|
14
|
-
const auth0Instance = getAuth0Instance.getAuth0Instance(
|
|
15
|
-
const sessionData =
|
|
16
|
-
? auth0Instance.getSession(request)
|
|
17
|
-
: auth0Instance.getSession()
|
|
13
|
+
const getEnrichedUser = async ({ brand, context, ...auth0context }) => {
|
|
14
|
+
const auth0Instance = getAuth0Instance.getAuth0Instance(auth0context);
|
|
15
|
+
const sessionData = context?.request
|
|
16
|
+
? await auth0Instance.getSession(context.request)
|
|
17
|
+
: await auth0Instance.getSession();
|
|
18
18
|
if (!sessionData || !sessionData.user)
|
|
19
19
|
return null;
|
|
20
20
|
const user = sessionData.user;
|
|
21
|
+
const { token } = context?.request
|
|
22
|
+
? await auth0Instance.getAccessToken(context.request, context.response)
|
|
23
|
+
: await auth0Instance.getAccessToken();
|
|
21
24
|
return session.enrichUser({
|
|
22
25
|
user,
|
|
23
|
-
accessToken:
|
|
26
|
+
accessToken: token,
|
|
24
27
|
brand,
|
|
25
28
|
});
|
|
26
29
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getUser.js","sources":["../../../../../src/server/helpers/getUser.ts"],"sourcesContent":[null],"names":["getAuth0Instance","enrichUser"],"mappings":";;;;;MAUa,OAAO,GAAG,OACrB,OAAgC,KACD;AAC/B,IAAA,MAAM,aAAa,GAAGA,iCAAgB,CAAC,OAAO,CAAC;AAC/C,IAAA,MAAM,WAAW,GAAG,MAAM,aAAa,CAAC,UAAU,EAAE;AAEpD,IAAA,IAAI,CAAC,WAAW,IAAI,CAAC,WAAW,CAAC,IAAI;AAAE,QAAA,OAAO,IAAI;IAElD,OAAO,WAAW,CAAC,IAAmB;AACxC;AAEO,MAAM,eAAe,GAAG,OAAO,EACpC,KAAK,EACL,OAAO,EACP,GAAG,
|
|
1
|
+
{"version":3,"file":"getUser.js","sources":["../../../../../src/server/helpers/getUser.ts"],"sourcesContent":[null],"names":["getAuth0Instance","enrichUser"],"mappings":";;;;;MAUa,OAAO,GAAG,OACrB,OAAgC,KACD;AAC/B,IAAA,MAAM,aAAa,GAAGA,iCAAgB,CAAC,OAAO,CAAC;AAC/C,IAAA,MAAM,WAAW,GAAG,MAAM,aAAa,CAAC,UAAU,EAAE;AAEpD,IAAA,IAAI,CAAC,WAAW,IAAI,CAAC,WAAW,CAAC,IAAI;AAAE,QAAA,OAAO,IAAI;IAElD,OAAO,WAAW,CAAC,IAAmB;AACxC;AAEO,MAAM,eAAe,GAAG,OAAO,EACpC,KAAK,EACL,OAAO,EACP,GAAG,YAAY,EAOhB,KAAyC;AACxC,IAAA,MAAM,aAAa,GAAGA,iCAAgB,CAAC,YAAY,CAAC;AACpD,IAAA,MAAM,WAAW,GAAG,OAAO,EAAE;UACzB,MAAM,aAAa,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO;AAChD,UAAE,MAAM,aAAa,CAAC,UAAU,EAAE;AAEpC,IAAA,IAAI,CAAC,WAAW,IAAI,CAAC,WAAW,CAAC,IAAI;AAAE,QAAA,OAAO,IAAI;AAElD,IAAA,MAAM,IAAI,GAAG,WAAW,CAAC,IAAmB;AAC5C,IAAA,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE;AACzB,UAAE,MAAM,aAAa,CAAC,cAAc,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,QAAQ;AACtE,UAAE,MAAM,aAAa,CAAC,cAAc,EAAE;AACxC,IAAA,OAAOC,kBAAU,CAAC;QAChB,IAAI;AACJ,QAAA,WAAW,EAAE,KAAK;QAClB,KAAK;AACN,KAAA,CAAC;AACJ;;;;;"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var server = require('next/server');
|
|
4
4
|
var headers = require('next/headers');
|
|
5
|
-
var
|
|
5
|
+
var jose = require('jose');
|
|
6
6
|
|
|
7
7
|
const createCallbackResponse = (context, appBaseUrl) => server.NextResponse.redirect(new URL(context.returnTo || '/', appBaseUrl));
|
|
8
8
|
const getLocaleFromContext = ({ returnTo }, appBaseUrl) => {
|
|
@@ -65,7 +65,7 @@ const onCallbackFactory = ({ auth0Config, appBaseUrl, onError, }) => async (erro
|
|
|
65
65
|
const cookieStore = await headers.cookies();
|
|
66
66
|
let selectedSellerId = cookieStore.get(auth0Config.selectedSellerIdCookie.name)?.value ?? null;
|
|
67
67
|
const decodedToken = session.tokenSet.accessToken
|
|
68
|
-
?
|
|
68
|
+
? jose.decodeJwt(session.tokenSet.accessToken)
|
|
69
69
|
: null;
|
|
70
70
|
const availableSellerIds = decodedToken?.sellerIds ?? null;
|
|
71
71
|
if (availableSellerIds &&
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"onCallbackFactory.js","sources":["../../../../../src/server/hooks/onCallbackFactory.ts"],"sourcesContent":[null],"names":["NextResponse","cookies","decodeJwt"],"mappings":"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
|
|
1
|
+
{"version":3,"file":"onCallbackFactory.js","sources":["../../../../../src/server/hooks/onCallbackFactory.ts"],"sourcesContent":[null],"names":["NextResponse","cookies","decodeJwt"],"mappings":"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"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { decodeJwt } from 'jose';
|
|
1
2
|
import { Auth0UserType } from '../../types/auth0/user.js';
|
|
2
3
|
import { getSeller } from '../../api/seller/getSeller.js';
|
|
3
4
|
import '../../api/seller/client.js';
|
|
4
|
-
import { decodeJwt } from '../../node_modules/jose/dist/webapi/util/decode_jwt.js';
|
|
5
5
|
|
|
6
6
|
const enrichUser = async ({ auth0User, accessToken, userHasSelectedSeller = false, }) => {
|
|
7
7
|
if (!accessToken) {
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { NextApiRequest } from 'next';
|
|
2
|
-
import { IncomingMessage } from 'http';
|
|
1
|
+
import { NextApiRequest, NextApiResponse } from 'next';
|
|
2
|
+
import { IncomingMessage, ServerResponse } from 'http';
|
|
3
3
|
import { Brand } from 'src/types/brand';
|
|
4
4
|
import { AuthProviderProps } from 'src/client/contexts/Auth';
|
|
5
5
|
import { GetAuth0InstanceContext } from '../getAuth0Instance';
|
|
6
6
|
export declare const getAuthProps: (context: GetAuth0InstanceContext & {
|
|
7
7
|
brand: Brand;
|
|
8
|
-
|
|
8
|
+
context?: {
|
|
9
|
+
request: NextApiRequest | IncomingMessage;
|
|
10
|
+
response: NextApiResponse | ServerResponse<IncomingMessage>;
|
|
11
|
+
};
|
|
9
12
|
}) => Promise<AuthProviderProps>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getAuthProps.js","sources":["../../../../../src/server/helpers/getAuthProps.ts"],"sourcesContent":[null],"names":[],"mappings":";;;MAWa,YAAY,GAAG,OAC1B,
|
|
1
|
+
{"version":3,"file":"getAuthProps.js","sources":["../../../../../src/server/helpers/getAuthProps.ts"],"sourcesContent":[null],"names":[],"mappings":";;;MAWa,YAAY,GAAG,OAC1B,OAMC,KAC6B;AAC9B,IAAA,MAAM,MAAM,GAAG,cAAc,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC;AAC/D,IAAA,MAAM,IAAI,GAAG,MAAM,eAAe,CAAC,OAAO,CAAC;AAE3C,IAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE;AACzB;;;;"}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import { NextApiRequest } from 'next';
|
|
2
|
-
import { IncomingMessage } from 'http';
|
|
1
|
+
import { NextApiRequest, NextApiResponse } from 'next';
|
|
2
|
+
import { IncomingMessage, ServerResponse } from 'http';
|
|
3
3
|
import { Brand } from 'src/types/brand';
|
|
4
4
|
import { EnrichedSessionUser, SessionUser } from 'src/types';
|
|
5
5
|
import { GetAuth0InstanceContext } from '../getAuth0Instance';
|
|
6
6
|
export declare const getUser: (context: GetAuth0InstanceContext) => Promise<SessionUser | null>;
|
|
7
|
-
export declare const getEnrichedUser: ({ brand,
|
|
7
|
+
export declare const getEnrichedUser: ({ brand, context, ...auth0context }: GetAuth0InstanceContext & {
|
|
8
8
|
brand: Brand;
|
|
9
|
-
|
|
9
|
+
context?: {
|
|
10
|
+
request: NextApiRequest | IncomingMessage;
|
|
11
|
+
response: NextApiResponse | ServerResponse<IncomingMessage>;
|
|
12
|
+
};
|
|
10
13
|
}) => Promise<EnrichedSessionUser | null>;
|
|
@@ -8,17 +8,20 @@ const getUser = async (context) => {
|
|
|
8
8
|
return null;
|
|
9
9
|
return sessionData.user;
|
|
10
10
|
};
|
|
11
|
-
const getEnrichedUser = async ({ brand,
|
|
12
|
-
const auth0Instance = getAuth0Instance(
|
|
13
|
-
const sessionData =
|
|
14
|
-
? auth0Instance.getSession(request)
|
|
15
|
-
: auth0Instance.getSession()
|
|
11
|
+
const getEnrichedUser = async ({ brand, context, ...auth0context }) => {
|
|
12
|
+
const auth0Instance = getAuth0Instance(auth0context);
|
|
13
|
+
const sessionData = context?.request
|
|
14
|
+
? await auth0Instance.getSession(context.request)
|
|
15
|
+
: await auth0Instance.getSession();
|
|
16
16
|
if (!sessionData || !sessionData.user)
|
|
17
17
|
return null;
|
|
18
18
|
const user = sessionData.user;
|
|
19
|
+
const { token } = context?.request
|
|
20
|
+
? await auth0Instance.getAccessToken(context.request, context.response)
|
|
21
|
+
: await auth0Instance.getAccessToken();
|
|
19
22
|
return enrichUser({
|
|
20
23
|
user,
|
|
21
|
-
accessToken:
|
|
24
|
+
accessToken: token,
|
|
22
25
|
brand,
|
|
23
26
|
});
|
|
24
27
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getUser.js","sources":["../../../../../src/server/helpers/getUser.ts"],"sourcesContent":[null],"names":[],"mappings":";;;MAUa,OAAO,GAAG,OACrB,OAAgC,KACD;AAC/B,IAAA,MAAM,aAAa,GAAG,gBAAgB,CAAC,OAAO,CAAC;AAC/C,IAAA,MAAM,WAAW,GAAG,MAAM,aAAa,CAAC,UAAU,EAAE;AAEpD,IAAA,IAAI,CAAC,WAAW,IAAI,CAAC,WAAW,CAAC,IAAI;AAAE,QAAA,OAAO,IAAI;IAElD,OAAO,WAAW,CAAC,IAAmB;AACxC;AAEO,MAAM,eAAe,GAAG,OAAO,EACpC,KAAK,EACL,OAAO,EACP,GAAG,
|
|
1
|
+
{"version":3,"file":"getUser.js","sources":["../../../../../src/server/helpers/getUser.ts"],"sourcesContent":[null],"names":[],"mappings":";;;MAUa,OAAO,GAAG,OACrB,OAAgC,KACD;AAC/B,IAAA,MAAM,aAAa,GAAG,gBAAgB,CAAC,OAAO,CAAC;AAC/C,IAAA,MAAM,WAAW,GAAG,MAAM,aAAa,CAAC,UAAU,EAAE;AAEpD,IAAA,IAAI,CAAC,WAAW,IAAI,CAAC,WAAW,CAAC,IAAI;AAAE,QAAA,OAAO,IAAI;IAElD,OAAO,WAAW,CAAC,IAAmB;AACxC;AAEO,MAAM,eAAe,GAAG,OAAO,EACpC,KAAK,EACL,OAAO,EACP,GAAG,YAAY,EAOhB,KAAyC;AACxC,IAAA,MAAM,aAAa,GAAG,gBAAgB,CAAC,YAAY,CAAC;AACpD,IAAA,MAAM,WAAW,GAAG,OAAO,EAAE;UACzB,MAAM,aAAa,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO;AAChD,UAAE,MAAM,aAAa,CAAC,UAAU,EAAE;AAEpC,IAAA,IAAI,CAAC,WAAW,IAAI,CAAC,WAAW,CAAC,IAAI;AAAE,QAAA,OAAO,IAAI;AAElD,IAAA,MAAM,IAAI,GAAG,WAAW,CAAC,IAAmB;AAC5C,IAAA,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE;AACzB,UAAE,MAAM,aAAa,CAAC,cAAc,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,QAAQ;AACtE,UAAE,MAAM,aAAa,CAAC,cAAc,EAAE;AACxC,IAAA,OAAO,UAAU,CAAC;QAChB,IAAI;AACJ,QAAA,WAAW,EAAE,KAAK;QAClB,KAAK;AACN,KAAA,CAAC;AACJ;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NextResponse } from 'next/server';
|
|
2
2
|
import { cookies } from 'next/headers';
|
|
3
|
-
import { decodeJwt } from '
|
|
3
|
+
import { decodeJwt } from 'jose';
|
|
4
4
|
|
|
5
5
|
const createCallbackResponse = (context, appBaseUrl) => NextResponse.redirect(new URL(context.returnTo || '/', appBaseUrl));
|
|
6
6
|
const getLocaleFromContext = ({ returnTo }, appBaseUrl) => {
|
package/dist/server.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NextRequest, NextResponse } from 'next/server';
|
|
2
2
|
import { Language } from '@smg-automotive/i18n-pkg';
|
|
3
|
-
import { NextApiRequest } from 'next';
|
|
4
|
-
import { IncomingMessage } from 'http';
|
|
3
|
+
import { NextApiRequest, NextApiResponse } from 'next';
|
|
4
|
+
import { IncomingMessage, ServerResponse } from 'http';
|
|
5
5
|
import { a as AuthProviderProps } from './Auth-DVS7k3hQ.js';
|
|
6
6
|
import { S as SessionUser } from './sessionUser-8ZPIZ_oX.js';
|
|
7
7
|
import 'react';
|
|
@@ -32,7 +32,10 @@ declare const getAccessToken: (context: GetAuth0InstanceContext) => Promise<stri
|
|
|
32
32
|
|
|
33
33
|
declare const getAuthProps: (context: GetAuth0InstanceContext & {
|
|
34
34
|
brand: Brand;
|
|
35
|
-
|
|
35
|
+
context?: {
|
|
36
|
+
request: NextApiRequest | IncomingMessage;
|
|
37
|
+
response: NextApiResponse | ServerResponse<IncomingMessage>;
|
|
38
|
+
};
|
|
36
39
|
}) => Promise<AuthProviderProps>;
|
|
37
40
|
|
|
38
41
|
declare const getUser: (context: GetAuth0InstanceContext) => Promise<SessionUser | null>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smg-automotive/auth",
|
|
3
|
-
"version": "7.1.0-auth0-update-tweaks.
|
|
3
|
+
"version": "7.1.0-auth0-update-tweaks.4",
|
|
4
4
|
"description": "SMG Automotive auth package",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -91,7 +91,8 @@
|
|
|
91
91
|
"dependencies": {
|
|
92
92
|
"@auth0/nextjs-auth0": "4.9.0",
|
|
93
93
|
"@smg-automotive/api-client-pkg": "4.5.0",
|
|
94
|
-
"@smg-automotive/i18n-pkg": "2.0.0"
|
|
94
|
+
"@smg-automotive/i18n-pkg": "2.0.0",
|
|
95
|
+
"jose": "6.1.0"
|
|
95
96
|
},
|
|
96
97
|
"peerDependencies": {
|
|
97
98
|
"next": "^15.0.0",
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
function decodeBase64(encoded) {
|
|
4
|
-
if (Uint8Array.fromBase64) {
|
|
5
|
-
return Uint8Array.fromBase64(encoded);
|
|
6
|
-
}
|
|
7
|
-
const binary = atob(encoded);
|
|
8
|
-
const bytes = new Uint8Array(binary.length);
|
|
9
|
-
for (let i = 0; i < binary.length; i++) {
|
|
10
|
-
bytes[i] = binary.charCodeAt(i);
|
|
11
|
-
}
|
|
12
|
-
return bytes;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
exports.decodeBase64 = decodeBase64;
|
|
16
|
-
//# sourceMappingURL=base64.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base64.js","sources":["../../../../../../../node_modules/jose/dist/webapi/lib/base64.js"],"sourcesContent":["export function encodeBase64(input) {\n if (Uint8Array.prototype.toBase64) {\n return input.toBase64();\n }\n const CHUNK_SIZE = 0x8000;\n const arr = [];\n for (let i = 0; i < input.length; i += CHUNK_SIZE) {\n arr.push(String.fromCharCode.apply(null, input.subarray(i, i + CHUNK_SIZE)));\n }\n return btoa(arr.join(''));\n}\nexport function decodeBase64(encoded) {\n if (Uint8Array.fromBase64) {\n return Uint8Array.fromBase64(encoded);\n }\n const binary = atob(encoded);\n const bytes = new Uint8Array(binary.length);\n for (let i = 0; i < binary.length; i++) {\n bytes[i] = binary.charCodeAt(i);\n }\n return bytes;\n}\n"],"names":[],"mappings":";;AAWO,SAAS,YAAY,CAAC,OAAO,EAAE;AACtC,IAAI,IAAI,UAAU,CAAC,UAAU,EAAE;AAC/B,QAAQ,OAAO,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC;AAC7C,IAAI;AACJ,IAAI,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC;AAChC,IAAI,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC;AAC/C,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AAC5C,QAAQ,KAAK,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;AACvC,IAAI;AACJ,IAAI,OAAO,KAAK;AAChB;;;;","x_google_ignoreList":[0]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"buffer_utils.js","sources":["../../../../../../../node_modules/jose/dist/webapi/lib/buffer_utils.js"],"sourcesContent":["export const encoder = new TextEncoder();\nexport const decoder = new TextDecoder();\nconst MAX_INT32 = 2 ** 32;\nexport function concat(...buffers) {\n const size = buffers.reduce((acc, { length }) => acc + length, 0);\n const buf = new Uint8Array(size);\n let i = 0;\n for (const buffer of buffers) {\n buf.set(buffer, i);\n i += buffer.length;\n }\n return buf;\n}\nfunction writeUInt32BE(buf, value, offset) {\n if (value < 0 || value >= MAX_INT32) {\n throw new RangeError(`value must be >= 0 and <= ${MAX_INT32 - 1}. Received ${value}`);\n }\n buf.set([value >>> 24, value >>> 16, value >>> 8, value & 0xff], offset);\n}\nexport function uint64be(value) {\n const high = Math.floor(value / MAX_INT32);\n const low = value % MAX_INT32;\n const buf = new Uint8Array(8);\n writeUInt32BE(buf, high, 0);\n writeUInt32BE(buf, low, 4);\n return buf;\n}\nexport function uint32be(value) {\n const buf = new Uint8Array(4);\n writeUInt32BE(buf, value);\n return buf;\n}\n"],"names":[],"mappings":";;AAAuB,IAAI,WAAW;AAC1B,MAAC,OAAO,GAAG,IAAI,WAAW;;;;","x_google_ignoreList":[0]}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
function isObjectLike(value) {
|
|
4
|
-
return typeof value === 'object' && value !== null;
|
|
5
|
-
}
|
|
6
|
-
var isObject = (input) => {
|
|
7
|
-
if (!isObjectLike(input) || Object.prototype.toString.call(input) !== '[object Object]') {
|
|
8
|
-
return false;
|
|
9
|
-
}
|
|
10
|
-
if (Object.getPrototypeOf(input) === null) {
|
|
11
|
-
return true;
|
|
12
|
-
}
|
|
13
|
-
let proto = input;
|
|
14
|
-
while (Object.getPrototypeOf(proto) !== null) {
|
|
15
|
-
proto = Object.getPrototypeOf(proto);
|
|
16
|
-
}
|
|
17
|
-
return Object.getPrototypeOf(input) === proto;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
module.exports = isObject;
|
|
21
|
-
//# sourceMappingURL=is_object.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is_object.js","sources":["../../../../../../../node_modules/jose/dist/webapi/lib/is_object.js"],"sourcesContent":["function isObjectLike(value) {\n return typeof value === 'object' && value !== null;\n}\nexport default (input) => {\n if (!isObjectLike(input) || Object.prototype.toString.call(input) !== '[object Object]') {\n return false;\n }\n if (Object.getPrototypeOf(input) === null) {\n return true;\n }\n let proto = input;\n while (Object.getPrototypeOf(proto) !== null) {\n proto = Object.getPrototypeOf(proto);\n }\n return Object.getPrototypeOf(input) === proto;\n};\n"],"names":[],"mappings":";;AAAA,SAAS,YAAY,CAAC,KAAK,EAAE;AAC7B,IAAI,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;AACtD;AACA,eAAe,CAAC,KAAK,KAAK;AAC1B,IAAI,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,iBAAiB,EAAE;AAC7F,QAAQ,OAAO,KAAK;AACpB,IAAI;AACJ,IAAI,IAAI,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE;AAC/C,QAAQ,OAAO,IAAI;AACnB,IAAI;AACJ,IAAI,IAAI,KAAK,GAAG,KAAK;AACrB,IAAI,OAAO,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE;AAClD,QAAQ,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC;AAC5C,IAAI;AACJ,IAAI,OAAO,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,KAAK;AACjD,CAAC;;;;","x_google_ignoreList":[0]}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var buffer_utils = require('../lib/buffer_utils.js');
|
|
4
|
-
var base64 = require('../lib/base64.js');
|
|
5
|
-
|
|
6
|
-
function decode(input) {
|
|
7
|
-
if (Uint8Array.fromBase64) {
|
|
8
|
-
return Uint8Array.fromBase64(typeof input === 'string' ? input : buffer_utils.decoder.decode(input), {
|
|
9
|
-
alphabet: 'base64url',
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
let encoded = input;
|
|
13
|
-
if (encoded instanceof Uint8Array) {
|
|
14
|
-
encoded = buffer_utils.decoder.decode(encoded);
|
|
15
|
-
}
|
|
16
|
-
encoded = encoded.replace(/-/g, '+').replace(/_/g, '/').replace(/\s/g, '');
|
|
17
|
-
try {
|
|
18
|
-
return base64.decodeBase64(encoded);
|
|
19
|
-
}
|
|
20
|
-
catch {
|
|
21
|
-
throw new TypeError('The input to be decoded is not correctly encoded.');
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
exports.decode = decode;
|
|
26
|
-
//# sourceMappingURL=base64url.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base64url.js","sources":["../../../../../../../node_modules/jose/dist/webapi/util/base64url.js"],"sourcesContent":["import { encoder, decoder } from '../lib/buffer_utils.js';\nimport { encodeBase64, decodeBase64 } from '../lib/base64.js';\nexport function decode(input) {\n if (Uint8Array.fromBase64) {\n return Uint8Array.fromBase64(typeof input === 'string' ? input : decoder.decode(input), {\n alphabet: 'base64url',\n });\n }\n let encoded = input;\n if (encoded instanceof Uint8Array) {\n encoded = decoder.decode(encoded);\n }\n encoded = encoded.replace(/-/g, '+').replace(/_/g, '/').replace(/\\s/g, '');\n try {\n return decodeBase64(encoded);\n }\n catch {\n throw new TypeError('The input to be decoded is not correctly encoded.');\n }\n}\nexport function encode(input) {\n let unencoded = input;\n if (typeof unencoded === 'string') {\n unencoded = encoder.encode(unencoded);\n }\n if (Uint8Array.prototype.toBase64) {\n return unencoded.toBase64({ alphabet: 'base64url', omitPadding: true });\n }\n return encodeBase64(unencoded).replace(/=/g, '').replace(/\\+/g, '-').replace(/\\//g, '_');\n}\n"],"names":["decoder","decodeBase64"],"mappings":";;;;;AAEO,SAAS,MAAM,CAAC,KAAK,EAAE;AAC9B,IAAI,IAAI,UAAU,CAAC,UAAU,EAAE;AAC/B,QAAQ,OAAO,UAAU,CAAC,UAAU,CAAC,OAAO,KAAK,KAAK,QAAQ,GAAG,KAAK,GAAGA,oBAAO,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;AAChG,YAAY,QAAQ,EAAE,WAAW;AACjC,SAAS,CAAC;AACV,IAAI;AACJ,IAAI,IAAI,OAAO,GAAG,KAAK;AACvB,IAAI,IAAI,OAAO,YAAY,UAAU,EAAE;AACvC,QAAQ,OAAO,GAAGA,oBAAO,CAAC,MAAM,CAAC,OAAO,CAAC;AACzC,IAAI;AACJ,IAAI,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;AAC9E,IAAI,IAAI;AACR,QAAQ,OAAOC,mBAAY,CAAC,OAAO,CAAC;AACpC,IAAI;AACJ,IAAI,MAAM;AACV,QAAQ,MAAM,IAAI,SAAS,CAAC,mDAAmD,CAAC;AAChF,IAAI;AACJ;;;;","x_google_ignoreList":[0]}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var base64url = require('./base64url.js');
|
|
4
|
-
var buffer_utils = require('../lib/buffer_utils.js');
|
|
5
|
-
var is_object = require('../lib/is_object.js');
|
|
6
|
-
var errors = require('./errors.js');
|
|
7
|
-
|
|
8
|
-
function decodeJwt(jwt) {
|
|
9
|
-
if (typeof jwt !== 'string')
|
|
10
|
-
throw new errors.JWTInvalid('JWTs must use Compact JWS serialization, JWT must be a string');
|
|
11
|
-
const { 1: payload, length } = jwt.split('.');
|
|
12
|
-
if (length === 5)
|
|
13
|
-
throw new errors.JWTInvalid('Only JWTs using Compact JWS serialization can be decoded');
|
|
14
|
-
if (length !== 3)
|
|
15
|
-
throw new errors.JWTInvalid('Invalid JWT');
|
|
16
|
-
if (!payload)
|
|
17
|
-
throw new errors.JWTInvalid('JWTs must contain a payload');
|
|
18
|
-
let decoded;
|
|
19
|
-
try {
|
|
20
|
-
decoded = base64url.decode(payload);
|
|
21
|
-
}
|
|
22
|
-
catch {
|
|
23
|
-
throw new errors.JWTInvalid('Failed to base64url decode the payload');
|
|
24
|
-
}
|
|
25
|
-
let result;
|
|
26
|
-
try {
|
|
27
|
-
result = JSON.parse(buffer_utils.decoder.decode(decoded));
|
|
28
|
-
}
|
|
29
|
-
catch {
|
|
30
|
-
throw new errors.JWTInvalid('Failed to parse the decoded payload as JSON');
|
|
31
|
-
}
|
|
32
|
-
if (!is_object(result))
|
|
33
|
-
throw new errors.JWTInvalid('Invalid JWT Claims Set');
|
|
34
|
-
return result;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
exports.decodeJwt = decodeJwt;
|
|
38
|
-
//# sourceMappingURL=decode_jwt.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"decode_jwt.js","sources":["../../../../../../../node_modules/jose/dist/webapi/util/decode_jwt.js"],"sourcesContent":["import { decode as b64u } from './base64url.js';\nimport { decoder } from '../lib/buffer_utils.js';\nimport isObject from '../lib/is_object.js';\nimport { JWTInvalid } from './errors.js';\nexport function decodeJwt(jwt) {\n if (typeof jwt !== 'string')\n throw new JWTInvalid('JWTs must use Compact JWS serialization, JWT must be a string');\n const { 1: payload, length } = jwt.split('.');\n if (length === 5)\n throw new JWTInvalid('Only JWTs using Compact JWS serialization can be decoded');\n if (length !== 3)\n throw new JWTInvalid('Invalid JWT');\n if (!payload)\n throw new JWTInvalid('JWTs must contain a payload');\n let decoded;\n try {\n decoded = b64u(payload);\n }\n catch {\n throw new JWTInvalid('Failed to base64url decode the payload');\n }\n let result;\n try {\n result = JSON.parse(decoder.decode(decoded));\n }\n catch {\n throw new JWTInvalid('Failed to parse the decoded payload as JSON');\n }\n if (!isObject(result))\n throw new JWTInvalid('Invalid JWT Claims Set');\n return result;\n}\n"],"names":["JWTInvalid","b64u","decoder","isObject"],"mappings":";;;;;;;AAIO,SAAS,SAAS,CAAC,GAAG,EAAE;AAC/B,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ;AAC/B,QAAQ,MAAM,IAAIA,iBAAU,CAAC,+DAA+D,CAAC;AAC7F,IAAI,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC;AACjD,IAAI,IAAI,MAAM,KAAK,CAAC;AACpB,QAAQ,MAAM,IAAIA,iBAAU,CAAC,0DAA0D,CAAC;AACxF,IAAI,IAAI,MAAM,KAAK,CAAC;AACpB,QAAQ,MAAM,IAAIA,iBAAU,CAAC,aAAa,CAAC;AAC3C,IAAI,IAAI,CAAC,OAAO;AAChB,QAAQ,MAAM,IAAIA,iBAAU,CAAC,6BAA6B,CAAC;AAC3D,IAAI,IAAI,OAAO;AACf,IAAI,IAAI;AACR,QAAQ,OAAO,GAAGC,gBAAI,CAAC,OAAO,CAAC;AAC/B,IAAI;AACJ,IAAI,MAAM;AACV,QAAQ,MAAM,IAAID,iBAAU,CAAC,wCAAwC,CAAC;AACtE,IAAI;AACJ,IAAI,IAAI,MAAM;AACd,IAAI,IAAI;AACR,QAAQ,MAAM,GAAG,IAAI,CAAC,KAAK,CAACE,oBAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AACpD,IAAI;AACJ,IAAI,MAAM;AACV,QAAQ,MAAM,IAAIF,iBAAU,CAAC,6CAA6C,CAAC;AAC3E,IAAI;AACJ,IAAI,IAAI,CAACG,SAAQ,CAAC,MAAM,CAAC;AACzB,QAAQ,MAAM,IAAIH,iBAAU,CAAC,wBAAwB,CAAC;AACtD,IAAI,OAAO,MAAM;AACjB;;;;","x_google_ignoreList":[0]}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
class JOSEError extends Error {
|
|
4
|
-
static code = 'ERR_JOSE_GENERIC';
|
|
5
|
-
code = 'ERR_JOSE_GENERIC';
|
|
6
|
-
constructor(message, options) {
|
|
7
|
-
super(message, options);
|
|
8
|
-
this.name = this.constructor.name;
|
|
9
|
-
Error.captureStackTrace?.(this, this.constructor);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
class JWTInvalid extends JOSEError {
|
|
13
|
-
static code = 'ERR_JWT_INVALID';
|
|
14
|
-
code = 'ERR_JWT_INVALID';
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
exports.JOSEError = JOSEError;
|
|
18
|
-
exports.JWTInvalid = JWTInvalid;
|
|
19
|
-
//# sourceMappingURL=errors.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sources":["../../../../../../../node_modules/jose/dist/webapi/util/errors.js"],"sourcesContent":["export class JOSEError extends Error {\n static code = 'ERR_JOSE_GENERIC';\n code = 'ERR_JOSE_GENERIC';\n constructor(message, options) {\n super(message, options);\n this.name = this.constructor.name;\n Error.captureStackTrace?.(this, this.constructor);\n }\n}\nexport class JWTClaimValidationFailed extends JOSEError {\n static code = 'ERR_JWT_CLAIM_VALIDATION_FAILED';\n code = 'ERR_JWT_CLAIM_VALIDATION_FAILED';\n claim;\n reason;\n payload;\n constructor(message, payload, claim = 'unspecified', reason = 'unspecified') {\n super(message, { cause: { claim, reason, payload } });\n this.claim = claim;\n this.reason = reason;\n this.payload = payload;\n }\n}\nexport class JWTExpired extends JOSEError {\n static code = 'ERR_JWT_EXPIRED';\n code = 'ERR_JWT_EXPIRED';\n claim;\n reason;\n payload;\n constructor(message, payload, claim = 'unspecified', reason = 'unspecified') {\n super(message, { cause: { claim, reason, payload } });\n this.claim = claim;\n this.reason = reason;\n this.payload = payload;\n }\n}\nexport class JOSEAlgNotAllowed extends JOSEError {\n static code = 'ERR_JOSE_ALG_NOT_ALLOWED';\n code = 'ERR_JOSE_ALG_NOT_ALLOWED';\n}\nexport class JOSENotSupported extends JOSEError {\n static code = 'ERR_JOSE_NOT_SUPPORTED';\n code = 'ERR_JOSE_NOT_SUPPORTED';\n}\nexport class JWEDecryptionFailed extends JOSEError {\n static code = 'ERR_JWE_DECRYPTION_FAILED';\n code = 'ERR_JWE_DECRYPTION_FAILED';\n constructor(message = 'decryption operation failed', options) {\n super(message, options);\n }\n}\nexport class JWEInvalid extends JOSEError {\n static code = 'ERR_JWE_INVALID';\n code = 'ERR_JWE_INVALID';\n}\nexport class JWSInvalid extends JOSEError {\n static code = 'ERR_JWS_INVALID';\n code = 'ERR_JWS_INVALID';\n}\nexport class JWTInvalid extends JOSEError {\n static code = 'ERR_JWT_INVALID';\n code = 'ERR_JWT_INVALID';\n}\nexport class JWKInvalid extends JOSEError {\n static code = 'ERR_JWK_INVALID';\n code = 'ERR_JWK_INVALID';\n}\nexport class JWKSInvalid extends JOSEError {\n static code = 'ERR_JWKS_INVALID';\n code = 'ERR_JWKS_INVALID';\n}\nexport class JWKSNoMatchingKey extends JOSEError {\n static code = 'ERR_JWKS_NO_MATCHING_KEY';\n code = 'ERR_JWKS_NO_MATCHING_KEY';\n constructor(message = 'no applicable key found in the JSON Web Key Set', options) {\n super(message, options);\n }\n}\nexport class JWKSMultipleMatchingKeys extends JOSEError {\n [Symbol.asyncIterator];\n static code = 'ERR_JWKS_MULTIPLE_MATCHING_KEYS';\n code = 'ERR_JWKS_MULTIPLE_MATCHING_KEYS';\n constructor(message = 'multiple matching keys found in the JSON Web Key Set', options) {\n super(message, options);\n }\n}\nexport class JWKSTimeout extends JOSEError {\n static code = 'ERR_JWKS_TIMEOUT';\n code = 'ERR_JWKS_TIMEOUT';\n constructor(message = 'request timed out', options) {\n super(message, options);\n }\n}\nexport class JWSSignatureVerificationFailed extends JOSEError {\n static code = 'ERR_JWS_SIGNATURE_VERIFICATION_FAILED';\n code = 'ERR_JWS_SIGNATURE_VERIFICATION_FAILED';\n constructor(message = 'signature verification failed', options) {\n super(message, options);\n }\n}\n"],"names":[],"mappings":";;AAAO,MAAM,SAAS,SAAS,KAAK,CAAC;AACrC,IAAI,OAAO,IAAI,GAAG,kBAAkB;AACpC,IAAI,IAAI,GAAG,kBAAkB;AAC7B,IAAI,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE;AAClC,QAAQ,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC;AAC/B,QAAQ,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI;AACzC,QAAQ,KAAK,CAAC,iBAAiB,GAAG,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC;AACzD,IAAI;AACJ;AAkDO,MAAM,UAAU,SAAS,SAAS,CAAC;AAC1C,IAAI,OAAO,IAAI,GAAG,iBAAiB;AACnC,IAAI,IAAI,GAAG,iBAAiB;AAC5B;;;;;","x_google_ignoreList":[0]}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
function decodeBase64(encoded) {
|
|
2
|
-
if (Uint8Array.fromBase64) {
|
|
3
|
-
return Uint8Array.fromBase64(encoded);
|
|
4
|
-
}
|
|
5
|
-
const binary = atob(encoded);
|
|
6
|
-
const bytes = new Uint8Array(binary.length);
|
|
7
|
-
for (let i = 0; i < binary.length; i++) {
|
|
8
|
-
bytes[i] = binary.charCodeAt(i);
|
|
9
|
-
}
|
|
10
|
-
return bytes;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export { decodeBase64 };
|
|
14
|
-
//# sourceMappingURL=base64.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base64.js","sources":["../../../../../../../node_modules/jose/dist/webapi/lib/base64.js"],"sourcesContent":["export function encodeBase64(input) {\n if (Uint8Array.prototype.toBase64) {\n return input.toBase64();\n }\n const CHUNK_SIZE = 0x8000;\n const arr = [];\n for (let i = 0; i < input.length; i += CHUNK_SIZE) {\n arr.push(String.fromCharCode.apply(null, input.subarray(i, i + CHUNK_SIZE)));\n }\n return btoa(arr.join(''));\n}\nexport function decodeBase64(encoded) {\n if (Uint8Array.fromBase64) {\n return Uint8Array.fromBase64(encoded);\n }\n const binary = atob(encoded);\n const bytes = new Uint8Array(binary.length);\n for (let i = 0; i < binary.length; i++) {\n bytes[i] = binary.charCodeAt(i);\n }\n return bytes;\n}\n"],"names":[],"mappings":"AAWO,SAAS,YAAY,CAAC,OAAO,EAAE;AACtC,IAAI,IAAI,UAAU,CAAC,UAAU,EAAE;AAC/B,QAAQ,OAAO,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC;AAC7C,IAAI;AACJ,IAAI,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC;AAChC,IAAI,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC;AAC/C,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AAC5C,QAAQ,KAAK,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;AACvC,IAAI;AACJ,IAAI,OAAO,KAAK;AAChB;;;;","x_google_ignoreList":[0]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"buffer_utils.js","sources":["../../../../../../../node_modules/jose/dist/webapi/lib/buffer_utils.js"],"sourcesContent":["export const encoder = new TextEncoder();\nexport const decoder = new TextDecoder();\nconst MAX_INT32 = 2 ** 32;\nexport function concat(...buffers) {\n const size = buffers.reduce((acc, { length }) => acc + length, 0);\n const buf = new Uint8Array(size);\n let i = 0;\n for (const buffer of buffers) {\n buf.set(buffer, i);\n i += buffer.length;\n }\n return buf;\n}\nfunction writeUInt32BE(buf, value, offset) {\n if (value < 0 || value >= MAX_INT32) {\n throw new RangeError(`value must be >= 0 and <= ${MAX_INT32 - 1}. Received ${value}`);\n }\n buf.set([value >>> 24, value >>> 16, value >>> 8, value & 0xff], offset);\n}\nexport function uint64be(value) {\n const high = Math.floor(value / MAX_INT32);\n const low = value % MAX_INT32;\n const buf = new Uint8Array(8);\n writeUInt32BE(buf, high, 0);\n writeUInt32BE(buf, low, 4);\n return buf;\n}\nexport function uint32be(value) {\n const buf = new Uint8Array(4);\n writeUInt32BE(buf, value);\n return buf;\n}\n"],"names":[],"mappings":"AAAuB,IAAI,WAAW;AAC1B,MAAC,OAAO,GAAG,IAAI,WAAW;;;;","x_google_ignoreList":[0]}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
function isObjectLike(value) {
|
|
2
|
-
return typeof value === 'object' && value !== null;
|
|
3
|
-
}
|
|
4
|
-
var isObject = (input) => {
|
|
5
|
-
if (!isObjectLike(input) || Object.prototype.toString.call(input) !== '[object Object]') {
|
|
6
|
-
return false;
|
|
7
|
-
}
|
|
8
|
-
if (Object.getPrototypeOf(input) === null) {
|
|
9
|
-
return true;
|
|
10
|
-
}
|
|
11
|
-
let proto = input;
|
|
12
|
-
while (Object.getPrototypeOf(proto) !== null) {
|
|
13
|
-
proto = Object.getPrototypeOf(proto);
|
|
14
|
-
}
|
|
15
|
-
return Object.getPrototypeOf(input) === proto;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export { isObject as default };
|
|
19
|
-
//# sourceMappingURL=is_object.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is_object.js","sources":["../../../../../../../node_modules/jose/dist/webapi/lib/is_object.js"],"sourcesContent":["function isObjectLike(value) {\n return typeof value === 'object' && value !== null;\n}\nexport default (input) => {\n if (!isObjectLike(input) || Object.prototype.toString.call(input) !== '[object Object]') {\n return false;\n }\n if (Object.getPrototypeOf(input) === null) {\n return true;\n }\n let proto = input;\n while (Object.getPrototypeOf(proto) !== null) {\n proto = Object.getPrototypeOf(proto);\n }\n return Object.getPrototypeOf(input) === proto;\n};\n"],"names":[],"mappings":"AAAA,SAAS,YAAY,CAAC,KAAK,EAAE;AAC7B,IAAI,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;AACtD;AACA,eAAe,CAAC,KAAK,KAAK;AAC1B,IAAI,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,iBAAiB,EAAE;AAC7F,QAAQ,OAAO,KAAK;AACpB,IAAI;AACJ,IAAI,IAAI,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE;AAC/C,QAAQ,OAAO,IAAI;AACnB,IAAI;AACJ,IAAI,IAAI,KAAK,GAAG,KAAK;AACrB,IAAI,OAAO,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE;AAClD,QAAQ,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC;AAC5C,IAAI;AACJ,IAAI,OAAO,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,KAAK;AACjD,CAAC;;;;","x_google_ignoreList":[0]}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { decoder } from '../lib/buffer_utils.js';
|
|
2
|
-
import { decodeBase64 } from '../lib/base64.js';
|
|
3
|
-
|
|
4
|
-
function decode(input) {
|
|
5
|
-
if (Uint8Array.fromBase64) {
|
|
6
|
-
return Uint8Array.fromBase64(typeof input === 'string' ? input : decoder.decode(input), {
|
|
7
|
-
alphabet: 'base64url',
|
|
8
|
-
});
|
|
9
|
-
}
|
|
10
|
-
let encoded = input;
|
|
11
|
-
if (encoded instanceof Uint8Array) {
|
|
12
|
-
encoded = decoder.decode(encoded);
|
|
13
|
-
}
|
|
14
|
-
encoded = encoded.replace(/-/g, '+').replace(/_/g, '/').replace(/\s/g, '');
|
|
15
|
-
try {
|
|
16
|
-
return decodeBase64(encoded);
|
|
17
|
-
}
|
|
18
|
-
catch {
|
|
19
|
-
throw new TypeError('The input to be decoded is not correctly encoded.');
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export { decode };
|
|
24
|
-
//# sourceMappingURL=base64url.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base64url.js","sources":["../../../../../../../node_modules/jose/dist/webapi/util/base64url.js"],"sourcesContent":["import { encoder, decoder } from '../lib/buffer_utils.js';\nimport { encodeBase64, decodeBase64 } from '../lib/base64.js';\nexport function decode(input) {\n if (Uint8Array.fromBase64) {\n return Uint8Array.fromBase64(typeof input === 'string' ? input : decoder.decode(input), {\n alphabet: 'base64url',\n });\n }\n let encoded = input;\n if (encoded instanceof Uint8Array) {\n encoded = decoder.decode(encoded);\n }\n encoded = encoded.replace(/-/g, '+').replace(/_/g, '/').replace(/\\s/g, '');\n try {\n return decodeBase64(encoded);\n }\n catch {\n throw new TypeError('The input to be decoded is not correctly encoded.');\n }\n}\nexport function encode(input) {\n let unencoded = input;\n if (typeof unencoded === 'string') {\n unencoded = encoder.encode(unencoded);\n }\n if (Uint8Array.prototype.toBase64) {\n return unencoded.toBase64({ alphabet: 'base64url', omitPadding: true });\n }\n return encodeBase64(unencoded).replace(/=/g, '').replace(/\\+/g, '-').replace(/\\//g, '_');\n}\n"],"names":[],"mappings":";;;AAEO,SAAS,MAAM,CAAC,KAAK,EAAE;AAC9B,IAAI,IAAI,UAAU,CAAC,UAAU,EAAE;AAC/B,QAAQ,OAAO,UAAU,CAAC,UAAU,CAAC,OAAO,KAAK,KAAK,QAAQ,GAAG,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;AAChG,YAAY,QAAQ,EAAE,WAAW;AACjC,SAAS,CAAC;AACV,IAAI;AACJ,IAAI,IAAI,OAAO,GAAG,KAAK;AACvB,IAAI,IAAI,OAAO,YAAY,UAAU,EAAE;AACvC,QAAQ,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC;AACzC,IAAI;AACJ,IAAI,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;AAC9E,IAAI,IAAI;AACR,QAAQ,OAAO,YAAY,CAAC,OAAO,CAAC;AACpC,IAAI;AACJ,IAAI,MAAM;AACV,QAAQ,MAAM,IAAI,SAAS,CAAC,mDAAmD,CAAC;AAChF,IAAI;AACJ;;;;","x_google_ignoreList":[0]}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { decode } from './base64url.js';
|
|
2
|
-
import { decoder } from '../lib/buffer_utils.js';
|
|
3
|
-
import isObject from '../lib/is_object.js';
|
|
4
|
-
import { JWTInvalid } from './errors.js';
|
|
5
|
-
|
|
6
|
-
function decodeJwt(jwt) {
|
|
7
|
-
if (typeof jwt !== 'string')
|
|
8
|
-
throw new JWTInvalid('JWTs must use Compact JWS serialization, JWT must be a string');
|
|
9
|
-
const { 1: payload, length } = jwt.split('.');
|
|
10
|
-
if (length === 5)
|
|
11
|
-
throw new JWTInvalid('Only JWTs using Compact JWS serialization can be decoded');
|
|
12
|
-
if (length !== 3)
|
|
13
|
-
throw new JWTInvalid('Invalid JWT');
|
|
14
|
-
if (!payload)
|
|
15
|
-
throw new JWTInvalid('JWTs must contain a payload');
|
|
16
|
-
let decoded;
|
|
17
|
-
try {
|
|
18
|
-
decoded = decode(payload);
|
|
19
|
-
}
|
|
20
|
-
catch {
|
|
21
|
-
throw new JWTInvalid('Failed to base64url decode the payload');
|
|
22
|
-
}
|
|
23
|
-
let result;
|
|
24
|
-
try {
|
|
25
|
-
result = JSON.parse(decoder.decode(decoded));
|
|
26
|
-
}
|
|
27
|
-
catch {
|
|
28
|
-
throw new JWTInvalid('Failed to parse the decoded payload as JSON');
|
|
29
|
-
}
|
|
30
|
-
if (!isObject(result))
|
|
31
|
-
throw new JWTInvalid('Invalid JWT Claims Set');
|
|
32
|
-
return result;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export { decodeJwt };
|
|
36
|
-
//# sourceMappingURL=decode_jwt.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"decode_jwt.js","sources":["../../../../../../../node_modules/jose/dist/webapi/util/decode_jwt.js"],"sourcesContent":["import { decode as b64u } from './base64url.js';\nimport { decoder } from '../lib/buffer_utils.js';\nimport isObject from '../lib/is_object.js';\nimport { JWTInvalid } from './errors.js';\nexport function decodeJwt(jwt) {\n if (typeof jwt !== 'string')\n throw new JWTInvalid('JWTs must use Compact JWS serialization, JWT must be a string');\n const { 1: payload, length } = jwt.split('.');\n if (length === 5)\n throw new JWTInvalid('Only JWTs using Compact JWS serialization can be decoded');\n if (length !== 3)\n throw new JWTInvalid('Invalid JWT');\n if (!payload)\n throw new JWTInvalid('JWTs must contain a payload');\n let decoded;\n try {\n decoded = b64u(payload);\n }\n catch {\n throw new JWTInvalid('Failed to base64url decode the payload');\n }\n let result;\n try {\n result = JSON.parse(decoder.decode(decoded));\n }\n catch {\n throw new JWTInvalid('Failed to parse the decoded payload as JSON');\n }\n if (!isObject(result))\n throw new JWTInvalid('Invalid JWT Claims Set');\n return result;\n}\n"],"names":["b64u"],"mappings":";;;;;AAIO,SAAS,SAAS,CAAC,GAAG,EAAE;AAC/B,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ;AAC/B,QAAQ,MAAM,IAAI,UAAU,CAAC,+DAA+D,CAAC;AAC7F,IAAI,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC;AACjD,IAAI,IAAI,MAAM,KAAK,CAAC;AACpB,QAAQ,MAAM,IAAI,UAAU,CAAC,0DAA0D,CAAC;AACxF,IAAI,IAAI,MAAM,KAAK,CAAC;AACpB,QAAQ,MAAM,IAAI,UAAU,CAAC,aAAa,CAAC;AAC3C,IAAI,IAAI,CAAC,OAAO;AAChB,QAAQ,MAAM,IAAI,UAAU,CAAC,6BAA6B,CAAC;AAC3D,IAAI,IAAI,OAAO;AACf,IAAI,IAAI;AACR,QAAQ,OAAO,GAAGA,MAAI,CAAC,OAAO,CAAC;AAC/B,IAAI;AACJ,IAAI,MAAM;AACV,QAAQ,MAAM,IAAI,UAAU,CAAC,wCAAwC,CAAC;AACtE,IAAI;AACJ,IAAI,IAAI,MAAM;AACd,IAAI,IAAI;AACR,QAAQ,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AACpD,IAAI;AACJ,IAAI,MAAM;AACV,QAAQ,MAAM,IAAI,UAAU,CAAC,6CAA6C,CAAC;AAC3E,IAAI;AACJ,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;AACzB,QAAQ,MAAM,IAAI,UAAU,CAAC,wBAAwB,CAAC;AACtD,IAAI,OAAO,MAAM;AACjB;;;;","x_google_ignoreList":[0]}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
class JOSEError extends Error {
|
|
2
|
-
static code = 'ERR_JOSE_GENERIC';
|
|
3
|
-
code = 'ERR_JOSE_GENERIC';
|
|
4
|
-
constructor(message, options) {
|
|
5
|
-
super(message, options);
|
|
6
|
-
this.name = this.constructor.name;
|
|
7
|
-
Error.captureStackTrace?.(this, this.constructor);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
class JWTInvalid extends JOSEError {
|
|
11
|
-
static code = 'ERR_JWT_INVALID';
|
|
12
|
-
code = 'ERR_JWT_INVALID';
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export { JOSEError, JWTInvalid };
|
|
16
|
-
//# sourceMappingURL=errors.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sources":["../../../../../../../node_modules/jose/dist/webapi/util/errors.js"],"sourcesContent":["export class JOSEError extends Error {\n static code = 'ERR_JOSE_GENERIC';\n code = 'ERR_JOSE_GENERIC';\n constructor(message, options) {\n super(message, options);\n this.name = this.constructor.name;\n Error.captureStackTrace?.(this, this.constructor);\n }\n}\nexport class JWTClaimValidationFailed extends JOSEError {\n static code = 'ERR_JWT_CLAIM_VALIDATION_FAILED';\n code = 'ERR_JWT_CLAIM_VALIDATION_FAILED';\n claim;\n reason;\n payload;\n constructor(message, payload, claim = 'unspecified', reason = 'unspecified') {\n super(message, { cause: { claim, reason, payload } });\n this.claim = claim;\n this.reason = reason;\n this.payload = payload;\n }\n}\nexport class JWTExpired extends JOSEError {\n static code = 'ERR_JWT_EXPIRED';\n code = 'ERR_JWT_EXPIRED';\n claim;\n reason;\n payload;\n constructor(message, payload, claim = 'unspecified', reason = 'unspecified') {\n super(message, { cause: { claim, reason, payload } });\n this.claim = claim;\n this.reason = reason;\n this.payload = payload;\n }\n}\nexport class JOSEAlgNotAllowed extends JOSEError {\n static code = 'ERR_JOSE_ALG_NOT_ALLOWED';\n code = 'ERR_JOSE_ALG_NOT_ALLOWED';\n}\nexport class JOSENotSupported extends JOSEError {\n static code = 'ERR_JOSE_NOT_SUPPORTED';\n code = 'ERR_JOSE_NOT_SUPPORTED';\n}\nexport class JWEDecryptionFailed extends JOSEError {\n static code = 'ERR_JWE_DECRYPTION_FAILED';\n code = 'ERR_JWE_DECRYPTION_FAILED';\n constructor(message = 'decryption operation failed', options) {\n super(message, options);\n }\n}\nexport class JWEInvalid extends JOSEError {\n static code = 'ERR_JWE_INVALID';\n code = 'ERR_JWE_INVALID';\n}\nexport class JWSInvalid extends JOSEError {\n static code = 'ERR_JWS_INVALID';\n code = 'ERR_JWS_INVALID';\n}\nexport class JWTInvalid extends JOSEError {\n static code = 'ERR_JWT_INVALID';\n code = 'ERR_JWT_INVALID';\n}\nexport class JWKInvalid extends JOSEError {\n static code = 'ERR_JWK_INVALID';\n code = 'ERR_JWK_INVALID';\n}\nexport class JWKSInvalid extends JOSEError {\n static code = 'ERR_JWKS_INVALID';\n code = 'ERR_JWKS_INVALID';\n}\nexport class JWKSNoMatchingKey extends JOSEError {\n static code = 'ERR_JWKS_NO_MATCHING_KEY';\n code = 'ERR_JWKS_NO_MATCHING_KEY';\n constructor(message = 'no applicable key found in the JSON Web Key Set', options) {\n super(message, options);\n }\n}\nexport class JWKSMultipleMatchingKeys extends JOSEError {\n [Symbol.asyncIterator];\n static code = 'ERR_JWKS_MULTIPLE_MATCHING_KEYS';\n code = 'ERR_JWKS_MULTIPLE_MATCHING_KEYS';\n constructor(message = 'multiple matching keys found in the JSON Web Key Set', options) {\n super(message, options);\n }\n}\nexport class JWKSTimeout extends JOSEError {\n static code = 'ERR_JWKS_TIMEOUT';\n code = 'ERR_JWKS_TIMEOUT';\n constructor(message = 'request timed out', options) {\n super(message, options);\n }\n}\nexport class JWSSignatureVerificationFailed extends JOSEError {\n static code = 'ERR_JWS_SIGNATURE_VERIFICATION_FAILED';\n code = 'ERR_JWS_SIGNATURE_VERIFICATION_FAILED';\n constructor(message = 'signature verification failed', options) {\n super(message, options);\n }\n}\n"],"names":[],"mappings":"AAAO,MAAM,SAAS,SAAS,KAAK,CAAC;AACrC,IAAI,OAAO,IAAI,GAAG,kBAAkB;AACpC,IAAI,IAAI,GAAG,kBAAkB;AAC7B,IAAI,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE;AAClC,QAAQ,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC;AAC/B,QAAQ,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI;AACzC,QAAQ,KAAK,CAAC,iBAAiB,GAAG,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC;AACzD,IAAI;AACJ;AAkDO,MAAM,UAAU,SAAS,SAAS,CAAC;AAC1C,IAAI,OAAO,IAAI,GAAG,iBAAiB;AACnC,IAAI,IAAI,GAAG,iBAAiB;AAC5B;;;;","x_google_ignoreList":[0]}
|