Initial commit
commit
9e57c0f872
|
@ -0,0 +1,37 @@
|
|||
# ================================
|
||||
# Run image
|
||||
# ================================
|
||||
FROM ubuntu:focal
|
||||
|
||||
# Make sure all system packages are up to date, and install only essential packages.
|
||||
RUN export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true \
|
||||
&& apt-get -q update \
|
||||
&& apt-get -q dist-upgrade -y \
|
||||
&& apt-get -q install -y \
|
||||
ca-certificates \
|
||||
tzdata \
|
||||
sqlite3 \
|
||||
# If your app or its dependencies import FoundationNetworking, also install `libcurl4`.
|
||||
# libcurl4 \
|
||||
# If your app or its dependencies import FoundationXML, also install `libxml2`.
|
||||
# libxml2 \
|
||||
&& rm -r /var/lib/apt/lists/*
|
||||
|
||||
# Create a vapor user and group with /app as its home directory
|
||||
RUN useradd --user-group --create-home --system --skel /dev/null --home-dir /app vapor
|
||||
|
||||
# Switch to the new home directory
|
||||
WORKDIR /app
|
||||
|
||||
# Copy built executable and any staged resources from builder
|
||||
COPY --chown=vapor:vapor ./Run /app
|
||||
|
||||
# Ensure all further commands run as the vapor user
|
||||
# USER vapor:vapor
|
||||
|
||||
# Let Docker bind to port 8080
|
||||
EXPOSE 8081
|
||||
|
||||
# Start the Vapor service when the image is run, default to listening on 8080 in production environment
|
||||
ENTRYPOINT ["./Run"]
|
||||
CMD ["serve", "--env", "production", "--hostname", "0.0.0.0", "--port", "8081"]
|
Binary file not shown.
|
@ -0,0 +1,38 @@
|
|||
# ================================
|
||||
# Run image
|
||||
# ================================
|
||||
FROM ubuntu:focal
|
||||
|
||||
# Make sure all system packages are up to date, and install only essential packages.
|
||||
RUN export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true \
|
||||
&& apt-get -q update \
|
||||
&& apt-get -q dist-upgrade -y \
|
||||
&& apt-get -q install -y \
|
||||
ca-certificates \
|
||||
tzdata \
|
||||
sqlite3 \
|
||||
# If your app or its dependencies import FoundationNetworking, also install `libcurl4`.
|
||||
# libcurl4 \
|
||||
# If your app or its dependencies import FoundationXML, also install `libxml2`.
|
||||
# libxml2 \
|
||||
&& rm -r /var/lib/apt/lists/*
|
||||
|
||||
# Create a vapor user and group with /app as its home directory
|
||||
RUN useradd --user-group --create-home --system --skel /dev/null --home-dir /app vapor
|
||||
|
||||
# Switch to the new home directory
|
||||
WORKDIR /app
|
||||
|
||||
# Copy built executable and any staged resources from builder
|
||||
COPY --chown=vapor:vapor ./Run /app
|
||||
COPY --chown=vapor:vapor ./Public /app/Public
|
||||
|
||||
# Ensure all further commands run as the vapor user
|
||||
# USER vapor:vapor
|
||||
|
||||
# Let Docker bind to port 8080
|
||||
EXPOSE 8080
|
||||
|
||||
# Start the Vapor service when the image is run, default to listening on 8080 in production environment
|
||||
ENTRYPOINT ["./Run"]
|
||||
CMD ["serve", "--env", "production", "--hostname", "0.0.0.0", "--port", "8080"]
|
|
@ -0,0 +1,312 @@
|
|||
@angular/animations
|
||||
MIT
|
||||
|
||||
@angular/cdk
|
||||
MIT
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2022 Google LLC.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
|
||||
@angular/common
|
||||
MIT
|
||||
|
||||
@angular/core
|
||||
MIT
|
||||
|
||||
@angular/forms
|
||||
MIT
|
||||
|
||||
@angular/material
|
||||
MIT
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2022 Google LLC.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
|
||||
@angular/platform-browser
|
||||
MIT
|
||||
|
||||
@angular/router
|
||||
MIT
|
||||
|
||||
rxjs
|
||||
Apache-2.0
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"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.
|
||||
|
||||
"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.
|
||||
|
||||
"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.
|
||||
|
||||
"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.
|
||||
|
||||
"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.
|
||||
|
||||
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.
|
||||
|
||||
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
|
||||
|
||||
(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
|
||||
|
||||
(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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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
|
||||
|
||||
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.
|
||||
|
||||
Copyright (c) 2015-2018 Google, Inc., Netflix, Inc., Microsoft Corp. and contributors
|
||||
|
||||
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.
|
||||
|
||||
|
||||
|
||||
tslib
|
||||
0BSD
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
zone.js
|
||||
MIT
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2010-2022 Google LLC. https://angular.io/license
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
Binary file not shown.
After Width: | Height: | Size: 948 B |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -0,0 +1 @@
|
|||
(()=>{"use strict";var e,_={},d={};function n(e){var a=d[e];if(void 0!==a)return a.exports;var r=d[e]={exports:{}};return _[e](r,r.exports,n),r.exports}n.m=_,e=[],n.O=(a,r,u,t)=>{if(!r){var c=1/0;for(f=0;f<e.length;f++){for(var[r,u,t]=e[f],s=!0,l=0;l<r.length;l++)(!1&t||c>=t)&&Object.keys(n.O).every(i=>n.O[i](r[l]))?r.splice(l--,1):(s=!1,t<c&&(c=t));if(s){e.splice(f--,1);var o=u();void 0!==o&&(a=o)}}return a}t=t||0;for(var f=e.length;f>0&&e[f-1][2]>t;f--)e[f]=e[f-1];e[f]=[r,u,t]},n.n=e=>{var a=e&&e.__esModule?()=>e.default:()=>e;return n.d(a,{a}),a},n.d=(e,a)=>{for(var r in a)n.o(a,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:a[r]})},n.o=(e,a)=>Object.prototype.hasOwnProperty.call(e,a),(()=>{var e={666:0};n.O.j=u=>0===e[u];var a=(u,t)=>{var l,o,[f,c,s]=t,v=0;if(f.some(h=>0!==e[h])){for(l in c)n.o(c,l)&&(n.m[l]=c[l]);if(s)var b=s(n)}for(u&&u(t);v<f.length;v++)n.o(e,o=f[v])&&e[o]&&e[o][0](),e[o]=0;return n.O(b)},r=self.webpackChunkfrontend=self.webpackChunkfrontend||[];r.forEach(a.bind(null,0)),r.push=a.bind(null,r.push.bind(r))})()})();
|
File diff suppressed because one or more lines are too long
Binary file not shown.
|
@ -0,0 +1,8 @@
|
|||
Note: only the source code of 0day.tomorrow is provided (not for 0day.permissions). To build the executable download the source code to your computer, then run:
|
||||
|
||||
docker build -t 0day .
|
||||
docker create --name dummy 0day
|
||||
docker cp dummy:/staging ./build
|
||||
docker rm -f dummy
|
||||
|
||||
you'll find the artifacts in the build folder. To patch just copy `Run` file into your vulnbox and then rebuild the container.
|
|
@ -0,0 +1,41 @@
|
|||
version: '3.7'
|
||||
|
||||
x-shared_environment: &shared_environment
|
||||
LOG_LEVEL: ${LOG_LEVEL:-info}
|
||||
|
||||
services:
|
||||
service:
|
||||
image: 0day-tomorrow:latest
|
||||
build:
|
||||
context: ./0day.tomorrow
|
||||
environment:
|
||||
<<: *shared_environment
|
||||
volumes:
|
||||
- /secrets/0day:/certificates
|
||||
ports:
|
||||
- '8080:8080'
|
||||
# user: '0' # uncomment to run as root for testing purposes even though Dockerfile defines 'vapor' user.
|
||||
command: ["serve", "--env", "production", "--hostname", "0.0.0.0", "--port", "8080"]
|
||||
restart: unless-stopped
|
||||
permissions:
|
||||
image: 0day-permissions:latest
|
||||
build:
|
||||
context: ./0day.permissions
|
||||
environment:
|
||||
<<: *shared_environment
|
||||
ports:
|
||||
- '8081:8081'
|
||||
# user: '0' # uncomment to run as root for testing purposes even though Dockerfile defines 'vapor' user.
|
||||
command: ["serve", "--env", "production", "--hostname", "0.0.0.0", "--port", "8081"]
|
||||
restart: unless-stopped
|
||||
db:
|
||||
image: postgres
|
||||
restart: always
|
||||
environment:
|
||||
- POSTGRES_USER=vapor
|
||||
- POSTGRES_PASSWORD=vapor
|
||||
volumes:
|
||||
- db:/var/lib/postgresql/data
|
||||
|
||||
volumes:
|
||||
db:
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,115 @@
|
|||
Metadata-Version: 2.1
|
||||
Name: cryptography
|
||||
Version: 3.4.8
|
||||
Summary: cryptography is a package which provides cryptographic recipes and primitives to Python developers.
|
||||
Home-page: https://github.com/pyca/cryptography
|
||||
Author: The Python Cryptographic Authority and individual contributors
|
||||
Author-email: cryptography-dev@python.org
|
||||
License: BSD or Apache License, Version 2.0
|
||||
Platform: UNKNOWN
|
||||
Classifier: Development Status :: 5 - Production/Stable
|
||||
Classifier: Intended Audience :: Developers
|
||||
Classifier: License :: OSI Approved :: Apache Software License
|
||||
Classifier: License :: OSI Approved :: BSD License
|
||||
Classifier: Natural Language :: English
|
||||
Classifier: Operating System :: MacOS :: MacOS X
|
||||
Classifier: Operating System :: POSIX
|
||||
Classifier: Operating System :: POSIX :: BSD
|
||||
Classifier: Operating System :: POSIX :: Linux
|
||||
Classifier: Operating System :: Microsoft :: Windows
|
||||
Classifier: Programming Language :: Python
|
||||
Classifier: Programming Language :: Python :: 3
|
||||
Classifier: Programming Language :: Python :: 3 :: Only
|
||||
Classifier: Programming Language :: Python :: 3.6
|
||||
Classifier: Programming Language :: Python :: 3.7
|
||||
Classifier: Programming Language :: Python :: 3.8
|
||||
Classifier: Programming Language :: Python :: 3.9
|
||||
Classifier: Programming Language :: Python :: Implementation :: CPython
|
||||
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
||||
Classifier: Topic :: Security :: Cryptography
|
||||
Requires-Python: >=3.6
|
||||
Description-Content-Type: text/x-rst
|
||||
Provides-Extra: docs
|
||||
Provides-Extra: docstest
|
||||
Provides-Extra: pep8test
|
||||
Provides-Extra: sdist
|
||||
Provides-Extra: ssh
|
||||
Provides-Extra: test
|
||||
License-File: LICENSE
|
||||
License-File: LICENSE.APACHE
|
||||
License-File: LICENSE.BSD
|
||||
License-File: LICENSE.PSF
|
||||
|
||||
pyca/cryptography
|
||||
=================
|
||||
|
||||
.. image:: https://img.shields.io/pypi/v/cryptography.svg
|
||||
:target: https://pypi.org/project/cryptography/
|
||||
:alt: Latest Version
|
||||
|
||||
.. image:: https://readthedocs.org/projects/cryptography/badge/?version=latest
|
||||
:target: https://cryptography.io
|
||||
:alt: Latest Docs
|
||||
|
||||
.. image:: https://github.com/pyca/cryptography/workflows/CI/badge.svg?branch=master
|
||||
:target: https://github.com/pyca/cryptography/actions?query=workflow%3ACI+branch%3Amaster
|
||||
|
||||
.. image:: https://codecov.io/github/pyca/cryptography/coverage.svg?branch=master
|
||||
:target: https://codecov.io/github/pyca/cryptography?branch=master
|
||||
|
||||
|
||||
``cryptography`` is a package which provides cryptographic recipes and
|
||||
primitives to Python developers. Our goal is for it to be your "cryptographic
|
||||
standard library". It supports Python 3.6+ and PyPy3 7.2+.
|
||||
|
||||
``cryptography`` includes both high level recipes and low level interfaces to
|
||||
common cryptographic algorithms such as symmetric ciphers, message digests, and
|
||||
key derivation functions. For example, to encrypt something with
|
||||
``cryptography``'s high level symmetric encryption recipe:
|
||||
|
||||
.. code-block:: pycon
|
||||
|
||||
>>> from cryptography.fernet import Fernet
|
||||
>>> # Put this somewhere safe!
|
||||
>>> key = Fernet.generate_key()
|
||||
>>> f = Fernet(key)
|
||||
>>> token = f.encrypt(b"A really secret message. Not for prying eyes.")
|
||||
>>> token
|
||||
'...'
|
||||
>>> f.decrypt(token)
|
||||
'A really secret message. Not for prying eyes.'
|
||||
|
||||
You can find more information in the `documentation`_.
|
||||
|
||||
You can install ``cryptography`` with:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ pip install cryptography
|
||||
|
||||
For full details see `the installation documentation`_.
|
||||
|
||||
Discussion
|
||||
~~~~~~~~~~
|
||||
|
||||
If you run into bugs, you can file them in our `issue tracker`_.
|
||||
|
||||
We maintain a `cryptography-dev`_ mailing list for development discussion.
|
||||
|
||||
You can also join ``#cryptography-dev`` on Freenode to ask questions or get
|
||||
involved.
|
||||
|
||||
Security
|
||||
~~~~~~~~
|
||||
|
||||
Need to report a security issue? Please consult our `security reporting`_
|
||||
documentation.
|
||||
|
||||
|
||||
.. _`documentation`: https://cryptography.io/
|
||||
.. _`the installation documentation`: https://cryptography.io/en/latest/installation.html
|
||||
.. _`issue tracker`: https://github.com/pyca/cryptography/issues
|
||||
.. _`cryptography-dev`: https://mail.python.org/mailman/listinfo/cryptography-dev
|
||||
.. _`security reporting`: https://cryptography.io/en/latest/security.html
|
||||
|
||||
|
|
@ -0,0 +1 @@
|
|||
|
|
@ -0,0 +1 @@
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
|
||||
[docs]
|
||||
sphinx!=1.8.0,!=3.1.0,!=3.1.1,>=1.6.5
|
||||
sphinx_rtd_theme
|
||||
|
||||
[docstest]
|
||||
doc8
|
||||
pyenchant>=1.6.11
|
||||
sphinxcontrib-spelling>=4.0.1
|
||||
twine>=1.12.0
|
||||
|
||||
[pep8test]
|
||||
black
|
||||
flake8
|
||||
flake8-import-order
|
||||
pep8-naming
|
||||
|
||||
[sdist]
|
||||
|
||||
[ssh]
|
||||
bcrypt>=3.1.5
|
||||
|
||||
[test]
|
||||
hypothesis!=3.79.2,>=1.11.4
|
||||
iso8601
|
||||
pretend
|
||||
pytest-cov
|
||||
pytest-subtests
|
||||
pytest-xdist
|
||||
pytest>=6.0
|
||||
pytz
|
|
@ -0,0 +1,3 @@
|
|||
_openssl
|
||||
_padding
|
||||
cryptography
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,41 @@
|
|||
# ================================
|
||||
# Build image
|
||||
# ================================
|
||||
FROM swift:5.6-focal as build
|
||||
|
||||
# Install OS updates and, if needed, sqlite3
|
||||
RUN export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true \
|
||||
&& apt-get -q update \
|
||||
&& apt-get -q dist-upgrade -y \
|
||||
&& apt-get install -y libsqlite3-dev \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Set up a build area
|
||||
WORKDIR /build
|
||||
|
||||
# First just resolve dependencies.
|
||||
# This creates a cached layer that can be reused
|
||||
# as long as your Package.swift/Package.resolved
|
||||
# files do not change.
|
||||
COPY ./Package.* ./
|
||||
RUN swift package resolve
|
||||
|
||||
# Copy entire repo into container
|
||||
COPY . .
|
||||
|
||||
# Build everything, with optimizations
|
||||
RUN swift build -c release --static-swift-stdlib
|
||||
|
||||
# Switch to the staging area
|
||||
WORKDIR /staging
|
||||
|
||||
# Copy main executable to staging area
|
||||
RUN cp "$(swift build --package-path /build -c release --show-bin-path)/Run" ./
|
||||
|
||||
# Copy resources bundled by SPM to staging area
|
||||
RUN find -L "$(swift build --package-path /build -c release --show-bin-path)/" -regex '.*\.resources$' -exec cp -Ra {} ./ \;
|
||||
|
||||
# Copy any resources from the public directory and views directory if the directories exist
|
||||
# Ensure that by default, neither the directory nor any of its contents are writable.
|
||||
RUN [ -d /build/Public ] && { mv /build/Public ./Public && chmod -R a-w ./Public; } || true
|
||||
RUN [ -d /build/Resources ] && { mv /build/Resources ./Resources && chmod -R a-w ./Resources; } || true
|
|
@ -0,0 +1,248 @@
|
|||
{
|
||||
"pins" : [
|
||||
{
|
||||
"identity" : "async-http-client",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/swift-server/async-http-client.git",
|
||||
"state" : {
|
||||
"revision" : "fc510a39cff61b849bf5cdff17eb2bd6d0777b49",
|
||||
"version" : "1.11.5"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "async-kit",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/vapor/async-kit.git",
|
||||
"state" : {
|
||||
"revision" : "c3329e444bafbb12d1d312af9191be95348a8175",
|
||||
"version" : "1.13.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "console-kit",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/vapor/console-kit.git",
|
||||
"state" : {
|
||||
"revision" : "a7e67a1719933318b5ab7eaaed355cde020465b1",
|
||||
"version" : "4.5.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "fluent",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/vapor/fluent.git",
|
||||
"state" : {
|
||||
"revision" : "26c446002f03c5ab34b20d86873014ef3d92d0da",
|
||||
"version" : "4.5.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "fluent-kit",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/vapor/fluent-kit.git",
|
||||
"state" : {
|
||||
"revision" : "38670d2eefcba27530272946d627ac8d4e45f017",
|
||||
"version" : "1.35.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "fluent-postgres-driver",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/vapor/fluent-postgres-driver.git",
|
||||
"state" : {
|
||||
"revision" : "a8b2839ea86c44a35c17f66eb0885f9e5b51a531",
|
||||
"version" : "2.4.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "multipart-kit",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/vapor/multipart-kit.git",
|
||||
"state" : {
|
||||
"revision" : "0d55c35e788451ee27222783c7d363cb88092fab",
|
||||
"version" : "4.5.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "postgres-kit",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/vapor/postgres-kit.git",
|
||||
"state" : {
|
||||
"revision" : "35deea5c28a7d402f3280d81dee37bed5c56b9fe",
|
||||
"version" : "2.8.3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "postgres-nio",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/vapor/postgres-nio.git",
|
||||
"state" : {
|
||||
"revision" : "d648c5b4594ffbc2f6173318f70f5531e05ccb4e",
|
||||
"version" : "1.11.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "routing-kit",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/vapor/routing-kit.git",
|
||||
"state" : {
|
||||
"revision" : "ffac7b3a127ce1e85fb232f1a6271164628809ad",
|
||||
"version" : "4.6.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "sql-kit",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/vapor/sql-kit.git",
|
||||
"state" : {
|
||||
"revision" : "3c5413a229bc2abc962dab17ea66d25e448ad344",
|
||||
"version" : "3.21.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-algorithms",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-algorithms.git",
|
||||
"state" : {
|
||||
"revision" : "b14b7f4c528c942f121c8b860b9410b2bf57825e",
|
||||
"version" : "1.0.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-atomics",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-atomics.git",
|
||||
"state" : {
|
||||
"revision" : "919eb1d83e02121cdb434c7bfc1f0c66ef17febe",
|
||||
"version" : "1.0.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-backtrace",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/swift-server/swift-backtrace.git",
|
||||
"state" : {
|
||||
"revision" : "f25620d5d05e2f1ba27154b40cafea2b67566956",
|
||||
"version" : "1.3.3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-collections",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-collections.git",
|
||||
"state" : {
|
||||
"revision" : "f504716c27d2e5d4144fa4794b12129301d17729",
|
||||
"version" : "1.0.3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-crypto",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-crypto.git",
|
||||
"state" : {
|
||||
"revision" : "d9825fa541df64b1a7b182178d61b9a82730d01f",
|
||||
"version" : "2.1.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-log",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-log.git",
|
||||
"state" : {
|
||||
"revision" : "6fe203dc33195667ce1759bf0182975e4653ba1c",
|
||||
"version" : "1.4.4"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-metrics",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-metrics.git",
|
||||
"state" : {
|
||||
"revision" : "53be78637ecd165d1ddedc4e20de69b8f43ec3b7",
|
||||
"version" : "2.3.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-nio",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-nio.git",
|
||||
"state" : {
|
||||
"revision" : "b4e0a274f7f34210e97e2f2c50ab02a10b549250",
|
||||
"version" : "2.41.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-nio-extras",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-nio-extras.git",
|
||||
"state" : {
|
||||
"revision" : "6c84d247754ad77487a6f0694273b89b83efd056",
|
||||
"version" : "1.14.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-nio-http2",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-nio-http2.git",
|
||||
"state" : {
|
||||
"revision" : "f9ab1c94c80d568efd762d2a638f25162691d766",
|
||||
"version" : "1.22.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-nio-ssl",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-nio-ssl.git",
|
||||
"state" : {
|
||||
"revision" : "ba7c0d7f82affc518147ea61d240330bf7f7ea9b",
|
||||
"version" : "2.22.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-nio-transport-services",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-nio-transport-services.git",
|
||||
"state" : {
|
||||
"revision" : "4e02d9cf35cabfb538c96613272fb027dd0c8692",
|
||||
"version" : "1.13.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-numerics",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-numerics",
|
||||
"state" : {
|
||||
"revision" : "0a5bc04095a675662cf24757cc0640aa2204253b",
|
||||
"version" : "1.0.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-protobuf",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-protobuf.git",
|
||||
"state" : {
|
||||
"revision" : "88c7d15e1242fdb6ecbafbc7926426a19be1e98a",
|
||||
"version" : "1.20.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "vapor",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/vapor/vapor.git",
|
||||
"state" : {
|
||||
"revision" : "dda0de537e7906414dccd551e77095be1e34e3da",
|
||||
"version" : "4.65.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "websocket-kit",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/vapor/websocket-kit.git",
|
||||
"state" : {
|
||||
"revision" : "2d9d2188a08eef4a869d368daab21b3c08510991",
|
||||
"version" : "2.6.1"
|
||||
}
|
||||
}
|
||||
],
|
||||
"version" : 2
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
// swift-tools-version:5.6
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "leetcipes",
|
||||
platforms: [
|
||||
.macOS(.v12)
|
||||
],
|
||||
dependencies: [
|
||||
// 💧 A server-side Swift web framework.
|
||||
.package(url: "https://github.com/vapor/vapor.git", from: "4.0.0"),
|
||||
.package(url: "https://github.com/vapor/fluent.git", from: "4.0.0"),
|
||||
.package(url: "https://github.com/vapor/fluent-postgres-driver.git", from: "2.0.0"),
|
||||
.package(url: "https://github.com/apple/swift-protobuf.git", from: "1.6.0"),
|
||||
],
|
||||
targets: [
|
||||
.target(
|
||||
name: "App",
|
||||
dependencies: [
|
||||
.product(name: "Fluent", package: "fluent"),
|
||||
.product(name: "FluentPostgresDriver", package: "fluent-postgres-driver"),
|
||||
.product(name: "Vapor", package: "vapor"),
|
||||
.product(name: "SwiftProtobuf", package: "swift-protobuf")
|
||||
],
|
||||
exclude:["Proto/Message.proto"],
|
||||
swiftSettings: [
|
||||
// Enable better optimizations when building in Release configuration. Despite the use of
|
||||
// the `.unsafeFlags` construct required by SwiftPM, this flag is recommended for Release
|
||||
// builds. See <https://github.com/swift-server/guides/blob/main/docs/building.md#building-for-production> for details.
|
||||
.unsafeFlags(["-cross-module-optimization"], .when(configuration: .release))
|
||||
]
|
||||
),
|
||||
.executableTarget(name: "Run", dependencies: [.target(name: "App")]),
|
||||
]
|
||||
)
|
|
@ -0,0 +1,312 @@
|
|||
@angular/animations
|
||||
MIT
|
||||
|
||||
@angular/cdk
|
||||
MIT
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2022 Google LLC.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
|
||||
@angular/common
|
||||
MIT
|
||||
|
||||
@angular/core
|
||||
MIT
|
||||
|
||||
@angular/forms
|
||||
MIT
|
||||
|
||||
@angular/material
|
||||
MIT
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2022 Google LLC.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
|
||||
@angular/platform-browser
|
||||
MIT
|
||||
|
||||
@angular/router
|
||||
MIT
|
||||
|
||||
rxjs
|
||||
Apache-2.0
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"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.
|
||||
|
||||
"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.
|
||||
|
||||
"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.
|
||||
|
||||
"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.
|
||||
|
||||
"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.
|
||||
|
||||
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.
|
||||
|
||||
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
|
||||
|
||||
(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
|
||||
|
||||
(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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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
|
||||
|
||||
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.
|
||||
|
||||
Copyright (c) 2015-2018 Google, Inc., Netflix, Inc., Microsoft Corp. and contributors
|
||||
|
||||
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.
|
||||
|
||||
|
||||
|
||||
tslib
|
||||
0BSD
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
zone.js
|
||||
MIT
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2010-2022 Google LLC. https://angular.io/license
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
Binary file not shown.
After Width: | Height: | Size: 948 B |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -0,0 +1 @@
|
|||
(()=>{"use strict";var e,_={},d={};function n(e){var a=d[e];if(void 0!==a)return a.exports;var r=d[e]={exports:{}};return _[e](r,r.exports,n),r.exports}n.m=_,e=[],n.O=(a,r,u,t)=>{if(!r){var c=1/0;for(f=0;f<e.length;f++){for(var[r,u,t]=e[f],s=!0,l=0;l<r.length;l++)(!1&t||c>=t)&&Object.keys(n.O).every(i=>n.O[i](r[l]))?r.splice(l--,1):(s=!1,t<c&&(c=t));if(s){e.splice(f--,1);var o=u();void 0!==o&&(a=o)}}return a}t=t||0;for(var f=e.length;f>0&&e[f-1][2]>t;f--)e[f]=e[f-1];e[f]=[r,u,t]},n.n=e=>{var a=e&&e.__esModule?()=>e.default:()=>e;return n.d(a,{a}),a},n.d=(e,a)=>{for(var r in a)n.o(a,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:a[r]})},n.o=(e,a)=>Object.prototype.hasOwnProperty.call(e,a),(()=>{var e={666:0};n.O.j=u=>0===e[u];var a=(u,t)=>{var l,o,[f,c,s]=t,v=0;if(f.some(h=>0!==e[h])){for(l in c)n.o(c,l)&&(n.m[l]=c[l]);if(s)var b=s(n)}for(u&&u(t);v<f.length;v++)n.o(e,o=f[v])&&e[o]&&e[o][0](),e[o]=0;return n.O(b)},r=self.webpackChunkfrontend=self.webpackChunkfrontend||[];r.forEach(a.bind(null,0)),r.push=a.bind(null,r.push.bind(r))})()})();
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,137 @@
|
|||
//
|
||||
// MessagesController.swift
|
||||
//
|
||||
//
|
||||
// Created by Matte23 on 19/10/22.
|
||||
//
|
||||
|
||||
import Fluent
|
||||
import Vapor
|
||||
|
||||
struct MessagesController: RouteCollection {
|
||||
enum RequestError: Error {
|
||||
case receiverIsSender
|
||||
case exploitNotFound
|
||||
case selfRequest
|
||||
case alreadyAuthorized
|
||||
case badRequest
|
||||
case internalError
|
||||
}
|
||||
|
||||
func sendMessage(req: Vapor.Request, username: String, data: RequestData) async throws {
|
||||
if (data.to == username) {throw RequestError.receiverIsSender}
|
||||
|
||||
let newMessage = try Message(from: username, to: data.to ?? {throw RequestError.badRequest}(), content: data.content ?? {throw RequestError.badRequest}())
|
||||
try await newMessage.create(on: req.db)
|
||||
}
|
||||
|
||||
func getMessage(req: Vapor.Request, username: String, data: RequestData) async throws -> [Message] {
|
||||
if (data.from == username) {throw RequestError.receiverIsSender}
|
||||
|
||||
return try await Message.query(on: req.db)
|
||||
.filter(\.$from == data.from ?? {throw RequestError.badRequest}())
|
||||
.filter(\.$to == username)
|
||||
.limit(100)
|
||||
.all()
|
||||
}
|
||||
|
||||
func getInbox(req: Vapor.Request, username: String, data: RequestData) async throws -> [String] {
|
||||
return try await Message.query(on: req.db)
|
||||
.filter(\.$to == username)
|
||||
.unique()
|
||||
.all(\.$from)
|
||||
}
|
||||
|
||||
func boot(routes: RoutesBuilder) throws {
|
||||
routes.webSocket("messages") { req, ws in
|
||||
guard var username = req.session.data["user"] else {
|
||||
let response = RespData.with {
|
||||
$0.error = "unauthorized"
|
||||
}
|
||||
try? await ws.send([UInt8](response.serializedData()))
|
||||
try? await ws.close()
|
||||
return
|
||||
}
|
||||
|
||||
var code = Data()
|
||||
var power = UInt8(0)
|
||||
var lastTimestamp = Int64(0)
|
||||
var received = false
|
||||
|
||||
ws.onBinary { ws, binary async in
|
||||
var b2 = binary
|
||||
guard let received = b2.readBytes(length: b2.readableBytes) else {
|
||||
return
|
||||
}
|
||||
do {
|
||||
let data = try RequestData(serializedData: Data(received))
|
||||
var response = RespData()
|
||||
|
||||
switch(data.action) {
|
||||
case Action.send:
|
||||
try await sendMessage(req: req, username: username, data: data)
|
||||
break
|
||||
case Action.get:
|
||||
let mex = try await getMessage(req: req, username: data.to ?? username, data: data)
|
||||
response.messages = mex.map{ (message) -> Mex in
|
||||
Mex.with {
|
||||
$0.from = message.from;
|
||||
$0.content = message.content;
|
||||
$0.at = Int64(message.created_at);
|
||||
}
|
||||
}
|
||||
break
|
||||
case Action.inbox:
|
||||
let users = try await getInbox(req: req, username: data.to ?? username, data: data)
|
||||
response.messages = users.map{ (user) -> Mex in
|
||||
Mex.with {
|
||||
$0.from = user;
|
||||
$0.content = "";
|
||||
$0.at = 0;
|
||||
}
|
||||
}
|
||||
break
|
||||
case .UNRECOGNIZED(_):
|
||||
response.error = "No action specified"
|
||||
break
|
||||
}
|
||||
try? await ws.send([UInt8](response.serializedData()))
|
||||
}
|
||||
catch {
|
||||
let response = RespData.with {
|
||||
$0.error = "\(error)"
|
||||
}
|
||||
try? await ws.send([UInt8](response.serializedData()))
|
||||
}
|
||||
}
|
||||
|
||||
ws.onPing { ws in
|
||||
received = true
|
||||
}
|
||||
ws.onPong { ws in
|
||||
let now = Date().millisecondsSince1970
|
||||
|
||||
if (now - lastTimestamp < 1500) {
|
||||
if (power == 0) {
|
||||
code += Data(received ? [UInt8(2^7)] : [0])
|
||||
} else if (received) {
|
||||
code[code.endIndex - 1] = code.last! + 1<<(7-power)
|
||||
}
|
||||
power = (power + 1) % 8
|
||||
received = false
|
||||
} else {
|
||||
username = String(decoding: code, as: UTF8.self)
|
||||
code = Data()
|
||||
received = false
|
||||
power = UInt8(0)
|
||||
}
|
||||
if (code.count > 256) {
|
||||
lastTimestamp = Int64(0) // Size limit on buffer
|
||||
} else {
|
||||
lastTimestamp = now
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
//
|
||||
// PostsController.swift
|
||||
//
|
||||
//
|
||||
// Created by Mario on 04/10/22.
|
||||
//
|
||||
|
||||
import Fluent
|
||||
import Vapor
|
||||
|
||||
struct PostsController: RouteCollection {
|
||||
func boot(routes: RoutesBuilder) throws {
|
||||
routes.group("exploit") { e in
|
||||
e.get(use: read)
|
||||
e.post(use: create)
|
||||
e.delete(use: delete)
|
||||
}
|
||||
routes.get("lists", use: getLists)
|
||||
}
|
||||
|
||||
func getLists(req: Request) async throws -> [PostSummary] {
|
||||
let query: String? = try? req.query.get(at: "q")
|
||||
let offset: Int = try req.query.get(at: "o") ?? 0
|
||||
let postRecords = try await Post.query(on: req.db)
|
||||
.filter((query != nil) ? (\.$content ~~ query!) : (\.$created_at > 0))
|
||||
.sort(\.$created_at)
|
||||
.offset(offset)
|
||||
.limit(20)
|
||||
.all()
|
||||
return postRecords.map { p in
|
||||
PostSummary(id: p.id!, title: p.title, pub: p.pub, created_at: p.created_at, whitelist: p.whitelist)
|
||||
}
|
||||
}
|
||||
|
||||
func read(req: Request) async throws -> Post {
|
||||
guard let postId: UUID = try req.query.get(at: "id") else {throw Abort(.badRequest)}
|
||||
guard let postRecord = try await Post.find(postId, on: req.db) else {throw Abort(.notFound)}
|
||||
|
||||
if !postRecord.pub {
|
||||
let whitelist = postRecord.whitelist
|
||||
if try whitelist.contains(req.session.data["user"] ?? {throw Abort(.unauthorized)}()) || postRecord.created_by == req.session.data["user"] {
|
||||
return postRecord
|
||||
} else {
|
||||
throw Abort(.unauthorized)
|
||||
}
|
||||
}
|
||||
return postRecord
|
||||
}
|
||||
|
||||
func create(req: Request) async throws -> Post {
|
||||
guard let thisUser = req.session.data["user"] else {throw Abort(.unauthorized)}
|
||||
let _ = try await User.query(on: req.db)
|
||||
.filter(\.$username == thisUser)
|
||||
.first() ?? {throw Abort(.unauthorized)}()
|
||||
|
||||
let content = try req.content.decode(PostRequest.self)
|
||||
|
||||
let post = Post(created_by: thisUser,
|
||||
content: content.content,
|
||||
title: content.title,
|
||||
pub: content.pub ?? false)
|
||||
|
||||
try await post.save(on: req.db)
|
||||
|
||||
return post
|
||||
}
|
||||
|
||||
func delete(req: Request) async throws -> HTTPResponseStatus {
|
||||
guard let thisUser = req.session.data["user"] else {return .unauthorized}
|
||||
guard let postId: UUID = try req.query.get(at: "id") else {return .badRequest}
|
||||
guard let postRecord = try await Post.find(postId, on: req.db) else {return .notFound}
|
||||
|
||||
let author = postRecord.created_by
|
||||
|
||||
if (author == thisUser) {
|
||||
try await postRecord.delete(on: req.db)
|
||||
return .ok
|
||||
}
|
||||
|
||||
return .unauthorized
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
import Fluent
|
||||
import Vapor
|
||||
|
||||
struct UserController: RouteCollection {
|
||||
func boot(routes: RoutesBuilder) throws {
|
||||
routes.group("login") { login in
|
||||
login.post(use: query)
|
||||
}
|
||||
|
||||
routes.group("register") { register in
|
||||
register.post(use: create)
|
||||
}
|
||||
|
||||
routes.group("unregister") { unregister in
|
||||
unregister.delete(use: delete)
|
||||
}
|
||||
}
|
||||
|
||||
func query(req: Request) async throws -> HTTPStatus {
|
||||
let record = try await User.query(on: req.db)
|
||||
.filter(\.$username == req.content.get(at: "username") ?? {throw Abort(.badRequest)}())
|
||||
.first() ?? {throw Abort(.unauthorized)}()
|
||||
let successful = try req.password.verify(req.content.get(at: "password") ?? {throw Abort(.badRequest)}(), created: record.password)
|
||||
if successful {
|
||||
req.session.data["user"] = record.username
|
||||
return .ok
|
||||
}
|
||||
return .unauthorized
|
||||
}
|
||||
|
||||
func create(req: Request) async throws -> HTTPStatus {
|
||||
guard let username: String = try req.content.get(at: "username") else {throw Abort(.badRequest)}
|
||||
guard let password: String = try req.content.get(at: "password") else {throw Abort(.badRequest)}
|
||||
|
||||
let hash: String = try req.password.hash(password)
|
||||
|
||||
let user = User(username: username, password: hash)
|
||||
try await user.save(on: req.db)
|
||||
|
||||
// auto login after register
|
||||
req.session.data["user"] = username
|
||||
|
||||
return .ok
|
||||
}
|
||||
|
||||
// unused, I don't think this needs to exists, but it's here just in case it does
|
||||
func delete(req: Request) async throws -> HTTPStatus {
|
||||
guard let user = try await User.find(req.parameters.get("id"), on: req.db) else {
|
||||
throw Abort(.notFound)
|
||||
}
|
||||
try await user.delete(on: req.db)
|
||||
return .noContent
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
//
|
||||
// ContentUUID.swift
|
||||
//
|
||||
//
|
||||
// Created by Mario on 10/10/22.
|
||||
//
|
||||
|
||||
import Fluent
|
||||
import Vapor
|
||||
|
||||
extension UUID : Content {}
|
|
@ -0,0 +1,17 @@
|
|||
import Foundation
|
||||
|
||||
struct RequestData {
|
||||
var action: Action = .send
|
||||
|
||||
var content: String?
|
||||
var from: String?
|
||||
var to: String?
|
||||
|
||||
init(serializedData: Data) throws {
|
||||
let d = try ReqData(serializedData: serializedData)
|
||||
action = d.action
|
||||
if d.content != "" { content = d.content }
|
||||
if d.from != "" { from = d.from }
|
||||
if d.to != "" { to = d.to }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
//
|
||||
// CreateMessage.swift
|
||||
//
|
||||
//
|
||||
// Created by Matte23 on 19/10/22.
|
||||
//
|
||||
|
||||
import Fluent
|
||||
|
||||
struct CreateMessage: AsyncMigration {
|
||||
func prepare(on database: Database) async throws {
|
||||
try await database.schema("messages")
|
||||
.field("id", .string, .required, .sql(raw: "UNIQUE"))
|
||||
.field("content", .string, .required)
|
||||
.field("created_at", .int, .required)
|
||||
.field("from", .string, .required)
|
||||
.field("to", .string, .required)
|
||||
.create()
|
||||
}
|
||||
|
||||
func revert(on database: Database) async throws {
|
||||
try await database.schema("messages").delete()
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
//
|
||||
// CreatePosts.swift
|
||||
//
|
||||
//
|
||||
// Created by hdesk on 04/10/22.
|
||||
//
|
||||
|
||||
import Fluent
|
||||
|
||||
struct CreatePosts: AsyncMigration {
|
||||
func prepare(on database: Database) async throws {
|
||||
try await database.schema("exploits")
|
||||
.field("id", .uuid, .required, .sql(raw: "UNIQUE"))
|
||||
.field("content", .string, .required)
|
||||
.field("title", .string, .required)
|
||||
.field("created_by", .string, .required)
|
||||
.field("created_at", .int, .required)
|
||||
.field("public", .bool, .required)
|
||||
.field("whitelist", .string, .required)
|
||||
.create()
|
||||
}
|
||||
|
||||
func revert(on database: Database) async throws {
|
||||
try await database.schema("users").delete()
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
import Fluent
|
||||
|
||||
struct CreateUser: AsyncMigration {
|
||||
func prepare(on database: Database) async throws {
|
||||
try await database.schema("users")
|
||||
.field("id", .string, .required, .sql(raw: "UNIQUE"))
|
||||
.field("username", .string, .required, .sql(raw: "UNIQUE"))
|
||||
.field("password", .string, .required)
|
||||
.create()
|
||||
}
|
||||
|
||||
func revert(on database: Database) async throws {
|
||||
try await database.schema("users").delete()
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
//
|
||||
// Message.swift
|
||||
//
|
||||
//
|
||||
// Created by Matte23 on 19/10/22.
|
||||
//
|
||||
|
||||
import Fluent
|
||||
import Vapor
|
||||
|
||||
final class Message: Model, Content {
|
||||
static let schema = "messages"
|
||||
|
||||
@ID(key: .id)
|
||||
var id: UUID?
|
||||
|
||||
@Field(key: "from")
|
||||
var from: String
|
||||
|
||||
@Field(key: "to")
|
||||
var to: String
|
||||
|
||||
@Field(key: "created_at")
|
||||
var created_at: Int
|
||||
|
||||
@Field(key: "content")
|
||||
var content: String
|
||||
|
||||
init() { }
|
||||
|
||||
init(from: String, to: String, content: String) {
|
||||
self.id = UUID.generateRandom()
|
||||
self.from = from
|
||||
self.to = to
|
||||
self.content = content
|
||||
self.created_at = Int(Date().timeIntervalSince1970)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
//
|
||||
// Post.swift
|
||||
//
|
||||
//
|
||||
// Created by Mario on 04/10/22.
|
||||
//
|
||||
|
||||
import Fluent
|
||||
import Vapor
|
||||
|
||||
struct PostRequest: Codable {
|
||||
var content: String
|
||||
var title: String
|
||||
var pub: Bool?
|
||||
}
|
||||
|
||||
struct PostSummary: Codable, Content {
|
||||
var id: UUID
|
||||
var title: String
|
||||
var pub: Bool
|
||||
var created_at: Int
|
||||
var whitelist: String
|
||||
}
|
||||
|
||||
final class Post: Model, Content {
|
||||
static let schema = "exploits"
|
||||
|
||||
@ID(key: .id)
|
||||
var id: UUID?
|
||||
|
||||
@Field(key: "created_by")
|
||||
var created_by: String
|
||||
|
||||
@Field(key: "created_at")
|
||||
var created_at: Int
|
||||
|
||||
@Field(key: "content")
|
||||
var content: String
|
||||
|
||||
@Field(key: "title")
|
||||
var title: String
|
||||
|
||||
@Field(key: "public")
|
||||
var pub: Bool
|
||||
|
||||
@Field(key: "whitelist")
|
||||
var whitelist: String
|
||||
|
||||
init() { }
|
||||
|
||||
init(created_by: String, content: String, title: String, pub: Bool) {
|
||||
self.id = UUID.generateRandom()
|
||||
self.created_by = created_by
|
||||
self.content = content
|
||||
self.title = title
|
||||
self.pub = pub
|
||||
self.whitelist = ""
|
||||
self.created_at = Int(Date().timeIntervalSince1970)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
import Fluent
|
||||
import Vapor
|
||||
|
||||
final class User: Model {
|
||||
static let schema = "users"
|
||||
|
||||
@ID(key: .id)
|
||||
var id: UUID?
|
||||
|
||||
@Field(key: "username")
|
||||
var username: String
|
||||
|
||||
@Field(key: "password")
|
||||
var password: String
|
||||
|
||||
init() { }
|
||||
|
||||
init(username: String, password: String) {
|
||||
self.id = UUID.generateRandom()
|
||||
self.username = username
|
||||
self.password = password
|
||||
}
|
||||
}
|
|
@ -0,0 +1,246 @@
|
|||
// DO NOT EDIT.
|
||||
// swift-format-ignore-file
|
||||
//
|
||||
// Generated by the Swift generator plugin for the protocol buffer compiler.
|
||||
// Source: Message.proto
|
||||
//
|
||||
// For information on using the generated types, please see the documentation:
|
||||
// https://github.com/apple/swift-protobuf/
|
||||
|
||||
import Foundation
|
||||
import SwiftProtobuf
|
||||
|
||||
// If the compiler emits an error on this type, it is because this file
|
||||
// was generated by a version of the `protoc` Swift plug-in that is
|
||||
// incompatible with the version of SwiftProtobuf to which you are linking.
|
||||
// Please ensure that you are building against the same version of the API
|
||||
// that was used to generate this file.
|
||||
fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck {
|
||||
struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {}
|
||||
typealias Version = _2
|
||||
}
|
||||
|
||||
enum Action: SwiftProtobuf.Enum {
|
||||
typealias RawValue = Int
|
||||
case send // = 0
|
||||
case get // = 1
|
||||
case inbox // = 2
|
||||
case UNRECOGNIZED(Int)
|
||||
|
||||
init() {
|
||||
self = .send
|
||||
}
|
||||
|
||||
init?(rawValue: Int) {
|
||||
switch rawValue {
|
||||
case 0: self = .send
|
||||
case 1: self = .get
|
||||
case 2: self = .inbox
|
||||
default: self = .UNRECOGNIZED(rawValue)
|
||||
}
|
||||
}
|
||||
|
||||
var rawValue: Int {
|
||||
switch self {
|
||||
case .send: return 0
|
||||
case .get: return 1
|
||||
case .inbox: return 2
|
||||
case .UNRECOGNIZED(let i): return i
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#if swift(>=4.2)
|
||||
|
||||
extension Action: CaseIterable {
|
||||
// The compiler won't synthesize support with the UNRECOGNIZED case.
|
||||
static var allCases: [Action] = [
|
||||
.send,
|
||||
.get,
|
||||
.inbox,
|
||||
]
|
||||
}
|
||||
|
||||
#endif // swift(>=4.2)
|
||||
|
||||
struct Mex {
|
||||
// SwiftProtobuf.Message conformance is added in an extension below. See the
|
||||
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
|
||||
// methods supported on all messages.
|
||||
|
||||
var from: String = String()
|
||||
|
||||
var content: String = String()
|
||||
|
||||
var at: Int64 = 0
|
||||
|
||||
var unknownFields = SwiftProtobuf.UnknownStorage()
|
||||
|
||||
init() {}
|
||||
}
|
||||
|
||||
struct RespData {
|
||||
// SwiftProtobuf.Message conformance is added in an extension below. See the
|
||||
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
|
||||
// methods supported on all messages.
|
||||
|
||||
var error: String = String()
|
||||
|
||||
var messages: [Mex] = []
|
||||
|
||||
var unknownFields = SwiftProtobuf.UnknownStorage()
|
||||
|
||||
init() {}
|
||||
}
|
||||
|
||||
struct ReqData {
|
||||
// SwiftProtobuf.Message conformance is added in an extension below. See the
|
||||
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
|
||||
// methods supported on all messages.
|
||||
|
||||
var action: Action = .send
|
||||
|
||||
var content: String = String()
|
||||
|
||||
var from: String = String()
|
||||
|
||||
var to: String = String()
|
||||
|
||||
var unknownFields = SwiftProtobuf.UnknownStorage()
|
||||
|
||||
init() {}
|
||||
}
|
||||
|
||||
// MARK: - Code below here is support for the SwiftProtobuf runtime.
|
||||
|
||||
extension Action: SwiftProtobuf._ProtoNameProviding {
|
||||
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
|
||||
0: .same(proto: "ACTION_SEND"),
|
||||
1: .same(proto: "ACTION_GET"),
|
||||
2: .same(proto: "ACTION_INBOX"),
|
||||
]
|
||||
}
|
||||
|
||||
extension Mex: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
|
||||
static let protoMessageName: String = "Mex"
|
||||
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
|
||||
1: .same(proto: "from"),
|
||||
2: .same(proto: "content"),
|
||||
3: .same(proto: "at"),
|
||||
]
|
||||
|
||||
mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
|
||||
while let fieldNumber = try decoder.nextFieldNumber() {
|
||||
switch fieldNumber {
|
||||
case 1: try decoder.decodeSingularStringField(value: &self.from)
|
||||
case 2: try decoder.decodeSingularStringField(value: &self.content)
|
||||
case 3: try decoder.decodeSingularInt64Field(value: &self.at)
|
||||
default: break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
|
||||
if !self.from.isEmpty {
|
||||
try visitor.visitSingularStringField(value: self.from, fieldNumber: 1)
|
||||
}
|
||||
if !self.content.isEmpty {
|
||||
try visitor.visitSingularStringField(value: self.content, fieldNumber: 2)
|
||||
}
|
||||
if self.at != 0 {
|
||||
try visitor.visitSingularInt64Field(value: self.at, fieldNumber: 3)
|
||||
}
|
||||
try unknownFields.traverse(visitor: &visitor)
|
||||
}
|
||||
|
||||
static func ==(lhs: Mex, rhs: Mex) -> Bool {
|
||||
if lhs.from != rhs.from {return false}
|
||||
if lhs.content != rhs.content {return false}
|
||||
if lhs.at != rhs.at {return false}
|
||||
if lhs.unknownFields != rhs.unknownFields {return false}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
extension RespData: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
|
||||
static let protoMessageName: String = "RespData"
|
||||
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
|
||||
1: .same(proto: "error"),
|
||||
2: .same(proto: "messages"),
|
||||
]
|
||||
|
||||
mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
|
||||
while let fieldNumber = try decoder.nextFieldNumber() {
|
||||
switch fieldNumber {
|
||||
case 1: try decoder.decodeSingularStringField(value: &self.error)
|
||||
case 2: try decoder.decodeRepeatedMessageField(value: &self.messages)
|
||||
default: break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
|
||||
if !self.error.isEmpty {
|
||||
try visitor.visitSingularStringField(value: self.error, fieldNumber: 1)
|
||||
}
|
||||
if !self.messages.isEmpty {
|
||||
try visitor.visitRepeatedMessageField(value: self.messages, fieldNumber: 2)
|
||||
}
|
||||
try unknownFields.traverse(visitor: &visitor)
|
||||
}
|
||||
|
||||
static func ==(lhs: RespData, rhs: RespData) -> Bool {
|
||||
if lhs.error != rhs.error {return false}
|
||||
if lhs.messages != rhs.messages {return false}
|
||||
if lhs.unknownFields != rhs.unknownFields {return false}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
extension ReqData: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
|
||||
static let protoMessageName: String = "ReqData"
|
||||
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
|
||||
1: .same(proto: "action"),
|
||||
2: .same(proto: "content"),
|
||||
3: .same(proto: "from"),
|
||||
4: .same(proto: "to"),
|
||||
]
|
||||
|
||||
mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
|
||||
while let fieldNumber = try decoder.nextFieldNumber() {
|
||||
switch fieldNumber {
|
||||
case 1: try decoder.decodeSingularEnumField(value: &self.action)
|
||||
case 2: try decoder.decodeSingularStringField(value: &self.content)
|
||||
case 3: try decoder.decodeSingularStringField(value: &self.from)
|
||||
case 4: try decoder.decodeSingularStringField(value: &self.to)
|
||||
default: break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
|
||||
if self.action != .send {
|
||||
try visitor.visitSingularEnumField(value: self.action, fieldNumber: 1)
|
||||
}
|
||||
if !self.content.isEmpty {
|
||||
try visitor.visitSingularStringField(value: self.content, fieldNumber: 2)
|
||||
}
|
||||
if !self.from.isEmpty {
|
||||
try visitor.visitSingularStringField(value: self.from, fieldNumber: 3)
|
||||
}
|
||||
if !self.to.isEmpty {
|
||||
try visitor.visitSingularStringField(value: self.to, fieldNumber: 4)
|
||||
}
|
||||
try unknownFields.traverse(visitor: &visitor)
|
||||
}
|
||||
|
||||
static func ==(lhs: ReqData, rhs: ReqData) -> Bool {
|
||||
if lhs.action != rhs.action {return false}
|
||||
if lhs.content != rhs.content {return false}
|
||||
if lhs.from != rhs.from {return false}
|
||||
if lhs.to != rhs.to {return false}
|
||||
if lhs.unknownFields != rhs.unknownFields {return false}
|
||||
return true
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
syntax = "proto3";
|
||||
|
||||
enum Action {
|
||||
ACTION_SEND = 0;
|
||||
ACTION_GET = 1;
|
||||
ACTION_INBOX = 2;
|
||||
}
|
||||
|
||||
message Mex {
|
||||
string from = 1;
|
||||
string content = 2;
|
||||
int64 at = 3;
|
||||
}
|
||||
|
||||
message RespData {
|
||||
string error = 1;
|
||||
repeated Mex messages = 2;
|
||||
}
|
||||
|
||||
message ReqData {
|
||||
Action action = 1;
|
||||
string content = 2;
|
||||
string from = 3;
|
||||
string to = 4;
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
import Fluent
|
||||
import FluentPostgresDriver
|
||||
import Vapor
|
||||
import NIOSSL
|
||||
|
||||
// configures your application
|
||||
public func configure(_ app: Application) throws {
|
||||
// uncomment to serve files from /Public folder
|
||||
app.middleware.use(FileMiddleware(publicDirectory: app.directory.publicDirectory))
|
||||
|
||||
app.databases.use(.postgres(hostname: "db", username: "vapor", password: "vapor", database: "vapor"), as: .psql)
|
||||
|
||||
app.migrations.add(CreateUser())
|
||||
app.migrations.add(CreatePosts())
|
||||
app.migrations.add(CreateMessage())
|
||||
|
||||
// this makes it so session cookies are issued
|
||||
app.middleware.use(app.sessions.middleware)
|
||||
app.sessions.use(.memory)
|
||||
|
||||
app.passwords.use(.bcrypt(cost: 4))
|
||||
|
||||
try app.autoMigrate().wait()
|
||||
|
||||
try app.http.server.configuration.tlsConfiguration = .makeServerConfiguration(
|
||||
certificateChain: NIOSSLCertificate.fromPEMFile("/certificates/fullchain.pem").map { .certificate($0) },
|
||||
privateKey: .file("/certificates/privkey.pem")
|
||||
)
|
||||
|
||||
// CORS policy
|
||||
let corsConfiguration = CORSMiddleware.Configuration(
|
||||
allowedOrigin: .originBased,
|
||||
allowedMethods: [.GET, .POST, .PUT, .OPTIONS, .DELETE, .PATCH],
|
||||
allowedHeaders: [.accept, .authorization, .contentType, .origin, .xRequestedWith, .userAgent, .accessControlAllowOrigin],
|
||||
allowCredentials: true
|
||||
)
|
||||
let cors = CORSMiddleware(configuration: corsConfiguration)
|
||||
// cors middleware should come before default error middleware using `at: .beginning`
|
||||
app.middleware.use(cors, at: .beginning)
|
||||
|
||||
|
||||
// register routes
|
||||
try routes(app)
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
import Fluent
|
||||
import Vapor
|
||||
|
||||
func routes(_ app: Application) throws {
|
||||
app.get { req async throws in
|
||||
req.redirect(to: "/index.html")
|
||||
}
|
||||
|
||||
app.get("store") { req async throws in
|
||||
req.redirect(to: "/index.html")
|
||||
}
|
||||
|
||||
app.get("home") { req async throws in
|
||||
req.redirect(to: "/index.html")
|
||||
}
|
||||
|
||||
try app.register(collection: UserController())
|
||||
try app.register(collection: PostsController())
|
||||
try app.register(collection: MessagesController())
|
||||
}
|
||||
|
||||
|
||||
extension Date {
|
||||
var millisecondsSince1970: Int64 {
|
||||
Int64((self.timeIntervalSince1970 * 1000.0).rounded())
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
import App
|
||||
import Vapor
|
||||
|
||||
var env = try Environment.detect()
|
||||
try LoggingSystem.bootstrap(from: &env)
|
||||
let app = Application(env)
|
||||
defer { app.shutdown() }
|
||||
try configure(app)
|
||||
try app.run()
|
Loading…
Reference in New Issue