@slates/provider-handler 1.0.0-rc.10 → 1.0.0-rc.15

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.cjs CHANGED
@@ -321,6 +321,7 @@ var createProviderHandler = (slate, listeners) => (0, import_proto.createSlatesP
321
321
  auth: currentAuth
322
322
  };
323
323
  };
324
+ let getAuthConfig = () => config.get()?.value ?? {};
324
325
  let getEmptyContext = () => new import_provider2.SlateContext({}, {}, {}, slate.spec, logger);
325
326
  let withRequestTraces = (context, result) => {
326
327
  let requestTraces = context.getHttpTraces();
@@ -590,7 +591,9 @@ var createProviderHandler = (slate, listeners) => (0, import_proto.createSlatesP
590
591
  clientId: params.clientId,
591
592
  clientSecret: params.clientSecret,
592
593
  scopes: params.scopes,
593
- callbackState: params.callbackState || {}
594
+ callbackParams: params.callbackParams || {},
595
+ callbackState: params.callbackState || {},
596
+ config: getAuthConfig()
594
597
  })
595
598
  )
596
599
  );
@@ -636,7 +639,8 @@ var createProviderHandler = (slate, listeners) => (0, import_proto.createSlatesP
636
639
  input: params.input,
637
640
  clientId: params.clientId,
638
641
  clientSecret: params.clientSecret,
639
- scopes: params.scopes
642
+ scopes: params.scopes,
643
+ config: getAuthConfig()
640
644
  })
641
645
  )
642
646
  );
@@ -674,14 +678,20 @@ var createProviderHandler = (slate, listeners) => (0, import_proto.createSlatesP
674
678
  profileKeyCount: getObjectKeyCount(result.profile)
675
679
  })
676
680
  },
677
- () => (0, import_provider2.runWithContext)(
678
- context,
679
- () => authMethod.getProfile({
681
+ () => (0, import_provider2.runWithContext)(context, () => {
682
+ if (authMethod.type === "auth.oauth") {
683
+ return authMethod.getProfile({
684
+ output: params.output,
685
+ input: params.input,
686
+ scopes: params.scopes,
687
+ config: getAuthConfig()
688
+ });
689
+ }
690
+ return authMethod.getProfile({
680
691
  output: params.output,
681
- input: params.input,
682
- scopes: params.scopes
683
- })
684
- )
692
+ input: params.input
693
+ });
694
+ })
685
695
  );
686
696
  return withRequestTraces(context, {
687
697
  profile: profileRes.profile
@@ -716,16 +726,25 @@ var createProviderHandler = (slate, listeners) => (0, import_proto.createSlatesP
716
726
  returnedInput: !!result.input
717
727
  })
718
728
  },
719
- () => (0, import_provider2.runWithContext)(
720
- context,
721
- () => authMethod.handleTokenRefresh({
729
+ () => (0, import_provider2.runWithContext)(context, () => {
730
+ if (authMethod.type === "auth.oauth") {
731
+ return authMethod.handleTokenRefresh({
732
+ output: params.output,
733
+ input: params.input,
734
+ clientId: params.clientId,
735
+ clientSecret: params.clientSecret,
736
+ scopes: params.scopes,
737
+ config: getAuthConfig()
738
+ });
739
+ }
740
+ return authMethod.handleTokenRefresh({
722
741
  output: params.output,
723
742
  input: params.input,
724
743
  clientId: params.clientId,
725
744
  clientSecret: params.clientSecret,
726
745
  scopes: params.scopes
727
- })
728
- )
746
+ });
747
+ })
729
748
  );
730
749
  return withRequestTraces(context, {
731
750
  output: refreshRes.output,
@@ -294,6 +294,7 @@ var createProviderHandler = (slate, listeners) => createSlatesProviderProtoHandl
294
294
  auth: currentAuth
295
295
  };
296
296
  };
297
+ let getAuthConfig = () => config.get()?.value ?? {};
297
298
  let getEmptyContext = () => new SlateContext({}, {}, {}, slate.spec, logger);
298
299
  let withRequestTraces = (context, result) => {
299
300
  let requestTraces = context.getHttpTraces();
@@ -563,7 +564,9 @@ var createProviderHandler = (slate, listeners) => createSlatesProviderProtoHandl
563
564
  clientId: params.clientId,
564
565
  clientSecret: params.clientSecret,
565
566
  scopes: params.scopes,
566
- callbackState: params.callbackState || {}
567
+ callbackParams: params.callbackParams || {},
568
+ callbackState: params.callbackState || {},
569
+ config: getAuthConfig()
567
570
  })
568
571
  )
569
572
  );
@@ -609,7 +612,8 @@ var createProviderHandler = (slate, listeners) => createSlatesProviderProtoHandl
609
612
  input: params.input,
610
613
  clientId: params.clientId,
611
614
  clientSecret: params.clientSecret,
612
- scopes: params.scopes
615
+ scopes: params.scopes,
616
+ config: getAuthConfig()
613
617
  })
614
618
  )
615
619
  );
@@ -647,14 +651,20 @@ var createProviderHandler = (slate, listeners) => createSlatesProviderProtoHandl
647
651
  profileKeyCount: getObjectKeyCount(result.profile)
648
652
  })
649
653
  },
650
- () => runWithContext(
651
- context,
652
- () => authMethod.getProfile({
654
+ () => runWithContext(context, () => {
655
+ if (authMethod.type === "auth.oauth") {
656
+ return authMethod.getProfile({
657
+ output: params.output,
658
+ input: params.input,
659
+ scopes: params.scopes,
660
+ config: getAuthConfig()
661
+ });
662
+ }
663
+ return authMethod.getProfile({
653
664
  output: params.output,
654
- input: params.input,
655
- scopes: params.scopes
656
- })
657
- )
665
+ input: params.input
666
+ });
667
+ })
658
668
  );
