@absolutejs/auth 0.7.5 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -39,6 +39,12 @@ var decodeBase64 = (input, toUint8Array = false) => {
39
39
  }
40
40
  return bytes;
41
41
  };
42
+ var hmacSha256 = async (message, secret) => {
43
+ const encoder = new TextEncoder;
44
+ const key = await crypto.subtle.importKey("raw", encoder.encode(secret), { hash: "SHA-256", name: "HMAC" }, false, ["sign"]);
45
+ const sigBuffer = await crypto.subtle.sign("HMAC", key, encoder.encode(message));
46
+ return Array.from(new Uint8Array(sigBuffer)).map((b) => b.toString(16).padStart(2, "0")).join("");
47
+ };
42
48
  var decodeJWT = (tokenString) => {
43
49
  const [headerSegment, payloadSegment, signatureSegment] = tokenString.split(".");
44
50
  if (!headerSegment || !payloadSegment || !signatureSegment) {
@@ -50,6 +56,27 @@ var decodeJWT = (tokenString) => {
50
56
  }
51
57
  return JSON.parse(decodedPayload);
52
58
  };
59
+ var getWithingsProps = async (config) => {
60
+ const timestamp = Math.floor(Date.now() / 1000);
61
+ const signature = `getnonce,${config.clientId},${timestamp}`;
62
+ const hashedSignature = await hmacSha256(signature, config.clientSecret);
63
+ const nonceUrl = new URL("https://wbsapi.withings.net/v2/signature");
64
+ nonceUrl.searchParams.set("action", "getnonce");
65
+ nonceUrl.searchParams.set("client_id", config.clientId);
66
+ nonceUrl.searchParams.set("timestamp", timestamp.toString());
67
+ nonceUrl.searchParams.set("signature", hashedSignature);
68
+ const nonceResponse = await fetch(nonceUrl.toString(), {
69
+ method: "POST"
70
+ });
71
+ const nonceData = await nonceResponse.json();
72
+ if (nonceData.status === 0) {
73
+ return {
74
+ hashedSignature,
75
+ nonce: nonceData.body.nonce
76
+ };
77
+ }
78
+ return;
79
+ };
53
80
  var createOAuth2Request = ({
54
81
  url,
55
82
  body,
@@ -68,7 +95,7 @@ var createOAuth2Request = ({
68
95
  }
69
96
  oauthHeaders.set("Authorization", `Basic ${encodeBase64(`${clientId}:${clientSecret}`)}`);
70
97
  }
71
- if (encoding === "json") {
98
+ if (encoding === "application/json") {
72
99
  oauthHeaders.set("Content-Type", "application/json");
73
100
  return new Request(url, {
74
101
  body: JSON.stringify(body),
@@ -148,13 +175,14 @@ var providers = defineProviders({
148
175
  isRefreshable: true,
149
176
  profileRequest: {
150
177
  authIn: "header",
178
+ encoding: "application/json",
151
179
  method: "GET",
152
180
  url: "https://api.intra.42.fr/v2/me"
153
181
  },
154
182
  scopeRequired: false,
155
183
  tokenRequest: {
156
184
  authIn: "body",
157
- encoding: "form",
185
+ encoding: "application/x-www-form-urlencoded",
158
186
  url: "https://api.intra.42.fr/oauth/token"
159
187
  }
160
188
  },
@@ -165,18 +193,20 @@ var providers = defineProviders({
165
193
  PKCEMethod: "S256",
166
194
  profileRequest: {
167
195
  authIn: "header",
196
+ encoding: "application/json",
168
197
  method: "GET",
169
198
  url: (config) => `https://${config.domain}/oauth2/userInfo`
170
199
  },
171
200
  revocationRequest: {
172
201
  authIn: "body",
202
+ encoding: "application/json",
173
203
  tokenParamName: "token",
174
204
  url: (config) => `https://${config.domain}/oauth2/revoke`
175
205
  },
176
206
  scopeRequired: false,
177
207
  tokenRequest: {
178
208
  authIn: "body",
179
- encoding: "form",
209
+ encoding: "application/x-www-form-urlencoded",
180
210
  url: (config) => `https://${config.domain}/oauth2/token`
181
211
  }
182
212
  },
@@ -189,6 +219,7 @@ var providers = defineProviders({
189
219
  body: {
190
220
  query: `query { Viewer { id name } }`
191
221
  },
222
+ encoding: "application/json",
192
223
  headers: {
193
224
  Accept: "application/json",
194
225
  "Content-Type": "application/json"
@@ -199,7 +230,7 @@ var providers = defineProviders({
199
230
  scopeRequired: false,
200
231
  tokenRequest: {
201
232
  authIn: "body",
202
- encoding: "form",
233
+ encoding: "application/x-www-form-urlencoded",
203
234
  url: "https://anilist.co/api/v2/oauth/token"
204
235
  }
205
236
  },
@@ -210,13 +241,14 @@ var providers = defineProviders({
210
241
  PKCEMethod: "S256",
211
242
  profileRequest: {
212
243
  authIn: "header",
244
+ encoding: "application/json",
213
245
  method: "GET",
214
246
  url: "https://appleid.apple.com/auth/userinfo"
215
247
  },
216
248
  scopeRequired: false,
217
249
  tokenRequest: {
218
250
  authIn: "body",
219
- encoding: "form",
251
+ encoding: "application/x-www-form-urlencoded",
220
252
  url: "https://appleid.apple.com/auth/token"
221
253
  }
222
254
  },
@@ -229,13 +261,14 @@ var providers = defineProviders({
229
261
  isRefreshable: true,
230
262
  profileRequest: {
231
263
  authIn: "header",
264
+ encoding: "application/json",
232
265
  method: "GET",
233
266
  url: "https://api.atlassian.com/me"
234
267
  },
235
268
  scopeRequired: true,
236
269
  tokenRequest: {
237
270
  authIn: "body",
238
- encoding: "form",
271
+ encoding: "application/x-www-form-urlencoded",
239
272
  url: "https://auth.atlassian.com/oauth/token"
240
273
  }
241
274
  },
@@ -246,6 +279,7 @@ var providers = defineProviders({
246
279
  PKCEMethod: "S256",
247
280
  profileRequest: {
248
281
  authIn: "header",
282
+ encoding: "application/json",
249
283
  method: "GET",
250
284
  url: (config) => `https://${config.domain}/userinfo`
251
285
  },
@@ -254,13 +288,14 @@ var providers = defineProviders({
254
288
  body: new URLSearchParams({
255
289
  token_type_hint: "refresh_token"
256
290
  }),
291
+ encoding: "application/json",
257
292
  tokenParamName: "token",
258
293
  url: (config) => `https://${config.domain}/oauth/revoke`
259
294
  },
260
295
  scopeRequired: false,
261
296
  tokenRequest: {
262
297
  authIn: "body",
263
- encoding: "form",
298
+ encoding: "application/x-www-form-urlencoded",
264
299
  url: (config) => `https://${config.domain}/oauth/token`
265
300
  }
266
301
  },
@@ -271,13 +306,14 @@ var providers = defineProviders({
271
306
  PKCEMethod: "S256",
272
307
  profileRequest: {
273
308
  authIn: "header",
309
+ encoding: "application/json",
274
310
  method: "GET",
275
311
  url: (config) => `https://${config.baseURL}/api/v3/user/`
276
312
  },
277
313
  scopeRequired: false,
278
314
  tokenRequest: {
279
315
  authIn: "body",
280
- encoding: "form",
316
+ encoding: "application/x-www-form-urlencoded",
281
317
  url: (config) => `https://${config.baseURL}/oauth/token`
282
318
  }
283
319
  },
@@ -288,13 +324,14 @@ var providers = defineProviders({
288
324
  PKCEMethod: "S256",
289
325
  profileRequest: {
290
326
  authIn: "header",
327
+ encoding: "application/json",
291
328
  method: "GET",
292
329
  url: "https://api.userprofile.autodesk.com/userinfo"
293
330
  },
294
331
  scopeRequired: false,
295
332
  tokenRequest: {
296
333
  authIn: "body",
297
- encoding: "form",
334
+ encoding: "application/x-www-form-urlencoded",
298
335
  url: "https://developer.api.autodesk.com/authentication/v2/token"
299
336
  }
300
337
  },
@@ -304,13 +341,14 @@ var providers = defineProviders({
304
341
  isRefreshable: false,
305
342
  profileRequest: {
306
343
  authIn: "header",
344
+ encoding: "application/json",
307
345
  method: "GET",
308
346
  url: "https://oauth.battle.net/userinfo"
309
347
  },
310
348
  scopeRequired: false,
311
349
  tokenRequest: {
312
350
  authIn: "body",
313
- encoding: "form",
351
+ encoding: "application/x-www-form-urlencoded",
314
352
  url: "https://oauth.battle.net/token"
315
353
  }
316
354
  },
@@ -320,13 +358,14 @@ var providers = defineProviders({
320
358
  isRefreshable: true,
321
359
  profileRequest: {
322
360
  authIn: "header",
361
+ encoding: "application/json",
323
362
  method: "GET",
324
363
  url: "https://api.bitbucket.org/2.0/user"
325
364
  },
326
365
  scopeRequired: false,
327
366
  tokenRequest: {
328
367
  authIn: "body",
329
- encoding: "form",
368
+ encoding: "application/x-www-form-urlencoded",
330
369
  url: "https://bitbucket.org/site/oauth2/access_token"
331
370
  }
332
371
  },
@@ -336,18 +375,20 @@ var providers = defineProviders({
336
375
  isRefreshable: true,
337
376
  profileRequest: {
338
377
  authIn: "header",
378
+ encoding: "application/json",
339
379
  method: "GET",
340
380
  url: "https://api.box.com/2.0/users/me"
341
381
  },
342
382
  revocationRequest: {
343
383
  authIn: "body",
384
+ encoding: "application/json",
344
385
  tokenParamName: "token",
345
386
  url: "https://api.box.com/oauth2/revoke"
346
387
  },
347
388
  scopeRequired: false,
348
389
  tokenRequest: {
349
390
  authIn: "body",
350
- encoding: "form",
391
+ encoding: "application/x-www-form-urlencoded",
351
392
  url: "https://api.box.com/oauth2/token"
352
393
  }
353
394
  },
@@ -357,6 +398,7 @@ var providers = defineProviders({
357
398
  isRefreshable: true,
358
399
  profileRequest: {
359
400
  authIn: "header",
401
+ encoding: "application/json",
360
402
  headers: {
361
403
  "X-API-Key": "<YOUR_API_KEY>"
362
404
  },
@@ -366,7 +408,7 @@ var providers = defineProviders({
366
408
  scopeRequired: false,
367
409
  tokenRequest: {
368
410
  authIn: "body",
369
- encoding: "form",
411
+ encoding: "application/x-www-form-urlencoded",
370
412
  url: "https://www.bungie.net/Platform/App/OAuth/token"
371
413
  }
372
414
  },
@@ -376,13 +418,14 @@ var providers = defineProviders({
376
418
  isRefreshable: true,
377
419
  profileRequest: {
378
420
  authIn: "header",
421
+ encoding: "application/json",
379
422
  method: "GET",
380
423
  url: "https://api.coinbase.com/v2/user"
381
424
  },
382
425
  scopeRequired: false,
383
426
  tokenRequest: {
384
427
  authIn: "body",
385
- encoding: "form",
428
+ encoding: "application/x-www-form-urlencoded",
386
429
  url: "https://api.coinbase.com/oauth/token"
387
430
  }
388
431
  },
@@ -393,13 +436,14 @@ var providers = defineProviders({
393
436
  PKCEMethod: "S256",
394
437
  profileRequest: {
395
438
  authIn: "header",
439
+ encoding: "application/json",
396
440
  method: "GET",
397
441
  url: "https://discord.com/api/users/@me"
398
442
  },
399
443
  scopeRequired: true,
400
444
  tokenRequest: {
401
445
  authIn: "body",
402
- encoding: "form",
446
+ encoding: "application/x-www-form-urlencoded",
403
447
  url: "https://discord.com/api/oauth2/token"
404
448
  }
405
449
  },
@@ -409,13 +453,14 @@ var providers = defineProviders({
409
453
  isRefreshable: true,
410
454
  profileRequest: {
411
455
  authIn: "header",
456
+ encoding: "application/json",
412
457
  method: "GET",
413
458
  url: "https://www.donationalerts.com/api/v1/user/oauth"
414
459
  },
415
460
  scopeRequired: false,
416
461
  tokenRequest: {
417
462
  authIn: "body",
418
- encoding: "form",
463
+ encoding: "application/x-www-form-urlencoded",
419
464
  url: "https://www.donationalerts.com/oauth/token"
420
465
  }
421
466
  },
@@ -425,13 +470,14 @@ var providers = defineProviders({
425
470
  isRefreshable: false,
426
471
  profileRequest: {
427
472
  authIn: "header",
473
+ encoding: "application/json",
428
474
  method: "GET",
429
475
  url: "https://api.dribbble.com/v2/user"
430
476
  },
431
477
  scopeRequired: false,
432
478
  tokenRequest: {
433
479
  authIn: "body",
434
- encoding: "form",
480
+ encoding: "application/x-www-form-urlencoded",
435
481
  url: "https://dribbble.com/oauth/token"
436
482
  }
437
483
  },
@@ -441,17 +487,19 @@ var providers = defineProviders({
441
487
  isRefreshable: true,
442
488
  profileRequest: {
443
489
  authIn: "header",
490
+ encoding: "application/json",
444
491
  method: "POST",
445
492
  url: "https://api.dropboxapi.com/2/users/get_current_account"
446
493
  },
447
494
  revocationRequest: {
448
495
  authIn: "header",
496
+ encoding: "application/json",
449
497
  url: "https://api.dropboxapi.com/2/auth/token/revoke"
450
498
  },
451
499
  scopeRequired: false,
452
500
  tokenRequest: {
453
501
  authIn: "body",
454
- encoding: "form",
502
+ encoding: "application/x-www-form-urlencoded",
455
503
  url: "https://api.dropboxapi.com/oauth2/token"
456
504
  }
457
505
  },
@@ -461,13 +509,14 @@ var providers = defineProviders({
461
509
  isRefreshable: true,
462
510
  profileRequest: {
463
511
  authIn: "header",
512
+ encoding: "application/json",
464
513
  method: "GET",
465
514
  url: "https://api.epicgames.dev/epic/oauth/v2/userInfo"
466
515
  },
467
516
  scopeRequired: false,
468
517
  tokenRequest: {
469
518
  authIn: "body",
470
- encoding: "form",
519
+ encoding: "application/x-www-form-urlencoded",
471
520
  url: "https://api.epicgames.dev/epic/oauth/v1/token"
472
521
  }
473
522
  },
@@ -477,13 +526,14 @@ var providers = defineProviders({
477
526
  isRefreshable: true,
478
527
  profileRequest: {
479
528
  authIn: "header",
529
+ encoding: "application/json",
480
530
  method: "GET",
481
531
  url: "https://openapi.etsy.com/v3/application/users/me"
482
532
  },
483
533
  scopeRequired: false,
484
534
  tokenRequest: {
485
535
  authIn: "body",
486
- encoding: "form",
536
+ encoding: "application/x-www-form-urlencoded",
487
537
  url: "https://api.etsy.com/v3/public/oauth/token"
488
538
  }
489
539
  },
@@ -494,6 +544,7 @@ var providers = defineProviders({
494
544
  PKCEMethod: "S256",
495
545
  profileRequest: {
496
546
  authIn: "query",
547
+ encoding: "application/json",
497
548
  method: "GET",
498
549
  searchParams: [["fields", "id,name,email,picture"]],
499
550
  url: "https://graph.facebook.com/me"
@@ -501,7 +552,7 @@ var providers = defineProviders({
501
552
  scopeRequired: false,
502
553
  tokenRequest: {
503
554
  authIn: "body",
504
- encoding: "form",
555
+ encoding: "application/x-www-form-urlencoded",
505
556
  url: "https://graph.facebook.com/v16.0/oauth/access_token"
506
557
  }
507
558
  },
@@ -512,13 +563,14 @@ var providers = defineProviders({
512
563
  PKCEMethod: "S256",
513
564
  profileRequest: {
514
565
  authIn: "header",
566
+ encoding: "application/json",
515
567
  method: "GET",
516
568
  url: "https://api.figma.com/v1/me"
517
569
  },
518
570
  scopeRequired: true,
519
571
  tokenRequest: {
520
572
  authIn: "body",
521
- encoding: "form",
573
+ encoding: "application/x-www-form-urlencoded",
522
574
  url: "https://api.figma.com/v1/oauth/token"
523
575
  }
524
576
  },
@@ -529,13 +581,14 @@ var providers = defineProviders({
529
581
  PKCEMethod: "S256",
530
582
  profileRequest: {
531
583
  authIn: "header",
584
+ encoding: "application/json",
532
585
  method: "GET",
533
586
  url: (config) => `${config.baseURL}/api/v1/user`
534
587
  },
535
588
  scopeRequired: false,
536
589
  tokenRequest: {
537
590
  authIn: "body",
538
- encoding: "form",
591
+ encoding: "application/x-www-form-urlencoded",
539
592
  url: (config) => `${config.baseURL}/login/oauth/access_token`
540
593
  }
541
594
  },
@@ -545,13 +598,14 @@ var providers = defineProviders({
545
598
  isRefreshable: false,
546
599
  profileRequest: {
547
600
  authIn: "header",
601
+ encoding: "application/json",
548
602
  method: "GET",
549
603
  url: "https://api.github.com/user"
550
604
  },
551
605
  scopeRequired: false,
552
606
  tokenRequest: {
553
607
  authIn: "body",
554
- encoding: "form",
608
+ encoding: "application/x-www-form-urlencoded",
555
609
  url: "https://github.com/login/oauth/access_token"
556
610
  }
557
611
  },
@@ -562,18 +616,20 @@ var providers = defineProviders({
562
616
  PKCEMethod: "S256",
563
617
  profileRequest: {
564
618
  authIn: "header",
619
+ encoding: "application/json",
565
620
  method: "GET",
566
621
  url: "https://gitlab.com/api/v4/user"
567
622
  },
568
623
  revocationRequest: {
569
624
  authIn: "body",
625
+ encoding: "application/json",
570
626
  tokenParamName: "token",
571
627
  url: (config) => `${config.baseURL}/oauth/revoke`
572
628
  },
573
629
  scopeRequired: false,
574
630
  tokenRequest: {
575
631
  authIn: "body",
576
- encoding: "form",
632
+ encoding: "application/x-www-form-urlencoded",
577
633
  url: (config) => `${config.baseURL}/oauth/token`
578
634
  }
579
635
  },
@@ -584,19 +640,21 @@ var providers = defineProviders({
584
640
  PKCEMethod: "S256",
585
641
  profileRequest: {
586
642
  authIn: "header",
643
+ encoding: "application/json",
587
644
  method: "GET",
588
645
  searchParams: [["personFields", "names,emailAddresses,photos"]],
589
646
  url: "https://people.googleapis.com/v1/people/me"
590
647
  },
591
648
  revocationRequest: {
592
649
  authIn: "body",
650
+ encoding: "application/json",
593
651
  tokenParamName: "token",
594
652
  url: "https://oauth2.googleapis.com/revoke"
595
653
  },
596
654
  scopeRequired: true,
597
655
  tokenRequest: {
598
656
  authIn: "body",
599
- encoding: "form",
657
+ encoding: "application/x-www-form-urlencoded",
600
658
  url: "https://oauth2.googleapis.com/token"
601
659
  }
602
660
  },
@@ -606,11 +664,13 @@ var providers = defineProviders({
606
664
  isRefreshable: true,
607
665
  profileRequest: {
608
666
  authIn: "header",
667
+ encoding: "application/json",
609
668
  method: "GET",
610
669
  url: (config) => config.environment === "production" ? "https://accounts.platform.intuit.com/v1/openid_connect/userinfo" : "https://sandbox-accounts.platform.intuit.com/v1/openid_connect/userinfo"
611
670
  },
612
671
  revocationRequest: {
613
672
  authIn: "body",
673
+ encoding: "application/json",
614
674
  headers: (config) => ({
615
675
  Authorization: `Basic ${encodeBase64(`${config.clientId}:${config.clientSecret}`)}`
616
676
  }),
@@ -620,7 +680,7 @@ var providers = defineProviders({
620
680
  scopeRequired: true,
621
681
  tokenRequest: {
622
682
  authIn: "body",
623
- encoding: "form",
683
+ encoding: "application/x-www-form-urlencoded",
624
684
  url: "https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer"
625
685
  }
626
686
  },
@@ -631,13 +691,14 @@ var providers = defineProviders({
631
691
  PKCEMethod: "S256",
632
692
  profileRequest: {
633
693
  authIn: "header",
694
+ encoding: "application/json",
634
695
  method: "GET",
635
696
  url: "https://kapi.kakao.com/v2/user/me"
636
697
  },
637
698
  scopeRequired: false,
638
699
  tokenRequest: {
639
700
  authIn: "body",
640
- encoding: "form",
701
+ encoding: "application/x-www-form-urlencoded",
641
702
  url: "https://kauth.kakao.com/oauth/token"
642
703
  }
643
704
  },
@@ -648,18 +709,20 @@ var providers = defineProviders({
648
709
  PKCEMethod: "S256",
649
710
  profileRequest: {
650
711
  authIn: "header",
712
+ encoding: "application/json",
651
713
  method: "GET",
652
714
  url: "https://api.kick.com/v1/user"
653
715
  },
654
716
  revocationRequest: {
655
717
  authIn: "body",
718
+ encoding: "application/json",
656
719
  tokenParamName: "token",
657
720
  url: (config) => `${config.realmURL}/protocol/openid-connect/revoke`
658
721
  },
659
722
  scopeRequired: false,
660
723
  tokenRequest: {
661
724
  authIn: "body",
662
- encoding: "form",
725
+ encoding: "application/x-www-form-urlencoded",
663
726
  url: (config) => `${config.realmURL}/protocol/openid-connect/token`
664
727
  }
665
728
  },
@@ -670,18 +733,20 @@ var providers = defineProviders({
670
733
  PKCEMethod: "S256",
671
734
  profileRequest: {
672
735
  authIn: "header",
736
+ encoding: "application/json",
673
737
  method: "GET",
674
738
  url: "https://id.kick.com/v1/user"
675
739
  },
676
740
  revocationRequest: {
677
741
  authIn: "body",
742
+ encoding: "application/json",
678
743
  tokenParamName: "token",
679
744
  url: "https://id.kick.com/oauth/revoke"
680
745
  },
681
746
  scopeRequired: false,
682
747
  tokenRequest: {
683
748
  authIn: "body",
684
- encoding: "form",
749
+ encoding: "application/x-www-form-urlencoded",
685
750
  url: "https://id.kick.com/oauth/token"
686
751
  }
687
752
  },
@@ -692,13 +757,14 @@ var providers = defineProviders({
692
757
  PKCEMethod: "S256",
693
758
  profileRequest: {
694
759
  authIn: "header",
760
+ encoding: "application/json",
695
761
  method: "GET",
696
762
  url: "https://lichess.org/api/account"
697
763
  },
698
764
  scopeRequired: false,
699
765
  tokenRequest: {
700
766
  authIn: "body",
701
- encoding: "form",
767
+ encoding: "application/x-www-form-urlencoded",
702
768
  url: "https://lichess.org/api/token"
703
769
  }
704
770
  },
@@ -709,13 +775,14 @@ var providers = defineProviders({
709
775
  PKCEMethod: "S256",
710
776
  profileRequest: {
711
777
  authIn: "header",
778
+ encoding: "application/json",
712
779
  method: "GET",
713
780
  url: "https://api.line.me/v2/profile"
714
781
  },
715
782
  scopeRequired: true,
716
783
  tokenRequest: {
717
784
  authIn: "body",
718
- encoding: "form",
785
+ encoding: "application/x-www-form-urlencoded",
719
786
  url: "https://api.line.me/oauth2/v2.1/token"
720
787
  }
721
788
  },
@@ -728,6 +795,7 @@ var providers = defineProviders({
728
795
  body: {
729
796
  query: `query { viewer { id name } }`
730
797
  },
798
+ encoding: "application/json",
731
799
  headers: {
732
800
  Accept: "application/json",
733
801
  "Content-Type": "application/json"
@@ -737,12 +805,13 @@ var providers = defineProviders({
737
805
  },
738
806
  revocationRequest: {
739
807
  authIn: "header",
808
+ encoding: "application/json",
740
809
  url: "https://api.linear.app/oauth/revoke"
741
810
  },
742
811
  scopeRequired: false,
743
812
  tokenRequest: {
744
813
  authIn: "body",
745
- encoding: "form",
814
+ encoding: "application/x-www-form-urlencoded",
746
815
  url: "https://api.linear.app/oauth/token"
747
816
  }
748
817
  },
@@ -753,13 +822,14 @@ var providers = defineProviders({
753
822
  PKCEMethod: "S256",
754
823
  profileRequest: {
755
824
  authIn: "header",
825
+ encoding: "application/json",
756
826
  method: "GET",
757
827
  url: "https://api.linkedin.com/v2/me"
758
828
  },
759
829
  scopeRequired: true,
760
830
  tokenRequest: {
761
831
  authIn: "body",
762
- encoding: "form",
832
+ encoding: "application/x-www-form-urlencoded",
763
833
  url: "https://www.linkedin.com/oauth/v2/accessToken"
764
834
  }
765
835
  },
@@ -770,18 +840,20 @@ var providers = defineProviders({
770
840
  PKCEMethod: "S256",
771
841
  profileRequest: {
772
842
  authIn: "header",
843
+ encoding: "application/json",
773
844
  method: "GET",
774
845
  url: (config) => `${config.baseURL}/api/v1/accounts/verify_credentials`
775
846
  },
776
847
  revocationRequest: {
777
848
  authIn: "body",
849
+ encoding: "application/json",
778
850
  tokenParamName: "token",
779
851
  url: (config) => `${config.baseURL}/oauth/revoke`
780
852
  },
781
853
  scopeRequired: false,
782
854
  tokenRequest: {
783
855
  authIn: "body",
784
- encoding: "form",
856
+ encoding: "application/x-www-form-urlencoded",
785
857
  url: (config) => `${config.baseURL}/oauth/token`
786
858
  }
787
859
  },
@@ -792,13 +864,14 @@ var providers = defineProviders({
792
864
  PKCEMethod: "S256",
793
865
  profileRequest: {
794
866
  authIn: "header",
867
+ encoding: "application/json",
795
868
  method: "GET",
796
869
  url: "https://api.mercadolibre.com/users/me"
797
870
  },
798
871
  scopeRequired: false,
799
872
  tokenRequest: {
800
873
  authIn: "body",
801
- encoding: "form",
874
+ encoding: "application/x-www-form-urlencoded",
802
875
  url: "https://api.mercadolibre.com/oauth/token"
803
876
  }
804
877
  },
@@ -808,13 +881,14 @@ var providers = defineProviders({
808
881
  isRefreshable: true,
809
882
  profileRequest: {
810
883
  authIn: "header",
884
+ encoding: "application/json",
811
885
  method: "GET",
812
886
  url: "https://api.mercadopago.com/v1/users/me"
813
887
  },
814
888
  scopeRequired: false,
815
889
  tokenRequest: {
816
890
  authIn: "body",
817
- encoding: "form",
891
+ encoding: "application/x-www-form-urlencoded",
818
892
  url: "https://api.mercadopago.com/oauth/token"
819
893
  }
820
894
  },
@@ -825,13 +899,14 @@ var providers = defineProviders({
825
899
  PKCEMethod: "S256",
826
900
  profileRequest: {
827
901
  authIn: "header",
902
+ encoding: "application/json",
828
903
  method: "GET",
829
904
  url: (config) => `https://${config.tenantId}.b2clogin.com/${config.tenantId}/openid/userinfo`
830
905
  },
831
906
  scopeRequired: false,
832
907
  tokenRequest: {
833
908
  authIn: "body",
834
- encoding: "form",
909
+ encoding: "application/x-www-form-urlencoded",
835
910
  url: (config) => `https://${config.tenantId}.b2clogin.com/${config.tenantId}/oauth2/v2.0/token`
836
911
  }
837
912
  },
@@ -842,13 +917,14 @@ var providers = defineProviders({
842
917
  PKCEMethod: "plain",
843
918
  profileRequest: {
844
919
  authIn: "header",
920
+ encoding: "application/json",
845
921
  method: "GET",
846
922
  url: "https://api.myanimelist.net/v2/users/@me"
847
923
  },
848
924
  scopeRequired: false,
849
925
  tokenRequest: {
850
926
  authIn: "body",
851
- encoding: "form",
927
+ encoding: "application/x-www-form-urlencoded",
852
928
  url: "https://myanimelist.net/v1/oauth2/token"
853
929
  }
854
930
  },
@@ -858,13 +934,14 @@ var providers = defineProviders({
858
934
  isRefreshable: true,
859
935
  profileRequest: {
860
936
  authIn: "header",
937
+ encoding: "application/json",
861
938
  method: "GET",
862
939
  url: "https://openapi.naver.com/v1/nid/me"
863
940
  },
864
941
  scopeRequired: false,
865
942
  tokenRequest: {
866
943
  authIn: "body",
867
- encoding: "form",
944
+ encoding: "application/x-www-form-urlencoded",
868
945
  url: "https://nid.naver.com/oauth2.0/token"
869
946
  }
870
947
  },
@@ -874,6 +951,7 @@ var providers = defineProviders({
874
951
  isRefreshable: false,
875
952
  profileRequest: {
876
953
  authIn: "header",
954
+ encoding: "application/json",
877
955
  headers: {
878
956
  "Notion-Version": "2022-06-28"
879
957
  },
@@ -883,7 +961,7 @@ var providers = defineProviders({
883
961
  scopeRequired: false,
884
962
  tokenRequest: {
885
963
  authIn: "header",
886
- encoding: "json",
964
+ encoding: "application/json",
887
965
  url: "https://api.notion.com/v1/oauth/token"
888
966
  }
889
967
  },
@@ -894,18 +972,20 @@ var providers = defineProviders({
894
972
  PKCEMethod: "S256",
895
973
  profileRequest: {
896
974
  authIn: "header",
975
+ encoding: "application/json",
897
976
  method: "GET",
898
977
  url: (config) => `https://${config.domain}/oauth2/default/v1/userinfo`
899
978
  },
900
979
  revocationRequest: {
901
980
  authIn: "body",
981
+ encoding: "application/json",
902
982
  tokenParamName: "token",
903
983
  url: (config) => `https://${config.domain}/oauth2/default/v1/revoke`
904
984
  },
905
985
  scopeRequired: true,
906
986
  tokenRequest: {
907
987
  authIn: "body",
908
- encoding: "form",
988
+ encoding: "application/x-www-form-urlencoded",
909
989
  url: (config) => `https://${config.domain}/oauth2/default/v1/token`
910
990
  }
911
991
  },
@@ -915,13 +995,14 @@ var providers = defineProviders({
915
995
  isRefreshable: true,
916
996
  profileRequest: {
917
997
  authIn: "header",
998
+ encoding: "application/json",
918
999
  method: "GET",
919
1000
  url: "https://osu.ppy.sh/api/v2/me"
920
1001
  },
921
1002
  scopeRequired: false,
922
1003
  tokenRequest: {
923
1004
  authIn: "body",
924
- encoding: "form",
1005
+ encoding: "application/x-www-form-urlencoded",
925
1006
  url: "https://osu.ppy.sh/oauth/token"
926
1007
  }
927
1008
  },
@@ -931,13 +1012,14 @@ var providers = defineProviders({
931
1012
  isRefreshable: true,
932
1013
  profileRequest: {
933
1014
  authIn: "header",
1015
+ encoding: "application/json",
934
1016
  method: "GET",
935
1017
  url: "https://www.patreon.com/api/oauth2/v2/identity"
936
1018
  },
937
1019
  scopeRequired: false,
938
1020
  tokenRequest: {
939
1021
  authIn: "body",
940
- encoding: "form",
1022
+ encoding: "application/x-www-form-urlencoded",
941
1023
  url: "https://www.patreon.com/api/oauth2/token"
942
1024
  }
943
1025
  },
@@ -948,18 +1030,20 @@ var providers = defineProviders({
948
1030
  PKCEMethod: "S256",
949
1031
  profileRequest: {
950
1032
  authIn: "header",
1033
+ encoding: "application/json",
951
1034
  method: "GET",
952
1035
  url: "https://api.polar.sh/v1/oauth2/userinfo"
953
1036
  },
954
1037
  revocationRequest: {
955
1038
  authIn: "body",
1039
+ encoding: "application/json",
956
1040
  tokenParamName: "token",
957
1041
  url: "https://api.polar.sh/v1/oauth2/revoke"
958
1042
  },
959
1043
  scopeRequired: true,
960
1044
  tokenRequest: {
961
1045
  authIn: "body",
962
- encoding: "form",
1046
+ encoding: "application/x-www-form-urlencoded",
963
1047
  url: "https://api.polar.sh/v1/oauth2/token"
964
1048
  }
965
1049
  },
@@ -970,13 +1054,14 @@ var providers = defineProviders({
970
1054
  PKCEMethod: "S256",
971
1055
  profileRequest: {
972
1056
  authIn: "header",
1057
+ encoding: "application/json",
973
1058
  method: "GET",
974
1059
  url: "https://www.polaraccesslink.com/v3/users/me"
975
1060
  },
976
1061
  scopeRequired: false,
977
1062
  tokenRequest: {
978
1063
  authIn: "header",
979
- encoding: "form",
1064
+ encoding: "application/x-www-form-urlencoded",
980
1065
  url: "https://polarremote.com/v2/oauth2/token"
981
1066
  }
982
1067
  },
@@ -987,13 +1072,14 @@ var providers = defineProviders({
987
1072
  PKCEMethod: "S256",
988
1073
  profileRequest: {
989
1074
  authIn: "header",
1075
+ encoding: "application/json",
990
1076
  method: "GET",
991
1077
  url: "https://www.polaraccesslink.com/v3/users/<USER_ID>"
992
1078
  },
993
1079
  scopeRequired: false,
994
1080
  tokenRequest: {
995
1081
  authIn: "header",
996
- encoding: "form",
1082
+ encoding: "application/x-www-form-urlencoded",
997
1083
  url: "https://auth.polar.com/oauth/token"
998
1084
  }
999
1085
  },
@@ -1003,6 +1089,7 @@ var providers = defineProviders({
1003
1089
  isRefreshable: true,
1004
1090
  profileRequest: {
1005
1091
  authIn: "header",
1092
+ encoding: "application/json",
1006
1093
  method: "GET",
1007
1094
  url: "https://oauth.reddit.com/api/v1/me"
1008
1095
  },
@@ -1011,12 +1098,13 @@ var providers = defineProviders({
1011
1098
  body: new URLSearchParams({
1012
1099
  token_type_hint: "refresh_token"
1013
1100
  }),
1101
+ encoding: "application/json",
1014
1102
  url: "https://www.reddit.com/api/v1/revoke_token"
1015
1103
  },
1016
1104
  scopeRequired: true,
1017
1105
  tokenRequest: {
1018
1106
  authIn: "header",
1019
- encoding: "form",
1107
+ encoding: "application/x-www-form-urlencoded",
1020
1108
  url: "https://www.reddit.com/api/v1/access_token"
1021
1109
  }
1022
1110
  },
@@ -1027,13 +1115,14 @@ var providers = defineProviders({
1027
1115
  PKCEMethod: "S256",
1028
1116
  profileRequest: {
1029
1117
  authIn: "header",
1118
+ encoding: "application/json",
1030
1119
  method: "GET",
1031
1120
  url: "https://apis.roblox.com/oauth/v1/userinfo"
1032
1121
  },
1033
1122
  scopeRequired: true,
1034
1123
  tokenRequest: {
1035
1124
  authIn: "body",
1036
- encoding: "form",
1125
+ encoding: "application/x-www-form-urlencoded",
1037
1126
  url: "https://apis.roblox.com/oauth/v1/token"
1038
1127
  }
1039
1128
  },
@@ -1044,17 +1133,19 @@ var providers = defineProviders({
1044
1133
  PKCEMethod: "S256",
1045
1134
  profileRequest: {
1046
1135
  authIn: "header",
1136
+ encoding: "application/json",
1047
1137
  method: "GET",
1048
1138
  url: "https://login.salesforce.com/services/oauth2/userinfo"
1049
1139
  },
1050
1140
  revocationRequest: {
1051
1141
  authIn: "header",
1142
+ encoding: "application/json",
1052
1143
  url: "https://login.salesforce.com/services/oauth2/revoke"
1053
1144
  },
1054
1145
  scopeRequired: false,
1055
1146
  tokenRequest: {
1056
1147
  authIn: "body",
1057
- encoding: "form",
1148
+ encoding: "application/x-www-form-urlencoded",
1058
1149
  url: "https://login.salesforce.com/services/oauth2/token"
1059
1150
  }
1060
1151
  },
@@ -1064,13 +1155,14 @@ var providers = defineProviders({
1064
1155
  isRefreshable: true,
1065
1156
  profileRequest: {
1066
1157
  authIn: "header",
1158
+ encoding: "application/json",
1067
1159
  method: "GET",
1068
1160
  url: "https://shikimori.one/api/users/whoami"
1069
1161
  },
1070
1162
  scopeRequired: false,
1071
1163
  tokenRequest: {
1072
1164
  authIn: "body",
1073
- encoding: "form",
1165
+ encoding: "application/x-www-form-urlencoded",
1074
1166
  url: "https://shikimori.org/oauth/token"
1075
1167
  }
1076
1168
  },
@@ -1080,18 +1172,20 @@ var providers = defineProviders({
1080
1172
  isRefreshable: true,
1081
1173
  profileRequest: {
1082
1174
  authIn: "query",
1175
+ encoding: "application/json",
1083
1176
  method: "GET",
1084
1177
  url: "https://slack.com/api/users.identity"
1085
1178
  },
1086
1179
  revocationRequest: {
1087
1180
  authIn: "body",
1181
+ encoding: "application/json",
1088
1182
  tokenParamName: "token",
1089
1183
  url: "https://slack.com/api/auth.revoke"
1090
1184
  },
1091
1185
  scopeRequired: true,
1092
1186
  tokenRequest: {
1093
1187
  authIn: "body",
1094
- encoding: "form",
1188
+ encoding: "application/x-www-form-urlencoded",
1095
1189
  url: "https://slack.com/api/openid.connect.token"
1096
1190
  }
1097
1191
  },
@@ -1102,13 +1196,14 @@ var providers = defineProviders({
1102
1196
  PKCEMethod: "S256",
1103
1197
  profileRequest: {
1104
1198
  authIn: "header",
1199
+ encoding: "application/json",
1105
1200
  method: "GET",
1106
1201
  url: "https://api.spotify.com/v1/me"
1107
1202
  },
1108
1203
  scopeRequired: false,
1109
1204
  tokenRequest: {
1110
1205
  authIn: "body",
1111
- encoding: "form",
1206
+ encoding: "application/x-www-form-urlencoded",
1112
1207
  url: "https://accounts.spotify.com/api/token"
1113
1208
  }
1114
1209
  },
@@ -1121,6 +1216,7 @@ var providers = defineProviders({
1121
1216
  body: {
1122
1217
  query: `query { currentUser { id slug email player { gamerTag } } }`
1123
1218
  },
1219
+ encoding: "application/json",
1124
1220
  headers: {
1125
1221
  Accept: "application/json",
1126
1222
  "Content-Type": "application/json"
@@ -1131,7 +1227,7 @@ var providers = defineProviders({
1131
1227
  scopeRequired: false,
1132
1228
  tokenRequest: {
1133
1229
  authIn: "body",
1134
- encoding: "form",
1230
+ encoding: "application/x-www-form-urlencoded",
1135
1231
  url: "https://api.start.gg/oauth/access_token"
1136
1232
  }
1137
1233
  },
@@ -1142,6 +1238,7 @@ var providers = defineProviders({
1142
1238
  PKCEMethod: "S256",
1143
1239
  profileRequest: {
1144
1240
  authIn: "header",
1241
+ encoding: "application/json",
1145
1242
  method: "GET",
1146
1243
  url: "https://www.strava.com/api/v3/athlete"
1147
1244
  },
@@ -1150,13 +1247,14 @@ var providers = defineProviders({
1150
1247
  body: new URLSearchParams({
1151
1248
  token_type_hint: "access_token"
1152
1249
  }),
1250
+ encoding: "application/json",
1153
1251
  tokenParamName: "access_token",
1154
1252
  url: "https://www.strava.com/oauth/deauthorize"
1155
1253
  },
1156
1254
  scopeRequired: false,
1157
1255
  tokenRequest: {
1158
1256
  authIn: "body",
1159
- encoding: "form",
1257
+ encoding: "application/x-www-form-urlencoded",
1160
1258
  url: "https://www.strava.com/oauth/token"
1161
1259
  }
1162
1260
  },
@@ -1166,13 +1264,14 @@ var providers = defineProviders({
1166
1264
  isRefreshable: false,
1167
1265
  profileRequest: {
1168
1266
  authIn: "header",
1267
+ encoding: "application/json",
1169
1268
  method: "GET",
1170
1269
  url: (config) => `${config.baseURL}/webman/sso/SSOUserInfo.cgi?client_id=${config.clientId}&access_token=${config.accessToken}`
1171
1270
  },
1172
1271
  scopeRequired: false,
1173
1272
  tokenRequest: {
1174
1273
  authIn: "body",
1175
- encoding: "form",
1274
+ encoding: "application/x-www-form-urlencoded",
1176
1275
  url: (config) => `${config.baseURL}/webman/sso/SSOAccessToken.cgi?client_id=${config.clientId}&client_secret=${config.clientSecret}`
1177
1276
  }
1178
1277
  },
@@ -1186,18 +1285,20 @@ var providers = defineProviders({
1186
1285
  PKCEMethod: "S256",
1187
1286
  profileRequest: {
1188
1287
  authIn: "query",
1288
+ encoding: "application/json",
1189
1289
  method: "GET",
1190
1290
  url: "https://open.douyin.com/oauth/userinfo"
1191
1291
  },
1192
1292
  revocationRequest: {
1193
1293
  authIn: "body",
1294
+ encoding: "application/json",
1194
1295
  tokenParamName: "token",
1195
1296
  url: "https://open.tiktokapis.com/v2/oauth/revoke/"
1196
1297
  },
1197
1298
  scopeRequired: false,
1198
1299
  tokenRequest: {
1199
1300
  authIn: "body",
1200
- encoding: "form",
1301
+ encoding: "application/x-www-form-urlencoded",
1201
1302
  url: "https://open.tiktokapis.com/v2/oauth/token/"
1202
1303
  }
1203
1304
  },
@@ -1207,13 +1308,14 @@ var providers = defineProviders({
1207
1308
  isRefreshable: true,
1208
1309
  profileRequest: {
1209
1310
  authIn: "header",
1311
+ encoding: "application/json",
1210
1312
  method: "GET",
1211
1313
  url: "https://v5api.tiltify.com/api/public/current-user"
1212
1314
  },
1213
1315
  scopeRequired: false,
1214
1316
  tokenRequest: {
1215
1317
  authIn: "body",
1216
- encoding: "form",
1318
+ encoding: "application/x-www-form-urlencoded",
1217
1319
  url: "https://v5api.tiltify.com/oauth/token"
1218
1320
  }
1219
1321
  },
@@ -1223,13 +1325,14 @@ var providers = defineProviders({
1223
1325
  isRefreshable: true,
1224
1326
  profileRequest: {
1225
1327
  authIn: "header",
1328
+ encoding: "application/json",
1226
1329
  method: "GET",
1227
1330
  url: "https://api.tumblr.com/v2/user/info"
1228
1331
  },
1229
1332
  scopeRequired: false,
1230
1333
  tokenRequest: {
1231
1334
  authIn: "body",
1232
- encoding: "form",
1335
+ encoding: "application/x-www-form-urlencoded",
1233
1336
  url: "https://api.tumblr.com/v2/oauth2/token"
1234
1337
  }
1235
1338
  },
@@ -1239,6 +1342,7 @@ var providers = defineProviders({
1239
1342
  isRefreshable: true,
1240
1343
  profileRequest: {
1241
1344
  authIn: "header",
1345
+ encoding: "application/json",
1242
1346
  headers: (config) => ({
1243
1347
  "Client-Id": config.clientId
1244
1348
  }),
@@ -1247,6 +1351,7 @@ var providers = defineProviders({
1247
1351
  },
1248
1352
  revocationRequest: {
1249
1353
  authIn: "query",
1354
+ encoding: "application/json",
1250
1355
  headers: (config) => ({
1251
1356
  "Client-Id": config.clientId
1252
1357
  }),
@@ -1256,7 +1361,7 @@ var providers = defineProviders({
1256
1361
  scopeRequired: false,
1257
1362
  tokenRequest: {
1258
1363
  authIn: "body",
1259
- encoding: "form",
1364
+ encoding: "application/x-www-form-urlencoded",
1260
1365
  url: "https://id.twitch.tv/oauth2/token"
1261
1366
  }
1262
1367
  },
@@ -1267,17 +1372,19 @@ var providers = defineProviders({
1267
1372
  PKCEMethod: "S256",
1268
1373
  profileRequest: {
1269
1374
  authIn: "header",
1375
+ encoding: "application/json",
1270
1376
  method: "GET",
1271
1377
  url: "https://api.twitter.com/2/users/me"
1272
1378
  },
1273
1379
  revocationRequest: {
1274
1380
  authIn: "header",
1381
+ encoding: "application/json",
1275
1382
  url: "https://api.twitter.com/2/oauth2/revoke"
1276
1383
  },
1277
1384
  scopeRequired: false,
1278
1385
  tokenRequest: {
1279
1386
  authIn: "body",
1280
- encoding: "form",
1387
+ encoding: "application/x-www-form-urlencoded",
1281
1388
  url: "https://api.twitter.com/2/oauth2/token"
1282
1389
  }
1283
1390
  },
@@ -1287,16 +1394,70 @@ var providers = defineProviders({
1287
1394
  isRefreshable: false,
1288
1395
  profileRequest: {
1289
1396
  authIn: "query",
1397
+ encoding: "application/json",
1290
1398
  method: "GET",
1291
1399
  url: "https://api.vk.com/method/users.get"
1292
1400
  },
1293
1401
  scopeRequired: false,
1294
1402
  tokenRequest: {
1295
1403
  authIn: "body",
1296
- encoding: "form",
1404
+ encoding: "application/x-www-form-urlencoded",
1297
1405
  url: "https://oauth.vk.com/access_token"
1298
1406
  }
1299
1407
  },
1408
+ withings: {
1409
+ authorizationUrl: "https://account.withings.com/oauth2_user/authorize2",
1410
+ isOIDC: false,
1411
+ isRefreshable: true,
1412
+ profileRequest: {
1413
+ authIn: "header",
1414
+ body: async (config) => {
1415
+ const props = await getWithingsProps(config);
1416
+ if (props === undefined)
1417
+ throw new Error("Failed to get Withings search properties");
1418
+ const { nonce, hashedSignature } = props;
1419
+ return [
1420
+ ["action", "getuser"],
1421
+ ["nonce", nonce],
1422
+ ["client_id", config.clientId],
1423
+ ["signature", hashedSignature]
1424
+ ];
1425
+ },
1426
+ encoding: "application/x-www-form-urlencoded",
1427
+ method: "POST",
1428
+ url: "https://wbsapi.withings.net/v2/oauth2"
1429
+ },
1430
+ refreshAccessTokenBody: {
1431
+ action: "requesttoken"
1432
+ },
1433
+ revocationRequest: {
1434
+ authIn: "header",
1435
+ body: async (config) => {
1436
+ const props = await getWithingsProps(config);
1437
+ if (!props)
1438
+ throw new Error("Failed to get Withings props");
1439
+ const { nonce, hashedSignature } = props;
1440
+ return [
1441
+ ["action", "revoke"],
1442
+ ["client_id", config.clientId],
1443
+ ["nonce", nonce],
1444
+ ["signature", hashedSignature]
1445
+ ];
1446
+ },
1447
+ encoding: "application/x-www-form-urlencoded",
1448
+ method: "POST",
1449
+ url: "https://wbsapi.withings.net/v2/oauth2"
1450
+ },
1451
+ scopeRequired: true,
1452
+ tokenRequest: {
1453
+ authIn: "body",
1454
+ encoding: "application/x-www-form-urlencoded",
1455
+ url: "https://wbsapi.withings.net/v2/oauth2"
1456
+ },
1457
+ validateAuthorizationCodeBody: {
1458
+ action: "requesttoken"
1459
+ }
1460
+ },
1300
1461
  workos: {
1301
1462
  authorizationUrl: "https://api.workos.com/sso/authorize",
1302
1463
  isOIDC: true,
@@ -1304,13 +1465,14 @@ var providers = defineProviders({
1304
1465
  PKCEMethod: "S256",
1305
1466
  profileRequest: {
1306
1467
  authIn: "header",
1468
+ encoding: "application/json",
1307
1469
  method: "GET",
1308
1470
  url: "https://api.workos.com/sso/userinfo"
1309
1471
  },
1310
1472
  scopeRequired: false,
1311
1473
  tokenRequest: {
1312
1474
  authIn: "body",
1313
- encoding: "form",
1475
+ encoding: "application/x-www-form-urlencoded",
1314
1476
  url: "https://api.workos.com/sso/token"
1315
1477
  }
1316
1478
  },
@@ -1321,17 +1483,19 @@ var providers = defineProviders({
1321
1483
  PKCEMethod: "S256",
1322
1484
  profileRequest: {
1323
1485
  authIn: "header",
1486
+ encoding: "application/json",
1324
1487
  method: "GET",
1325
1488
  url: "https://api.login.yahoo.com/openid/v1/userinfo"
1326
1489
  },
1327
1490
  revocationRequest: {
1328
1491
  authIn: "header",
1492
+ encoding: "application/json",
1329
1493
  url: "https://api.login.yahoo.com/oauth2/revoke"
1330
1494
  },
1331
1495
  scopeRequired: false,
1332
1496
  tokenRequest: {
1333
1497
  authIn: "body",
1334
- encoding: "form",
1498
+ encoding: "application/x-www-form-urlencoded",
1335
1499
  url: "https://api.login.yahoo.com/oauth2/get_token"
1336
1500
  }
1337
1501
  },
@@ -1346,18 +1510,20 @@ var providers = defineProviders({
1346
1510
  PKCEMethod: "S256",
1347
1511
  profileRequest: {
1348
1512
  authIn: "header",
1513
+ encoding: "application/json",
1349
1514
  method: "GET",
1350
1515
  url: "https://login.yandex.ru/info"
1351
1516
  },
1352
1517
  revocationRequest: {
1353
1518
  authIn: "body",
1519
+ encoding: "application/json",
1354
1520
  tokenParamName: "access_token",
1355
1521
  url: "https://oauth.yandex.com/revoke_token"
1356
1522
  },
1357
1523
  scopeRequired: false,
1358
1524
  tokenRequest: {
1359
1525
  authIn: "body",
1360
- encoding: "form",
1526
+ encoding: "application/x-www-form-urlencoded",
1361
1527
  url: "https://oauth.yandex.com/token"
1362
1528
  }
1363
1529
  },
@@ -1368,11 +1534,13 @@ var providers = defineProviders({
1368
1534
  PKCEMethod: "S256",
1369
1535
  profileRequest: {
1370
1536
  authIn: "header",
1537
+ encoding: "application/json",
1371
1538
  method: "GET",
1372
1539
  url: "https://api.zoom.us/v2/users/me"
1373
1540
  },
1374
1541
  revocationRequest: {
1375
1542
  authIn: "query",
1543
+ encoding: "application/json",
1376
1544
  headers: (config) => ({
1377
1545
  Authorization: `Basic ${btoa(`${config.clientId}:${config.clientSecret}`)}`
1378
1546
  }),
@@ -1382,7 +1550,7 @@ var providers = defineProviders({
1382
1550
  scopeRequired: false,
1383
1551
  tokenRequest: {
1384
1552
  authIn: "body",
1385
- encoding: "form",
1553
+ encoding: "application/x-www-form-urlencoded",
1386
1554
  url: "https://zoom.us/oauth/token"
1387
1555
  }
1388
1556
  }
@@ -1393,12 +1561,15 @@ var oidcProviderOptions = Object.keys(providers).filter(isOIDCProviderOption);
1393
1561
  var revocableProviderOptions = Object.keys(providers).filter(isRevocableProviderOption);
1394
1562
  var scopeRequiredProviderOptions = Object.keys(providers).filter(isScopeRequiredProviderOption);
1395
1563
  var pkceProviderOptions = Object.keys(providers).filter(isPKCEProviderOption);
1396
- var createOAuth2Client = (providerName, config) => {
1564
+ var createOAuth2Client = async (providerName, config) => {
1397
1565
  const meta = providers[providerName];
1398
1566
  const isConfigPropertyFunction = (cfgProp) => typeof cfgProp === "function";
1399
- const resolveConfigProp = (cfgProp) => isConfigPropertyFunction(cfgProp) ? cfgProp(config) : cfgProp;
1400
- const authorizationUrl = resolveConfigProp(meta.authorizationUrl);
1401
- const tokenUrl = resolveConfigProp(meta.tokenRequest.url);
1567
+ const resolveConfigProp = async (cfgProp) => {
1568
+ const result = isConfigPropertyFunction(cfgProp) ? cfgProp(config) : cfgProp;
1569
+ return await result;
1570
+ };
1571
+ const authorizationUrl = await resolveConfigProp(meta.authorizationUrl);
1572
+ const tokenUrl = await resolveConfigProp(meta.tokenRequest.url);
1402
1573
  return {
1403
1574
  async createAuthorizationUrl(opts) {
1404
1575
  const { state, scope = [], searchParams = [], codeVerifier } = opts;
@@ -1409,8 +1580,10 @@ var createOAuth2Client = (providerName, config) => {
1409
1580
  url.searchParams.set("redirect_uri", config.redirectUri);
1410
1581
  if (state)
1411
1582
  url.searchParams.set("state", state);
1412
- if (scope.length)
1413
- url.searchParams.set("scope", scope.join(" "));
1583
+ if (scope.length !== 0) {
1584
+ const delimeter = providerName === "withings" ? "," : " ";
1585
+ url.searchParams.set("scope", scope.join(delimeter));
1586
+ }
1414
1587
  if (meta.PKCEMethod !== undefined) {
1415
1588
  if (!codeVerifier) {
1416
1589
  throw new Error("`codeVerifier` is required when PKCE is enabled");
@@ -1431,28 +1604,30 @@ var createOAuth2Client = (providerName, config) => {
1431
1604
  authIn,
1432
1605
  searchParams,
1433
1606
  body: profileBody,
1434
- headers
1607
+ headers,
1608
+ encoding
1435
1609
  } = profileRequest;
1436
- const endpoint = new URL(resolveConfigProp(url));
1437
- new URLSearchParams(searchParams).forEach((value, key) => endpoint.searchParams.append(key, value));
1610
+ const endpoint = new URL(await resolveConfigProp(url));
1611
+ const resolvedBody = await resolveConfigProp(profileBody);
1612
+ new URLSearchParams(await resolveConfigProp(searchParams)).forEach((value, key) => endpoint.searchParams.append(key, value));
1438
1613
  let headerEntries = [];
1439
- const rawHeaders = headers ? resolveConfigProp(headers) : undefined;
1614
+ const rawHeaders = headers ? await resolveConfigProp(headers) : undefined;
1440
1615
  if (rawHeaders instanceof Headers)
1441
1616
  headerEntries = Array.from(rawHeaders.entries());
1442
1617
  else if (Array.isArray(rawHeaders))
1443
1618
  headerEntries = rawHeaders;
1444
1619
  else if (rawHeaders && typeof rawHeaders === "object")
1445
1620
  headerEntries = Object.entries(rawHeaders);
1446
- const profileHeaders = Object.fromEntries(headerEntries.filter(([, value]) => value !== ""));
1621
+ const profileHeaders = Object.fromEntries(headerEntries.filter(([, v]) => v !== ""));
1447
1622
  if (authIn === "header") {
1448
1623
  profileHeaders.Authorization = `Bearer ${accessToken}`;
1449
1624
  } else {
1450
1625
  endpoint.searchParams.append("access_token", accessToken);
1451
1626
  }
1452
1627
  const init = { headers: profileHeaders, method };
1453
- if (method === "POST" && profileBody) {
1454
- profileHeaders["Content-Type"] = "application/json";
1455
- init.body = JSON.stringify(profileBody);
1628
+ if (method === "POST" && resolvedBody != null) {
1629
+ profileHeaders["Content-Type"] = encoding;
1630
+ init.body = encoding === "application/json" ? JSON.stringify(resolvedBody) : new URLSearchParams(resolvedBody).toString();
1456
1631
  }
1457
1632
  const response = await fetch(endpoint.toString(), init);
1458
1633
  if (!response.ok)
@@ -1490,9 +1665,10 @@ var createOAuth2Client = (providerName, config) => {
1490
1665
  throw new Error("Token revocation not defined for this provider");
1491
1666
  }
1492
1667
  const { url, authIn, body, headers, tokenParamName } = revocationRequest;
1493
- const endpoint = resolveConfigProp(url);
1494
- const revocationBody = body ?? new URLSearchParams;
1495
- const revocationHeaders = new Headers(headers && resolveConfigProp(headers));
1668
+ const endpoint = await resolveConfigProp(url);
1669
+ const resolvedBody = await resolveConfigProp(body);
1670
+ const revocationBody = new URLSearchParams(resolvedBody);
1671
+ const revocationHeaders = new Headers(headers && await resolveConfigProp(headers));
1496
1672
  const { clientId } = config;
1497
1673
  const clientSecret = hasClientSecret(config) ? config.clientSecret : undefined;
1498
1674
  let request;
@@ -1506,7 +1682,7 @@ var createOAuth2Client = (providerName, config) => {
1506
1682
  body: revocationBody,
1507
1683
  clientId,
1508
1684
  clientSecret,
1509
- encoding: "form",
1685
+ encoding: "application/x-www-form-urlencoded",
1510
1686
  headers: revocationHeaders,
1511
1687
  url: endpoint.toString()
1512
1688
  });
@@ -1517,7 +1693,7 @@ var createOAuth2Client = (providerName, config) => {
1517
1693
  body: revocationBody,
1518
1694
  clientId,
1519
1695
  clientSecret,
1520
- encoding: "form",
1696
+ encoding: "application/x-www-form-urlencoded",
1521
1697
  headers: revocationHeaders,
1522
1698
  url: endpoint.toString()
1523
1699
  });
@@ -1527,7 +1703,7 @@ var createOAuth2Client = (providerName, config) => {
1527
1703
  body: revocationBody,
1528
1704
  clientId,
1529
1705
  clientSecret,
1530
- encoding: "form",
1706
+ encoding: "application/x-www-form-urlencoded",
1531
1707
  headers: revocationHeaders,
1532
1708
  url: `${endpoint.toString()}?${tokenParamName}=${token}`
1533
1709
  });
@@ -1555,7 +1731,7 @@ var createOAuth2Client = (providerName, config) => {
1555
1731
  }
1556
1732
  bodyObj.code_verifier = codeVerifier;
1557
1733
  }
1558
- const payload = encoding === "json" ? bodyObj : new URLSearchParams(bodyObj);
1734
+ const payload = encoding === "application/json" ? bodyObj : new URLSearchParams(bodyObj);
1559
1735
  const request = createOAuth2Request({
1560
1736
  authIn,
1561
1737
  body: payload,
@@ -1727,13 +1903,12 @@ var callback = ({
1727
1903
  }
1728
1904
  try {
1729
1905
  const tokenResponse = await providerInstance.validateAuthorizationCode(requiresPKCE ? { code, codeVerifier: verifier } : { code });
1730
- const userProfile = tokenResponse.id_token ? decodeJWT(tokenResponse.id_token) : await providerInstance.fetchUserProfile(tokenResponse.access_token);
1731
1906
  await onCallback?.({
1732
1907
  authProvider,
1908
+ providerInstance,
1733
1909
  session,
1734
1910
  tokenResponse,
1735
- user_session_id,
1736
- userProfile
1911
+ user_session_id
1737
1912
  });
1738
1913
  const redirectUrl = redirect_url?.value ?? "/";
1739
1914
  return redirect(redirectUrl);
@@ -1950,7 +2125,6 @@ var signout = ({
1950
2125
  // src/status.ts
1951
2126
  import { Elysia as Elysia9 } from "elysia";
1952
2127
  var status = ({
1953
- clientProviders,
1954
2128
  statusRoute = "/oauth2/status",
1955
2129
  onStatus
1956
2130
  }) => new Elysia9().use(sessionStore()).get(statusRoute, async ({
@@ -1996,13 +2170,23 @@ var status = ({
1996
2170
  // src/utils.ts
1997
2171
  var instantiateUserSession = async ({
1998
2172
  user_session_id,
2173
+ authProvider,
1999
2174
  session,
2000
2175
  tokenResponse,
2176
+ providerInstance,
2001
2177
  getUser,
2002
2178
  createUser
2003
2179
  }) => {
2004
- let user = await getUser();
2005
- user = user ?? await createUser();
2180
+ let userProfile;
2181
+ if (tokenResponse.id_token) {
2182
+ userProfile = decodeJWT(tokenResponse.id_token);
2183
+ } else if (authProvider === "withings") {
2184
+ userProfile = tokenResponse.body;
2185
+ } else {
2186
+ userProfile = await providerInstance.fetchUserProfile(tokenResponse.access_token);
2187
+ }
2188
+ let user = await getUser(userProfile);
2189
+ user = user ?? await createUser(userProfile);
2006
2190
  if (!isValidUser(user))
2007
2191
  throw new Error("Internal Server Error - Invalid user schema");
2008
2192
  const sessionKey = crypto.randomUUID();
@@ -2023,7 +2207,7 @@ var createAuthConfiguration = (configuration) => configuration;
2023
2207
  var createProvidersConfiguration = (providersConfiguration) => providersConfiguration;
2024
2208
 
2025
2209
  // src/index.ts
2026
- var absoluteAuth = ({
2210
+ var absoluteAuth = async ({
2027
2211
  providersConfiguration,
2028
2212
  authorizeRoute,
2029
2213
  callbackRoute,
@@ -2040,17 +2224,21 @@ var absoluteAuth = ({
2040
2224
  onSignOut,
2041
2225
  onRevocation
2042
2226
  }) => {
2043
- const clientProviders = Object.entries(providersConfiguration).reduce((acc, [providerName, providerConfig]) => {
2044
- if (isValidProviderOption(providerName)) {
2045
- acc[providerName] = {
2046
- providerInstance: createOAuth2Client(providerName, providerConfig.credentials),
2227
+ const entryPromises = [];
2228
+ for (const [providerName, providerConfig] of Object.entries(providersConfiguration)) {
2229
+ if (!isValidProviderOption(providerName))
2230
+ continue;
2231
+ entryPromises.push(createOAuth2Client(providerName, providerConfig.credentials).then((providerInstance) => [
2232
+ providerName,
2233
+ {
2234
+ providerInstance,
2047
2235
  scope: providerConfig.scope,
2048
2236
  searchParams: providerConfig.searchParams
2049
- };
2050
- }
2051
- return acc;
2052
- }, {});
2053
- return new Elysia10().use(signout({ onSignOut, signoutRoute })).use(revoke({ clientProviders, onRevocation, revokeRoute })).use(status({ clientProviders, onStatus, statusRoute })).use(refresh({ clientProviders, onRefresh, refreshRoute })).use(authorize({ authorizeRoute, clientProviders, onAuthorize })).use(callback({
2237
+ }
2238
+ ]));
2239
+ }
2240
+ const clientProviders = Object.fromEntries(await Promise.all(entryPromises));
2241
+ return new Elysia10().use(signout({ onSignOut, signoutRoute })).use(revoke({ clientProviders, onRevocation, revokeRoute })).use(status({ onStatus, statusRoute })).use(refresh({ clientProviders, onRefresh, refreshRoute })).use(authorize({ authorizeRoute, clientProviders, onAuthorize })).use(callback({
2054
2242
  callbackRoute,
2055
2243
  clientProviders,
2056
2244
  onCallback