Commit Graph

92 Commits

Author SHA1 Message Date
Harry
09a6635857
Add Backup proto file 2023-10-19 15:38:23 -07:00
Max Radermacher
be8ba49b4e
[ServiceId] Update protobuf field names 2023-08-02 17:21:59 -05:00
Max Radermacher
0b574cfbc8
Remove E164s from a bunch of protobufs 2023-05-12 00:38:01 -07:00
Max Radermacher
ebf6b8f5e7
Support PNIs in SignalServiceAddress 2023-03-23 12:43:01 -07:00
Max Radermacher
56154557dd
Add isStructurallyValidE164
This merges & replaces `resemblesE164:` and `isValidE164`.

Co-authored-by: Evan Hahn <69474926+EvanHahn-Signal@users.noreply.github.com>
2023-02-13 13:45:00 -08:00
Max Radermacher
2f8d76fed0
Add buildInfallibly to proto wrappers 2023-02-06 11:37:42 -08:00
Nora Trapp
bb84fd3473 Add new storyViewReceiptsEnabled flag to storage service 2022-10-18 11:23:26 -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
Evan Hahn
160d46ef77
Fix debug assert when proto message has no addresses
This restores the behavior prior to
4a0141be41, where I made a mistake that
affect development builds.

Previously, the generated code looked like this, to prevent
instantiation of `SignalServiceAddress`es with no identifiers:

    // This is a sketch!
    let address: SignalServiceAddress? = {
      guard hasUuid || hasE164 else { return nil }
      let address = SignalServiceAddress(uuid: uuid, e164: e164)
      guard address.isValid else {
        owsFailDebug("address was unexpectedly invalid")
        return nil
      }
      return address
    }()

It makes sense (to me) to do this, because all proto fields are
optional. That means you can have a valid message that lacks both of
these fields, which is allowed. It shouldn't error.

However, I changed it to the equivalent of this, which caused an error
in `SignalServiceAddress`'s initializer:

    let address: SignalServiceAddress? = {
      let address = SignalServiceAddress(uuid: uuid, e164: e164)
      guard address.isValid else {
        return nil
      }
      return address
    }()

This reverts that to avoid the debug assertion failure. I don't think
this ever affected "real" builds beyond some extra logging.
2022-10-05 07:31:59 -07:00
Evan Hahn
4a0141be41
Omit E164 from outgoing envelopes
[Android][0] and [Desktop][1] have already removed this field. This
follows suit.

The highlights:

- `SignalService.proto` removes some fields by making them `reserved`
- `ProtoWrappers.py` updates our code generation to support addresses
  that only have a UUID (previously, you needed both a UUID and E164
  field)
- Most everything else is removing E164s

[0]: 9c266e7995
[1]: 2b0d3cab40
2022-10-03 23:55:39 +00:00
Evan Hahn
d3ec8f1fd1 Remove unused arguments from proto wrapper script
`--add-description` and `--skip-address-helpers` are unused in the
project. This removes them, along with some commented-out arguments.
2022-10-03 19:43:37 +00:00
Evan Hahn
653cb30a59 Use reserved in protobufs
_This change should have no user impact._ And you can see that the only
changes to generated files are in comments.

Before this change, we used comments to denote reserved or deprecated
fields. This works, but I think we should instead use the `reserved`
keyword, which offers a few advantages. From [the protobuf docs][0]:

> If you update a message type by entirely removing a field, or
> commenting it out, future users can reuse the field number when making
> their own updates to the type. This can cause severe issues if they
> later load old versions of the same .proto, including data corruption,
> privacy bugs, and so on. One way to make sure this doesn't happen is
> to specify that the field numbers (and/or names, which can also cause
> issues for JSON serialization) of your deleted fields are reserved.
> The protocol buffer compiler will complain if any future users try to
> use these field identifiers.

This updates our proto files to use `reserved` instead of comments. It
also adds support to our wrapper script. (I moved a few things around in
that script, too, for consistency.)

I think this is a useful change on its own, but I think it'll make
things a little better when we deprecate some fields, which we're
planning to do soon.

[0]: https://developers.google.com/protocol-buffers/docs/proto3#reserved
2022-09-27 18:45:38 +00:00
Nora Trapp
9776699137 Sync when contacts become unregistered 2022-09-15 14:09:03 -07:00
Jordan Rose
e9b6439518 Un-nest builders for our proto wrapper types
We expose many of these builders to Objective-C, but Swift is unable
to map forward-declarations of those types (@class) back to the real
Swift classes because they're nested within the protos. Since we're
already using fully-qualified names even in Swift (e.g.
"SSKProtoContentBuilder"), nesting isn't worth the trouble it's
causing.
2022-05-19 15:40:21 -07:00
Evan Hahn
16aa421d3e More Python 3 script fixes 2022-03-24 10:28:27 -05:00
Evan Hahn
c254811765 Remove unnecessary coding: utf-8 heading from Python scripts
Python 3 uses UTF-8 for source files by default. This removes the
unnecessary `coding: utf-8` declaration comment from all files.
2022-03-21 14:43:45 -05:00
Evan Hahn
1101db6a29 Upgrade scripts to Python 3
Python 2 was [removed from macOS in 12.3][0]. This change:

