bento-get 1.112.0 → 1.112.2
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 +2 -2
- package/dist/hooks/useGithubAuth.js +0 -44
- package/dist/hooks/useGithubAuth.js.map +0 -6
- package/dist/hooks/useGithubAuth.mjs +0 -49
- package/dist/hooks/useGithubAuth.mjs.map +0 -1
- package/dist/hooks/useGithubAuth.native.js +0 -52
- package/dist/hooks/useGithubAuth.native.js.map +0 -1
- package/dist/hooks/useGithubAuthPooling.js +0 -45
- package/dist/hooks/useGithubAuthPooling.js.map +0 -6
- package/dist/hooks/useGithubAuthPooling.mjs +0 -51
- package/dist/hooks/useGithubAuthPooling.mjs.map +0 -1
- package/dist/hooks/useGithubAuthPooling.native.js +0 -58
- package/dist/hooks/useGithubAuthPooling.native.js.map +0 -1
- package/types/hooks/useGithubAuth.d.ts +0 -14
- package/types/hooks/useGithubAuth.d.ts.map +0 -1
- package/types/hooks/useGithubAuthPooling.d.ts +0 -9
- package/types/hooks/useGithubAuthPooling.d.ts.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bento-get",
|
|
3
|
-
"version": "1.112.
|
|
3
|
+
"version": "1.112.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"bin": "dist/cli.js",
|
|
6
6
|
"type": "module",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"zod": "^3.22.4"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@tamagui/build": "1.112.
|
|
60
|
+
"@tamagui/build": "1.112.2",
|
|
61
61
|
"@types/copy-paste": "^1.1.33",
|
|
62
62
|
"@types/react": "npm:@types/react@18.2.55"
|
|
63
63
|
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import querystring from "node:querystring";
|
|
3
|
-
import fetch from "node-fetch";
|
|
4
|
-
import open from "open";
|
|
5
|
-
import useSWR from "swr";
|
|
6
|
-
import { GITHUB_CLIENT_ID } from "../constants.js";
|
|
7
|
-
import { useGithubAuthPooling } from "./useGithubAuthPooling.js";
|
|
8
|
-
import { debugLog } from "../commands/index.js";
|
|
9
|
-
const fetcher = async (url) => {
|
|
10
|
-
const res = await fetch(url, {
|
|
11
|
-
method: "POST",
|
|
12
|
-
headers: { "Content-Type": "application/json" },
|
|
13
|
-
body: JSON.stringify({
|
|
14
|
-
client_id: GITHUB_CLIENT_ID,
|
|
15
|
-
scope: "read:org"
|
|
16
|
-
})
|
|
17
|
-
});
|
|
18
|
-
if (!res.ok) {
|
|
19
|
-
const error = new Error("An error occurred while fetching the data.");
|
|
20
|
-
throw error.info = await res.json(), error.status = res.status, error;
|
|
21
|
-
}
|
|
22
|
-
return await res.text();
|
|
23
|
-
}, useGithubAuth = () => {
|
|
24
|
-
const { data, error, isLoading } = useSWR(
|
|
25
|
-
"https://github.com/login/device/code",
|
|
26
|
-
fetcher
|
|
27
|
-
), parsedData = React.useMemo(() => data ? querystring.parse(data) : null, [data]);
|
|
28
|
-
debugLog({
|
|
29
|
-
parsedData
|
|
30
|
-
}), useGithubAuthPooling({ deviceCodeData: parsedData });
|
|
31
|
-
const openLoginUrl = React.useCallback(() => {
|
|
32
|
-
parsedData && open(parsedData.verification_uri);
|
|
33
|
-
}, [parsedData]);
|
|
34
|
-
return {
|
|
35
|
-
data: parsedData,
|
|
36
|
-
error,
|
|
37
|
-
isLoading,
|
|
38
|
-
openLoginUrl
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
export {
|
|
42
|
-
useGithubAuth
|
|
43
|
-
};
|
|
44
|
-
//# sourceMappingURL=useGithubAuth.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/hooks/useGithubAuth.tsx"],
|
|
4
|
-
"mappings": "AAAA,OAAO,WAAW;AAClB,OAAO,iBAAiB;AACxB,OAAO,WAAW;AAClB,OAAO,UAAU;AACjB,OAAO,YAAY;AAEnB,SAAS,wBAAwB;AACjC,SAAS,4BAA4B;AACrC,SAAS,gBAAgB;AAEzB,MAAM,UAAU,OAAO,QAAgB;AACrC,QAAM,MAAM,MAAM,MAAM,KAAK;AAAA,IAC3B,QAAQ;AAAA,IACR,SAAS,EAAE,gBAAgB,mBAAmB;AAAA,IAC9C,MAAM,KAAK,UAAU;AAAA,MACnB,WAAW;AAAA,MACX,OAAO;AAAA,IACT,CAAC;AAAA,EACH,CAAC;AACD,MAAI,CAAC,IAAI,IAAI;AACX,UAAM,QAAQ,IAAI,MAAM,4CAA4C;AAIpE,gBAAM,OAAO,MAAM,IAAI,KAAK,GAC5B,MAAM,SAAS,IAAI,QACb;AAAA,EACR;AAEA,SADe,MAAM,IAAI,KAAK;AAEhC,GAUa,gBAAgB,MAAM;AACjC,QAAM,EAAE,MAAM,OAAO,UAAU,IAAI;AAAA,IACjC;AAAA,IACA;AAAA,EACF,GAEM,aAAa,MAAM,QAAQ,MAC1B,OACE,YAAY,MAAM,IAAI,IADX,MAEjB,CAAC,IAAI,CAAC;AAET,WAAS;AAAA,IACP;AAAA,EACF,CAAC,GAED,qBAAqB,EAAE,gBAAgB,WAAW,CAAC;AAEnD,QAAM,eAAe,MAAM,YAAY,MAAM;AAC3C,IAAI,cACF,KAAK,WAAW,gBAAgB;AAAA,EAEpC,GAAG,CAAC,UAAU,CAAC;AAEf,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import querystring from "node:querystring";
|
|
3
|
-
import fetch from "node-fetch";
|
|
4
|
-
import open from "open";
|
|
5
|
-
import useSWR from "swr";
|
|
6
|
-
import { GITHUB_CLIENT_ID } from "../constants.js";
|
|
7
|
-
import { useGithubAuthPooling } from "./useGithubAuthPooling.js";
|
|
8
|
-
import { debugLog } from "../commands/index.js";
|
|
9
|
-
const fetcher = async url => {
|
|
10
|
-
const res = await fetch(url, {
|
|
11
|
-
method: "POST",
|
|
12
|
-
headers: {
|
|
13
|
-
"Content-Type": "application/json"
|
|
14
|
-
},
|
|
15
|
-
body: JSON.stringify({
|
|
16
|
-
client_id: GITHUB_CLIENT_ID,
|
|
17
|
-
scope: "read:org"
|
|
18
|
-
})
|
|
19
|
-
});
|
|
20
|
-
if (!res.ok) {
|
|
21
|
-
const error = new Error("An error occurred while fetching the data.");
|
|
22
|
-
throw error.info = await res.json(), error.status = res.status, error;
|
|
23
|
-
}
|
|
24
|
-
return await res.text();
|
|
25
|
-
},
|
|
26
|
-
useGithubAuth = () => {
|
|
27
|
-
const {
|
|
28
|
-
data,
|
|
29
|
-
error,
|
|
30
|
-
isLoading
|
|
31
|
-
} = useSWR("https://github.com/login/device/code", fetcher),
|
|
32
|
-
parsedData = React.useMemo(() => data ? querystring.parse(data) : null, [data]);
|
|
33
|
-
debugLog({
|
|
34
|
-
parsedData
|
|
35
|
-
}), useGithubAuthPooling({
|
|
36
|
-
deviceCodeData: parsedData
|
|
37
|
-
});
|
|
38
|
-
const openLoginUrl = React.useCallback(() => {
|
|
39
|
-
parsedData && open(parsedData.verification_uri);
|
|
40
|
-
}, [parsedData]);
|
|
41
|
-
return {
|
|
42
|
-
data: parsedData,
|
|
43
|
-
error,
|
|
44
|
-
isLoading,
|
|
45
|
-
openLoginUrl
|
|
46
|
-
};
|
|
47
|
-
};
|
|
48
|
-
export { useGithubAuth };
|
|
49
|
-
//# sourceMappingURL=useGithubAuth.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["React","querystring","fetch","open","useSWR","GITHUB_CLIENT_ID","useGithubAuthPooling","debugLog","fetcher","url","res","method","headers","body","JSON","stringify","client_id","scope","ok","error","Error","info","json","status","text","useGithubAuth","data","isLoading","parsedData","useMemo","parse","deviceCodeData","openLoginUrl","useCallback","verification_uri"],"sources":["../../src/hooks/useGithubAuth.tsx"],"sourcesContent":[null],"mappings":"AAAA,OAAOA,KAAA,MAAW;AAClB,OAAOC,WAAA,MAAiB;AACxB,OAAOC,KAAA,MAAW;AAClB,OAAOC,IAAA,MAAU;AACjB,OAAOC,MAAA,MAAY;AAEnB,SAASC,gBAAA,QAAwB;AACjC,SAASC,oBAAA,QAA4B;AACrC,SAASC,QAAA,QAAgB;AAEzB,MAAMC,OAAA,GAAU,MAAOC,GAAA,IAAgB;IACrC,MAAMC,GAAA,GAAM,MAAMR,KAAA,CAAMO,GAAA,EAAK;MAC3BE,MAAA,EAAQ;MACRC,OAAA,EAAS;QAAE,gBAAgB;MAAmB;MAC9CC,IAAA,EAAMC,IAAA,CAAKC,SAAA,CAAU;QACnBC,SAAA,EAAWX,gBAAA;QACXY,KAAA,EAAO;MACT,CAAC;IACH,CAAC;IACD,IAAI,CAACP,GAAA,CAAIQ,EAAA,EAAI;MACX,MAAMC,KAAA,GAAQ,IAAIC,KAAA,CAAM,4CAA4C;MAIpE,MAAAD,KAAA,CAAME,IAAA,GAAO,MAAMX,GAAA,CAAIY,IAAA,CAAK,GAC5BH,KAAA,CAAMI,MAAA,GAASb,GAAA,CAAIa,MAAA,EACbJ,KAAA;IACR;IAEA,OADe,MAAMT,GAAA,CAAIc,IAAA,CAAK;EAEhC;EAUaC,aAAA,GAAgBA,CAAA,KAAM;IACjC,MAAM;QAAEC,IAAA;QAAMP,KAAA;QAAOQ;MAAU,IAAIvB,MAAA,CACjC,wCACAI,OACF;MAEMoB,UAAA,GAAa5B,KAAA,CAAM6B,OAAA,CAAQ,MAC1BH,IAAA,GACEzB,WAAA,CAAY6B,KAAA,CAAMJ,IAAI,IADX,MAEjB,CAACA,IAAI,CAAC;IAETnB,QAAA,CAAS;MACPqB;IACF,CAAC,GAEDtB,oBAAA,CAAqB;MAAEyB,cAAA,EAAgBH;IAAW,CAAC;IAEnD,MAAMI,YAAA,GAAehC,KAAA,CAAMiC,WAAA,CAAY,MAAM;MACvCL,UAAA,IACFzB,IAAA,CAAKyB,UAAA,CAAWM,gBAAgB;IAEpC,GAAG,CAACN,UAAU,CAAC;IAEf,OAAO;MACLF,IAAA,EAAME,UAAA;MACNT,KAAA;MACAQ,SAAA;MACAK;IACF;EACF","ignoreList":[]}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import querystring from "node:querystring";
|
|
3
|
-
import fetch from "node-fetch";
|
|
4
|
-
import open from "open";
|
|
5
|
-
import useSWR from "swr";
|
|
6
|
-
import { GITHUB_CLIENT_ID } from "../constants.js";
|
|
7
|
-
import { useGithubAuthPooling } from "./useGithubAuthPooling.js";
|
|
8
|
-
import { debugLog } from "../commands/index.js";
|
|
9
|
-
var fetcher = async function (url) {
|
|
10
|
-
var res = await fetch(url, {
|
|
11
|
-
method: "POST",
|
|
12
|
-
headers: {
|
|
13
|
-
"Content-Type": "application/json"
|
|
14
|
-
},
|
|
15
|
-
body: JSON.stringify({
|
|
16
|
-
client_id: GITHUB_CLIENT_ID,
|
|
17
|
-
scope: "read:org"
|
|
18
|
-
})
|
|
19
|
-
});
|
|
20
|
-
if (!res.ok) {
|
|
21
|
-
var error = new Error("An error occurred while fetching the data.");
|
|
22
|
-
throw error.info = await res.json(), error.status = res.status, error;
|
|
23
|
-
}
|
|
24
|
-
var result = await res.text();
|
|
25
|
-
return result;
|
|
26
|
-
},
|
|
27
|
-
useGithubAuth = function () {
|
|
28
|
-
var {
|
|
29
|
-
data,
|
|
30
|
-
error,
|
|
31
|
-
isLoading
|
|
32
|
-
} = useSWR("https://github.com/login/device/code", fetcher),
|
|
33
|
-
parsedData = React.useMemo(function () {
|
|
34
|
-
return data ? querystring.parse(data) : null;
|
|
35
|
-
}, [data]);
|
|
36
|
-
debugLog({
|
|
37
|
-
parsedData
|
|
38
|
-
}), useGithubAuthPooling({
|
|
39
|
-
deviceCodeData: parsedData
|
|
40
|
-
});
|
|
41
|
-
var openLoginUrl = React.useCallback(function () {
|
|
42
|
-
parsedData && open(parsedData.verification_uri);
|
|
43
|
-
}, [parsedData]);
|
|
44
|
-
return {
|
|
45
|
-
data: parsedData,
|
|
46
|
-
error,
|
|
47
|
-
isLoading,
|
|
48
|
-
openLoginUrl
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
export { useGithubAuth };
|
|
52
|
-
//# sourceMappingURL=useGithubAuth.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["React","querystring","fetch","open","useSWR","GITHUB_CLIENT_ID","useGithubAuthPooling","debugLog","fetcher","url","res","method","headers","body","JSON","stringify","client_id","scope","ok","error","Error","info","json","status","result","text","useGithubAuth","data","isLoading","parsedData","useMemo","parse","deviceCodeData","openLoginUrl","useCallback","verification_uri"],"sources":["../../src/hooks/useGithubAuth.tsx"],"sourcesContent":[null],"mappings":"AAAA,OAAOA,KAAA,MAAW;AAClB,OAAOC,WAAA,MAAiB;AACxB,OAAOC,KAAA,MAAW;AAClB,OAAOC,IAAA,MAAU;AACjB,OAAOC,MAAA,MAAY;AAEnB,SAASC,gBAAA,QAAwB;AACjC,SAASC,oBAAA,QAA4B;AACrC,SAASC,QAAA,QAAgB;AAEzB,IAAAC,OAAM,kBAAAA,CAAiBC,GAAgB;IACrC,IAAAC,GAAM,SAAMR,KAAM,CAAAO,GAAM;MACtBE,MAAA,EAAQ;MACRC,OAAA,EAAS;QACT,cAAW;MAAU;MACRC,IACX,EAAAC,IAAO,CAAAC,SAAA;QACRC,SAAA,EAAAX,gBAAA;QACFY,KAAA;MACD;IACE;IAIA,KAAAP,GAAA,CAAAQ,EAAA;MAGF,IAAAC,KAAA,OAAAC,KAAA;MAEA,MADeD,KAAM,CAAAE,IAAI,SAAKX,GAAA,CAAAY,IAAA,IAAAH,KAAA,CAAAI,MAAA,GAAAb,GAAA,CAAAa,MAAA,EAAAJ,KAAA;IAEhC;IAWE,IAAAK,MAAQ,SAAMd,GAAO,CAAAe,IAAA;IAAc,OACjCD,MAAA;EAAA;EAAAE,aACA,YAAAA,CAAA;IACF,IAEM;QAAAC,IAAA;QAAAR,KAAa;QAAAS;MAAM,CAAQ,GAAAxB,MAC1B,uCAEH,EAAII,OAAC;MAAAqB,UAAA,GAAA7B,KAAA,CAAA8B,OAAA;QAET,OAASH,IAAA,GAAA1B,WAAA,CAAA8B,KAAA,CAAAJ,IAAA;MAAA,GACP,CACDA,IAED,CAEA;IACEpB,QAAI;MAGNsB;IAEA,IAAAvB,oBAAO;MACL0B,cAAM,EAAAH;IAAA,EACN;IAAA,IACAI,YAAA,GAAAjC,KAAA,CAAAkC,WAAA;MACAL,UAAA,IAAA1B,IAAA,CAAA0B,UAAA,CAAAM,gBAAA;IACF,IACFN,UAAA,C","ignoreList":[]}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import useSWR from "swr";
|
|
3
|
-
import { AppContext } from "../data/AppContext.js";
|
|
4
|
-
import { GITHUB_CLIENT_ID } from "../constants.js";
|
|
5
|
-
const useGithubAuthPooling = ({
|
|
6
|
-
deviceCodeData
|
|
7
|
-
}) => {
|
|
8
|
-
const appContext = React.useContext(AppContext), fetchAccessToken = async (url) => {
|
|
9
|
-
const response = await fetch(url, {
|
|
10
|
-
method: "POST",
|
|
11
|
-
headers: {
|
|
12
|
-
"Content-Type": "application/json",
|
|
13
|
-
Accept: "application/json"
|
|
14
|
-
},
|
|
15
|
-
body: JSON.stringify({
|
|
16
|
-
// client_id: deviceCodeData.client_id,
|
|
17
|
-
client_id: GITHUB_CLIENT_ID,
|
|
18
|
-
device_code: deviceCodeData?.device_code,
|
|
19
|
-
grant_type: "urn:ietf:params:oauth:grant-type:device_code"
|
|
20
|
-
})
|
|
21
|
-
});
|
|
22
|
-
if (!response.ok)
|
|
23
|
-
throw new Error("Failed to fetch access token");
|
|
24
|
-
const result = await response.json();
|
|
25
|
-
if (result.error)
|
|
26
|
-
throw new Error(result.error);
|
|
27
|
-
return result.access_token && (appContext.tokenStore.set("token", result), appContext.setInstallState((prev) => ({
|
|
28
|
-
...prev,
|
|
29
|
-
shouldOpenBrowser: !1
|
|
30
|
-
})), result.access_token), result;
|
|
31
|
-
}, { data, error, isLoading } = useSWR(
|
|
32
|
-
appContext.installState?.shouldOpenBrowser && deviceCodeData ? "https://github.com/login/oauth/access_token" : null,
|
|
33
|
-
fetchAccessToken,
|
|
34
|
-
{
|
|
35
|
-
onErrorRetry: (_error, _key, _config, revalidate, { retryCount }) => {
|
|
36
|
-
setTimeout(() => revalidate({ retryCount }), 5e3);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
);
|
|
40
|
-
return { data, error, isLoadingPooling: isLoading };
|
|
41
|
-
};
|
|
42
|
-
export {
|
|
43
|
-
useGithubAuthPooling
|
|
44
|
-
};
|
|
45
|
-
//# sourceMappingURL=useGithubAuthPooling.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/hooks/useGithubAuthPooling.tsx"],
|
|
4
|
-
"mappings": "AAAA,OAAO,WAAW;AAClB,OAAO,YAAY;AAEnB,SAAS,kBAAkB;AAC3B,SAAS,wBAAwB;AAG1B,MAAM,uBAAuB,CAAC;AAAA,EACnC;AACF,MAEM;AACJ,QAAM,aAAa,MAAM,WAAW,UAAU,GAExC,mBAAmB,OAAO,QAAgB;AAC9C,UAAM,WAAW,MAAM,MAAM,KAAK;AAAA,MAChC,QAAQ;AAAA,MACR,SAAS;AAAA,QACP,gBAAgB;AAAA,QAChB,QAAQ;AAAA,MACV;AAAA,MACA,MAAM,KAAK,UAAU;AAAA;AAAA,QAEnB,WAAW;AAAA,QACX,aAAa,gBAAgB;AAAA,QAC7B,YAAY;AAAA,MACd,CAAC;AAAA,IACH,CAAC;AACD,QAAI,CAAC,SAAS;AACZ,YAAM,IAAI,MAAM,8BAA8B;AAEhD,UAAM,SAAS,MAAM,SAAS,KAAK;AAEnC,QAAI,OAAO;AACT,YAAM,IAAI,MAAM,OAAO,KAAK;AAE9B,WAAI,OAAO,iBAET,WAAW,WAAW,IAAI,SAAS,MAAM,GACzC,WAAW,gBAAgB,CAAC,UACnB;AAAA,MACL,GAAG;AAAA,MACH,mBAAmB;AAAA,IACrB,EACD,GACD,OAAO,eAEF;AAAA,EACT,GAEM,EAAE,MAAM,OAAO,UAAU,IAAI;AAAA,IACjC,WAAW,cAAc,qBAAqB,iBAC1C,gDACA;AAAA,IACJ;AAAA,IACA;AAAA,MACE,cAAc,CAAC,QAAQ,MAAM,SAAS,YAAY,EAAE,WAAW,MAAM;AAWnE,mBAAW,MAAM,WAAW,EAAE,WAAW,CAAC,GAAG,GAAI;AAAA,MACnD;AAAA,IACF;AAAA,EACF;AACA,SAAO,EAAE,MAAM,OAAO,kBAAkB,UAAU;AACpD;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import useSWR from "swr";
|
|
3
|
-
import { AppContext } from "../data/AppContext.js";
|
|
4
|
-
import { GITHUB_CLIENT_ID } from "../constants.js";
|
|
5
|
-
const useGithubAuthPooling = ({
|
|
6
|
-
deviceCodeData
|
|
7
|
-
}) => {
|
|
8
|
-
const appContext = React.useContext(AppContext),
|
|
9
|
-
fetchAccessToken = async url => {
|
|
10
|
-
const response = await fetch(url, {
|
|
11
|
-
method: "POST",
|
|
12
|
-
headers: {
|
|
13
|
-
"Content-Type": "application/json",
|
|
14
|
-
Accept: "application/json"
|
|
15
|
-
},
|
|
16
|
-
body: JSON.stringify({
|
|
17
|
-
// client_id: deviceCodeData.client_id,
|
|
18
|
-
client_id: GITHUB_CLIENT_ID,
|
|
19
|
-
device_code: deviceCodeData?.device_code,
|
|
20
|
-
grant_type: "urn:ietf:params:oauth:grant-type:device_code"
|
|
21
|
-
})
|
|
22
|
-
});
|
|
23
|
-
if (!response.ok) throw new Error("Failed to fetch access token");
|
|
24
|
-
const result = await response.json();
|
|
25
|
-
if (result.error) throw new Error(result.error);
|
|
26
|
-
return result.access_token && (appContext.tokenStore.set("token", result), appContext.setInstallState(prev => ({
|
|
27
|
-
...prev,
|
|
28
|
-
shouldOpenBrowser: !1
|
|
29
|
-
})), result.access_token), result;
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
data,
|
|
33
|
-
error,
|
|
34
|
-
isLoading
|
|
35
|
-
} = useSWR(appContext.installState?.shouldOpenBrowser && deviceCodeData ? "https://github.com/login/oauth/access_token" : null, fetchAccessToken, {
|
|
36
|
-
onErrorRetry: (_error, _key, _config, revalidate, {
|
|
37
|
-
retryCount
|
|
38
|
-
}) => {
|
|
39
|
-
setTimeout(() => revalidate({
|
|
40
|
-
retryCount
|
|
41
|
-
}), 5e3);
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
return {
|
|
45
|
-
data,
|
|
46
|
-
error,
|
|
47
|
-
isLoadingPooling: isLoading
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
export { useGithubAuthPooling };
|
|
51
|
-
//# sourceMappingURL=useGithubAuthPooling.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["React","useSWR","AppContext","GITHUB_CLIENT_ID","useGithubAuthPooling","deviceCodeData","appContext","useContext","fetchAccessToken","url","response","fetch","method","headers","Accept","body","JSON","stringify","client_id","device_code","grant_type","ok","Error","result","json","error","access_token","tokenStore","set","setInstallState","prev","shouldOpenBrowser","data","isLoading","installState","onErrorRetry","_error","_key","_config","revalidate","retryCount","setTimeout","isLoadingPooling"],"sources":["../../src/hooks/useGithubAuthPooling.tsx"],"sourcesContent":[null],"mappings":"AAAA,OAAOA,KAAA,MAAW;AAClB,OAAOC,MAAA,MAAY;AAEnB,SAASC,UAAA,QAAkB;AAC3B,SAASC,gBAAA,QAAwB;AAG1B,MAAMC,oBAAA,GAAuBA,CAAC;EACnCC;AACF,MAEM;EACJ,MAAMC,UAAA,GAAaN,KAAA,CAAMO,UAAA,CAAWL,UAAU;IAExCM,gBAAA,GAAmB,MAAOC,GAAA,IAAgB;MAC9C,MAAMC,QAAA,GAAW,MAAMC,KAAA,CAAMF,GAAA,EAAK;QAChCG,MAAA,EAAQ;QACRC,OAAA,EAAS;UACP,gBAAgB;UAChBC,MAAA,EAAQ;QACV;QACAC,IAAA,EAAMC,IAAA,CAAKC,SAAA,CAAU;UAAA;UAEnBC,SAAA,EAAWf,gBAAA;UACXgB,WAAA,EAAad,cAAA,EAAgBc,WAAA;UAC7BC,UAAA,EAAY;QACd,CAAC;MACH,CAAC;MACD,IAAI,CAACV,QAAA,CAASW,EAAA,EACZ,MAAM,IAAIC,KAAA,CAAM,8BAA8B;MAEhD,MAAMC,MAAA,GAAS,MAAMb,QAAA,CAASc,IAAA,CAAK;MAEnC,IAAID,MAAA,CAAOE,KAAA,EACT,MAAM,IAAIH,KAAA,CAAMC,MAAA,CAAOE,KAAK;MAE9B,OAAIF,MAAA,CAAOG,YAAA,KAETpB,UAAA,CAAWqB,UAAA,CAAWC,GAAA,CAAI,SAASL,MAAM,GACzCjB,UAAA,CAAWuB,eAAA,CAAiBC,IAAA,KACnB;QACL,GAAGA,IAAA;QACHC,iBAAA,EAAmB;MACrB,EACD,GACDR,MAAA,CAAOG,YAAA,GAEFH,MAAA;IACT;IAEM;MAAES,IAAA;MAAMP,KAAA;MAAOQ;IAAU,IAAIhC,MAAA,CACjCK,UAAA,CAAW4B,YAAA,EAAcH,iBAAA,IAAqB1B,cAAA,GAC1C,gDACA,MACJG,gBAAA,EACA;MACE2B,YAAA,EAAcA,CAACC,MAAA,EAAQC,IAAA,EAAMC,OAAA,EAASC,UAAA,EAAY;QAAEC;MAAW,MAAM;QAWnEC,UAAA,CAAW,MAAMF,UAAA,CAAW;UAAEC;QAAW,CAAC,GAAG,GAAI;MACnD;IACF,CACF;EACA,OAAO;IAAER,IAAA;IAAMP,KAAA;IAAOiB,gBAAA,EAAkBT;EAAU;AACpD","ignoreList":[]}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import useSWR from "swr";
|
|
3
|
-
import { AppContext } from "../data/AppContext.js";
|
|
4
|
-
import { GITHUB_CLIENT_ID } from "../constants.js";
|
|
5
|
-
var useGithubAuthPooling = function (param) {
|
|
6
|
-
var {
|
|
7
|
-
deviceCodeData
|
|
8
|
-
} = param,
|
|
9
|
-
_appContext_installState,
|
|
10
|
-
appContext = React.useContext(AppContext),
|
|
11
|
-
fetchAccessToken = async function (url) {
|
|
12
|
-
var response = await fetch(url, {
|
|
13
|
-
method: "POST",
|
|
14
|
-
headers: {
|
|
15
|
-
"Content-Type": "application/json",
|
|
16
|
-
Accept: "application/json"
|
|
17
|
-
},
|
|
18
|
-
body: JSON.stringify({
|
|
19
|
-
// client_id: deviceCodeData.client_id,
|
|
20
|
-
client_id: GITHUB_CLIENT_ID,
|
|
21
|
-
device_code: deviceCodeData?.device_code,
|
|
22
|
-
grant_type: "urn:ietf:params:oauth:grant-type:device_code"
|
|
23
|
-
})
|
|
24
|
-
});
|
|
25
|
-
if (!response.ok) throw new Error("Failed to fetch access token");
|
|
26
|
-
var result = await response.json();
|
|
27
|
-
if (result.error) throw new Error(result.error);
|
|
28
|
-
return result.access_token && (appContext.tokenStore.set("token", result), appContext.setInstallState(function (prev) {
|
|
29
|
-
return {
|
|
30
|
-
...prev,
|
|
31
|
-
shouldOpenBrowser: !1
|
|
32
|
-
};
|
|
33
|
-
}), result.access_token), result;
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
data,
|
|
37
|
-
error,
|
|
38
|
-
isLoading
|
|
39
|
-
} = useSWR(!((_appContext_installState = appContext.installState) === null || _appContext_installState === void 0) && _appContext_installState.shouldOpenBrowser && deviceCodeData ? "https://github.com/login/oauth/access_token" : null, fetchAccessToken, {
|
|
40
|
-
onErrorRetry: function (_error, _key, _config, revalidate, param2) {
|
|
41
|
-
var {
|
|
42
|
-
retryCount
|
|
43
|
-
} = param2;
|
|
44
|
-
setTimeout(function () {
|
|
45
|
-
return revalidate({
|
|
46
|
-
retryCount
|
|
47
|
-
});
|
|
48
|
-
}, 5e3);
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
return {
|
|
52
|
-
data,
|
|
53
|
-
error,
|
|
54
|
-
isLoadingPooling: isLoading
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
export { useGithubAuthPooling };
|
|
58
|
-
//# sourceMappingURL=useGithubAuthPooling.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["React","useSWR","AppContext","GITHUB_CLIENT_ID","useGithubAuthPooling","param","deviceCodeData","_appContext_installState","appContext","useContext","fetchAccessToken","url","response","fetch","method","headers","Accept","body","JSON","stringify","client_id","device_code","grant_type","ok","Error","result","json","error","access_token","tokenStore","set","setInstallState","prev","shouldOpenBrowser","data","isLoading","installState","onErrorRetry","_error","_key","_config","revalidate","param2","retryCount","setTimeout"],"sources":["../../src/hooks/useGithubAuthPooling.tsx"],"sourcesContent":[null],"mappings":"AAAA,OAAOA,KAAA,MAAW;AAClB,OAAOC,MAAA,MAAY;AAEnB,SAASC,UAAA,QAAkB;AAC3B,SAASC,gBAAA,QAAwB;AAG1B,IAAAC,oBAAM,YAAAA,CAAwBC,KAAA;EACnC;MAAAC;IAAA,IAAAD,KAAA;IAAAE,wBAAA;IAAAC,UAAA,GAAAR,KAAA,CAAAS,UAAA,CAAAP,UAAA;IAAAQ,gBAAA,kBAAAA,CAAAC,GAAA;MACF,IAEMC,QAAA,SAAAC,KAAA,CAAAF,GAAA;QACJG,MAAM;QAGJC,OAAM;UACJ,cAAQ;UACRC,MAAA,EAAS;QAAA;QACSC,IAChB,EAAAC,IAAQ,CAAAC,SAAA;UACV;UACAC,SAAW,EAAAjB,gBAAU;UAAAkB,WAAA,EAAAf,cAAA,EAAAe,WAAA;UAEnBC,UAAA,EAAW;QAAA;MACkB;MACjB,IACb,CAAAV,QAAA,CAAAW,EAAA,EACF,UAAAC,KAAA;MACD,IAAIC,MAAC,SAASb,QAAA,CAAAc,IAAA;MACZ,IAAAD,MAAM,CAAAE,KAAI,EAEZ,MAAM,IAAAH,KAAS,CAAAC,MAAM,CAAAE,KAAS;MAE9B,OAAIF,MAAO,CAAAG,YAAA,KAAApB,UAAA,CAAAqB,UAAA,CAAAC,GAAA,UAAAL,MAAA,GAAAjB,UAAA,CAAAuB,eAAA,WAAAC,IAAA;QACT,OAAM;UAER,GAAIA,IAAA;UAKEC,iBAAG;QACH;MACF,EACD,EAAAR,MACD,CAAAG,YAAO,GAAAH,MAEF;IACT;IAEM;MAAES,IAAA;MAAMP,KAAA;MAAOQ;IAAU,IAAIlC,MAAA,IAAAM,wBAAA,GAAAC,UAAA,CAAA4B,YAAA,cAAA7B,wBAAA,gBAAAA,wBAAA,CAAA0B,iBAAA,IAAA3B,cAAA,yDAAAI,gBAAA;MACjC2B,YAAW,WAAAA,CAAAC,MAAc,EAAAC,IAAA,EAAAC,OAAA,EAAqBC,UAAA,EAAAC,MAC1C;QAEJ;UAAAC;QAAA,IAAAD,MAAA;QACAE,UAAA;UACE,OAAAH,UAAe;YAWbE;UACF;QACF;MACF;IACA;EACF","ignoreList":[]}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export type GithubCode = {
|
|
2
|
-
device_code: string;
|
|
3
|
-
expires_in: string;
|
|
4
|
-
interval: string;
|
|
5
|
-
user_code: string;
|
|
6
|
-
verification_uri: string;
|
|
7
|
-
} | null;
|
|
8
|
-
export declare const useGithubAuth: () => {
|
|
9
|
-
data: GithubCode;
|
|
10
|
-
error: any;
|
|
11
|
-
isLoading: boolean;
|
|
12
|
-
openLoginUrl: () => void;
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=useGithubAuth.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useGithubAuth.d.ts","sourceRoot":"","sources":["../../src/hooks/useGithubAuth.tsx"],"names":[],"mappings":"AAgCA,MAAM,MAAM,UAAU,GAAG;IACvB,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,gBAAgB,EAAE,MAAM,CAAA;CACzB,GAAG,IAAI,CAAA;AAER,eAAO,MAAM,aAAa;;;;;CA6BzB,CAAA"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { GithubCode } from './useGithubAuth.js';
|
|
2
|
-
export declare const useGithubAuthPooling: ({ deviceCodeData, }: {
|
|
3
|
-
deviceCodeData: GithubCode;
|
|
4
|
-
}) => {
|
|
5
|
-
data: string | undefined;
|
|
6
|
-
error: any;
|
|
7
|
-
isLoadingPooling: boolean;
|
|
8
|
-
};
|
|
9
|
-
//# sourceMappingURL=useGithubAuthPooling.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useGithubAuthPooling.d.ts","sourceRoot":"","sources":["../../src/hooks/useGithubAuthPooling.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAEpD,eAAO,MAAM,oBAAoB,wBAE9B;IACD,cAAc,EAAE,UAAU,CAAA;CAC3B;;;;CA6DA,CAAA"}
|