@@ -4153,231 +4153,6 @@ ca/T0LLtgmbMmxSv/MmzIg==
4153
4153
} ) ;
4154
4154
} ) ;
4155
4155
} ) ;
4156
-
4157
- describe ( "getFederatedConnectionTokenSet" , async ( ) => {
4158
- it ( "should call for an access token when no federated connection token set in the session" , async ( ) => {
4159
- const secret = await generateSecret ( 32 ) ;
4160
- const transactionStore = new TransactionStore ( {
4161
- secret
4162
- } ) ;
4163
- const sessionStore = new StatelessSessionStore ( {
4164
- secret
4165
- } ) ;
4166
- const fetchSpy = getMockAuthorizationServer ( {
4167
- tokenEndpointResponse : {
4168
- token_type : "Bearer" ,
4169
- access_token : DEFAULT . accessToken ,
4170
- expires_in : 86400 // expires in 10 days
4171
- } as oauth . TokenEndpointResponse
4172
- } ) ;
4173
-
4174
- const authClient = new AuthClient ( {
4175
- transactionStore,
4176
- sessionStore,
4177
-
4178
- domain : DEFAULT . domain ,
4179
- clientId : DEFAULT . clientId ,
4180
- clientSecret : DEFAULT . clientSecret ,
4181
-
4182
- secret,
4183
- appBaseUrl : DEFAULT . appBaseUrl ,
4184
-
4185
- fetch : fetchSpy
4186
- } ) ;
4187
-
4188
- const expiresAt = Math . floor ( Date . now ( ) / 1000 ) - 10 * 24 * 60 * 60 ; // expired 10 days ago
4189
- const tokenSet = {
4190
- accessToken : DEFAULT . accessToken ,
4191
- refreshToken : DEFAULT . refreshToken ,
4192
- expiresAt
4193
- } ;
4194
-
4195
- const response = await authClient . getFederatedConnectionTokenSet (
4196
- tokenSet ,
4197
- undefined ,
4198
- { connection : "google-oauth2" , login_hint : "000100123" }
4199
- ) ;
4200
- const [ error , federatedConnectionTokenSet ] = response ;
4201
- expect ( error ) . toBe ( null ) ;
4202
- expect ( fetchSpy ) . toHaveBeenCalled ( ) ;
4203
- expect ( federatedConnectionTokenSet ) . toEqual ( {
4204
- accessToken : DEFAULT . accessToken ,
4205
- connection : "google-oauth2" ,
4206
- expiresAt : expect . any ( Number )
4207
- } ) ;
4208
- } ) ;
4209
-
4210
- it ( "should return access token from the session when federated connection token set in the session is not expired" , async ( ) => {
4211
- const secret = await generateSecret ( 32 ) ;
4212
- const transactionStore = new TransactionStore ( {
4213
- secret
4214
- } ) ;
4215
- const sessionStore = new StatelessSessionStore ( {
4216
- secret
4217
- } ) ;
4218
- const fetchSpy = vi . fn ( ) ;
4219
- const authClient = new AuthClient ( {
4220
- transactionStore,
4221
- sessionStore,
4222
-
4223
- domain : DEFAULT . domain ,
4224
- clientId : DEFAULT . clientId ,
4225
- clientSecret : DEFAULT . clientSecret ,
4226
-
4227
- secret,
4228
- appBaseUrl : DEFAULT . appBaseUrl ,
4229
-
4230
- fetch : fetchSpy
4231
- } ) ;
4232
-
4233
- const expiresAt = Math . floor ( Date . now ( ) / 1000 ) - 10 * 24 * 60 * 60 ; // expired 10 days ago
4234
- const tokenSet = {
4235
- accessToken : DEFAULT . accessToken ,
4236
- refreshToken : DEFAULT . refreshToken ,
4237
- expiresAt,
4238
- } ;
4239
-
4240
- const response = await authClient . getFederatedConnectionTokenSet (
4241
- tokenSet ,
4242
- { connection : 'google-oauth2' , accessToken : 'fc_at' , expiresAt : Math . floor ( Date . now ( ) / 1000 ) + 86400 } ,
4243
- { connection : "google-oauth2" , login_hint : "000100123" }
4244
- ) ;
4245
- const [ error , federatedConnectionTokenSet ] = response ;
4246
- expect ( error ) . toBe ( null ) ;
4247
- expect ( federatedConnectionTokenSet ) . toEqual ( {
4248
- accessToken : 'fc_at' ,
4249
- connection : "google-oauth2" ,
4250
- expiresAt : expect . any ( Number )
4251
- } ) ;
4252
- expect ( fetchSpy ) . not . toHaveBeenCalled ( ) ;
4253
- } ) ;
4254
-
4255
- it ( "should call for an access token when federated connection token set in the session is expired" , async ( ) => {
4256
- const secret = await generateSecret ( 32 ) ;
4257
- const transactionStore = new TransactionStore ( {
4258
- secret
4259
- } ) ;
4260
- const sessionStore = new StatelessSessionStore ( {
4261
- secret
4262
- } ) ;
4263
- const fetchSpy = getMockAuthorizationServer ( {
4264
- tokenEndpointResponse : {
4265
- token_type : "Bearer" ,
4266
- access_token : DEFAULT . accessToken ,
4267
- expires_in : 86400 // expires in 10 days
4268
- } as oauth . TokenEndpointResponse
4269
- } ) ;
4270
- const authClient = new AuthClient ( {
4271
- transactionStore,
4272
- sessionStore,
4273
-
4274
- domain : DEFAULT . domain ,
4275
- clientId : DEFAULT . clientId ,
4276
- clientSecret : DEFAULT . clientSecret ,
4277
-
4278
- secret,
4279
- appBaseUrl : DEFAULT . appBaseUrl ,
4280
-
4281
- fetch : fetchSpy
4282
- } ) ;
4283
-
4284
- const expiresAt = Math . floor ( Date . now ( ) / 1000 ) - 10 * 24 * 60 * 60 ; // expired 10 days ago
4285
- const tokenSet = {
4286
- accessToken : DEFAULT . accessToken ,
4287
- refreshToken : DEFAULT . refreshToken ,
4288
- expiresAt,
4289
- } ;
4290
-
4291
- const response = await authClient . getFederatedConnectionTokenSet (
4292
- tokenSet ,
4293
- { connection : 'google-oauth2' , accessToken : 'fc_at' , expiresAt } ,
4294
- { connection : "google-oauth2" , login_hint : "000100123" }
4295
- ) ;
4296
- const [ error , federatedConnectionTokenSet ] = response ;
4297
- expect ( error ) . toBe ( null ) ;
4298
- expect ( federatedConnectionTokenSet ) . toEqual ( {
4299
- accessToken : DEFAULT . accessToken ,
4300
- connection : "google-oauth2" ,
4301
- expiresAt : expect . any ( Number )
4302
- } ) ;
4303
- expect ( fetchSpy ) . toHaveBeenCalled ( ) ;
4304
- } ) ;
4305
-
4306
- it ( "should return an error if the discovery endpoint could not be fetched" , async ( ) => {
4307
- const secret = await generateSecret ( 32 ) ;
4308
- const transactionStore = new TransactionStore ( {
4309
- secret
4310
- } ) ;
4311
- const sessionStore = new StatelessSessionStore ( {
4312
- secret
4313
- } ) ;
4314
- const authClient = new AuthClient ( {
4315
- transactionStore,
4316
- sessionStore,
4317
-
4318
- domain : DEFAULT . domain ,
4319
- clientId : DEFAULT . clientId ,
4320
- clientSecret : DEFAULT . clientSecret ,
4321
-
4322
- secret,
4323
- appBaseUrl : DEFAULT . appBaseUrl ,
4324
-
4325
- fetch : getMockAuthorizationServer ( {
4326
- discoveryResponse : new Response ( null , { status : 500 } )
4327
- } )
4328
- } ) ;
4329
-
4330
- const expiresAt = Math . floor ( Date . now ( ) / 1000 ) - 10 * 24 * 60 * 60 ; // expired 10 days ago
4331
- const tokenSet = {
4332
- accessToken : DEFAULT . accessToken ,
4333
- refreshToken : DEFAULT . refreshToken ,
4334
- expiresAt
4335
- } ;
4336
-
4337
- const [ error , federatedConnectionTokenSet ] =
4338
- await authClient . getFederatedConnectionTokenSet ( tokenSet , undefined , {
4339
- connection : "google-oauth2"
4340
- } ) ;
4341
- expect ( error ?. code ) . toEqual ( "discovery_error" ) ;
4342
- expect ( federatedConnectionTokenSet ) . toBeNull ( ) ;
4343
- } ) ;
4344
-
4345
- it ( "should return an error if the token set does not contain a refresh token" , async ( ) => {
4346
- const secret = await generateSecret ( 32 ) ;
4347
- const transactionStore = new TransactionStore ( {
4348
- secret
4349
- } ) ;
4350
- const sessionStore = new StatelessSessionStore ( {
4351
- secret
4352
- } ) ;
4353
- const authClient = new AuthClient ( {
4354
- transactionStore,
4355
- sessionStore,
4356
-
4357
- domain : DEFAULT . domain ,
4358
- clientId : DEFAULT . clientId ,
4359
- clientSecret : DEFAULT . clientSecret ,
4360
-
4361
- secret,
4362
- appBaseUrl : DEFAULT . appBaseUrl ,
4363
-
4364
- fetch : getMockAuthorizationServer ( )
4365
- } ) ;
4366
-
4367
- const expiresAt = Math . floor ( Date . now ( ) / 1000 ) - 10 * 24 * 60 * 60 ; // expired 10 days ago
4368
- const tokenSet = {
4369
- accessToken : DEFAULT . accessToken ,
4370
- expiresAt
4371
- } ;
4372
-
4373
- const [ error , federatedConnectionTokenSet ] =
4374
- await authClient . getFederatedConnectionTokenSet ( tokenSet , undefined , {
4375
- connection : "google-oauth2"
4376
- } ) ;
4377
- expect ( error ?. code ) . toEqual ( "missing_refresh_token" ) ;
4378
- expect ( federatedConnectionTokenSet ) . toBeNull ( ) ;
4379
- } ) ;
4380
- } ) ;
4381
4156
} ) ;
4382
4157
4383
4158
const _authorizationServerMetadata = {
@@ -4449,4 +4224,4 @@ const _authorizationServerMetadata = {
4449
4224
backchannel_logout_session_supported : true ,
4450
4225
end_session_endpoint : "https://guabu.us.auth0.com/oidc/logout" ,
4451
4226
pushed_authorization_request_endpoint : "https://guabu.us.auth0.com/oauth/par"
4452
- } ;
4227
+ } ;
0 commit comments