diff --git a/.github/workflows/register.yml b/.github/workflows/register.yml
new file mode 100644
index 0000000..5e95594
--- /dev/null
+++ b/.github/workflows/register.yml
@@ -0,0 +1,113 @@
+name: Register APP
+
+on:
+ workflow_dispatch:
+
+jobs:
+ Register:
+ runs-on: ubuntu-latest
+ if: ${{ github.event.repository.private }}
+
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v3
+ with:
+ ref: master
+ token: ${{ secrets.PAT }}
+
+ - name: Sync with upstream
+ run: bash wrapper.sh pull
+
+ - name: Check environment variables
+ env:
+ USER: ${{ secrets.USER }}
+ PASSWD: ${{ secrets.PASSWD }}
+ run: bash wrapper.sh check_env
+
+ - name: Setup nodejs
+ id: setup-nodejs
+ uses: actions/setup-node@v3
+ with:
+ node-version: 18.14.2
+ # cache: 'npm'
+ # cache-dependency-path: '**/package.json'
+
+ - name: Set up python
+ id: setup-python
+ uses: actions/setup-python@v4
+ with:
+ python-version: '3.10.10'
+
+ - name: Load cached utils
+ id: cached-utils
+ uses: actions/cache@v3
+ with:
+ path: ~/.local
+ key: ${{ runner.os }}-utils-az-poetry-20230204
+ restore-keys: |
+ ${{ runner.os }}-utils-
+
+ # - name: Check utils version
+ # id: utils-version
+ # run: |
+ # echo "~/.local/bin" >> $GITHUB_PATH
+ # {
+ # export PATH=~/.local/bin:$PATH
+ # [ "$(az version -o tsv --query "\"azure-cli\"")" = "2.39.0" ] && echo "az=true"
+ # poetry -V | grep -q 1.3.2 && echo "poetry=true"
+ # } 2>/dev/null | tee -a $GITHUB_OUTPUT || true
+
+ - name: Install poetry
+ # if: steps.utils-version.outputs.poetry != 'true'
+ if: steps.cached-utils.outputs.cache-hit != 'true'
+ uses: snok/install-poetry@v1
+ with:
+ version: 1.3.2
+ virtualenvs-create: true
+ virtualenvs-in-project: true
+ installer-parallel: true
+
+ # https://github.com/Azure/azure-cli/issues/7124
+ - name: Install specific version of azure-cli
+ if: steps.cached-utils.outputs.cache-hit != 'true'
+ run: |
+ [ "$(az version -o tsv --query "\"azure-cli\"")" = "2.39.0" ] && exit 0
+
+ sudo apt-get remove azure-cli -y
+ sudo apt-get autoremove -y
+ # the default variables are fine
+ # PIPX_HOME=~/.local/pipx PIPX_BIN_DIR=~/.local/bin pipx install azure-cli==2.39.0
+ pipx install azure-cli==2.39.0
+ # this path has been added by the previous step
+ # echo "~/.local/bin" >> $GITHUB_PATH
+
+ - name: Load cached venv
+ id: cached-poetry-dependencies
+ uses: actions/cache@v3
+ with:
+ path: .venv
+ key: ${{ runner.os }}-python-${{ steps.setup-python.outputs.python-version }}-venv-${{ hashFiles('**/poetry.lock') }}
+
+ - name: Install python dependencies
+ if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
+ run: poetry install --no-interaction --no-root --only main
+
+ - name: Load cached node dependencies
+ id: cached-node-dependencies
+ uses: actions/cache@v3
+ with:
+ path: register/node_modules
+ key: ${{ runner.os }}-node-${{ steps.setup-nodejs.outputs.node-version }}-pkg-${{ hashFiles('**/package.json') }}
+
+ - name: Install node dependencies
+ if: steps.cached-node-dependencies.outputs.cache-hit != 'true'
+ run: cd register && npm install
+
+ - name: Register apps
+ env:
+ USER: ${{ secrets.USER }}
+ PASSWD: ${{ secrets.PASSWD }}
+ run: bash wrapper.sh register
+
+ - name: Commit and push
+ run: bash wrapper.sh push "generate app config"
diff --git a/.github/workflows/routine.yml b/.github/workflows/routine.yml
new file mode 100644
index 0000000..804ee6f
--- /dev/null
+++ b/.github/workflows/routine.yml
@@ -0,0 +1,138 @@
+name: Invoke API
+
+on:
+ schedule:
+ - cron: '7 1,5,10,14,17,22 * * *'
+ # https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#providing-inputs
+ workflow_dispatch:
+ inputs:
+ unconditional-invoking:
+ description: 'Invoke API unconditionally'
+ type: boolean
+ required: true
+ default: true
+
+# https://github.com/actions/checkout/issues/19
+jobs:
+ # Random:
+ # runs-on: ubuntu-latest
+ # outputs:
+ # runnable: ${{ steps.decision.outputs.runnable }}
+ # steps:
+ # - name: Checkout code
+ # uses: actions/checkout@v3
+ # with:
+ # ref: master
+ # token: ${{ secrets.PAT }}
+
+ # - name: Pull upstream
+ # run: bash wrapper.sh pull sync
+
+ # - name: Commit and push
+ # run: bash wrapper.sh push "sync with upstream"
+
+ # - name: Make a decision
+ # id: decision
+ # env:
+ # PASSWD: ${{ secrets.PASSWD }}
+ # run: |
+ # sum=$(cksum <<< "$PASSWD" | cut -f1 -d' ')
+ # m=$(date "+%-m")
+ # d=$(date "+%-d")
+ # h=$(date "+%-H")
+ # [ $(((d + m + sum) % 6)) = 1 ] && exit 0
+ # [ $(((h + d + sum) & 1)) = 1 ] && exit 0
+ # echo "::set-output name=runnable::true"
+
+ Invoke:
+ runs-on: ubuntu-latest
+ if: ${{ github.event.repository.private }}
+ # needs: Random
+ # if: needs.Random.outputs.runnable == 'true'
+
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v3
+ with:
+ ref: master
+ token: ${{ secrets.PAT }}
+
+ - name: Sync with upstream
+ run: bash wrapper.sh pull
+
+ - name: Check config files
+ env:
+ USER: ${{ secrets.USER }}
+ run: |
+ bash wrapper.sh has_valid_cfg || {
+ echo "Config files are not valid, please run Register App action."
+ exit 1
+ }
+
+ - name: Make a decision
+ id: decision
+ env:
+ PASSWD: ${{ secrets.PASSWD }}
+ run: |
+ [ "${{ inputs.unconditional-invoking }}" = "true" ] && {
+ echo "runnable=true" >> $GITHUB_OUTPUT
+ exit 0
+ }
+
+ sum=$(cksum <<< "$PASSWD" | cut -f1 -d' ')
+ m=$(date "+%-m")
+ d=$(date "+%-d")
+ h=$(date "+%-H")
+ [ $(((d + m + sum) % 6)) = 1 ] && exit 0
+ [ $(((h + d + sum) & 1)) = 1 ] && exit 0
+ # echo "::set-output name=runnable::true"
+ echo "runnable=true" >> $GITHUB_OUTPUT
+
+ - name: Set up python
+ if: steps.decision.outputs.runnable == 'true'
+ id: setup-python
+ uses: actions/setup-python@v4
+ with:
+ python-version: '3.10.10'
+
+ - name: Load cached utils
+ if: steps.decision.outputs.runnable == 'true'
+ id: cached-utils
+ uses: actions/cache@v3
+ with:
+ path: ~/.local
+ key: ${{ runner.os }}-utils-az-poetry-20230204
+ restore-keys: |
+ ${{ runner.os }}-utils-
+
+ - name: Install poetry
+ if: steps.decision.outputs.runnable == 'true' && steps.cached-utils.outputs.cache-hit != 'true'
+ uses: snok/install-poetry@v1
+ with:
+ version: 1.3.2
+ virtualenvs-create: true
+ virtualenvs-in-project: true
+ installer-parallel: true
+
+ - name: Load cached venv
+ if: steps.decision.outputs.runnable == 'true'
+ id: cached-poetry-dependencies
+ uses: actions/cache@v3
+ with:
+ path: .venv
+ key: ${{ runner.os }}-python-${{ steps.setup-python.outputs.python-version }}-venv-${{ hashFiles('**/poetry.lock') }}
+
+ - name: Install python dependencies
+ if: steps.decision.outputs.runnable == 'true' && steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
+ run: poetry install --no-interaction --no-root --only main
+
+ - name: Test API
+ if: steps.decision.outputs.runnable == 'true'
+ env:
+ USER: ${{ secrets.USER }}
+ PASSWD: ${{ secrets.PASSWD }}
+ run: bash wrapper.sh invoke
+
+ - name: Commit and push
+ if: steps.decision.outputs.runnable == 'true'
+ run: bash wrapper.sh push "update app config"
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..bd3fb50
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,141 @@
+# Byte-compiled / optimized / DLL files
+__pycache__/
+*.py[cod]
+*$py.class
+
+# C extensions
+*.so
+
+# Distribution / packaging
+.Python
+build/
+develop-eggs/
+dist/
+downloads/
+eggs/
+.eggs/
+lib/
+lib64/
+parts/
+sdist/
+var/
+wheels/
+share/python-wheels/
+*.egg-info/
+.installed.cfg
+*.egg
+MANIFEST
+
+# PyInstaller
+# Usually these files are written by a python script from a template
+# before PyInstaller builds the exe, so as to inject date/other infos into it.
+*.manifest
+*.spec
+
+# Installer logs
+pip-log.txt
+pip-delete-this-directory.txt
+
+# Unit test / coverage reports
+htmlcov/
+.tox/
+.nox/
+.coverage
+.coverage.*
+.cache
+nosetests.xml
+coverage.xml
+*.cover
+*.py,cover
+.hypothesis/
+.pytest_cache/
+cover/
+
+# Translations
+*.mo
+*.pot
+
+# Django stuff:
+*.log
+local_settings.py
+db.sqlite3
+db.sqlite3-journal
+
+# Flask stuff:
+instance/
+.webassets-cache
+
+# Scrapy stuff:
+.scrapy
+
+# Sphinx documentation
+docs/_build/
+
+# PyBuilder
+.pybuilder/
+target/
+
+# Jupyter Notebook
+.ipynb_checkpoints
+
+# IPython
+profile_default/
+ipython_config.py
+
+# pyenv
+# For a library or package, you might want to ignore these files since the code is
+# intended to run in multiple environments; otherwise, check them in:
+# .python-version
+
+# pipenv
+# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
+# However, in case of collaboration, if having platform-specific dependencies or dependencies
+# having no cross-platform support, pipenv may install dependencies that don't work, or not
+# install all needed dependencies.
+#Pipfile.lock
+
+# PEP 582; used by e.g. github.com/David-OConnor/pyflow
+__pypackages__/
+
+# Celery stuff
+celerybeat-schedule
+celerybeat.pid
+
+# SageMath parsed files
+*.sage.py
+
+# Environments
+.env
+.venv
+env/
+venv/
+ENV/
+env.bak/
+venv.bak/
+
+# Spyder project settings
+.spyderproject
+.spyproject
+
+# Rope project settings
+.ropeproject
+
+# mkdocs documentation
+/site
+
+# mypy
+.mypy_cache/
+.dmypy.json
+dmypy.json
+
+# Pyre type checker
+.pyre/
+
+# pytype static type analyzer
+.pytype/
+
+# Cython debug symbols
+cython_debug/
+
+# Runtime files
+utils.meta
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..f288702
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C)
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ Copyright (C)
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..eb43027
--- /dev/null
+++ b/README.md
@@ -0,0 +1,11 @@
+# Usage
+
+Set the following repo secrets, disable the security defaults of your E5 admin accounts, then trigger `Register APP` workflow manually. Read [The Intro](https://logi.im/script/permanently-keeping-an-office-e5-account.html) for step by step instructions.
+
+| Name | Value |
+| ------ | ----------------------------------------------------------------- |
+| PAT | Github personal access token with `workflow` permission |
+| USER | E5 admin emails line separated, no leading and trailing spaces |
+| PASSWD | E5 admin passwords line separated, no leading and trailing spaces |
+
+version@202305070221
diff --git a/config/app0.json b/config/app0.json
new file mode 100644
index 0000000..fa32365
--- /dev/null
+++ b/config/app0.json
@@ -0,0 +1 @@
+fSI9WTJkbnFWOTdvV3lxNFM1U1A0YmVLRDltVUZ3UWE4dDVSRTR1RnM3cDYyNllZUytJMzdlQkhtb2tFU1d5S2FQZ2xNNnZQczJUWUc2ZWltQ2FlTXA1KzRMLzhPeTcwcGowODg1QlIxUFkxNnRjbERjWFE5QVo3YWJvYW8wVzhKMVpuUkpGVHFzaTJRak84aGVOb0JVVGtMbUVsOGZtS3VtQm5lR1VFOGN3RE1DRmpsS2pzTXBsNTRmeTJLKzQra0VPMExwbThvR1NLMlhuSGY5NktlcG5aYnRZdjN2OUhaOHVsZFVGd2cyWjFyaENoRFZjQ2FGSkk5QVJxbEdXTVgrWUFERmwxakhCNUoyUGxGUlBPdktjNWwyNmVwWlhVVzVYVE1ReG5mNnhHZDdsMkF2QjRFMlF1NmQ3RFIvb0FIc3haaVZzeWtoWWRIbkhNYkhoQVVObkYrdnV0bW9LSlFLTTgrZkN4b2YyNnRHOUZRNnROakxLRE9DV2s1R3ZjSDkzMjdCRitESStVZmI1SCtCQ0dROVNjYXhCc0xzYnBGK044Mk9IRms5YTFYYStzakwxd0tSZ0xhaFhXTFBKQTdKQXorWVZtRnduVFF4SmQ5cnpaQ3ZCbUg4NGp3ZnVUVk9QS0VvYzlHRTJaVTZ2ZStLQnVxb1lFOHJ5Nk9iM1VEamp3c3dGbkdON09PS1ZudUJ3S2R0ZzZhTlJYeCtkT3ZDYzRnZ2FKVHhTUU9vNE0vcHo4OEZRY0dQRHBNSm1KMjFnZFdxTkFONW5ITXBNTXV5TXR4ZnBqT2NDYXk1b1AxcjM4UXRrM3k1U3hQekh5V05IUTFaSEprbkh6NmMrbklWaU5VbzkvTGRzZTNhZnQwRFoycjFOcXBXTjNtOExmcDJoOEJXRTZmdjUzbzd4WnBPb0dBM0x0c0hJMlRvOWt5ZGRBTml6SnVacXh6cWdWSHdPWTYrRUgzSXdtajFFeE5XMmpFdU1CK0VGL1JqUTVwbGFXY1d0ZlZCNTd2TytkUGo2a081Qy9DT2ZldnFrQ05yRm14R1EvNzBsQW1ncjI2QmNEQzRsNDJTMzNQbzVzNFV5N29KU1dmcE8wVDh1Nm1QMUx4ZDZFWGxsd3liM013WXd6VW51cVBmcVNTYnAxc1BrZkN0V2hURUt0UCtFTUYxeWlyRDdSUGZlemNRWHhVTm0rc0lRMTdBQzNtSlc4blhZZ1d3WHpIWDIxVWxJWGJoNDRVY1FUUlU0Qkx5RXJaTGdEN1VDbUJ1aW93dmpQcmpwUWVCc3NBeXdhcGlpcFdROEtJd0RCVXNXNURwZm1BQ3J6N1h3U01zeFVRNzErSEhweHZjMmZYb01wT0swQXpReVc1aUVvUXdJRGw3SHJtbWhvZWlZRXpvRmZWK1BXMnEwU2pmUG1CKy9KWVBMMk9uK3R0enpYTFNhTFY3T3M4UHlYT2F1RDhWamtrQkZ4YXdLd09RaGdPZEk4MkhKSm50UC9wbTFQT1pjaW9ITGlualZSOEhTTGluamtJM3NNYXU3dEhueldrUFUzbVY0NysrY3owUUYwOENxWVVONGdNcGtFVENVMkROU3NXVW00Z2xDaTRrWTUwVGFYWE13WmJaOVBjZThMRkV6dEJHaS9LR1Zva0FUY0pvTTRoUFZzOVV6Zmd0YzhzaFk4MFVpZlVpSzFYeFREWGFPLy9SK0l2VlYveDNHeTdLM2VUOW9YUjQwVmw3cXBRcGJnR3RnNDFnTHAxV3U3RXh3V3dNVEptVW5qNmFYa1hTamFZOVZ0Uk1MSHZCN3ZlQTdEbzlGUUpMUFBMMFBsd3lrRXJZQ2NlcUhVektnSjNZSHE3RXRCM3VmZEgrZDZjWUxrc2N2dExpdm5tWW9OM3hlTDMxVFR6VDJtcTlRVHl4M2hXRHY3bEgvQVNNQTZHODVsQXNSRnZ0OGRUMlhjVzloYTMwUU9Jd29SWDVZbUNlcmUvWmFJK2VTRHB4UkhaRmltTU81Q09PVER0Tks4eWluUVorIiA6InR4ZXRyZWhwaWMiICwiPT1nUmllMXRPcGxLTWVOYk54MEJydzZoIiA6InZpIns=
\ No newline at end of file
diff --git a/crypto.py b/crypto.py
new file mode 100644
index 0000000..69cc6ed
--- /dev/null
+++ b/crypto.py
@@ -0,0 +1,48 @@
+import os
+import sys
+import json
+from base64 import b64encode, b64decode
+from Crypto.Cipher import AES
+from Crypto.Util.Padding import pad, unpad
+from util import multi_accounts_task
+
+# PASSWD can't be empty.
+KEY = (os.getenv("PASSWD") + "=" * 15)[:16]
+
+
+def encrypt(data: str, key: str):
+ cipher = AES.new(key.encode("utf-8"), AES.MODE_CBC)
+ ct_bytes = cipher.encrypt(pad(data.encode("utf-8"), AES.block_size))
+ iv = b64encode(cipher.iv).decode("utf-8")
+ ct = b64encode(ct_bytes).decode("utf-8")
+ return b64encode(
+ json.dumps({"iv": iv, "ciphertext": ct})[::-1].encode("utf-8")
+ ).decode("utf-8")
+
+
+def decrypt(data: str, key: str):
+ data = json.loads(b64decode(data)[::-1])
+ iv = b64decode(data["iv"])
+ ct = b64decode(data["ciphertext"])
+ cipher = AES.new(key.encode("utf-8"), AES.MODE_CBC, iv)
+ return unpad(cipher.decrypt(ct), AES.block_size).decode("utf-8")
+
+
+def handle(path, *_):
+ with open(path, "r") as f:
+ origin = f.read()
+
+ with open(path, "w") as f:
+ if sys.argv[1] == "e":
+ f.write(encrypt(origin, KEY))
+ return "应用信息已加密"
+ elif sys.argv[1] == "d":
+ f.write(decrypt(origin, KEY))
+ return "应用信息已解密"
+
+
+if __name__ == "__main__":
+ if len(sys.argv) == 1:
+ exit(1)
+
+ multi_accounts_task(handle)
diff --git a/poetry.lock b/poetry.lock
new file mode 100644
index 0000000..d29243a
--- /dev/null
+++ b/poetry.lock
@@ -0,0 +1,175 @@
+[[package]]
+name = "autopep8"
+version = "1.5.6"
+description = "A tool that automatically formats Python code to conform to the PEP 8 style guide"
+category = "dev"
+optional = false
+python-versions = "*"
+
+[package.dependencies]
+pycodestyle = ">=2.7.0"
+toml = "*"
+
+[[package]]
+name = "certifi"
+version = "2020.12.5"
+description = "Python package for providing Mozilla's CA Bundle."
+category = "main"
+optional = false
+python-versions = "*"
+
+[[package]]
+name = "chardet"
+version = "4.0.0"
+description = "Universal encoding detector for Python 2 and 3"
+category = "main"
+optional = false
+python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
+
+[[package]]
+name = "idna"
+version = "2.10"
+description = "Internationalized Domain Names in Applications (IDNA)"
+category = "main"
+optional = false
+python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
+
+[[package]]
+name = "pycodestyle"
+version = "2.7.0"
+description = "Python style guide checker"
+category = "dev"
+optional = false
+python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
+
+[[package]]
+name = "pycryptodome"
+version = "3.10.1"
+description = "Cryptographic library for Python"
+category = "main"
+optional = false
+python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
+
+[[package]]
+name = "requests"
+version = "2.25.1"
+description = "Python HTTP for Humans."
+category = "main"
+optional = false
+python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
+
+[package.dependencies]
+certifi = ">=2017.4.17"
+chardet = ">=3.0.2,<5"
+idna = ">=2.5,<3"
+urllib3 = ">=1.21.1,<1.27"
+
+[package.extras]
+security = ["pyOpenSSL (>=0.14)", "cryptography (>=1.3.4)"]
+socks = ["PySocks (>=1.5.6,!=1.5.7)", "win-inet-pton"]
+
+[[package]]
+name = "rope"
+version = "0.19.0"
+description = "a python refactoring library..."
+category = "dev"
+optional = false
+python-versions = "*"
+
+[package.extras]
+dev = ["pytest"]
+
+[[package]]
+name = "toml"
+version = "0.10.2"
+description = "Python Library for Tom's Obvious, Minimal Language"
+category = "dev"
+optional = false
+python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*"
+
+[[package]]
+name = "urllib3"
+version = "1.26.4"
+description = "HTTP library with thread-safe connection pooling, file post, and more."
+category = "main"
+optional = false
+python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4"
+
+[package.extras]
+secure = ["pyOpenSSL (>=0.14)", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "certifi", "ipaddress"]
+socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"]
+brotli = ["brotlipy (>=0.6.0)"]
+
+[metadata]
+lock-version = "1.1"
+python-versions = "^3.9"
+content-hash = "926e88a54ab02384b77d5de2dc23a09bf12bf8a7807022d3b6bd18e87e4343ee"
+
+[metadata.files]
+autopep8 = [
+ {file = "autopep8-1.5.6-py2.py3-none-any.whl", hash = "sha256:f01b06a6808bc31698db907761e5890eb2295e287af53f6693b39ce55454034a"},
+ {file = "autopep8-1.5.6.tar.gz", hash = "sha256:5454e6e9a3d02aae38f866eec0d9a7de4ab9f93c10a273fb0340f3d6d09f7514"},
+]
+certifi = [
+ {file = "certifi-2020.12.5-py2.py3-none-any.whl", hash = "sha256:719a74fb9e33b9bd44cc7f3a8d94bc35e4049deebe19ba7d8e108280cfd59830"},
+ {file = "certifi-2020.12.5.tar.gz", hash = "sha256:1a4995114262bffbc2413b159f2a1a480c969de6e6eb13ee966d470af86af59c"},
+]
+chardet = [
+ {file = "chardet-4.0.0-py2.py3-none-any.whl", hash = "sha256:f864054d66fd9118f2e67044ac8981a54775ec5b67aed0441892edb553d21da5"},
+ {file = "chardet-4.0.0.tar.gz", hash = "sha256:0d6f53a15db4120f2b08c94f11e7d93d2c911ee118b6b30a04ec3ee8310179fa"},
+]
+idna = [
+ {file = "idna-2.10-py2.py3-none-any.whl", hash = "sha256:b97d804b1e9b523befed77c48dacec60e6dcb0b5391d57af6a65a312a90648c0"},
+ {file = "idna-2.10.tar.gz", hash = "sha256:b307872f855b18632ce0c21c5e45be78c0ea7ae4c15c828c20788b26921eb3f6"},
+]
+pycodestyle = [
+ {file = "pycodestyle-2.7.0-py2.py3-none-any.whl", hash = "sha256:514f76d918fcc0b55c6680472f0a37970994e07bbb80725808c17089be302068"},
+ {file = "pycodestyle-2.7.0.tar.gz", hash = "sha256:c389c1d06bf7904078ca03399a4816f974a1d590090fecea0c63ec26ebaf1cef"},
+]
+pycryptodome = [
+ {file = "pycryptodome-3.10.1-cp27-cp27m-macosx_10_9_x86_64.whl", hash = "sha256:1c5e1ca507de2ad93474be5cfe2bfa76b7cf039a1a32fc196f40935944871a06"},
+ {file = "pycryptodome-3.10.1-cp27-cp27m-manylinux1_i686.whl", hash = "sha256:6260e24d41149268122dd39d4ebd5941e9d107f49463f7e071fd397e29923b0c"},
+ {file = "pycryptodome-3.10.1-cp27-cp27m-manylinux1_x86_64.whl", hash = "sha256:3f840c49d38986f6e17dbc0673d37947c88bc9d2d9dba1c01b979b36f8447db1"},
+ {file = "pycryptodome-3.10.1-cp27-cp27m-manylinux2010_i686.whl", hash = "sha256:2dea65df54349cdfa43d6b2e8edb83f5f8d6861e5cf7b1fbc3e34c5694c85e27"},
+ {file = "pycryptodome-3.10.1-cp27-cp27m-manylinux2010_x86_64.whl", hash = "sha256:e61e363d9a5d7916f3a4ce984a929514c0df3daf3b1b2eb5e6edbb131ee771cf"},
+ {file = "pycryptodome-3.10.1-cp27-cp27m-manylinux2014_aarch64.whl", hash = "sha256:2603c98ae04aac675fefcf71a6c87dc4bb74a75e9071ae3923bbc91a59f08d35"},
+ {file = "pycryptodome-3.10.1-cp27-cp27m-win32.whl", hash = "sha256:38661348ecb71476037f1e1f553159b80d256c00f6c0b00502acac891f7116d9"},
+ {file = "pycryptodome-3.10.1-cp27-cp27m-win_amd64.whl", hash = "sha256:1723ebee5561628ce96748501cdaa7afaa67329d753933296321f0be55358dce"},
+ {file = "pycryptodome-3.10.1-cp27-cp27mu-manylinux1_i686.whl", hash = "sha256:77997519d8eb8a4adcd9a47b9cec18f9b323e296986528186c0e9a7a15d6a07e"},
+ {file = "pycryptodome-3.10.1-cp27-cp27mu-manylinux1_x86_64.whl", hash = "sha256:99b2f3fc51d308286071d0953f92055504a6ffe829a832a9fc7a04318a7683dd"},
+ {file = "pycryptodome-3.10.1-cp27-cp27mu-manylinux2010_i686.whl", hash = "sha256:e0a4d5933a88a2c98bbe19c0c722f5483dc628d7a38338ac2cb64a7dbd34064b"},
+ {file = "pycryptodome-3.10.1-cp27-cp27mu-manylinux2010_x86_64.whl", hash = "sha256:d3d6958d53ad307df5e8469cc44474a75393a434addf20ecd451f38a72fe29b8"},
+ {file = "pycryptodome-3.10.1-cp27-cp27mu-manylinux2014_aarch64.whl", hash = "sha256:a8eb8b6ea09ec1c2535bf39914377bc8abcab2c7d30fa9225eb4fe412024e427"},
+ {file = "pycryptodome-3.10.1-cp35-abi3-macosx_10_9_x86_64.whl", hash = "sha256:31c1df17b3dc5f39600a4057d7db53ac372f492c955b9b75dd439f5d8b460129"},
+ {file = "pycryptodome-3.10.1-cp35-abi3-manylinux1_i686.whl", hash = "sha256:a3105a0eb63eacf98c2ecb0eb4aa03f77f40fbac2bdde22020bb8a536b226bb8"},
+ {file = "pycryptodome-3.10.1-cp35-abi3-manylinux1_x86_64.whl", hash = "sha256:a92d5c414e8ee1249e850789052608f582416e82422502dc0ac8c577808a9067"},
+ {file = "pycryptodome-3.10.1-cp35-abi3-manylinux2010_i686.whl", hash = "sha256:60386d1d4cfaad299803b45a5bc2089696eaf6cdd56f9fc17479a6f89595cfc8"},
+ {file = "pycryptodome-3.10.1-cp35-abi3-manylinux2010_x86_64.whl", hash = "sha256:501ab36aae360e31d0ec370cf5ce8ace6cb4112060d099b993bc02b36ac83fb6"},
+ {file = "pycryptodome-3.10.1-cp35-abi3-manylinux2014_aarch64.whl", hash = "sha256:fc7489a50323a0df02378bc2fff86eb69d94cc5639914346c736be981c6a02e7"},
+ {file = "pycryptodome-3.10.1-cp35-abi3-win32.whl", hash = "sha256:9b6f711b25e01931f1c61ce0115245a23cdc8b80bf8539ac0363bdcf27d649b6"},
+ {file = "pycryptodome-3.10.1-cp35-abi3-win_amd64.whl", hash = "sha256:7fd519b89585abf57bf47d90166903ec7b43af4fe23c92273ea09e6336af5c07"},
+ {file = "pycryptodome-3.10.1-pp27-pypy_73-macosx_10_9_x86_64.whl", hash = "sha256:09c1555a3fa450e7eaca41ea11cd00afe7c91fef52353488e65663777d8524e0"},
+ {file = "pycryptodome-3.10.1-pp27-pypy_73-manylinux1_x86_64.whl", hash = "sha256:758949ca62690b1540dfb24ad773c6da9cd0e425189e83e39c038bbd52b8e438"},
+ {file = "pycryptodome-3.10.1-pp27-pypy_73-manylinux2010_x86_64.whl", hash = "sha256:e3bf558c6aeb49afa9f0c06cee7fb5947ee5a1ff3bd794b653d39926b49077fa"},
+ {file = "pycryptodome-3.10.1-pp27-pypy_73-win32.whl", hash = "sha256:f977cdf725b20f6b8229b0c87acb98c7717e742ef9f46b113985303ae12a99da"},
+ {file = "pycryptodome-3.10.1-pp36-pypy36_pp73-macosx_10_9_x86_64.whl", hash = "sha256:6d2df5223b12437e644ce0a3be7809471ffa71de44ccd28b02180401982594a6"},
+ {file = "pycryptodome-3.10.1-pp36-pypy36_pp73-manylinux1_x86_64.whl", hash = "sha256:98213ac2b18dc1969a47bc65a79a8fca02a414249d0c8635abb081c7f38c91b6"},
+ {file = "pycryptodome-3.10.1-pp36-pypy36_pp73-manylinux2010_x86_64.whl", hash = "sha256:12222a5edc9ca4a29de15fbd5339099c4c26c56e13c2ceddf0b920794f26165d"},
+ {file = "pycryptodome-3.10.1-pp36-pypy36_pp73-win32.whl", hash = "sha256:6bbf7fee7b7948b29d7e71fcacf48bac0c57fb41332007061a933f2d996f9713"},
+ {file = "pycryptodome-3.10.1.tar.gz", hash = "sha256:3e2e3a06580c5f190df843cdb90ea28d61099cf4924334d5297a995de68e4673"},
+]
+requests = [
+ {file = "requests-2.25.1-py2.py3-none-any.whl", hash = "sha256:c210084e36a42ae6b9219e00e48287def368a26d03a048ddad7bfee44f75871e"},
+ {file = "requests-2.25.1.tar.gz", hash = "sha256:27973dd4a904a4f13b263a19c866c13b92a39ed1c964655f025f3f8d3d75b804"},
+]
+rope = [
+ {file = "rope-0.19.0.tar.gz", hash = "sha256:64e6d747532e1f5c8009ec5aae3e5523a5bcedf516f39a750d57d8ed749d90da"},
+]
+toml = [
+ {file = "toml-0.10.2-py2.py3-none-any.whl", hash = "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"},
+ {file = "toml-0.10.2.tar.gz", hash = "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"},
+]
+urllib3 = [
+ {file = "urllib3-1.26.4-py2.py3-none-any.whl", hash = "sha256:2f4da4594db7e1e110a944bb1b551fdf4e6c136ad42e4234131391e21eb5b0df"},
+ {file = "urllib3-1.26.4.tar.gz", hash = "sha256:e7b021f7241115872f92f43c6508082facffbd1c048e3c6e2bb9c2a157e28937"},
+]
diff --git a/pyproject.toml b/pyproject.toml
new file mode 100644
index 0000000..849f190
--- /dev/null
+++ b/pyproject.toml
@@ -0,0 +1,21 @@
+[tool.poetry]
+authors = ["vcheckzen"]
+description = "keep e5 alive"
+name = "keepalivee5"
+version = "0.1.0"
+
+[tool.poetry.dependencies]
+python = "^3.9"
+requests = "^2.25.1"
+pycryptodome = "^3.10.1"
+
+[tool.poetry.dev-dependencies]
+autopep8 = "^1.5.6"
+rope = "^0.19.0"
+
+[build-system]
+build-backend = "poetry.core.masonry.api"
+requires = ["poetry-core>=1.0.0"]
+
+[virtualenvs]
+in-project = true
\ No newline at end of file
diff --git a/register/.gitignore b/register/.gitignore
new file mode 100644
index 0000000..1f22b9c
--- /dev/null
+++ b/register/.gitignore
@@ -0,0 +1,116 @@
+# Logs
+logs
+*.log
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+lerna-debug.log*
+
+# Diagnostic reports (https://nodejs.org/api/report.html)
+report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
+
+# Runtime data
+pids
+*.pid
+*.seed
+*.pid.lock
+
+# Directory for instrumented libs generated by jscoverage/JSCover
+lib-cov
+
+# Coverage directory used by tools like istanbul
+coverage
+*.lcov
+
+# nyc test coverage
+.nyc_output
+
+# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
+.grunt
+
+# Bower dependency directory (https://bower.io/)
+bower_components
+
+# node-waf configuration
+.lock-wscript
+
+# Compiled binary addons (https://nodejs.org/api/addons.html)
+build/Release
+
+# Dependency directories
+node_modules/
+jspm_packages/
+
+# Snowpack dependency directory (https://snowpack.dev/)
+web_modules/
+
+# TypeScript cache
+*.tsbuildinfo
+
+# Optional npm cache directory
+.npm
+
+# Optional eslint cache
+.eslintcache
+
+# Microbundle cache
+.rpt2_cache/
+.rts2_cache_cjs/
+.rts2_cache_es/
+.rts2_cache_umd/
+
+# Optional REPL history
+.node_repl_history
+
+# Output of 'npm pack'
+*.tgz
+
+# Yarn Integrity file
+.yarn-integrity
+
+# dotenv environment variables file
+.env
+.env.test
+
+# parcel-bundler cache (https://parceljs.org/)
+.cache
+.parcel-cache
+
+# Next.js build output
+.next
+out
+
+# Nuxt.js build / generate output
+.nuxt
+dist
+
+# Gatsby files
+.cache/
+# Comment in the public line in if your project uses Gatsby and not Next.js
+# https://nextjs.org/blog/next-9-1#public-directory-support
+# public
+
+# vuepress build output
+.vuepress/dist
+
+# Serverless directories
+.serverless/
+
+# FuseBox cache
+.fusebox/
+
+# DynamoDB Local files
+.dynamodb/
+
+# TernJS port file
+.tern-port
+
+# Stores VSCode versions used for testing VSCode extensions
+.vscode-test
+
+# yarn v2
+.yarn/cache
+.yarn/unplugged
+.yarn/build-state.yml
+.yarn/install-state.gz
+.pnp.*
diff --git a/register/client.js b/register/client.js
new file mode 100644
index 0000000..8984da2
--- /dev/null
+++ b/register/client.js
@@ -0,0 +1,63 @@
+const puppeteer = require('puppeteer');
+const config = require(process.argv[2]);
+const except = require('./except.js');
+
+let browser = { close: async () => {} };
+setTimeout(async () => {
+ await browser.close();
+ except.fatalError(config.username);
+}, except.totalTimeout);
+
+const sleep = (seconds) =>
+ new Promise((resolve) => setTimeout(resolve, (seconds || 1) * 1000));
+
+(async () => {
+ try {
+ browser = await puppeteer.launch({
+ // headless: false,
+ headless: true,
+ args: ['--no-sandbox'],
+ });
+ const page = await browser.newPage();
+ // https://pptr.dev/#?product=Puppeteer&version=v10.4.0&show=api-pagesetdefaulttimeouttimeout
+ await page.setDefaultTimeout(except.methodTimeout);
+ await page.setDefaultNavigationTimeout(except.methodTimeout);
+
+ await page.goto(
+ `https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=${config.client_id}&scope=offline_access%20User.Read&response_type=code&redirect_uri=${config.redirect_uri}`
+ );
+
+ // email
+ await page.waitForSelector('input[type=email]');
+ await page.type('input[type=email]', config.username);
+ // next
+ await page.waitForSelector('[type=submit]');
+ await sleep(1);
+ await page.click('[type=submit]');
+
+ // password
+ await page.waitForSelector('input[type=password]');
+ await page.type('input[type=password]', config.password);
+ // login
+ await sleep(3);
+ await page.waitForSelector('[type=submit]');
+ await page.click('[type=submit]');
+ await page.waitForNavigation();
+
+ // consent
+ await page.waitForSelector('[type=checkbox]');
+ await sleep(1);
+ await page.click('[type=checkbox]');
+
+ // accept
+ await page.waitForSelector('[type=submit]');
+ await page.click('[type=submit]');
+ // request redirect uri
+ await sleep(3);
+ await browser.close();
+ process.exit(0);
+ } catch (error) {
+ await browser.close();
+ except.fatalError(config.username, error);
+ }
+})();
\ No newline at end of file
diff --git a/register/except.js b/register/except.js
new file mode 100644
index 0000000..5d9c3b8
--- /dev/null
+++ b/register/except.js
@@ -0,0 +1,11 @@
+exports.methodTimeout = 1000 * 10; // 10s
+exports.totalTimeout = exports.methodTimeout * 6; // 1min
+
+exports.fatalError = (username, error) => {
+ console.error(
+ `✘ 账号 [${username}] 注册失败, 请按照链接说明关闭安全默认值(多因素认证):`,
+ 'https://docs.microsoft.com/zh-cn/azure/active-directory/fundamentals/concept-fundamentals-security-defaults#disabling-security-defaults',
+ error
+ );
+ process.exit(1);
+};
diff --git a/register/name_generator/.gitignore b/register/name_generator/.gitignore
new file mode 100644
index 0000000..ea8c4bf
--- /dev/null
+++ b/register/name_generator/.gitignore
@@ -0,0 +1 @@
+/target
diff --git a/register/name_generator/Cargo.lock b/register/name_generator/Cargo.lock
new file mode 100644
index 0000000..39976ad
--- /dev/null
+++ b/register/name_generator/Cargo.lock
@@ -0,0 +1,42 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "aho-corasick"
+version = "0.7.20"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac"
+dependencies = [
+ "memchr",
+]
+
+[[package]]
+name = "memchr"
+version = "2.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
+
+[[package]]
+name = "name_generator"
+version = "0.1.0"
+dependencies = [
+ "regex",
+]
+
+[[package]]
+name = "regex"
+version = "1.7.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8b1f693b24f6ac912f4893ef08244d70b6067480d2f1a46e950c9691e6749d1d"
+dependencies = [
+ "aho-corasick",
+ "memchr",
+ "regex-syntax",
+]
+
+[[package]]
+name = "regex-syntax"
+version = "0.6.29"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
diff --git a/register/name_generator/Cargo.toml b/register/name_generator/Cargo.toml
new file mode 100644
index 0000000..9e34fd3
--- /dev/null
+++ b/register/name_generator/Cargo.toml
@@ -0,0 +1,9 @@
+[package]
+name = "name_generator"
+version = "0.1.0"
+edition = "2021"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
+regex = "1.5.4"
\ No newline at end of file
diff --git a/register/name_generator/bin/ng b/register/name_generator/bin/ng
new file mode 100644
index 0000000..652cf74
Binary files /dev/null and b/register/name_generator/bin/ng differ
diff --git a/register/name_generator/src/main.rs b/register/name_generator/src/main.rs
new file mode 100644
index 0000000..ad29466
--- /dev/null
+++ b/register/name_generator/src/main.rs
@@ -0,0 +1,383 @@
+const NAME_LIST_STR: &str = "1. Facebook
+2. Instagram
+3. TikTok
+4. WhatsApp
+5. Netflix
+6. YouTube
+7. Twitter
+8. Snapchat
+9. Pinterest
+10. LinkedIn
+11. Skype
+12. Google Maps
+13. Uber
+14. Lyft
+15. Airbnb
+16. Dropbox
+17. Evernote
+18. Slack
+19. Trello
+20. Grammarly
+21. Duolingo
+22. Headspace
+23. Calm
+24. Waze
+25. Yelp
+26. Shazam
+27. SoundCloud
+28. Spotify
+29. Pandora
+30. Apple Music
+31. Amazon Prime Video
+32. Hulu
+33. ESPN
+34. Nike Training Club
+35. MyFitnessPal
+36. Fitbit
+37. Strava
+38. MapMyRun
+39. Runkeeper
+40. Pocket
+41. Flipboard
+42. Feedly
+43. Medium
+44. TED
+45. Coursera
+46. Khan Academy
+47. Udemy
+48. Skillshare
+49. Headspace for Kids
+50. Epic!
+51. ABCmouse.com
+52. Rosetta Stone
+53. Babbel
+54. Memrise
+55. Lumosity
+56. Elevate
+57. Peak
+58. Heads Up!
+59. Trivia Crack
+60. Words with Friends
+61. Candy Crush Saga
+62. Clash of Clans
+63. Minecraft
+64. Fortnite
+65. PUBG Mobile
+66. Among Us
+67. Temple Run
+68. Subway Surfers
+69. Angry Birds
+70. Cut the Rope
+71. Fruit Ninja
+72. Doodle Jump
+73. Jetpack Joyride
+74. Plants vs. Zombies
+75. Monument Valley
+76. Scribblenauts Remix
+77. World of Goo
+78. The Room
+79. Limbo
+80. Badland
+81. Alto's Adventure
+82. Monument Valley 2
+83. Tiny Wings
+84. Shadow Fight 2
+85. Asphalt 8: Airborne
+86. Real Racing 3
+87. PUBG Mobile Lite
+88. Free Fire
+89. Call of Duty: Mobile
+90. Madden NFL 21 Mobile Football
+91. FIFA Soccer
+92. NBA 2K Mobile Basketball
+93. Chess.com
+94. Lichess
+95. Wordscapes
+96. Pokémon Go
+97. Wizards Unite
+98. Ingress
+99. Geocaching
+100. iNaturalist
+101. Adobe Creative Cloud
+102. Canva
+103. Sketchbook
+104. Procreate
+105. Photoshop Express
+106. Lightroom
+107. VSCO
+108. Snapseed
+109. Pixelmator
+110. PicCollage
+111. Layout from Instagram
+112. Afterlight 2
+113. Prisma Photo Editor
+114. Facetune
+115. FaceApp
+116. BeautyPlus
+117. YouCam Makeup
+118. Perfect365
+119. B612
+120. Snapchat Bitmoji
+121. Microsoft Office
+122. Google Drive
+123. Dropbox Paper
+124. Zoho Docs
+125. Evernote Scannable
+126. CamScanner
+127. Scanner Pro
+128. Genius Scan
+129. Notability
+130. GoodNotes
+131. MyScript Nebo
+132. MindNode
+133. OmniFocus
+134. Things
+135. Todoist
+136. Habitica
+137. Forest
+138. Headspace for Work
+139. HelloMind
+140. Smiling Mind
+141. Brain.fm
+142. My Study Life
+143. Quizlet
+144. AnkiApp
+145. Flashcards+
+146. Evernote Peek
+147. Wolfram Alpha
+148. Google Translate
+149. iTranslate
+150. Babylon Translator
+151. TripIt
+152. Airbnb Experiences
+153. Booking.com
+154. Kayak
+155. Expedia
+156. Hopper
+157. Skyscanner
+158. TripAdvisor
+159. Yelp Reservations
+160. OpenTable
+161. Grubhub
+162. Uber Eats
+163. Postmates
+164. DoorDash
+165. Slice
+166. Instacart
+167. Shipt
+168. FreshDirect
+169. HelloFresh
+170. Blue Apron
+171. Allrecipes
+172. Epicurious
+173. Tasty
+174. Yummly
+175. Food Network Kitchen
+176. Wine-Searcher
+177. Vivino
+178. Untappd
+179. Mixology
+180. BarEye
+181. MyFitnessPal by Under Armour
+182. Nike Run Club
+183. Headspace for Work
+184. HelloMind
+185. Smiling Mind
+186. Brain.fm
+187. My Study Life
+188. Quizlet
+189. AnkiApp
+190. Flashcards+
+191. Evernote Peek
+192. Wolfram Alpha
+193. Google Translate
+194. iTranslate
+195. Babylon Translator
+196. TripIt
+197. Airbnb Experiences
+198. Booking.com
+199. Kayak
+200. Expedia
+201. Hopper
+202. Skyscanner
+203. TripAdvisor
+204. Yelp Reservations
+205. OpenTable
+206. Grubhub
+207. Uber Eats
+208. Postmates
+209. DoorDash
+210. Slice
+211. Instacart
+212. Shipt
+213. FreshDirect
+214. HelloFresh
+215. Blue Apron
+216. Allrecipes
+217. Epicurious
+218. Tasty
+219. Yummly
+220. Food Network Kitchen
+221. Wine-Searcher
+222. Vivino
+223. Untappd
+224. Mixology
+225. BarEye
+226. MyFitnessPal by Under Armour
+227. Nike Run Club
+228. Run with Map My Run
+229. Strava
+230. Runtastic
+231. Fit Radio
+232. Aaptiv
+233. Yoga Studio
+234. Daily Burn
+235. Sworkit
+236. 7 Minute Workout
+237. JEFIT
+238. Gymaholic
+239. StrongLifts 5x5
+240. Zombies, Run!
+241. Sleep Cycle
+242. Pillow
+243. White Noise
+244. Rain Rain
+245. Noisli
+246. Focus@Will
+247. Freedom
+248. Moment
+249. Offtime
+250. RescueTime
+251. Toggl
+252. TickTick
+253. Remember The Milk
+254. Any.do
+255. Todoist
+256. Google Tasks
+257. Wunderlist
+258. Asana
+259. Trello
+260. Monday.com
+261. Basecamp
+262. Notion
+263. Evernote Business
+264. Slack
+265. Discord
+266. Zoom
+267. Skype for Business
+268. Google Meet
+269. GoToMeeting
+270. Cisco Webex Meetings
+271. Join.me
+272. Zoho Meeting
+273. BlueJeans
+274. Microsoft Teams
+275. Dropbox Business
+276. Box
+277. OneDrive for Business
+278. Citrix Files
+279. Egnyte
+280. Google Drive for Work
+281. Apple iCloud for Business
+282. DocuSign
+283. Adobe Sign
+284. HelloSign
+285. SignNow
+286. PandaDoc
+287. Formstack Sign
+288. Typeform
+289. Wufoo
+290. JotForm
+291. SurveyMonkey
+292. Qualtrics
+293. Typeform
+294. Wufoo
+295. JotForm
+296. SurveyMonkey
+297. Qualtrics
+298. Google Forms
+299. Paperform
+300. Cognito Forms
+301. Typeform
+302. QuickBooks
+303. Xero
+304. Wave
+305. FreshBooks
+306. Square
+307. PayPal Here
+308. Stripe
+309. Shopify
+310. WooCommerce
+311. Magento
+312. BigCommerce
+313. Ecwid
+314. Salesforce
+315. HubSpot
+316. Marketo
+317. Pardot
+318. Mailchimp
+319. Constant Contact
+320. AWeber
+321. Campaign Monitor
+322. GetResponse
+323. ActiveCampaign
+324. Klaviyo
+325. Emma
+326. Drip
+327. ConvertKit
+328. Hootsuite
+329. Sprout Social
+330. Buffer
+331. Later
+332. Planoly
+333. Tailwind
+334. Canva
+335. Piktochart
+336. Venngage
+337. Adobe Spark
+338. Easil
+339. Snappa
+340. PromoRepublic
+341. Loom
+342. Zoom
+343. GoToWebinar
+344. Livestorm
+345. Crowdcast
+346. Twitch
+347. YouTube Live
+348. Facebook Live
+349. Instagram Live
+350. Periscope
+351. Vimeo
+352. Wistia
+353. Brightcove
+354. Vidyard
+355. BombBomb
+356. Animoto
+357. Biteable
+358. Powtoon
+359. Emaze
+360. Prezi
+361. Haiku Deck
+362. Slides
+363. Google Slides";
+
+use std::env;
+use regex::Regex;
+
+fn main() {
+ let args: Vec = env::args().collect();
+ let id = args
+ .get(1)
+ .expect("Need identifier argument.")
+ .parse::()
+ .expect("The identifier argument must be an unsigned integer.");
+
+ let mut names_str_iter = NAME_LIST_STR.split("\n");
+ let count = names_str_iter.clone().count();
+
+ let re = Regex::new(r"[^a-zA-Z]").unwrap();
+ let name = re.replace_all(names_str_iter.nth(id % count).unwrap(), "");
+
+ println!("{}", name);
+}
\ No newline at end of file
diff --git a/register/package.json b/register/package.json
new file mode 100644
index 0000000..88f9be1
--- /dev/null
+++ b/register/package.json
@@ -0,0 +1,12 @@
+{
+ "name": "refresh-token",
+ "version": "1.0.1",
+ "main": "index.js",
+ "license": "MIT",
+ "dependencies": {
+ "axios": "^0.21.1",
+ "express": "^4.17.1",
+ "puppeteer": "^10.4.0",
+ "qs": "^6.10.1"
+ }
+}
diff --git a/register/purge.js b/register/purge.js
new file mode 100644
index 0000000..5c457f7
--- /dev/null
+++ b/register/purge.js
@@ -0,0 +1,46 @@
+const axios = require('axios');
+
+/**
+ * Permanently remove the deleted apps
+ * @param {String} accessToken
+ * @param {[String]} appNamePrefixes
+ */
+async function removeOldApps(accessToken, appNamePrefixes) {
+ const client = axios.create({
+ headers: {
+ authorization: `Bearer ${accessToken}`,
+ 'Content-Type': 'application/json',
+ ConsistencyLevel: 'eventual',
+ },
+ });
+
+ const searchParams = appNamePrefixes
+ .map((name) => `"displayName:${name}"`)
+ .join(' OR ');
+
+ const remove = (id) =>
+ client.delete(
+ `https://graph.microsoft.com/v1.0/directory/deletedItems/${id}`
+ );
+
+ const list = () =>
+ client.get(
+ 'https://graph.microsoft.com/v1.0/directory/deleteditems/Microsoft.Graph.Application',
+ {
+ params: {
+ $select: 'id',
+ $search: searchParams,
+ $count: 'true',
+ $top: '999',
+ },
+ }
+ );
+
+ while (true) {
+ const data = (await list()).data;
+ if (data['@odata.count'] == 0) break;
+ await Promise.all(data.value.map((obj) => remove(obj.id)));
+ }
+}
+
+module.exports = removeOldApps;
diff --git a/register/register_apps_by_force.sh b/register/register_apps_by_force.sh
new file mode 100644
index 0000000..c9d21e0
--- /dev/null
+++ b/register/register_apps_by_force.sh
@@ -0,0 +1,217 @@
+#!/usr/bin/env bash
+
+# https://docs.microsoft.com/en-us/cli/azure/microsoft-graph-migration
+
+# https://gist.github.com/mohanpedala/1e2ff5661761d3abd0385e8223e16425
+set -eu
+# set -x
+
+# GITHUB_PATH takes care of it
+# export PATH=~/.local/bin:$PATH
+
+CONFIG_PATH='../config'
+NAME_GENERATOR='./name_generator/bin/ng'
+PERMISSIONS_FILE='./required-resource-accesses.json'
+
+_id() {
+ cksum <<<"$1" | cut -f1 -d' '
+}
+
+BASE_PORT=$(($(_id "$USER") % 50000 + 3000))
+
+jq() {
+ # echo -n "$1" | python3 -c "import sys,json; print(json.load(sys.stdin)$2)"
+ python3 -c "import sys,json; print(json.loads(sys.argv[1])$2)" "$1"
+}
+
+es() {
+ # echo -n "$1" | python3 -c "import sys,json; print(json.dumps(sys.stdin.read()))"
+ python3 -c "import sys,json; json.dump(sys.argv[1], sys.stdout)" "$1"
+}
+
+arr_2_json() {
+ python3 -c "import sys,json; json.dump(sys.argv[1:], sys.stdout)" "$@"
+}
+
+register_app() {
+ order="$1"
+ username="$2"
+ password="$3"
+
+ config_file="$CONFIG_PATH/app$order.json"
+ reply_uri="http://localhost:$((BASE_PORT + order))/"
+
+ # separate multiple accounts
+ export AZURE_CONFIG_DIR="/tmp/az-cli/$order"
+ mkdir -p "$AZURE_CONFIG_DIR"
+ # clear account if exists
+ # az account clear
+
+ # login
+ # https://docs.microsoft.com/en-us/cli/azure/reference-index?view=azure-cli-latest#az-login
+ # ret="$(az login \
+ # --allow-no-subscriptions \
+ # -u "$username" \
+ # -p "$password" 2>/dev/null)"
+ # tenant_id="$(jq "$ret" "[0]['tenantId']")"
+ az login \
+ --allow-no-subscriptions \
+ -u "$username" \
+ -p "$password" \
+ --only-show-errors 1>/dev/null || {
+ echo "登录失败,账号或密码错误,或未关闭安全默认值(多因素认证),请进一步阅读英文日志"
+ exit 1
+ }
+
+ # https://docs.microsoft.com/en-us/graph/api/user-list?view=graph-rest-1.0&tabs=csharp#response-1
+ # azure-cli version > 2.36.0
+ # user_id="$(jq "$(az ad user list)" "[0]['id']")"
+ # https://learn.microsoft.com/en-us/cli/azure/ad/user?view=azure-cli-latest#az-ad-user-show
+ user_id="$(jq "$(az ad user show --id "$username")" "['id']")"
+ # azure-cli version <= 2.36.0
+ # user_id="$(jq "$(az ad user list)" "[0]['objectId']")"
+
+ _ng() {
+ id="$(_id "$1")"
+ echo -n "$("$NAME_GENERATOR" "$id")"
+
+ # with id
+ [ "${2:-x}" = "w" ] && echo -n "$id"
+
+ # there is 'set -e'
+ return 0
+ }
+
+ # delete existing apps
+ # https://docs.microsoft.com/en-us/cli/azure/ad/app?view=azure-cli-latest#az-ad-app-list
+ # https://docs.microsoft.com/en-us/graph/api/application-list?view=graph-rest-1.0&tabs=http#response-1
+ has_old_app="false"
+ app_name="$(_ng "$user_id" "w")"
+ old_app_name_prefixes=('E5_ALIVE' "$(_ng "$username")" "$app_name")
+ for prfx in "${old_app_name_prefixes[@]}"; do
+ while true; do
+ ret=$(az ad app list --display-name "$prfx")
+ [ "$ret" = "[]" ] && break
+
+ has_old_app="true"
+ # https://docs.microsoft.com/en-us/cli/azure/ad/app?view=azure-cli-latest#az-ad-app-delete
+ az ad app delete \
+ --id "$(jq "$ret" "[0]['appId']")" \
+ --only-show-errors
+
+ sleep 3
+ done
+ done
+ # wait azure system to refresh
+ [ "$has_old_app" = "true" ] && sleep 17
+
+ # create a new app
+ # https://docs.microsoft.com/en-us/cli/azure/ad/app?view=azure-cli-latest#az-ad-app-create
+ # https://docs.microsoft.com/en-us/graph/api/application-post-applications?view=graph-rest-1.0&tabs=http#response-1
+ # --identifier-uris api://e5.app \
+ # azure-cli version > 2.36.0
+ ret="$(az ad app create \
+ --display-name "$app_name" \
+ --web-redirect-uris "$reply_uri" \
+ --required-resource-accesses "@$PERMISSIONS_FILE")"
+ # azure-cli version <= 2.36.0
+ # ret="$(az ad app create \
+ # --display-name "$app_name" \
+ # --reply-urls "$reply_uri" \
+ # --available-to-other-tenants true \
+ # --required-resource-accesses "@$PERMISSIONS_FILE")"
+ app_id="$(jq "$ret" "['appId']")"
+
+ # wait azure system to refresh
+ sleep 5
+
+ # set owner
+ # https://docs.microsoft.com/en-us/cli/azure/ad/app/owner?view=azure-cli-latest#az-ad-app-owner-add
+ az ad app owner add \
+ --id "$app_id" \
+ --owner-object-id "$user_id" \
+ --only-show-errors
+
+ # wait azure system to refresh
+ sleep 30
+
+ # grant admin consent
+ # https://docs.microsoft.com/en-us/cli/azure/ad/app/permission?view=azure-cli-latest#az-ad-app-permission-admin-consent
+ az ad app permission admin-consent \
+ --id "$app_id" \
+ --only-show-errors
+
+ # generate client secret
+ # https://docs.microsoft.com/en-us/cli/azure/ad/app/credential?view=azure-cli-latest#az-ad-app-credential-reset
+ # https://docs.microsoft.com/en-us/graph/api/application-addpassword?view=graph-rest-1.0&tabs=http
+ ret="$(az ad app credential reset \
+ --id "$app_id" \
+ --years 100 2>/dev/null)"
+ client_secret="$(jq "$ret" "['password']")"
+
+ # wait azure system to refresh
+ sleep 30
+
+ # save app details
+ # shellcheck disable=SC2086
+ cat >"$config_file" </dev/null ||
+ exit 1
+}
+
+# rm -rf "$CONFIG_PATH"
+# mkdir -p "$CONFIG_PATH"
+# chmod +x "$NAME_GENERATOR"
+
+# https://ss64.com/bash/mapfile.html
+# mapfile -t users < <(echo -e "$USER")
+# mapfile -t passwords < <(echo -e "$PASSWD")
+# for ((i = 0; i < "${#users[@]}"; i++)); do
+# {
+# can not capture stdout or stderr if set -e is open and
+# error occurs in register_app
+# log=$(register_app "$i" "${users[$i]}" "${passwords[$i]}")
+# echo "$log"
+# echo "$log" | grep '注册成功' >/dev/null
+# register_app "$i" "${users[$i]}" "${passwords[$i]}"
+# } &
+# pids[$i]=$!
+# register_app "$i" "${users[$i]}" "${passwords[$i]}" &
+# done
+
+# https://stackoverflow.com/questions/356100/how-to-wait-in-bash-for-several-subprocesses-to-finish-and-return-exit-code-0
+# https://man7.org/linux/man-pages/man1/wait.1p.html
+# ecode=0
+# for pid in "${pids[@]}"; do
+# wait $pid || ecode=1
+# done
+
+# exit $ecode
+
+main() {
+ rm -rf "$CONFIG_PATH"
+ mkdir -p "$CONFIG_PATH"
+ chmod +x "$NAME_GENERATOR"
+
+ mapfile -t users < <(echo -e "$USER")
+ mapfile -t passwords < <(echo -e "$PASSWD")
+ for ((i = 0; i < "${#users[@]}"; i++)); do
+ register_app "$i" "${users[$i]}" "${passwords[$i]}" &
+ done
+ wait
+}
+
+main
diff --git a/register/required-resource-accesses.json b/register/required-resource-accesses.json
new file mode 100644
index 0000000..e78fc22
--- /dev/null
+++ b/register/required-resource-accesses.json
@@ -0,0 +1,55 @@
+[
+ {
+ "resourceAccess": [
+ {
+ "id": "570282fd-fa5c-430d-a7fd-fc8dc98a9dca",
+ "type": "Scope"
+ },
+ {
+ "id": "818c620a-27a9-40bd-a6a5-d96f7d610b4b",
+ "type": "Scope"
+ },
+ {
+ "id": "87f447af-9fa4-4c32-9dfa-4a57a73d18ce",
+ "type": "Scope"
+ },
+ {
+ "id": "89fe6a52-be36-487e-b7d8-d061c450a026",
+ "type": "Scope"
+ },
+ {
+ "id": "a154be20-db9c-4678-8ab7-66f6cc099a59",
+ "type": "Scope"
+ },
+ {
+ "id": "204e0828-b5ca-4ad8-b9f3-f32a958e7cc4",
+ "type": "Scope"
+ },
+ {
+ "id": "06da0dbc-49e2-44d2-8312-53f166ab848a",
+ "type": "Scope"
+ },
+ {
+ "id": "c5366453-9fb0-48a5-a156-24f0c49a4b84",
+ "type": "Scope"
+ },
+ {
+ "id": "024d486e-b451-40bb-833d-3e66d98c5c73",
+ "type": "Scope"
+ },
+ {
+ "id": "df85f4d6-205c-4ac5-a5ea-6bf408dba283",
+ "type": "Scope"
+ },
+ {
+ "id": "863451e7-0667-486c-a5d6-d135439485f0",
+ "type": "Scope"
+ },
+ {
+ "id": "205e70e5-aba6-4c52-a976-6d2d46c48043",
+ "type": "Scope"
+ }
+ ],
+ "resourceAppId": "00000003-0000-0000-c000-000000000000"
+ }
+]
\ No newline at end of file
diff --git a/register/server.js b/register/server.js
new file mode 100644
index 0000000..6e667c6
--- /dev/null
+++ b/register/server.js
@@ -0,0 +1,49 @@
+const fs = require('fs');
+const qs = require('qs');
+const axios = require('axios');
+const express = require('express');
+
+const configFile = process.argv[2];
+const config = require(configFile);
+const except = require('./except.js');
+const removeOldApps = require('./purge.js');
+
+setTimeout(() => {
+ server.close();
+ process.exit(1);
+}, except.totalTimeout);
+
+const app = express();
+
+app.get('/', (req, res) => {
+ res.send(req.query.code);
+
+ server.close(async () => {
+ try {
+ const resp = await axios.post(
+ 'https://login.microsoftonline.com/common/oauth2/v2.0/token',
+ qs.stringify({
+ client_id: config.client_id,
+ client_secret: config.client_secret,
+ code: req.query.code,
+ redirect_uri: config.redirect_uri,
+ grant_type: 'authorization_code',
+ })
+ );
+
+ config.refresh_token = resp?.data?.refresh_token || '';
+ if (config.refresh_token.length < 5) {
+ throw new Error('Getting token failed.');
+ }
+ fs.writeFileSync(configFile, JSON.stringify(config));
+ removeOldApps(resp.data.access_token, config.old_app_name_prefixes).catch(
+ () => {}
+ );
+ console.log(`✔ 账号 [${config.username}] 注册成功.`);
+ } catch (error) {
+ except.fatalError(config.username, error);
+ }
+ });
+});
+
+const server = app.listen(config.redirect_uri.match(/\d+/)[0]);
diff --git a/task.py b/task.py
new file mode 100644
index 0000000..ed5b700
--- /dev/null
+++ b/task.py
@@ -0,0 +1,122 @@
+# import time
+import json
+import random
+import requests
+from concurrent.futures import ThreadPoolExecutor
+from util import multi_accounts_task, GracefulKiller
+
+MIN_INVOKE_TIMES = 176
+MAX_INVOKE_TIMES = 237
+EXECUTOR_KILLER = GracefulKiller()
+
+
+def config(path, data=None):
+ if not data:
+ with open(path, mode="r") as conf:
+ return json.load(conf)
+
+ # fast-fail
+ json.loads(json.dumps(data))
+ with open(path, mode="w") as conf:
+ json.dump(data, conf)
+
+ # with open(path, mode="r+") as conf:
+ # if not data:
+ # return json.load(conf)
+ # json.dump(data, conf, sort_keys=True, indent=4)
+
+
+def get_access_token(app):
+ try:
+ return requests.post(
+ "https://login.microsoftonline.com/common/oauth2/v2.0/token",
+ data={
+ "grant_type": "refresh_token",
+ "refresh_token": app["refresh_token"],
+ "client_id": app["client_id"],
+ "client_secret": app["client_secret"],
+ "redirect_uri": app["redirect_uri"],
+ },
+ ).json()
+ except Exception:
+ return {}
+
+
+def invoke_api(path):
+ app = config(path)
+ tokens = get_access_token(app)
+ access_token = tokens.get("access_token", "")
+ refresh_token = tokens.get("refresh_token", "")
+ username = app["username"]
+
+ if len(access_token) < 5 or len(refresh_token) < 5:
+ return f"✘ 账号 [{username}] 调用失败."
+
+ apis = [
+ "https://graph.microsoft.com/v1.0/groups",
+ "https://graph.microsoft.com/v1.0/sites/root",
+ "https://graph.microsoft.com/v1.0/sites/root/sites",
+ "https://graph.microsoft.com/v1.0/sites/root/drives",
+ "https://graph.microsoft.com/v1.0/sites/root/columns",
+ "https://graph.microsoft.com/v1.0/me/",
+ "https://graph.microsoft.com/v1.0/me/events",
+ "https://graph.microsoft.com/v1.0/me/people",
+ "https://graph.microsoft.com/v1.0/me/contacts",
+ "https://graph.microsoft.com/v1.0/me/calendars",
+ "https://graph.microsoft.com/v1.0/me/drive",
+ "https://graph.microsoft.com/v1.0/me/drive/root",
+ "https://graph.microsoft.com/v1.0/me/drive/root/children",
+ "https://graph.microsoft.com/v1.0/me/drive/recent",
+ "https://graph.microsoft.com/v1.0/me/drive/sharedWithMe",
+ "https://graph.microsoft.com/v1.0/me/onenote/pages",
+ "https://graph.microsoft.com/v1.0/me/onenote/sections",
+ "https://graph.microsoft.com/v1.0/me/onenote/notebooks",
+ "https://graph.microsoft.com/v1.0/me/outlook/masterCategories",
+ "https://graph.microsoft.com/v1.0/me/mailFolders",
+ "https://graph.microsoft.com/v1.0/me/mailFolders/Inbox/messages/delta",
+ "https://graph.microsoft.com/v1.0/me/mailFolders/inbox/messageRules",
+ "https://graph.microsoft.com/v1.0/me/messages",
+ "https://graph.microsoft.com/v1.0/me/messages?$filter=importance eq 'high'",
+ 'https://graph.microsoft.com/v1.0/me/messages?$search="hello world"',
+ "https://graph.microsoft.com/beta/me/messages?$select=internetMessageHeaders&$top",
+ ]
+ headers = {"Authorization": f"Bearer {access_token}"}
+
+ def single_period(period):
+ if EXECUTOR_KILLER.kill_now:
+ return ""
+
+ result = "=" * 100 + "\n"
+ random.shuffle(apis)
+ probability = random.random()
+ for api in apis:
+ if random.random() < probability:
+ continue
+ try:
+ if requests.get(api, headers=headers).status_code == 200:
+ result += "{:>20s} | {:>6s} | {:<50s}\n".format(
+ f"账号: {username}", f"周期: {period}", f"成功: {api}"
+ )
+ except Exception:
+ # time.sleep(random.random()*3)
+ pass
+
+ if EXECUTOR_KILLER.kill_now:
+ return result
+
+ return result
+
+ with ThreadPoolExecutor() as executor:
+ max = random.randint(MIN_INVOKE_TIMES, MAX_INVOKE_TIMES)
+ futures = [executor.submit(single_period, period) for period in range(1, max)]
+ result = "".join((f.result() for f in futures))
+
+ # save refresh_token
+ app["refresh_token"] = refresh_token
+ config(path, app)
+
+ return f"{result}✔ 账号 [{username}] 调用成功."
+
+
+if __name__ == "__main__":
+ multi_accounts_task(invoke_api)
\ No newline at end of file
diff --git a/util.py b/util.py
new file mode 100644
index 0000000..61323b4
--- /dev/null
+++ b/util.py
@@ -0,0 +1,37 @@
+import os
+import signal
+from concurrent.futures import ThreadPoolExecutor
+
+CONFIG_PATH = "./config"
+
+
+def multi_accounts_task(fn):
+ configs = []
+ try:
+ for path in os.listdir(CONFIG_PATH):
+ configs.append(os.path.join(CONFIG_PATH, path))
+ except Exception:
+ pass
+
+ if len(configs) == 0:
+ print("没有找到配置文件, 请执行应用注册 Action.")
+ exit(1)
+
+ with ThreadPoolExecutor() as executor:
+ for future in [executor.submit(fn, cfg) for cfg in configs]:
+ print(f"{future.result()}")
+
+
+class GracefulKiller:
+ """https://stackoverflow.com/questions/18499497/how-to-process-sigterm-signal-gracefully"""
+
+ kill_now = False
+
+ def __init__(self):
+ signal.signal(signal.SIGINT, self.exit_gracefully)
+ signal.signal(signal.SIGTERM, self.exit_gracefully)
+ # https://stackoverflow.com/questions/33242630/how-to-handle-os-system-sigkill-signal-inside-python
+ # signal.signal(signal.SIGKILL, self.exit_gracefully)
+
+ def exit_gracefully(self, *args):
+ self.kill_now = True
diff --git a/wrapper.sh b/wrapper.sh
new file mode 100644
index 0000000..9b69ac4
--- /dev/null
+++ b/wrapper.sh
@@ -0,0 +1,186 @@
+#!/usr/bin/env bash
+
+UPSTREAM="https://github.com/vcheckzen/KeepAliveE5.git"
+BOT_USER="github-actions[bot]"
+BOT_EMAIL="41898282+github-actions[bot]@users.noreply.github.com"
+CONFIG_PATH="config"
+
+exit_on_error() {
+ min_secs="$1"
+ max_time="$2"
+ cmd="$3"
+
+ start=$(date +%s)
+ # https://man7.org/linux/man-pages/man1/timeout.1.html
+ # https://stackoverflow.com/questions/29936956/linux-how-does-the-kill-k-switch-work-in-timeout-command
+ # https://stackoverflow.com/questions/42615374/the-linux-timeout-command-and-exit-codes
+ # do not quote $cmd
+ # shellcheck disable=SC2086
+ # output="$(2>&1 timeout -s KILL "$max_time" $cmd)"
+ output="$(timeout 2>&1 --preserve-status -k 1m "$max_time" $cmd)"
+ ret=$?
+ end=$(date +%s)
+ [ "$output" ] && echo "$output"
+
+ [ $ret -ne 0 ] && exit 1
+ [ $((end - start)) -lt "$min_secs" ] && exit 1
+ # https://man7.org/linux/man-pages/man1/grep.1.html
+ # https://unix.stackexchange.com/questions/305547/broken-pipe-when-grepping-output-but-only-with-i-flag
+ echo "$output" | grep '成功' >/dev/null || exit 1
+ echo "$output" | grep -iE '错误|失败|error|except' >/dev/null && exit 1
+
+ return 0
+}
+
+last_advice() {
+ echo -n "$1"
+ # omit default
+ [ "$2" != "o" ] &&
+ echo -n " Before doing that, check if your usernames are matched with \
+the relevant passwords, and if the security defaults are disabled."
+ echo
+ exit 1
+}
+
+trim() {
+ sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' <<<"$1"
+}
+
+check_env() {
+ fix_advice="请修正后重新执行应用注册."
+
+ for k in USER PASSWD; do
+ # v="$(eval "echo "\$$k"")"
+ v="${!k}"
+ trimmed="$(trim "$v")"
+ [ "$trimmed" != "$v" ] && {
+ last_advice "$k 变量中存在多余的空白字符,$fix_advice" "o"
+ }
+ [ "$trimmed" ] || {
+ last_advice "未添加 $k 变量,或变量值为空白字符,$fix_advice" "o"
+ }
+ done
+
+ # https://ss64.com/bash/mapfile.html
+ mapfile -t users < <(echo -e "$USER")
+ mapfile -t passwords < <(echo -e "$PASSWD")
+ len="$(echo -e "${#users[@]}\n${#passwords[@]}" | sort -n | tail -1)"
+ for ((i = 0; i < "$len"; i++)); do
+ [ "$(trim "${users[$i]}")" ] || {
+ last_advice "USER 变量中存在多余的换行,$fix_advice" "o"
+ }
+ [ "$(trim "${passwords[$i]}")" ] || {
+ last_advice "PASSWD 变量中存在多余的换行,$fix_advice" "o"
+ }
+ done
+}
+
+has_valid_cfg() {
+ [ -d "$CONFIG_PATH" ] || return 1
+
+ [ "$(wc 2>/dev/null -c "$CONFIG_PATH"/* |
+ tail -1 | cut -d' ' -f1 | xargs | sed 's/^$/0/')" -eq 0 ] &&
+ return 1
+
+ cfg_files=("$CONFIG_PATH"/*.json)
+ [ ${#cfg_files[@]} -eq "$(echo -e "$USER" | wc -l)" ]
+}
+
+register() {
+ (
+ cd register || exit 1
+ exit_on_error "90" "5m" "bash register_apps_by_force.sh"
+ )
+ ret=$?
+
+ fix_advice="please rerun Register APP Action."
+ has_valid_cfg ||
+ last_advice "Configuration files were not completely generated, $fix_advice"
+
+ poetry run python crypto.py e ||
+ last_advice "File encryption failed, $fix_advice"
+
+ [ $ret -ne 0 ] &&
+ last_advice "APP registration is not completely finished, $fix_advice"
+
+ exit $ret
+}
+
+invoke() {
+ has_valid_cfg ||
+ last_advice "配置文件不合法, 请执行应用注册 Action." "o"
+
+ # sleep $((RANDOM % 127))
+ fix_advice="rerun Register APP Action if this condition has occurred more \
+than 3 times."
+ poetry run python crypto.py d ||
+ last_advice "Configuration file decryption failed, $fix_advice"
+
+ (exit_on_error "25" "4m" "poetry run python task.py")
+ ret=$?
+
+ poetry run python crypto.py e ||
+ last_advice "The configure file encryption failed, $fix_advice"
+
+ [ $ret -ne 0 ] && last_advice "Invoking APIs failed, $fix_advice"
+
+ exit $ret
+}
+
+sync() {
+ action="$1"
+ message="$2"
+
+ # call windows git from wsl
+ git=git
+ command -v git.exe 1>/dev/null && git=git.exe
+
+ $git config user.name "$BOT_USER"
+ $git config user.email "$BOT_EMAIL"
+
+ [ "$action" = "pull" ] && {
+ [ -d "$CONFIG_PATH" ] && {
+ tmp_path="$(mktemp -d)"
+ mv "$CONFIG_PATH" "$tmp_path"
+ }
+
+ $git remote add upstream "$UPSTREAM"
+ $git pull upstream master 1>/dev/null 2>&1
+ $git reset --hard upstream/master
+
+ [ -z ${tmp_path+x} ] || {
+ mv "$tmp_path"/* ./
+ rm -rf "$tmp_path"
+ }
+
+ # exit 0
+ message="sync with upstream"
+ }
+
+ $git checkout --orphan latest_branch
+ $git rm -rf --cached .
+ $git add -A
+ $git commit -m "$message"
+ $git branch -D master
+ $git branch -m master
+ $git push -f origin master
+}
+
+case $1 in
+check_env | has_valid_cfg | register | invoke)
+ $1
+ ;;
+pull | push)
+ sync "$@"
+ ;;
+upg)
+ sed -i \
+ "s/\(version@\)[0-9]\+/\1$(env TZ=Asia/Shanghai date +%Y%m%d%H%M)/" \
+ README.md
+ sync push reset
+ ;;
+*)
+ echo "Not supported"
+ exit 1
+ ;;
+esac