Added core project files.
7
.eslintignore
Normal file
|
@ -0,0 +1,7 @@
|
|||
node_modules
|
||||
dist
|
||||
README.md
|
||||
LICENSE
|
||||
src/webrtc
|
||||
scripts/
|
||||
assets
|
14
.eslintrc
Normal file
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"plugins": ["@typescript-eslint"],
|
||||
"root": true,
|
||||
"rules": {
|
||||
"no-mixed-spaces-and-tabs": "off",
|
||||
"@typescript-eslint/no-inferrable-types": "off", // Required by typeorm
|
||||
"@typescript-eslint/no-var-requires": "off" // Sometimes requred by typeorm to resolve circular deps
|
||||
},
|
||||
"env": {
|
||||
"node": true
|
||||
}
|
||||
}
|
4
.gitattributes
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
* text=auto
|
||||
*.sh -crlf
|
||||
*.nix -crlf
|
||||
.husky/pre-commit -crlf
|
22
.gitignore
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
**/.DS_STORE
|
||||
db/
|
||||
dist/
|
||||
node_modules
|
||||
database.db
|
||||
tsconfig.tsbuildinfo
|
||||
files/
|
||||
assets/cache
|
||||
.env
|
||||
config.json
|
||||
assets/cacheMisses
|
||||
|
||||
.vscode/settings.json
|
||||
|
||||
build
|
||||
|
||||
*.log
|
||||
*.log.ansi
|
||||
*.tmp
|
||||
tmp/
|
||||
dump/
|
||||
result
|
28
.husky/pre-commit
Normal file
|
@ -0,0 +1,28 @@
|
|||
#!/usr/bin/env sh
|
||||
#!nix-shell -i "bash" -p bash prefetch-npm-deps jq nodejs nix-output-monitor
|
||||
. "$(dirname -- "$0")/_/husky.sh"
|
||||
|
||||
# Check if nix is available
|
||||
if [ -x "$(/usr/bin/env which nix-shell 2>/dev/null)" ]; then
|
||||
# Check if we haven't re-executed ourselves yet
|
||||
if [ ! "$HOOK_NIX_SHELL" ]; then
|
||||
echo "Nix is available, updating nix flake..."
|
||||
export HOOK_NIX_SHELL=1
|
||||
nix-shell $0
|
||||
exit $?
|
||||
else
|
||||
nix flake update
|
||||
# run ./nix-update.sh if package lock has changed and has no unstaged changes
|
||||
if [ -n "$(git status --porcelain=v1 2>/dev/null | grep -E '^(MM| M) package-lock.json')" ]; then
|
||||
echo "package-lock.json has unstaged changes. Skipping update of nix dependencies."
|
||||
elif [ ! -n "$(git status --porcelain=v1 2>/dev/null | grep -E '^M package-lock.json')" ]; then
|
||||
echo "package-lock.json has no changes. Skipping update of nix dependencies."
|
||||
else
|
||||
./nix-update.sh || exit $?
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "You do not appear to have nix installed. Skipping update of nix dependencies."
|
||||
fi
|
||||
|
||||
npx -y lint-staged
|
3
.lintstagedrc
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"*.{j,t}s": ["eslint", "prettier --write"]
|
||||
}
|
6
.prettierignore
Normal file
|
@ -0,0 +1,6 @@
|
|||
assets
|
||||
dist
|
||||
node_modules
|
||||
.github
|
||||
.vscode
|
||||
hashes.json
|
11
.prettierrc.json
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"trailingComma": "all",
|
||||
"tabWidth": 4,
|
||||
"semi": true,
|
||||
"arrowParens": "always",
|
||||
"bracketSameLine": false,
|
||||
"bracketSpacing": true,
|
||||
"quoteProps": "as-needed",
|
||||
"useTabs": true,
|
||||
"singleQuote": false
|
||||
}
|
21
.vscode/launch.json
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Launch current file",
|
||||
"program": "${relativeFile}",
|
||||
"request": "launch",
|
||||
"skipFiles": ["<node_internals>/**"],
|
||||
"type": "node"
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Bundle",
|
||||
"skipFiles": ["<node_internals>/**"],
|
||||
"program": "${workspaceFolder}/src/bundle/start.ts",
|
||||
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
|
||||
"preLaunchTask": "tsc: build - tsconfig.json"
|
||||
}
|
||||
]
|
||||
}
|
210
LICENSE
|
@ -1,73 +1,201 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2024 ValkyrieChat
|
||||
Copyright 2024 ValkyrieChat
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
120
assets/email_templates/new_login_location.html
Normal file
|
@ -0,0 +1,120 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta http-equiv="Content-Type" content="text/html charset=UTF-8" />
|
||||
<title>Verify {instanceName} Login from New Location</title>
|
||||
|
||||
<style>
|
||||
* {
|
||||
font-size: 16px;
|
||||
line-height: 24px;
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
}
|
||||
|
||||
p {
|
||||
color: white;
|
||||
}
|
||||
|
||||
.ExternalClass {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div style="background-color: #202225">
|
||||
<img
|
||||
src="https://cdn.dragonschildstudios.com/Bygul1.png"
|
||||
alt="Branding"
|
||||
style="
|
||||
width: 100%;
|
||||
max-width: 200px;
|
||||
margin: 0 auto;
|
||||
display: block;
|
||||
padding: 20px;
|
||||
"
|
||||
/>
|
||||
<div
|
||||
style="
|
||||
width: 100%;
|
||||
max-width: 500px;
|
||||
margin: 0 auto;
|
||||
padding: 40px 50px;
|
||||
background-color: #32353b;
|
||||
border-radius: 5px;
|
||||
"
|
||||
>
|
||||
<p
|
||||
style="
|
||||
font-weight: 600;
|
||||
font-size: 20px;
|
||||
letter-spacing: 0.27px;
|
||||
line-height: 24px;
|
||||
"
|
||||
>
|
||||
Hey {userUsername},
|
||||
</p>
|
||||
<p>
|
||||
It looks like someone tried to log into your {instanceName}
|
||||
account from a new location. If this is you, follow the link
|
||||
below to authorize logging in from this location on your
|
||||
account. If this isn't you, we suggest changing your
|
||||
password as soon as possible.
|
||||
</p>
|
||||
<p>
|
||||
<strong>IP Address:</strong> {ipAddress}
|
||||
<br />
|
||||
<strong>Location:</strong> {locationCity}, {locationRegion},
|
||||
{locationCountryName}
|
||||
</p>
|
||||
<div>
|
||||
<div
|
||||
style="
|
||||
text-align: center;
|
||||
justify-content: center;
|
||||
padding-bottom: 10px;
|
||||
"
|
||||
>
|
||||
<a
|
||||
href="{actionUrl}"
|
||||
target="_blank"
|
||||
style="
|
||||
font-size: 15px;
|
||||
border: none;
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
cursor: pointer;
|
||||
padding: 15px 19px;
|
||||
background-color: #0185ff;
|
||||
border-radius: 5px;
|
||||
"
|
||||
>Verify Login</a
|
||||
>
|
||||
</div>
|
||||
<hr />
|
||||
<div
|
||||
style="
|
||||
text-align: center;
|
||||
justify-content: center;
|
||||
padding-bottom: 10px;
|
||||
"
|
||||
>
|
||||
<p>
|
||||
Alternatively, you can directly paste this link into
|
||||
your browser:
|
||||
</p>
|
||||
<a
|
||||
href="{actionUrl}"
|
||||
target="_blank"
|
||||
style="word-wrap: break-word"
|
||||
>{actionUrl}</a
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
65
assets/email_templates/password_changed.html
Normal file
|
@ -0,0 +1,65 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta http-equiv="Content-Type" content="text/html charset=UTF-8" />
|
||||
<title>{instanceName} Password Changed</title>
|
||||
|
||||
<style>
|
||||
* {
|
||||
font-size: 16px;
|
||||
line-height: 24px;
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
}
|
||||
p {
|
||||
color: white;
|
||||
}
|
||||
.ExternalClass {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div style="background-color: #202225">
|
||||
<img
|
||||
src="https://cdn.dragonschildstudios.com/Bygul1.png"
|
||||
alt="Branding"
|
||||
style="
|
||||
width: 100%;
|
||||
max-width: 200px;
|
||||
margin: 0 auto;
|
||||
display: block;
|
||||
padding: 20px;
|
||||
"
|
||||
/>
|
||||
<div
|
||||
style="
|
||||
width: 100%;
|
||||
max-width: 500px;
|
||||
margin: 0 auto;
|
||||
padding: 40px 50px;
|
||||
background-color: #32353b;
|
||||
border-radius: 5px;
|
||||
"
|
||||
>
|
||||
<p
|
||||
style="
|
||||
font-weight: 600;
|
||||
font-size: 20px;
|
||||
letter-spacing: 0.27px;
|
||||
line-height: 24px;
|
||||
"
|
||||
>
|
||||
Hey {userUsername},
|
||||
</p>
|
||||
<p>Your {instanceName} password has been changed.</p>
|
||||
<p>
|
||||
If this wasn't done by you, please immediately reset the
|
||||
password to your {instanceName} account.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
106
assets/email_templates/password_reset_request.html
Normal file
|
@ -0,0 +1,106 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta http-equiv="Content-Type" content="text/html charset=UTF-8" />
|
||||
<title>Password Reset Request for {instanceName}</title>
|
||||
|
||||
<style>
|
||||
* {
|
||||
font-size: 16px;
|
||||
line-height: 24px;
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
}
|
||||
|
||||
p {
|
||||
color: white;
|
||||
}
|
||||
|
||||
.ExternalClass {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div style="background-color: #202225">
|
||||
<img
|
||||
src="https://cdn.dragonschildstudios.com/Bygul1.png"
|
||||
alt="Branding"
|
||||
style="
|
||||
width: 100%;
|
||||
max-width: 200px;
|
||||
margin: 0 auto;
|
||||
display: block;
|
||||
padding: 20px;
|
||||
"
|
||||
/>
|
||||
<div
|
||||
style="
|
||||
width: 100%;
|
||||
max-width: 500px;
|
||||
margin: 0 auto;
|
||||
padding: 40px 50px;
|
||||
background-color: #32353b;
|
||||
border-radius: 5px;
|
||||
"
|
||||
>
|
||||
<p
|
||||
style="
|
||||
font-weight: 600;
|
||||
font-size: 20px;
|
||||
letter-spacing: 0.27px;
|
||||
line-height: 24px;
|
||||
"
|
||||
>
|
||||
Hey {userUsername},
|
||||
</p>
|
||||
<p>
|
||||
Your {instanceName} password can be reset by clicking the
|
||||
button below. If you did not request a new password, please
|
||||
ignore this email.
|
||||
</p>
|
||||
<div>
|
||||
<div
|
||||
style="
|
||||
text-align: center;
|
||||
justify-content: center;
|
||||
padding-bottom: 10px;
|
||||
"
|
||||
>
|
||||
<a
|
||||
href="{actionUrl}"
|
||||
target="_blank"
|
||||
style="
|
||||
font-size: 15px;
|
||||
border: none;
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
cursor: pointer;
|
||||
padding: 15px 19px;
|
||||
background-color: #ff5f00;
|
||||
border-radius: 5px;
|
||||
"
|
||||
>Reset Password</a
|
||||
>
|
||||
</div>
|
||||
<hr />
|
||||
<div style="text-align: center">
|
||||
<p>
|
||||
Alternatively, you can directly paste this link into
|
||||
your browser:
|
||||
</p>
|
||||
<a
|
||||
href="{actionUrl}"
|
||||
target="_blank"
|
||||
style="word-wrap: break-word"
|
||||
>{actionUrl}</a
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
69
assets/email_templates/phone_removed.html
Normal file
|
@ -0,0 +1,69 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta http-equiv="Content-Type" content="text/html charset=UTF-8" />
|
||||
<title>Phone Removed From {instanceName} Account</title>
|
||||
|
||||
<style>
|
||||
* {
|
||||
font-size: 16px;
|
||||
line-height: 24px;
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
}
|
||||
p {
|
||||
color: white;
|
||||
}
|
||||
.ExternalClass {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div style="background-color: #202225">
|
||||
<img
|
||||
src="https://cdn.dragonschildstudios.com/Bygul1.png"
|
||||
alt="Branding"
|
||||
style="
|
||||
width: 100%;
|
||||
max-width: 200px;
|
||||
margin: 0 auto;
|
||||
display: block;
|
||||
padding: 20px;
|
||||
"
|
||||
/>
|
||||
<div
|
||||
style="
|
||||
width: 100%;
|
||||
max-width: 500px;
|
||||
margin: 0 auto;
|
||||
padding: 40px 50px;
|
||||
background-color: #32353b;
|
||||
border-radius: 5px;
|
||||
"
|
||||
>
|
||||
<p
|
||||
style="
|
||||
font-weight: 600;
|
||||
font-size: 20px;
|
||||
letter-spacing: 0.27px;
|
||||
line-height: 24px;
|
||||
"
|
||||
>
|
||||
Hey {userUsername},
|
||||
</p>
|
||||
<p>
|
||||
Your phone number ********{phoneNumber} was recently removed
|
||||
from this account and added to a different {instanceName}
|
||||
account.
|
||||
</p>
|
||||
<p>
|
||||
Please note that your phone number can only be linked to one
|
||||
{instanceName} account at a time.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
104
assets/email_templates/verify_email.html
Normal file
|
@ -0,0 +1,104 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta http-equiv="Content-Type" content="text/html charset=UTF-8" />
|
||||
<title>Verify Email Address for {instanceName}</title>
|
||||
|
||||
<style>
|
||||
* {
|
||||
font-size: 16px;
|
||||
line-height: 24px;
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
}
|
||||
p {
|
||||
color: white;
|
||||
}
|
||||
.ExternalClass {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div style="background-color: #202225">
|
||||
<img
|
||||
src="https://cdn.dragonschildstudios.com/Bygul1.png"
|
||||
alt="Branding"
|
||||
style="
|
||||
width: 100%;
|
||||
max-width: 200px;
|
||||
margin: 0 auto;
|
||||
display: block;
|
||||
padding: 20px;
|
||||
"
|
||||
/>
|
||||
<div
|
||||
style="
|
||||
width: 100%;
|
||||
max-width: 500px;
|
||||
margin: 0 auto;
|
||||
padding: 40px 50px;
|
||||
background-color: #32353b;
|
||||
border-radius: 5px;
|
||||
"
|
||||
>
|
||||
<p
|
||||
style="
|
||||
font-weight: 600;
|
||||
font-size: 20px;
|
||||
letter-spacing: 0.27px;
|
||||
line-height: 24px;
|
||||
"
|
||||
>
|
||||
Hey {userUsername},
|
||||
</p>
|
||||
<p>
|
||||
Thanks for registering for an account on {instanceName}!
|
||||
Before we get started, we just need to confirm that this is
|
||||
you. Click below to verify your email address:
|
||||
</p>
|
||||
<div>
|
||||
<div
|
||||
style="
|
||||
text-align: center;
|
||||
justify-content: center;
|
||||
padding-bottom: 10px;
|
||||
"
|
||||
>
|
||||
<a
|
||||
class="btn"
|
||||
href="{actionUrl}"
|
||||
target="_blank"
|
||||
style="
|
||||
font-size: 15px;
|
||||
border: none;
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
cursor: pointer;
|
||||
padding: 15px 19px;
|
||||
background-color: #ff5f00;
|
||||
border-radius: 5px;
|
||||
"
|
||||
>Verify Email</a
|
||||
>
|
||||
</div>
|
||||
<hr />
|
||||
<div style="text-align: center">
|
||||
<p>
|
||||
Alternatively, you can directly paste this link into
|
||||
your browser:
|
||||
</p>
|
||||
<a
|
||||
href="{actionUrl}"
|
||||
target="_blank"
|
||||
style="word-wrap: break-word"
|
||||
>{actionUrl}</a
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
24
assets/locales/en/auth.json
Normal file
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"login": {
|
||||
"INVALID_LOGIN": "Invalid login or password.",
|
||||
"INVALID_PASSWORD": "Invalid Password",
|
||||
"ACCOUNT_DISABLED": "This account is disabled",
|
||||
"INVALID_TOTP_CODE": "Invalid two-factor code.",
|
||||
"INVALID_TOTP_SECRET": "Invalid two-factor secret."
|
||||
},
|
||||
"register": {
|
||||
"REGISTRATION_DISABLED": "New user registration is disabled",
|
||||
"INVITE_ONLY": "You must be invited to register",
|
||||
"EMAIL_INVALID": "Invalid Email",
|
||||
"EMAIL_ALREADY_REGISTERED": "Email is already registered",
|
||||
"DATE_OF_BIRTH_UNDERAGE": "You need to be {{years}} years or older",
|
||||
"PASSWORD_REQUIREMENTS_MIN_LENGTH": "The password must be at least {{min}} characters long.",
|
||||
"CONSENT_REQUIRED": "You must agree to the Terms of Service and Privacy Policy.",
|
||||
"USERNAME_TOO_MANY_USERS": "Too many users have this username, please try another",
|
||||
"TOO_MANY_REGISTRATIONS": "Too many registrations, please try again later"
|
||||
},
|
||||
"password_reset": {
|
||||
"EMAIL_DOES_NOT_EXIST": "Email does not exist.",
|
||||
"INVALID_TOKEN": "Invalid token."
|
||||
}
|
||||
}
|
49
assets/locales/en/common.json
Normal file
|
@ -0,0 +1,49 @@
|
|||
{
|
||||
"field": {
|
||||
"BASE_TYPE_REQUIRED": "This field is required",
|
||||
"BASE_TYPE_STRING": "This field must be a string",
|
||||
"BASE_TYPE_NUMBER": "This field must be a number",
|
||||
"BASE_TYPE_BIGINT": "This field must be a bigint",
|
||||
"BASE_TYPE_BOOLEAN": "This field must be a boolean",
|
||||
"BASE_TYPE_CHOICES": "This field must be one of ({{types}})",
|
||||
"BASE_TYPE_CLASS": "This field must be an instance of {{type}}",
|
||||
"BASE_TYPE_OBJECT": "This field must be an object",
|
||||
"BASE_TYPE_ARRAY": "This field must be an array",
|
||||
"UNKOWN_FIELD": "Unknown key: {{key}}",
|
||||
"BASE_TYPE_CONSTANT": "This field must be {{value}}",
|
||||
"EMAIL_TYPE_INVALID_EMAIL": "Not a well-formed email address",
|
||||
"DATE_TYPE_PARSE": "Could not parse {{date}}. Should be ISO8601",
|
||||
"BASE_TYPE_BAD_LENGTH": "Must be between {{length}} in length"
|
||||
},
|
||||
"body": {
|
||||
"INVALID_BODY": "Invalid Body",
|
||||
"INVALID_REQUEST_SIGNATURE": "Invalid request signature",
|
||||
"MISSING_FILE": "File missing",
|
||||
"INVALID_FILE_TYPE": "Invalid file type"
|
||||
},
|
||||
"notfound": {
|
||||
"CHANNEL": "This channel doesn't exist",
|
||||
"USER": "User not found",
|
||||
"ROLE": "Role not found",
|
||||
"REACTION": "Reaction not found",
|
||||
"FILE": "File not found"
|
||||
},
|
||||
"toomany": {
|
||||
"CHANNEL": "Too many channels",
|
||||
"USER": "Too many users",
|
||||
"ROLE": "Too many roles",
|
||||
"REACTION": "Too many reactions",
|
||||
"FILE": "Too many files",
|
||||
"MESSAGE": "Too many messages"
|
||||
},
|
||||
"relationship": {
|
||||
"ALREADY_BLOCKED": "You already blocked the user",
|
||||
"NOT_FRIENDS": "You are not friends with the user",
|
||||
"ALREADY_FRIENDS": "You are already friends with the user",
|
||||
"ALREADY_SENT": "You already sent a friend request",
|
||||
"ADD_SELF": "You can't add yourself as a friend",
|
||||
"REMOVE_SELF": "You can't remove yourself as a friend",
|
||||
"UNBLOCK": "Unblock the user before sending a friend request",
|
||||
"BLOCKED": "The user blocked you"
|
||||
}
|
||||
}
|
18089
assets/openapi.json
Normal file
BIN
assets/public/1276374a404452756f3c9cc2601508a5.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
assets/public/22341bdb500c7b63a93bbce957d1601e.png
Normal file
After Width: | Height: | Size: 4.4 KiB |
BIN
assets/public/2e46fe14586f8e95471c0917f56726b5.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
assets/public/3b70bb66089c60f8be5e214bf8574c9d.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
assets/public/4a8562cf00887030c416d3ec2d46385a.png
Normal file
After Width: | Height: | Size: 4.3 KiB |
BIN
assets/public/4ab900144b0865430dc9be825c838faa.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
assets/public/7213ab6677377974697dfdfbaf5f6a6f.png
Normal file
After Width: | Height: | Size: 4.1 KiB |
BIN
assets/public/904bf9f1b61f53ef4a3b7a893afeabe3.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
assets/public/9581acd31832465bdeaa5385b0e919a3.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
assets/public/9b0bb198936784c45c72833cc426cc55.png
Normal file
After Width: | Height: | Size: 4.1 KiB |
BIN
assets/public/9d6ddb4e4d899a533a8cc617011351c9.png
Normal file
After Width: | Height: | Size: 4.4 KiB |
BIN
assets/public/a8a4727cf2dc2939bd3c657fad4463fa.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
assets/public/d9977836b82058bf2f74eebd50edc095.png
Normal file
After Width: | Height: | Size: 4.4 KiB |
115
assets/public/endpoints.json
Normal file
|
@ -0,0 +1,115 @@
|
|||
{
|
||||
"USER_CHANNELS": "/users/@me/channels",
|
||||
"USER_ACTIVITY_STATISTICS": "/users/@me/activities/statistics/applications",
|
||||
"ACTIVITIES": "/activities",
|
||||
"LOBBIES": "/lobbies",
|
||||
"LOBBY_SEARCH": "/lobbies/search",
|
||||
"NETWORKING_TOKEN": "/networking/token",
|
||||
"USER_GAMES_NOTIFICATIONS": "/users/@me/settings/game-notifications",
|
||||
"USER_GAMES_NOTIFICATIONS_OVERRIDES": "/users/@me/settings/game-notifications/overrides",
|
||||
"UNVERIFIED_APPLICATIONS": "/unverified-applications",
|
||||
"UNVERIFIED_APPLICATIONS_ICONS": "/unverified-applications/icons",
|
||||
"BULK_ACK": "/read-states/ack-bulk",
|
||||
"GUILDS": "/guilds",
|
||||
"CHANNELS": "/channels",
|
||||
"TUTORIAL_INDICATORS": "/tutorial/indicators",
|
||||
"TUTORIAL_INDICATORS_SUPPRESS": "/tutorial/indicators/suppress",
|
||||
"USERS": "/users",
|
||||
"ME": "/users/@me",
|
||||
"DELETE_ACCOUNT": "/users/@me/delete",
|
||||
"DISABLE_ACCOUNT": "/users/@me/disable",
|
||||
"DEVICES": "/users/@me/devices",
|
||||
"SETTINGS": "/users/@me/settings",
|
||||
"SETTINGS_CONSENT": "/users/@me/consent",
|
||||
"PHONE": "/users/@me/phone",
|
||||
"VERIFY_PHONE": "/users/@me/phone/verify",
|
||||
"VERIFY_PHONE_NEW": "/phone-verifications/verify",
|
||||
"RESEND_PHONE": "/phone-verifications/resend",
|
||||
"CONNECTIONS": "/users/@me/connections",
|
||||
"CONNECTION_SYNC_CONTACTS": "/users/@me/connections/contacts/@me/external-friend-list-entries",
|
||||
"NOTES": "/users/@me/notes",
|
||||
"MENTIONS": "/users/@me/mentions",
|
||||
"CAPTCHA": "/users/@me/captcha/verify",
|
||||
"EXPERIMENTS": "/experiments",
|
||||
"LOGIN": "/auth/login",
|
||||
"LOGIN_MFA": "/auth/mfa/totp",
|
||||
"LOGIN_SMS": "/auth/mfa/sms",
|
||||
"LOGIN_SMS_SEND": "/auth/mfa/sms/send",
|
||||
"REMOTE_AUTH_INITIALIZE": "/users/@me/remote-auth",
|
||||
"REMOTE_AUTH_CANCEL": "/users/@me/remote-auth/cancel",
|
||||
"REMOTE_AUTH_FINISH": "/users/@me/remote-auth/finish",
|
||||
"LOGOUT": "/auth/logout",
|
||||
"REGISTER": "/auth/register",
|
||||
"REGISTER_PHONE": "/auth/register/phone",
|
||||
"TRACK": "/science",
|
||||
"SSO": "/sso",
|
||||
"VERIFY": "/auth/verify",
|
||||
"AUTHORIZE_IP": "/auth/authorize-ip",
|
||||
"VERIFY_RESEND": "/auth/verify/resend",
|
||||
"FORGOT_PASSWORD": "/auth/forgot",
|
||||
"RESET_PASSWORD": "/auth/reset",
|
||||
"ICE": "/voice/ice",
|
||||
"REPORT": "/report",
|
||||
"REPORT_V2": "/reports",
|
||||
"REPORT_OPTIONS": "/report/options",
|
||||
"INTEGRATIONS": "/integrations",
|
||||
"GATEWAY": "/gateway",
|
||||
"APPLICATIONS_DETECTABLE": "/applications/detectable",
|
||||
"OAUTH2_AUTHORIZE": "/oauth2/authorize",
|
||||
"OAUTH2_AUTHORIZE_WEBHOOK_CHANNELS": "/oauth2/authorize/webhook-channels",
|
||||
"OAUTH2_CURRENT_AUTH": "/oauth2/@me",
|
||||
"OAUTH2_TOKENS": "/oauth2/tokens",
|
||||
"OAUTH2_WHITELIST_ACCEPT": "/oauth2/whitelist/accept",
|
||||
"MFA_TOTP_ENABLE": "/users/@me/mfa/totp/enable",
|
||||
"MFA_TOTP_DISABLE": "/users/@me/mfa/totp/disable",
|
||||
"MFA_SMS_ENABLE": "/users/@me/mfa/sms/enable",
|
||||
"MFA_SMS_DISABLE": "/users/@me/mfa/sms/disable",
|
||||
"MFA_CODES": "/users/@me/mfa/codes",
|
||||
"DISABLE_EMAIL_NOTIFICATIONS": "/users/disable-email-notifications",
|
||||
"GUILD_PREMIUM_SUBSCRIPTION_COOLDOWN": "/users/@me/guilds/premium/subscriptions/cooldown",
|
||||
"USER_GUILD_PREMIUM_SUBSCRIPTIONS": "/users/@me/guilds/premium/subscriptions",
|
||||
"USER_PREMIUM_GUILD_SUBSCRIPTION_SLOTS": "/users/@me/guilds/premium/subscription-slots",
|
||||
"BILLING_STRIPE_SETUP_INTENT_SECRET": "/users/@me/billing/stripe/setup-intents",
|
||||
"BILLING_PAYMENT_SOURCES": "/users/@me/billing/payment-sources",
|
||||
"BILLING_PAYMENTS": "/users/@me/billing/payments",
|
||||
"BILLING_BRAINTREE_POPUP_BRIDGE": "/billing/braintree/popup-bridge",
|
||||
"BILLING_BRAINTREE_POPUP_BRIDGE_CALLBACK": "/billing/braintree/popup-bridge/callback",
|
||||
"BILLING_SUBSCRIPTIONS": "/users/@me/billing/subscriptions",
|
||||
"BILLING_APPLY_APPLE_RECEIPT": "/billing/apple/apply-receipt",
|
||||
"BILLING_INVOICE_PREVIEW": "/users/@me/billing/invoices/preview",
|
||||
"USER_AGREEMENTS": "/users/@me/agreements",
|
||||
"HANDOFF": "/auth/handoff",
|
||||
"HANDOFF_EXCHANGE": "/auth/handoff/exchange",
|
||||
"LIBRARY": "/users/@me/library",
|
||||
"AUTH_CONSENT_REQUIRED": "/auth/consent-required",
|
||||
"USER_HARVEST": "/users/@me/harvest",
|
||||
"APPLICATION_BRANCHES": "/branches",
|
||||
"APPLICATIONS_PUBLIC": "/applications/public",
|
||||
"APPLICATIONS_TRENDING": "/applications/trending/global",
|
||||
"STORE_PUBLISHED_LISTINGS_APPLICATIONS": "/store/published-listings/applications",
|
||||
"STORE_PUBLISHED_LISTINGS_SKUS": "/store/published-listings/skus",
|
||||
"ENTITLEMENTS_GIFTABLE": "/users/@me/entitlements/gifts",
|
||||
"PROMOTIONS": "/promotions",
|
||||
"PROMOTION_ACK": "/promotions/ack",
|
||||
"HYPESQUAD_ONLINE": "/hypesquad/online",
|
||||
"GIFS_SEARCH": "/gifs/search",
|
||||
"GIFS_TRENDING": "/gifs/trending",
|
||||
"GIFS_TRENDING_GIFS": "/gifs/trending-gifs",
|
||||
"GIFS_SELECT": "/gifs/select",
|
||||
"GIFS_SUGGEST": "/gifs/suggest",
|
||||
"GIFS_TRENDING_SEARCH": "/gifs/trending-search",
|
||||
"USER_GIFT_CODE_CREATE": "/users/@me/entitlements/gift-codes",
|
||||
"USER_GIFT_CODES": "/users/@me/entitlements/gift-codes",
|
||||
"GUILD_DISCOVERY": "/discoverable-guilds",
|
||||
"GUILD_DISCOVERY_CATEGORIES": "/discovery/categories",
|
||||
"GUILD_DISCOVERY_VALID_TERM": "/discovery/valid-term",
|
||||
"USER_AFFINITIES": "/users/@me/affinities/users",
|
||||
"GUILD_AFFINITIES": "/users/@me/affinities/guilds",
|
||||
"XBOX_GAME_PASS_PROMOTION": "/promotions/xbox-game-pass",
|
||||
"XBOX_GAME_PASS_PROMOTION_REDEEM": "/promotions/xbox-game-pass/redeem",
|
||||
"FUNIMATION_PROMOTION": "/promotions/funimation",
|
||||
"PARTNERS_CONNECTIONS": "/partners/connections",
|
||||
"PARTNERS_APPLY": "/partners/apply",
|
||||
"USER_STICKER_PACKS": "/users/@me/sticker-packs",
|
||||
"INTERACTIONS": "/interactions"
|
||||
}
|
BIN
assets/public/fac7e78de9753d4a37083bba74c1d9ef.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
26
assets/public/features.json
Normal file
|
@ -0,0 +1,26 @@
|
|||
[
|
||||
"ANIMATED_ICON",
|
||||
"BANNER",
|
||||
"COMMERCE",
|
||||
"COMMUNITY",
|
||||
"DISCOVERABLE",
|
||||
"DISCOVERABLE_DISABLED",
|
||||
"ENABLED_DISCOVERABLE_BEFORE",
|
||||
"HUB",
|
||||
"INVITE_SPLASH",
|
||||
"MONETIZATION_ENABLED",
|
||||
"MORE_EMOJI",
|
||||
"MORE_STICKERS",
|
||||
"NEWS",
|
||||
"PARTNERED",
|
||||
"PREVIEW_ENABLED",
|
||||
"PRIVATE_THREADS",
|
||||
"SEVEN_DAY_THREAD_ARCHIVE",
|
||||
"THREE_DAY_THREAD_ARCHIVE",
|
||||
"THREADS_ENABLED",
|
||||
"TICKETED_EVENTS_ENABLED",
|
||||
"VANITY_URL",
|
||||
"VERIFIED",
|
||||
"VIP_REGIONS",
|
||||
"WELCOME_SCREEN_ENABLED"
|
||||
]
|
65
assets/public/index.html
Normal file
|
@ -0,0 +1,65 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Valkyrie Server</title>
|
||||
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Montserrat&display=swap" rel="stylesheet">
|
||||
|
||||
<style>
|
||||
body {
|
||||
font-family: 'Montserrat', sans-serif;
|
||||
background-color: rgb(10, 10, 10);
|
||||
color: white;
|
||||
font-size: 1.1rem;
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
* {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
p {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
margin: 0 40px 0 40px;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
#wordmark {
|
||||
width: min(500px, 50%);
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
a, a:visited {
|
||||
color: #0185ff;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container">
|
||||
<img alt="ValkyrieChat Logo"
|
||||
id="wordmark"
|
||||
src="https://cdn.dragonschildstudios.com/Bygul1.png" />
|
||||
|
||||
<h1>Welcome!</h1>
|
||||
<p>If you're viewing this page, that means you've successfully set up your very own ValkyrieChat instance!</p>
|
||||
<p>For information on how to configure your shiny new setup, you should visit <a href="https://docs.valkyriecoms.com">our documentation</a></p>
|
||||
<p>For information on how to connect and use your instance, <a href="https://docs.valkyriecoms.com/setup/clients">click here</a></p>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
147
assets/public/verify.html
Normal file
|
@ -0,0 +1,147 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Valkyrie Server</title>
|
||||
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css2?family=Montserrat&display=swap"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
|
||||
<style>
|
||||
body {
|
||||
font-family: "Montserrat", sans-serif;
|
||||
background-color: rgb(10, 10, 10);
|
||||
color: white;
|
||||
font-size: 1.1rem;
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
* {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
p {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
#wordmark {
|
||||
width: min(200px, 50%);
|
||||
margin: 20px;
|
||||
position: absolute;
|
||||
top: 20px;
|
||||
left: 20px;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 1.5rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
font-size: 1.1rem;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.container {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.box {
|
||||
width: 22vw;
|
||||
padding: 32px;
|
||||
border-radius: 8px;
|
||||
background-color: rgb(32, 32, 32);
|
||||
align-items: center;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container">
|
||||
<img
|
||||
alt="ValkyrieChat Logo"
|
||||
id="wordmark"
|
||||
src="https://cdn.dragonschildstudios.com/Bygul1.png"
|
||||
/>
|
||||
|
||||
<div class="box">
|
||||
<p id="title" class="title">Verifying your email</p>
|
||||
<p id="subtitle" class="subtitle">Please wait...</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
window.onload = verify;
|
||||
|
||||
function verify() {
|
||||
const title = document.getElementById("title");
|
||||
const subtitle = document.getElementById("subtitle");
|
||||
|
||||
// if no fragment identifier in URL, error
|
||||
if (!window.location.hash) {
|
||||
title.innerText = "Invalid Link";
|
||||
subtitle.innerText = "Please check the link and try again.";
|
||||
return;
|
||||
}
|
||||
|
||||
// convert fragment to a key-value pair
|
||||
const fragment = window.location.hash.substring(1);
|
||||
const pairs = fragment.split("&");
|
||||
const values = {};
|
||||
pairs.forEach((pair) => {
|
||||
const [key, value] = pair.split("=");
|
||||
values[key] = value;
|
||||
});
|
||||
|
||||
// ensure token key is present
|
||||
if (!values.token) {
|
||||
title.innerText = "Invalid Link";
|
||||
subtitle.innerText = "Please check the link and try again.";
|
||||
return;
|
||||
}
|
||||
|
||||
// make request to server
|
||||
const token = values.token;
|
||||
fetch("/api/auth/verify", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
token,
|
||||
}),
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then((data) => {
|
||||
// check for an error response
|
||||
if ("message" in data) {
|
||||
title.innerText = "Email Verification Link Expired";
|
||||
subtitle.innerText =
|
||||
"Please request a new verification link.";
|
||||
return;
|
||||
}
|
||||
|
||||
title.innerText = "Email Verified";
|
||||
subtitle.innerText = "You can now login.";
|
||||
})
|
||||
.catch((error) => {
|
||||
title.innerText = "Email Verification Failed";
|
||||
subtitle.innerText = error;
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
657878
assets/schemas.json
Normal file
80
flake.nix
Normal file
|
@ -0,0 +1,80 @@
|
|||
{
|
||||
description = "Valkyrie server, written in Typescript.";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils }:
|
||||
flake-utils.lib.eachSystem flake-utils.lib.allSystems (system:
|
||||
let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
};
|
||||
hashesFile = builtins.fromJSON (builtins.readFile ./hashes.json);
|
||||
lib = pkgs.lib;
|
||||
in rec {
|
||||
packages.default = pkgs.buildNpmPackage {
|
||||
pname = "valkyrie-server-ts";
|
||||
name = "valkyrie-server-ts";
|
||||
|
||||
meta = with lib; {
|
||||
description = "Valkyrie server, a FOSS reimplementation of the Discord backend.";
|
||||
homepage = "https://toastielab.dev/ValkyrieChat/Server";
|
||||
license = licenses.agpl3Plus;
|
||||
platforms = platforms.all;
|
||||
mainProgram = "start-bundle";
|
||||
};
|
||||
|
||||
src = ./.;
|
||||
nativeBuildInputs = with pkgs; [ python3 ];
|
||||
npmDepsHash = hashesFile.npmDepsHash;
|
||||
makeCacheWritable = true;
|
||||
postPatch = ''
|
||||
substituteInPlace package.json --replace 'npx patch-package' '${pkgs.nodePackages.patch-package}/bin/patch-package'
|
||||
'';
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
set -x
|
||||
#remove packages not needed for production, or at least try to...
|
||||
npm prune --omit dev --no-save $npmInstallFlags "''${npmInstallFlagsArray[@]}" $npmFlags "''${npmFlagsArray[@]}"
|
||||
find node_modules -maxdepth 1 -type d -empty -delete
|
||||
|
||||
mkdir -p $out/node_modules/
|
||||
cp -r node_modules/* $out/node_modules/
|
||||
cp -r dist/ $out/node_modules/@valkyrie
|
||||
for i in dist/**/start.js
|
||||
do
|
||||
makeWrapper ${pkgs.nodejs-slim}/bin/node $out/bin/start-`dirname ''${i/dist\//}` --prefix NODE_PATH : $out/node_modules --add-flags $out/node_modules/@valkyrie`dirname ''${i/dist/}`/start.js
|
||||
done
|
||||
set +x
|
||||
substituteInPlace package.json --replace 'dist/' 'node_modules/@valkyrie/'
|
||||
find $out/node_modules/@valkyrie/ -type f -name "*.js" | while read srcFile; do
|
||||
echo Patching imports in ''${srcFile/$out\/node_modules\/@valkyrie//}...
|
||||
substituteInPlace $srcFile --replace 'require("./' 'require(__dirname + "/'
|
||||
substituteInPlace $srcFile --replace 'require("../' 'require(__dirname + "/../'
|
||||
substituteInPlace $srcFile --replace ', "assets"' ', "..", "assets"'
|
||||
#substituteInPlace $srcFile --replace 'require("@valkyrie/' 'require("
|
||||
done
|
||||
set -x
|
||||
cp -r assets/ $out/
|
||||
cp package.json $out/
|
||||
rm -v $out/assets/openapi.json
|
||||
#rm -v $out/assets/schemas.json
|
||||
|
||||
#debug utils:
|
||||
#cp $out/node_modules/@valkyrie/ $out/build_output -r
|
||||
set +x
|
||||
runHook postInstall
|
||||
'';
|
||||
};
|
||||
devShell = pkgs.mkShell {
|
||||
buildInputs = with pkgs; [
|
||||
nodejs
|
||||
nodePackages.typescript
|
||||
];
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
3
hashes.json
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"npmDepsHash": "sha256-qcHlktC4qrhOJ6AwKbccPkr0cVrAtPhGK+xD/eV+scU="
|
||||
}
|
26
nginx.conf
Normal file
|
@ -0,0 +1,26 @@
|
|||
# This is an example nginx config for Valkyrie.
|
||||
|
||||
server {
|
||||
# Change server_name
|
||||
server_name valkyrie.example.com;
|
||||
listen 80;
|
||||
|
||||
location / {
|
||||
# do NOT change this
|
||||
proxy_pass http://127.0.0.1:3001;
|
||||
proxy_set_header Host $host;
|
||||
proxy_pass_request_headers on;
|
||||
add_header Last-Modified $date_gmt;
|
||||
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-Proto https;
|
||||
proxy_set_header X-Forwarded-For $remote_addr;
|
||||
proxy_set_header X-Forwarded-Host $remote_addr;
|
||||
proxy_no_cache 1;
|
||||
proxy_cache_bypass 1;
|
||||
|
||||
# this is important
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
}
|
||||
}
|
10
nix-update.sh
Normal file
|
@ -0,0 +1,10 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i "bash -x" -p bash prefetch-npm-deps jq git nix-output-monitor
|
||||
nix flake update --extra-experimental-features 'nix-command flakes'
|
||||
DEPS_HASH=`prefetch-npm-deps package-lock.json`
|
||||
TMPFILE=$(mktemp)
|
||||
jq '.npmDepsHash = "'$DEPS_HASH'"' hashes.json > $TMPFILE
|
||||
mv -- "$TMPFILE" hashes.json
|
||||
|
||||
nom build .# --extra-experimental-features 'nix-command flakes' || exit $?
|
||||
git add hashes.json flake.lock flake.nix
|
11184
package-lock.json
generated
Normal file
127
package.json
Normal file
|
@ -0,0 +1,127 @@
|
|||
{
|
||||
"name": "valkyrie-server",
|
||||
"version": "1.0.0",
|
||||
"description": "A Valkyriechat server written in Node.js",
|
||||
"scripts": {
|
||||
"prepare": "husky install",
|
||||
"postinstall": "npx patch-package",
|
||||
"start": "node dist/bundle/start.js",
|
||||
"start:api": "node dist/api/start.js",
|
||||
"start:cdn": "node dist/cdn/start.js",
|
||||
"start:gateway": "node dist/gateway/start.js",
|
||||
"build": "tsc -p .",
|
||||
"watch": "tsc -w -p .",
|
||||
"test": "node scripts/test.js",
|
||||
"lint": "eslint .",
|
||||
"setup": "npm run build && npm run generate:schema",
|
||||
"sync:db": "npm run build && node scripts/syncronise.js",
|
||||
"generate:rights": "node scripts/rights.js",
|
||||
"generate:schema": "node scripts/schema.js",
|
||||
"generate:migration": "node -r dotenv/config -r module-alias/register node_modules/typeorm/cli.js migration:generate -d dist/util/util/Database.js",
|
||||
"generate:openapi": "node scripts/openapi.js",
|
||||
"add:license": "node scripts/license.js",
|
||||
"migrate-from-staging": "node -r dotenv/config -r module-alias/register scripts/stagingMigration/index.js"
|
||||
},
|
||||
"main": "dist/bundle/index.js",
|
||||
"types": "src/bundle/index.ts",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://toastielab.dev/ValkyrieChat/Server.git"
|
||||
},
|
||||
"author": "Valkyriechat",
|
||||
"license": "Apache-2.0",
|
||||
"bugs": {
|
||||
"url": "https://toastielab.dev/ValkyrieChat/Server/issues"
|
||||
},
|
||||
"imports": {
|
||||
"#*": "./dist/*/index.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/amqplib": "^0.8.2",
|
||||
"@types/bcrypt": "^5.0.0",
|
||||
"@types/body-parser": "^1.19.2",
|
||||
"@types/cookie-parser": "^1.4.3",
|
||||
"@types/express": "^4.17.17",
|
||||
"@types/i18next-node-fs-backend": "^2.1.2",
|
||||
"@types/json-bigint": "^1.0.1",
|
||||
"@types/jsonwebtoken": "^9.0.2",
|
||||
"@types/morgan": "^1.9.4",
|
||||
"@types/multer": "^1.4.7",
|
||||
"@types/murmurhash-js": "^1.0.4",
|
||||
"@types/node": "^18.17.3",
|
||||
"@types/node-fetch": "^2.6.4",
|
||||
"@types/node-os-utils": "^1.3.1",
|
||||
"@types/nodemailer": "^6.4.9",
|
||||
"@types/probe-image-size": "^7.2.0",
|
||||
"@types/sharp": "^0.31.1",
|
||||
"@types/ws": "^8.5.5",
|
||||
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
||||
"@typescript-eslint/parser": "^6.21.0",
|
||||
"eslint": "^8.56.0",
|
||||
"express": "^4.19.2",
|
||||
"husky": "^8.0.3",
|
||||
"prettier": "^2.8.8",
|
||||
"pretty-quick": "^3.1.3",
|
||||
"typescript": "^4.9.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-s3": "^3.629.0",
|
||||
"@sentry/integrations": "^7.66.0",
|
||||
"@sentry/node": "^7.66.0",
|
||||
"ajv": "8.6.2",
|
||||
"ajv-formats": "2.1.1",
|
||||
"amqplib": "^0.10.3",
|
||||
"bcrypt": "^5.1.0",
|
||||
"body-parser": "1.20.1",
|
||||
"cheerio": "^1.0.0-rc.12",
|
||||
"cookie-parser": "^1.4.6",
|
||||
"dotenv": "^16.3.1",
|
||||
"exif-be-gone": "^1.3.2",
|
||||
"fast-zlib": "^2.0.1",
|
||||
"fido2-lib": "^3.4.1",
|
||||
"file-type": "~16.5.4",
|
||||
"form-data": "^4.0.0",
|
||||
"i18next": "^21.10.0",
|
||||
"i18next-fs-backend": "^2.1.5",
|
||||
"i18next-http-middleware": "^3.3.2",
|
||||
"image-size": "^1.0.2",
|
||||
"json-bigint": "^1.0.0",
|
||||
"jsonwebtoken": "^9.0.1",
|
||||
"lambert-server": "^1.2.12",
|
||||
"missing-native-js-functions": "^1.4.3",
|
||||
"module-alias": "^2.2.3",
|
||||
"morgan": "^1.10.0",
|
||||
"multer": "^1.4.5-lts.1",
|
||||
"murmurhash-js": "^1.0.0",
|
||||
"node-2fa": "^2.0.3",
|
||||
"node-fetch": "^2.6.12",
|
||||
"node-os-utils": "^1.3.7",
|
||||
"nodemailer": "^6.9.14",
|
||||
"picocolors": "^1.0.0",
|
||||
"probe-image-size": "^7.2.3",
|
||||
"proxy-agent": "^6.3.0",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"ts-node": "^10.9.1",
|
||||
"tslib": "^2.6.1",
|
||||
"typeorm": "^0.3.17",
|
||||
"typescript-json-schema": "^0.50.1",
|
||||
"wretch": "^2.6.0",
|
||||
"ws": "^8.17.1"
|
||||
},
|
||||
"_moduleAliases": {
|
||||
"@valkyrie/api": "dist/api",
|
||||
"@valkyrie/cdn": "dist/cdn",
|
||||
"@valkyrie/gateway": "dist/gateway",
|
||||
"@valkyrie/util": "dist/util"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"erlpack": "^0.1.4",
|
||||
"jimp": "^0.22.12",
|
||||
"mysql": "^2.18.1",
|
||||
"nodemailer-mailgun-transport": "^2.1.5",
|
||||
"nodemailer-mailjet-transport": "github:n0script22/nodemailer-mailjet-transport",
|
||||
"nodemailer-sendgrid-transport": "github:Maria-Golomb/nodemailer-sendgrid-transport",
|
||||
"pg": "^8.11.3",
|
||||
"sqlite3": "^5.1.6"
|
||||
}
|
||||
}
|
249
patches/ajv+8.6.2.patch
Normal file
|
@ -0,0 +1,249 @@
|
|||
diff --git a/node_modules/ajv/dist/compile/jtd/parse.js b/node_modules/ajv/dist/compile/jtd/parse.js
|
||||
index 1eeb1be..7684121 100644
|
||||
--- a/node_modules/ajv/dist/compile/jtd/parse.js
|
||||
+++ b/node_modules/ajv/dist/compile/jtd/parse.js
|
||||
@@ -239,6 +239,9 @@ function parseType(cxt) {
|
||||
gen.if(fail, () => parsingError(cxt, codegen_1.str `invalid timestamp`));
|
||||
break;
|
||||
}
|
||||
+ case "bigint":
|
||||
+ parseBigInt(cxt);
|
||||
+ break
|
||||
case "float32":
|
||||
case "float64":
|
||||
parseNumber(cxt);
|
||||
@@ -284,6 +287,15 @@ function parseNumber(cxt, maxDigits) {
|
||||
skipWhitespace(cxt);
|
||||
gen.if(codegen_1._ `"-0123456789".indexOf(${jsonSlice(1)}) < 0`, () => jsonSyntaxError(cxt), () => parseWith(cxt, parseJson_1.parseJsonNumber, maxDigits));
|
||||
}
|
||||
+function parseBigInt(cxt, maxDigits) {
|
||||
+ const {gen} = cxt
|
||||
+ skipWhitespace(cxt)
|
||||
+ gen.if(
|
||||
+ _`"-0123456789".indexOf(${jsonSlice(1)}) < 0`,
|
||||
+ () => jsonSyntaxError(cxt),
|
||||
+ () => parseWith(cxt, parseJson_1.parseJsonBigInt, maxDigits)
|
||||
+ )
|
||||
+}
|
||||
function parseBooleanToken(bool, fail) {
|
||||
return (cxt) => {
|
||||
const { gen, data } = cxt;
|
||||
diff --git a/node_modules/ajv/dist/compile/rules.js b/node_modules/ajv/dist/compile/rules.js
|
||||
index 82a591f..1ebd8fe 100644
|
||||
--- a/node_modules/ajv/dist/compile/rules.js
|
||||
+++ b/node_modules/ajv/dist/compile/rules.js
|
||||
@@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getRules = exports.isJSONType = void 0;
|
||||
-const _jsonTypes = ["string", "number", "integer", "boolean", "null", "object", "array"];
|
||||
+const _jsonTypes = ["string", "number", "integer", "boolean", "null", "object", "array","bigint"];
|
||||
const jsonTypes = new Set(_jsonTypes);
|
||||
function isJSONType(x) {
|
||||
return typeof x == "string" && jsonTypes.has(x);
|
||||
@@ -13,10 +13,11 @@ function getRules() {
|
||||
string: { type: "string", rules: [] },
|
||||
array: { type: "array", rules: [] },
|
||||
object: { type: "object", rules: [] },
|
||||
+ bigint: {type: "bigint", rules: []}
|
||||
};
|
||||
return {
|
||||
- types: { ...groups, integer: true, boolean: true, null: true },
|
||||
- rules: [{ rules: [] }, groups.number, groups.string, groups.array, groups.object],
|
||||
+ types: { ...groups, integer: true, boolean: true, null: true, bigint: true },
|
||||
+ rules: [{ rules: [] }, groups.number, groups.string, groups.array, groups.object, groups.bigint],
|
||||
post: { rules: [] },
|
||||
all: {},
|
||||
keywords: {},
|
||||
diff --git a/node_modules/ajv/dist/compile/validate/dataType.js b/node_modules/ajv/dist/compile/validate/dataType.js
|
||||
index 6319e76..8b50b4c 100644
|
||||
--- a/node_modules/ajv/dist/compile/validate/dataType.js
|
||||
+++ b/node_modules/ajv/dist/compile/validate/dataType.js
|
||||
@@ -52,7 +52,7 @@ function coerceAndCheckDataType(it, types) {
|
||||
return checkTypes;
|
||||
}
|
||||
exports.coerceAndCheckDataType = coerceAndCheckDataType;
|
||||
-const COERCIBLE = new Set(["string", "number", "integer", "boolean", "null"]);
|
||||
+const COERCIBLE = new Set(["string", "number", "integer", "boolean", "null","bigint"]);
|
||||
function coerceToTypes(types, coerceTypes) {
|
||||
return coerceTypes
|
||||
? types.filter((t) => COERCIBLE.has(t) || (coerceTypes === "array" && t === "array"))
|
||||
@@ -83,6 +83,14 @@ function coerceData(it, types, coerceTo) {
|
||||
});
|
||||
function coerceSpecificType(t) {
|
||||
switch (t) {
|
||||
+ case "bigint":
|
||||
+ gen
|
||||
+ .elseIf(
|
||||
+ codegen_1._`${dataType} == "boolean" || ${data} === null
|
||||
+ || (${dataType} == "string" && ${data} && ${data} == BigInt(${data}))`
|
||||
+ )
|
||||
+ .assign(coerced, codegen_1._`BigInt(${data})`)
|
||||
+ return
|
||||
case "string":
|
||||
gen
|
||||
.elseIf(codegen_1._ `${dataType} == "number" || ${dataType} == "boolean"`)
|
||||
@@ -143,6 +151,9 @@ function checkDataType(dataType, data, strictNums, correct = DataType.Correct) {
|
||||
case "number":
|
||||
cond = numCond();
|
||||
break;
|
||||
+ case "bigint":
|
||||
+ cond = codegen_1._`typeof ${data} == "bigint" && isFinite(${data})`
|
||||
+ break
|
||||
default:
|
||||
return codegen_1._ `typeof ${data} ${EQ} ${dataType}`;
|
||||
}
|
||||
diff --git a/node_modules/ajv/dist/refs/json-schema-2019-09/meta/validation.json b/node_modules/ajv/dist/refs/json-schema-2019-09/meta/validation.json
|
||||
index 7027a12..25679c8 100644
|
||||
--- a/node_modules/ajv/dist/refs/json-schema-2019-09/meta/validation.json
|
||||
+++ b/node_modules/ajv/dist/refs/json-schema-2019-09/meta/validation.json
|
||||
@@ -78,7 +78,7 @@
|
||||
"default": 0
|
||||
},
|
||||
"simpleTypes": {
|
||||
- "enum": ["array", "boolean", "integer", "null", "number", "object", "string"]
|
||||
+ "enum": ["array", "boolean", "integer", "null", "number", "object", "string","bigint"]
|
||||
},
|
||||
"stringArray": {
|
||||
"type": "array",
|
||||
diff --git a/node_modules/ajv/dist/refs/json-schema-2020-12/meta/validation.json b/node_modules/ajv/dist/refs/json-schema-2020-12/meta/validation.json
|
||||
index e0ae13d..57c9036 100644
|
||||
--- a/node_modules/ajv/dist/refs/json-schema-2020-12/meta/validation.json
|
||||
+++ b/node_modules/ajv/dist/refs/json-schema-2020-12/meta/validation.json
|
||||
@@ -78,7 +78,7 @@
|
||||
"default": 0
|
||||
},
|
||||
"simpleTypes": {
|
||||
- "enum": ["array", "boolean", "integer", "null", "number", "object", "string"]
|
||||
+ "enum": ["array", "boolean", "integer", "null", "number", "object", "string","bigint"]
|
||||
},
|
||||
"stringArray": {
|
||||
"type": "array",
|
||||
diff --git a/node_modules/ajv/dist/refs/json-schema-draft-06.json b/node_modules/ajv/dist/refs/json-schema-draft-06.json
|
||||
index 5410064..774435b 100644
|
||||
--- a/node_modules/ajv/dist/refs/json-schema-draft-06.json
|
||||
+++ b/node_modules/ajv/dist/refs/json-schema-draft-06.json
|
||||
@@ -16,7 +16,7 @@
|
||||
"allOf": [{"$ref": "#/definitions/nonNegativeInteger"}, {"default": 0}]
|
||||
},
|
||||
"simpleTypes": {
|
||||
- "enum": ["array", "boolean", "integer", "null", "number", "object", "string"]
|
||||
+ "enum": ["array", "boolean", "integer", "null", "number", "object", "string","bigint"]
|
||||
},
|
||||
"stringArray": {
|
||||
"type": "array",
|
||||
diff --git a/node_modules/ajv/dist/refs/json-schema-draft-07.json b/node_modules/ajv/dist/refs/json-schema-draft-07.json
|
||||
index 6a74851..fc6dd7d 100644
|
||||
--- a/node_modules/ajv/dist/refs/json-schema-draft-07.json
|
||||
+++ b/node_modules/ajv/dist/refs/json-schema-draft-07.json
|
||||
@@ -16,7 +16,7 @@
|
||||
"allOf": [{"$ref": "#/definitions/nonNegativeInteger"}, {"default": 0}]
|
||||
},
|
||||
"simpleTypes": {
|
||||
- "enum": ["array", "boolean", "integer", "null", "number", "object", "string"]
|
||||
+ "enum": ["array", "boolean", "integer", "null", "number", "object", "string","bigint"]
|
||||
},
|
||||
"stringArray": {
|
||||
"type": "array",
|
||||
diff --git a/node_modules/ajv/dist/refs/jtd-schema.js b/node_modules/ajv/dist/refs/jtd-schema.js
|
||||
index 1ee940a..1148887 100644
|
||||
--- a/node_modules/ajv/dist/refs/jtd-schema.js
|
||||
+++ b/node_modules/ajv/dist/refs/jtd-schema.js
|
||||
@@ -38,6 +38,7 @@ const typeForm = (root) => ({
|
||||
"uint16",
|
||||
"int32",
|
||||
"uint32",
|
||||
+ "bigint",
|
||||
],
|
||||
},
|
||||
},
|
||||
diff --git a/node_modules/ajv/dist/runtime/parseJson.js b/node_modules/ajv/dist/runtime/parseJson.js
|
||||
index 2576a6e..e7447b1 100644
|
||||
--- a/node_modules/ajv/dist/runtime/parseJson.js
|
||||
+++ b/node_modules/ajv/dist/runtime/parseJson.js
|
||||
@@ -97,6 +97,71 @@ exports.parseJsonNumber = parseJsonNumber;
|
||||
parseJsonNumber.message = undefined;
|
||||
parseJsonNumber.position = 0;
|
||||
parseJsonNumber.code = 'require("ajv/dist/runtime/parseJson").parseJsonNumber';
|
||||
+
|
||||
+function parseJsonBigInt(s, pos, maxDigits) {
|
||||
+ let numStr = "";
|
||||
+ let c;
|
||||
+ parseJsonBigInt.message = undefined;
|
||||
+ if (s[pos] === "-") {
|
||||
+ numStr += "-";
|
||||
+ pos++;
|
||||
+ }
|
||||
+ if (s[pos] === "0") {
|
||||
+ numStr += "0";
|
||||
+ pos++;
|
||||
+ }
|
||||
+ else {
|
||||
+ if (!parseDigits(maxDigits)) {
|
||||
+ errorMessage();
|
||||
+ return undefined;
|
||||
+ }
|
||||
+ }
|
||||
+ if (maxDigits) {
|
||||
+ parseJsonBigInt.position = pos;
|
||||
+ return BigInt(numStr);
|
||||
+ }
|
||||
+ if (s[pos] === ".") {
|
||||
+ numStr += ".";
|
||||
+ pos++;
|
||||
+ if (!parseDigits()) {
|
||||
+ errorMessage();
|
||||
+ return undefined;
|
||||
+ }
|
||||
+ }
|
||||
+ if (((c = s[pos]), c === "e" || c === "E")) {
|
||||
+ numStr += "e";
|
||||
+ pos++;
|
||||
+ if (((c = s[pos]), c === "+" || c === "-")) {
|
||||
+ numStr += c;
|
||||
+ pos++;
|
||||
+ }
|
||||
+ if (!parseDigits()) {
|
||||
+ errorMessage();
|
||||
+ return undefined;
|
||||
+ }
|
||||
+ }
|
||||
+ parseJsonBigInt.position = pos;
|
||||
+ return BigInt(numStr);
|
||||
+ function parseDigits(maxLen) {
|
||||
+ let digit = false;
|
||||
+ while (((c = s[pos]), c >= "0" && c <= "9" && (maxLen === undefined || maxLen-- > 0))) {
|
||||
+ digit = true;
|
||||
+ numStr += c;
|
||||
+ pos++;
|
||||
+ }
|
||||
+ return digit;
|
||||
+ }
|
||||
+ function errorMessage() {
|
||||
+ parseJsonBigInt.position = pos;
|
||||
+ parseJsonBigInt.message = pos < s.length ? `unexpected token ${s[pos]}` : "unexpected end";
|
||||
+ }
|
||||
+}
|
||||
+exports.parseJsonBigInt = parseJsonBigInt;
|
||||
+parseJsonBigInt.message = undefined;
|
||||
+parseJsonBigInt.position = 0;
|
||||
+parseJsonBigInt.code = 'require("ajv/dist/runtime/parseJson").parseJsonBigInt';
|
||||
+
|
||||
+
|
||||
const escapedChars = {
|
||||
b: "\b",
|
||||
f: "\f",
|
||||
diff --git a/node_modules/ajv/dist/vocabularies/jtd/type.js b/node_modules/ajv/dist/vocabularies/jtd/type.js
|
||||
index 428bddb..fbc3070 100644
|
||||
--- a/node_modules/ajv/dist/vocabularies/jtd/type.js
|
||||
+++ b/node_modules/ajv/dist/vocabularies/jtd/type.js
|
||||
@@ -45,6 +45,9 @@ const def = {
|
||||
cond = timestampCode(cxt);
|
||||
break;
|
||||
}
|
||||
+ case "bigint":
|
||||
+ cond = codegen_1._`typeof ${data} == "bigint" || typeof ${data} == "string"`
|
||||
+ break
|
||||
case "float32":
|
||||
case "float64":
|
||||
cond = codegen_1._ `typeof ${data} == "number"`;
|
39
patches/body-parser+1.20.1.patch
Normal file
|
@ -0,0 +1,39 @@
|
|||
diff --git a/node_modules/body-parser/lib/types/json.js b/node_modules/body-parser/lib/types/json.js
|
||||
index c2745be..17c2cfe 100644
|
||||
--- a/node_modules/body-parser/lib/types/json.js
|
||||
+++ b/node_modules/body-parser/lib/types/json.js
|
||||
@@ -18,6 +18,7 @@ var createError = require('http-errors')
|
||||
var debug = require('debug')('body-parser:json')
|
||||
var read = require('../read')
|
||||
var typeis = require('type-is')
|
||||
+var JSONbig = require("json-bigint");
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
@@ -86,7 +87,7 @@ function json (options) {
|
||||
|
||||
try {
|
||||
debug('parse json')
|
||||
- return JSON.parse(body, reviver)
|
||||
+ return JSONbig.parse(body, reviver)
|
||||
} catch (e) {
|
||||
throw normalizeJsonSyntaxError(e, {
|
||||
message: e.message,
|
||||
@@ -157,7 +158,7 @@ function createStrictSyntaxError (str, char) {
|
||||
: ''
|
||||
|
||||
try {
|
||||
- JSON.parse(partial); /* istanbul ignore next */ throw new SyntaxError('strict violation')
|
||||
+ JSONbig.parse(partial); /* istanbul ignore next */ throw new SyntaxError('strict violation')
|
||||
} catch (e) {
|
||||
return normalizeJsonSyntaxError(e, {
|
||||
message: e.message.replace('#', char),
|
||||
@@ -216,7 +217,7 @@ function normalizeJsonSyntaxError (error, obj) {
|
||||
}
|
||||
|
||||
// replace stack before message for Node.js 0.10 and below
|
||||
- error.stack = obj.stack.replace(error.message, obj.message)
|
||||
+ error.stack = obj.stack?.replace(error.message, obj.message)
|
||||
error.message = obj.message
|
||||
|
||||
return error
|
55
patches/express+4.19.2.patch
Normal file
|
@ -0,0 +1,55 @@
|
|||
diff --git a/node_modules/express/lib/response.js b/node_modules/express/lib/response.js
|
||||
index dd7b3c8..a339896 100644
|
||||
--- a/node_modules/express/lib/response.js
|
||||
+++ b/node_modules/express/lib/response.js
|
||||
@@ -27,7 +27,6 @@ var merge = require('utils-merge');
|
||||
var sign = require('cookie-signature').sign;
|
||||
var normalizeType = require('./utils').normalizeType;
|
||||
var normalizeTypes = require('./utils').normalizeTypes;
|
||||
-var setCharset = require('./utils').setCharset;
|
||||
var cookie = require('cookie');
|
||||
var send = require('send');
|
||||
var extname = path.extname;
|
||||
@@ -54,7 +53,6 @@ module.exports = res
|
||||
* @private
|
||||
*/
|
||||
|
||||
-var charsetRegExp = /;\s*charset\s*=/;
|
||||
var schemaAndHostRegExp = /^(?:[a-zA-Z][a-zA-Z0-9+.-]*:)?\/\/[^\\\/\?]+/;
|
||||
|
||||
/**
|
||||
@@ -165,16 +163,6 @@ res.send = function send(body) {
|
||||
break;
|
||||
}
|
||||
|
||||
- // write strings in utf-8
|
||||
- if (typeof chunk === 'string') {
|
||||
- encoding = 'utf8';
|
||||
- type = this.get('Content-Type');
|
||||
-
|
||||
- // reflect this in content-type
|
||||
- if (typeof type === 'string') {
|
||||
- this.set('Content-Type', setCharset(type, 'utf-8'));
|
||||
- }
|
||||
- }
|
||||
|
||||
// determine if ETag should be generated
|
||||
var etagFn = app.get('etag fn')
|
||||
@@ -781,17 +769,6 @@ res.header = function header(field, val) {
|
||||
? val.map(String)
|
||||
: String(val);
|
||||
|
||||
- // add charset to content-type
|
||||
- if (field.toLowerCase() === 'content-type') {
|
||||
- if (Array.isArray(value)) {
|
||||
- throw new TypeError('Content-Type cannot be set to an Array');
|
||||
- }
|
||||
- if (!charsetRegExp.test(value)) {
|
||||
- var charset = mime.charsets.lookup(value.split(';')[0]);
|
||||
- if (charset) value += '; charset=' + charset.toLowerCase();
|
||||
- }
|
||||
- }
|
||||
-
|
||||
this.setHeader(field, value);
|
||||
} else {
|
||||
for (var key in field) {
|
14
patches/typescript-json-schema+0.50.1.patch
Normal file
|
@ -0,0 +1,14 @@
|
|||
diff --git a/node_modules/typescript-json-schema/dist/typescript-json-schema.js b/node_modules/typescript-json-schema/dist/typescript-json-schema.js
|
||||
index 47e1598..8397b9d 100644
|
||||
--- a/node_modules/typescript-json-schema/dist/typescript-json-schema.js
|
||||
+++ b/node_modules/typescript-json-schema/dist/typescript-json-schema.js
|
||||
@@ -432,6 +432,9 @@ var JsonSchemaGenerator = (function () {
|
||||
else if (flags & ts.TypeFlags.Boolean) {
|
||||
definition.type = "boolean";
|
||||
}
|
||||
+ else if (flags & ts.TypeFlags.BigInt) {
|
||||
+ definition.type = "bigint";
|
||||
+ }
|
||||
else if (flags & ts.TypeFlags.Null) {
|
||||
definition.type = "null";
|
||||
}
|
60
scripts/license.js
Normal file
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
Automatically appends our license preamble to each source file.
|
||||
Does not prepend if preamble already exists.
|
||||
Does not replace if change in util/licensePreamble.txt was made.
|
||||
Does not prepend is file contains @fc-license-skip
|
||||
*/
|
||||
|
||||
const Path = require("path");
|
||||
const fs = require("fs");
|
||||
const walk = require("./util/walk");
|
||||
|
||||
const VALKYRIE_SOURCE_DIR = Path.join(__dirname, "..", "src");
|
||||
const VALKYRIE_SCRIPTS_DIR = Path.join(__dirname);
|
||||
const VALKYRIE_LICENSE_PREAMBLE = fs
|
||||
.readFileSync(Path.join(__dirname, "util", "licensePreamble.txt"))
|
||||
.toString()
|
||||
.split("\r") // remove windows bs
|
||||
.join("") // ^
|
||||
.split("\n")
|
||||
.map((x) => `\t${x}`)
|
||||
.join("\n");
|
||||
|
||||
const languageCommentStrings = {
|
||||
js: ["/*", "*/"],
|
||||
ts: ["/*", "*/"],
|
||||
};
|
||||
|
||||
const addToDir = (dir) => {
|
||||
const files = walk(dir, Object.keys(languageCommentStrings));
|
||||
|
||||
for (let path of files) {
|
||||
const file = fs.readFileSync(path).toString().split("\r").join("");
|
||||
const fileType = path.slice(path.lastIndexOf(".") + 1);
|
||||
const commentStrings = languageCommentStrings[fileType];
|
||||
if (!commentStrings) continue;
|
||||
|
||||
const preamble =
|
||||
commentStrings[0] +
|
||||
"\n" +
|
||||
VALKYRIE_LICENSE_PREAMBLE +
|
||||
"\n" +
|
||||
commentStrings[1];
|
||||
|
||||
if (file.startsWith(preamble)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// This is kind of lame.
|
||||
if (file.includes("@fc-license-skip") && path != __filename) {
|
||||
console.log(`skipping ${path} as it has a different license.`);
|
||||
continue;
|
||||
}
|
||||
|
||||
console.log(`writing to ${path}`);
|
||||
fs.writeFileSync(path, preamble + "\n\n" + file);
|
||||
}
|
||||
};
|
||||
|
||||
addToDir(VALKYRIE_SOURCE_DIR);
|
||||
addToDir(VALKYRIE_SCRIPTS_DIR);
|
242
scripts/openapi.js
Normal file
|
@ -0,0 +1,242 @@
|
|||
require("module-alias/register");
|
||||
const getRouteDescriptions = require("./util/getRouteDescriptions");
|
||||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
const {
|
||||
NO_AUTHORIZATION_ROUTES,
|
||||
} = require("../dist/api/middlewares/Authentication");
|
||||
require("missing-native-js-functions");
|
||||
|
||||
const openapiPath = path.join(__dirname, "..", "assets", "openapi.json");
|
||||
const SchemaPath = path.join(__dirname, "..", "assets", "schemas.json");
|
||||
const schemas = JSON.parse(fs.readFileSync(SchemaPath, { encoding: "utf8" }));
|
||||
|
||||
let specification = {
|
||||
openapi: "3.1.0",
|
||||
info: {
|
||||
title: "Valkyrie Server",
|
||||
description:
|
||||
"Valkyrie is a Discord.com server implementation and extension, with the goal of complete feature parity with Discord.com, all while adding some additional goodies, security, privacy, and configuration options.",
|
||||
license: {
|
||||
name: "Apache-2.0",
|
||||
url: "https://www.gnu.org/licenses/agpl-3.0.en.html",
|
||||
},
|
||||
version: "1.0.0",
|
||||
},
|
||||
externalDocs: {
|
||||
description: "Valkyrie Docs",
|
||||
url: "https://docs.valkyriecoms.com",
|
||||
},
|
||||
servers: [
|
||||
{
|
||||
url: "https://old.server.valkyriecoms.com/api/",
|
||||
description: "Official Valkyrie Instance",
|
||||
},
|
||||
],
|
||||
components: {
|
||||
securitySchemes: {
|
||||
bearer: {
|
||||
type: "http",
|
||||
scheme: "bearer",
|
||||
description: "Bearer/Bot prefixes are not required.",
|
||||
bearerFormat: "JWT",
|
||||
in: "header",
|
||||
},
|
||||
},
|
||||
},
|
||||
tags: [],
|
||||
paths: {},
|
||||
};
|
||||
|
||||
const schemaRegEx = new RegExp(/^[\w.]+$/);
|
||||
function combineSchemas(schemas) {
|
||||
let definitions = {};
|
||||
|
||||
for (const name in schemas) {
|
||||
definitions = {
|
||||
...definitions,
|
||||
...schemas[name].definitions,
|
||||
[name]: {
|
||||
...schemas[name],
|
||||
definitions: undefined,
|
||||
$schema: undefined,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
for (const key in definitions) {
|
||||
if (!schemaRegEx.test(key)) {
|
||||
console.error(`Invalid schema name: ${key}`);
|
||||
continue;
|
||||
}
|
||||
specification.components = specification.components || {};
|
||||
specification.components.schemas =
|
||||
specification.components.schemas || {};
|
||||
specification.components.schemas[key] = definitions[key];
|
||||
delete definitions[key].additionalProperties;
|
||||
delete definitions[key].$schema;
|
||||
const definition = definitions[key];
|
||||
|
||||
if (typeof definition.properties === "object") {
|
||||
for (const property of Object.values(definition.properties)) {
|
||||
if (Array.isArray(property.type)) {
|
||||
if (property.type.includes("null")) {
|
||||
property.type = property.type.find((x) => x !== "null");
|
||||
property.nullable = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return definitions;
|
||||
}
|
||||
|
||||
function getTag(key) {
|
||||
return key.match(/\/([\w-]+)/)[1];
|
||||
}
|
||||
|
||||
function apiRoutes(missingRoutes) {
|
||||
const routes = getRouteDescriptions();
|
||||
|
||||
// populate tags
|
||||
const tags = Array.from(routes.keys())
|
||||
.map((x) => getTag(x))
|
||||
.sort((a, b) => a.localeCompare(b));
|
||||
specification.tags = tags.unique().map((x) => ({ name: x }));
|
||||
|
||||
routes.forEach((route, pathAndMethod) => {
|
||||
const [p, method] = pathAndMethod.split("|");
|
||||
const path = p.replace(/:(\w+)/g, "{$1}");
|
||||
|
||||
let obj = specification.paths[path]?.[method] || {};
|
||||
obj["x-right-required"] = route.right;
|
||||
obj["x-permission-required"] = route.permission;
|
||||
obj["x-fires-event"] = route.event;
|
||||
|
||||
if (
|
||||
!NO_AUTHORIZATION_ROUTES.some((x) => {
|
||||
if (typeof x === "string")
|
||||
return (method.toUpperCase() + " " + path).startsWith(x);
|
||||
return x.test(method.toUpperCase() + " " + path);
|
||||
})
|
||||
) {
|
||||
obj.security = [{ bearer: [] }];
|
||||
}
|
||||
|
||||
if (route.description) obj.description = route.description;
|
||||
if (route.summary) obj.summary = route.summary;
|
||||
if (route.deprecated) obj.deprecated = route.deprecated;
|
||||
|
||||
if (route.requestBody) {
|
||||
obj.requestBody = {
|
||||
required: true,
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
$ref: `#/components/schemas/${route.requestBody}`,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
if (route.responses) {
|
||||
obj.responses = {};
|
||||
|
||||
for (const [k, v] of Object.entries(route.responses)) {
|
||||
if (v.body)
|
||||
obj.responses[k] = {
|
||||
description: obj?.responses?.[k]?.description || "",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: {
|
||||
$ref: `#/components/schemas/${v.body}`,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
else
|
||||
obj.responses[k] = {
|
||||
description:
|
||||
obj?.responses?.[k]?.description ||
|
||||
"No description available",
|
||||
};
|
||||
}
|
||||
} else {
|
||||
obj.responses = {
|
||||
default: {
|
||||
description: "No description available",
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
// handles path parameters
|
||||
if (p.includes(":")) {
|
||||
obj.parameters = p.match(/:\w+/g)?.map((x) => ({
|
||||
name: x.replace(":", ""),
|
||||
in: "path",
|
||||
required: true,
|
||||
schema: { type: "string" },
|
||||
description: x.replace(":", ""),
|
||||
}));
|
||||
}
|
||||
|
||||
if (route.query) {
|
||||
// map to array
|
||||
const query = Object.entries(route.query).map(([k, v]) => ({
|
||||
name: k,
|
||||
in: "query",
|
||||
required: v.required,
|
||||
schema: { type: v.type },
|
||||
description: v.description,
|
||||
}));
|
||||
|
||||
obj.parameters = [...(obj.parameters || []), ...query];
|
||||
}
|
||||
|
||||
obj.tags = [...(obj.tags || []), getTag(p)].unique();
|
||||
|
||||
if (missingRoutes.additional.includes(path.replace(/\/$/, ""))) {
|
||||
obj["x-badges"] = [
|
||||
{
|
||||
label: "Valkyrie-only",
|
||||
color: "red",
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
specification.paths[path] = Object.assign(
|
||||
specification.paths[path] || {},
|
||||
{
|
||||
[method]: obj,
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
async function main() {
|
||||
console.log("Generating OpenAPI Specification...");
|
||||
|
||||
const routesRes = await fetch(
|
||||
"https://toastielab.dev/ValkyrieChat/missing-routes/raw/branch/main/missing.json",
|
||||
{
|
||||
headers: {
|
||||
Accept: "application/json",
|
||||
},
|
||||
},
|
||||
);
|
||||
const missingRoutes = await routesRes.json();
|
||||
|
||||
combineSchemas(schemas);
|
||||
apiRoutes(missingRoutes);
|
||||
|
||||
fs.writeFileSync(
|
||||
openapiPath,
|
||||
JSON.stringify(specification, null, 4)
|
||||
.replaceAll("#/definitions", "#/components/schemas")
|
||||
.replaceAll("bigint", "number"),
|
||||
);
|
||||
}
|
||||
|
||||
main();
|
28
scripts/rights.js
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
Calculates a discord.com-like rights value.
|
||||
*/
|
||||
|
||||
require("module-alias/register");
|
||||
const { Rights } = require("..");
|
||||
|
||||
const allRights = new Rights(1).bitfield;
|
||||
console.log(`All rights:`, allRights);
|
||||
|
||||
var discordLike = allRights;
|
||||
discordLike -= Rights.FLAGS.OPERATOR;
|
||||
discordLike -= Rights.FLAGS.MANAGE_APPLICATIONS;
|
||||
discordLike -= Rights.FLAGS.MANAGE_MESSAGES;
|
||||
discordLike -= Rights.FLAGS.MANAGE_RATE_LIMITS;
|
||||
discordLike -= Rights.FLAGS.MANAGE_ROUTING;
|
||||
discordLike -= Rights.FLAGS.MANAGE_TICKETS;
|
||||
discordLike -= Rights.FLAGS.MANAGE_USERS;
|
||||
discordLike -= Rights.FLAGS.MANAGE_GUILDS;
|
||||
discordLike -= Rights.FLAGS.ADD_MEMBERS;
|
||||
discordLike -= Rights.FLAGS.BYPASS_RATE_LIMITS;
|
||||
discordLike -= Rights.FLAGS.CREDITABLE;
|
||||
discordLike -= Rights.FLAGS.MANAGE_GUILD_DIRECTORY;
|
||||
discordLike -= Rights.FLAGS.SEND_BACKDATED_EVENTS;
|
||||
discordLike -= Rights.FLAGS.EDIT_FLAGS;
|
||||
discordLike -= Rights.FLAGS.SELF_EDIT_FLAGS;
|
||||
discordLike -= Rights.FLAGS.MANAGE_GROUPS;
|
||||
console.log(`Discord.com-like rights:`, discordLike);
|
96
scripts/schema.js
Normal file
|
@ -0,0 +1,96 @@
|
|||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
const TJS = require("typescript-json-schema");
|
||||
const walk = require("./util/walk");
|
||||
const schemaPath = path.join(__dirname, "..", "assets", "schemas.json");
|
||||
|
||||
const settings = {
|
||||
required: true,
|
||||
ignoreErrors: true,
|
||||
excludePrivate: true,
|
||||
defaultNumberType: "integer",
|
||||
noExtraProps: true,
|
||||
defaultProps: false,
|
||||
};
|
||||
|
||||
const Excluded = [
|
||||
"DefaultSchema",
|
||||
"Schema",
|
||||
"EntitySchema",
|
||||
"ServerResponse",
|
||||
"Http2ServerResponse",
|
||||
"ExpressResponse",
|
||||
"global.Express.Response",
|
||||
"global.Response",
|
||||
"Response",
|
||||
"e.Response",
|
||||
"request.Response",
|
||||
"supertest.Response",
|
||||
"DiagnosticsChannel.Response",
|
||||
"_Response",
|
||||
"ReadableStream<any>",
|
||||
|
||||
// TODO: Figure out how to exclude schemas from node_modules?
|
||||
"SomeJSONSchema",
|
||||
"UncheckedPartialSchema",
|
||||
"PartialSchema",
|
||||
"UncheckedPropertiesSchema",
|
||||
"PropertiesSchema",
|
||||
"AsyncSchema",
|
||||
"AnySchema",
|
||||
"SMTPConnection.CustomAuthenticationResponse",
|
||||
"TransportMakeRequestResponse",
|
||||
];
|
||||
|
||||
function main() {
|
||||
const program = TJS.programFromConfig(
|
||||
path.join(__dirname, "..", "tsconfig.json"),
|
||||
walk(path.join(__dirname, "..", "src", "util", "schemas")),
|
||||
);
|
||||
const generator = TJS.buildGenerator(program, settings);
|
||||
if (!generator || !program) return;
|
||||
|
||||
let schemas = generator.getUserSymbols().filter((x) => {
|
||||
return (
|
||||
(x.endsWith("Schema") ||
|
||||
x.endsWith("Response") ||
|
||||
x.startsWith("API")) &&
|
||||
!Excluded.includes(x)
|
||||
);
|
||||
});
|
||||
|
||||
var definitions = {};
|
||||
|
||||
for (const name of schemas) {
|
||||
const part = TJS.generateSchema(program, name, settings, [], generator);
|
||||
if (!part) continue;
|
||||
|
||||
// this is a hack. want some want to check if its a @column, instead
|
||||
if (part.properties) {
|
||||
for (let key in part.properties) {
|
||||
if (
|
||||
[
|
||||
// BaseClass methods
|
||||
"toJSON",
|
||||
"hasId",
|
||||
"save",
|
||||
"remove",
|
||||
"softRemove",
|
||||
"recover",
|
||||
"reload",
|
||||
"assign",
|
||||
].includes(key)
|
||||
) {
|
||||
delete part.properties[key];
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
definitions = { ...definitions, [name]: { ...part } };
|
||||
}
|
||||
|
||||
fs.writeFileSync(schemaPath, JSON.stringify(definitions, null, 4));
|
||||
}
|
||||
|
||||
main();
|
22
scripts/stagingMigration/index.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
const { DataSourceOptions, DatabaseType, initDatabase } = require("../..");
|
||||
const path = require("path");
|
||||
|
||||
(async () => {
|
||||
DataSourceOptions.setOptions({
|
||||
logging: true,
|
||||
migrations: [
|
||||
path.join(
|
||||
process.cwd(),
|
||||
"scripts",
|
||||
"stagingMigration",
|
||||
DatabaseType,
|
||||
"*.js",
|
||||
),
|
||||
],
|
||||
});
|
||||
|
||||
const dbConnection = await DataSourceOptions.initialize();
|
||||
await dbConnection.runMigrations();
|
||||
await dbConnection.destroy();
|
||||
console.log("migration done");
|
||||
})();
|
1103
scripts/stagingMigration/maria/1672833135670-staging.js
Normal file
1103
scripts/stagingMigration/mysql/1672833135670-staging.js
Normal file
153
scripts/stagingMigration/postgres/1672815835837-staging.js
Normal file
|
@ -0,0 +1,153 @@
|
|||
const { MigrationInterface, QueryRunner } = require("typeorm");
|
||||
|
||||
module.exports = class staging1672815835837 {
|
||||
name = "staging1672815835837";
|
||||
|
||||
async up(queryRunner) {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "users" DROP CONSTRAINT IF EXISTS "FK_76ba283779c8441fd5ff819c8cf"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "user_settings" RENAME COLUMN "id" TO "index"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "user_settings" RENAME CONSTRAINT "PK_00f004f5922a0744d174530d639" TO "PK_e81f8bb92802737337d35c00981"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE "embed_cache" ("id" character varying NOT NULL, "url" character varying NOT NULL, "embed" text NOT NULL, CONSTRAINT "PK_0abb7581d4efc5a8b1361389c5e" PRIMARY KEY ("id"))`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE "security_settings" ("id" character varying NOT NULL, "guild_id" character varying, "channel_id" character varying, "encryption_permission_mask" integer NOT NULL, "allowed_algorithms" text NOT NULL, "current_algorithm" character varying NOT NULL, "used_since_message" character varying, CONSTRAINT "PK_4aec436cf81177ae97a1bcec3c7" PRIMARY KEY ("id"))`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "client_release" DROP COLUMN IF EXISTS "deb_url"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "client_release" DROP COLUMN IF EXISTS "osx_url"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "client_release" DROP COLUMN IF EXISTS "win_url"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "users" DROP CONSTRAINT IF EXISTS "REL_76ba283779c8441fd5ff819c8c"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "users" DROP COLUMN IF EXISTS "settingsId"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "client_release" ADD "platform" character varying NOT NULL`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "client_release" ADD "enabled" boolean NOT NULL`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "users" ADD "purchased_flags" integer NOT NULL DEFAULT 0`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "users" ADD "premium_usage_flags" integer NOT NULl DEFAULT 0`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "users" ADD "settingsIndex" integer`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "users" ADD CONSTRAINT "UQ_0c14beb78d8c5ccba66072adbc7" UNIQUE ("settingsIndex")`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "client_release" DROP COLUMN IF EXISTS "pub_date"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "client_release" ADD "pub_date" TIMESTAMP NOT NULL`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`UPDATE channels SET nsfw = false WHERE nsfw IS NULL`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "channels" ALTER COLUMN "nsfw" SET NOT NULL`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`UPDATE channels SET flags = 0 WHERE flags IS NULL`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "channels" ALTER COLUMN "flags" SET NOT NULL`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`UPDATE channels SET default_thread_rate_limit_per_user = 0 WHERE default_thread_rate_limit_per_user IS NULL`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "channels" ALTER COLUMN "default_thread_rate_limit_per_user" SET NOT NULL`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "user_settings" DROP CONSTRAINT IF EXISTS "PK_e81f8bb92802737337d35c00981"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "user_settings" DROP COLUMN IF EXISTS "index"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "user_settings" ADD "index" SERIAL NOT NULL`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "user_settings" ADD CONSTRAINT "PK_e81f8bb92802737337d35c00981" PRIMARY KEY ("index")`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "guilds" DROP COLUMN IF EXISTS "primary_category_id"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "guilds" ADD "primary_category_id" character varying`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`UPDATE guilds SET large = false WHERE large IS NULL`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "guilds" ALTER COLUMN "large" SET NOT NULL`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`UPDATE guilds SET premium_tier = 0 WHERE premium_tier IS NULL`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "guilds" ALTER COLUMN "premium_tier" SET NOT NULL`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`UPDATE guilds SET unavailable = false WHERE unavailable IS NULL`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "guilds" ALTER COLUMN "unavailable" SET NOT NULL`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`UPDATE guilds SET widget_enabled = false WHERE widget_enabled IS NULL`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "guilds" ALTER COLUMN "widget_enabled" SET NOT NULL`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`UPDATE guilds SET nsfw = false WHERE nsfw IS NULL`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "guilds" ALTER COLUMN "nsfw" SET NOT NULL`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "members" DROP COLUMN IF EXISTS "premium_since"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "members" ADD "premium_since" bigint`,
|
||||
);
|
||||
await queryRunner.query(`ALTER TABLE members ADD theme_colors text`);
|
||||
await queryRunner.query(`ALTER TABLE members ADD pronouns varchar`);
|
||||
await queryRunner.query(`UPDATE users SET bio = '' WHERE bio IS NULL`);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE users ALTER COLUMN bio SET NOT NULL`,
|
||||
);
|
||||
await queryRunner.query(`ALTER TABLE users ADD theme_colors text`);
|
||||
await queryRunner.query(`ALTER TABLE users ADD pronouns varchar`);
|
||||
await queryRunner.query(
|
||||
`UPDATE users SET mfa_enabled = false WHERE mfa_enabled IS NULL`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE users ALTER COLUMN mfa_enabled SET NOT NULL`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "users" ADD CONSTRAINT "FK_0c14beb78d8c5ccba66072adbc7" FOREIGN KEY ("settingsIndex") REFERENCES "user_settings"("index") ON DELETE NO ACTION ON UPDATE NO ACTION`,
|
||||
);
|
||||
}
|
||||
|
||||
async down(queryRunner) {}
|
||||
};
|
52
scripts/stress/identify.js
Normal file
|
@ -0,0 +1,52 @@
|
|||
/* eslint-env node */
|
||||
|
||||
require("dotenv").config();
|
||||
const { OPCODES } = require("../../dist/gateway/util/Constants.js");
|
||||
const WebSocket = require("ws");
|
||||
const ENDPOINT = `ws://localhost:3001?v=9&encoding=json`;
|
||||
const TOKEN = process.env.TOKEN;
|
||||
const TOTAL_ITERATIONS = process.env.ITER ? parseInt(process.env.ITER) : 500;
|
||||
|
||||
const doTimedIdentify = () =>
|
||||
new Promise((resolve) => {
|
||||
let start;
|
||||
const ws = new WebSocket(ENDPOINT);
|
||||
ws.on("message", (data) => {
|
||||
const parsed = JSON.parse(data);
|
||||
|
||||
switch (parsed.op) {
|
||||
case OPCODES.Hello:
|
||||
// send identify
|
||||
start = performance.now();
|
||||
ws.send(
|
||||
JSON.stringify({
|
||||
op: OPCODES.Identify,
|
||||
d: {
|
||||
token: TOKEN,
|
||||
properties: {},
|
||||
},
|
||||
}),
|
||||
);
|
||||
break;
|
||||
case OPCODES.Dispatch:
|
||||
if (parsed.t == "READY") {
|
||||
ws.close();
|
||||
return resolve(performance.now() - start);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
(async () => {
|
||||
const perfs = [];
|
||||
while (perfs.length < TOTAL_ITERATIONS) {
|
||||
const ret = await doTimedIdentify();
|
||||
perfs.push(ret);
|
||||
// console.log(`${perfs.length}/${TOTAL_ITERATIONS} - this: ${Math.floor(ret)}ms`)
|
||||
}
|
||||
|
||||
const avg = perfs.reduce((prev, curr) => prev + curr) / (perfs.length - 1);
|
||||
console.log(`Average identify time: ${Math.floor(avg * 100) / 100}ms`);
|
||||
})();
|
17
scripts/stress/login.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
const fetch = require("node-fetch");
|
||||
const ENDPOINT = process.env.API || "http://localhost:3001";
|
||||
|
||||
async function main() {
|
||||
const ret = await fetch(`${ENDPOINT}/api/auth/login`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
login: process.argv[2],
|
||||
password: process.argv[3],
|
||||
}),
|
||||
headers: { "content-type": "application/json " },
|
||||
});
|
||||
|
||||
console.log((await ret.json()).token);
|
||||
}
|
||||
|
||||
main();
|
25
scripts/stress/users.js
Normal file
|
@ -0,0 +1,25 @@
|
|||
require("dotenv").config();
|
||||
const fetch = require("node-fetch");
|
||||
const count = Number(process.env.COUNT) || 50;
|
||||
const endpoint = process.env.API || "http://localhost:3001";
|
||||
|
||||
async function main() {
|
||||
for (let i = 0; i < count; i++) {
|
||||
fetch(`${endpoint}/api/auth/register`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
fingerprint: `${i}.wR8vi8lGlFBJerErO9LG5NViJFw`,
|
||||
username: `test${i}`,
|
||||
invite: null,
|
||||
consent: true,
|
||||
date_of_birth: "2000-01-01",
|
||||
gift_code_sku_id: null,
|
||||
captcha_key: null,
|
||||
}),
|
||||
headers: { "content-type": "application/json" },
|
||||
});
|
||||
console.log(i);
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
20
scripts/syncronise.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
"Why?" I hear you say! "Why don't you just use `typeorm schema:sync`?"!
|
||||
Because we have a lot ( like, 30? ) cyclic imports in the entities folder,
|
||||
which breaks that command entirely!
|
||||
|
||||
however!
|
||||
it doesn't break the below, thus we're left with this :sob:
|
||||
*/
|
||||
|
||||
require("module-alias/register");
|
||||
require("dotenv").config();
|
||||
const { initDatabase } = require("..");
|
||||
|
||||
(async () => {
|
||||
const db = await initDatabase();
|
||||
console.log("synchronising");
|
||||
await db.synchronize();
|
||||
console.log("done");
|
||||
db.destroy();
|
||||
})();
|
33
scripts/test.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
Super simple script to check if the server starts at all, for use in gh actions.
|
||||
Not a proper test framework by any means.
|
||||
*/
|
||||
|
||||
const { spawn } = require("child_process");
|
||||
const path = require("path");
|
||||
|
||||
const server = spawn("node", [
|
||||
path.join(__dirname, "..", "dist", "bundle", "start.js"),
|
||||
]);
|
||||
|
||||
server.stdout.on("data", (data) => {
|
||||
process.stdout.write(data);
|
||||
|
||||
if (data.toString().toLowerCase().includes("listening")) {
|
||||
// we good :)
|
||||
console.log("we good");
|
||||
server.kill();
|
||||
process.exit();
|
||||
}
|
||||
});
|
||||
|
||||
server.stderr.on("data", (err) => {
|
||||
process.stdout.write(err);
|
||||
// we bad :(
|
||||
process.kill(1);
|
||||
});
|
||||
|
||||
server.on("close", (code) => {
|
||||
console.log("closed with code", code);
|
||||
process.exit(code);
|
||||
});
|
64
scripts/util/getRouteDescriptions.js
Normal file
|
@ -0,0 +1,64 @@
|
|||
const express = require("express");
|
||||
const path = require("path");
|
||||
const { traverseDirectory } = require("lambert-server");
|
||||
const RouteUtility = require("../../dist/api/util/handlers/route.js");
|
||||
|
||||
const methods = ["get", "post", "put", "delete", "patch"];
|
||||
const routes = new Map();
|
||||
let currentFile = "";
|
||||
let currentPath = "";
|
||||
|
||||
/*
|
||||
For some reason, if a route exports multiple functions, it won't be registered here!
|
||||
If someone could fix that I'd really appreciate it, but for now just, don't do that :p
|
||||
*/
|
||||
|
||||
const proxy = (file, method, prefix, path, ...args) => {
|
||||
const opts = args.find((x) => x?.prototype?.OPTS_MARKER == true);
|
||||
if (!opts)
|
||||
return console.error(
|
||||
`${file} has route without route() description middleware`,
|
||||
);
|
||||
|
||||
console.log(prefix + path + " - " + method);
|
||||
opts.file = file.replace("/dist/", "/src/").replace(".js", ".ts");
|
||||
routes.set(prefix + path + "|" + method, opts());
|
||||
};
|
||||
|
||||
express.Router = () => {
|
||||
return Object.fromEntries(
|
||||
methods.map((method) => [
|
||||
method,
|
||||
proxy.bind(null, currentFile, method, currentPath),
|
||||
]),
|
||||
);
|
||||
};
|
||||
|
||||
RouteUtility.route = (opts) => {
|
||||
const func = function () {
|
||||
return opts;
|
||||
};
|
||||
func.prototype.OPTS_MARKER = true;
|
||||
return func;
|
||||
};
|
||||
|
||||
module.exports = function getRouteDescriptions() {
|
||||
const root = path.join(__dirname, "..", "..", "dist", "api", "routes", "/");
|
||||
traverseDirectory({ dirname: root, recursive: true }, (file) => {
|
||||
currentFile = file;
|
||||
|
||||
currentPath = file.replace(root.slice(0, -1), "");
|
||||
currentPath = currentPath.split(".").slice(0, -1).join("."); // trancate .js/.ts file extension of path
|
||||
currentPath = currentPath.replaceAll("#", ":").replaceAll("\\", "/"); // replace # with : for path parameters and windows paths with slashes
|
||||
if (currentPath.endsWith("/index"))
|
||||
currentPath = currentPath.slice(0, "/index".length * -1); // delete index from path
|
||||
|
||||
try {
|
||||
require(file);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
});
|
||||
|
||||
return routes;
|
||||
};
|
14
scripts/util/licensePreamble.txt
Normal file
|
@ -0,0 +1,14 @@
|
|||
ValkyrieChat: A re-implementation and extension of the Discord.com backend.
|
||||
Copyright (C) 2024 ValkyrieChat
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
19
scripts/util/walk.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
const fs = require("fs");
|
||||
|
||||
/** dir: string. types: string[] ( file types ) */
|
||||
module.exports = function walk(dir, types = ["ts"]) {
|
||||
var results = [];
|
||||
var list = fs.readdirSync(dir);
|
||||
list.forEach(function (file) {
|
||||
file = dir + "/" + file;
|
||||
var stat = fs.statSync(file);
|
||||
if (stat && stat.isDirectory()) {
|
||||
/* Recurse into a subdirectory */
|
||||
results = results.concat(walk(file, types));
|
||||
} else {
|
||||
if (!types.find((x) => file.endsWith(x))) return;
|
||||
results.push(file);
|
||||
}
|
||||
});
|
||||
return results;
|
||||
};
|
23
server.code-workspace
Normal file
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": "src"
|
||||
},
|
||||
{
|
||||
"path": "assets"
|
||||
},
|
||||
{
|
||||
"path": "scripts"
|
||||
},
|
||||
{
|
||||
"path": "."
|
||||
}
|
||||
],
|
||||
"settings": {
|
||||
"typescript.tsdk": "util\\node_modules\\typescript\\lib"
|
||||
},
|
||||
"launch": {
|
||||
"version": "0.2.0",
|
||||
"configurations": []
|
||||
}
|
||||
}
|
57
tsconfig.json
Normal file
|
@ -0,0 +1,57 @@
|
|||
{
|
||||
"exclude": ["./src/webrtc"],
|
||||
"include": ["./src"],
|
||||
"compilerOptions": {
|
||||
/* Projects */
|
||||
"incremental": true /* Save .tsbuildinfo files to allow for incremental compilation of projects. */,
|
||||
|
||||
/* Language and Environment */
|
||||
"target": "ESNext" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
|
||||
"lib": [
|
||||
"ESNext"
|
||||
] /* Specify a set of bundled library declaration files that describe the target runtime environment. */,
|
||||
"experimentalDecorators": true /* Enable experimental support for TC39 stage 2 draft decorators. */,
|
||||
"emitDecoratorMetadata": true /* Emit design-type metadata for decorated declarations in source files. */,
|
||||
|
||||
/* Modules */
|
||||
"module": "commonjs" /* Specify what module code is generated. */,
|
||||
"moduleResolution": "node" /* Specify how TypeScript looks up a file from a given module specifier. */,
|
||||
"baseUrl": "./src/",
|
||||
"paths": {
|
||||
"@valkyrie/api*": ["./api"],
|
||||
"@valkyrie/gateway*": ["./gateway"],
|
||||
"@valkyrie/cdn*": ["./cdn"],
|
||||
"@valkyrie/util*": ["./util"]
|
||||
} /* Specify a set of entries that re-map imports to additional lookup locations. */,
|
||||
"types": [
|
||||
"node"
|
||||
] /* Specify type package names to be included without being referenced in a source file. */,
|
||||
"resolveJsonModule": true /* Enable importing .json files. */,
|
||||
|
||||
/* JavaScript Support */
|
||||
"allowJs": true /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */,
|
||||
"checkJs": true /* Enable error reporting in type-checked JavaScript files. */,
|
||||
|
||||
/* Emit */
|
||||
"declaration": false /* Generate .d.ts files from TypeScript and JavaScript files in your project. */,
|
||||
"declarationMap": false /* Create sourcemaps for d.ts files. */,
|
||||
"sourceMap": true /* Create source map files for emitted JavaScript files. */,
|
||||
"outDir": "./dist/" /* Specify an output folder for all emitted files. */,
|
||||
"importHelpers": true /* Allow importing helper functions from tslib once per project, instead of including them per-file. */,
|
||||
"noEmitHelpers": true /* Disable generating custom helper functions like '__extends' in compiled output. */,
|
||||
|
||||
/* Interop Constraints */
|
||||
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
|
||||
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
|
||||
|
||||
/* Type Checking */
|
||||
"strict": true /* Enable all strict type-checking options. */,
|
||||
"noImplicitAny": true /* Enable error reporting for expressions and declarations with an implied 'any' type. */,
|
||||
"strictNullChecks": true /* When type checking, take into account 'null' and 'undefined'. */,
|
||||
"strictPropertyInitialization": false /* Check for class properties that are declared but not set in the constructor. */,
|
||||
"alwaysStrict": true /* Ensure 'use strict' is always emitted. */,
|
||||
|
||||
/* Completeness */
|
||||
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
||||
}
|
||||
}
|