Setup knip
This commit is contained in:
parent
a28d941ee9
commit
1d53ccfee1
@ -14,7 +14,8 @@ const config = {
|
||||
// importing commonjs modules from esmodules in storybook. As a part of
|
||||
// converting to TypeScript we should use esmodules and can eventually
|
||||
// remove this plugin
|
||||
process.env.SIGNAL_ENV === 'storybook' && '@babel/transform-runtime',
|
||||
process.env.SIGNAL_ENV === 'storybook' &&
|
||||
import.meta.resolve('@babel/plugin-transform-runtime'),
|
||||
].filter(plugin => {
|
||||
return typeof plugin === 'string';
|
||||
}),
|
||||
|
||||
15
.github/workflows/ci.yml
vendored
15
.github/workflows/ci.yml
vendored
@ -59,12 +59,20 @@ jobs:
|
||||
# environment variable
|
||||
NPM_CONFIG_NODE_GYP: echo
|
||||
|
||||
- name: Install Sticker Creator node_modules
|
||||
run: pnpm install
|
||||
working-directory: sticker-creator
|
||||
|
||||
- run: pnpm run generate
|
||||
- run: pnpm run lint
|
||||
- run: pnpm run lint-prettier
|
||||
- run: pnpm run lint-css
|
||||
- run: pnpm run check:types
|
||||
- run: pnpm run oxlint --format=github
|
||||
- run: pnpm run lint-deps
|
||||
- run: pnpm run lint-license-comments
|
||||
- run: pnpm run lint-intl
|
||||
|
||||
- run: pnpm run lint-knip:all --reporter github-actions
|
||||
- run: pnpm run lint-knip:prod --reporter github-actions
|
||||
- name: Check acknowledgments file is up to date
|
||||
run: pnpm run build:acknowledgments
|
||||
env:
|
||||
@ -358,9 +366,6 @@ jobs:
|
||||
- name: Check Sticker Creator linting
|
||||
run: pnpm run lint
|
||||
|
||||
- name: Run tests
|
||||
run: pnpm test -- --run
|
||||
|
||||
mock-tests:
|
||||
needs: lint
|
||||
|
||||
|
||||
1
.npmrc
1
.npmrc
@ -1,4 +1,5 @@
|
||||
legacy-peer-deps=true
|
||||
save-exact=true
|
||||
public-hoist-pattern[]=*eslint-*
|
||||
minimum-release-age=4320 # 3 days
|
||||
minimum-release-age-exclude[]=@signalapp/*
|
||||
|
||||
@ -621,7 +621,12 @@
|
||||
// [pedantic] Disallow inline comments after code
|
||||
"eslint/no-inline-comments": "off", // DECIDEME (errors: 333)
|
||||
// [pedantic] Disallow variable or function declarations in nested blocks
|
||||
"eslint/no-inner-declarations": "error",
|
||||
"eslint/no-inner-declarations": [
|
||||
"error",
|
||||
{
|
||||
"blockScopedFunctions": "disallow"
|
||||
}
|
||||
],
|
||||
// [pedantic] (🚧 planned autofix) Disallow if statements as the only statement in else blocks
|
||||
"eslint/no-lonely-if": "error",
|
||||
// [pedantic] Disallow function declarations that contain unsafe references inside loop statements
|
||||
@ -1658,11 +1663,12 @@
|
||||
"test/test.m",
|
||||
".babelrc.mjs",
|
||||
".prettierrc.mjs",
|
||||
".storybook/main.ts",
|
||||
".storybook/test-runner.ts",
|
||||
".stylelintrc.js",
|
||||
".stylelintrc.mjs",
|
||||
"ci.js",
|
||||
"dangerfile.js",
|
||||
"eslint-local-rules.js",
|
||||
"dangerfile.mjs",
|
||||
"knip.js",
|
||||
"preload.wrapper.ts",
|
||||
"rolldown.config.ts"
|
||||
],
|
||||
@ -1721,6 +1727,7 @@
|
||||
".stylelintrc.mjs",
|
||||
"ci.js",
|
||||
"dangerfile.mjs",
|
||||
"knip.js",
|
||||
"preload.wrapper.ts",
|
||||
"rolldown.config.ts"
|
||||
],
|
||||
@ -1746,7 +1753,7 @@
|
||||
"ts/util/lint/**",
|
||||
"ts/windows/main/*_test.*",
|
||||
"test/test.mjs",
|
||||
"dangerfile.js",
|
||||
"dangerfile.mjs",
|
||||
"preload.wrapper.ts",
|
||||
"rolldown.config.ts"
|
||||
],
|
||||
|
||||
7
.storybook/StorybookThemeContext.std.d.ts
vendored
7
.storybook/StorybookThemeContext.std.d.ts
vendored
@ -1,7 +0,0 @@
|
||||
// Copyright 2021 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import type { Context } from 'react';
|
||||
import type { ThemeType } from '../ts/types/Util.std.ts';
|
||||
|
||||
export const StorybookThemeContext: Context<ThemeType>;
|
||||
@ -68,10 +68,13 @@ const storybookConfig: StorybookConfig = {
|
||||
webpackConfig.module!.rules!.unshift({
|
||||
test: /\.scss$/,
|
||||
use: [
|
||||
{ loader: 'style-loader' },
|
||||
{ loader: 'css-loader', options: { modules: false, url: false } },
|
||||
{ loader: require.resolve('style-loader') },
|
||||
{
|
||||
loader: 'sass-loader',
|
||||
loader: require.resolve('css-loader'),
|
||||
options: { modules: false, url: false },
|
||||
},
|
||||
{
|
||||
loader: require.resolve('sass-loader'),
|
||||
options: {
|
||||
additionalData: '$is-storybook: true;',
|
||||
},
|
||||
@ -92,13 +95,11 @@ const storybookConfig: StorybookConfig = {
|
||||
test: /tailwind-config\.css$/,
|
||||
use: [
|
||||
{
|
||||
loader: 'postcss-loader',
|
||||
loader: require.resolve('postcss-loader'),
|
||||
options: {
|
||||
postcssOptions: {
|
||||
config: false,
|
||||
plugins: {
|
||||
'@tailwindcss/postcss': {},
|
||||
},
|
||||
plugins: [require.resolve('@tailwindcss/postcss')],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@ -16,7 +16,7 @@ import type { Store } from 'redux';
|
||||
import { combineReducers, createStore } from 'redux';
|
||||
import { Globals } from '@react-spring/web';
|
||||
|
||||
import { StorybookThemeContext } from './StorybookThemeContext.std.js';
|
||||
import { StorybookThemeContext } from './StorybookThemeContext.std.ts';
|
||||
import { SystemThemeType, ThemeType } from '../ts/types/Util.std.ts';
|
||||
import { setupI18n } from '../ts/util/setupI18n.dom.tsx';
|
||||
import { HourCyclePreference } from '../ts/types/I18N.std.ts';
|
||||
@ -31,7 +31,7 @@ import { parseUnknown } from '../ts/util/schemas.std.ts';
|
||||
import { LocaleEmojiListSchema } from '../ts/types/emoji.std.ts';
|
||||
import { FunProvider } from '../ts/components/fun/FunProvider.dom.tsx';
|
||||
import { EmojiSkinTone } from '../ts/components/fun/data/emojis.std.ts';
|
||||
import { MOCK_GIFS_PAGINATED_ONE_PAGE } from '../ts/components/fun/mocks.dom.tsx';
|
||||
import { MOCK_GIFS_PAGINATED_ONE_PAGE } from '../ts/test-helpers/funPickerMocks.dom.tsx';
|
||||
import { NavTab } from '../ts/types/Nav.std.ts';
|
||||
|
||||
import type { FunEmojiSelection } from '../ts/components/fun/panels/FunPanelEmojis.dom.tsx';
|
||||
|
||||
@ -1,9 +1,12 @@
|
||||
// Copyright 2023 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
// @ts-check
|
||||
// @ts-expect-error
|
||||
import githubActionsFormatter from '@csstools/stylelint-formatter-github';
|
||||
|
||||
/** @type {import('stylelint').Config} */
|
||||
const config = {
|
||||
formatter: process.env.CI ? githubActionsFormatter : undefined,
|
||||
extends: [
|
||||
'stylelint-config-recommended-scss',
|
||||
'stylelint-config-css-modules',
|
||||
|
||||
@ -155,6 +155,27 @@ Signal Desktop makes use of the following open source projects.
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
## @csstools/stylelint-formatter-github
|
||||
|
||||
MIT No Attribution (MIT-0)
|
||||
|
||||
Copyright 2023 Romain Menke, Antonio Laguna <antonio@laguna.es>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the “Software”), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so.
|
||||
|
||||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
## @electron/asar
|
||||
|
||||
Copyright (c) 2014 GitHub Inc.
|
||||
@ -229,18 +250,6 @@ Signal Desktop makes use of the following open source projects.
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
## @formatjs/fast-memoize
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2023 FormatJS
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
## @formatjs/icu-messageformat-parser
|
||||
|
||||
MIT License
|
||||
@ -1324,210 +1333,6 @@ Signal Desktop makes use of the following open source projects.
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
## @react-types/shared
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2019 Adobe
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
## @signalapp/minimask
|
||||
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
@ -4698,30 +4503,6 @@ Signal Desktop makes use of the following open source projects.
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE
|
||||
|
||||
## @types/intl-tel-input
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE
|
||||
|
||||
## @types/is-glob
|
||||
|
||||
MIT License
|
||||
@ -5058,30 +4839,6 @@ Signal Desktop makes use of the following open source projects.
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE
|
||||
|
||||
## @types/react-redux
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE
|
||||
|
||||
## @types/react-virtualized
|
||||
|
||||
MIT License
|
||||
@ -5226,30 +4983,6 @@ Signal Desktop makes use of the following open source projects.
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE
|
||||
|
||||
## @typescript-eslint/parser
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019 typescript-eslint and other contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
## @typescript-eslint/rule-tester
|
||||
|
||||
MIT License
|
||||
@ -5356,35 +5089,6 @@ Signal Desktop makes use of the following open source projects.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
## babel-core
|
||||
|
||||
License: MIT
|
||||
|
||||
## babel-loader
|
||||
|
||||
Copyright (c) 2014-2019 Luís Couto <hello@luiscouto.pt>
|
||||
|
||||
MIT License
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
## babel-plugin-lodash
|
||||
|
||||
Copyright JS Foundation and other contributors <https://js.foundation/>
|
||||
@ -6264,25 +5968,6 @@ Signal Desktop makes use of the following open source projects.
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
## encoding
|
||||
|
||||
Copyright (c) 2012-2014 Andris Reinman
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
## enhanced-resolve
|
||||
|
||||
Copyright JS Foundation and other contributors
|
||||
@ -7130,6 +6815,10 @@ Signal Desktop makes use of the following open source projects.
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
## knip
|
||||
|
||||
License: ISC
|
||||
|
||||
## linkify-it
|
||||
|
||||
Copyright (c) 2015 Vitaly Puzrin.
|
||||
@ -7442,67 +7131,6 @@ Signal Desktop makes use of the following open source projects.
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
## node-gyp
|
||||
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2012 Nathan Rajlich <nathan@tootallnate.net>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
files (the "Software"), to deal in the Software without
|
||||
restriction, including without limitation the rights to use,
|
||||
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
## node-gyp-build
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2017 Mathias Buus
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
## nop
|
||||
|
||||
Copyright (c) 2012 Ian Hansen (//github.com/supershabam)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
## normalize-path
|
||||
|
||||
The MIT License (MIT)
|
||||
@ -7527,7 +7155,7 @@ Signal Desktop makes use of the following open source projects.
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
## npm-run-all
|
||||
## npm-run-all2
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
@ -8769,30 +8397,6 @@ Signal Desktop makes use of the following open source projects.
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
## resolve-url-loader
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Ben Holloway
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
## rolldown
|
||||
|
||||
MIT License
|
||||
|
||||
@ -2,22 +2,37 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
// @ts-check
|
||||
|
||||
/** @type {typeof import("danger").danger} */
|
||||
/**
|
||||
* @type {typeof import("danger").danger}
|
||||
* @public
|
||||
*/
|
||||
// @ts-expect-error
|
||||
export const danger = globalThis.danger;
|
||||
|
||||
/** @type {typeof import("danger").warn} */
|
||||
/**
|
||||
* @type {typeof import("danger").warn}
|
||||
* @public
|
||||
*/
|
||||
// @ts-expect-error
|
||||
export const warn = globalThis.warn;
|
||||
|
||||
/** @type {typeof import("danger").fail} */
|
||||
/**
|
||||
* @type {typeof import("danger").fail}
|
||||
* @public
|
||||
*/
|
||||
// @ts-expect-error
|
||||
export const fail = globalThis.fail;
|
||||
|
||||
/** @type {typeof import("danger").message} */
|
||||
/**
|
||||
* @type {typeof import("danger").message}
|
||||
* @public
|
||||
*/
|
||||
// @ts-expect-error
|
||||
export const message = globalThis.message;
|
||||
|
||||
/** @type {typeof import("danger").markdown} */
|
||||
/**
|
||||
* @type {typeof import("danger").markdown}
|
||||
* @public
|
||||
*/
|
||||
// @ts-expect-error
|
||||
export const markdown = globalThis.markdown;
|
||||
|
||||
@ -1,14 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Copyright 2022 Signal Messenger, LLC
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
if [ -f ./node_modules/.bin/danger ]; then
|
||||
echo "Running with ./node_modules/.bin/danger"
|
||||
./node_modules/.bin/danger $@
|
||||
elif [ -f ./danger/node_modules/.bin/danger ]; then
|
||||
echo "Running with ./danger/node_modules/.bin/danger"
|
||||
./danger/node_modules/.bin/danger $@
|
||||
else
|
||||
echo "Danger not found, did you run yarn in either the root or danger/ dir?"
|
||||
exit 1
|
||||
fi
|
||||
@ -1,5 +1,9 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"scripts": {
|
||||
"danger:local": "npx --no danger local --dangerfile ../dangerfile.mjs --base main",
|
||||
"danger:ci": "npx --no danger ci --dangerfile ../dangerfile.mjs --base origin/main"
|
||||
},
|
||||
"devDependencies": {
|
||||
"danger": "13.0.7",
|
||||
"js-yaml": "4.1.1",
|
||||
"semver": "7.7.4"
|
||||
|
||||
2
danger/pnpm-lock.yaml
generated
2
danger/pnpm-lock.yaml
generated
@ -7,7 +7,7 @@ settings:
|
||||
importers:
|
||||
|
||||
.:
|
||||
dependencies:
|
||||
devDependencies:
|
||||
danger:
|
||||
specifier: 13.0.7
|
||||
version: 13.0.7
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 340 B |
124
knip.js
Normal file
124
knip.js
Normal file
@ -0,0 +1,124 @@
|
||||
// Copyright 2026 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
// @ts-check
|
||||
|
||||
const PROD_ONLY =
|
||||
process.argv.includes('--production') || process.argv.includes('--strict');
|
||||
|
||||
/** @type {import('knip').KnipConfig} */
|
||||
const config = {
|
||||
tags: ['-@knipignore', ...(PROD_ONLY ? ['-@testexport'] : [])],
|
||||
treatConfigHintsAsErrors: true,
|
||||
ignoreExportsUsedInFile: PROD_ONLY
|
||||
? true
|
||||
: {
|
||||
type: true,
|
||||
interface: true,
|
||||
enum: true,
|
||||
member: true,
|
||||
},
|
||||
exclude: ['types'],
|
||||
ignoreIssues: {
|
||||
'ts/axo/**/*.{ts,tsx}': ['namespaceMembers'],
|
||||
},
|
||||
workspaces: {
|
||||
'.': {
|
||||
entry: [
|
||||
// Main
|
||||
'app/config.main.ts!',
|
||||
// Preload
|
||||
'ts/windows/about/preload.preload.ts!',
|
||||
'ts/windows/calldiagnostic/preload.preload.ts!',
|
||||
'ts/windows/debuglog/preload.preload.ts!',
|
||||
'ts/windows/loading/preload.preload.ts!',
|
||||
'ts/windows/permissions/preload.preload.ts!',
|
||||
'ts/windows/screenShare/preload.preload.ts!',
|
||||
'ts/windows/sticker-creator/preload.preload.ts!',
|
||||
// DOM
|
||||
'ts/windows/about/app.dom.tsx!',
|
||||
'ts/windows/calldiagnostic/app.dom.tsx!',
|
||||
'ts/windows/debuglog/app.dom.tsx!',
|
||||
'ts/windows/loading/start.dom.ts!',
|
||||
'ts/windows/permissions/app.dom.tsx!',
|
||||
'ts/windows/screenShare/app.dom.tsx!',
|
||||
// Others
|
||||
'codemods/**/*.mjs',
|
||||
'scripts/**/*.mjs',
|
||||
],
|
||||
project: [
|
||||
// Production
|
||||
'ts/**/*.{ts,tsx}!',
|
||||
'!ts/**/*.stories.{ts,tsx}!',
|
||||
'!ts/storybook/**/*.{ts,tsx}!',
|
||||
'!ts/test-electron/**/*.{ts,tsx}!',
|
||||
'!ts/test-helpers/**/*.{ts,tsx}!',
|
||||
'!ts/test-mock/**/*.{ts,tsx}!',
|
||||
'!ts/test-node/**/*.{ts,tsx}!',
|
||||
'!ts/util/lint/**/*.{ts,tsx}!',
|
||||
'app/**/*.{ts,tsx}!',
|
||||
|
||||
// Development
|
||||
'ts/**/*.d.ts',
|
||||
'ts/util/lint/**/*.{ts,tsx}',
|
||||
'test/**/*.mjs',
|
||||
'scripts/**/*.mjs',
|
||||
'codemods/**/*.mjs',
|
||||
|
||||
// exclude workspaces
|
||||
'!danger/**/*.mjs',
|
||||
],
|
||||
ignoreDependencies: [
|
||||
'buffer', // same name as builtin
|
||||
'url', // same name as builtin
|
||||
'danger', // turn into real workspace
|
||||
'emoji-datasource-apple', // storybook plugin doesn't understand staticDirs
|
||||
],
|
||||
ignoreFiles: [
|
||||
'ts/components/Profiler.dom.tsx',
|
||||
...(PROD_ONLY ? ['ts/axo/AxoAvatar.dom.tsx'] : []),
|
||||
],
|
||||
ignoreBinaries: ['cwebp', ...(PROD_ONLY ? ['electron'] : [])],
|
||||
storybook: {
|
||||
entry: [
|
||||
'.storybook/main.ts',
|
||||
'.storybook/preview.tsx',
|
||||
'.storybook/test-runner.ts',
|
||||
'ts/**/*.stories.{ts,tsx}',
|
||||
],
|
||||
},
|
||||
mocha: {
|
||||
entry: [
|
||||
'.mocharc.json',
|
||||
'ts/test-electron/**/*.{ts,tsx}',
|
||||
'ts/test-helpers/**/*.{ts,tsx}',
|
||||
'ts/test-mock/**/*.{ts,tsx}',
|
||||
'ts/test-node/**/*.{ts,tsx}',
|
||||
],
|
||||
},
|
||||
oxlint: {
|
||||
entry: ['.oxlintrc.json', '.oxlint/plugins.mjs'],
|
||||
project: ['.oxlint/rules/**/*.mjs'],
|
||||
},
|
||||
danger: {
|
||||
entry: ['dangerfile.mjs'],
|
||||
project: ['danger/**/*.mjs'],
|
||||
},
|
||||
},
|
||||
danger: {
|
||||
project: ['danger-exports.mjs', 'rules/**/*.mjs'],
|
||||
},
|
||||
'packages/mute-state-change': {
|
||||
ignoreBinaries: ['xcrun'],
|
||||
ignoreDependencies: ['node-addon-api'],
|
||||
},
|
||||
'sticker-creator': {
|
||||
project: [
|
||||
'src/**/*.{ts,tsx}!',
|
||||
'src/util/protos.js!',
|
||||
'!src/**/*.test.{ts,tsx}!',
|
||||
],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default config;
|
||||
26
package.json
26
package.json
@ -52,14 +52,18 @@
|
||||
"test-oxlint": "mocha --require .oxlint/test-setup.mjs .oxlint/rules/**/*.test.mjs",
|
||||
"test-lint-intl": "tsx ./build/intl-linter/linter.node.ts --test",
|
||||
"oxlint": "oxlint",
|
||||
"lint": "run-p --aggregate-output --print-label lint-prettier lint-css check:types oxlint",
|
||||
"lint": "run-p --aggregate-output --print-label lint-prettier lint-css check:types oxlint lint-knip",
|
||||
"lint-deps": "tsx ts/util/lint/linter.node.ts",
|
||||
"lint-deps:sort": "tsx ts/util/lint/sort_exceptions.node.ts",
|
||||
"lint-license-comments": "tsx ts/util/lint/license_comments.node.ts",
|
||||
"lint-prettier": "pprettier --check '**/*.{ts,tsx,d.ts,js,json,html,scss,md,yml,yaml}' '!node_modules/**'",
|
||||
"lint-intl": "tsx ./build/intl-linter/linter.node.ts",
|
||||
"lint-css": "stylelint '**/*.scss' --cache",
|
||||
"danger:local": "./danger/danger.sh local --base main",
|
||||
"danger:ci": "./danger/danger.sh ci --base origin/main",
|
||||
"lint-knip": "pnpm run lint-knip:all && pnpm run lint-knip:prod",
|
||||
"lint-knip:all": "knip --cache",
|
||||
"lint-knip:prod": "knip --production --cache",
|
||||
"danger:local": "cd danger && npm run danger:local",
|
||||
"danger:ci": "cd danger && npm run danger:ci",
|
||||
"format": "pprettier --write '**/*.{ts,tsx,d.ts,js,json,html,scss,md,yml,yaml}' '!node_modules/**'",
|
||||
"svgo": "svgo --multipass images/**/*.svg images/*.svg",
|
||||
"transpile": "run-p check:types build:rolldown",
|
||||
@ -131,11 +135,11 @@
|
||||
"@babel/plugin-transform-typescript": "7.28.6",
|
||||
"@babel/preset-react": "7.28.5",
|
||||
"@babel/preset-typescript": "7.28.5",
|
||||
"@csstools/stylelint-formatter-github": "2.0.0",
|
||||
"@electron/asar": "3.4.1",
|
||||
"@electron/fuses": "1.5.0",
|
||||
"@electron/notarize": "2.1.0",
|
||||
"@electron/symbolicate-mac": "2.3.1",
|
||||
"@formatjs/fast-memoize": "3.1.1",
|
||||
"@formatjs/icu-messageformat-parser": "3.5.3",
|
||||
"@formatjs/intl": "4.1.4",
|
||||
"@formatjs/intl-localematcher": "0.2.32",
|
||||
@ -152,7 +156,6 @@
|
||||
"@react-aria/interactions": "3.27.1",
|
||||
"@react-aria/utils": "3.33.1",
|
||||
"@react-spring/web": "10.0.3",
|
||||
"@react-types/shared": "3.33.1",
|
||||
"@signalapp/minimask": "1.0.1",
|
||||
"@signalapp/mock-server": "21.0.1",
|
||||
"@signalapp/quill-cjs": "2.1.2",
|
||||
@ -186,7 +189,6 @@
|
||||
"@types/fs-extra": "11.0.4",
|
||||
"@types/google-libphonenumber": "7.4.30",
|
||||
"@types/humanize-duration": "3.27.4",
|
||||
"@types/intl-tel-input": "18.1.4",
|
||||
"@types/is-glob": "4.0.4",
|
||||
"@types/js-yaml": "4.0.9",
|
||||
"@types/json-to-ast": "2.1.4",
|
||||
@ -201,19 +203,15 @@
|
||||
"@types/pngjs": "6.0.5",
|
||||
"@types/react": "19.2.14",
|
||||
"@types/react-dom": "19.2.3",
|
||||
"@types/react-redux": "7.1.34",
|
||||
"@types/react-virtualized": "9.22.3",
|
||||
"@types/redux-logger": "3.0.13",
|
||||
"@types/semver": "7.7.1",
|
||||
"@types/sinon": "21.0.0",
|
||||
"@types/split2": "4.2.3",
|
||||
"@types/write-file-atomic": "4.0.3",
|
||||
"@typescript-eslint/parser": "8.58.0",
|
||||
"@typescript-eslint/rule-tester": "8.58.0",
|
||||
"@typescript-eslint/utils": "8.58.0",
|
||||
"@typescript/native-preview": "7.0.0-dev.20260303.1",
|
||||
"babel-core": "7.0.0-bridge.0",
|
||||
"babel-loader": "9.2.1",
|
||||
"babel-plugin-lodash": "3.3.4",
|
||||
"better-blockmap": "2.0.1",
|
||||
"blob-util": "2.0.2",
|
||||
@ -244,7 +242,6 @@
|
||||
"electron-mocha": "13.1.0",
|
||||
"emoji-datasource-apple": "16.0.0",
|
||||
"emoji-regex": "10.6.0",
|
||||
"encoding": "0.1.13",
|
||||
"enhanced-resolve": "5.20.1",
|
||||
"enquirer": "2.4.1",
|
||||
"eslint": "10.1.0",
|
||||
@ -267,6 +264,7 @@
|
||||
"is-glob": "4.0.3",
|
||||
"js-yaml": "4.1.1",
|
||||
"json-to-ast": "2.1.0",
|
||||
"knip": "6.3.0",
|
||||
"linkify-it": "5.0.0",
|
||||
"lodash": "4.17.23",
|
||||
"log-symbols": "7.0.1",
|
||||
@ -278,11 +276,8 @@
|
||||
"motion": "12.38.0",
|
||||
"mp4box": "0.5.3",
|
||||
"node-fetch": "3.3.2",
|
||||
"node-gyp": "11.0.0",
|
||||
"node-gyp-build": "4.8.4",
|
||||
"nop": "1.0.0",
|
||||
"normalize-path": "3.0.0",
|
||||
"npm-run-all": "4.1.5",
|
||||
"npm-run-all2": "8.0.4",
|
||||
"oxc-transform": "0.123.0",
|
||||
"oxlint": "1.57.0",
|
||||
"oxlint-tsgolint": "0.17.4",
|
||||
@ -318,7 +313,6 @@
|
||||
"redux-promise-middleware": "6.2.0",
|
||||
"redux-thunk": "3.1.0",
|
||||
"reselect": "5.1.1",
|
||||
"resolve-url-loader": "5.0.0",
|
||||
"rolldown": "1.0.0-rc.13",
|
||||
"sass": "1.98.0",
|
||||
"sass-loader": "16.0.7",
|
||||
|
||||
1679
pnpm-lock.yaml
generated
1679
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -221,32 +221,6 @@ for (const dep of upgradeableDeps) {
|
||||
{ stdio: 'inherit' }
|
||||
);
|
||||
|
||||
// oxlint-disable-next-line no-constant-condition
|
||||
while (true) {
|
||||
try {
|
||||
// oxlint-disable-next-line no-await-in-loop
|
||||
await execa(
|
||||
'npx',
|
||||
['patch-package', '--error-on-fail', '--error-on-warn'],
|
||||
{ stdio: 'inherit' }
|
||||
);
|
||||
break;
|
||||
} catch {
|
||||
/** @type {{ retry: boolean }} */
|
||||
// oxlint-disable-next-line no-await-in-loop
|
||||
const { retry } = await enquirer.prompt({
|
||||
type: 'confirm',
|
||||
name: 'retry',
|
||||
message: 'Retry patch-package?',
|
||||
initial: true,
|
||||
});
|
||||
|
||||
if (!retry) {
|
||||
throw new Error('Failed to apply patch-package');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** @type {{ npmScriptsToRun: Array<string> }} */
|
||||
// oxlint-disable-next-line no-await-in-loop
|
||||
const { npmScriptsToRun } = await enquirer.prompt({
|
||||
|
||||
@ -18,24 +18,17 @@
|
||||
"eslint": "eslint --cache .",
|
||||
"prettier:format": "prettier --list-different --cache --write .",
|
||||
"prettier:check": "prettier --cache --check .",
|
||||
"build:protos": "protopiler --output src/util/protos.js --typedefs src/util/protos.d.ts ./protos",
|
||||
"test": "vitest"
|
||||
"build:protos": "protopiler --output src/util/protos.js --typedefs src/util/protos.d.ts ./protos"
|
||||
},
|
||||
"dependencies": {
|
||||
"@formatjs/fast-memoize": "1.2.8",
|
||||
"@indutny/emoji-picker-react": "4.10.1",
|
||||
"@indutny/protopiler": "4.0.0",
|
||||
"@popperjs/core": "2.11.8",
|
||||
"@react-aria/interactions": "3.19.0",
|
||||
"@reduxjs/toolkit": "1.9.5",
|
||||
"@stablelib/x25519": "1.0.3",
|
||||
"base64-js": "1.5.1",
|
||||
"classnames": "2.3.2",
|
||||
"debug": "4.3.4",
|
||||
"focus-trap-react": "10.1.1",
|
||||
"memoizee": "0.4.15",
|
||||
"npm-run-all": "4.1.5",
|
||||
"qrcode-generator": "1.4.4",
|
||||
"react": "18.3.1",
|
||||
"react-dom": "18.3.1",
|
||||
"react-dropzone": "14.2.3",
|
||||
@ -46,31 +39,25 @@
|
||||
"react-sortablejs": "6.1.4",
|
||||
"redux": "4.2.1",
|
||||
"reselect": "4.1.8",
|
||||
"sortablejs": "1.15.0",
|
||||
"zod": "3.22.3"
|
||||
"sortablejs": "1.15.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/debug": "4.1.7",
|
||||
"@types/lodash": "4.14.194",
|
||||
"@types/memoizee": "0.4.8",
|
||||
"@types/react": "18.3.20",
|
||||
"@types/react-dom": "18.3.6",
|
||||
"@types/sortablejs": "1.15.1",
|
||||
"@typescript-eslint/eslint-plugin": "5.59.0",
|
||||
"@typescript-eslint/parser": "5.59.0",
|
||||
"@vitejs/plugin-react": "3.1.0",
|
||||
"emoji-datasource-apple": "16.0.0",
|
||||
"eslint": "8.38.0",
|
||||
"eslint-config-airbnb-typescript-prettier": "5.0.0",
|
||||
"eslint-config-prettier": "8.8.0",
|
||||
"eslint-plugin-react": "7.32.2",
|
||||
"happy-dom": "8.9.0",
|
||||
"npm-run-all2": "8.0.4",
|
||||
"prettier": "2.8.7",
|
||||
"rollup-plugin-visualizer": "5.9.0",
|
||||
"sass": "1.62.0",
|
||||
"typescript": "5.0.4",
|
||||
"vite": "4.5.3",
|
||||
"vitest": "0.30.1"
|
||||
"vite": "4.5.3"
|
||||
},
|
||||
"pnpm": {
|
||||
"onlyBuiltDependencies": [
|
||||
|
||||
1077
sticker-creator/pnpm-lock.yaml
generated
1077
sticker-creator/pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -1,20 +0,0 @@
|
||||
// Copyright 2022 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
syntax = "proto3";
|
||||
|
||||
option go_package = "internal/pkg/messages";
|
||||
|
||||
message ProvisioningToken {
|
||||
optional string token = 1;
|
||||
}
|
||||
|
||||
message ProvisioningEnvelope {
|
||||
optional bytes publicKey = 1;
|
||||
optional bytes ciphertext = 2;
|
||||
}
|
||||
|
||||
message ProvisioningMessage {
|
||||
optional string username = 1;
|
||||
optional string password = 2;
|
||||
}
|
||||
@ -8,8 +8,6 @@ import styles from './ConfirmModal.module.scss';
|
||||
import type { Props } from '../elements/ConfirmDialog';
|
||||
import { ConfirmDialog } from '../elements/ConfirmDialog';
|
||||
|
||||
export type Mode = 'removable' | 'pick-emoji' | 'add';
|
||||
|
||||
export function ConfirmModal(props: Props): React.JSX.Element {
|
||||
const { onCancel } = props;
|
||||
const ref = useRef<HTMLDivElement>(null);
|
||||
|
||||
@ -1,9 +0,0 @@
|
||||
// Copyright 2022 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
@import '../colors.scss';
|
||||
|
||||
.code {
|
||||
width: 100%;
|
||||
max-width: 500px;
|
||||
}
|
||||
@ -1,30 +0,0 @@
|
||||
// Copyright 2022 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import React, { useMemo } from 'react';
|
||||
import qrcode from 'qrcode-generator';
|
||||
|
||||
import styles from './QrCode.module.scss';
|
||||
|
||||
const AUTODETECT_TYPE_NUMBER = 0;
|
||||
const ERROR_CORRECTION_LEVEL = 'L';
|
||||
|
||||
type PropsType = Readonly<{
|
||||
alt: string;
|
||||
data: string;
|
||||
}>;
|
||||
|
||||
export function QrCode(props: PropsType): React.JSX.Element {
|
||||
const { alt, data } = props;
|
||||
|
||||
const src = useMemo(() => {
|
||||
const qrCode = qrcode(AUTODETECT_TYPE_NUMBER, ERROR_CORRECTION_LEVEL);
|
||||
qrCode.addData(data);
|
||||
qrCode.make();
|
||||
|
||||
const svgData = qrCode.createSvgTag({ cellSize: 1, margin: 0 });
|
||||
return `data:image/svg+xml;utf8,${svgData}`;
|
||||
}, [data]);
|
||||
|
||||
return <img alt={alt} className={styles.code} src={src} />;
|
||||
}
|
||||
@ -7,9 +7,6 @@ export const MIN_STICKERS = 1;
|
||||
export const MAX_STICKERS = 200;
|
||||
export const MAX_STICKER_BYTE_SIZE = 300 * 1024;
|
||||
|
||||
export const SECOND = 1000;
|
||||
export const MINUTE = 60 * SECOND;
|
||||
|
||||
export enum ArtType {
|
||||
Sticker = 'sticker',
|
||||
}
|
||||
|
||||
@ -1,31 +0,0 @@
|
||||
// Copyright 2023 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
.base {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.left {
|
||||
composes: base;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
.right {
|
||||
composes: base;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.top {
|
||||
composes: base;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.bottom {
|
||||
composes: base;
|
||||
align-items: flex-end;
|
||||
}
|
||||
@ -1,39 +0,0 @@
|
||||
// Copyright 2023 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import React from 'react';
|
||||
import styles from './StoryRow.module.scss';
|
||||
|
||||
type Props = {
|
||||
left?: boolean;
|
||||
right?: boolean;
|
||||
top?: boolean;
|
||||
bottom?: boolean;
|
||||
};
|
||||
|
||||
const getClassName = ({ left, right, top, bottom }: Props) => {
|
||||
if (left) {
|
||||
return styles.left;
|
||||
}
|
||||
|
||||
if (right) {
|
||||
return styles.right;
|
||||
}
|
||||
|
||||
if (top) {
|
||||
return styles.top;
|
||||
}
|
||||
|
||||
if (bottom) {
|
||||
return styles.bottom;
|
||||
}
|
||||
|
||||
return styles.base;
|
||||
};
|
||||
|
||||
export function StoryRow({
|
||||
children,
|
||||
...props
|
||||
}: React.PropsWithChildren<Props>): React.JSX.Element {
|
||||
return <div className={getClassName(props)}>{children}</div>;
|
||||
}
|
||||
@ -1,8 +0,0 @@
|
||||
// Copyright 2021 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { useMemo } from 'react';
|
||||
import { createRefMerger } from '../util/refMerger';
|
||||
|
||||
export const useRefMerger = (): ReturnType<typeof createRefMerger> =>
|
||||
useMemo(createRefMerger, []);
|
||||
@ -15,7 +15,6 @@ import {
|
||||
import './index.scss';
|
||||
import { store } from './store';
|
||||
import { Root } from './routes/Root';
|
||||
// import { Index } from './routes/Index';
|
||||
import { createArtRoutes } from './routes/art';
|
||||
import { loadLocale } from './util/i18n';
|
||||
|
||||
|
||||
@ -1,9 +0,0 @@
|
||||
// Copyright 2022 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
.container {
|
||||
padding: 1rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
}
|
||||
@ -1,24 +0,0 @@
|
||||
// Copyright 2022 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import React from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
import { useI18n } from '../contexts/I18n';
|
||||
import styles from './Index.module.scss';
|
||||
|
||||
export function Index(): React.JSX.Element {
|
||||
const i18n = useI18n();
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className={styles.container}>
|
||||
<Link to="/art/?artType=sticker">
|
||||
{i18n('index--create-sticker-pack')}
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
<footer />
|
||||
</>
|
||||
);
|
||||
}
|
||||
@ -78,14 +78,6 @@ export const usePackUrl = (): string => useSelector(selectUrl);
|
||||
export const useToasts = (): ReadonlyArray<StateToastData> =>
|
||||
useSelector(({ art }: RootState) => art.toasts);
|
||||
|
||||
export const useAddMoreCount = (): number =>
|
||||
useSelector(({ art }: RootState) => {
|
||||
assert(art.artType === ArtType.Sticker, 'Unexpected art type');
|
||||
const min = MIN_STICKERS;
|
||||
|
||||
return Math.min(Math.max(min - art.order.length, 0), min);
|
||||
});
|
||||
|
||||
const selectOrderedData = createSelector(
|
||||
({ art }: RootState) => art.order,
|
||||
({ art }: RootState) => art.data,
|
||||
|
||||
@ -1,10 +0,0 @@
|
||||
// Copyright 2022 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { useSelector } from 'react-redux';
|
||||
|
||||
import type { RootState } from '../store';
|
||||
import type { Credentials } from '../types.d';
|
||||
|
||||
export const useCredentials = (): Credentials | undefined =>
|
||||
useSelector(({ credentials }: RootState) => credentials.credentials);
|
||||
@ -71,7 +71,7 @@ const adjustCover = (state: Draft<ArtState>) => {
|
||||
}
|
||||
};
|
||||
|
||||
export const artSlice = createSlice({
|
||||
const artSlice = createSlice({
|
||||
name: 'art',
|
||||
initialState,
|
||||
reducers: {
|
||||
|
||||
@ -15,7 +15,7 @@ const initialState: CredentialsState = {
|
||||
credentials: undefined,
|
||||
};
|
||||
|
||||
export const credentialsSlice = createSlice({
|
||||
const credentialsSlice = createSlice({
|
||||
name: 'credentials',
|
||||
initialState,
|
||||
reducers: {
|
||||
@ -28,5 +28,4 @@ export const credentialsSlice = createSlice({
|
||||
},
|
||||
});
|
||||
|
||||
export const { setCredentials } = credentialsSlice.actions;
|
||||
export default credentialsSlice.reducer;
|
||||
|
||||
@ -21,4 +21,3 @@ export const store = configureStore({
|
||||
});
|
||||
|
||||
export type RootState = ReturnType<typeof store.getState>;
|
||||
export type AppDispatch = typeof store.dispatch;
|
||||
|
||||
@ -1,21 +0,0 @@
|
||||
// Copyright 2022 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
export function isUnsupported(): boolean {
|
||||
const subtle = window.crypto?.subtle;
|
||||
if (!subtle) {
|
||||
return true;
|
||||
}
|
||||
if (
|
||||
!subtle.importKey ||
|
||||
!subtle.deriveBits ||
|
||||
!subtle.sign ||
|
||||
!subtle.encrypt
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
if (!window.crypto.getRandomValues) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -1,8 +1,6 @@
|
||||
// Copyright 2022 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import b64 from 'base64-js';
|
||||
|
||||
import type {
|
||||
Manifest,
|
||||
AnnotatedImage,
|
||||
@ -28,8 +26,6 @@ const PACK_KEY_STICKER_INFO = encoder.encode('Sticker Pack');
|
||||
const PACK_KEY_AES_KEY_SIZE = 32;
|
||||
const PACK_KEY_MAC_KEY_SIZE = 32;
|
||||
const IV_SIZE = 16;
|
||||
const MAC_SIZE = 32;
|
||||
const RANDOM_STRING_SIZE = 32;
|
||||
|
||||
const BITS_PER_BYTE = 8;
|
||||
|
||||
@ -49,7 +45,7 @@ export type DeriveKeysOptions = Readonly<{
|
||||
secret: Uint8Array;
|
||||
}>;
|
||||
|
||||
export async function deriveKeys({
|
||||
async function deriveKeys({
|
||||
info,
|
||||
secret,
|
||||
}: DeriveKeysOptions): Promise<EncryptAttachmentKeys> {
|
||||
@ -180,7 +176,7 @@ export async function encrypt({
|
||||
};
|
||||
}
|
||||
|
||||
export async function encryptAttachment(
|
||||
async function encryptAttachment(
|
||||
plaintext: Uint8Array,
|
||||
{ aesKey, macKey }: EncryptAttachmentKeys
|
||||
): Promise<Uint8Array> {
|
||||
@ -212,50 +208,3 @@ export async function encryptAttachment(
|
||||
|
||||
return new Uint8Array([...ivAndCiphertext, ...mac]);
|
||||
}
|
||||
|
||||
export async function decryptAttachment(
|
||||
data: Uint8Array,
|
||||
{ aesKey, macKey }: EncryptAttachmentKeys
|
||||
): Promise<Uint8Array> {
|
||||
if (data.length < IV_SIZE + MAC_SIZE) {
|
||||
throw new Error('Attachment is too small');
|
||||
}
|
||||
|
||||
const ivAndCipherText = data.slice(0, -MAC_SIZE);
|
||||
const mac = data.slice(-MAC_SIZE);
|
||||
|
||||
const isValid = await crypto.subtle.verify(
|
||||
{
|
||||
name: 'HMAC',
|
||||
},
|
||||
macKey,
|
||||
mac,
|
||||
ivAndCipherText
|
||||
);
|
||||
|
||||
if (!isValid) {
|
||||
throw new Error('Invalid mac');
|
||||
}
|
||||
|
||||
const iv = ivAndCipherText.slice(0, IV_SIZE);
|
||||
const ciphertext = ivAndCipherText.slice(IV_SIZE);
|
||||
|
||||
const plaintext = new Uint8Array(
|
||||
await crypto.subtle.decrypt(
|
||||
{
|
||||
name: 'AES-CBC',
|
||||
iv,
|
||||
},
|
||||
aesKey,
|
||||
ciphertext
|
||||
)
|
||||
);
|
||||
|
||||
return plaintext;
|
||||
}
|
||||
|
||||
export function getRandomString(): string {
|
||||
const source = new Uint8Array(RANDOM_STRING_SIZE);
|
||||
crypto.getRandomValues(source);
|
||||
return b64.fromByteArray(source);
|
||||
}
|
||||
|
||||
@ -1,72 +0,0 @@
|
||||
// Copyright 2022 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import type { RefObject } from 'react';
|
||||
|
||||
export type ClickHandlerType = (target: Node) => boolean;
|
||||
export type ContainerElementType = Node | RefObject<Node> | null | undefined;
|
||||
|
||||
// TODO(indutny): DESKTOP-4177
|
||||
// A stack of handlers. Handlers are executed from the top to the bottom
|
||||
const fakeClickHandlers = new Array<{
|
||||
name: string;
|
||||
handleEvent: (event: MouseEvent) => boolean;
|
||||
}>();
|
||||
|
||||
function runFakeClickHandlers(event: MouseEvent): void {
|
||||
for (const entry of fakeClickHandlers.slice().reverse()) {
|
||||
const { handleEvent } = entry;
|
||||
if (handleEvent(event)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export type HandleOutsideClickOptionsType = Readonly<{
|
||||
name: string;
|
||||
containerElements: ReadonlyArray<ContainerElementType>;
|
||||
}>;
|
||||
|
||||
export const handleOutsideClick = (
|
||||
handler: ClickHandlerType,
|
||||
{ name, containerElements }: HandleOutsideClickOptionsType
|
||||
): (() => void) => {
|
||||
const handleEvent = (event: MouseEvent) => {
|
||||
const target = event.target as Node;
|
||||
|
||||
const isInside = containerElements.some(elem => {
|
||||
if (!elem) {
|
||||
return false;
|
||||
}
|
||||
if (elem instanceof Node) {
|
||||
return elem.contains(target);
|
||||
}
|
||||
return elem.current?.contains(target);
|
||||
});
|
||||
|
||||
// Clicked inside of one of container elements - stop processing
|
||||
if (isInside) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Stop processing if requested by handler function
|
||||
return handler(target);
|
||||
};
|
||||
|
||||
const fakeHandler = { name, handleEvent };
|
||||
fakeClickHandlers.push(fakeHandler);
|
||||
if (fakeClickHandlers.length === 1) {
|
||||
const useCapture = true;
|
||||
document.addEventListener('click', runFakeClickHandlers, useCapture);
|
||||
}
|
||||
|
||||
return () => {
|
||||
const index = fakeClickHandlers.indexOf(fakeHandler);
|
||||
fakeClickHandlers.splice(index, 1);
|
||||
|
||||
if (fakeClickHandlers.length === 0) {
|
||||
const useCapture = true;
|
||||
document.removeEventListener('click', runFakeClickHandlers, useCapture);
|
||||
}
|
||||
};
|
||||
};
|
||||
@ -1,7 +1,6 @@
|
||||
// Copyright 2022 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import memoize from '@formatjs/fast-memoize';
|
||||
import type { IntlShape } from 'react-intl';
|
||||
import { createIntl, createIntlCache } from 'react-intl';
|
||||
import createDebug from 'debug';
|
||||
@ -16,21 +15,7 @@ import { assert } from './assert';
|
||||
|
||||
const debug = createDebug('signal:i18n');
|
||||
|
||||
export const formatters = {
|
||||
getNumberFormat: memoize((locale, opts) => {
|
||||
return new Intl.NumberFormat(locale, opts);
|
||||
}),
|
||||
getDateTimeFormat: memoize((locale, opts) => {
|
||||
return new Intl.DateTimeFormat(locale, opts);
|
||||
}),
|
||||
getPluralRules: memoize((locale, opts) => {
|
||||
return new Intl.PluralRules(locale, opts);
|
||||
}),
|
||||
};
|
||||
|
||||
export function isLocaleMessageType(
|
||||
value: unknown
|
||||
): value is LocaleMessageType {
|
||||
function isLocaleMessageType(value: unknown): value is LocaleMessageType {
|
||||
return (
|
||||
typeof value === 'object' &&
|
||||
value != null &&
|
||||
|
||||
46
sticker-creator/src/util/protos.d.ts
vendored
46
sticker-creator/src/util/protos.d.ts
vendored
@ -6,52 +6,6 @@ type $Oneof<Variants extends Record<string, unknown>> = {
|
||||
[PartialKey in Exclude<keyof Variants, Key>]?: never;
|
||||
};
|
||||
}[keyof Variants];
|
||||
export namespace ProvisioningToken {
|
||||
export function decode(
|
||||
data: Uint8Array<ArrayBuffer>,
|
||||
): ProvisioningToken;
|
||||
export function encode(data: Params): Uint8Array<ArrayBuffer>;
|
||||
export type Params = {
|
||||
$unknown?: Array<Uint8Array<ArrayBuffer>> | null;
|
||||
token: string | null;
|
||||
};
|
||||
}
|
||||
export type ProvisioningToken = {
|
||||
$unknown: Array<Uint8Array<ArrayBuffer>>;
|
||||
token: string | null;
|
||||
};
|
||||
export namespace ProvisioningEnvelope {
|
||||
export function decode(
|
||||
data: Uint8Array<ArrayBuffer>,
|
||||
): ProvisioningEnvelope;
|
||||
export function encode(data: Params): Uint8Array<ArrayBuffer>;
|
||||
export type Params = {
|
||||
$unknown?: Array<Uint8Array<ArrayBuffer>> | null;
|
||||
publicKey: Uint8Array<ArrayBuffer> | null;
|
||||
ciphertext: Uint8Array<ArrayBuffer> | null;
|
||||
};
|
||||
}
|
||||
export type ProvisioningEnvelope = {
|
||||
$unknown: Array<Uint8Array<ArrayBuffer>>;
|
||||
publicKey: Uint8Array<ArrayBuffer> | null;
|
||||
ciphertext: Uint8Array<ArrayBuffer> | null;
|
||||
};
|
||||
export namespace ProvisioningMessage {
|
||||
export function decode(
|
||||
data: Uint8Array<ArrayBuffer>,
|
||||
): ProvisioningMessage;
|
||||
export function encode(data: Params): Uint8Array<ArrayBuffer>;
|
||||
export type Params = {
|
||||
$unknown?: Array<Uint8Array<ArrayBuffer>> | null;
|
||||
username: string | null;
|
||||
password: string | null;
|
||||
};
|
||||
}
|
||||
export type ProvisioningMessage = {
|
||||
$unknown: Array<Uint8Array<ArrayBuffer>>;
|
||||
username: string | null;
|
||||
password: string | null;
|
||||
};
|
||||
export namespace StickerPack {
|
||||
export namespace Sticker {
|
||||
export function decode(
|
||||
|
||||
@ -2,137 +2,8 @@ import {
|
||||
encode as $encode, decode as $decode,
|
||||
} from '@indutny/protopiler';
|
||||
const $EMPTY_BYTES = new Uint8Array(0);
|
||||
const ProvisioningToken$SPEC = [112];
|
||||
const ProvisioningEnvelope$SPEC = [96,96];
|
||||
const ProvisioningMessage$SPEC = [112,112];
|
||||
const StickerPack_Sticker$SPEC = [33,112];
|
||||
const StickerPack$SPEC = [112,112,128,128];
|
||||
export const ProvisioningToken = {
|
||||
decode(data, start, end) {
|
||||
const res = {
|
||||
$unknown: [],
|
||||
token: null,
|
||||
};
|
||||
$decode(data, ProvisioningToken$SPEC, (id, value) => {
|
||||
switch (id) {
|
||||
case 1:
|
||||
res.token = value;
|
||||
break;
|
||||
default:
|
||||
res.$unknown.push(value);
|
||||
break;
|
||||
}
|
||||
}, start, end);
|
||||
return res;
|
||||
},
|
||||
$f(data) {
|
||||
const fields = [];
|
||||
if (data.token != null) {
|
||||
fields.push({
|
||||
i: 1,
|
||||
t: 112,
|
||||
v: data.token,
|
||||
b: 0,
|
||||
});
|
||||
}
|
||||
return fields;
|
||||
},
|
||||
encode(data) {
|
||||
return $encode(this.$f(data));
|
||||
}
|
||||
};
|
||||
export const ProvisioningEnvelope = {
|
||||
decode(data, start, end) {
|
||||
const res = {
|
||||
$unknown: [],
|
||||
publicKey: null,
|
||||
ciphertext: null,
|
||||
};
|
||||
$decode(data, ProvisioningEnvelope$SPEC, (id, value) => {
|
||||
switch (id) {
|
||||
case 1:
|
||||
res.publicKey = value;
|
||||
break;
|
||||
case 2:
|
||||
res.ciphertext = value;
|
||||
break;
|
||||
default:
|
||||
res.$unknown.push(value);
|
||||
break;
|
||||
}
|
||||
}, start, end);
|
||||
return res;
|
||||
},
|
||||
$f(data) {
|
||||
const fields = [];
|
||||
if (data.publicKey != null) {
|
||||
fields.push({
|
||||
i: 1,
|
||||
t: 96,
|
||||
v: data.publicKey,
|
||||
b: 0,
|
||||
});
|
||||
}
|
||||
if (data.ciphertext != null) {
|
||||
fields.push({
|
||||
i: 2,
|
||||
t: 96,
|
||||
v: data.ciphertext,
|
||||
b: 0,
|
||||
});
|
||||
}
|
||||
return fields;
|
||||
},
|
||||
encode(data) {
|
||||
return $encode(this.$f(data));
|
||||
}
|
||||
};
|
||||
export const ProvisioningMessage = {
|
||||
decode(data, start, end) {
|
||||
const res = {
|
||||
$unknown: [],
|
||||
username: null,
|
||||
password: null,
|
||||
};
|
||||
$decode(data, ProvisioningMessage$SPEC, (id, value) => {
|
||||
switch (id) {
|
||||
case 1:
|
||||
res.username = value;
|
||||
break;
|
||||
case 2:
|
||||
res.password = value;
|
||||
break;
|
||||
default:
|
||||
res.$unknown.push(value);
|
||||
break;
|
||||
}
|
||||
}, start, end);
|
||||
return res;
|
||||
},
|
||||
$f(data) {
|
||||
const fields = [];
|
||||
if (data.username != null) {
|
||||
fields.push({
|
||||
i: 1,
|
||||
t: 112,
|
||||
v: data.username,
|
||||
b: 0,
|
||||
});
|
||||
}
|
||||
if (data.password != null) {
|
||||
fields.push({
|
||||
i: 2,
|
||||
t: 112,
|
||||
v: data.password,
|
||||
b: 0,
|
||||
});
|
||||
}
|
||||
return fields;
|
||||
},
|
||||
encode(data) {
|
||||
return $encode(this.$f(data));
|
||||
}
|
||||
};
|
||||
export const StickerPack = {
|
||||
Sticker: {
|
||||
decode(data, start, end) {
|
||||
|
||||
@ -1,29 +0,0 @@
|
||||
// Copyright 2022 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { vi, describe, it, assert } from 'vitest';
|
||||
import { webcrypto } from 'node:crypto';
|
||||
|
||||
import { Provisioning } from './provisioning';
|
||||
|
||||
vi.stubGlobal('crypto', webcrypto);
|
||||
|
||||
describe.concurrent('provisioning', () => {
|
||||
it('should encrypt/decrypt the message', async () => {
|
||||
const us = await Provisioning.create();
|
||||
const them = await Provisioning.create();
|
||||
|
||||
const message = {
|
||||
username: 'signal',
|
||||
password: 'whisper',
|
||||
};
|
||||
|
||||
const encrypted = await them.encryptMessage(message, us.publicKey);
|
||||
const decrypted = await us.decryptMessage(encrypted);
|
||||
|
||||
assert.deepStrictEqual(decrypted, {
|
||||
$unknown: [],
|
||||
...message,
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -1,99 +0,0 @@
|
||||
// Copyright 2022 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import b64 from 'base64-js';
|
||||
import {
|
||||
generateKeyPair,
|
||||
sharedKey as computeSharedKey,
|
||||
} from '@stablelib/x25519';
|
||||
|
||||
import { deriveKeys, decryptAttachment, encryptAttachment } from './crypto';
|
||||
import { ProvisioningEnvelope, ProvisioningMessage } from './protos';
|
||||
|
||||
const encoder = new TextEncoder();
|
||||
|
||||
const PROVISIONING_INFO = encoder.encode('Art Service Provisioning Message');
|
||||
|
||||
function prefixKey(key: Uint8Array): Uint8Array {
|
||||
if (key.length === 32) {
|
||||
return new Uint8Array([0x05, ...key]);
|
||||
}
|
||||
|
||||
if (key.length !== 33 || key[0] !== 0x05) {
|
||||
throw new Error('Invalid key');
|
||||
}
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
function unprefixKey(key: Uint8Array): Uint8Array {
|
||||
if (key.length === 32) {
|
||||
return key;
|
||||
}
|
||||
|
||||
if (key.length !== 33 || key[0] !== 0x05) {
|
||||
throw new Error('Invalid key');
|
||||
}
|
||||
|
||||
return key.slice(1);
|
||||
}
|
||||
|
||||
export class Provisioning {
|
||||
protected constructor(
|
||||
private readonly privateKey: Uint8Array,
|
||||
public readonly publicKey: Uint8Array
|
||||
) {}
|
||||
|
||||
public static async create(): Promise<Provisioning> {
|
||||
const { secretKey: privateKey, publicKey } = generateKeyPair();
|
||||
|
||||
return new Provisioning(privateKey, publicKey);
|
||||
}
|
||||
|
||||
public getUrl(token: string): string {
|
||||
const url = new URL('sgnl://art-auth');
|
||||
url.searchParams.set('token', token);
|
||||
url.searchParams.set(
|
||||
'pub_key',
|
||||
b64.fromByteArray(prefixKey(this.publicKey))
|
||||
);
|
||||
return url.toString();
|
||||
}
|
||||
|
||||
public async decryptMessage(
|
||||
envelopeData: Uint8Array
|
||||
): Promise<ProvisioningMessage> {
|
||||
const envelope = ProvisioningEnvelope.decode(envelopeData);
|
||||
if (!envelope.publicKey) {
|
||||
throw new Error('Missing publicKey');
|
||||
}
|
||||
if (!envelope.ciphertext) {
|
||||
throw new Error('Missing ciphertext');
|
||||
}
|
||||
|
||||
const secret = await computeSharedKey(
|
||||
this.privateKey,
|
||||
unprefixKey(envelope.publicKey)
|
||||
);
|
||||
const keys = await deriveKeys({ info: PROVISIONING_INFO, secret });
|
||||
|
||||
const plaintext = await decryptAttachment(envelope.ciphertext, keys);
|
||||
return ProvisioningMessage.decode(plaintext);
|
||||
}
|
||||
|
||||
public async encryptMessage(
|
||||
message: ProvisioningMessage.Params,
|
||||
theirKey: Uint8Array
|
||||
): Promise<Uint8Array> {
|
||||
const secret = computeSharedKey(this.privateKey, unprefixKey(theirKey));
|
||||
const keys = await deriveKeys({ info: PROVISIONING_INFO, secret });
|
||||
|
||||
const plaintext = ProvisioningMessage.encode(message);
|
||||
const ciphertext = await encryptAttachment(plaintext, keys);
|
||||
|
||||
return ProvisioningEnvelope.encode({
|
||||
publicKey: this.publicKey,
|
||||
ciphertext,
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -1,35 +0,0 @@
|
||||
// Copyright 2021 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import type { MutableRefObject, Ref } from 'react';
|
||||
import memoizee from 'memoizee';
|
||||
|
||||
/**
|
||||
* Merges multiple refs.
|
||||
*
|
||||
* Returns a new function each time, which may cause unnecessary re-renders. Try
|
||||
* `createRefMerger` if you want to cache the function.
|
||||
*/
|
||||
export function refMerger<T>(
|
||||
...refs: Array<Ref<unknown>>
|
||||
): (topLevelRef: T) => void {
|
||||
return (el: T) => {
|
||||
refs.forEach(ref => {
|
||||
// This is a simplified version of [what React does][0] to set a ref.
|
||||
// [0]: https://github.com/facebook/react/blob/29b7b775f2ecf878eaf605be959d959030598b07/packages/react-reconciler/src/ReactFiberCommitWork.js#L661-L677
|
||||
if (typeof ref === 'function') {
|
||||
ref(el);
|
||||
} else if (ref) {
|
||||
// I believe the types for `ref` are wrong in this case, as `ref.current` should
|
||||
// not be `readonly`. That's why we do this cast. See [the React source][1].
|
||||
// [1]: https://github.com/facebook/react/blob/29b7b775f2ecf878eaf605be959d959030598b07/packages/shared/ReactTypes.js#L78-L80
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
(ref as MutableRefObject<T>).current = el;
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export function createRefMerger(): typeof refMerger {
|
||||
return memoizee(refMerger, { length: false, max: 1 });
|
||||
}
|
||||
@ -1,8 +1,6 @@
|
||||
// Copyright 2023 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { brotliCompress } from 'zlib';
|
||||
import { promisify } from 'util';
|
||||
import { defineConfig } from 'vite';
|
||||
import react from '@vitejs/plugin-react';
|
||||
import { visualizer } from 'rollup-plugin-visualizer';
|
||||
@ -17,9 +15,6 @@ export default defineConfig({
|
||||
worker: {
|
||||
format: 'es',
|
||||
},
|
||||
test: {
|
||||
environment: 'happy-dom',
|
||||
},
|
||||
plugins: [react(), visualizer()],
|
||||
server: {
|
||||
proxy: {
|
||||
|
||||
@ -8,9 +8,6 @@ const bytes = globalThis.window?.SignalContext?.bytes || new Bytes();
|
||||
export function fromBase64(value: string): Uint8Array<ArrayBuffer> {
|
||||
return bytes.fromBase64(value);
|
||||
}
|
||||
export function fromBase64url(value: string): Uint8Array<ArrayBuffer> {
|
||||
return bytes.fromBase64url(value);
|
||||
}
|
||||
|
||||
export function fromHex(value: string): Uint8Array<ArrayBuffer> {
|
||||
return bytes.fromHex(value);
|
||||
|
||||
@ -13,8 +13,8 @@ import { strictAssert } from '../util/assert.std.ts';
|
||||
import { MINUTE } from '../util/durations/index.std.ts';
|
||||
import { isOlderThan } from '../util/timestamp.std.ts';
|
||||
import { sleep } from '../util/sleep.std.ts';
|
||||
import { stats } from '../util/benchmark/stats.std.ts';
|
||||
import type { StatsType } from '../util/benchmark/stats.std.ts';
|
||||
import { stats } from '../test-helpers/benchmarkStats.std.ts';
|
||||
import type { StatsType } from '../test-helpers/benchmarkStats.std.ts';
|
||||
import type { MessageAttributesType } from '../model-types.d.ts';
|
||||
import { createLogger } from '../logging/log.std.ts';
|
||||
import { postSaveUpdates } from '../util/cleanup.preload.ts';
|
||||
@ -35,7 +35,7 @@ type PopulateConversationArgsType = {
|
||||
) => MessageAttributesType;
|
||||
};
|
||||
|
||||
export async function populateConversationWithMessages({
|
||||
async function populateConversationWithMessages({
|
||||
conversationId,
|
||||
messageCount,
|
||||
unreadCount = 0,
|
||||
|
||||
@ -291,6 +291,7 @@ const IV_LENGTH = 16;
|
||||
const NONCE_LENGTH = 16;
|
||||
const SYMMETRIC_MAC_LENGTH = 16;
|
||||
|
||||
/** @testexport */
|
||||
export function encryptSymmetric(
|
||||
key: Uint8Array<ArrayBuffer>,
|
||||
plaintext: Uint8Array<ArrayBuffer>
|
||||
@ -310,6 +311,7 @@ export function encryptSymmetric(
|
||||
return Bytes.concatenate([nonce, ciphertext, mac]);
|
||||
}
|
||||
|
||||
/** @testexport */
|
||||
export function decryptSymmetric(
|
||||
key: Uint8Array<ArrayBuffer>,
|
||||
data: Uint8Array<ArrayBuffer>
|
||||
@ -378,7 +380,7 @@ export function verifyHmacSha256(
|
||||
}
|
||||
}
|
||||
|
||||
export function encryptAes256CbcPkcsPadding(
|
||||
function encryptAes256CbcPkcsPadding(
|
||||
key: Uint8Array<ArrayBuffer>,
|
||||
plaintext: Uint8Array<ArrayBuffer>,
|
||||
iv: Uint8Array<ArrayBuffer>
|
||||
@ -426,7 +428,7 @@ export function decryptAesCtr(
|
||||
});
|
||||
}
|
||||
|
||||
export function encryptAesGcm(
|
||||
function encryptAesGcm(
|
||||
key: Uint8Array<ArrayBuffer>,
|
||||
iv: Uint8Array<ArrayBuffer>,
|
||||
plaintext: Uint8Array<ArrayBuffer>,
|
||||
@ -440,7 +442,7 @@ export function encryptAesGcm(
|
||||
});
|
||||
}
|
||||
|
||||
export function decryptAesGcm(
|
||||
function decryptAesGcm(
|
||||
key: Uint8Array<ArrayBuffer>,
|
||||
iv: Uint8Array<ArrayBuffer>,
|
||||
ciphertext: Uint8Array<ArrayBuffer>
|
||||
@ -460,24 +462,11 @@ export function sha256(data: Uint8Array<ArrayBuffer>): Uint8Array<ArrayBuffer> {
|
||||
|
||||
// Utility
|
||||
|
||||
export function getZeroes(n: number): Uint8Array<ArrayBuffer> {
|
||||
function getZeroes(n: number): Uint8Array<ArrayBuffer> {
|
||||
return new Uint8Array(n);
|
||||
}
|
||||
|
||||
export function highBitsToInt(byte: number): number {
|
||||
// oxlint-disable-next-line no-bitwise
|
||||
return (byte & 0xff) >> 4;
|
||||
}
|
||||
|
||||
export function intsToByteHighAndLow(
|
||||
highValue: number,
|
||||
lowValue: number
|
||||
): number {
|
||||
// oxlint-disable-next-line no-bitwise
|
||||
return ((highValue << 4) | lowValue) & 0xff;
|
||||
}
|
||||
|
||||
export function getFirstBytes(
|
||||
function getFirstBytes(
|
||||
data: Uint8Array<ArrayBuffer>,
|
||||
n: number
|
||||
): Uint8Array<ArrayBuffer> {
|
||||
@ -589,6 +578,7 @@ export function encryptAttachment({
|
||||
};
|
||||
}
|
||||
|
||||
/** @testexport */
|
||||
export function padAndEncryptAttachment({
|
||||
plaintext,
|
||||
keys,
|
||||
|
||||
@ -4,7 +4,6 @@
|
||||
import * as client from '@signalapp/libsignal-client';
|
||||
import type { KyberPreKeyRecord } from '@signalapp/libsignal-client';
|
||||
|
||||
import * as Bytes from './Bytes.std.ts';
|
||||
import { constantTimeEqual } from './Crypto.node.ts';
|
||||
import type {
|
||||
KeyPairType,
|
||||
@ -98,15 +97,6 @@ export function createKeyPair(
|
||||
return new client.IdentityKeyPair(pubKey, privKey);
|
||||
}
|
||||
|
||||
export function prefixPublicKey(
|
||||
pubKey: Uint8Array<ArrayBuffer>
|
||||
): Uint8Array<ArrayBuffer> {
|
||||
return Bytes.concatenate([
|
||||
new Uint8Array([0x05]),
|
||||
validatePubKeyFormat(pubKey),
|
||||
]);
|
||||
}
|
||||
|
||||
export function calculateAgreement(
|
||||
pubKey: client.PublicKey,
|
||||
privKey: client.PrivateKey
|
||||
@ -114,6 +104,7 @@ export function calculateAgreement(
|
||||
return privKey.agree(pubKey);
|
||||
}
|
||||
|
||||
/** @testexport */
|
||||
export function verifySignature(
|
||||
pubKey: client.PublicKey,
|
||||
message: Uint8Array<ArrayBuffer>,
|
||||
@ -129,22 +120,7 @@ export function calculateSignature(
|
||||
return privKey.sign(plaintext);
|
||||
}
|
||||
|
||||
function validatePubKeyFormat(
|
||||
pubKey: Uint8Array<ArrayBuffer>
|
||||
): Uint8Array<ArrayBuffer> {
|
||||
if (
|
||||
pubKey === undefined ||
|
||||
((pubKey.byteLength !== 33 || pubKey[0] !== 5) && pubKey.byteLength !== 32)
|
||||
) {
|
||||
throw new Error('Invalid public key');
|
||||
}
|
||||
if (pubKey.byteLength === 33) {
|
||||
return pubKey.subarray(1);
|
||||
}
|
||||
|
||||
return pubKey;
|
||||
}
|
||||
|
||||
/** @testexport */
|
||||
export function setPublicKeyTypeByte(publicKey: Uint8Array<ArrayBuffer>): void {
|
||||
// oxlint-disable-next-line no-param-reassign
|
||||
publicKey[0] = 5;
|
||||
|
||||
@ -351,6 +351,7 @@ export function getValue(
|
||||
}
|
||||
|
||||
// See isRemoteConfigBucketEnabled in selectors/items.ts
|
||||
/** @knipignore Keep around for future features that might need it */
|
||||
export function isBucketValueEnabled(
|
||||
name: ConfigKeyType,
|
||||
e164: string | undefined,
|
||||
|
||||
@ -191,18 +191,15 @@ async function _fillCaches<ID, T extends HasIdType<ID>, HydratedType>(
|
||||
object[field] = cache as any;
|
||||
}
|
||||
|
||||
export function hydrateSession(session: SessionType): SessionRecord {
|
||||
function hydrateSession(session: SessionType): SessionRecord {
|
||||
return SessionRecord.deserialize(session.record);
|
||||
}
|
||||
export function hydratePublicKey(identityKey: IdentityKeyType): PublicKey {
|
||||
return PublicKey.deserialize(identityKey.publicKey);
|
||||
}
|
||||
export function hydratePreKey(preKey: PreKeyType): PreKeyRecord {
|
||||
function hydratePreKey(preKey: PreKeyType): PreKeyRecord {
|
||||
const publicKey = PublicKey.deserialize(preKey.publicKey);
|
||||
const privateKey = PrivateKey.deserialize(preKey.privateKey);
|
||||
return PreKeyRecord.new(preKey.keyId, publicKey, privateKey);
|
||||
}
|
||||
export function hydrateSignedPreKey(
|
||||
function hydrateSignedPreKey(
|
||||
signedPreKey: SignedPreKeyType
|
||||
): SignedPreKeyRecord {
|
||||
const createdAt = signedPreKey.created_at;
|
||||
|
||||
@ -6,7 +6,7 @@ import React from 'react';
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { AxoAvatar } from './AxoAvatar.dom.tsx';
|
||||
import { tw } from './tw.dom.tsx';
|
||||
import { BADGES_FIXTURE } from './_internal/storybook-fixtures.std.tsx';
|
||||
import { BADGES_FIXTURE } from '../test-helpers/axoStorybookFixtures.std.tsx';
|
||||
import { _getAllAxoSymbolIconNames } from './_internal/AxoSymbolDefs.generated.std.ts';
|
||||
import { AxoTokens } from './AxoTokens.std.ts';
|
||||
|
||||
|
||||
@ -138,10 +138,12 @@ const AxoButtonSizes = {
|
||||
type AxoButtonVariant = keyof typeof AxoButtonVariants;
|
||||
type AxoButtonSize = keyof typeof AxoButtonSizes;
|
||||
|
||||
/** @testexport */
|
||||
export function _getAllAxoButtonVariants(): ReadonlyArray<AxoButtonVariant> {
|
||||
return Object.keys(AxoButtonVariants) as Array<AxoButtonVariant>;
|
||||
}
|
||||
|
||||
/** @testexport */
|
||||
export function _getAllAxoButtonSizes(): ReadonlyArray<AxoButtonSize> {
|
||||
return Object.keys(AxoButtonSizes) as Array<AxoButtonSize>;
|
||||
}
|
||||
|
||||
@ -10,7 +10,7 @@ import {
|
||||
useStrictContext,
|
||||
} from './_internal/StrictContext.dom.tsx';
|
||||
|
||||
export const Namespace = 'AxoRadioGroup';
|
||||
const Namespace = 'AxoRadioGroup';
|
||||
|
||||
/**
|
||||
* @example Anatomy
|
||||
|
||||
@ -21,7 +21,7 @@ type AxoScrollAreaOrientation = 'vertical' | 'horizontal' | 'both';
|
||||
const AxoScrollAreaOrientationContext =
|
||||
createStrictContext<AxoScrollAreaOrientation>(`${Namespace}.Root`);
|
||||
|
||||
export function useAxoScrollAreaOrientation(): AxoScrollArea.Orientation {
|
||||
function useAxoScrollAreaOrientation(): AxoScrollArea.Orientation {
|
||||
return useStrictContext(AxoScrollAreaOrientationContext);
|
||||
}
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
import { assert } from './_internal/assert.std.tsx';
|
||||
|
||||
export namespace AxoTokens {
|
||||
export type HexColor = `#${string}` & { HexColor: never };
|
||||
type HexColor = `#${string}` & { HexColor: never };
|
||||
|
||||
function hexColor(input: `#${string}`): HexColor {
|
||||
return input as HexColor;
|
||||
@ -25,7 +25,7 @@ export namespace AxoTokens {
|
||||
| 'A200'
|
||||
| 'A210';
|
||||
|
||||
export type ColorValues = Readonly<{
|
||||
type ColorValues = Readonly<{
|
||||
bg: HexColor;
|
||||
fg: HexColor;
|
||||
}>;
|
||||
@ -64,7 +64,7 @@ export namespace AxoTokens {
|
||||
return ALL_COLOR_NAMES[hash % ALL_COLOR_NAMES.length]!;
|
||||
}
|
||||
|
||||
export type GradientValues = Readonly<{
|
||||
type GradientValues = Readonly<{
|
||||
start: HexColor;
|
||||
end: HexColor;
|
||||
}>;
|
||||
@ -111,7 +111,7 @@ export namespace AxoTokens {
|
||||
return `linear-gradient(to bottom, ${gradient.start}, ${gradient.end})`;
|
||||
}
|
||||
|
||||
export type ContactPresetName =
|
||||
type ContactPresetName =
|
||||
| 'abstract_01'
|
||||
| 'abstract_02'
|
||||
| 'abstract_03'
|
||||
@ -125,7 +125,7 @@ export namespace AxoTokens {
|
||||
| 'incognito'
|
||||
| 'ghost';
|
||||
|
||||
export type GroupPresetName =
|
||||
type GroupPresetName =
|
||||
| 'balloon'
|
||||
| 'book'
|
||||
| 'briefcase'
|
||||
|
||||
@ -1121,10 +1121,12 @@ const InlineDefs: Record<string, SymbolDef> = {
|
||||
'videocamera-slash-fill': '\u{E1EC}',
|
||||
} satisfies Record<InlineDefsName, SymbolDef>;
|
||||
|
||||
/** @testexport */
|
||||
export function _getAllAxoSymbolIconNames(): ReadonlyArray<AxoSymbolIconName> {
|
||||
return Object.keys(IconDefs) as Array<AxoSymbolIconName>;
|
||||
}
|
||||
|
||||
/** @testexport */
|
||||
export function _getAllAxoSymbolInlineGlyphNames(): ReadonlyArray<AxoSymbolInlineGlyphName> {
|
||||
return Object.keys(IconDefs) as Array<AxoSymbolIconName>;
|
||||
}
|
||||
|
||||
@ -168,7 +168,7 @@ function inherits(role: AnyAriaRole, superRole: AnyAriaRole): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
export function isValidAriaRole(role: string | null): role is AriaRole {
|
||||
function isValidAriaRole(role: string | null): role is AriaRole {
|
||||
return role != null && Object.hasOwn(ParentRoles, role);
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// Copyright 2025 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
export class AssertionError extends TypeError {
|
||||
class AssertionError extends TypeError {
|
||||
override name = 'AssertionError';
|
||||
}
|
||||
|
||||
|
||||
@ -164,14 +164,14 @@ import { badgeImageFileDownloader } from './badges/badgeImageFileDownloader.prel
|
||||
import * as Deletes from './messageModifiers/Deletes.preload.ts';
|
||||
import * as Edits from './messageModifiers/Edits.preload.ts';
|
||||
import * as MessageReceipts from './messageModifiers/MessageReceipts.preload.ts';
|
||||
import * as MessageRequests from './messageModifiers/MessageRequests.preload.ts';
|
||||
import * as MessageRequests from './messageModifiers/MessageRequests.dom.ts';
|
||||
import * as PinnedMessages from './messageModifiers/PinnedMessages.preload.ts';
|
||||
import * as Polls from './messageModifiers/Polls.preload.ts';
|
||||
import * as Reactions from './messageModifiers/Reactions.preload.ts';
|
||||
import * as ViewOnceOpenSyncs from './messageModifiers/ViewOnceOpenSyncs.preload.ts';
|
||||
import type { DeleteAttributesType } from './messageModifiers/Deletes.preload.ts';
|
||||
import type { EditAttributesType } from './messageModifiers/Edits.preload.ts';
|
||||
import type { MessageRequestAttributesType } from './messageModifiers/MessageRequests.preload.ts';
|
||||
import type { MessageRequestAttributesType } from './messageModifiers/MessageRequests.dom.ts';
|
||||
import type {
|
||||
PollVoteAttributesType,
|
||||
PollTerminateAttributesType,
|
||||
@ -319,7 +319,7 @@ export async function cleanupSessionResets(): Promise<void> {
|
||||
await itemStorage.put('sessionResets', sessionResets);
|
||||
}
|
||||
|
||||
export async function startApp(): Promise<void> {
|
||||
async function startApp(): Promise<void> {
|
||||
if (window.initialTheme === ThemeType.light) {
|
||||
document.body.classList.add('light-theme');
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@ export const badgeFromServerSchema = z.object({
|
||||
});
|
||||
|
||||
// GET /v1/subscription/configuration
|
||||
export const boostBadgesFromServerSchema = z.object({
|
||||
const boostBadgesFromServerSchema = z.object({
|
||||
levels: z.record(
|
||||
z.string(),
|
||||
z
|
||||
@ -78,7 +78,7 @@ export function parseBoostBadgeListFromServer(
|
||||
return result;
|
||||
}
|
||||
|
||||
export function parseBadgeFromServer(
|
||||
function parseBadgeFromServer(
|
||||
value: unknown,
|
||||
updatesUrl: string
|
||||
): BadgeType | undefined {
|
||||
|
||||
@ -409,11 +409,11 @@ export class GumVideoCapturer {
|
||||
}
|
||||
}
|
||||
|
||||
export const MAX_VIDEO_CAPTURE_WIDTH = 2880;
|
||||
export const MAX_VIDEO_CAPTURE_HEIGHT = 1800;
|
||||
export const MAX_VIDEO_CAPTURE_AREA =
|
||||
const MAX_VIDEO_CAPTURE_WIDTH = 2880;
|
||||
const MAX_VIDEO_CAPTURE_HEIGHT = 1800;
|
||||
const MAX_VIDEO_CAPTURE_AREA =
|
||||
MAX_VIDEO_CAPTURE_WIDTH * MAX_VIDEO_CAPTURE_HEIGHT;
|
||||
export const MAX_VIDEO_CAPTURE_BUFFER_SIZE = MAX_VIDEO_CAPTURE_AREA * 4;
|
||||
const MAX_VIDEO_CAPTURE_BUFFER_SIZE = MAX_VIDEO_CAPTURE_AREA * 4;
|
||||
|
||||
export class CanvasVideoRenderer {
|
||||
private canvas?: RefObject<HTMLCanvasElement | null>;
|
||||
|
||||
@ -23,7 +23,6 @@ import type {
|
||||
ConversationTypeType,
|
||||
} from '../state/ducks/conversations.preload.ts';
|
||||
import { AvatarColors } from '../types/Colors.std.ts';
|
||||
import { generateAci } from '../types/ServiceId.std.ts';
|
||||
import { getDefaultConversation } from '../test-helpers/getDefaultConversation.std.ts';
|
||||
import { fakeGetGroupCallVideoFrameSource } from '../test-helpers/fakeGetGroupCallVideoFrameSource.std.ts';
|
||||
import { StorySendMode } from '../types/Stories.std.ts';
|
||||
@ -33,6 +32,7 @@ import {
|
||||
getDefaultCallLinkConversation,
|
||||
} from '../test-helpers/fakeCallLink.std.ts';
|
||||
import { allRemoteParticipants } from './CallScreen.dom.stories.tsx';
|
||||
import { generateAci } from '../test-helpers/serviceIdUtils.std.ts';
|
||||
|
||||
const { i18n } = window.SignalContext;
|
||||
|
||||
|
||||
@ -116,7 +116,7 @@ type AnimatedEmojiProps = {
|
||||
onAnimationEnd?: () => unknown;
|
||||
};
|
||||
|
||||
export function AnimatedEmoji({
|
||||
function AnimatedEmoji({
|
||||
value,
|
||||
fromRotate,
|
||||
fromX,
|
||||
|
||||
@ -19,7 +19,6 @@ import {
|
||||
GroupCallJoinState,
|
||||
} from '../types/Calling.std.ts';
|
||||
import { CallMode } from '../types/CallDisposition.std.ts';
|
||||
import { generateAci } from '../types/ServiceId.std.ts';
|
||||
import type { AciString } from '../types/ServiceId.std.ts';
|
||||
import type { ConversationType } from '../state/ducks/conversations.preload.ts';
|
||||
import { AvatarColors } from '../types/Colors.std.ts';
|
||||
@ -37,6 +36,7 @@ import { CallingToastProvider, useCallingToasts } from './CallingToast.dom.tsx';
|
||||
import type { CallingImageDataCache } from './CallManager.dom.tsx';
|
||||
import { MINUTE } from '../util/durations/index.std.ts';
|
||||
import { strictAssert } from '../util/assert.std.ts';
|
||||
import { generateAci } from '../test-helpers/serviceIdUtils.std.ts';
|
||||
|
||||
const { sample, shuffle, times } = lodash;
|
||||
|
||||
|
||||
@ -7,7 +7,6 @@ import lodash from 'lodash';
|
||||
import classNames from 'classnames';
|
||||
import type { VideoFrameSource } from '@signalapp/ringrtc';
|
||||
import type {
|
||||
ActiveCallStateType,
|
||||
BatchUserActionPayloadType,
|
||||
PendingUserActionPayloadType,
|
||||
SendGroupCallRaiseHandType,
|
||||
@ -158,15 +157,6 @@ export type PropsType = {
|
||||
setLocalAudioRemoteMuted: SetMutedByType;
|
||||
};
|
||||
|
||||
export const isInSpeakerView = (
|
||||
call: Pick<ActiveCallStateType, 'viewMode'> | undefined
|
||||
): boolean => {
|
||||
return (
|
||||
call?.viewMode === CallViewMode.Presentation ||
|
||||
call?.viewMode === CallViewMode.Speaker
|
||||
);
|
||||
};
|
||||
|
||||
const REACTIONS_TOASTS_TRANSITION_FROM = {
|
||||
opacity: 0,
|
||||
};
|
||||
|
||||
@ -10,10 +10,10 @@ import type { PropsType } from './CallingAdhocCallInfo.dom.tsx';
|
||||
import { CallingAdhocCallInfo } from './CallingAdhocCallInfo.dom.tsx';
|
||||
import { AvatarColors } from '../types/Colors.std.ts';
|
||||
import type { GroupCallRemoteParticipantType } from '../types/Calling.std.ts';
|
||||
import { generateAci } from '../types/ServiceId.std.ts';
|
||||
import { getDefaultConversation } from '../test-helpers/getDefaultConversation.std.ts';
|
||||
import type { CallLinkType } from '../types/CallLink.std.ts';
|
||||
import { CallLinkRestrictions } from '../types/CallLink.std.ts';
|
||||
import { generateAci } from '../test-helpers/serviceIdUtils.std.ts';
|
||||
|
||||
const { sample } = lodash;
|
||||
|
||||
|
||||
@ -11,7 +11,6 @@ import { AvatarColors } from '../types/Colors.std.ts';
|
||||
import type { ConversationType } from '../state/ducks/conversations.preload.ts';
|
||||
import type { PropsType } from './CallingLobby.dom.tsx';
|
||||
import { CallingLobby as UnwrappedCallingLobby } from './CallingLobby.dom.tsx';
|
||||
import { generateAci } from '../types/ServiceId.std.ts';
|
||||
import {
|
||||
getDefaultConversation,
|
||||
getDefaultConversationWithServiceId,
|
||||
@ -19,6 +18,7 @@ import {
|
||||
import { CallingToastProvider } from './CallingToast.dom.tsx';
|
||||
import { CallMode } from '../types/CallDisposition.std.ts';
|
||||
import { getDefaultCallLinkConversation } from '../test-helpers/fakeCallLink.std.ts';
|
||||
import { generateAci } from '../test-helpers/serviceIdUtils.std.ts';
|
||||
|
||||
const { times } = lodash;
|
||||
|
||||
|
||||
@ -8,8 +8,8 @@ import { action } from '@storybook/addon-actions';
|
||||
import type { Meta } from '@storybook/react';
|
||||
import type { PropsType } from './CallingParticipantsList.dom.tsx';
|
||||
import { CallingParticipantsList } from './CallingParticipantsList.dom.tsx';
|
||||
import { generateAci } from '../types/ServiceId.std.ts';
|
||||
import { createCallParticipant } from '../test-helpers/createCallParticipant.std.ts';
|
||||
import { generateAci } from '../test-helpers/serviceIdUtils.std.ts';
|
||||
|
||||
const { i18n } = window.SignalContext;
|
||||
|
||||
|
||||
@ -7,9 +7,9 @@ import { getDefaultConversation } from '../test-helpers/getDefaultConversation.s
|
||||
import type { PropsType } from './CallingPreCallInfo.dom.tsx';
|
||||
import { CallingPreCallInfo, RingMode } from './CallingPreCallInfo.dom.tsx';
|
||||
import type { ConversationType } from '../state/ducks/conversations.preload.ts';
|
||||
import { generateAci } from '../types/ServiceId.std.ts';
|
||||
import { FAKE_CALL_LINK } from '../test-helpers/fakeCallLink.std.ts';
|
||||
import { callLinkToConversation } from '../util/callLinks.std.ts';
|
||||
import { generateAci } from '../test-helpers/serviceIdUtils.std.ts';
|
||||
|
||||
const { i18n } = window.SignalContext;
|
||||
const getDefaultGroupConversation = () =>
|
||||
|
||||
@ -7,7 +7,7 @@ import type { Meta } from '@storybook/react';
|
||||
import { IMAGE_JPEG } from '../types/MIME.std.ts';
|
||||
import type { Props } from './CompositionArea.dom.tsx';
|
||||
import { CompositionArea } from './CompositionArea.dom.tsx';
|
||||
import { StorybookThemeContext } from '../../.storybook/StorybookThemeContext.std.js';
|
||||
import { StorybookThemeContext } from '../../.storybook/StorybookThemeContext.std.ts';
|
||||
|
||||
import { fakeDraftAttachment } from '../test-helpers/fakeAttachment.std.ts';
|
||||
import { landscapeGreenUrl } from '../storybook/Fixtures.std.ts';
|
||||
|
||||
@ -7,9 +7,9 @@ import type { Meta } from '@storybook/react';
|
||||
import { getDefaultConversation } from '../test-helpers/getDefaultConversation.std.ts';
|
||||
import type { Props } from './CompositionInput.dom.tsx';
|
||||
import { CompositionInput } from './CompositionInput.dom.tsx';
|
||||
import { generateAci } from '../types/ServiceId.std.ts';
|
||||
import { StorybookThemeContext } from '../../.storybook/StorybookThemeContext.std.js';
|
||||
import { StorybookThemeContext } from '../../.storybook/StorybookThemeContext.std.ts';
|
||||
import { EmojiSkinTone } from './fun/data/emojis.std.ts';
|
||||
import { generateAci } from '../test-helpers/serviceIdUtils.std.ts';
|
||||
|
||||
const { i18n } = window.SignalContext;
|
||||
|
||||
|
||||
@ -14,7 +14,7 @@ import { MessageStatuses } from '../types/message/MessageStatus.std.ts';
|
||||
import { ContactCheckboxDisabledReason } from './conversationList/ContactCheckbox.dom.tsx';
|
||||
import { getDefaultConversation } from '../test-helpers/getDefaultConversation.std.ts';
|
||||
import { ThemeType } from '../types/Util.std.ts';
|
||||
import { StorybookThemeContext } from '../../.storybook/StorybookThemeContext.std.js';
|
||||
import { StorybookThemeContext } from '../../.storybook/StorybookThemeContext.std.ts';
|
||||
import { makeFakeLookupConversationWithoutServiceId } from '../test-helpers/fakeLookupConversationWithoutServiceId.std.ts';
|
||||
|
||||
const { times, omit } = lodash;
|
||||
|
||||
@ -146,7 +146,7 @@ type HeaderRowType = {
|
||||
getHeaderText: (i18n: LocalizerType) => string;
|
||||
};
|
||||
|
||||
// Exported for tests across multiple files
|
||||
/** @testexport */
|
||||
export function _testHeaderText(row: Row | void): string | null {
|
||||
if (row?.type === RowType.Header) {
|
||||
return row.getHeaderText(((key: string) => key) as LocalizerType);
|
||||
|
||||
@ -12,7 +12,7 @@ import {
|
||||
} from './ForwardMessagesModal.dom.tsx';
|
||||
import { IMAGE_JPEG, VIDEO_MP4, stringToMIMEType } from '../types/MIME.std.ts';
|
||||
import { getDefaultConversation } from '../test-helpers/getDefaultConversation.std.ts';
|
||||
import { StorybookThemeContext } from '../../.storybook/StorybookThemeContext.std.js';
|
||||
import { StorybookThemeContext } from '../../.storybook/StorybookThemeContext.std.ts';
|
||||
import { CompositionTextArea } from './CompositionTextArea.dom.tsx';
|
||||
import type { MessageForwardDraft } from '../types/ForwardDraft.std.ts';
|
||||
import { EmojiSkinTone } from './fun/data/emojis.std.ts';
|
||||
|
||||
@ -10,9 +10,9 @@ import { GroupCallOverflowArea } from './GroupCallOverflowArea.dom.tsx';
|
||||
import { getDefaultConversationWithServiceId } from '../test-helpers/getDefaultConversation.std.ts';
|
||||
import { fakeGetGroupCallVideoFrameSource } from '../test-helpers/fakeGetGroupCallVideoFrameSource.std.ts';
|
||||
import { FRAME_BUFFER_SIZE } from '../calling/constants.std.ts';
|
||||
import { generateAci } from '../types/ServiceId.std.ts';
|
||||
import type { CallingImageDataCache } from './CallManager.dom.tsx';
|
||||
import { MINUTE } from '../util/durations/index.std.ts';
|
||||
import { generateAci } from '../test-helpers/serviceIdUtils.std.ts';
|
||||
|
||||
const { memoize, times } = lodash;
|
||||
|
||||
|
||||
@ -8,9 +8,9 @@ import type { PropsType } from './GroupCallRemoteParticipant.dom.tsx';
|
||||
import { GroupCallRemoteParticipant } from './GroupCallRemoteParticipant.dom.tsx';
|
||||
import { getDefaultConversation } from '../test-helpers/getDefaultConversation.std.ts';
|
||||
import { FRAME_BUFFER_SIZE } from '../calling/constants.std.ts';
|
||||
import { generateAci } from '../types/ServiceId.std.ts';
|
||||
import type { CallingImageDataCache } from './CallManager.dom.tsx';
|
||||
import { MINUTE } from '../util/durations/index.std.ts';
|
||||
import { generateAci } from '../test-helpers/serviceIdUtils.std.ts';
|
||||
|
||||
const { memoize } = lodash;
|
||||
|
||||
|
||||
@ -27,7 +27,7 @@ import {
|
||||
} from '../test-helpers/getDefaultConversation.std.ts';
|
||||
import { DialogType } from '../types/Dialogs.std.ts';
|
||||
import { SocketStatus } from '../types/SocketStatus.std.ts';
|
||||
import { StorybookThemeContext } from '../../.storybook/StorybookThemeContext.std.js';
|
||||
import { StorybookThemeContext } from '../../.storybook/StorybookThemeContext.std.ts';
|
||||
import {
|
||||
makeFakeLookupConversationWithoutServiceId,
|
||||
useUuidFetchState,
|
||||
|
||||
@ -7,7 +7,7 @@ import { action } from '@storybook/addon-actions';
|
||||
import type { Meta } from '@storybook/react';
|
||||
import type { ButtonProps } from './PlaybackButton.dom.tsx';
|
||||
import { PlaybackButton } from './PlaybackButton.dom.tsx';
|
||||
import { StorybookThemeContext } from '../../.storybook/StorybookThemeContext.std.js';
|
||||
import { StorybookThemeContext } from '../../.storybook/StorybookThemeContext.std.ts';
|
||||
import { ThemeType } from '../types/Util.std.ts';
|
||||
import { AUDIO_MP3 } from '../types/MIME.std.ts';
|
||||
|
||||
|
||||
@ -328,7 +328,7 @@ export function PreferencesBackups({
|
||||
);
|
||||
}
|
||||
|
||||
export function renderPaidBackupsSummary({
|
||||
function renderPaidBackupsSummary({
|
||||
subscriptionStatus,
|
||||
i18n,
|
||||
locale,
|
||||
@ -351,7 +351,7 @@ export function renderPaidBackupsSummary({
|
||||
);
|
||||
}
|
||||
|
||||
export function renderFreeBackupsSummary({
|
||||
function renderFreeBackupsSummary({
|
||||
backupFreeMediaDays,
|
||||
i18n,
|
||||
}: {
|
||||
|
||||
@ -256,7 +256,7 @@ function getRandomColor(): number {
|
||||
return argb;
|
||||
}
|
||||
|
||||
export function getColorFromProfile(argb: number): string {
|
||||
function getColorFromProfile(argb: number): string {
|
||||
const rgb = argb - ARGB_BITS;
|
||||
return `#${rgb.toString(16)}`;
|
||||
}
|
||||
|
||||
@ -6,7 +6,6 @@ import React, { forwardRef } from 'react';
|
||||
import classNames from 'classnames';
|
||||
|
||||
import { Button } from 'react-aria-components';
|
||||
import type { LocalizerType } from '../types/Util.std.ts';
|
||||
import { FunStaticEmoji } from './fun/FunEmoji.dom.tsx';
|
||||
import {
|
||||
getEmojiDebugLabel,
|
||||
@ -65,35 +64,6 @@ export const ReactionPickerPickerEmojiButton = React.forwardRef<
|
||||
);
|
||||
});
|
||||
|
||||
export function ReactionPickerPickerMoreButton({
|
||||
i18n,
|
||||
onClick,
|
||||
}: Readonly<{
|
||||
i18n: LocalizerType;
|
||||
onClick: () => unknown;
|
||||
}>): React.JSX.Element {
|
||||
return (
|
||||
<button
|
||||
aria-label={i18n('icu:Reactions--more')}
|
||||
className="module-ReactionPickerPicker__button module-ReactionPickerPicker__button--more"
|
||||
onClick={event => {
|
||||
event.stopPropagation();
|
||||
onClick();
|
||||
}}
|
||||
onKeyDown={event => {
|
||||
if (event.key === 'Enter' || event.key === 'Space') {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
onClick();
|
||||
}
|
||||
}}
|
||||
tabIndex={0}
|
||||
title={i18n('icu:Reactions--more')}
|
||||
type="button"
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export const ReactionPickerPicker = forwardRef<
|
||||
HTMLDivElement,
|
||||
{
|
||||
|
||||
@ -10,7 +10,7 @@ import type {
|
||||
} from './SafetyNumberChangeDialog.dom.tsx';
|
||||
import { SafetyNumberChangeDialog } from './SafetyNumberChangeDialog.dom.tsx';
|
||||
import { getDefaultConversation } from '../test-helpers/getDefaultConversation.std.ts';
|
||||
import { StorybookThemeContext } from '../../.storybook/StorybookThemeContext.std.js';
|
||||
import { StorybookThemeContext } from '../../.storybook/StorybookThemeContext.std.ts';
|
||||
import { getFakeBadge } from '../test-helpers/getFakeBadge.std.ts';
|
||||
import { MY_STORY_ID } from '../types/Stories.std.ts';
|
||||
import { generateStoryDistributionId } from '../types/StoryDistributionId.std.ts';
|
||||
|
||||
@ -236,7 +236,7 @@ function PhoneNumberStage({
|
||||
);
|
||||
}
|
||||
|
||||
export function VerificationCodeStage({
|
||||
function VerificationCodeStage({
|
||||
number,
|
||||
sessionId,
|
||||
registerSingleDevice,
|
||||
@ -341,7 +341,7 @@ export function VerificationCodeStage({
|
||||
);
|
||||
}
|
||||
|
||||
export function ProfileNameStage({
|
||||
function ProfileNameStage({
|
||||
uploadProfile,
|
||||
onNext,
|
||||
}: {
|
||||
|
||||
@ -1,25 +0,0 @@
|
||||
// Copyright 2021 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import type { ReactNode } from 'react';
|
||||
import React from 'react';
|
||||
|
||||
// Whenever you don't want click or key events to propagate into their parent container
|
||||
export function StopPropagation({
|
||||
children,
|
||||
className,
|
||||
}: {
|
||||
children: ReactNode;
|
||||
className?: string;
|
||||
}): React.JSX.Element {
|
||||
return (
|
||||
// oxlint-disable-next-line jsx-a11y/no-static-element-interactions
|
||||
<div
|
||||
className={className}
|
||||
onClick={ev => ev.stopPropagation()}
|
||||
onKeyDown={ev => ev.stopPropagation()}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@ -1272,7 +1272,7 @@ type GroupStorySettingsModalProps = {
|
||||
onRemoveGroup(group: ConversationType): void;
|
||||
};
|
||||
|
||||
export function GroupStorySettingsModal({
|
||||
function GroupStorySettingsModal({
|
||||
i18n,
|
||||
group,
|
||||
onClose,
|
||||
|
||||
@ -49,7 +49,7 @@ export type PropsType = {
|
||||
|
||||
const SHORT_TIMEOUT = 3 * SECOND;
|
||||
|
||||
export function renderToast({
|
||||
function renderToast({
|
||||
changeLocation,
|
||||
hideToast,
|
||||
i18n,
|
||||
@ -996,7 +996,7 @@ export function renderToast({
|
||||
throw missingCaseError(toastType);
|
||||
}
|
||||
|
||||
export function renderMegaphone({
|
||||
function renderMegaphone({
|
||||
i18n,
|
||||
megaphone,
|
||||
containerWidthBreakpoint,
|
||||
|
||||
@ -25,7 +25,7 @@ type EventWrapperPropsType = {
|
||||
// disabled button. This uses native browser events to avoid that.
|
||||
//
|
||||
// See <https://lecstor.com/react-disabled-button-onmouseleave/>.
|
||||
export const TooltipEventWrapper = React.forwardRef<
|
||||
const TooltipEventWrapper = React.forwardRef<
|
||||
HTMLSpanElement,
|
||||
EventWrapperPropsType
|
||||
>(function TooltipEvent(
|
||||
|
||||
@ -55,7 +55,7 @@ const DEFAULT_PRESET: ColorMapEntryType = {
|
||||
tint: '#ecf0fb',
|
||||
};
|
||||
|
||||
export const COLOR_MAP: ReadonlyMap<number, ColorMapEntryType> = new Map([
|
||||
const COLOR_MAP: ReadonlyMap<number, ColorMapEntryType> = new Map([
|
||||
[ColorEnum.BLUE, DEFAULT_PRESET],
|
||||
[ColorEnum.WHITE, { fg: '#000000', bg: '#ffffff', tint: '#f5f5f5' }],
|
||||
[ColorEnum.GREY, { fg: '#464852', bg: '#6a6c75', tint: '#f0f0f1' }],
|
||||
@ -214,8 +214,7 @@ type GenerateImageURLOptionsType = Readonly<{
|
||||
colorId: number;
|
||||
}>;
|
||||
|
||||
// Exported for testing
|
||||
export async function _generateImageBlob({
|
||||
async function _generateImageBlob({
|
||||
link,
|
||||
username,
|
||||
hint,
|
||||
|
||||
@ -39,7 +39,7 @@ const computeQueue = new PQueue({
|
||||
concurrency: MAX_PARALLEL_COMPUTE,
|
||||
});
|
||||
|
||||
export async function getAudioDuration(buffer: ArrayBuffer): Promise<number> {
|
||||
async function getAudioDuration(buffer: ArrayBuffer): Promise<number> {
|
||||
const blob = new Blob([buffer]);
|
||||
const blobURL = URL.createObjectURL(blob);
|
||||
const audio = new Audio();
|
||||
|
||||
@ -22,18 +22,6 @@ type ReleaseNotesType = {
|
||||
features: Array<React.JSX.Element>;
|
||||
};
|
||||
|
||||
// Exported so it doesn't get marked unused
|
||||
export function ExternalLink(props: {
|
||||
href: string;
|
||||
children: ReactNode;
|
||||
}): React.JSX.Element {
|
||||
return (
|
||||
<a href={props.href} target="_blank" rel="noreferrer">
|
||||
{props.children}
|
||||
</a>
|
||||
);
|
||||
}
|
||||
|
||||
export function WhatsNewModal({
|
||||
i18n,
|
||||
hideWhatsNewModal,
|
||||
|
||||
@ -1,126 +0,0 @@
|
||||
// Copyright 2020 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import * as React from 'react';
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import type { Meta } from '@storybook/react';
|
||||
import { generateAci } from '../../types/ServiceId.std.ts';
|
||||
import type { Props } from './AtMentionify.dom.tsx';
|
||||
import { AtMentionify } from './AtMentionify.dom.tsx';
|
||||
|
||||
const SERVICE_ID_1 = generateAci();
|
||||
const SERVICE_ID_2 = generateAci();
|
||||
const SERVICE_ID_3 = generateAci();
|
||||
const SERVICE_ID_4 = generateAci();
|
||||
const SERVICE_ID_5 = generateAci();
|
||||
const SERVICE_ID_6 = generateAci();
|
||||
|
||||
export default {
|
||||
title: 'Components/Conversation/AtMentionify',
|
||||
} satisfies Meta<Props>;
|
||||
|
||||
const createProps = (overrideProps: Partial<Props> = {}): Props => ({
|
||||
mentions: overrideProps.mentions,
|
||||
direction: overrideProps.direction || 'incoming',
|
||||
showConversation: action('showConversation'),
|
||||
text: overrideProps.text || '',
|
||||
});
|
||||
|
||||
export function NoMentions(): React.JSX.Element {
|
||||
const props = createProps({
|
||||
text: 'Hello World',
|
||||
});
|
||||
|
||||
return <AtMentionify {...props} />;
|
||||
}
|
||||
|
||||
export function MultipleMentions(): React.JSX.Element {
|
||||
const mentions = [
|
||||
{
|
||||
start: 4,
|
||||
length: 1,
|
||||
mentionAci: SERVICE_ID_1,
|
||||
replacementText: 'Professor Farnsworth',
|
||||
conversationID: 'x',
|
||||
},
|
||||
{
|
||||
start: 2,
|
||||
length: 1,
|
||||
mentionAci: SERVICE_ID_2,
|
||||
replacementText: 'Philip J Fry',
|
||||
conversationID: 'x',
|
||||
},
|
||||
{
|
||||
start: 0,
|
||||
length: 1,
|
||||
mentionAci: SERVICE_ID_3,
|
||||
replacementText: 'Yancy Fry',
|
||||
conversationID: 'x',
|
||||
},
|
||||
];
|
||||
const props = createProps({
|
||||
mentions,
|
||||
direction: 'outgoing',
|
||||
text: AtMentionify.preprocessMentions('\uFFFC \uFFFC \uFFFC', mentions),
|
||||
});
|
||||
|
||||
return <AtMentionify {...props} />;
|
||||
}
|
||||
|
||||
export function ComplexMentions(): React.JSX.Element {
|
||||
const mentions = [
|
||||
{
|
||||
start: 80,
|
||||
length: 1,
|
||||
mentionAci: SERVICE_ID_4,
|
||||
replacementText: 'Cereal Killer',
|
||||
conversationID: 'x',
|
||||
},
|
||||
{
|
||||
start: 78,
|
||||
length: 1,
|
||||
mentionAci: SERVICE_ID_5,
|
||||
replacementText: 'Acid Burn',
|
||||
conversationID: 'x',
|
||||
},
|
||||
{
|
||||
start: 4,
|
||||
length: 1,
|
||||
mentionAci: SERVICE_ID_6,
|
||||
replacementText: 'Zero Cool',
|
||||
conversationID: 'x',
|
||||
},
|
||||
];
|
||||
|
||||
const props = createProps({
|
||||
mentions,
|
||||
text: AtMentionify.preprocessMentions(
|
||||
'Hey \uFFFC\nCheck out https://www.signal.org I think you will really like it 😍\n\ncc \uFFFC \uFFFC',
|
||||
mentions
|
||||
),
|
||||
});
|
||||
|
||||
return <AtMentionify {...props} />;
|
||||
}
|
||||
|
||||
export function WithOddCharacter(): React.JSX.Element {
|
||||
const mentions = [
|
||||
{
|
||||
start: 4,
|
||||
length: 1,
|
||||
mentionAci: SERVICE_ID_6,
|
||||
replacementText: 'Zero Cool',
|
||||
conversationID: 'x',
|
||||
},
|
||||
];
|
||||
|
||||
const props = createProps({
|
||||
mentions,
|
||||
text: AtMentionify.preprocessMentions(
|
||||
'Hey \uFFFC - Check out │https://www.signal.org│',
|
||||
mentions
|
||||
),
|
||||
});
|
||||
|
||||
return <AtMentionify {...props} />;
|
||||
}
|
||||
@ -1,114 +0,0 @@
|
||||
// Copyright 2020 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import React from 'react';
|
||||
import lodash from 'lodash';
|
||||
import type {
|
||||
HydratedBodyRangeMention,
|
||||
BodyRange,
|
||||
} from '../../types/BodyRange.std.ts';
|
||||
import { AtMention } from './AtMention.dom.tsx';
|
||||
|
||||
const { sortBy } = lodash;
|
||||
|
||||
export type Props = {
|
||||
mentions?: ReadonlyArray<HydratedBodyRangeMention>;
|
||||
direction?: 'incoming' | 'outgoing';
|
||||
showConversation?: (options: {
|
||||
conversationId: string;
|
||||
messageId?: string;
|
||||
}) => unknown;
|
||||
text: string;
|
||||
};
|
||||
|
||||
export function AtMentionify({
|
||||
mentions,
|
||||
direction,
|
||||
showConversation,
|
||||
text,
|
||||
}: Props): React.JSX.Element {
|
||||
if (!mentions) {
|
||||
return <>{text}</>;
|
||||
}
|
||||
|
||||
const MENTIONS_REGEX = /(\uFFFC@(\d+))/g;
|
||||
|
||||
let match = MENTIONS_REGEX.exec(text);
|
||||
let last = 0;
|
||||
|
||||
const rangeStarts = new Map<number, HydratedBodyRangeMention>();
|
||||
mentions.forEach(range => {
|
||||
rangeStarts.set(range.start, range);
|
||||
});
|
||||
|
||||
const results = [];
|
||||
while (match) {
|
||||
if (last < match.index) {
|
||||
const textWithNoMentions = text.slice(last, match.index);
|
||||
results.push(textWithNoMentions);
|
||||
}
|
||||
|
||||
const rangeStart = Number(match[2]);
|
||||
const range = rangeStarts.get(rangeStart);
|
||||
|
||||
if (range) {
|
||||
results.push(
|
||||
<AtMention
|
||||
key={range.start}
|
||||
direction={direction}
|
||||
isInvisible={false}
|
||||
onClick={() => {
|
||||
if (showConversation) {
|
||||
showConversation({ conversationId: range.conversationID });
|
||||
}
|
||||
}}
|
||||
onKeyUp={e => {
|
||||
if (
|
||||
e.target === e.currentTarget &&
|
||||
e.keyCode === 13 &&
|
||||
showConversation
|
||||
) {
|
||||
showConversation({ conversationId: range.conversationID });
|
||||
}
|
||||
}}
|
||||
id={range.conversationID}
|
||||
name={range.replacementText}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
last = MENTIONS_REGEX.lastIndex;
|
||||
match = MENTIONS_REGEX.exec(text);
|
||||
}
|
||||
|
||||
if (last < text.length) {
|
||||
results.push(text.slice(last));
|
||||
}
|
||||
|
||||
return <>{results}</>;
|
||||
}
|
||||
|
||||
// At-mentions need to be pre-processed before being pushed through the
|
||||
// AtMentionify component, this is due to bodyRanges containing start+length
|
||||
// values that operate on the raw string. The text has to be passed through
|
||||
// other components before being rendered in the <MessageBody />, components
|
||||
// such as Linkify, and Emojify. These components receive the text prop as a
|
||||
// string, therefore we're unable to mark it up with DOM nodes prior to handing
|
||||
// it off to them. This function will encode the "start" position into the text
|
||||
// string so we can later pull it off when rendering the @mention.
|
||||
AtMentionify.preprocessMentions = <T extends BodyRange.Mention>(
|
||||
text: string,
|
||||
mentions?: ReadonlyArray<BodyRange<T>>
|
||||
): string => {
|
||||
if (!mentions || !mentions.length) {
|
||||
return text;
|
||||
}
|
||||
|
||||
// Sorting by the start index to ensure that we always replace last -> first.
|
||||
return sortBy(mentions, 'start').reduceRight((str, range) => {
|
||||
const textBegin = str.substr(0, range.start);
|
||||
const encodedMention = `\uFFFC@${range.start}`;
|
||||
const textEnd = str.substr(range.start + range.length, str.length);
|
||||
return `${textBegin}${encodedMention}${textEnd}`;
|
||||
}, text);
|
||||
};
|
||||
@ -11,7 +11,6 @@ import {
|
||||
GroupCallStatus,
|
||||
DirectCallStatus,
|
||||
} from '../../types/CallDisposition.std.ts';
|
||||
import { generateAci } from '../../types/ServiceId.std.ts';
|
||||
import {
|
||||
CallingNotification,
|
||||
type PropsType,
|
||||
@ -22,6 +21,7 @@ import {
|
||||
} from '../../test-helpers/getDefaultConversation.std.ts';
|
||||
import type { CallStatus } from '../../types/CallDisposition.std.ts';
|
||||
import type { ConversationType } from '../../state/ducks/conversations.preload.ts';
|
||||
import { generateAci } from '../../test-helpers/serviceIdUtils.std.ts';
|
||||
|
||||
const { i18n } = window.SignalContext;
|
||||
|
||||
|
||||
@ -13,7 +13,7 @@ import {
|
||||
} from '../../test-helpers/getDefaultConversation.std.ts';
|
||||
import { getRandomColor } from '../../test-helpers/getRandomColor.std.ts';
|
||||
import { DurationInSeconds } from '../../util/durations/index.std.ts';
|
||||
import { StorybookThemeContext } from '../../../.storybook/StorybookThemeContext.std.js';
|
||||
import { StorybookThemeContext } from '../../../.storybook/StorybookThemeContext.std.ts';
|
||||
import type { PropsType } from './ConversationHeader.dom.tsx';
|
||||
import {
|
||||
ConversationHeader,
|
||||
|
||||
@ -8,7 +8,7 @@ import { action } from '@storybook/addon-actions';
|
||||
import type { Props } from './ConversationHero.dom.tsx';
|
||||
import { ConversationHero } from './ConversationHero.dom.tsx';
|
||||
import { HasStories } from '../../types/Stories.std.ts';
|
||||
import { StorybookThemeContext } from '../../../.storybook/StorybookThemeContext.std.js';
|
||||
import { StorybookThemeContext } from '../../../.storybook/StorybookThemeContext.std.ts';
|
||||
import { getDefaultConversation } from '../../test-helpers/getDefaultConversation.std.ts';
|
||||
import { ThemeType } from '../../types/Util.std.ts';
|
||||
import type { GroupV2Membership } from './conversation-details/ConversationDetailsMembershipList.dom.tsx';
|
||||
|
||||
@ -13,7 +13,7 @@ type Props = {
|
||||
children: React.ReactNode;
|
||||
};
|
||||
|
||||
export function getTooltipContent(i18n: LocalizerType): string {
|
||||
function getTooltipContent(i18n: LocalizerType): string {
|
||||
return i18n('icu:Donations__OfflineTooltip');
|
||||
}
|
||||
|
||||
|
||||
@ -4,13 +4,16 @@
|
||||
import * as React from 'react';
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import type { Meta } from '@storybook/react';
|
||||
import { generateAci, generatePni } from '../../types/ServiceId.std.ts';
|
||||
import type { ServiceIdString, AciString } from '../../types/ServiceId.std.ts';
|
||||
import type { GroupV2ChangeType } from '../../types/groups.std.ts';
|
||||
import { SignalService as Proto } from '../../protobuf/index.std.ts';
|
||||
import type { SmartContactRendererType } from '../../groupChange.std.ts';
|
||||
import type { PropsType } from './GroupV2Change.dom.tsx';
|
||||
import { GroupV2Change } from './GroupV2Change.dom.tsx';
|
||||
import {
|
||||
generateAci,
|
||||
generatePni,
|
||||
} from '../../test-helpers/serviceIdUtils.std.ts';
|
||||
|
||||
// Note: this should be kept up to date with backup_groupv2_notifications_test.ts, to
|
||||
// maintain the comprehensive set of GroupV2 notifications we need to handle
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user