Commit Graph

580 Commits

Author SHA1 Message Date
Max Radermacher
6dede44db6
Remove unused CDSv1 code
It’s been replaced by CDSv2.
2023-02-22 14:43:09 -08:00
Max Radermacher
59593c3c97
Add ServiceId & E164 types
* Use the new E164 type in a few places
* Use the new ServiceId type in a few places
2023-02-21 23:13:46 -08:00
Harry
a6b2326ef3
Update registation API responses to match updated server spec
* Interpret nil nextVerificationAttempt as a code not having been sent yet, not as no code able to be submitted

* Update request and submit verification code handlers to latest server spec

* Update CreateAccountResponse codes to match server spec

* Update ChangeNumberResponse codes to match server spec

* Rename some cases for clarity, propagate up network errors vs generic errors

* pr comments
2023-02-17 14:11:43 -08:00
Sasha Weiss
a6a17dcb6c
"Create a username" megaphone 2023-02-17 11:21:54 -08:00
Harry
a23d469aac
Finish registration in RegistrationCoordinator
* Finish registration in RegistrationCoordinator

* Get tests to compile again (but not pass)

* Tests passing again

* Test session happy path all the way through to completion

* Test KBS auth credential happy path all the way through to completion

* Test KBS reg recovery password happy path all the way through to completion

* PR comments
2023-02-16 17:21:21 -08:00
Harry
3d6225060d
Add RegistrationCoordinator
* Add ability to compute registration recovery password

* Add RegistrationCoordinator

* remove repeat nav controller that evan added

* Scaffolding for RegistrationCoodinator test

* Add first round of RegistrationCoordinator tests, some stuff I needed to get them working, and some fixes to RegistrationCoordinator itself I discovered thanks to the tests

* switch to owsFailBeta

* Add auth credential candidate flow tests, related fixes and additions to coordinator and friends

* Add tests for session based registration path and associated fixes

* PR comment nits
2023-02-14 08:50:24 -08:00
Max Radermacher
272093e5f2
Fix device limit exceeded error handling 2023-02-13 13:45:26 -08:00
Max Radermacher
90769ea381
Swiftify OWSDeviceProvisioner 2023-02-13 12:12:16 -08:00
Max Radermacher
aa43d78815 Clean up OWSHTTPError.errorUserInfo 2023-02-13 10:44:23 -08:00
Harry
79fdf07723
Add registration create account, change number, and check kbs credential requests
* Add registration create account, change number, and check kbs credential requests

* some more comments

* pr comments

* Add authentication fields to create account request
2023-02-09 10:11:29 -08:00
Sasha Weiss
bcfd291f9c
Add support for username hashing 2023-02-08 16:02:02 -08:00
Max Radermacher
57b21b308d Swiftify pre key request parameters 2023-02-08 12:08:00 -08:00
Max Radermacher
da19593f49
Add & use DeviceMessage type when sending messages 2023-02-08 12:05:13 -08:00
Sasha Weiss
e5f1af6c2e
Support lookup-by-username 2023-02-08 10:16:57 -08:00
Harry
003cc19e62
Update SignalCoreKit. Use explicit DispatchQueue instead of relying on the implicit type on promise 'on' params
* Use explicit DispatchQueue instead of relying on the implicit type on promise 'on' params

* Update SignalCoreKit
2023-02-07 16:14:39 -08:00
Harry
ff7567370c
Add request/response types for Registration Session APIs
* Add UnknownEnumCodable+tests

* Add Registration session requests and responses + tests

* Use shared Accept-Language code
2023-02-06 12:44:31 -08:00
Harry
9a511cdda0
Add deprecated prefix to all existing onboarding/registration types
* Add deprecated prefix to all existing onboarding/registration types. (Will be forked to new versions later, potentially untouched)

* Mark old requests deprecated
2023-02-03 15:02:04 -08:00
Adam Mork
728862da6f
[Payments] Biometry Payments Lock
* payment lock

* add 30 day timeout to showing the payment lock suggestion

* fix linting

* update comment