659
669
  return withRequestTraces(context, {
660
670
  profile: profileRes.profile
@@ -689,16 +699,25 @@ var createProviderHandler = (slate, listeners) => createSlatesProviderProtoHandl
689
699
  returnedInput: !!result.input
690
700
  })
691
701
  },
692
- () => runWithContext(
693
- context,
694
- () => authMethod.handleTokenRefresh({
702
+ () => runWithContext(context, () => {
703
+ if (authMethod.type === "auth.oauth") {
704
+ return authMethod.handleTokenRefresh({
705
+ output: params.output,
706
+ input: params.input,
707
+ clientId: params.clientId,
708
+ clientSecret: params.clientSecret,
709
+ scopes: params.scopes,
710
+ config: getAuthConfig()
711
+ });
712
+ }
713
+ return authMethod.handleTokenRefresh({
695
714
  output: params.output,
696
715
  input: params.input,
697
716
  clientId: params.clientId,
698
717
  clientSecret: params.clientSecret,
699
718
  scopes: params.scopes
700
- })
701
- )
719
+ });
720
+ })
702
721
  );
703
722
  return withRequestTraces(context, {
704
723
  output: refreshRes.output,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slates/provider-handler",
3
- "version": "1.0.0-rc.10",
3
+ "version": "1.0.0-rc.15",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -26,14 +26,14 @@
26
26
  "unpkg": "./dist/index.module.js",
27
27
  "scripts": {
28
28
  "test": "vitest run --passWithNoTests",
29
- "lint": "prettier src/**/*.ts --check",
30
29
  "build": "tsup --config ../../tsup.packages.config.ts",
31
- "typecheck": "tsc --noEmit"
30
+ "typecheck": "tsc --noEmit",
31
+ "biome:check": "biome check --write src"
32
32
  },
33
33
  "dependencies": {
34
34
  "@lowerdeck/error": "^1.1.0",
35
- "@slates/proto": "1.0.0-rc.9",
36
- "@slates/provider": "1.0.0-rc.11",
35
+ "@slates/proto": "1.0.0-rc.10",
36
+ "@slates/provider": "1.0.0-rc.14",
37
37
  "zod": "^4.2.1"
38
38
  },
39
39
  "devDependencies": {
package/src/index.ts CHANGED
@@ -225,6 +225,8 @@ export let createProviderHandler = <ConfigType extends {}, AuthType extends {}>(
225
225
  };
226
226
  };
227
227
 
228
+ let getAuthConfig = (): Record<string, any> => config.get()?.value ?? {};
229
+
228
230
  let getEmptyContext = () => new SlateContext({}, {}, {}, slate.spec as any, logger);
229
231
  let withRequestTraces = <Result extends Record<string, any>>(
230
232
  context: SlateContext<any, any, any>,
@@ -539,7 +541,9 @@ export let createProviderHandler = <ConfigType extends {}, AuthType extends {}>(
539
541
  clientId: params.clientId,
540
542
  clientSecret: params.clientSecret,
541
543
  scopes: params.scopes,
542
- callbackState: params.callbackState || {}
544
+ callbackParams: params.callbackParams || {},
545
+ callbackState: params.callbackState || {},
546
+ config: getAuthConfig()
543
547
  })
544
548
  )
545
549
  );
@@ -589,7 +593,8 @@ export let createProviderHandler = <ConfigType extends {}, AuthType extends {}>(
589
593
  input: params.input,
590
594
  clientId: params.clientId,
591
595
  clientSecret: params.clientSecret,
592
- scopes: params.scopes
596
+ scopes: params.scopes,
597
+ config: getAuthConfig()
593
598
  })
594
599
  )
595
600
  );
@@ -632,15 +637,21 @@ export let createProviderHandler = <ConfigType extends {}, AuthType extends {}>(
632
637
  })
633
638
  },
634
639
  () =>
635
- runWithContext(
636
- context,
637
- () =>
638
- authMethod.getProfile!({
640
+ runWithContext(context, () => {
641
+ if (authMethod.type === 'auth.oauth') {
642
+ return authMethod.getProfile!({
639
643
  output: params.output as any,
640
644
  input: params.input,
641
- scopes: params.scopes
642
- })!
643
- )
645
+ scopes: params.scopes,
646
+ config: getAuthConfig()
647
+ });
648
+ }
649
+
650
+ return authMethod.getProfile!({
651
+ output: params.output as any,
652
+ input: params.input
653
+ })!;
654
+ })
644
655
  );
645
656
 
646
657
  return withRequestTraces(context, {
@@ -680,15 +691,26 @@ export let createProviderHandler = <ConfigType extends {}, AuthType extends {}>(
680
691
  })
681
692
  },
682
693
  () =>
683
- runWithContext(context, () =>
684
- authMethod.handleTokenRefresh!({
694
+ runWithContext(context, () => {
695
+ if (authMethod.type === 'auth.oauth') {
696
+ return authMethod.handleTokenRefresh!({
697
+ output: params.output as any,
698
+ input: params.input,
699
+ clientId: params.clientId,
700
+ clientSecret: params.clientSecret,
701
+ scopes: params.scopes,
702
+ config: getAuthConfig()
703
+ });
704
+ }
705
+
706
+ return authMethod.handleTokenRefresh!({
685
707
  output: params.output as any,
686
708
  input: params.input,
687
709
  clientId: params.clientId,
688
710
  clientSecret: params.clientSecret,
689
711
  scopes: params.scopes
690
- })
691
- )
712
+ });
713
+ })
692
714
  );
693
715
 
694
716
  return withRequestTraces(context, {