Commit Graph

552 Commits

Author SHA1 Message Date
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
Max Radermacher
6e6327b007
Remove gv1-migration capability 2022-11-17 16:12:06 -08:00
Max Radermacher
27c985dcfd Don’t try to fetch profiles for e164s 2022-11-03 13:06:00 -07:00
Evan Hahn
a941c82c14
Prefer isEmpty with strings
This change may improve performance slightly but should have no other
user impact.

`myString.isEmpty` is faster than `myString.count == 0` or equivalent,
because computing `count` may require iterating over the string.

I tried to fix all occurrences of this.

Tested this by sending a message in a group and doing a full
re-registration, just in case I broke something there.
2022-11-01 17:53:46 -05:00
Evan Hahn
4675434c6c Add FiatMoney type
This change should have no user impact.

We commonly pair a currency, like USD, and an amount, like 1.23. This
adds the `FiatMoney` struct. It's a simple struct with two fields.

After adding it, I tried to use it everywhere. (It's possible I missed a
spot.)

I think this is a useful change on its own, but it'll be nice for an
upcoming change, too.

See also: [Android's equivalent class][0].

[0]: cb65347bb3/core-util/src/main/java/org/signal/core/util/money/FiatMoney.java (L1)
2022-10-26 17:04:51 -05:00
Max Radermacher
cc4af7b88e Remove CDSH 2022-10-18 16:08:33 -07:00
Evan Hahn
370ff654e7
Change license to AGPL
Change license to AGPL

This commit:

- Updates the `LICENSE` file

- Start every file with something like:

      // Copyright YEAR_FIRST_PUBLISHED Signal Messenger, LLC
      // SPDX-License-Identifier: AGPL-3.0-only

---

First, I removed existing license headers with this Ruby 3.1.2 script:

    require 'set'

    EXTENSIONS_TO_CHECK = Set['.h', '.hpp', '.cpp', '.m', '.mm', '.pch', '.swift']

    same = 0
    different = 0

    all_files = `git ls-files`.lines.map { |line| line.strip }
    all_files.each do |relative_path|
      if relative_path == 'Pods'
        next
      end

      unless EXTENSIONS_TO_CHECK.include? File.extname(relative_path)
        next
      end

      path = File.expand_path(relative_path)

      contents = File.read(path)
      new_contents = contents.sub(/\/\/\n\/\/  Copyright .*\n\/\/\n\n/, '')

      if contents == new_contents
        same += 1
      else
        different += 1
      end

      File.write(path, new_contents)
    end

    puts "updated #{different} file(s), left #{same} untouched"

I'm sure this script could be improved, but it worked well enough.

Then, I created `Scripts/lint/lint-license-headers` and ran it to auto-
fix a lot of files. This changed the mode of some files, but I think
that's actually desirable. For example,
`SignalServiceKit/src/Util/AppContext.m` previously had a mode of
`0755/-rwxr-xr-x`, and it's now `0644/-rw-r--r--`.

Then I fixed some stragglers and updated the precommit script.

See [a similar change in the Desktop app][0].

[0]: 8bfaf598af
2022-10-13 08:25:37 -05:00
Max Radermacher
9953f99784 Remove unused donation code 2022-10-12 11:30:39 -07:00
Nora Trapp
53f6561543 Enable the stories capability for all linked devices 2022-10-12 11:24:51 -07:00
Evan Hahn
760e5c1c97
Add PNI registration ID to account attributes
Like "regular" registration IDs, this attaches a PNI registration ID to
account attributes. It's already synced at the right times (see
[`updateAccountAttributesIfNecessaryAttempt`][0]).

Tested this by registering and seeing the payload correctly sent to the
server.