* Payment Lock: Fix project file & submodules (#4878)

* revert ringrtc changes

* revert pods changes

* fix project file

* PR Comment suggestions and fixes

* PR suggestions

* revert screen lock to previous implementation

* rename OWSPaymentLock to OWSPaymentsLock (missing plural s), remove
super-class dependency. Make OWSPaymentsLock more "swifty".

* revert changes to call-site for OWSScreenLock

* update call-sites for OWSPaymentsLock

* forgot to add PaymentOnboarding class and localization comment improvements

* change function call-site

* Remove OWSLocalAuthentication from project

* remove OWSLocalAuth from project file

* make edge-case default more secure if storage not ready

* fix project file

* lint fix

* fix linting errors

* Revert compact format style for OWSLocalizedString

* fix localization call-sites to use literals, update localization file after autogen

* Add new Payments Lock Prompt view to be shown after activating payments. Factor out the BiometryType "current biometry" into its own class with helpers to easily getting the devices current setup.

* fix linting issues, sort project file, and autogen localizations

* require payments lock to look at the recovery phrase

* fix linting issue

* fix missing localizations (caused by dynamic creation in previous commit)

* use Pods commit from signal/main

* re-run linter on latest commits

* new header comments for new branch files

* update submodule commits

* Use existing secondsInDay constant kDayInterval, use weak self guard statement instead of optional self in escaping closure.

* Revert submodule changes

* Remove duplicate copyright headers

* Revert copyright header changes

* Restore some missing translations

* Add localization for unknown LocalAuthentication error/state.

* remove Pods changes

* linting

* use submodule commits from main

* subclass the old Objc OWSViewController super-class, should fix CICD

* change capitalized Passcode to lower-case in non-title situation.

* remove early exit guard from biometryType computed function. Reason being that the type can be gathered from a policy that evaluates to false. In a case where the user has a FaceID phone but its disabled, the messaging would be incorrect. removing the early exit evaluates the biometryType which apple provides even if the policy returns false.

* inline snooze date

* inject write transaction to some convenience methods to reduce database overhead when multiple calls need to happen at the same time.

* make combined set and snooze function, update combined call-site

* rename long function

* use false instead of sender.on to avoid sneaky view issues

* add tryToUnlockPromise function to clean up call sites

* change superclass, fix Promise statement

* call super class function

* remove objc

* add unlock failed action sheet helper class and put at all relevant call-sites, still need to test though.

* add unlock failed action sheet helper class and put at all relevant call-sites, still need to test though. linting

* project file changes for new file

* re-render payments lock toggle after failure to change setting.

re-render payments lock toggle after failure to change setting.

* move around action sheet call-site to account for an action sheet already being presented. remove unecc. return

* fix merge conflicts, linting

* re-gen strings file

---------

Co-authored-by: Max Radermacher <max@signal.org>
2023-02-03 12:56:54 -08:00
Harry
43ce863362
Support for re-registration 2023-02-02 10:17:52 -08:00
Harry
6576349613
Migrate KeyBackupService to the Swift Way™️
* Put KeyBackupService in its own folder

* Put SDSKeyValueStore in its own directory

* Put SDSDatabaseStorage in its own directory

* Stop doing useless dispatches in SDSTransactable

* Add V2 DB classes

* Wrap SDSKeyValueStore in a protocol and factory

* Make TSConstantsProtocol public to take it as a param in other places

* Take explicit transactions and do single lookups in TSAccountManager registration state methods

* Take explicit transaction on OWS2FAManager

* Make KeyBackupService an instance that takes dependencies on init

* Protocolize KeyBackupService

* Put Dependencies+SSK in its own directory

* Add DependenciesBridge

* add ViewControllerContext

* used shared context in OnboardingController

* Don't check KeyBackupService in RemoteConfigManager; the one and only callsite already checks it separately

* All the random cleanup that needed to happen to get the app to build again.

* Add mock dbv2 classes

* Migrate existing KeyBackupServiceTests

* Namespace KBS shims

* DBV2 -> DB, after changing the min swiftlint type length to 2 chars

* add toy example

* Unwrap writes as reads

* pr comments

* pr comments 2: return of the nits

* final Pr comment
2023-02-02 09:42:05 -08:00
Evan Hahn
cc92abdc90
Clean up "delete subscriber ID" request
This is similar to 227f05e932.

This change should have no user impact.

This changes the "delete subscriber ID" request in the following ways:

- Adds tests
- Converts it to Swift
- Renames `deleteSubscriptionIDRequest` to `deleteSubscriberID`
- Serializes the data inside the method, rather than requiring callers
  to do so
2023-01-27 15:11:48 -08:00
Max Radermacher
5c96ccb1bd
Clean up calls to setIsDeregistered 2023-01-26 14:04:06 -08:00
Evan Hahn
227f05e932 Clean up "set subscriber ID" request
This change should have no user impact.

This changes the "set subscriber ID" request in the following ways:

- Adds tests
- Converts it to Swift
- Renames `setSubscriptionIDRequest` to `setSubscriberID`
- Serializes the data inside the method, rather than requiring callers
  to do so

Tested this with automated tests and manually starting a subscription in
staging.
2023-01-26 13:45:25 -06:00
Sasha Weiss
1126c98f19
"Select a username" UX 2023-01-26 11:38:21 -08:00
Evan Hahn
53942beda9 Remove unused CDS request
This change should have no user impact.

The last caller was removed in 3f746368cd,
so we can safely remove this request.
2023-01-25 18:42:19 -06:00
Evan Hahn
abd130a4c2
Clean up preauth challenge request
This change should have no user impact. It makes a few cleanups to
`OWSRequestFactory.requestPreauthChallengeRequest`:

- Adds tests
- Converts it to Swift
- Renames it to `requestPreauthChallenge`
- URL-encodes the parameters. This required some additional scaffolding;
  see `URLPathComponents`.
2023-01-25 14:22:22 -06:00
Evan Hahn
8d707a9c74
Add spam reporting tokens 2023-01-25 14:14:57 -06:00
Evan Hahn
35c314bde5
Clean up donation configuration request
This change should have no user impact.

This changes a few things about
`OWSRequestFactory.donationConfigurationRequest()`:

- Adds tests
- Converts it to Swift
- Renames it to `donationConfiguration()`
- Makes it an unauthenticated request

I'm most concerned about that last thing, because it's a behavior
change. However, I think this is safe because:

1. I tested it in a simulator and it works

2. [Android appears to do the same thing][0]

3. A normal `curl` works just fine:

   ```
   curl --insecure 'https://chat.signal.org/v1/subscription/configuration'
   ```

[0]: 657c5d2bce/libsignal/service/src/main/java/org/whispersystems/signalservice/internal/push/PushServiceSocket.java (L1074)
2023-01-25 13:10:22 -06:00
Max Radermacher
4fda12f514
Handle badURL & 0.0.0.0 DNS responses 2023-01-24 14:21:12 -08:00
Max Radermacher
0dc492fec5
Use common logic when creating web sockets 2023-01-24 14:01:34 -08:00
Max Radermacher
b077a195fb Remove unused isRESTOnlyEndpoint 2023-01-24 13:57:42 -08:00
Max Radermacher
30bb2a52a8
Add OWSURLSessionEndpoint
Right now, we create a request before we make a session for a web
socket. However, as part of the next change, we’ll start creating the
request from the session. This new type breaks the circular reference;
we can create an endpoint, then a request, then a session.
2023-01-24 12:19:36 -08:00
Evan Hahn
9563ea810c
Clean up device provisioning request
This change should have no user impact. It makes a few changes to
`OWSRequestFactory.deviceProvisioningRequestWithMessageBody`:

- Adds tests
- Converts it to Swift
- Renames it to `provisionDevice`
- URL-encodes one of the parameters

(I was thankful for `OWSDeviceProvisionerTest` when I made this change,
as it increased my confidence that this was safe.)
2023-01-24 09:42:52 -08:00
Max Radermacher
bd7f7440bf
Consolidate checks for whether to use web sockets
Co-authored-by: Evan Hahn <69474926+EvanHahn-Signal@users.noreply.github.com>
2023-01-20 13:19:39 -08:00
Evan Hahn
62215b97c3
Clean up "report spam" request code
This change should have no user impact.

This makes the following changes to `OWSRequestFactory.reportSpam`:

- Converts it to Swift
- Adds tests
- Handles a server GUID that couldn't be URL-encoded. For example, if it
  contained spaces, we'd crash constructing the URL. No longer!
- Handles an empty server GUID
2023-01-20 14:15:33 -06:00
Max Radermacher
4bf583ddd6 Remove requestUrl from requestMissing
We don’t know the request’s URL if we can’t build the request.
2023-01-20 11:17:19 -08:00
Evan Hahn
76fb4a8b02 Swiftify OWSRequestFactory.enable2FARequest
This change should have no user impact.
2023-01-20 11:47:51 -06:00
Sasha Weiss
bcbf52101e
PayPal recurring donations
Co-Authored-By: Evan Hahn <evanhahn@signal.org>
2023-01-18 14:48:50 -08:00
Evan Hahn
6e97ff3c8f
Gifting: add PayPal support 2023-01-18 16:38:57 -06:00
Evan Hahn
6d10ff194b Add owsFailBeta and owsAssertBeta
These are like `owsFail` and `owsAssert` but only crash in prerelease
builds.
2023-01-18 12:25:54 -06:00
Sasha Weiss
f4af994294
Move boost payment requests to extension in own file 2023-01-10 11:32:15 -08:00
Max Radermacher
fd3457b9a5 Update sending flow to use UUIDs 2023-01-09 12:00:51 -08:00
Max Radermacher
6c2eabaacb
Only use ACI when fetching pre keys 2023-01-09 12:00:07 -08:00
Max Radermacher
19a5143b3f Remove deprecated endpoint for acking messages 2023-01-02 15:30:20 -08:00
Max Radermacher
921301cdb0
Add CDSv2 2022-12-14 16:30:35 -08:00
Max Radermacher
20d46d1e59
Clean up Giphy search 2022-12-13 12:20:19 -08:00
Evan Hahn
c1da120d2a
Fully remove "gv1-migration" capability code
This was partly done in 6e6327b007. The
server now [hard-codes this capability to `true`][0] so it's completely
useless for us to set it.

[0]: fb4ed20ff5
2022-12-06 12:56:59 -08:00
Sasha Weiss
ee4799b506 One-time donations via PayPal 2022-12-01 14:39:03 -08:00
Sasha Weiss
40e765fa4f Integrate the /v1/subscription/configuration API 2022-12-01 14:39:03 -08:00
Max Radermacher
0fb57a74ae
Fix various bugs in OWSHttpHeaders
First, `OWSHttpHeaders(httpHeaders:)` completely ignored its argument.
This doesn’t actually seem to have led to any bugs in practice; one time
the caller appears to have worked around the bug by adding the headers
again, and another time the caller relied on `allHTTPHeaderFields`
ignoring unrelated values.

Second, `URLRequest` has both `addValue` and `setValue` methods for its
headers. The former will construct a comma-separated list if the header
is already set, and the latter will replace it if it’s already set. (If
the header hasn’t been set, the two are equivalent, which is why call
sites weren’t broken even though they used the wrong method.) This was
broken only in multi-part uploads, but it was broken for "User-Agent"
and "Accept-Language", both of which are non-critical.

Third, `URLRequest`’s `allHTTPHeaderFields` doesn’t behave the way you
might expect. There’s a unit test which demonstrates some of the weird
behaviors, but any fields that aren’t present in the assigned value
aren’t touched. It seems as though most code was written as if calling
this method would fully replace *all* the HTTP headers. (The
`replace(…)` and `removeAllHeaders` methods have been removed because
they didn’t do what you’d think, and they weren’t necessary.)

Also:
* Remove Obj-C support from OWSHttpHeaders
* Move & simplify tests for HTTP Retry-After header
* Remove unused `asConnectionFailureError` method
2022-11-22 11:43:55 -08:00