@slates/provider-handler 1.0.0-rc.11 → 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 +32 -14
- package/dist/index.module.js +32 -14
- package/package.json +5 -5
- package/src/index.ts +34 -13
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();
|
|
@@ -591,7 +592,8 @@ var createProviderHandler = (slate, listeners) => (0, import_proto.createSlatesP
|
|
|
591
592
|
clientSecret: params.clientSecret,
|
|
592
593
|
scopes: params.scopes,
|
|
593
594
|
callbackParams: params.callbackParams || {},
|
|
594
|
-
callbackState: params.callbackState || {}
|
|
595
|
+
callbackState: params.callbackState || {},
|
|
596
|
+
config: getAuthConfig()
|
|
595
597
|
})
|
|
596
598
|
)
|
|
597
599
|
);
|
|
@@ -637,7 +639,8 @@ var createProviderHandler = (slate, listeners) => (0, import_proto.createSlatesP
|
|
|
637
639
|
input: params.input,
|
|
638
640
|
clientId: params.clientId,
|
|
639
641
|
clientSecret: params.clientSecret,
|
|
640
|
-
scopes: params.scopes
|
|
642
|
+
scopes: params.scopes,
|
|
643
|
+
config: getAuthConfig()
|
|
641
644
|
})
|
|
642
645
|
)
|
|
643
646
|
);
|
|
@@ -675,14 +678,20 @@ var createProviderHandler = (slate, listeners) => (0, import_proto.createSlatesP
|
|
|
675
678
|
profileKeyCount: getObjectKeyCount(result.profile)
|
|
676
679
|
})
|
|
677
680
|
},
|
|
678
|
-
() => (0, import_provider2.runWithContext)(
|
|
679
|
-
|
|
680
|
-
|
|
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({
|
|
681
691
|
output: params.output,
|
|
682
|
-
input: params.input
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
)
|
|
692
|
+
input: params.input
|
|
693
|
+
});
|
|
694
|
+
})
|
|
686
695
|
);
|
|
687
696
|
return withRequestTraces(context, {
|
|
688
697
|
profile: profileRes.profile
|
|
@@ -717,16 +726,25 @@ var createProviderHandler = (slate, listeners) => (0, import_proto.createSlatesP
|
|
|
717
726
|
returnedInput: !!result.input
|
|
718
727
|
})
|
|
719
728
|
},
|
|
720
|
-
() => (0, import_provider2.runWithContext)(
|
|
721
|
-
|
|
722
|
-
|
|
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({
|
|
723
741
|
output: params.output,
|
|
724
742
|
input: params.input,
|
|
725
743
|
clientId: params.clientId,
|
|
726
744
|
clientSecret: params.clientSecret,
|
|
727
745
|
scopes: params.scopes
|
|
728
|
-
})
|
|
729
|
-
)
|
|
746
|
+
});
|
|
747
|
+
})
|
|
730
748
|
);
|
|
731
749
|
return withRequestTraces(context, {
|
|
732
750
|
output: refreshRes.output,
|
package/dist/index.module.js
CHANGED
|
@@ -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();
|
|
@@ -564,7 +565,8 @@ var createProviderHandler = (slate, listeners) => createSlatesProviderProtoHandl
|
|
|
564
565
|
clientSecret: params.clientSecret,
|
|
565
566
|
scopes: params.scopes,
|
|
566
567
|
callbackParams: params.callbackParams || {},
|
|
567
|
-
callbackState: params.callbackState || {}
|
|
568
|
+
callbackState: params.callbackState || {},
|
|
569
|
+
config: getAuthConfig()
|
|
568
570
|
})
|
|
569
571
|
)
|
|
570
572
|
);
|
|
@@ -610,7 +612,8 @@ var createProviderHandler = (slate, listeners) => createSlatesProviderProtoHandl
|
|
|
610
612
|
input: params.input,
|
|
611
613
|
clientId: params.clientId,
|
|
612
614
|
clientSecret: params.clientSecret,
|
|
613
|
-
scopes: params.scopes
|
|
615
|
+
scopes: params.scopes,
|
|
616
|
+
config: getAuthConfig()
|
|
614
617
|
})
|
|
615
618
|
)
|
|
616
619
|
);
|
|
@@ -648,14 +651,20 @@ var createProviderHandler = (slate, listeners) => createSlatesProviderProtoHandl
|
|
|
648
651
|
profileKeyCount: getObjectKeyCount(result.profile)
|
|
649
652
|
})
|
|
650
653
|
},
|
|
651
|
-
() => runWithContext(
|
|
652
|
-
|
|
653
|
-
|
|
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({
|
|
654
664
|
output: params.output,
|
|
655
|
-
input: params.input
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
)
|
|
665
|
+
input: params.input
|
|
666
|
+
});
|
|
667
|
+
})
|
|
659
668
|
);
|
|
660
669
|
return withRequestTraces(context, {
|
|
661
670
|
profile: profileRes.profile
|
|
@@ -690,16 +699,25 @@ var createProviderHandler = (slate, listeners) => createSlatesProviderProtoHandl
|
|
|
690
699
|
returnedInput: !!result.input
|
|
691
700
|
})
|
|
692
701
|
},
|
|
693
|
-
() => runWithContext(
|
|
694
|
-
|
|
695
|
-
|
|
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({
|
|
696
714
|
output: params.output,
|
|
697
715
|
input: params.input,
|
|
698
716
|
clientId: params.clientId,
|
|
699
717
|
clientSecret: params.clientSecret,
|
|
700
718
|
scopes: params.scopes
|
|
701
|
-
})
|
|
702
|
-
)
|
|
719
|
+
});
|
|
720
|
+
})
|
|
703
721
|
);
|
|
704
722
|
return withRequestTraces(context, {
|
|
705
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.
|
|
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.
|
|
36
|
-
"@slates/provider": "1.0.0-rc.
|
|
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>,
|
|
@@ -540,7 +542,8 @@ export let createProviderHandler = <ConfigType extends {}, AuthType extends {}>(
|
|
|
540
542
|
clientSecret: params.clientSecret,
|
|
541
543
|
scopes: params.scopes,
|
|
542
544
|
callbackParams: params.callbackParams || {},
|
|
543
|
-
callbackState: params.callbackState || {}
|
|
545
|
+
callbackState: params.callbackState || {},
|
|
546
|
+
config: getAuthConfig()
|
|
544
547
|
})
|
|
545
548
|
)
|
|
546
549
|
);
|
|
@@ -590,7 +593,8 @@ export let createProviderHandler = <ConfigType extends {}, AuthType extends {}>(
|
|
|
590
593
|
input: params.input,
|
|
591
594
|
clientId: params.clientId,
|
|
592
595
|
clientSecret: params.clientSecret,
|
|
593
|
-
scopes: params.scopes
|
|
596
|
+
scopes: params.scopes,
|
|
597
|
+
config: getAuthConfig()
|
|
594
598
|
})
|
|
595
599
|
)
|
|
596
600
|
);
|
|
@@ -633,15 +637,21 @@ export let createProviderHandler = <ConfigType extends {}, AuthType extends {}>(
|
|
|
633
637
|
})
|
|
634
638
|
},
|
|
635
639
|
() =>
|
|
636
|
-
runWithContext(
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
authMethod.getProfile!({
|
|
640
|
+
runWithContext(context, () => {
|
|
641
|
+
if (authMethod.type === 'auth.oauth') {
|
|
642
|
+
return authMethod.getProfile!({
|
|
640
643
|
output: params.output as any,
|
|
641
644
|
input: params.input,
|
|
642
|
-
scopes: params.scopes
|
|
643
|
-
|
|
644
|
-
|
|
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
|
+
})
|
|
645
655
|
);
|
|
646
656
|
|
|
647
657
|
return withRequestTraces(context, {
|
|
@@ -681,15 +691,26 @@ export let createProviderHandler = <ConfigType extends {}, AuthType extends {}>(
|
|
|
681
691
|
})
|
|
682
692
|
},
|
|
683
693
|
() =>
|
|
684
|
-
runWithContext(context, () =>
|
|
685
|
-
authMethod.
|
|
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!({
|
|
686
707
|
output: params.output as any,
|
|
687
708
|
input: params.input,
|
|
688
709
|
clientId: params.clientId,
|
|
689
710
|
clientSecret: params.clientSecret,
|
|
690
711
|
scopes: params.scopes
|
|
691
|
-
})
|
|
692
|
-
)
|
|
712
|
+
});
|
|
713
|
+
})
|
|
693
714
|
);
|
|
694
715
|
|
|
695
716
|
return withRequestTraces(context, {
|