commit 10bc7c6acf13b0240b0081088cfd5c3742d17d6e Author: abearxiong Date: Sun Oct 20 19:45:15 2024 +0800 init test diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b512c09 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..925abeb --- /dev/null +++ b/package.json @@ -0,0 +1,24 @@ +{ + "name": "super-test", + "version": "1.0.0", + "description": "", + "main": "index.js", + "type": "module", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "packageManager": "pnpm@9.8.0+sha512.8e4c3550fb500e808dbc30bb0ce4dd1eb614e30b1c55245f211591ec2cdf9c611cabd34e1364b42f564bd54b3945ed0f49d61d1bbf2ec9bd74b866fcdc723276", + "dependencies": { + "@supabase/supabase-js": "^2.45.4", + "jsonwebtoken": "^9.0.2", + "nodemailer": "^6.9.15", + "pg": "^8.13.0" + }, + "devDependencies": { + "@types/jsonwebtoken": "^9.0.7", + "@types/pg": "^8.11.10" + } +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml new file mode 100644 index 0000000..3c67444 --- /dev/null +++ b/pnpm-lock.yaml @@ -0,0 +1,436 @@ +lockfileVersion: '9.0' + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + +importers: + + .: + dependencies: + '@supabase/supabase-js': + specifier: ^2.45.4 + version: 2.45.4 + jsonwebtoken: + specifier: ^9.0.2 + version: 9.0.2 + nodemailer: + specifier: ^6.9.15 + version: 6.9.15 + pg: + specifier: ^8.13.0 + version: 8.13.0 + devDependencies: + '@types/jsonwebtoken': + specifier: ^9.0.7 + version: 9.0.7 + '@types/pg': + specifier: ^8.11.10 + version: 8.11.10 + +packages: + + '@supabase/auth-js@2.65.0': + resolution: {integrity: sha512-+wboHfZufAE2Y612OsKeVP4rVOeGZzzMLD/Ac3HrTQkkY4qXNjI6Af9gtmxwccE5nFvTiF114FEbIQ1hRq5uUw==} + + '@supabase/functions-js@2.4.1': + resolution: {integrity: sha512-8sZ2ibwHlf+WkHDUZJUXqqmPvWQ3UHN0W30behOJngVh/qHHekhJLCFbh0AjkE9/FqqXtf9eoVvmYgfCLk5tNA==} + + '@supabase/node-fetch@2.6.15': + resolution: {integrity: sha512-1ibVeYUacxWYi9i0cf5efil6adJ9WRyZBLivgjs+AUpewx1F3xPi7gLgaASI2SmIQxPoCEjAsLAzKPgMJVgOUQ==} + engines: {node: 4.x || >=6.0.0} + + '@supabase/postgrest-js@1.16.1': + resolution: {integrity: sha512-EOSEZFm5pPuCPGCmLF1VOCS78DfkSz600PBuvBND/IZmMciJ1pmsS3ss6TkB6UkuvTybYiBh7gKOYyxoEO3USA==} + + '@supabase/realtime-js@2.10.2': + resolution: {integrity: sha512-qyCQaNg90HmJstsvr2aJNxK2zgoKh9ZZA8oqb7UT2LCh3mj9zpa3Iwu167AuyNxsxrUE8eEJ2yH6wLCij4EApA==} + + '@supabase/storage-js@2.7.0': + resolution: {integrity: sha512-iZenEdO6Mx9iTR6T7wC7sk6KKsoDPLq8rdu5VRy7+JiT1i8fnqfcOr6mfF2Eaqky9VQzhP8zZKQYjzozB65Rig==} + + '@supabase/supabase-js@2.45.4': + resolution: {integrity: sha512-E5p8/zOLaQ3a462MZnmnz03CrduA5ySH9hZyL03Y+QZLIOO4/Gs8Rdy4ZCKDHsN7x0xdanVEWWFN3pJFQr9/hg==} + + '@types/jsonwebtoken@9.0.7': + resolution: {integrity: sha512-ugo316mmTYBl2g81zDFnZ7cfxlut3o+/EQdaP7J8QN2kY6lJ22hmQYCK5EHcJHbrW+dkCGSCPgbG8JtYj6qSrg==} + + '@types/node@22.7.5': + resolution: {integrity: sha512-jML7s2NAzMWc//QSJ1a3prpk78cOPchGvXJsC3C6R6PSMoooztvRVQEz89gmBTBY1SPMaqo5teB4uNHPdetShQ==} + + '@types/pg@8.11.10': + resolution: {integrity: sha512-LczQUW4dbOQzsH2RQ5qoeJ6qJPdrcM/DcMLoqWQkMLMsq83J5lAX3LXjdkWdpscFy67JSOWDnh7Ny/sPFykmkg==} + + '@types/phoenix@1.6.5': + resolution: {integrity: sha512-xegpDuR+z0UqG9fwHqNoy3rI7JDlvaPh2TY47Fl80oq6g+hXT+c/LEuE43X48clZ6lOfANl5WrPur9fYO1RJ/w==} + + '@types/ws@8.5.12': + resolution: {integrity: sha512-3tPRkv1EtkDpzlgyKyI8pGsGZAGPEaXeu0DOj5DI25Ja91bdAYddYHbADRYVrZMRbfW+1l5YwXVDKohDJNQxkQ==} + + buffer-equal-constant-time@1.0.1: + resolution: {integrity: sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==} + + ecdsa-sig-formatter@1.0.11: + resolution: {integrity: sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==} + + jsonwebtoken@9.0.2: + resolution: {integrity: sha512-PRp66vJ865SSqOlgqS8hujT5U4AOgMfhrwYIuIhfKaoSCZcirrmASQr8CX7cUg+RMih+hgznrjp99o+W4pJLHQ==} + engines: {node: '>=12', npm: '>=6'} + + jwa@1.4.1: + resolution: {integrity: sha512-qiLX/xhEEFKUAJ6FiBMbes3w9ATzyk5W7Hvzpa/SLYdxNtng+gcurvrI7TbACjIXlsJyr05/S1oUhZrc63evQA==} + + jws@3.2.2: + resolution: {integrity: sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA==} + + lodash.includes@4.3.0: + resolution: {integrity: sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w==} + + lodash.isboolean@3.0.3: + resolution: {integrity: sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg==} + + lodash.isinteger@4.0.4: + resolution: {integrity: sha512-DBwtEWN2caHQ9/imiNeEA5ys1JoRtRfY3d7V9wkqtbycnAmTvRRmbHKDV4a0EYc678/dia0jrte4tjYwVBaZUA==} + + lodash.isnumber@3.0.3: + resolution: {integrity: sha512-QYqzpfwO3/CWf3XP+Z+tkQsfaLL/EnUlXWVkIk5FUPc4sBdTehEqZONuyRt2P67PXAk+NXmTBcc97zw9t1FQrw==} + + lodash.isplainobject@4.0.6: + resolution: {integrity: sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==} + + lodash.isstring@4.0.1: + resolution: {integrity: sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw==} + + lodash.once@4.1.1: + resolution: {integrity: sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==} + + ms@2.1.3: + resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} + + nodemailer@6.9.15: + resolution: {integrity: sha512-AHf04ySLC6CIfuRtRiEYtGEXgRfa6INgWGluDhnxTZhHSKvrBu7lc1VVchQ0d8nPc4cFaZoPq8vkyNoZr0TpGQ==} + engines: {node: '>=6.0.0'} + + obuf@1.1.2: + resolution: {integrity: sha512-PX1wu0AmAdPqOL1mWhqmlOd8kOIZQwGZw6rh7uby9fTc5lhaOWFLX3I6R1hrF9k3zUY40e6igsLGkDXK92LJNg==} + + pg-cloudflare@1.1.1: + resolution: {integrity: sha512-xWPagP/4B6BgFO+EKz3JONXv3YDgvkbVrGw2mTo3D6tVDQRh1e7cqVGvyR3BE+eQgAvx1XhW/iEASj4/jCWl3Q==} + + pg-connection-string@2.7.0: + resolution: {integrity: sha512-PI2W9mv53rXJQEOb8xNR8lH7Hr+EKa6oJa38zsK0S/ky2er16ios1wLKhZyxzD7jUReiWokc9WK5nxSnC7W1TA==} + + pg-int8@1.0.1: + resolution: {integrity: sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw==} + engines: {node: '>=4.0.0'} + + pg-numeric@1.0.2: + resolution: {integrity: sha512-BM/Thnrw5jm2kKLE5uJkXqqExRUY/toLHda65XgFTBTFYZyopbKjBe29Ii3RbkvlsMoFwD+tHeGaCjjv0gHlyw==} + engines: {node: '>=4'} + + pg-pool@3.7.0: + resolution: {integrity: sha512-ZOBQForurqh4zZWjrgSwwAtzJ7QiRX0ovFkZr2klsen3Nm0aoh33Ls0fzfv3imeH/nw/O27cjdz5kzYJfeGp/g==} + peerDependencies: + pg: '>=8.0' + + pg-protocol@1.7.0: + resolution: {integrity: sha512-hTK/mE36i8fDDhgDFjy6xNOG+LCorxLG3WO17tku+ij6sVHXh1jQUJ8hYAnRhNla4QVD2H8er/FOjc/+EgC6yQ==} + + pg-types@2.2.0: + resolution: {integrity: sha512-qTAAlrEsl8s4OiEQY69wDvcMIdQN6wdz5ojQiOy6YRMuynxenON0O5oCpJI6lshc6scgAY8qvJ2On/p+CXY0GA==} + engines: {node: '>=4'} + + pg-types@4.0.2: + resolution: {integrity: sha512-cRL3JpS3lKMGsKaWndugWQoLOCoP+Cic8oseVcbr0qhPzYD5DWXK+RZ9LY9wxRf7RQia4SCwQlXk0q6FCPrVng==} + engines: {node: '>=10'} + + pg@8.13.0: + resolution: {integrity: sha512-34wkUTh3SxTClfoHB3pQ7bIMvw9dpFU1audQQeZG837fmHfHpr14n/AELVDoOYVDW2h5RDWU78tFjkD+erSBsw==} + engines: {node: '>= 8.0.0'} + peerDependencies: + pg-native: '>=3.0.1' + peerDependenciesMeta: + pg-native: + optional: true + + pgpass@1.0.5: + resolution: {integrity: sha512-FdW9r/jQZhSeohs1Z3sI1yxFQNFvMcnmfuj4WBMUTxOrAyLMaTcE1aAMBiTlbMNaXvBCQuVi0R7hd8udDSP7ug==} + + postgres-array@2.0.0: + resolution: {integrity: sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA==} + engines: {node: '>=4'} + + postgres-array@3.0.2: + resolution: {integrity: sha512-6faShkdFugNQCLwucjPcY5ARoW1SlbnrZjmGl0IrrqewpvxvhSLHimCVzqeuULCbG0fQv7Dtk1yDbG3xv7Veog==} + engines: {node: '>=12'} + + postgres-bytea@1.0.0: + resolution: {integrity: sha512-xy3pmLuQqRBZBXDULy7KbaitYqLcmxigw14Q5sj8QBVLqEwXfeybIKVWiqAXTlcvdvb0+xkOtDbfQMOf4lST1w==} + engines: {node: '>=0.10.0'} + + postgres-bytea@3.0.0: + resolution: {integrity: sha512-CNd4jim9RFPkObHSjVHlVrxoVQXz7quwNFpz7RY1okNNme49+sVyiTvTRobiLV548Hx/hb1BG+iE7h9493WzFw==} + engines: {node: '>= 6'} + + postgres-date@1.0.7: + resolution: {integrity: sha512-suDmjLVQg78nMK2UZ454hAG+OAW+HQPZ6n++TNDUX+L0+uUlLywnoxJKDou51Zm+zTCjrCl0Nq6J9C5hP9vK/Q==} + engines: {node: '>=0.10.0'} + + postgres-date@2.1.0: + resolution: {integrity: sha512-K7Juri8gtgXVcDfZttFKVmhglp7epKb1K4pgrkLxehjqkrgPhfG6OO8LHLkfaqkbpjNRnra018XwAr1yQFWGcA==} + engines: {node: '>=12'} + + postgres-interval@1.2.0: + resolution: {integrity: sha512-9ZhXKM/rw350N1ovuWHbGxnGh/SNJ4cnxHiM0rxE4VN41wsg8P8zWn9hv/buK00RP4WvlOyr/RBDiptyxVbkZQ==} + engines: {node: '>=0.10.0'} + + postgres-interval@3.0.0: + resolution: {integrity: sha512-BSNDnbyZCXSxgA+1f5UU2GmwhoI0aU5yMxRGO8CdFEcY2BQF9xm/7MqKnYoM1nJDk8nONNWDk9WeSmePFhQdlw==} + engines: {node: '>=12'} + + postgres-range@1.1.4: + resolution: {integrity: sha512-i/hbxIE9803Alj/6ytL7UHQxRvZkI9O4Sy+J3HGc4F4oo/2eQAjTSNJ0bfxyse3bH0nuVesCk+3IRLaMtG3H6w==} + + safe-buffer@5.2.1: + resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==} + + semver@7.6.3: + resolution: {integrity: sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==} + engines: {node: '>=10'} + hasBin: true + + split2@4.2.0: + resolution: {integrity: sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==} + engines: {node: '>= 10.x'} + + tr46@0.0.3: + resolution: {integrity: sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==} + + undici-types@6.19.8: + resolution: {integrity: sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==} + + webidl-conversions@3.0.1: + resolution: {integrity: sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==} + + whatwg-url@5.0.0: + resolution: {integrity: sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==} + + ws@8.18.0: + resolution: {integrity: sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==} + engines: {node: '>=10.0.0'} + peerDependencies: + bufferutil: ^4.0.1 + utf-8-validate: '>=5.0.2' + peerDependenciesMeta: + bufferutil: + optional: true + utf-8-validate: + optional: true + + xtend@4.0.2: + resolution: {integrity: sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==} + engines: {node: '>=0.4'} + +snapshots: + + '@supabase/auth-js@2.65.0': + dependencies: + '@supabase/node-fetch': 2.6.15 + + '@supabase/functions-js@2.4.1': + dependencies: + '@supabase/node-fetch': 2.6.15 + + '@supabase/node-fetch@2.6.15': + dependencies: + whatwg-url: 5.0.0 + + '@supabase/postgrest-js@1.16.1': + dependencies: + '@supabase/node-fetch': 2.6.15 + + '@supabase/realtime-js@2.10.2': + dependencies: + '@supabase/node-fetch': 2.6.15 + '@types/phoenix': 1.6.5 + '@types/ws': 8.5.12 + ws: 8.18.0 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + + '@supabase/storage-js@2.7.0': + dependencies: + '@supabase/node-fetch': 2.6.15 + + '@supabase/supabase-js@2.45.4': + dependencies: + '@supabase/auth-js': 2.65.0 + '@supabase/functions-js': 2.4.1 + '@supabase/node-fetch': 2.6.15 + '@supabase/postgrest-js': 1.16.1 + '@supabase/realtime-js': 2.10.2 + '@supabase/storage-js': 2.7.0 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + + '@types/jsonwebtoken@9.0.7': + dependencies: + '@types/node': 22.7.5 + + '@types/node@22.7.5': + dependencies: + undici-types: 6.19.8 + + '@types/pg@8.11.10': + dependencies: + '@types/node': 22.7.5 + pg-protocol: 1.7.0 + pg-types: 4.0.2 + + '@types/phoenix@1.6.5': {} + + '@types/ws@8.5.12': + dependencies: + '@types/node': 22.7.5 + + buffer-equal-constant-time@1.0.1: {} + + ecdsa-sig-formatter@1.0.11: + dependencies: + safe-buffer: 5.2.1 + + jsonwebtoken@9.0.2: + dependencies: + jws: 3.2.2 + lodash.includes: 4.3.0 + lodash.isboolean: 3.0.3 + lodash.isinteger: 4.0.4 + lodash.isnumber: 3.0.3 + lodash.isplainobject: 4.0.6 + lodash.isstring: 4.0.1 + lodash.once: 4.1.1 + ms: 2.1.3 + semver: 7.6.3 + + jwa@1.4.1: + dependencies: + buffer-equal-constant-time: 1.0.1 + ecdsa-sig-formatter: 1.0.11 + safe-buffer: 5.2.1 + + jws@3.2.2: + dependencies: + jwa: 1.4.1 + safe-buffer: 5.2.1 + + lodash.includes@4.3.0: {} + + lodash.isboolean@3.0.3: {} + + lodash.isinteger@4.0.4: {} + + lodash.isnumber@3.0.3: {} + + lodash.isplainobject@4.0.6: {} + + lodash.isstring@4.0.1: {} + + lodash.once@4.1.1: {} + + ms@2.1.3: {} + + nodemailer@6.9.15: {} + + obuf@1.1.2: {} + + pg-cloudflare@1.1.1: + optional: true + + pg-connection-string@2.7.0: {} + + pg-int8@1.0.1: {} + + pg-numeric@1.0.2: {} + + pg-pool@3.7.0(pg@8.13.0): + dependencies: + pg: 8.13.0 + + pg-protocol@1.7.0: {} + + pg-types@2.2.0: + dependencies: + pg-int8: 1.0.1 + postgres-array: 2.0.0 + postgres-bytea: 1.0.0 + postgres-date: 1.0.7 + postgres-interval: 1.2.0 + + pg-types@4.0.2: + dependencies: + pg-int8: 1.0.1 + pg-numeric: 1.0.2 + postgres-array: 3.0.2 + postgres-bytea: 3.0.0 + postgres-date: 2.1.0 + postgres-interval: 3.0.0 + postgres-range: 1.1.4 + + pg@8.13.0: + dependencies: + pg-connection-string: 2.7.0 + pg-pool: 3.7.0(pg@8.13.0) + pg-protocol: 1.7.0 + pg-types: 2.2.0 + pgpass: 1.0.5 + optionalDependencies: + pg-cloudflare: 1.1.1 + + pgpass@1.0.5: + dependencies: + split2: 4.2.0 + + postgres-array@2.0.0: {} + + postgres-array@3.0.2: {} + + postgres-bytea@1.0.0: {} + + postgres-bytea@3.0.0: + dependencies: + obuf: 1.1.2 + + postgres-date@1.0.7: {} + + postgres-date@2.1.0: {} + + postgres-interval@1.2.0: + dependencies: + xtend: 4.0.2 + + postgres-interval@3.0.0: {} + + postgres-range@1.1.4: {} + + safe-buffer@5.2.1: {} + + semver@7.6.3: {} + + split2@4.2.0: {} + + tr46@0.0.3: {} + + undici-types@6.19.8: {} + + webidl-conversions@3.0.1: {} + + whatwg-url@5.0.0: + dependencies: + tr46: 0.0.3 + webidl-conversions: 3.0.1 + + ws@8.18.0: {} + + xtend@4.0.2: {} diff --git a/src/get-list.ts b/src/get-list.ts new file mode 100644 index 0000000..87e8704 --- /dev/null +++ b/src/get-list.ts @@ -0,0 +1,6 @@ +import { supabase, supabaseServer } from './module/supabase'; + +const getUserList = await supabaseServer.auth.admin.listUsers(); + +console.log('getUserList', getUserList); +console.log('getUserList', JSON.stringify(getUserList.data.users[0], null, 2)); diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..5bc725b --- /dev/null +++ b/src/index.ts @@ -0,0 +1,39 @@ +import { QueryResult, QueryData, QueryError } from '@supabase/supabase-js'; + +import { createClient, AuthClient } from '@supabase/supabase-js'; +// const url = 'http://192.168.31.220:8000' +// const url = 'http://supabase.xiongxiao.me' +const url = 'http://supabase.xiongxiao.me' + +// const authClient = new AuthClient({ url: url }); +// // const auth = await authClient.signInWithPassword({ email: 'xiongxiao1012@outlook.com', password:'123456xx' }); +// // const auth = await authClient.signInWithPassword({ email: 'admin@zxj.im', password:'123456xx' }); +// const auth = await authClient.signInAnonymously(); +// console.log('auth', auth); + +// Create a single supabase client for interacting with your database +const publicAnonKey = + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ewogICJyb2xlIjogImFub24iLAogICJpc3MiOiAic3VwYWJhc2UiLAogICJpYXQiOiAxNzI4NTc2MDAwLAogICJleHAiOiAxODg2MzQyNDAwCn0._O6nSz8km61C76qGnRMa44e4sou1qCRBhy8O0riHQmM'; +const supabase = createClient(url, publicAnonKey); + +// const anony = await supabase.auth.signInAnonymously(); +// console.log('anony', anony); +// const u = await supabase.auth.signInWithPassword({ +// email: 'xiongxiao1012@outlook.com', +// password: '123456xx', +// }); +// console.log('u', u); +supabase.auth.signInWithSSO +const countriesWithCitiesQuery = supabase.from('public_test').select(` + id, + title + `); +type CountriesWithCities = QueryData; + +const { data, error } = await countriesWithCitiesQuery; +if (error) throw error; +// const countriesWithCities: CountriesWithCities = data; + +// console.log(countriesWithCities); +// console.log('Hello world'); +console.log('data', data); diff --git a/src/login-by-magic.ts b/src/login-by-magic.ts new file mode 100644 index 0000000..a49abda --- /dev/null +++ b/src/login-by-magic.ts @@ -0,0 +1,14 @@ +import { supabase } from './module/supabase'; + +const u = await supabase.auth.signInWithOtp({ + email: 'admin@zxj.im', + options: { + emailRedirectTo: 'https://envision.xiongxiao.me/user/otp', + data: { + referrer: 'special_campaign', // 自定义元数据字段 + name: 'admin', + }, + }, +}); + +console.log('u', u); \ No newline at end of file diff --git a/src/login-by-server.ts b/src/login-by-server.ts new file mode 100644 index 0000000..64c11ad --- /dev/null +++ b/src/login-by-server.ts @@ -0,0 +1,52 @@ +import { supabaseServer, supabase } from './module/supabase'; + +// const u = await supabase.auth.signInWithPassword({ +// email: 'admin@zxj.im', +// password: '123456xx', +// }); +const token = + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIzZjgyZTNhZS1iN2MyLTQyNDQtODQ5Zi1kNDUzZjMwNGIyZjIiLCJhdWQiOiJhdXRoZW50aWNhdGVkIiwiZXhwIjoxNzI5NDE1NDQwLCJpYXQiOjE3Mjk0MTE4NDAsImVtYWlsIjoiYWRtaW5AenhqLmltIiwicGhvbmUiOiIiLCJhcHBfbWV0YWRhdGEiOnsicHJvdmlkZXIiOiJlbWFpbCIsInByb3ZpZGVycyI6WyJlbWFpbCJdfSwidXNlcl9tZXRhZGF0YSI6e30sInJvbGUiOiJhdXRoZW50aWNhdGVkIiwiYWFsIjoiYWFsMSIsImFtciI6W3sibWV0aG9kIjoicGFzc3dvcmQiLCJ0aW1lc3RhbXAiOjE3Mjk0MTE4NDB9XSwic2Vzc2lvbl9pZCI6IjEwOWEyZjZjLWM4NmEtNGVjZC05MzMxLWFhNDEyMzc1NDM1ZCIsImlzX2Fub255bW91cyI6ZmFsc2V9.voDVDh5Qlockr5nmx6Hhe3pcBnm5Aqq6r-aeSY-QUwA'; + +const simpleToken = + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIzZjgyZTNhZS1iN2MyLTQyNDQtODQ5Zi1kNDUzZjMwNGIyZjIiLCJhdWQiOiJhdXRoZW50aWNhdGVkIiwicm9sZSI6ImF1dGhlbnRpY2F0ZWQiLCJpYXQiOjE3Mjk0MTIzNzksImV4cCI6MTcyOTQzNzU3OX0.ZiLSxOJ-iy6YtuhXzWokHMLswsFu4u3716qEJmEkdJc'; +const simpleToken2 = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjE0MjA2MzA1LThiNWMtNDRjYy1iMTc3LTc2NmNmZTJlNDUyZiIsInVzZXJuYW1lIjoicm9vdCIsInR5cGUiOiJ1c2VyIiwiYXVkIjoiYXV0aGVudGljYXRlZCIsInJvbGUiOiJhdXRoZW50aWNhdGVkIiwic3ViIjoiM2Y4MmUzYWUtYjdjMi00MjQ0LTg0OWYtZDQ1M2YzMDRiMmYyIiwiaWF0IjoxNzI5NDE3OTc1LCJleHAiOjE3MzAwMjI3NzV9.niMsxSGuj-iHOY6SUskZwHWXIB9xfhRvpLw1GrqOJLg' +const client = await supabase.auth.setSession({ + access_token: simpleToken2, + refresh_token: simpleToken2, +}); +// const user = await supabase.auth.getUser(simpleToken); +// console.log('client', user); + +// supabase.auth.getSession(); +// const isLogin = await supabase.auth.getSession(); +// console.log('client', client); +// console.log('client', isLogin); + +// const { data, error } = await supabase.from('public_test').select(` +// id, +// title +// `); +// console.log('data', data); + +// public_test 添加一条数据 +// const { data, error } = await supabase.from('public_test').insert([ +// { +// title: 'hello', +// }, +// ]); +// console.log('insert', data); + +// const { data, error } = await supabase.from('snippet').select(` +// id, +// description +// `); +// console.log('data', data); +const { data, error } = await supabase.from('snippet').insert([ + { + name: 'hello from supa', + }, +]); +console.log('insert', data); +if (error) { + console.log('error', error); +} diff --git a/src/login.ts b/src/login.ts new file mode 100644 index 0000000..a5f3401 --- /dev/null +++ b/src/login.ts @@ -0,0 +1,7 @@ +import { supabase } from './module/supabase'; +const u = await supabase.auth.signInWithPassword({ + email: 'admin@zxj.im', + password: '123456xx', +}); + +console.log('u', u); \ No newline at end of file diff --git a/src/module/supabase.ts b/src/module/supabase.ts new file mode 100644 index 0000000..660c3f7 --- /dev/null +++ b/src/module/supabase.ts @@ -0,0 +1,21 @@ +import { QueryResult, QueryData, QueryError } from '@supabase/supabase-js'; + +import { createClient, AuthClient } from '@supabase/supabase-js'; +// const url = 'http://192.168.31.220:8000' +// const url = 'http://supabase.xiongxiao.me' +const url = 'http://supabase.xiongxiao.me'; + +// const authClient = new AuthClient({ url: url }); +// // const auth = await authClient.signInWithPassword({ email: 'xiongxiao1012@outlook.com', password:'123456xx' }); +// // const auth = await authClient.signInWithPassword({ email: 'admin@zxj.im', password:'123456xx' }); +// const auth = await authClient.signInAnonymously(); +// console.log('auth', auth); + +// Create a single supabase client for interacting with your database +const publicAnonKey = + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ewogICJyb2xlIjogImFub24iLAogICJpc3MiOiAic3VwYWJhc2UiLAogICJpYXQiOiAxNzI4NTc2MDAwLAogICJleHAiOiAxODg2MzQyNDAwCn0._O6nSz8km61C76qGnRMa44e4sou1qCRBhy8O0riHQmM'; +const serverKey = + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ewogICJyb2xlIjogInNlcnZpY2Vfcm9sZSIsCiAgImlzcyI6ICJzdXBhYmFzZSIsCiAgImlhdCI6IDE3Mjg1NzYwMDAsCiAgImV4cCI6IDE4ODYzNDI0MDAKfQ.J9TQ7GUTbh7bKOXCyC1FWiJMrAEzGuJaMGHZZSiIG58'; +export const supabase = createClient(url, publicAnonKey); + +export const supabaseServer = createClient(url, serverKey); diff --git a/src/pg.ts b/src/pg.ts new file mode 100644 index 0000000..0ff3cde --- /dev/null +++ b/src/pg.ts @@ -0,0 +1,43 @@ +import pg from 'pg'; + +// 使用pg链接数据库 +// postgres: { +// username: 'root', +// host: 'light.xiongxiao.me', +// database: 'xpostgres', +// password: 'abearxiong', +// port: 5432, +// }, + +const pool = new pg.Pool({ + user: 'postgres', + host: '124.222.140.199', + database: 'postgres', + password: '123456xx', + port: 5434, +}); +pool.query('SELECT NOW()', (err, res) => { + console.log(err, res); + pool.end(); +}); + +// 配置数据库连接信息 +// const client = new pg.Client({ +// connectionString: 'postgresql://postgres:123456xx@light.xiongxiao.me:5434/postgres', +// }); + +// // 连接到数据库 +// client.connect() +// .then(() => { +// console.log('Connected to the PostgreSQL database successfully!'); +// return client.query('SELECT NOW()'); // 示例查询 +// }) +// .then((res) => { +// console.log('Server time:', res.rows[0]); +// }) +// .catch((err) => { +// console.error('Database connection error:', err.stack); +// }) +// .finally(() => { +// client.end(); // 关闭数据库连接 +// }); \ No newline at end of file diff --git a/src/send.ts b/src/send.ts new file mode 100644 index 0000000..f58a74a --- /dev/null +++ b/src/send.ts @@ -0,0 +1,29 @@ +import nodemailer from 'nodemailer'; + +// 创建传输器(transporter)对象 +const transporter = nodemailer.createTransport({ + host: 'smtp.feishu.cn', // 替换为你的SMTP服务器地址 + port: 587, // SMTP端口 + secure: false, // 使用TLS协议,false表示不强制加密连接(可根据需求调整) + auth: { + user: 'root@xiongxiao.me', // 替换为你的邮箱账号 + pass: 'K4fyaHkXTiVZGanV', // 替换为你的邮箱密码 + }, +}); + +// 邮件信息 +const mailOptions = { + from: '"Test Sender" root@xiongxiao.me', // 发件人 + to: 'xiongxiao1012@outlook.com', // 收件人(可以用逗号分隔多个收件人) + subject: 'SMTP Test Email', // 主题 + text: 'Hello, this is a test email sent using Node.js!', // 纯文本内容 + html: 'Hello, this is a test email sent using Node.js!', // HTML内容 +}; + +// 发送邮件 +transporter.sendMail(mailOptions, (error, info) => { + if (error) { + return console.log('Error:', error); + } + console.log('Email sent successfully! Message ID:', info.messageId); +}); diff --git a/src/token-show.ts b/src/token-show.ts new file mode 100644 index 0000000..24f0a9e --- /dev/null +++ b/src/token-show.ts @@ -0,0 +1,27 @@ +import { supabase } from './module/supabase'; +import jsonwentoken from 'jsonwebtoken'; +const token = + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIzZjgyZTNhZS1iN2MyLTQyNDQtODQ5Zi1kNDUzZjMwNGIyZjIiLCJhdWQiOiJhdXRoZW50aWNhdGVkIiwiZXhwIjoxNzI5NDE1NDQwLCJpYXQiOjE3Mjk0MTE4NDAsImVtYWlsIjoiYWRtaW5AenhqLmltIiwicGhvbmUiOiIiLCJhcHBfbWV0YWRhdGEiOnsicHJvdmlkZXIiOiJlbWFpbCIsInByb3ZpZGVycyI6WyJlbWFpbCJdfSwidXNlcl9tZXRhZGF0YSI6e30sInJvbGUiOiJhdXRoZW50aWNhdGVkIiwiYWFsIjoiYWFsMSIsImFtciI6W3sibWV0aG9kIjoicGFzc3dvcmQiLCJ0aW1lc3RhbXAiOjE3Mjk0MTE4NDB9XSwic2Vzc2lvbl9pZCI6IjEwOWEyZjZjLWM4NmEtNGVjZC05MzMxLWFhNDEyMzc1NDM1ZCIsImlzX2Fub255bW91cyI6ZmFsc2V9.voDVDh5Qlockr5nmx6Hhe3pcBnm5Aqq6r-aeSY-QUwA'; +const secret = 'WQEL5ffVF3lmnYiJn0Z9w2raDCLiLOPjuebrVave'; + +// const { data, error } = supabase.auth. + +const decoded = jsonwentoken.verify(token, secret); + +console.log('decoded', decoded); + +const encode = jsonwentoken.sign( + { + sub: '3f82e3ae-b7c2-4244-849f-d453f304b2f2', + aud: 'authenticated', + role: 'authenticated', + }, + secret, + { + expiresIn: '7h', + }, +); + +console.log('encode', encode); + +console.log(jsonwentoken.verify(encode, secret));