- Automatically converts many files with [2to3][1]
- Manually updates all [shebangs][2] to use `python3` instead of
  versionless `python` or `python2.7`
- Manually applies a few fixes, many of which were noted by 2to3
- Manually undoes a few fixes that were automatically done by 2to3

[0]: https://www.macrumors.com/2022/01/28/apple-removing-python-2-in-macos-12-3/
[1]: https://docs.python.org/3/library/2to3.html
[2]: https://en.wikipedia.org/wiki/Shebang_(Unix)
2022-03-21 12:58:33 -05:00
Dimitris Apostolou
62724cf0be Fix typos 2022-03-18 11:31:06 -07:00
Michelle Linington
886a9f8e6f Generate CDS protos 2022-02-22 12:41:04 -08:00
Michelle Linington
e3d18733da Bump copyright 2022-01-28 13:23:47 -08:00
Matthew Chen
c2171db12d Assert when we emit invalid e164 in a proto. 2021-09-01 16:33:16 -03:00
Matthew Chen
953fe32300 Never emit invalid e164 in storage service contact records; be robust to invalid e164 incoming protos. 2021-09-01 16:33:16 -03:00
Michelle Linington
4eeb4e34be Tests should be runnable in Profiling scheme 2021-08-26 20:57:06 -07:00
Nora Trapp
0dba0878a2 Adhere proto wrappers to NSSecureCoding 2021-08-17 13:42:07 -07:00
Matthew Chen
2d0fdff372 Payments: Update proto schema. 2021-04-06 13:57:06 -03:00
Nora Trapp
26253a0a27 Set the proto address during initialization 2021-02-16 13:05:13 -08:00
Matthew Chen
b890fdeed8 Fix build warnings. 2021-01-23 22:45:33 -03:00
Jordan Rose
98884f9cba Proto wrappers: use structs when ObjC compatibility isn't needed
Shaves off about 20% of a deep serialization benchmark (that's
unfortunately using code that isn't checked in yet).

Also removes Equatable from oneof enums, which wasn't really doing the
right thing anyway when there were non-primitive payloads because the
proto classes didn't override isEqual.
2020-11-17 12:46:26 -08:00
Jordan Rose
a25f4b9e26 Proto builders: dramatically speed up add*() using in-place mutation
The Swift compiler ought to be smart enough to prove that
copy-out/mutate/copy-in is the same as mutate-in-place for structs,
but it currently isn't clever enough to do that.
(See https://bugs.swift.org/browse/SR-11895.)
2020-11-17 12:46:26 -08:00
Matthew Chen
b13ff0c879 Respond to CR. 2020-10-08 17:31:29 -03:00
Matthew Chen
3942ff7fb2 Cautious proto address parsing. 2020-08-19 13:24:16 -03:00
Nora Trapp
9696671f8a Add trustLevel to SignalServiceAddress 2020-08-05 14:36:43 -07:00
Nora Trapp
c5214e38b6 Add Codable adherance to proto wrappers 2020-07-22 14:34:24 -07:00
Nora Trapp
c4111f59d0 Generate interface for unknownFields 2020-07-22 14:34:24 -07:00
Matthew Chen
752bcdd6f9 Use blob protos for encrypted attributes. 2020-04-27 14:48:29 -03:00
Ehren Kret
429aa7bf32 Update proto wrapper script for python3 2020-04-09 12:45:34 -07:00
Nora Trapp
89450058b4 More proto changes: flatten and limit account to relevant data 2020-03-24 17:11:02 -07:00
Nora Trapp
45945a530c Add support for proto3 oneof and fix a few other proto3 paths 2020-03-24 17:11:01 -07:00
Matthew Chen
3d5954dcf0 Update proto wrappers for group v2 protos (proto3, swift-only, free-standing enums, etc.) 2019-11-19 11:06:42 -03:00
Matthew Chen
6415eef120 Restore the group proto changes. 2019-11-19 11:06:42 -03:00
Matthew Chen
f5e9a83834 Revert "Merge branch 'charlesmchen/groupsProtos'"
This reverts commit ede6b98234, reversing
changes made to 35271c6d3e.
2019-11-06 17:48:52 -03:00
Matthew Chen
353fca396e Add Groups protos. 2019-11-06 17:34:56 -03:00
Nora Trapp
19f3de798e Limit optional proto setters to ObjC only 2019-07-24 14:53:45 -07:00
Nora Trapp
a439c89e93 Change proto builder setters to accept optional input 2019-07-24 14:53:45 -07:00
Michael Kirk
fefc06530b ProtoWrappers generation optionally skips address helpers 2019-07-16 22:45:13 -06:00
Nora Trapp
430a4b872a If proto doesn't have uuid or e164 address should be nil 2019-07-16 09:23:15 -07:00
Nora Trapp
c416ee5a60 Generate proto address accessors 2019-07-10 13:31:03 -07:00
Nora Trapp
37406153c6 Add support for camel case conversion from upper and lower snake case 2019-06-18 19:04:08 -07:00
Matthew Chen
307a3f38a2 Respond to CR. 2019-05-29 11:26:40 -04:00
Matthew Chen
9ae86e438b Add "required" getter for optional enums. 2019-05-29 11:05:32 -04:00