See also: [Android's implementation][1].

[0]: 487405ef08/SignalServiceKit/src/Account/TSAccountManager.swift (L137)
[1]: 6e5f28339d/libsignal/service/src/main/java/org/whispersystems/signalservice/internal/push/PushServiceSocket.java (L378)
2022-10-05 16:13:33 -05:00
Nora Trapp
433d63f003 Flag on websocket and REST message requests that stories are enabled 2022-10-05 12:24:13 -07:00
Nora Trapp
1e613fe438 Use unrestricted sealed sender for story sends 2022-10-05 12:24:13 -07:00
Evan Hahn
56589799cb
Clean up registration ID generation
_This change should have no user impact._

This cleans up the way we generate registration IDs. It:

- Rewrites the generation code in Swift
- Removes the "sneaky transaction" method. I did this for clarity, and
  because we won't use it for much longer
- Turns a log warning into a regular log—generating a registration ID is
  not a problem
- Adds tests

I think this is a useful change on its own, but will be handy for an
upcoming change, too.
2022-10-05 14:09:07 +00:00
Sasha Weiss
ac97aeba92
Migrate to using ExpiredProfileKeyCredentials 2022-09-26 14:33:57 -07:00
Nora Trapp
286a930a79 Add support the Signal TLS Proxy 2022-09-26 13:48:00 -07:00
Michelle Linington
4ada6b3a3f Derive bundle ID from an Xcode build setting
See [#5423][5423].

[5423]: https://github.com/signalapp/Signal-iOS/pull/5423
2022-09-21 18:10:42 +00:00
Nora Trapp
54be3e5e21 Add API to lookup safety number changes for a batch of addresses 2022-09-08 09:42:43 -07:00
Sasha Weiss
f37a0040ad
Replace AuthCredential with AuthCredentialWithPni 2022-09-07 15:39:50 -07:00
Nora Trapp
09598d2e7a Add remote flag for stories 2022-08-31 13:34:24 -07:00
Evan Hahn
5a0f836f0d Use "timestamp" instead of "timeStamp"
This change should have no user impact.

We use "timestamp", all lowercase, in most of the codebase. This makes
it consistent.
2022-08-26 14:17:12 -05:00
Harry
33e26b6c4c
Migrate OWSSignalService from objc to swift, and split it into a protocol and implementation
* Split OWSSignalService into a swift protocol and implementation, migrated from objc

* Put OWSSignalService under SSKEnvironment and use mock in mock environment

* Rename from basename + impl to protocol + basename

* extend mock functionality a bit

* pr feedback
2022-08-24 14:36:52 -07:00
Harry
2950667ac9
Split OWSURLSession into a protocol and implementation
* Split OWSURLSession into a protocol and implementation

* Add OWSURLSessionMock

* Rename from basename + impl to protocol + basename

* add simple init for mock session

* nits from pr comments

* pr comments 2
2022-08-24 13:33:27 -07:00
Evan Hahn
da322d3bf9 Add "urgent" boolean to outgoing messages
To improve message reliability, we're adding an urgency flag to outgoing
messages. For example, outgoing calls are urgent, but delivery receipts
are not. [Android][] and [Desktop][] have already done this work.

At a high level, I added an `isUrgent` property to `TSOutgoingMessage`s.
It defaults to `true`. Some subclasses, like
`OWSReceiptsForSenderMessage`, override it to return `false`.

Builds off of a few other commits (not necessary to understand this
commit, but might be useful for posterity):

- e858a0d916
- 8c6d2ebe8c
- 402b117221
- 2ba0cd764d
- 266a4663e9
- 8e5009bbf7

[Android]: dc04c8ed98
[Desktop]: 06190b1434
2022-08-18 07:35:41 -05:00
Evan Hahn
2ba0cd764d Update comments that reference server code
This change should have no user impact because it only changes
comments.

We had some comments that referenced the Signal server repo. They
referenced a commit that was a little out of date (from March 2022).
This updates the links.
2022-08-15 11:54:48 -05:00
Evan Hahn
028d97c2cb
Use remote config for gift badges
This removes `FeatureFlags.giftBadgeReceiving` and
`FeatureFlags.giftBadgeSending`, replacing them with
`RemoteConfig.canReceiveGiftBadges` and
`RemoteConfig.canSendGiftBadges`.
2022-07-20 08:50:58 -05:00
Evan Hahn
f4714b1a83 Basic support for sending gift badges
If you've got the `giftBadgeSending` flag enabled, you can now send gift
badges to anyone who has the capability.

This commit doesn't complete the feature, though. It is missing:

- Proper durability and error handling (to be addressed separately)
- Saving of receipts
- A few other cleanups
2022-06-22 15:50:51 +00:00
Evan Hahn
a1eb9e3042 Clean up boostCreatePaymentIntent()
This makes a few small changes to `OWSRequestFactory.boostCreatePaymentIntent()`:

- Adds tests
- Rewrites the function in Swift

I made sure I could do a boost (in staging) in the simulator.
2022-06-21 17:33:28 +00:00
Evan Hahn
8009206c18 Respect recipient capabilities when sending gift badges
This respects the `giftBadges` capability when trying to send gift
badges. In other words, it prevents you from sending gift badges to
someone who lacks the capability.

The bulk of this change involves fetching and saving of this new
capability. The rest of the code involves showing it on the "choose
recipient" screen (and some debug screens).
2022-06-10 22:37:22 +00:00
Max Radermacher
c404773145 Add giftBadge capability 2022-05-23 15:25:19 +00:00