wrangler 0.0.0-e928f94 → 0.0.0-e9a1820
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/package.json +13 -7
- package/src/__tests__/index.test.ts +254 -120
- package/src/__tests__/jest.setup.ts +18 -0
- package/src/__tests__/kv.test.ts +322 -0
- package/src/__tests__/mock-cfetch.ts +63 -0
- package/src/__tests__/mock-dialogs.ts +65 -0
- package/src/__tests__/run-in-tmp.ts +19 -0
- package/src/__tests__/run-wrangler.ts +32 -0
- package/src/api/form_data.ts +65 -75
- package/src/api/inspect.ts +0 -11
- package/src/api/worker.ts +33 -39
- package/src/cli.ts +6 -7
- package/src/config.ts +14 -5
- package/src/dev.tsx +264 -109
- package/src/dialogs.tsx +3 -11
- package/src/index.tsx +254 -210
- package/src/kv.tsx +65 -19
- package/src/pages.tsx +107 -99
- package/src/proxy.ts +103 -0
- package/src/publish.ts +37 -33
- package/src/user.tsx +9 -16
- package/wrangler-dist/cli.js +20754 -26926
- package/wrangler-dist/cli.js.map +3 -3
- package/src/__tests__/fixtures/init/.gitkeep +0 -0
- package/src/__tests__/mock-cfetch.js +0 -46
package/src/user.tsx
CHANGED
|
@@ -578,19 +578,16 @@ export async function getAuthURL(scopes?: string[]): Promise<string> {
|
|
|
578
578
|
* Refresh an access token from the remote service.
|
|
579
579
|
*/
|
|
580
580
|
async function exchangeRefreshTokenForAccessToken(): Promise<AccessContext> {
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
if (!refreshToken) {
|
|
581
|
+
if (!LocalState.refreshToken) {
|
|
584
582
|
console.warn("No refresh token is present.");
|
|
585
583
|
}
|
|
586
584
|
|
|
587
|
-
const url = TOKEN_URL;
|
|
588
585
|
const body =
|
|
589
586
|
`grant_type=refresh_token&` +
|
|
590
|
-
`refresh_token=${refreshToken?.value}&` +
|
|
587
|
+
`refresh_token=${LocalState.refreshToken?.value}&` +
|
|
591
588
|
`client_id=${CLIENT_ID}`;
|
|
592
589
|
|
|
593
|
-
const response = await fetch(
|
|
590
|
+
const response = await fetch(TOKEN_URL, {
|
|
594
591
|
method: "POST",
|
|
595
592
|
body,
|
|
596
593
|
headers: {
|
|
@@ -617,10 +614,9 @@ async function exchangeRefreshTokenForAccessToken(): Promise<AccessContext> {
|
|
|
617
614
|
LocalState.accessToken = accessToken;
|
|
618
615
|
|
|
619
616
|
if (refresh_token) {
|
|
620
|
-
|
|
617
|
+
LocalState.refreshToken = {
|
|
621
618
|
value: refresh_token,
|
|
622
619
|
};
|
|
623
|
-
LocalState.refreshToken = refreshToken;
|
|
624
620
|
}
|
|
625
621
|
|
|
626
622
|
if (scope) {
|
|
@@ -666,7 +662,6 @@ async function exchangeAuthCodeForAccessToken(): Promise<AccessContext> {
|
|
|
666
662
|
console.warn("No authorization grant code is being passed.");
|
|
667
663
|
}
|
|
668
664
|
|
|
669
|
-
const url = TOKEN_URL;
|
|
670
665
|
const body =
|
|
671
666
|
`grant_type=authorization_code&` +
|
|
672
667
|
`code=${encodeURIComponent(authorizationCode || "")}&` +
|
|
@@ -674,7 +669,7 @@ async function exchangeAuthCodeForAccessToken(): Promise<AccessContext> {
|
|
|
674
669
|
`client_id=${encodeURIComponent(CLIENT_ID)}&` +
|
|
675
670
|
`code_verifier=${codeVerifier}`;
|
|
676
671
|
|
|
677
|
-
const response = await fetch(
|
|
672
|
+
const response = await fetch(TOKEN_URL, {
|
|
678
673
|
method: "POST",
|
|
679
674
|
body,
|
|
680
675
|
headers: {
|
|
@@ -709,10 +704,9 @@ async function exchangeAuthCodeForAccessToken(): Promise<AccessContext> {
|
|
|
709
704
|
LocalState.accessToken = accessToken;
|
|
710
705
|
|
|
711
706
|
if (refresh_token) {
|
|
712
|
-
|
|
707
|
+
LocalState.refreshToken = {
|
|
713
708
|
value: refresh_token,
|
|
714
709
|
};
|
|
715
|
-
LocalState.refreshToken = refreshToken;
|
|
716
710
|
}
|
|
717
711
|
|
|
718
712
|
if (scope) {
|
|
@@ -816,7 +810,7 @@ export async function loginOrRefreshIfRequired(): Promise<boolean> {
|
|
|
816
810
|
|
|
817
811
|
export async function login(props?: LoginProps): Promise<boolean> {
|
|
818
812
|
const urlToOpen = await getAuthURL(props?.scopes);
|
|
819
|
-
open(urlToOpen);
|
|
813
|
+
await open(urlToOpen);
|
|
820
814
|
// TODO: log url only if on system where it's unreliable/unavailable
|
|
821
815
|
// console.log(`💁 Opened ${urlToOpen}`);
|
|
822
816
|
let server;
|
|
@@ -921,15 +915,14 @@ export async function refreshToken(): Promise<boolean> {
|
|
|
921
915
|
|
|
922
916
|
export async function logout(): Promise<void> {
|
|
923
917
|
throwIfNotInitialised();
|
|
924
|
-
|
|
925
|
-
if (!refreshToken) {
|
|
918
|
+
if (!LocalState.refreshToken) {
|
|
926
919
|
console.log("Not logged in, exiting...");
|
|
927
920
|
return;
|
|
928
921
|
}
|
|
929
922
|
const body =
|
|
930
923
|
`client_id=${encodeURIComponent(CLIENT_ID)}&` +
|
|
931
924
|
`token_type_hint=refresh_token&` +
|
|
932
|
-
`token=${encodeURIComponent(refreshToken?.value || "")}`;
|
|
925
|
+
`token=${encodeURIComponent(LocalState.refreshToken?.value || "")}`;
|
|
933
926
|
|
|
934
927
|
const response = await fetch(REVOKE_URL, {
|
|
935
928
|
method: "POST",
|