diff --git a/.gitignore b/.gitignore index be7da6a..64d780f 100644 --- a/.gitignore +++ b/.gitignore @@ -14,7 +14,7 @@ yarn.lock /build .parcel-cache/ dist/ -.leancloud +.env* # misc .DS_Store diff --git a/package.json b/package.json index 1707ba9..b3ec613 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "node": ">=18" }, "dependencies": { + "@authing/guard": "^5.3.4", "@octokit/rest": "^20.1.1", "browser-unhandled-rejection": "^1.0.2", "classnames": "^2.5.1", @@ -18,6 +19,7 @@ "marked": "^12.0.2", "mobx": "^6.12.3", "mobx-react": "^9.1.1", + "mobx-restful": "^0.7.0-rc.0", "react": "^18.3.1", "react-bootstrap": "^2.10.2", "react-dom": "^18.3.1", @@ -35,18 +37,18 @@ "@types/jest": "^29.5.12", "@types/lodash.debounce": "^4.0.9", "@types/node": "^18.19.33", - "@types/react": "^18.3.2", + "@types/react": "^18.3.3", "@types/react-dom": "^18.3.0", "@types/turndown": "^5.0.4", "buffer": "^6.0.3", "husky": "^9.0.11", "jest": "^29.7.0", - "lint-staged": "^15.2.4", + "lint-staged": "^15.2.5", "parcel": "~2.12.0", "prettier": "^3.2.5", "process": "^0.11.10", "ts-jest": "^29.1.3", - "tsx": "^4.10.5", + "tsx": "^4.11.0", "typescript": "~5.4.5", "workbox-cli": "^7.1.0" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b7dc569..30e1227 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,6 +8,9 @@ importers: .: dependencies: + '@authing/guard': + specifier: ^5.3.4 + version: 5.3.4 '@octokit/rest': specifier: ^20.1.1 version: 20.1.1 @@ -41,12 +44,15 @@ importers: mobx-react: specifier: ^9.1.1 version: 9.1.1(mobx@6.12.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + mobx-restful: + specifier: ^0.7.0-rc.0 + version: 0.7.0-rc.0(mobx@6.12.3)(typescript@5.4.5) react: specifier: ^18.3.1 version: 18.3.1 react-bootstrap: specifier: ^2.10.2 - version: 2.10.2(@types/react@18.3.2)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + version: 2.10.2(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) react-dom: specifier: ^18.3.1 version: 18.3.1(react@18.3.1) @@ -88,8 +94,8 @@ importers: specifier: ^18.19.33 version: 18.19.33 '@types/react': - specifier: ^18.3.2 - version: 18.3.2 + specifier: ^18.3.3 + version: 18.3.3 '@types/react-dom': specifier: ^18.3.0 version: 18.3.0 @@ -106,8 +112,8 @@ importers: specifier: ^29.7.0 version: 29.7.0(@types/node@18.19.33) lint-staged: - specifier: ^15.2.4 - version: 15.2.4 + specifier: ^15.2.5 + version: 15.2.5 parcel: specifier: ~2.12.0 version: 2.12.0(@swc/helpers@0.5.11)(terser@5.31.0)(typescript@5.4.5) @@ -121,8 +127,8 @@ importers: specifier: ^29.1.3 version: 29.1.3(@babel/core@7.24.5)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.24.5))(jest@29.7.0(@types/node@18.19.33))(typescript@5.4.5) tsx: - specifier: ^4.10.5 - version: 4.10.5 + specifier: ^4.11.0 + version: 4.11.0 typescript: specifier: ~5.4.5 version: 5.4.5 @@ -142,6 +148,20 @@ packages: peerDependencies: ajv: '>=8' + '@authing/guard-shim-react@4.5.19': + resolution: {integrity: sha512-7E26GQpRWLIneVrWn09wyt9hN8D8ssuVEHHIO9a8P6GW2tbThZFruAPzRE8xa1TFgKctUEgLHKwa2xie8BhJjA==} + peerDependencies: + authing-js-sdk: ^4.23.44 + + '@authing/guard@5.3.4': + resolution: {integrity: sha512-v+t4IalygWB9dGv1uavRy9/dc6jXE0riXIx9Yt0e4TKe7HwB3+eTx7yPWo7jJGbwsd5CpPvZNIKwcK4yYKI5oA==} + + '@authing/native-js-ui-components@4.5.19': + resolution: {integrity: sha512-h4b+80xyse0lLWCvBtIXcn4neSlpbDG2eSiGgBg3SFHAgzT9LmoAWh6CqsIJKT0amdps8YwGR1K2mPcy775b3A==} + + '@authing/react-ui-components@4.5.19': + resolution: {integrity: sha512-mRty3V/mg9RvcMrVNZclQGAYyrnox+MIGCZDGs27s7Drbs35xc1vu88TRbV1jAhidWdrMH7Q5363FBrrbMApcA==} + '@babel/code-frame@7.24.2': resolution: {integrity: sha512-y5+tLQyV8pg3fsiln67BVLD1P13Eg4lh5RW9mF0zUuvLrv9uIQ4MCL+CRT+FTsBlBjcIan6PGsLcBN0m3ClUyQ==} engines: {node: '>=6.9.0'} @@ -1649,8 +1669,8 @@ packages: '@types/react-transition-group@4.4.10': resolution: {integrity: sha512-hT/+s0VQs2ojCX823m60m5f0sL5idt9SO6Tj6Dg+rdphGPIeJbJ6CxvBYkgkGKrYeDjvIpKTR38UzmtHJOGW3Q==} - '@types/react@18.3.2': - resolution: {integrity: sha512-Btgg89dAnqD4vV7R3hlwOxgqobUQKgx3MmrQRi0yYbs/P0ym8XozIAlkqVilPqHQwXs4e9Tf63rrCgl58BcO4w==} + '@types/react@18.3.3': + resolution: {integrity: sha512-hti/R0pS0q1/xx+TsI73XIqk26eBsISZ2R0wUijXIngRK9R/e7Xw/cXVxQK7R5JjW+SV4zGcn5hXjudkN/pLIw==} '@types/resolve@1.20.2': resolution: {integrity: sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==} @@ -1751,6 +1771,9 @@ packages: async@3.2.5: resolution: {integrity: sha512-baNZyqaaLhyLVKm/DlvdW051MSgO6b8eVfIezl9E5PqWxFgzLm/wQntEW4zOytVburDEr0JlALEpdOFwvErLsg==} + asynckit@0.4.0: + resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==} + at-least-node@1.0.0: resolution: {integrity: sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==} engines: {node: '>= 4.0.0'} @@ -1759,6 +1782,9 @@ packages: resolution: {integrity: sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ==} engines: {node: '>= 0.4'} + axios@0.27.2: + resolution: {integrity: sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==} + babel-jest@29.7.0: resolution: {integrity: sha512-BrvGY3xZSwEcCzKvKsCi2GgHqDqsYkOP4/by5xCgIwGXQxIEh+8ew3gmrE1y7XRR6LHZIj6yLYnUi/mm2KXKBg==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} @@ -2004,6 +2030,10 @@ packages: colorette@2.0.20: resolution: {integrity: sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==} + combined-stream@1.0.8: + resolution: {integrity: sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==} + engines: {node: '>= 0.8'} + commander@12.1.0: resolution: {integrity: sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==} engines: {node: '>=18'} @@ -2145,6 +2175,10 @@ packages: resolution: {integrity: sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==} engines: {node: '>= 0.4'} + delayed-stream@1.0.0: + resolution: {integrity: sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==} + engines: {node: '>=0.4.0'} + deprecation@2.3.1: resolution: {integrity: sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==} @@ -2358,9 +2392,22 @@ packages: resolution: {integrity: sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==} engines: {node: '>=8'} + follow-redirects@1.15.6: + resolution: {integrity: sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==} + engines: {node: '>=4.0'} + peerDependencies: + debug: '*' + peerDependenciesMeta: + debug: + optional: true + for-each@0.3.3: resolution: {integrity: sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==} + form-data@4.0.0: + resolution: {integrity: sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==} + engines: {node: '>= 6'} + fs-extra@9.1.0: resolution: {integrity: sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==} engines: {node: '>=10'} @@ -3026,6 +3073,12 @@ packages: resolution: {integrity: sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==} engines: {node: '>=6'} + koajax@0.9.6: + resolution: {integrity: sha512-Cv5HH7igfN7HEGLwRzu4TEzXLTm3QSpbR48Gif9dhPPBNKZ8ELS1bbh3Dik1s83vpKnnjC+DcFU8ql+LwNg3tQ==} + deprecated: Don't use versions with old API & bugs + peerDependencies: + jsdom: '>=21' + koajax@1.1.0: resolution: {integrity: sha512-5BzwkuLlZGC1Ro3NgJRMysXc/FtnHJiCMpLOTgDBHl+4v1xtBWTHvMm4SL2mwf2wszJ5OUWQ6m5I3M63rIqzKQ==} peerDependencies: @@ -3109,8 +3162,8 @@ packages: lines-and-columns@1.2.4: resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==} - lint-staged@15.2.4: - resolution: {integrity: sha512-3F9KRQIS2fVDGtCkBp4Bx0jswjX7zUcKx6OF0ZeY1prksUyKPRIIUqZhIUYAstJfvj6i48VFs4dwVIbCYwvTYQ==} + lint-staged@15.2.5: + resolution: {integrity: sha512-j+DfX7W9YUvdzEZl3Rk47FhDF6xwDBV5wwsCPw6BwWZVPYJemusQmvb9bRsW23Sqsaa+vRloAWogbK4BUuU2zA==} engines: {node: '>=18.12.0'} hasBin: true @@ -3220,14 +3273,18 @@ packages: merge-stream@2.0.0: resolution: {integrity: sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==} - micromatch@4.0.6: - resolution: {integrity: sha512-Y4Ypn3oujJYxJcMacVgcs92wofTHxp9FzfDpQON4msDefoC0lb3ETvQLOdLcbhSwU1bz8HrL/1sygfBIHudrkQ==} - engines: {node: '>=8.6'} - micromatch@4.0.7: resolution: {integrity: sha512-LPP/3KorzCwBxfeUuZmaR6bG2kdeHSbe0P2tY3FLRU4vYrjYz5hI4QZwV0njUx3jeuKe67YukQ1LSPZBKDqO/Q==} engines: {node: '>=8.6'} + mime-db@1.52.0: + resolution: {integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==} + engines: {node: '>= 0.6'} + + mime-types@2.1.35: + resolution: {integrity: sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==} + engines: {node: '>= 0.6'} + mime@1.6.0: resolution: {integrity: sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==} engines: {node: '>=4'} @@ -3289,6 +3346,11 @@ packages: react-native: optional: true + mobx-restful@0.7.0-rc.0: + resolution: {integrity: sha512-fM2ymsA+u8N0sCK8d1sb26Zja9G4PxKMWuRzFJzVzvKX0ba1pViRCeC4qiH8ITzhAw/vIySNeGZ8iObxAZN5ww==} + peerDependencies: + mobx: '>=6.11' + mobx@6.12.3: resolution: {integrity: sha512-c8NKkO4R2lShkSXZ2Ongj1ycjugjzFFo/UswHBnS62y07DMcTc9Rvo03/3nRyszIvwPNljlkd4S828zIBv/piw==} @@ -3475,10 +3537,6 @@ packages: resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} engines: {node: '>=8.6'} - picomatch@4.0.2: - resolution: {integrity: sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==} - engines: {node: '>=12'} - pidtree@0.6.0: resolution: {integrity: sha512-eG2dWTVw5bzqGRztnHExczNxt5VGsE6OwTeCG3fdUf9KBsZzO3R5OIIIzWR+iZA0NtZ+RDVdaoE2dK1cn6jH4g==} engines: {node: '>=0.10'} @@ -3607,6 +3665,11 @@ packages: '@types/react': optional: true + react-dom@16.14.0: + resolution: {integrity: sha512-1gCeQXDLoIqMgqD3IO2Ah9bnf0w9kzhwN5q4FGnHZ67hBm9yePzB5JJAIQCc8x3pFnNlwFq4RidZggNAAkzWWw==} + peerDependencies: + react: ^16.14.0 + react-dom@18.3.1: resolution: {integrity: sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==} peerDependencies: @@ -3634,6 +3697,10 @@ packages: react: '>=16.6.0' react-dom: '>=16.6.0' + react@16.14.0: + resolution: {integrity: sha512-0X2CImDkJGApiAlcf0ODKIneSwBPhqJawOa5wCtKbu7ZECrmS26NvtSILynQ66cgkT/RJ4LidJOc3bUESwmU8g==} + engines: {node: '>=0.10.0'} + react@18.3.1: resolution: {integrity: sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==} engines: {node: '>=0.10.0'} @@ -3785,6 +3852,9 @@ packages: sax@1.3.0: resolution: {integrity: sha512-0s+oAmw9zLl1V1cS9BtZN7JAd0cW5e0QH4W3LWEK6a4LaLEA2OTpGYWDY+6XasBLtz6wkm3u1xRw95mRuJ59WA==} + scheduler@0.19.1: + resolution: {integrity: sha512-n/zwRWRYSUj0/3g/otKDRPMh6qv2SYMWNq85IEa8iZyAv8od9zDYpGSnpBEjNgcMNq6Scbu5KfIPxNF72R/2EA==} + scheduler@0.23.2: resolution: {integrity: sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ==} @@ -4089,8 +4159,8 @@ packages: tslib@2.6.2: resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==} - tsx@4.10.5: - resolution: {integrity: sha512-twDSbf7Gtea4I2copqovUiNTEDrT8XNFXsuHpfGbdpW/z9ZW4fTghzzhAG0WfrCuJmJiOEY1nLIjq4u3oujRWQ==} + tsx@4.11.0: + resolution: {integrity: sha512-vzGGELOgAupsNVssAmZjbUDfdm/pWP4R+Kg8TVdsonxbXk0bEpE1qh0yV6/QxUVXaVlNemgcPajGdJJ82n3stg==} engines: {node: '>=18.0.0'} hasBin: true @@ -4392,6 +4462,34 @@ snapshots: jsonpointer: 5.0.1 leven: 3.1.0 + '@authing/guard-shim-react@4.5.19': {} + + '@authing/guard@5.3.4': + dependencies: + '@authing/react-ui-components': 4.5.19 + axios: 0.27.2 + react: 16.14.0 + react-dom: 16.14.0(react@16.14.0) + transitivePeerDependencies: + - authing-js-sdk + - debug + + '@authing/native-js-ui-components@4.5.19': + dependencies: + '@authing/guard-shim-react': 4.5.19 + react: 16.14.0 + react-dom: 16.14.0(react@16.14.0) + transitivePeerDependencies: + - authing-js-sdk + + '@authing/react-ui-components@4.5.19': + dependencies: + '@authing/guard-shim-react': 4.5.19 + '@authing/native-js-ui-components': 4.5.19 + react: 16.14.0 + transitivePeerDependencies: + - authing-js-sdk + '@babel/code-frame@7.24.2': dependencies: '@babel/highlight': 7.24.5 @@ -6375,13 +6473,13 @@ snapshots: '@types/react-dom@18.3.0': dependencies: - '@types/react': 18.3.2 + '@types/react': 18.3.3 '@types/react-transition-group@4.4.10': dependencies: - '@types/react': 18.3.2 + '@types/react': 18.3.3 - '@types/react@18.3.2': + '@types/react@18.3.3': dependencies: '@types/prop-types': 15.7.12 csstype: 3.1.3 @@ -6476,12 +6574,21 @@ snapshots: async@3.2.5: {} + asynckit@0.4.0: {} + at-least-node@1.0.0: {} available-typed-arrays@1.0.7: dependencies: possible-typed-array-names: 1.0.0 + axios@0.27.2: + dependencies: + follow-redirects: 1.15.6 + form-data: 4.0.0 + transitivePeerDependencies: + - debug + babel-jest@29.7.0(@babel/core@7.24.5): dependencies: '@babel/core': 7.24.5 @@ -6767,6 +6874,10 @@ snapshots: colorette@2.0.20: {} + combined-stream@1.0.8: + dependencies: + delayed-stream: 1.0.0 + commander@12.1.0: {} commander@2.20.3: {} @@ -6912,6 +7023,8 @@ snapshots: has-property-descriptors: 1.0.2 object-keys: 1.1.1 + delayed-stream@1.0.0: {} + deprecation@2.3.1: {} dequal@2.0.3: {} @@ -7184,10 +7297,18 @@ snapshots: locate-path: 5.0.0 path-exists: 4.0.0 + follow-redirects@1.15.6: {} + for-each@0.3.3: dependencies: is-callable: 1.2.7 + form-data@4.0.0: + dependencies: + asynckit: 0.4.0 + combined-stream: 1.0.8 + mime-types: 2.1.35 + fs-extra@9.1.0: dependencies: at-least-node: 1.0.0 @@ -7980,6 +8101,15 @@ snapshots: kleur@3.0.3: {} + koajax@0.9.6(typescript@5.4.5): + dependencies: + '@swc/helpers': 0.5.11 + iterable-observer: 1.0.1 + regenerator-runtime: 0.14.1 + web-utility: 4.4.0(typescript@5.4.5) + transitivePeerDependencies: + - typescript + koajax@1.1.0(typescript@5.4.5): dependencies: '@swc/helpers': 0.5.11 @@ -8054,7 +8184,7 @@ snapshots: lines-and-columns@1.2.4: {} - lint-staged@15.2.4: + lint-staged@15.2.5: dependencies: chalk: 5.3.0 commander: 12.1.0 @@ -8062,7 +8192,7 @@ snapshots: execa: 8.0.1 lilconfig: 3.1.1 listr2: 8.2.1 - micromatch: 4.0.6 + micromatch: 4.0.7 pidtree: 0.6.0 string-argv: 0.3.2 yaml: 2.4.2 @@ -8206,16 +8336,17 @@ snapshots: merge-stream@2.0.0: {} - micromatch@4.0.6: - dependencies: - braces: 3.0.3 - picomatch: 4.0.2 - micromatch@4.0.7: dependencies: braces: 3.0.3 picomatch: 2.3.1 + mime-db@1.52.0: {} + + mime-types@2.1.35: + dependencies: + mime-db: 1.52.0 + mime@1.6.0: optional: true @@ -8259,6 +8390,17 @@ snapshots: optionalDependencies: react-dom: 18.3.1(react@18.3.1) + mobx-restful@0.7.0-rc.0(mobx@6.12.3)(typescript@5.4.5): + dependencies: + '@swc/helpers': 0.5.11 + koajax: 0.9.6(typescript@5.4.5) + mobx: 6.12.3 + regenerator-runtime: 0.14.1 + web-utility: 4.4.0(typescript@5.4.5) + transitivePeerDependencies: + - jsdom + - typescript + mobx@6.12.3: {} ms@2.1.2: {} @@ -8461,8 +8603,6 @@ snapshots: picomatch@2.3.1: {} - picomatch@4.0.2: {} - pidtree@0.6.0: {} pify@2.3.0: {} @@ -8568,7 +8708,7 @@ snapshots: minimist: 1.2.8 strip-json-comments: 2.0.1 - react-bootstrap@2.10.2(@types/react@18.3.2)(react-dom@18.3.1(react@18.3.1))(react@18.3.1): + react-bootstrap@2.10.2(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1): dependencies: '@babel/runtime': 7.24.5 '@restart/hooks': 0.4.16(react@18.3.1) @@ -8585,7 +8725,15 @@ snapshots: uncontrollable: 7.2.1(react@18.3.1) warning: 4.0.3 optionalDependencies: - '@types/react': 18.3.2 + '@types/react': 18.3.3 + + react-dom@16.14.0(react@16.14.0): + dependencies: + loose-envify: 1.4.0 + object-assign: 4.1.1 + prop-types: 15.8.1 + react: 16.14.0 + scheduler: 0.19.1 react-dom@18.3.1(react@18.3.1): dependencies: @@ -8612,6 +8760,12 @@ snapshots: react: 18.3.1 react-dom: 18.3.1(react@18.3.1) + react@16.14.0: + dependencies: + loose-envify: 1.4.0 + object-assign: 4.1.1 + prop-types: 15.8.1 + react@18.3.1: dependencies: loose-envify: 1.4.0 @@ -8774,6 +8928,11 @@ snapshots: sax@1.3.0: optional: true + scheduler@0.19.1: + dependencies: + loose-envify: 1.4.0 + object-assign: 4.1.1 + scheduler@0.23.2: dependencies: loose-envify: 1.4.0 @@ -9074,7 +9233,7 @@ snapshots: tslib@2.6.2: {} - tsx@4.10.5: + tsx@4.11.0: dependencies: esbuild: 0.20.2 get-tsconfig: 4.7.5 @@ -9149,7 +9308,7 @@ snapshots: uncontrollable@7.2.1(react@18.3.1): dependencies: '@babel/runtime': 7.24.5 - '@types/react': 18.3.2 + '@types/react': 18.3.3 invariant: 2.2.4 react: 18.3.1 react-lifecycles-compat: 3.0.4 diff --git a/src/component/SessionBox.less b/src/component/SessionBox.less new file mode 100644 index 0000000..f3bed6b --- /dev/null +++ b/src/component/SessionBox.less @@ -0,0 +1,3 @@ +.g2-change-language-text { + display: none !important; +} diff --git a/src/component/SessionBox.tsx b/src/component/SessionBox.tsx new file mode 100644 index 0000000..5134a3d --- /dev/null +++ b/src/component/SessionBox.tsx @@ -0,0 +1,74 @@ +import { Guard } from '@authing/guard'; +import { observer } from 'mobx-react'; +import { Component, MouseEvent, PropsWithChildren } from 'react'; + +import userStore from '../model/User'; +import './SessionBox.less'; + +export const guard = new Guard({ + mode: 'modal', + appId: process.env.AUTHING_APP_ID! +}); + +export type SessionBoxProps = PropsWithChildren<{ + className?: string; + autoCover?: boolean; +}>; + +@observer +export default class SessionBox extends Component { + #started = false; + + componentDidMount() { + const { autoCover } = this.props; + + if (autoCover) this.openModal(); + } + + closeModal = () => { + this.#started = false; + + guard.hide(); + + document.scrollingElement?.classList.remove('overflow-hidden'); + }; + + async openModal() { + if (!userStore.sessionExpired) return; + + document.scrollingElement?.classList.add('overflow-hidden'); + + guard.on('close', this.closeModal); + guard.on('login-error', this.closeModal); + + this.#started = true; + + const user = await guard.start(); + + await userStore.signIn(user); + + this.closeModal(); + } + + captureInput = (event: MouseEvent) => { + event.preventDefault(); + event.stopPropagation(); + + if (this.#started) guard.show(); + else this.openModal(); + }; + + render() { + const { className, autoCover, children } = this.props, + { session } = userStore; + + return ( +
+ {(!autoCover || session) && children} +
+ ); + } +} diff --git a/src/index.html b/src/index.html index 2ecf059..d2b4234 100644 --- a/src/index.html +++ b/src/index.html @@ -24,6 +24,10 @@ rel="stylesheet" href="https://unpkg.com/@fortawesome/fontawesome-free@5.15.4/css/all.min.css" /> + diff --git a/src/model/User.ts b/src/model/User.ts new file mode 100644 index 0000000..5571393 --- /dev/null +++ b/src/model/User.ts @@ -0,0 +1,24 @@ +import { User } from '@authing/guard'; +import { computed, observable } from 'mobx'; +import { BaseModel } from 'mobx-restful'; + +export class UserModel extends BaseModel { + @observable + accessor session: User | undefined = + localStorage.session && JSON.parse(localStorage.session); + + @computed + get sessionExpired() { + const { session } = this; + + return !session || +new Date(session.tokenExpiredAt) < Date.now(); + } + + signIn(user: User) { + localStorage.session = JSON.stringify(user); + + return (this.session = user); + } +} + +export default new UserModel(); diff --git a/src/page/index.tsx b/src/page/index.tsx index 1b8bccf..fc4c624 100644 --- a/src/page/index.tsx +++ b/src/page/index.tsx @@ -6,6 +6,7 @@ import { UserBar } from '../component/UserBar'; import ApplicationModel from '../model'; import { Editor } from './Editor'; import { menu, title } from './index.json'; +import SessionBox from '../component/SessionBox'; export interface FrameProps { repository: string; @@ -31,7 +32,9 @@ export const Application: FC = observer(({ repository, store }) => ( - + + + ));