@golocalinteractive/golocal-cloud-wrapper 1.0.56 → 1.0.57
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/context/PermissionsContext.d.ts +6 -3
- package/dist/context/PermissionsContext.d.ts.map +1 -1
- package/dist/golocal-cloud-wrapper.css +1 -2
- package/dist/golocal-cloud-wrapper.es.js +9662 -88
- package/dist/golocal-cloud-wrapper.umd.js +182 -0
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/lib/auth/index.d.ts +0 -1
- package/dist/lib/auth/index.d.ts.map +1 -1
- package/package.json +1 -2
- package/dist/golocal-cloud-wrapper.es10.js +0 -66
- package/dist/golocal-cloud-wrapper.es100.js +0 -4
- package/dist/golocal-cloud-wrapper.es101.js +0 -62
- package/dist/golocal-cloud-wrapper.es102.js +0 -77
- package/dist/golocal-cloud-wrapper.es103.js +0 -4
- package/dist/golocal-cloud-wrapper.es104.js +0 -41
- package/dist/golocal-cloud-wrapper.es105.js +0 -4
- package/dist/golocal-cloud-wrapper.es106.js +0 -106
- package/dist/golocal-cloud-wrapper.es107.js +0 -148
- package/dist/golocal-cloud-wrapper.es108.js +0 -28
- package/dist/golocal-cloud-wrapper.es109.js +0 -51
- package/dist/golocal-cloud-wrapper.es11.js +0 -233
- package/dist/golocal-cloud-wrapper.es110.js +0 -25
- package/dist/golocal-cloud-wrapper.es111.js +0 -30
- package/dist/golocal-cloud-wrapper.es112.js +0 -82
- package/dist/golocal-cloud-wrapper.es113.js +0 -125
- package/dist/golocal-cloud-wrapper.es114.js +0 -39
- package/dist/golocal-cloud-wrapper.es115.js +0 -38
- package/dist/golocal-cloud-wrapper.es116.js +0 -7
- package/dist/golocal-cloud-wrapper.es117.js +0 -4
- package/dist/golocal-cloud-wrapper.es118.js +0 -4
- package/dist/golocal-cloud-wrapper.es119.js +0 -4
- package/dist/golocal-cloud-wrapper.es12.js +0 -23
- package/dist/golocal-cloud-wrapper.es120.js +0 -208
- package/dist/golocal-cloud-wrapper.es121.js +0 -145
- package/dist/golocal-cloud-wrapper.es122.js +0 -58
- package/dist/golocal-cloud-wrapper.es123.js +0 -34
- package/dist/golocal-cloud-wrapper.es124.js +0 -4
- package/dist/golocal-cloud-wrapper.es125.js +0 -39
- package/dist/golocal-cloud-wrapper.es126.js +0 -4
- package/dist/golocal-cloud-wrapper.es127.js +0 -4
- package/dist/golocal-cloud-wrapper.es128.js +0 -224
- package/dist/golocal-cloud-wrapper.es129.js +0 -4
- package/dist/golocal-cloud-wrapper.es13.js +0 -24
- package/dist/golocal-cloud-wrapper.es130.js +0 -4
- package/dist/golocal-cloud-wrapper.es131.js +0 -35
- package/dist/golocal-cloud-wrapper.es132.js +0 -4
- package/dist/golocal-cloud-wrapper.es133.js +0 -23
- package/dist/golocal-cloud-wrapper.es134.js +0 -123
- package/dist/golocal-cloud-wrapper.es135.js +0 -469
- package/dist/golocal-cloud-wrapper.es136.js +0 -46
- package/dist/golocal-cloud-wrapper.es137.js +0 -71
- package/dist/golocal-cloud-wrapper.es138.js +0 -66
- package/dist/golocal-cloud-wrapper.es139.js +0 -4
- package/dist/golocal-cloud-wrapper.es14.js +0 -115
- package/dist/golocal-cloud-wrapper.es140.js +0 -27
- package/dist/golocal-cloud-wrapper.es141.js +0 -66
- package/dist/golocal-cloud-wrapper.es142.js +0 -27
- package/dist/golocal-cloud-wrapper.es143.js +0 -5
- package/dist/golocal-cloud-wrapper.es144.js +0 -650
- package/dist/golocal-cloud-wrapper.es145.js +0 -301
- package/dist/golocal-cloud-wrapper.es146.js +0 -90
- package/dist/golocal-cloud-wrapper.es147.js +0 -83
- package/dist/golocal-cloud-wrapper.es148.js +0 -65
- package/dist/golocal-cloud-wrapper.es149.js +0 -1230
- package/dist/golocal-cloud-wrapper.es15.js +0 -641
- package/dist/golocal-cloud-wrapper.es150.js +0 -8
- package/dist/golocal-cloud-wrapper.es151.js +0 -15
- package/dist/golocal-cloud-wrapper.es152.js +0 -139
- package/dist/golocal-cloud-wrapper.es153.js +0 -23
- package/dist/golocal-cloud-wrapper.es154.js +0 -132
- package/dist/golocal-cloud-wrapper.es155.js +0 -19
- package/dist/golocal-cloud-wrapper.es156.js +0 -37
- package/dist/golocal-cloud-wrapper.es157.js +0 -49
- package/dist/golocal-cloud-wrapper.es158.js +0 -10
- package/dist/golocal-cloud-wrapper.es159.js +0 -5
- package/dist/golocal-cloud-wrapper.es16.js +0 -17
- package/dist/golocal-cloud-wrapper.es160.js +0 -35
- package/dist/golocal-cloud-wrapper.es161.js +0 -174
- package/dist/golocal-cloud-wrapper.es162.js +0 -21
- package/dist/golocal-cloud-wrapper.es163.js +0 -4
- package/dist/golocal-cloud-wrapper.es164.js +0 -330
- package/dist/golocal-cloud-wrapper.es165.js +0 -4
- package/dist/golocal-cloud-wrapper.es166.js +0 -34
- package/dist/golocal-cloud-wrapper.es167.js +0 -40
- package/dist/golocal-cloud-wrapper.es168.js +0 -30
- package/dist/golocal-cloud-wrapper.es169.js +0 -62
- package/dist/golocal-cloud-wrapper.es17.js +0 -26
- package/dist/golocal-cloud-wrapper.es170.js +0 -4
- package/dist/golocal-cloud-wrapper.es171.js +0 -340
- package/dist/golocal-cloud-wrapper.es172.js +0 -4
- package/dist/golocal-cloud-wrapper.es173.js +0 -4
- package/dist/golocal-cloud-wrapper.es174.js +0 -4
- package/dist/golocal-cloud-wrapper.es175.js +0 -4
- package/dist/golocal-cloud-wrapper.es176.js +0 -4
- package/dist/golocal-cloud-wrapper.es177.js +0 -24
- package/dist/golocal-cloud-wrapper.es178.js +0 -4
- package/dist/golocal-cloud-wrapper.es179.js +0 -24
- package/dist/golocal-cloud-wrapper.es18.js +0 -5
- package/dist/golocal-cloud-wrapper.es180.js +0 -98
- package/dist/golocal-cloud-wrapper.es181.js +0 -4
- package/dist/golocal-cloud-wrapper.es182.js +0 -46
- package/dist/golocal-cloud-wrapper.es183.js +0 -35
- package/dist/golocal-cloud-wrapper.es184.js +0 -61
- package/dist/golocal-cloud-wrapper.es185.js +0 -4
- package/dist/golocal-cloud-wrapper.es186.js +0 -4
- package/dist/golocal-cloud-wrapper.es187.js +0 -4
- package/dist/golocal-cloud-wrapper.es188.js +0 -23
- package/dist/golocal-cloud-wrapper.es189.js +0 -4
- package/dist/golocal-cloud-wrapper.es19.js +0 -110
- package/dist/golocal-cloud-wrapper.es190.js +0 -4
- package/dist/golocal-cloud-wrapper.es191.js +0 -720
- package/dist/golocal-cloud-wrapper.es192.js +0 -153
- package/dist/golocal-cloud-wrapper.es193.js +0 -166
- package/dist/golocal-cloud-wrapper.es194.js +0 -49
- package/dist/golocal-cloud-wrapper.es195.js +0 -71
- package/dist/golocal-cloud-wrapper.es196.js +0 -25
- package/dist/golocal-cloud-wrapper.es197.js +0 -5
- package/dist/golocal-cloud-wrapper.es198.js +0 -118
- package/dist/golocal-cloud-wrapper.es199.js +0 -16
- package/dist/golocal-cloud-wrapper.es20.js +0 -12
- package/dist/golocal-cloud-wrapper.es200.js +0 -4
- package/dist/golocal-cloud-wrapper.es201.js +0 -429
- package/dist/golocal-cloud-wrapper.es202.js +0 -335
- package/dist/golocal-cloud-wrapper.es203.js +0 -235
- package/dist/golocal-cloud-wrapper.es204.js +0 -38
- package/dist/golocal-cloud-wrapper.es205.js +0 -88
- package/dist/golocal-cloud-wrapper.es206.js +0 -47
- package/dist/golocal-cloud-wrapper.es207.js +0 -13
- package/dist/golocal-cloud-wrapper.es208.js +0 -19
- package/dist/golocal-cloud-wrapper.es209.js +0 -102
- package/dist/golocal-cloud-wrapper.es21.js +0 -185
- package/dist/golocal-cloud-wrapper.es210.js +0 -4
- package/dist/golocal-cloud-wrapper.es211.js +0 -4
- package/dist/golocal-cloud-wrapper.es212.js +0 -24
- package/dist/golocal-cloud-wrapper.es213.js +0 -30
- package/dist/golocal-cloud-wrapper.es214.js +0 -30
- package/dist/golocal-cloud-wrapper.es215.js +0 -34
- package/dist/golocal-cloud-wrapper.es216.js +0 -4
- package/dist/golocal-cloud-wrapper.es217.js +0 -4
- package/dist/golocal-cloud-wrapper.es218.js +0 -48
- package/dist/golocal-cloud-wrapper.es219.js +0 -33
- package/dist/golocal-cloud-wrapper.es22.js +0 -23
- package/dist/golocal-cloud-wrapper.es220.js +0 -30
- package/dist/golocal-cloud-wrapper.es221.js +0 -4
- package/dist/golocal-cloud-wrapper.es222.js +0 -4
- package/dist/golocal-cloud-wrapper.es223.js +0 -78
- package/dist/golocal-cloud-wrapper.es224.js +0 -4
- package/dist/golocal-cloud-wrapper.es225.js +0 -4
- package/dist/golocal-cloud-wrapper.es226.js +0 -4
- package/dist/golocal-cloud-wrapper.es227.js +0 -4
- package/dist/golocal-cloud-wrapper.es228.js +0 -4
- package/dist/golocal-cloud-wrapper.es229.js +0 -24
- package/dist/golocal-cloud-wrapper.es23.js +0 -38
- package/dist/golocal-cloud-wrapper.es230.js +0 -4
- package/dist/golocal-cloud-wrapper.es231.js +0 -4
- package/dist/golocal-cloud-wrapper.es232.js +0 -202
- package/dist/golocal-cloud-wrapper.es233.js +0 -97
- package/dist/golocal-cloud-wrapper.es234.js +0 -4
- package/dist/golocal-cloud-wrapper.es235.js +0 -173
- package/dist/golocal-cloud-wrapper.es236.js +0 -4
- package/dist/golocal-cloud-wrapper.es237.js +0 -21
- package/dist/golocal-cloud-wrapper.es238.js +0 -30
- package/dist/golocal-cloud-wrapper.es239.js +0 -154
- package/dist/golocal-cloud-wrapper.es24.js +0 -16
- package/dist/golocal-cloud-wrapper.es240.js +0 -131
- package/dist/golocal-cloud-wrapper.es241.js +0 -61
- package/dist/golocal-cloud-wrapper.es242.js +0 -42
- package/dist/golocal-cloud-wrapper.es243.js +0 -89
- package/dist/golocal-cloud-wrapper.es244.js +0 -24
- package/dist/golocal-cloud-wrapper.es245.js +0 -19
- package/dist/golocal-cloud-wrapper.es246.js +0 -127
- package/dist/golocal-cloud-wrapper.es247.js +0 -24
- package/dist/golocal-cloud-wrapper.es248.js +0 -33
- package/dist/golocal-cloud-wrapper.es249.js +0 -12
- package/dist/golocal-cloud-wrapper.es25.js +0 -17
- package/dist/golocal-cloud-wrapper.es250.js +0 -24
- package/dist/golocal-cloud-wrapper.es251.js +0 -17
- package/dist/golocal-cloud-wrapper.es252.js +0 -78
- package/dist/golocal-cloud-wrapper.es253.js +0 -19
- package/dist/golocal-cloud-wrapper.es254.js +0 -102
- package/dist/golocal-cloud-wrapper.es255.js +0 -29
- package/dist/golocal-cloud-wrapper.es256.js +0 -151
- package/dist/golocal-cloud-wrapper.es257.js +0 -4
- package/dist/golocal-cloud-wrapper.es258.js +0 -76
- package/dist/golocal-cloud-wrapper.es259.js +0 -92
- package/dist/golocal-cloud-wrapper.es26.js +0 -102
- package/dist/golocal-cloud-wrapper.es260.js +0 -71
- package/dist/golocal-cloud-wrapper.es261.js +0 -124
- package/dist/golocal-cloud-wrapper.es262.js +0 -35
- package/dist/golocal-cloud-wrapper.es263.js +0 -7
- package/dist/golocal-cloud-wrapper.es264.js +0 -23
- package/dist/golocal-cloud-wrapper.es265.js +0 -102
- package/dist/golocal-cloud-wrapper.es266.js +0 -106
- package/dist/golocal-cloud-wrapper.es267.js +0 -4
- package/dist/golocal-cloud-wrapper.es268.js +0 -4
- package/dist/golocal-cloud-wrapper.es269.js +0 -38
- package/dist/golocal-cloud-wrapper.es27.js +0 -45
- package/dist/golocal-cloud-wrapper.es270.js +0 -4
- package/dist/golocal-cloud-wrapper.es271.js +0 -4
- package/dist/golocal-cloud-wrapper.es272.js +0 -4
- package/dist/golocal-cloud-wrapper.es273.js +0 -4
- package/dist/golocal-cloud-wrapper.es274.js +0 -4
- package/dist/golocal-cloud-wrapper.es275.js +0 -4
- package/dist/golocal-cloud-wrapper.es276.js +0 -4
- package/dist/golocal-cloud-wrapper.es277.js +0 -11
- package/dist/golocal-cloud-wrapper.es278.js +0 -29
- package/dist/golocal-cloud-wrapper.es279.js +0 -4
- package/dist/golocal-cloud-wrapper.es28.js +0 -8
- package/dist/golocal-cloud-wrapper.es280.js +0 -4
- package/dist/golocal-cloud-wrapper.es281.js +0 -4
- package/dist/golocal-cloud-wrapper.es282.js +0 -4
- package/dist/golocal-cloud-wrapper.es283.js +0 -5
- package/dist/golocal-cloud-wrapper.es284.js +0 -36
- package/dist/golocal-cloud-wrapper.es285.js +0 -46
- package/dist/golocal-cloud-wrapper.es286.js +0 -55
- package/dist/golocal-cloud-wrapper.es287.js +0 -41
- package/dist/golocal-cloud-wrapper.es288.js +0 -70
- package/dist/golocal-cloud-wrapper.es289.js +0 -20
- package/dist/golocal-cloud-wrapper.es29.js +0 -13
- package/dist/golocal-cloud-wrapper.es290.js +0 -8
- package/dist/golocal-cloud-wrapper.es291.js +0 -4
- package/dist/golocal-cloud-wrapper.es292.js +0 -58
- package/dist/golocal-cloud-wrapper.es293.js +0 -31
- package/dist/golocal-cloud-wrapper.es294.js +0 -6
- package/dist/golocal-cloud-wrapper.es295.js +0 -11
- package/dist/golocal-cloud-wrapper.es296.js +0 -24
- package/dist/golocal-cloud-wrapper.es297.js +0 -32
- package/dist/golocal-cloud-wrapper.es298.js +0 -12
- package/dist/golocal-cloud-wrapper.es299.js +0 -10
- package/dist/golocal-cloud-wrapper.es3.js +0 -22
- package/dist/golocal-cloud-wrapper.es30.js +0 -13
- package/dist/golocal-cloud-wrapper.es300.js +0 -10
- package/dist/golocal-cloud-wrapper.es301.js +0 -159
- package/dist/golocal-cloud-wrapper.es302.js +0 -24
- package/dist/golocal-cloud-wrapper.es303.js +0 -21
- package/dist/golocal-cloud-wrapper.es304.js +0 -16
- package/dist/golocal-cloud-wrapper.es305.js +0 -48
- package/dist/golocal-cloud-wrapper.es306.js +0 -9
- package/dist/golocal-cloud-wrapper.es307.js +0 -37
- package/dist/golocal-cloud-wrapper.es308.js +0 -8
- package/dist/golocal-cloud-wrapper.es309.js +0 -9
- package/dist/golocal-cloud-wrapper.es31.js +0 -299
- package/dist/golocal-cloud-wrapper.es310.js +0 -15
- package/dist/golocal-cloud-wrapper.es32.js +0 -13
- package/dist/golocal-cloud-wrapper.es33.js +0 -13
- package/dist/golocal-cloud-wrapper.es34.js +0 -30
- package/dist/golocal-cloud-wrapper.es35.js +0 -342
- package/dist/golocal-cloud-wrapper.es36.js +0 -16
- package/dist/golocal-cloud-wrapper.es37.js +0 -16
- package/dist/golocal-cloud-wrapper.es38.js +0 -16
- package/dist/golocal-cloud-wrapper.es39.js +0 -491
- package/dist/golocal-cloud-wrapper.es4.js +0 -20
- package/dist/golocal-cloud-wrapper.es40.js +0 -17
- package/dist/golocal-cloud-wrapper.es41.js +0 -4
- package/dist/golocal-cloud-wrapper.es42.js +0 -41
- package/dist/golocal-cloud-wrapper.es43.js +0 -274
- package/dist/golocal-cloud-wrapper.es44.js +0 -4
- package/dist/golocal-cloud-wrapper.es45.js +0 -30
- package/dist/golocal-cloud-wrapper.es46.js +0 -22
- package/dist/golocal-cloud-wrapper.es47.js +0 -16
- package/dist/golocal-cloud-wrapper.es48.js +0 -18
- package/dist/golocal-cloud-wrapper.es49.js +0 -22
- package/dist/golocal-cloud-wrapper.es5.js +0 -12
- package/dist/golocal-cloud-wrapper.es50.js +0 -22
- package/dist/golocal-cloud-wrapper.es51.js +0 -26
- package/dist/golocal-cloud-wrapper.es52.js +0 -22
- package/dist/golocal-cloud-wrapper.es53.js +0 -17
- package/dist/golocal-cloud-wrapper.es54.js +0 -4
- package/dist/golocal-cloud-wrapper.es55.js +0 -4
- package/dist/golocal-cloud-wrapper.es56.js +0 -39
- package/dist/golocal-cloud-wrapper.es57.js +0 -17
- package/dist/golocal-cloud-wrapper.es58.js +0 -2959
- package/dist/golocal-cloud-wrapper.es59.js +0 -417
- package/dist/golocal-cloud-wrapper.es6.js +0 -68
- package/dist/golocal-cloud-wrapper.es60.js +0 -25
- package/dist/golocal-cloud-wrapper.es61.js +0 -28
- package/dist/golocal-cloud-wrapper.es62.js +0 -32
- package/dist/golocal-cloud-wrapper.es63.js +0 -41
- package/dist/golocal-cloud-wrapper.es64.js +0 -20
- package/dist/golocal-cloud-wrapper.es65.js +0 -11
- package/dist/golocal-cloud-wrapper.es66.js +0 -81
- package/dist/golocal-cloud-wrapper.es67.js +0 -14
- package/dist/golocal-cloud-wrapper.es68.js +0 -71
- package/dist/golocal-cloud-wrapper.es69.js +0 -212
- package/dist/golocal-cloud-wrapper.es7.js +0 -16
- package/dist/golocal-cloud-wrapper.es70.js +0 -208
- package/dist/golocal-cloud-wrapper.es71.js +0 -18
- package/dist/golocal-cloud-wrapper.es72.js +0 -129
- package/dist/golocal-cloud-wrapper.es73.js +0 -43
- package/dist/golocal-cloud-wrapper.es74.js +0 -29
- package/dist/golocal-cloud-wrapper.es75.js +0 -11
- package/dist/golocal-cloud-wrapper.es76.js +0 -122
- package/dist/golocal-cloud-wrapper.es77.js +0 -880
- package/dist/golocal-cloud-wrapper.es78.js +0 -288
- package/dist/golocal-cloud-wrapper.es79.js +0 -36
- package/dist/golocal-cloud-wrapper.es8.js +0 -48
- package/dist/golocal-cloud-wrapper.es80.js +0 -12
- package/dist/golocal-cloud-wrapper.es81.js +0 -334
- package/dist/golocal-cloud-wrapper.es82.js +0 -5
- package/dist/golocal-cloud-wrapper.es83.js +0 -8
- package/dist/golocal-cloud-wrapper.es84.js +0 -58
- package/dist/golocal-cloud-wrapper.es85.js +0 -5
- package/dist/golocal-cloud-wrapper.es86.js +0 -104
- package/dist/golocal-cloud-wrapper.es87.js +0 -468
- package/dist/golocal-cloud-wrapper.es88.js +0 -10
- package/dist/golocal-cloud-wrapper.es89.js +0 -6
- package/dist/golocal-cloud-wrapper.es9.js +0 -90
- package/dist/golocal-cloud-wrapper.es90.js +0 -14
- package/dist/golocal-cloud-wrapper.es91.js +0 -17
- package/dist/golocal-cloud-wrapper.es92.js +0 -70
- package/dist/golocal-cloud-wrapper.es93.js +0 -10
- package/dist/golocal-cloud-wrapper.es94.js +0 -227
- package/dist/golocal-cloud-wrapper.es95.js +0 -297
- package/dist/golocal-cloud-wrapper.es96.js +0 -25
- package/dist/golocal-cloud-wrapper.es97.js +0 -39
- package/dist/golocal-cloud-wrapper.es98.js +0 -616
- package/dist/golocal-cloud-wrapper.es99.js +0 -17
- package/dist/lib/auth/getUserData.d.ts +0 -7
- package/dist/lib/auth/getUserData.d.ts.map +0 -1
- package/dist/providers/PermissionsProvider.d.ts +0 -4
- package/dist/providers/PermissionsProvider.d.ts.map +0 -1
|
@@ -1,650 +0,0 @@
|
|
|
1
|
-
import { s as serverExports } from "./golocal-cloud-wrapper.es82.js";
|
|
2
|
-
import { generateRandomCodeVerifier, calculatePKCECodeChallenge, generateRandomState, generateRandomNonce, validateAuthResponse, authorizationCodeGrantRequest, allowInsecureRequests, customFetch, processAuthorizationCodeResponse, getValidatedIdTokenClaims, refreshTokenGrantRequest, processRefreshTokenResponse, discoveryRequest, processDiscoveryResponse, pushedAuthorizationRequest, processPushedAuthorizationResponse, PrivateKeyJwt, ClientSecretPost, genericTokenEndpointRequest, processGenericTokenEndpointResponse } from "./golocal-cloud-wrapper.es149.js";
|
|
3
|
-
import packageJson from "./golocal-cloud-wrapper.es150.js";
|
|
4
|
-
import { MissingStateError, InvalidStateError, AuthorizationError, OAuth2Error, AuthorizationCodeGrantRequestError, AuthorizationCodeGrantError, AccessTokenErrorCode, AccessTokenError, DiscoveryError, BackchannelLogoutError, AccessTokenForConnectionError, AccessTokenForConnectionErrorCode } from "./golocal-cloud-wrapper.es19.js";
|
|
5
|
-
import { removeTrailingSlash, ensureNoLeadingSlash, normalizeWithBasePath, ensureTrailingSlash } from "./golocal-cloud-wrapper.es60.js";
|
|
6
|
-
import { toSafeRedirect } from "./golocal-cloud-wrapper.es151.js";
|
|
7
|
-
import { addCacheControlHeadersForSession } from "./golocal-cloud-wrapper.es152.js";
|
|
8
|
-
import { filterDefaultIdTokenClaims } from "./golocal-cloud-wrapper.es153.js";
|
|
9
|
-
import { createRemoteJWKSet, jwksCache } from "./golocal-cloud-wrapper.es154.js";
|
|
10
|
-
import { jwtVerify } from "./golocal-cloud-wrapper.es155.js";
|
|
11
|
-
import { importPKCS8 } from "./golocal-cloud-wrapper.es156.js";
|
|
12
|
-
const INTERNAL_AUTHORIZE_PARAMS = [
|
|
13
|
-
"client_id",
|
|
14
|
-
"redirect_uri",
|
|
15
|
-
"response_type",
|
|
16
|
-
"code_challenge",
|
|
17
|
-
"code_challenge_method",
|
|
18
|
-
"state",
|
|
19
|
-
"nonce"
|
|
20
|
-
];
|
|
21
|
-
const DEFAULT_SCOPES = ["openid", "profile", "email", "offline_access"].join(" ");
|
|
22
|
-
const GRANT_TYPE_FEDERATED_CONNECTION_ACCESS_TOKEN = "urn:auth0:params:oauth:grant-type:token-exchange:federated-connection-access-token";
|
|
23
|
-
const SUBJECT_TYPE_REFRESH_TOKEN = "urn:ietf:params:oauth:token-type:refresh_token";
|
|
24
|
-
const REQUESTED_TOKEN_TYPE_FEDERATED_CONNECTION_ACCESS_TOKEN = "http://auth0.com/oauth/token-type/federated-connection-access-token";
|
|
25
|
-
function createRouteUrl(path, baseUrl) {
|
|
26
|
-
return new URL(ensureNoLeadingSlash(normalizeWithBasePath(path)), ensureTrailingSlash(baseUrl));
|
|
27
|
-
}
|
|
28
|
-
class AuthClient {
|
|
29
|
-
constructor(options) {
|
|
30
|
-
this.fetch = options.fetch || fetch;
|
|
31
|
-
this.jwksCache = options.jwksCache || {};
|
|
32
|
-
this.allowInsecureRequests = options.allowInsecureRequests ?? false;
|
|
33
|
-
this.httpOptions = () => {
|
|
34
|
-
const headers = new Headers();
|
|
35
|
-
const enableTelemetry = options.enableTelemetry ?? true;
|
|
36
|
-
const timeout = options.httpTimeout ?? 5e3;
|
|
37
|
-
if (enableTelemetry) {
|
|
38
|
-
const name = "nextjs-auth0";
|
|
39
|
-
const version = packageJson.version;
|
|
40
|
-
headers.set("User-Agent", `${name}/${version}`);
|
|
41
|
-
headers.set("Auth0-Client", encodeBase64(JSON.stringify({
|
|
42
|
-
name,
|
|
43
|
-
version
|
|
44
|
-
})));
|
|
45
|
-
}
|
|
46
|
-
return {
|
|
47
|
-
signal: AbortSignal.timeout(timeout),
|
|
48
|
-
headers
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
if (this.allowInsecureRequests && process.env.NODE_ENV === "production") {
|
|
52
|
-
console.warn("allowInsecureRequests is enabled in a production environment. This is not recommended.");
|
|
53
|
-
}
|
|
54
|
-
this.transactionStore = options.transactionStore;
|
|
55
|
-
this.sessionStore = options.sessionStore;
|
|
56
|
-
this.domain = options.domain;
|
|
57
|
-
this.clientMetadata = { client_id: options.clientId };
|
|
58
|
-
this.clientSecret = options.clientSecret;
|
|
59
|
-
this.authorizationParameters = options.authorizationParameters || {
|
|
60
|
-
scope: DEFAULT_SCOPES
|
|
61
|
-
};
|
|
62
|
-
this.pushedAuthorizationRequests = options.pushedAuthorizationRequests ?? false;
|
|
63
|
-
this.clientAssertionSigningKey = options.clientAssertionSigningKey;
|
|
64
|
-
this.clientAssertionSigningAlg = options.clientAssertionSigningAlg || "RS256";
|
|
65
|
-
if (!this.authorizationParameters.scope) {
|
|
66
|
-
this.authorizationParameters.scope = DEFAULT_SCOPES;
|
|
67
|
-
}
|
|
68
|
-
const scope = this.authorizationParameters.scope.split(" ").map((s) => s.trim());
|
|
69
|
-
if (!scope.includes("openid")) {
|
|
70
|
-
throw new Error("The 'openid' scope must be included in the set of scopes. See https://auth0.com/docs");
|
|
71
|
-
}
|
|
72
|
-
this.appBaseUrl = options.appBaseUrl;
|
|
73
|
-
this.signInReturnToPath = options.signInReturnToPath || "/";
|
|
74
|
-
this.beforeSessionSaved = options.beforeSessionSaved;
|
|
75
|
-
this.onCallback = options.onCallback || this.defaultOnCallback;
|
|
76
|
-
this.routes = {
|
|
77
|
-
login: "/auth/login",
|
|
78
|
-
logout: "/auth/logout",
|
|
79
|
-
callback: "/auth/callback",
|
|
80
|
-
backChannelLogout: "/auth/backchannel-logout",
|
|
81
|
-
profile: process.env.NEXT_PUBLIC_PROFILE_ROUTE || "/auth/profile",
|
|
82
|
-
accessToken: process.env.NEXT_PUBLIC_ACCESS_TOKEN_ROUTE || "/auth/access-token",
|
|
83
|
-
...options.routes
|
|
84
|
-
};
|
|
85
|
-
this.enableAccessTokenEndpoint = options.enableAccessTokenEndpoint ?? true;
|
|
86
|
-
this.noContentProfileResponseWhenUnauthenticated = options.noContentProfileResponseWhenUnauthenticated ?? false;
|
|
87
|
-
}
|
|
88
|
-
async handler(req) {
|
|
89
|
-
const { pathname } = req.nextUrl;
|
|
90
|
-
const sanitizedPathname = removeTrailingSlash(pathname);
|
|
91
|
-
const method = req.method;
|
|
92
|
-
if (method === "GET" && sanitizedPathname === this.routes.login) {
|
|
93
|
-
return this.handleLogin(req);
|
|
94
|
-
} else if (method === "GET" && sanitizedPathname === this.routes.logout) {
|
|
95
|
-
return this.handleLogout(req);
|
|
96
|
-
} else if (method === "GET" && sanitizedPathname === this.routes.callback) {
|
|
97
|
-
return this.handleCallback(req);
|
|
98
|
-
} else if (method === "GET" && sanitizedPathname === this.routes.profile) {
|
|
99
|
-
return this.handleProfile(req);
|
|
100
|
-
} else if (method === "GET" && sanitizedPathname === this.routes.accessToken && this.enableAccessTokenEndpoint) {
|
|
101
|
-
return this.handleAccessToken(req);
|
|
102
|
-
} else if (method === "POST" && sanitizedPathname === this.routes.backChannelLogout) {
|
|
103
|
-
return this.handleBackChannelLogout(req);
|
|
104
|
-
} else {
|
|
105
|
-
const res = serverExports.NextResponse.next();
|
|
106
|
-
const session = await this.sessionStore.get(req.cookies);
|
|
107
|
-
if (session) {
|
|
108
|
-
await this.sessionStore.set(req.cookies, res.cookies, {
|
|
109
|
-
...session
|
|
110
|
-
});
|
|
111
|
-
addCacheControlHeadersForSession(res);
|
|
112
|
-
}
|
|
113
|
-
return res;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
async startInteractiveLogin(options = {}) {
|
|
117
|
-
const redirectUri = createRouteUrl(this.routes.callback, this.appBaseUrl);
|
|
118
|
-
let returnTo = this.signInReturnToPath;
|
|
119
|
-
if (options.returnTo) {
|
|
120
|
-
const safeBaseUrl = new URL(this.authorizationParameters.redirect_uri || this.appBaseUrl);
|
|
121
|
-
const sanitizedReturnTo = toSafeRedirect(options.returnTo, safeBaseUrl);
|
|
122
|
-
if (sanitizedReturnTo) {
|
|
123
|
-
returnTo = sanitizedReturnTo.pathname + sanitizedReturnTo.search + sanitizedReturnTo.hash;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
const codeChallengeMethod = "S256";
|
|
127
|
-
const codeVerifier = generateRandomCodeVerifier();
|
|
128
|
-
const codeChallenge = await calculatePKCECodeChallenge(codeVerifier);
|
|
129
|
-
const state = generateRandomState();
|
|
130
|
-
const nonce = generateRandomNonce();
|
|
131
|
-
const authorizationParams = new URLSearchParams();
|
|
132
|
-
authorizationParams.set("client_id", this.clientMetadata.client_id);
|
|
133
|
-
authorizationParams.set("redirect_uri", redirectUri.toString());
|
|
134
|
-
authorizationParams.set("response_type", "code");
|
|
135
|
-
authorizationParams.set("code_challenge", codeChallenge);
|
|
136
|
-
authorizationParams.set("code_challenge_method", codeChallengeMethod);
|
|
137
|
-
authorizationParams.set("state", state);
|
|
138
|
-
authorizationParams.set("nonce", nonce);
|
|
139
|
-
const mergedAuthorizationParams = {
|
|
140
|
-
// any custom params to forward to /authorize defined as configuration
|
|
141
|
-
...this.authorizationParameters,
|
|
142
|
-
// custom parameters passed in via the query params to ensure only the confidential client can set them
|
|
143
|
-
...options.authorizationParameters
|
|
144
|
-
};
|
|
145
|
-
Object.entries(mergedAuthorizationParams).forEach(([key, val]) => {
|
|
146
|
-
if (!INTERNAL_AUTHORIZE_PARAMS.includes(key) && val != null) {
|
|
147
|
-
authorizationParams.set(key, String(val));
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
const transactionState = {
|
|
151
|
-
nonce,
|
|
152
|
-
maxAge: this.authorizationParameters.max_age,
|
|
153
|
-
codeVerifier,
|
|
154
|
-
responseType: "code",
|
|
155
|
-
state,
|
|
156
|
-
returnTo
|
|
157
|
-
};
|
|
158
|
-
const [error, authorizationUrl] = await this.authorizationUrl(authorizationParams);
|
|
159
|
-
if (error) {
|
|
160
|
-
return new serverExports.NextResponse("An error occured while trying to initiate the login request.", {
|
|
161
|
-
status: 500
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
const res = serverExports.NextResponse.redirect(authorizationUrl.toString());
|
|
165
|
-
await this.transactionStore.save(res.cookies, transactionState);
|
|
166
|
-
return res;
|
|
167
|
-
}
|
|
168
|
-
async handleLogin(req) {
|
|
169
|
-
const searchParams = Object.fromEntries(req.nextUrl.searchParams.entries());
|
|
170
|
-
const options = {
|
|
171
|
-
// SECURITY CRITICAL: Only forward query params when PAR is disabled
|
|
172
|
-
authorizationParameters: !this.pushedAuthorizationRequests ? searchParams : {},
|
|
173
|
-
returnTo: searchParams.returnTo
|
|
174
|
-
};
|
|
175
|
-
return this.startInteractiveLogin(options);
|
|
176
|
-
}
|
|
177
|
-
async handleLogout(req) {
|
|
178
|
-
const session = await this.sessionStore.get(req.cookies);
|
|
179
|
-
const [discoveryError, authorizationServerMetadata] = await this.discoverAuthorizationServerMetadata();
|
|
180
|
-
if (discoveryError) {
|
|
181
|
-
return new serverExports.NextResponse("An error occured while trying to initiate the logout request.", {
|
|
182
|
-
status: 500
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
const returnTo = req.nextUrl.searchParams.get("returnTo") || this.appBaseUrl;
|
|
186
|
-
if (!authorizationServerMetadata.end_session_endpoint) {
|
|
187
|
-
console.warn("The Auth0 client does not have RP-initiated logout enabled, the user will be redirected to the `/v2/logout` endpoint instead. Learn how to enable it here: https://auth0.com/docs/authenticate/login/logout/log-users-out-of-auth0#enable-endpoint-discovery");
|
|
188
|
-
const url2 = new URL("/v2/logout", this.issuer);
|
|
189
|
-
url2.searchParams.set("returnTo", returnTo);
|
|
190
|
-
url2.searchParams.set("client_id", this.clientMetadata.client_id);
|
|
191
|
-
const res2 = serverExports.NextResponse.redirect(url2);
|
|
192
|
-
await this.sessionStore.delete(req.cookies, res2.cookies);
|
|
193
|
-
await this.transactionStore.deleteAll(req.cookies, res2.cookies);
|
|
194
|
-
return res2;
|
|
195
|
-
}
|
|
196
|
-
const url = new URL(authorizationServerMetadata.end_session_endpoint);
|
|
197
|
-
url.searchParams.set("client_id", this.clientMetadata.client_id);
|
|
198
|
-
url.searchParams.set("post_logout_redirect_uri", returnTo);
|
|
199
|
-
if (session == null ? void 0 : session.internal.sid) {
|
|
200
|
-
url.searchParams.set("logout_hint", session.internal.sid);
|
|
201
|
-
}
|
|
202
|
-
if (session == null ? void 0 : session.tokenSet.idToken) {
|
|
203
|
-
url.searchParams.set("id_token_hint", session == null ? void 0 : session.tokenSet.idToken);
|
|
204
|
-
}
|
|
205
|
-
const res = serverExports.NextResponse.redirect(url);
|
|
206
|
-
await this.sessionStore.delete(req.cookies, res.cookies);
|
|
207
|
-
addCacheControlHeadersForSession(res);
|
|
208
|
-
await this.transactionStore.deleteAll(req.cookies, res.cookies);
|
|
209
|
-
return res;
|
|
210
|
-
}
|
|
211
|
-
async handleCallback(req) {
|
|
212
|
-
const state = req.nextUrl.searchParams.get("state");
|
|
213
|
-
if (!state) {
|
|
214
|
-
return this.onCallback(new MissingStateError(), {}, null);
|
|
215
|
-
}
|
|
216
|
-
const transactionStateCookie = await this.transactionStore.get(req.cookies, state);
|
|
217
|
-
if (!transactionStateCookie) {
|
|
218
|
-
return this.onCallback(new InvalidStateError(), {}, null);
|
|
219
|
-
}
|
|
220
|
-
const transactionState = transactionStateCookie.payload;
|
|
221
|
-
const onCallbackCtx = {
|
|
222
|
-
returnTo: transactionState.returnTo
|
|
223
|
-
};
|
|
224
|
-
const [discoveryError, authorizationServerMetadata] = await this.discoverAuthorizationServerMetadata();
|
|
225
|
-
if (discoveryError) {
|
|
226
|
-
return this.onCallback(discoveryError, onCallbackCtx, null);
|
|
227
|
-
}
|
|
228
|
-
let codeGrantParams;
|
|
229
|
-
try {
|
|
230
|
-
codeGrantParams = validateAuthResponse(authorizationServerMetadata, this.clientMetadata, req.nextUrl.searchParams, transactionState.state);
|
|
231
|
-
} catch (e) {
|
|
232
|
-
return this.onCallback(new AuthorizationError({
|
|
233
|
-
cause: new OAuth2Error({
|
|
234
|
-
code: e.error,
|
|
235
|
-
message: e.error_description
|
|
236
|
-
})
|
|
237
|
-
}), onCallbackCtx, null);
|
|
238
|
-
}
|
|
239
|
-
let codeGrantResponse;
|
|
240
|
-
try {
|
|
241
|
-
const redirectUri = createRouteUrl(this.routes.callback, this.appBaseUrl);
|
|
242
|
-
codeGrantResponse = await authorizationCodeGrantRequest(authorizationServerMetadata, this.clientMetadata, await this.getClientAuth(), codeGrantParams, redirectUri.toString(), transactionState.codeVerifier, {
|
|
243
|
-
...this.httpOptions(),
|
|
244
|
-
[customFetch]: this.fetch,
|
|
245
|
-
[allowInsecureRequests]: this.allowInsecureRequests
|
|
246
|
-
});
|
|
247
|
-
} catch (e) {
|
|
248
|
-
return this.onCallback(new AuthorizationCodeGrantRequestError(e.message), onCallbackCtx, null);
|
|
249
|
-
}
|
|
250
|
-
let oidcRes;
|
|
251
|
-
try {
|
|
252
|
-
oidcRes = await processAuthorizationCodeResponse(authorizationServerMetadata, this.clientMetadata, codeGrantResponse, {
|
|
253
|
-
expectedNonce: transactionState.nonce,
|
|
254
|
-
maxAge: transactionState.maxAge,
|
|
255
|
-
requireIdToken: true
|
|
256
|
-
});
|
|
257
|
-
} catch (e) {
|
|
258
|
-
return this.onCallback(new AuthorizationCodeGrantError({
|
|
259
|
-
cause: new OAuth2Error({
|
|
260
|
-
code: e.error,
|
|
261
|
-
message: e.error_description
|
|
262
|
-
})
|
|
263
|
-
}), onCallbackCtx, null);
|
|
264
|
-
}
|
|
265
|
-
const idTokenClaims = getValidatedIdTokenClaims(oidcRes);
|
|
266
|
-
let session = {
|
|
267
|
-
user: idTokenClaims,
|
|
268
|
-
tokenSet: {
|
|
269
|
-
accessToken: oidcRes.access_token,
|
|
270
|
-
idToken: oidcRes.id_token,
|
|
271
|
-
scope: oidcRes.scope,
|
|
272
|
-
refreshToken: oidcRes.refresh_token,
|
|
273
|
-
expiresAt: Math.floor(Date.now() / 1e3) + Number(oidcRes.expires_in)
|
|
274
|
-
},
|
|
275
|
-
internal: {
|
|
276
|
-
sid: idTokenClaims.sid,
|
|
277
|
-
createdAt: Math.floor(Date.now() / 1e3)
|
|
278
|
-
}
|
|
279
|
-
};
|
|
280
|
-
const res = await this.onCallback(null, onCallbackCtx, session);
|
|
281
|
-
if (this.beforeSessionSaved) {
|
|
282
|
-
const updatedSession = await this.beforeSessionSaved(session, oidcRes.id_token ?? null);
|
|
283
|
-
session = {
|
|
284
|
-
...updatedSession,
|
|
285
|
-
internal: session.internal
|
|
286
|
-
};
|
|
287
|
-
} else {
|
|
288
|
-
session.user = filterDefaultIdTokenClaims(idTokenClaims);
|
|
289
|
-
}
|
|
290
|
-
await this.sessionStore.set(req.cookies, res.cookies, session, true);
|
|
291
|
-
addCacheControlHeadersForSession(res);
|
|
292
|
-
await this.transactionStore.delete(res.cookies, state);
|
|
293
|
-
return res;
|
|
294
|
-
}
|
|
295
|
-
async handleProfile(req) {
|
|
296
|
-
const session = await this.sessionStore.get(req.cookies);
|
|
297
|
-
if (!session) {
|
|
298
|
-
if (this.noContentProfileResponseWhenUnauthenticated) {
|
|
299
|
-
return new serverExports.NextResponse(null, {
|
|
300
|
-
status: 204
|
|
301
|
-
});
|
|
302
|
-
}
|
|
303
|
-
return new serverExports.NextResponse(null, {
|
|
304
|
-
status: 401
|
|
305
|
-
});
|
|
306
|
-
}
|
|
307
|
-
const res = serverExports.NextResponse.json(session == null ? void 0 : session.user);
|
|
308
|
-
addCacheControlHeadersForSession(res);
|
|
309
|
-
return res;
|
|
310
|
-
}
|
|
311
|
-
async handleAccessToken(req) {
|
|
312
|
-
const session = await this.sessionStore.get(req.cookies);
|
|
313
|
-
if (!session) {
|
|
314
|
-
return serverExports.NextResponse.json({
|
|
315
|
-
error: {
|
|
316
|
-
message: "The user does not have an active session.",
|
|
317
|
-
code: AccessTokenErrorCode.MISSING_SESSION
|
|
318
|
-
}
|
|
319
|
-
}, {
|
|
320
|
-
status: 401
|
|
321
|
-
});
|
|
322
|
-
}
|
|
323
|
-
const [error, updatedTokenSet] = await this.getTokenSet(session.tokenSet);
|
|
324
|
-
if (error) {
|
|
325
|
-
return serverExports.NextResponse.json({
|
|
326
|
-
error: {
|
|
327
|
-
message: error.message,
|
|
328
|
-
code: error.code
|
|
329
|
-
}
|
|
330
|
-
}, {
|
|
331
|
-
status: 401
|
|
332
|
-
});
|
|
333
|
-
}
|
|
334
|
-
const res = serverExports.NextResponse.json({
|
|
335
|
-
token: updatedTokenSet.accessToken,
|
|
336
|
-
scope: updatedTokenSet.scope,
|
|
337
|
-
expires_at: updatedTokenSet.expiresAt
|
|
338
|
-
});
|
|
339
|
-
if (updatedTokenSet.accessToken !== session.tokenSet.accessToken || updatedTokenSet.refreshToken !== session.tokenSet.refreshToken || updatedTokenSet.expiresAt !== session.tokenSet.expiresAt) {
|
|
340
|
-
await this.sessionStore.set(req.cookies, res.cookies, {
|
|
341
|
-
...session,
|
|
342
|
-
tokenSet: updatedTokenSet
|
|
343
|
-
});
|
|
344
|
-
addCacheControlHeadersForSession(res);
|
|
345
|
-
}
|
|
346
|
-
return res;
|
|
347
|
-
}
|
|
348
|
-
async handleBackChannelLogout(req) {
|
|
349
|
-
if (!this.sessionStore.store) {
|
|
350
|
-
return new serverExports.NextResponse("A session data store is not configured.", {
|
|
351
|
-
status: 500
|
|
352
|
-
});
|
|
353
|
-
}
|
|
354
|
-
if (!this.sessionStore.store.deleteByLogoutToken) {
|
|
355
|
-
return new serverExports.NextResponse("Back-channel logout is not supported by the session data store.", {
|
|
356
|
-
status: 500
|
|
357
|
-
});
|
|
358
|
-
}
|
|
359
|
-
const body = new URLSearchParams(await req.text());
|
|
360
|
-
const logoutToken = body.get("logout_token");
|
|
361
|
-
if (!logoutToken) {
|
|
362
|
-
return new serverExports.NextResponse("Missing `logout_token` in the request body.", {
|
|
363
|
-
status: 400
|
|
364
|
-
});
|
|
365
|
-
}
|
|
366
|
-
const [error, logoutTokenClaims] = await this.verifyLogoutToken(logoutToken);
|
|
367
|
-
if (error) {
|
|
368
|
-
return new serverExports.NextResponse(error.message, {
|
|
369
|
-
status: 400
|
|
370
|
-
});
|
|
371
|
-
}
|
|
372
|
-
await this.sessionStore.store.deleteByLogoutToken(logoutTokenClaims);
|
|
373
|
-
return new serverExports.NextResponse(null, {
|
|
374
|
-
status: 204
|
|
375
|
-
});
|
|
376
|
-
}
|
|
377
|
-
/**
|
|
378
|
-
* getTokenSet returns a valid token set. If the access token has expired, it will attempt to
|
|
379
|
-
* refresh it using the refresh token, if available.
|
|
380
|
-
*/
|
|
381
|
-
async getTokenSet(tokenSet, forceRefresh) {
|
|
382
|
-
if (!tokenSet.refreshToken && tokenSet.expiresAt <= Date.now() / 1e3) {
|
|
383
|
-
return [
|
|
384
|
-
new AccessTokenError(AccessTokenErrorCode.MISSING_REFRESH_TOKEN, "The access token has expired and a refresh token was not provided. The user needs to re-authenticate."),
|
|
385
|
-
null
|
|
386
|
-
];
|
|
387
|
-
}
|
|
388
|
-
if (tokenSet.refreshToken) {
|
|
389
|
-
if (forceRefresh || tokenSet.expiresAt <= Date.now() / 1e3) {
|
|
390
|
-
const [discoveryError, authorizationServerMetadata] = await this.discoverAuthorizationServerMetadata();
|
|
391
|
-
if (discoveryError) {
|
|
392
|
-
return [discoveryError, null];
|
|
393
|
-
}
|
|
394
|
-
const refreshTokenRes = await refreshTokenGrantRequest(authorizationServerMetadata, this.clientMetadata, await this.getClientAuth(), tokenSet.refreshToken, {
|
|
395
|
-
...this.httpOptions(),
|
|
396
|
-
[customFetch]: this.fetch,
|
|
397
|
-
[allowInsecureRequests]: this.allowInsecureRequests
|
|
398
|
-
});
|
|
399
|
-
let oauthRes;
|
|
400
|
-
try {
|
|
401
|
-
oauthRes = await processRefreshTokenResponse(authorizationServerMetadata, this.clientMetadata, refreshTokenRes);
|
|
402
|
-
} catch (e) {
|
|
403
|
-
return [
|
|
404
|
-
new AccessTokenError(AccessTokenErrorCode.FAILED_TO_REFRESH_TOKEN, "The access token has expired and there was an error while trying to refresh it.", new OAuth2Error({
|
|
405
|
-
code: e.error,
|
|
406
|
-
message: e.error_description
|
|
407
|
-
})),
|
|
408
|
-
null
|
|
409
|
-
];
|
|
410
|
-
}
|
|
411
|
-
const accessTokenExpiresAt = Math.floor(Date.now() / 1e3) + Number(oauthRes.expires_in);
|
|
412
|
-
const updatedTokenSet = {
|
|
413
|
-
...tokenSet,
|
|
414
|
-
// contains the existing `iat` claim to maintain the session lifetime
|
|
415
|
-
accessToken: oauthRes.access_token,
|
|
416
|
-
idToken: oauthRes.id_token,
|
|
417
|
-
expiresAt: accessTokenExpiresAt
|
|
418
|
-
};
|
|
419
|
-
if (oauthRes.refresh_token) {
|
|
420
|
-
updatedTokenSet.refreshToken = oauthRes.refresh_token;
|
|
421
|
-
} else {
|
|
422
|
-
updatedTokenSet.refreshToken = tokenSet.refreshToken;
|
|
423
|
-
}
|
|
424
|
-
return [null, updatedTokenSet];
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
return [null, tokenSet];
|
|
428
|
-
}
|
|
429
|
-
async discoverAuthorizationServerMetadata() {
|
|
430
|
-
if (this.authorizationServerMetadata) {
|
|
431
|
-
return [null, this.authorizationServerMetadata];
|
|
432
|
-
}
|
|
433
|
-
const issuer = new URL(this.issuer);
|
|
434
|
-
try {
|
|
435
|
-
const authorizationServerMetadata = await discoveryRequest(issuer, {
|
|
436
|
-
...this.httpOptions(),
|
|
437
|
-
[customFetch]: this.fetch,
|
|
438
|
-
[allowInsecureRequests]: this.allowInsecureRequests
|
|
439
|
-
}).then((response) => processDiscoveryResponse(issuer, response));
|
|
440
|
-
this.authorizationServerMetadata = authorizationServerMetadata;
|
|
441
|
-
return [null, authorizationServerMetadata];
|
|
442
|
-
} catch (e) {
|
|
443
|
-
console.error(`An error occured while performing the discovery request. issuer=${issuer.toString()}, error:`, e);
|
|
444
|
-
return [
|
|
445
|
-
new DiscoveryError("Discovery failed for the OpenID Connect configuration."),
|
|
446
|
-
null
|
|
447
|
-
];
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
async defaultOnCallback(error, ctx) {
|
|
451
|
-
if (error) {
|
|
452
|
-
return new serverExports.NextResponse(error.message, {
|
|
453
|
-
status: 500
|
|
454
|
-
});
|
|
455
|
-
}
|
|
456
|
-
const res = serverExports.NextResponse.redirect(createRouteUrl(ctx.returnTo || "/", this.appBaseUrl));
|
|
457
|
-
return res;
|
|
458
|
-
}
|
|
459
|
-
async verifyLogoutToken(logoutToken) {
|
|
460
|
-
const [discoveryError, authorizationServerMetadata] = await this.discoverAuthorizationServerMetadata();
|
|
461
|
-
if (discoveryError) {
|
|
462
|
-
return [discoveryError, null];
|
|
463
|
-
}
|
|
464
|
-
const ID_TOKEN_SIGNING_ALG = "RS256";
|
|
465
|
-
const keyInput = createRemoteJWKSet(new URL(authorizationServerMetadata.jwks_uri), {
|
|
466
|
-
[jwksCache]: this.jwksCache
|
|
467
|
-
});
|
|
468
|
-
const { payload } = await jwtVerify(logoutToken, keyInput, {
|
|
469
|
-
issuer: authorizationServerMetadata.issuer,
|
|
470
|
-
audience: this.clientMetadata.client_id,
|
|
471
|
-
algorithms: [ID_TOKEN_SIGNING_ALG],
|
|
472
|
-
requiredClaims: ["iat"]
|
|
473
|
-
});
|
|
474
|
-
if (!("sid" in payload) && !("sub" in payload)) {
|
|
475
|
-
return [
|
|
476
|
-
new BackchannelLogoutError('either "sid" or "sub" (or both) claims must be present'),
|
|
477
|
-
null
|
|
478
|
-
];
|
|
479
|
-
}
|
|
480
|
-
if ("sid" in payload && typeof payload.sid !== "string") {
|
|
481
|
-
return [new BackchannelLogoutError('"sid" claim must be a string'), null];
|
|
482
|
-
}
|
|
483
|
-
if ("sub" in payload && typeof payload.sub !== "string") {
|
|
484
|
-
return [new BackchannelLogoutError('"sub" claim must be a string'), null];
|
|
485
|
-
}
|
|
486
|
-
if ("nonce" in payload) {
|
|
487
|
-
return [new BackchannelLogoutError('"nonce" claim is prohibited'), null];
|
|
488
|
-
}
|
|
489
|
-
if (!("events" in payload)) {
|
|
490
|
-
return [new BackchannelLogoutError('"events" claim is missing'), null];
|
|
491
|
-
}
|
|
492
|
-
if (typeof payload.events !== "object" || payload.events === null) {
|
|
493
|
-
return [
|
|
494
|
-
new BackchannelLogoutError('"events" claim must be an object'),
|
|
495
|
-
null
|
|
496
|
-
];
|
|
497
|
-
}
|
|
498
|
-
if (!("http://schemas.openid.net/event/backchannel-logout" in payload.events)) {
|
|
499
|
-
return [
|
|
500
|
-
new BackchannelLogoutError('"http://schemas.openid.net/event/backchannel-logout" member is missing in the "events" claim'),
|
|
501
|
-
null
|
|
502
|
-
];
|
|
503
|
-
}
|
|
504
|
-
if (typeof payload.events["http://schemas.openid.net/event/backchannel-logout"] !== "object") {
|
|
505
|
-
return [
|
|
506
|
-
new BackchannelLogoutError('"http://schemas.openid.net/event/backchannel-logout" member in the "events" claim must be an object'),
|
|
507
|
-
null
|
|
508
|
-
];
|
|
509
|
-
}
|
|
510
|
-
return [
|
|
511
|
-
null,
|
|
512
|
-
{
|
|
513
|
-
sid: payload.sid,
|
|
514
|
-
sub: payload.sub
|
|
515
|
-
}
|
|
516
|
-
];
|
|
517
|
-
}
|
|
518
|
-
async authorizationUrl(params) {
|
|
519
|
-
const [discoveryError, authorizationServerMetadata] = await this.discoverAuthorizationServerMetadata();
|
|
520
|
-
if (discoveryError) {
|
|
521
|
-
return [discoveryError, null];
|
|
522
|
-
}
|
|
523
|
-
if (this.pushedAuthorizationRequests && !authorizationServerMetadata.pushed_authorization_request_endpoint) {
|
|
524
|
-
console.error("The Auth0 tenant does not have pushed authorization requests enabled. Learn how to enable it here: https://auth0.com/docs/get-started/applications/configure-par");
|
|
525
|
-
return [
|
|
526
|
-
new Error("The authorization server does not support pushed authorization requests."),
|
|
527
|
-
null
|
|
528
|
-
];
|
|
529
|
-
}
|
|
530
|
-
const authorizationUrl = new URL(authorizationServerMetadata.authorization_endpoint);
|
|
531
|
-
if (this.pushedAuthorizationRequests) {
|
|
532
|
-
const response = await pushedAuthorizationRequest(authorizationServerMetadata, this.clientMetadata, await this.getClientAuth(), params, {
|
|
533
|
-
...this.httpOptions(),
|
|
534
|
-
[customFetch]: this.fetch,
|
|
535
|
-
[allowInsecureRequests]: this.allowInsecureRequests
|
|
536
|
-
});
|
|
537
|
-
let parRes;
|
|
538
|
-
try {
|
|
539
|
-
parRes = await processPushedAuthorizationResponse(authorizationServerMetadata, this.clientMetadata, response);
|
|
540
|
-
} catch (e) {
|
|
541
|
-
return [
|
|
542
|
-
new AuthorizationError({
|
|
543
|
-
cause: new OAuth2Error({
|
|
544
|
-
code: e.error,
|
|
545
|
-
message: e.error_description
|
|
546
|
-
}),
|
|
547
|
-
message: "An error occured while pushing the authorization request."
|
|
548
|
-
}),
|
|
549
|
-
null
|
|
550
|
-
];
|
|
551
|
-
}
|
|
552
|
-
authorizationUrl.searchParams.set("request_uri", parRes.request_uri);
|
|
553
|
-
authorizationUrl.searchParams.set("client_id", this.clientMetadata.client_id);
|
|
554
|
-
return [null, authorizationUrl];
|
|
555
|
-
}
|
|
556
|
-
authorizationUrl.search = params.toString();
|
|
557
|
-
return [null, authorizationUrl];
|
|
558
|
-
}
|
|
559
|
-
async getClientAuth() {
|
|
560
|
-
if (!this.clientSecret && !this.clientAssertionSigningKey) {
|
|
561
|
-
throw new Error("The client secret or client assertion signing key must be provided.");
|
|
562
|
-
}
|
|
563
|
-
let clientPrivateKey = this.clientAssertionSigningKey;
|
|
564
|
-
if (clientPrivateKey && !(clientPrivateKey instanceof CryptoKey)) {
|
|
565
|
-
clientPrivateKey = await importPKCS8(clientPrivateKey, this.clientAssertionSigningAlg);
|
|
566
|
-
}
|
|
567
|
-
return clientPrivateKey ? PrivateKeyJwt(clientPrivateKey) : ClientSecretPost(this.clientSecret);
|
|
568
|
-
}
|
|
569
|
-
get issuer() {
|
|
570
|
-
return this.domain.startsWith("http://") || this.domain.startsWith("https://") ? this.domain : `https://${this.domain}`;
|
|
571
|
-
}
|
|
572
|
-
/**
|
|
573
|
-
* Exchanges a refresh token for an access token for a connection.
|
|
574
|
-
*
|
|
575
|
-
* This method performs a token exchange using the provided refresh token and connection details.
|
|
576
|
-
* It first checks if the refresh token is present in the `tokenSet`. If not, it returns an error.
|
|
577
|
-
* Then, it constructs the necessary parameters for the token exchange request and performs
|
|
578
|
-
* the request to the authorization server's token endpoint.
|
|
579
|
-
*
|
|
580
|
-
* @returns {Promise<[AccessTokenForConnectionError, null] | [null, ConnectionTokenSet]>} A promise that resolves to a tuple.
|
|
581
|
-
* The first element is either an `AccessTokenForConnectionError` if an error occurred, or `null` if the request was successful.
|
|
582
|
-
* The second element is either `null` if an error occurred, or a `ConnectionTokenSet` object
|
|
583
|
-
* containing the access token, expiration time, and scope if the request was successful.
|
|
584
|
-
*
|
|
585
|
-
* @throws {AccessTokenForConnectionError} If the refresh token is missing or if there is an error during the token exchange process.
|
|
586
|
-
*/
|
|
587
|
-
async getConnectionTokenSet(tokenSet, connectionTokenSet, options) {
|
|
588
|
-
if (!tokenSet.refreshToken && (!connectionTokenSet || connectionTokenSet.expiresAt <= Date.now() / 1e3)) {
|
|
589
|
-
return [
|
|
590
|
-
new AccessTokenForConnectionError(AccessTokenForConnectionErrorCode.MISSING_REFRESH_TOKEN, "A refresh token was not present, Connection Access Token requires a refresh token. The user needs to re-authenticate."),
|
|
591
|
-
null
|
|
592
|
-
];
|
|
593
|
-
}
|
|
594
|
-
if (tokenSet.refreshToken && (!connectionTokenSet || connectionTokenSet.expiresAt <= Date.now() / 1e3)) {
|
|
595
|
-
const params = new URLSearchParams();
|
|
596
|
-
params.append("connection", options.connection);
|
|
597
|
-
params.append("subject_token_type", SUBJECT_TYPE_REFRESH_TOKEN);
|
|
598
|
-
params.append("subject_token", tokenSet.refreshToken);
|
|
599
|
-
params.append("requested_token_type", REQUESTED_TOKEN_TYPE_FEDERATED_CONNECTION_ACCESS_TOKEN);
|
|
600
|
-
if (options.login_hint) {
|
|
601
|
-
params.append("login_hint", options.login_hint);
|
|
602
|
-
}
|
|
603
|
-
const [discoveryError, authorizationServerMetadata] = await this.discoverAuthorizationServerMetadata();
|
|
604
|
-
if (discoveryError) {
|
|
605
|
-
return [discoveryError, null];
|
|
606
|
-
}
|
|
607
|
-
const httpResponse = await genericTokenEndpointRequest(authorizationServerMetadata, this.clientMetadata, await this.getClientAuth(), GRANT_TYPE_FEDERATED_CONNECTION_ACCESS_TOKEN, params, {
|
|
608
|
-
[customFetch]: this.fetch,
|
|
609
|
-
[allowInsecureRequests]: this.allowInsecureRequests
|
|
610
|
-
});
|
|
611
|
-
let tokenEndpointResponse;
|
|
612
|
-
try {
|
|
613
|
-
tokenEndpointResponse = await processGenericTokenEndpointResponse(authorizationServerMetadata, this.clientMetadata, httpResponse);
|
|
614
|
-
} catch (err) {
|
|
615
|
-
return [
|
|
616
|
-
new AccessTokenForConnectionError(AccessTokenForConnectionErrorCode.FAILED_TO_EXCHANGE, "There was an error trying to exchange the refresh token for a connection access token.", new OAuth2Error({
|
|
617
|
-
code: err.error,
|
|
618
|
-
message: err.error_description
|
|
619
|
-
})),
|
|
620
|
-
null
|
|
621
|
-
];
|
|
622
|
-
}
|
|
623
|
-
return [
|
|
624
|
-
null,
|
|
625
|
-
{
|
|
626
|
-
accessToken: tokenEndpointResponse.access_token,
|
|
627
|
-
expiresAt: Math.floor(Date.now() / 1e3) + Number(tokenEndpointResponse.expires_in),
|
|
628
|
-
scope: tokenEndpointResponse.scope,
|
|
629
|
-
connection: options.connection
|
|
630
|
-
}
|
|
631
|
-
];
|
|
632
|
-
}
|
|
633
|
-
return [null, connectionTokenSet];
|
|
634
|
-
}
|
|
635
|
-
}
|
|
636
|
-
const encodeBase64 = (input) => {
|
|
637
|
-
const unencoded = new TextEncoder().encode(input);
|
|
638
|
-
const CHUNK_SIZE = 32768;
|
|
639
|
-
const arr = [];
|
|
640
|
-
for (let i = 0; i < unencoded.length; i += CHUNK_SIZE) {
|
|
641
|
-
arr.push(
|
|
642
|
-
// @ts-expect-error Argument of type 'Uint8Array' is not assignable to parameter of type 'number[]'.
|
|
643
|
-
String.fromCharCode.apply(null, unencoded.subarray(i, i + CHUNK_SIZE))
|
|
644
|
-
);
|
|
645
|
-
}
|
|
646
|
-
return btoa(arr.join(""));
|
|
647
|
-
};
|
|
648
|
-
export {
|
|
649
|
-
AuthClient
|
|
650
|
-
};
|