0
0
mirror of https://github.com/signalapp/libsignal.git synced 2024-09-20 12:02:18 +02:00
Commit Graph

269 Commits

Author SHA1 Message Date
Jordan Rose
ec16fb3067 yarn format 2021-11-08 11:06:32 -08:00
Jordan Rose
32a05f398c node: Add/standardize zkgroup license headers 2021-11-08 11:06:32 -08:00
Jordan Rose
ef958176bd node: Get zkgroup working (and passing tests) 2021-11-08 11:06:32 -08:00
Jordan Rose
96c85fb545 node: Add zkgroup sources verbatim (does not compile) 2021-11-08 11:06:32 -08:00
Jordan Rose
852069bdc9 bridge: Add zkgroup APIs
These APIs are designed to match the generated "simpleapi" entry
points in the original zkgroup repository, to make it easier to adapt
the existing Java, Swift, and TypeScript code to libsignal-client.

The cbindgen-generated signal_ffi.h now includes constants, so that
the fixed-size arrays used to serialize zkgroup types can use named
constants in Rust. This meant filtering out some constants that were
getting picked up but that should not be included.

Note that this commit makes references to Java exception types that
will be added in a later commit.
2021-11-08 11:04:41 -08:00
Jordan Rose
4dc3ca5e6e bridge: Add support for bincode-serialized args and results
This will be used by zkgroup. Note that in order to print the type
correctly in C, a type `Serialized<FooBar>` will be translated to
`[u8; FOO_BAR_LEN]`, where 'FOO_BAR_LEN' has to be a constant that's
in scope.
2021-11-08 11:04:41 -08:00
Jordan Rose
ad5166e814 node: Factor out loading the native module into its own file
This logic is a bit finicky and it's better not to repeat it.
2021-11-01 11:46:52 -07:00
Jordan Rose
2544f3d827 bridge: Be more explicit about bridging u64 timestamps
u64 can't be represented as a primitive in Java or TypeScript (and for
the latter, Neon doesn't support bigint yet). However, for timestamps
represented as milliseconds, the integer-safe range of float64 still
covers more than 285,000 years, so it's reasonably safe to use
TypeScript's 'number' or Java's 'long' to represent these
ostensibly-64-bit values. Indicate this with a new Timestamp wrapper
type in the bridge layer.

In theory we could push this new Timestamp type down to the
libsignal-protocol crate. However, the protocol itself doesn't impose
any restrictions on the timestamp fields, so I figured it was best to
put it at the bridge layer, to indicate that it's about how Signal
specifically uses these fields.

This commit paves the way for being stricter about *other* u64 values
that might want to use the full 64-bit space.
2021-11-01 11:46:16 -07:00
Jim Gustafson
8310666076 Implement node interfaces for HsmEnclave 2021-10-26 18:58:20 -07:00
Jordan Rose
ed2e5bce3a bridge: Update generated decls 2021-10-25 15:19:47 -07:00
Jordan Rose
26ebba20ab bridge: Restrict bridge_deserialize! to only the most common case
Unlike bridge_get or bridge_get_bytearray, bridge_deserialize doesn't
do any complicated transformation of the return value to accept
optional or non-optional, failable and non-failable results alike. At
the same time, its syntax has been subtly different from the other
bridge_fn macros, dating from when we were first setting up this
library. Since the extra parameters to rename or disable a particular
bridge's entry point were rarely used, this commit removes them and
replaces those use sites with spelled-out bridge_fns. This in turn
allows removing the custom per-bridge implementations of
bridge_deserialize in favor of a bridge_fn-based implementation like
bridge_get already has.
2021-10-25 13:18:11 -07:00
Jordan Rose
64ad39c54d Remove support for HKDF "versions"
Previously, we had HKDF-for-session-version-3, which matches RFC 5869,
and HKDF-for-session-version-2, which produced slightly different
results. However, nothing in the current versions of Signal uses
anything but the RFC-compliant version. Therefore, this commit removes
support for version 2 and deprecates the entry points that take a
version:

- Java: The HKDFv3 class is deprecated in favor of static methods on
  the HKDF class.
- Swift: The hkdf function that takes a 'version' parameter is
  deprecated in favor of a new overload that does not.
- TypeScript: The HKDF class is deprecated in favor of a top-level
  hkdf function.
- Rust: The libsignal-protocol implementation of HKDF has been removed
  entirely in favor of the hkdf crate.

There are no significant benchmark deltas from this change, and a
minimal code size increase that's the cost for removing our own
implementation of HKDF. The deprecations can be removed as a later
breaking change.
2021-10-14 16:02:56 -07:00
Jordan Rose
ddce4ee3a4 Make it clear to node-gyp which action arguments are paths
On Windows, node-gyp tries to be helpful by changing forward slashes
to backslashes and making paths relative to the source root rather
than the build directory, and indeed we rely on that. However, it has
to guess what's a path and what isn't. Previously, we worked around
that by manually stripping the prepended "..\", but the node-gyp
maintainers suggested a better workaround of using joined arguments
instead (`--foo=bar` instead of `--foo bar`).
2021-09-21 10:28:11 -07:00
Jordan Rose
8c5b6af3fa Sealed sender v2: add an InvalidRegistrationId exception/error
This dedicated error is thrown when a recipient has a registration ID
that's out of the range used by Signal [0, 0x3FFF]. These IDs cannot
be encoded in the sealed sender v2 format and are not supported, even
though they don't cause any problems for 1:1 messages.
2021-08-31 13:11:10 -07:00
Jordan Rose
d72047a245 Bridge: expose RustCrypto's AES-GCM-SIV instead of our own
Same as before, but for the wrapper exposed to the app languages.
2021-07-01 13:46:20 -07:00
Andreas Schneider
a8a24f66c6 node: Build node modules with python3
This fixes the build on openSUSE Tumbleweed.
2021-06-09 09:19:17 +02:00
Jordan Rose
b780409c1b Add a deviceId field to DecryptionErrorMessage
This allows a device to know whether it's the one that sent a bad
message, and take action accordingly.

We could have a slightly more typesafe API here by using
ProtocolAddress and extracting the device ID, but that doesn't match
up with getting the device ID out of a sealed sender certificate.
2021-05-26 17:23:42 -07:00
Jordan Rose
b17b83614c Node: fix merge conflict in tests. 2021-05-26 16:41:48 -07:00
Jordan Rose
2491447ee7
Merge pull request #316 from signalapp/jrose/DecryptionErrorMessage-and-PlaintextContent-2
Add DecryptionErrorMessage and PlaintextContent (alternate)
2021-05-26 16:27:49 -07:00
Jordan Rose
51dd86a1db Finalize ContentHint design
- Default: sender will not resend; an error should be shown
  immediately
- Resendable: sender will try to resend; delay any error UI if
  possible
- Implicit: don't show any error UI at all; this is something sent
  implicitly like a typing message or a receipt
2021-05-26 15:57:45 -07:00
Jordan Rose
f7acf9005e Add SessionRecord.currentRatchetKeyMatches
This checks if there is an active sender state using the given ratchet
key, for use with decryption error messages. In this case, the app may
choose to archive the current session, or take even stronger actions
such as fetching new prekeys for the recipient.
2021-05-26 15:41:04 -07:00
Jordan Rose
3f3a6e1aca Expose DecryptionErrorMessage and PlaintextContent to Java/Swift/TS 2021-05-26 15:41:04 -07:00
Jordan Rose
6f9083175e Get registration IDs from sessions for Sealed Sender v2
The app-visible change is that sealedSenderMultiRecipientEncrypt now
takes a SessionStore as well. Sessions will be looked up in bulk using
a new SessionStore API, 'loadExistingSessions' or
'getExistingSessions`. The registration ID is then loaded from each
session and included in the resulting SSv2 payload.

The implementation is a bit of a divergence from some other APIs in
libsignal-client in that the "look up in bulk" step is performed in
the Java, Swift, or TypeScript layer, with the resulting sessions
passed down to Rust. Why? Because otherwise we'd pass a list of
addresses into Rust, which would have to turn them back into a Java,
Swift, or TypeScript array to call the SessionStore method. This would
be (1) a bunch of extra work to implement, and (2) a waste of CPU when
we already /have/ a list of addresses in the correct format: the
argument to sealedSenderMultiRecipientEncrypt.

This is an example of "the boundaries between the Rust and
Java/Swift/TypeScript parts of the library don't have to be perfect;
they're internal to the overall product". In this case, we've taken
that a little further than usual: usually we try to make the
libsignal-protocol API as convenient as possible as well, but here it
had to be a bit lower-level to satisfy the needs of the app language
wrappers. (Specifically, callers need to fetch the list of
SessionRecords themselves.)

P.S. Why doesn't v1 of sealed sender include registration IDs? Because
for SSv1, libsignal-client isn't producing the entire request body to
upload to the server; it's only producing the message content that
will be decrypted by the recipient. With SSv2, the serialized message
the recipient downloads has both shared and per-recipient data in it,
which the server must assemble from the uploaded request. Because of
this, SSv2's encrypt API might as well produce the entire request.
2021-05-20 18:04:03 -07:00
Jordan Rose
1fd8da669b
Revert "Add registration IDs to the Sealed Sender v2 upload (encrypt) format" (#303) 2021-05-17 10:03:49 -07:00
Jordan Rose
b5cddf9dbb Add registration IDs to the Sealed Sender v2 upload (encrypt) format
Registration IDs are used to detect if a device ID has been reused,
since the new device will (with high probability) use a different
randomly-generated registration ID from the old one. The server should
be able to validate this for SSv2 like it does for SSv1, though the
handling of this for SSv1 is in the various apps.
2021-05-14 15:38:31 -07:00
Jordan Rose
5ef78c0004
Merge pull request #293 from signalapp/jrose/SenderKey-message-versions
A SenderKeyMessage's version must match the SenderKeyState
2021-05-10 17:02:23 -07:00
Jordan Rose
1871473315
Merge pull request #282 from signalapp/jrose/node-DuplicatedMessageError
Node: Make a dedicated error code for DuplicatedMessage
2021-05-10 10:05:52 -07:00
Jordan Rose
4569e1ffaf SenderKey: Use the session version as the message version
We still encode the "current" version in the message version byte, but
the part that the receiver will check is now based on the session's
original message version rather than the "current" version in the
sender. (Note that these are the /same/ version right now, so this
change won't have any effect on the current wire format.)

This matches the behavior of SignalMessage and PreKeySignalMessage.
2021-05-07 18:24:44 -07:00
Jordan Rose
8af0ab17f2 Remove public constructors for *Message types
The parameters for these constructors cannot be chosen correctly in
isolation; messages always need to be created as part of a session.

The Node APIs have been renamed with leading underscores rather than
removed because we *did* have tests that explicitly constructed
messages just to test that they faithfully preserve information. In
this case the parameters are plausible values but not used for
anything.
2021-05-07 18:17:46 -07:00
Jordan Rose
f962e387b7 Java: allow a null info for HKDF (treated as empty)
Restores compatibility with libsignal-protocol-java.
2021-05-07 10:47:34 -07:00
Jordan Rose
e60e62286c Node: Make a dedicated error code for DuplicatedMessage
This was MessageCounterError in libtextsecure; it's an "error" in that
it interrupts processing of an individual message, but that message
is then be discarded in practice.
2021-04-29 10:57:39 -07:00
Jordan Rose
8db505b4f7 GitHub: add a workflow to publish a tag to NPM
And remove the old copy_repo.sh used to generate
libsignal-client-node.
2021-04-28 10:50:27 -07:00
Jordan Rose
1ccc91ae81 Node: use prebuildify to handle package prebuilding 2021-04-28 10:50:27 -07:00
Jordan Rose
9e74165f0d Bridge: add support for strongly-typed Node errors
Within a new 'Errors' module, we have a base class that indicates this
is a strongly-typed error, and an enum to identify what kind of error
it is and thus what extra properties it might have. TypeScript's type
narrowing support make this possible to do safely as long as all
instances of the base class do in fact have the extra properties that
match their code (and do not have an invalid code).

To expose this to Rust (via Neon):

- After loading the Rust library into Node, set an 'Errors' property
  with the relevant error types on the module object.

- Whenever a bridge_fn produces an error, pass it to a new
  SignalNodeError::throw API along with the 'this' object, which is
  assumed to have to be the object with the 'Errors' property.

This is a little less tidy than how we do Java exceptions, but it
comes from not having access to the error classes by some kind of
absolute name. Alternate approaches considered include:

- Use an initialized-once global. Downside: would not work if you ever
  had more than one Node engine live in a process, or quit and restarted
  it.

- Store the errors on the global object under some long, complicated
  key (like "org.signal.libsignal-client.Errors"). Downside: pollutes
  the global object.

- Generate the base class using Neon instead of writing it in
  TypeScript. Downsides: inconvenient, difficult to maintain, harder to
  use /from/ TypeScript.
2021-04-07 10:23:43 -07:00
Jordan Rose
18463e8357 Switch to a flat (non-protobuf) encoding for SealedSender v2
We're optimizing for size overhead in this encoding, so forego the
flexibility of protobufs in favor of a flat encoding (though one that
still uses protobuf's varints). Additionally, this encoding includes
the recipients inline in the message so the client can dump it all to
server in one go.

As a side effect, this means an SSv2 message encoded for sending no
longer has the same format as one encoded for receiving when there's
only one recipient. Consequently, all the tests need to be modified to
"fan out" a multi-recipient message to several single-recipient
messages. For simplicity, the wrapper language tests only support this
operation for SSv2 messages sent to exactly one recipient.
2021-04-05 11:46:52 -07:00
Jordan Rose
690dfde027 Add contentHint and groupId fields to UnidentifiedSenderMessageContent
And to the ProtocolExceptions for Java, thrown when a sealed sender
message's content fails to decrypt. (Eventually all languages will
support this.)
2021-04-05 11:46:52 -07:00
Jordan Rose
d339d5a072 Expose Sealed Sender v2 to clients
- Add a new "multi-recipient encrypt" entry point
- Add an "encrypt v1 sealed sender from UnidentifiedSenderMessage-
  Content" entry point
- Add a public constructor for UnidentifiedSenderMessageContent
- Change group_encrypt to return a CiphertextMessage instead of bytes,
  so it can be used with the above
- Java: add SenderKeyStore to SignalProtocolStore requirements
2021-04-05 11:31:27 -07:00
Jordan Rose
8509374928 SenderKeyDistributionMessage is not a CiphertextMessage
It's a payload message, something that would go inside a SignalMessage
or PreKeySignalMessage. Drop it from all the enums, and while we're
here let's sync up the CiphertextMessageType::SenderKey case with the
sealed sender content type and the envelope content type.
2021-04-05 11:31:27 -07:00
Jordan Rose
35810dc80b protocol: Test version bytes the same way as libsignal-protocol-java
This slipped in the original translation to Rust, but it doesn't
matter in practice because both nibbles of the version byte have had
the same value for a long time.
2021-03-31 14:53:33 -07:00
Jordan Rose
fd21109476 Use a strongly-typed UUID for the distribution ID of SenderKeyMessages
That's a java.util.UUID for Android, Foundation.UUID for iOS, and, uh,
strings for Electron.
2021-03-25 12:48:14 -07:00
Jordan Rose
f6267f3391 Remove SenderKeyName abstraction
With distribution IDs embedded in SenderKeyMessage and
SenderKeyDistributionMessage, the abstraction of SenderKeyName (a
sender address + distribution ID tuple) is no longer pulling its
weight. Remove it from the implementation and the public API.
2021-03-25 09:44:31 -07:00
Jordan Rose
4ce9f7c192 Include distribution ID inside SenderKey[Distribution]Message
The distribution ID is used to identify which key a particular sender
is using to encrypt their SenderKeyMessage, so it has to be known as
part of decryption. The previous design had the distribution ID stored
alongside each message (perhaps on the "envelope" structure that's
received from the server), but that's harder to keep track of, and it
would only be present for certain message kinds anyway.
2021-03-25 09:44:04 -07:00
Jordan Rose
1a25f63a95 SenderKey: Rename 'keyId' to 'chainId', 'groupId' to 'distributionId'
Clarifies the use of "ID" in SenderKey-related APIs. I've left
deprecated entry points for Java but not for Swift and TypeScript
(which are not in use yet).

- SenderKeyMessage::key_id -> chain_id (avoids double "key" in name)
- SenderKeyDistributionMessage::id -> chain_id (to match SKM)
- SenderKeyName::group_id -> distribution_id (it's not the global group ID)
2021-03-25 09:40:20 -07:00
Jack Lloyd
09dd544f8a Fix bridge_handle! logic for disabling for certain targets
It only matched exactly `$typ as false` so for example
`$typ as false, mut = true` would cause the type to still be emitted.
2021-03-17 17:26:58 -04:00
Jack Lloyd
f8648c21cd Add hashes and HMAC for Java 2021-03-15 13:30:39 -04:00
Jordan Rose
a37295e3a8 Node: use 'Native' to refer to the loaded Rust library
Specifically, use 'NativeImpl' to refer to the run-time bindings
(instead of 'SC'), and 'Native' to refer to the TypeScript module for
those bindings (instead of 'SignalClient'). This makes
compile-time diagnostics clearer, since the overall Node package is
named 'signal-client'.
2021-03-12 12:57:10 -08:00
Jordan Rose
70e495446d Bridge: add ignored Context args to methods taking stores for JNI/Node
Previously we defined one entry point for FFI (Swift) that took an
extra "context" parameter (to pass through iOS's database
transactions), and one for JNI+Node that did not (no context needed
currently). But this is all in our glue layer, which doesn't need to
be a perfect reflection of the outside interface. Remove that
duplication by accepting a Context parameter for both JNI and Node
that, for now, must be null.
2021-03-10 17:59:08 -08:00
Jordan Rose
400ad3ed56 Node: align log levels for TypeScript with log levels in the Rust enum 2021-03-09 10:17:07 -08:00
Jack Lloyd
875b18489d Test other SessionRecord getters 2021-03-08 15:42:31 -05:00
Jack Lloyd
7bfd89c82b Fix lint 2021-03-08 12:28:57 -05:00
Jack Lloyd
1d479fb928 Add a test of hasCurrentState
(which fails at the moment)
2021-03-08 12:07:35 -05:00
Jack Lloyd
4d0557c6c4
Merge pull request #233 from signalapp/jack/self-send-indicator
Have TS binding return null on a sealed sender self-send
2021-03-03 16:10:41 -05:00
Jack Lloyd
655a2a050d Have TS binding return null on a sealed sender self-send
As untyped errors make it difficult to detect this case vs other error conditions
2021-03-03 14:13:36 -05:00
Jack Lloyd
54af088e04 Expose HasCurrentState for Node
Desktop relies on this notion
2021-03-03 12:58:19 -05:00
Jack Lloyd
7de6609d87 Fix test 2021-02-26 12:14:19 -05:00
Jordan Rose
9a9b59160b Bridge: Move remaining JNI and Node store-based APIs over to bridge_fn
The exception is Java's SessionCipher_EncryptMessage, which
instantiates a different Java type based on the message type.
2021-02-19 17:31:35 -08:00
Jordan Rose
25c7b19891 Port SenderKeyStore to async bridge_fn 2021-02-19 14:55:26 -08:00
Jordan Rose
9d14d77bad Node: handle cleanups when there are argument type errors 2021-02-19 14:50:34 -08:00
Jordan Rose
cca278480e Node: Rust handle arguments should always be wrapped in JS objects
This will be necessary for async, which needs to keep the boxed Rust
values alive. (Node N-API only allows keeping JS objects alive; boxed
values don't count on their own.)
2021-02-19 12:16:30 -08:00
Jordan Rose
45d06344b1
Merge pull request #206 from signalapp/jrose/node-build-fixes
Node: fix debug build, generate source maps for testing
2021-02-19 10:59:57 -08:00
Jordan Rose
60234869ec Node: generate source maps for testing 2021-02-19 09:58:54 -08:00
Jordan Rose
e9be91f34d build_node_bridge.py: fix debug build 2021-02-19 09:58:54 -08:00
Jack Lloyd
e58c723c29 Have fns names match Swift's camalCase names 2021-02-19 08:42:35 -05:00
Jack Lloyd
852d3542eb Add sealed sender TS test 2021-02-18 15:24:42 -05:00
Jack Lloyd
6c94e037b4 TS store APIs 2021-02-18 14:27:23 -05:00
Jordan Rose
10976eb755 Node: statically link the C runtime on Windows
On Windows, the C runtime doesn't come preinstalled, so we need to
link it to avoid passing a dependency on to our users.
2021-02-16 15:44:53 -08:00
Jordan Rose
65c6efd64d
Merge pull request #195 from dennisameling/add-cross-compilation-support
Add node multi-arch/cross-compilation support
2021-02-12 17:02:36 -08:00
Dennis Ameling
0042e0d60c Add Node multi-arch support 2021-02-13 01:45:37 +01:00
Jack Lloyd
89670ba4d9 Fix store interface to return Promise 2021-02-12 16:13:53 -05:00
Jack Lloyd
4e75eda3dd Add support for SenderKeyStore in TypeScript API 2021-02-12 15:41:38 -05:00
Jack Lloyd
b10f747048 Add a few missing bindings 2021-02-08 13:53:07 -05:00
Jack Lloyd
7ab4892042 More Node bindings
SenderCertificate
SenderKeyDistributionMessage
SenderKeyMessage
SenderKeyName
SenderKeyRecord
ServerCertificate
SessionRecord
SignedPreKeyRecord
UnidentifiedSenderMessageContent
2021-02-08 11:43:30 -05:00
Jack Lloyd
a1eb7f72e1
Merge pull request #179 from signalapp/jack/node-fingerprint
Add Fingerprint API to Node binding
2021-02-04 17:29:02 -05:00
Jack Lloyd
619367bd0f Prefix internal funcs with _ 2021-02-04 17:22:43 -05:00
Jack Lloyd
334231fbf0
Merge pull request #178 from signalapp/jack/remove-displayable-format
Remove DisplayableFingerprint_Format from bridge
2021-02-04 16:40:39 -05:00
Jack Lloyd
8f95c1bea1 Add Fingerprint API to Node binding 2021-02-04 16:35:24 -05:00
Jack Lloyd
26d46e3d2d Remove DisplayableFingerprint_Format from bridge
This should only be done by the fingerprint generator.

Was exposed in Java but never called by Android. Not even exposed in Swift
2021-02-04 16:18:18 -05:00
Jordan Rose
512d0226bc Reject SenderCertificates without UUIDs
Additionally, never look up a session by e164 when decrypting
sealed-sender messages.

This is an API-breaking change for both Java and Swift clients;
certain fields and arguments are no longer Optional. On top of that,
some tests may need to be updated to provide UUIDs instead of just
phone numbers.
2021-02-04 11:25:33 -08:00
Jordan Rose
3df874ab21 Move Fingerprint generation into bridge/shared/
JNI keeps its implementation separate because it takes untyped
buffers, but it's still simpler using bridge_fn.
2021-02-03 17:48:47 -08:00
Jordan Rose
b522c42526 Bridge: use Node's bridge_fn HKDF for JNI as well
FFI's is still separate because it generates its output into an
existing buffer, which is a different signature than the other two.
2021-02-03 17:01:11 -08:00
Jordan Rose
9add3ec440 Move remaining FFI accessors into bridge/shared 2021-02-03 16:57:26 -08:00
Jordan Rose
478e178ac4 Add bridge_fn_void and use it for SessionRecord_ArchiveCurrentState
This also builds on the mutable borrow groundwork in the previous
commit.
2021-02-03 15:38:34 -08:00
Jack Lloyd
079c23b269 Add HKDF to Node via bridge 2021-02-03 17:26:11 -05:00
Jack Lloyd
cad920850a More Node bindings
Aes256GcmSiv
ProtocolAddress
PreKeyRecord
PreKeyBundle
PreKeySignalMessage
SignalMessage
2021-02-03 15:10:06 -05:00
Jack Lloyd
13715b7ebf CamelCase arguments in libsignal_client.d.ts 2021-02-02 17:01:24 -05:00
Jordan Rose
c05ec3368f Bridge: move last ffi/jni macro-based APIs over to regular bridge_fns
Slightly more verbose than a dedicated macro, but not worth keeping
around.
2021-02-01 18:33:48 -08:00
Jordan Rose
6e46c905f4 Bridge: move remaining int-returning APIs to plain bridge_fns
They don't fit in bridge_get! because they have extra logic, but
that's okay.
2021-02-01 18:33:48 -08:00
Jordan Rose
1187d3c1de Bridge: move simple object returns to bridge_get! as well 2021-02-01 18:33:48 -08:00
Jordan Rose
3d95678b76 Bridge: add a general bridge_get! and use it for strings and ints 2021-02-01 18:33:48 -08:00
Jordan Rose
1683b28da4 Bridge: Optimistically assume Node doesn't need anything FFI doesn't 2021-02-01 18:18:42 -08:00
Jordan Rose
e65fff9433 Bridge: bridge_handle! should imply bridge_destroy! 2021-02-01 18:18:42 -08:00
Jordan Rose
f92e670bfd Bridge: move PreKeyBundle_New into bridge_fn
This is the first use of Option<&PublicKey> as an argument type.
2021-02-01 18:18:42 -08:00
Jordan Rose
dffb8864c6 Bridge: implement bridge_get[_optional]_string using bridge_fn
Replaces per-bridge implementations. Unfortunately, the other macros
are a little harder:

- bridge_deserialize and bridge_destroy allow customizing the /type/
  name rather than the final function name
- bridge_get[_optional]_bytearray avoids extra copies differently from
  bridge_fn_buffer

This reorders the FFI arguments to put the output at the front, a
convention we've been slowly moving towards anyway.
2021-01-28 17:59:11 -08:00
Jordan Rose
6320fad629
Merge pull request #156 from signalapp/jrose/generate-ts-interface
Node: Autogenerate libsignal_client.d.ts like we do Native.java
2021-01-28 16:04:35 -08:00
Jordan Rose
2138efe861
Merge pull request #154 from signalapp/jrose/node-logging
Node: Add an entry point for logging
2021-01-28 16:04:13 -08:00
Jack Lloyd
b8674f713b Use LTO for building Node cdylib 2021-01-28 18:23:21 -05:00
Jack Lloyd
abfc1bff3f Tweak copy_repo script 2021-01-28 18:23:21 -05:00
Jack Lloyd
34d74250b3 Copy lib to expected location 2021-01-28 18:23:21 -05:00
Jack Lloyd
810af28150 Fix the script 2021-01-28 18:23:21 -05:00
Jack Lloyd
346ea73f43 Add a copy_repo script 2021-01-28 18:23:21 -05:00
Jack Lloyd
222ece9f92 Changes to support building Node library on Windows 2021-01-28 18:23:19 -05:00
Jordan Rose
de9f7454c5 Node: Sort libsignal_client.d.ts
This groups related functions (but does little else for organization)
2021-01-26 15:48:13 -08:00
Jordan Rose
fdceb3abb8 Node: standardize on "Foo_Bar" for functions exposed from Rust
This is easier for the Rust macros to generate than "Foo_bar", and
it's also the same as what we've been doing for Java.
2021-01-26 15:48:13 -08:00
Jordan Rose
7210f6b86f Node: Autogenerate libsignal_client.d.ts like we do Native.java
This collects doc comments of the form "ts: <some TS declaration>",
which can be written manually *or* generated by the various "bridge"
macros. If the declaration looks like a function, it also does some
substitution of Rust types for TypeScript types, to make
autogeneration easier.
2021-01-26 15:48:13 -08:00
Jordan Rose
4a476eb52a Node: Add an entry point for logging 2021-01-26 10:53:53 -08:00
Jordan Rose
448923ff43 Use the linkme crate to avoid registering Node functions manually
This only works on functions using the macros in libsignal-bridge; for
anything else we'll keep using neon::ModuleContext::export_function
manually, at least for now.
2021-01-21 18:06:41 -08:00
Jordan Rose
951d2a9183 Node: name native library as libsignal_client_PLATFORM.node
This makes it easier to have a combined artifact root for all
supported platforms.
2021-01-14 09:45:47 -08:00
Jack Lloyd
16dfd3acb0 Add PublicKey and PrivateKey operations to Node layer 2020-12-18 17:33:28 -05:00
Jordan Rose
4b398a8d77
Merge pull request #101 from signalapp/jrose/java-small-test-fixes
Get local and Android device tests working correctly
2020-12-09 11:19:56 -08:00
Jordan Rose
d05089e6e8 Java: get local tests working on Mac as well 2020-12-08 17:24:03 -08:00
Jordan Rose
2a7f8c040a Node: Fix case typo in build_node_bridge.sh 2020-12-04 10:45:01 -08:00
Jordan Rose
9a21e7babc Node: Switch to Neon's napi-runtime and JsBox
We lose the ability to define classes in Rust, but we probably want to
be doing that in TypeScript anyway.
2020-12-04 10:44:58 -08:00
Jordan Rose
6bc0541c4d Fix quoting in Swift and Node build scripts 2020-11-16 11:02:39 -08:00
Jordan Rose
932d4a3438 Move wrapper-specific shell scripts into subfolders
And use bash instead of plain sh for stricter checking.
2020-11-11 11:15:25 -08:00
Jordan Rose
7bfee717bf Switch ESLint configuration to more closely match Signal-Desktop 2020-11-11 11:06:05 -08:00
Jordan Rose
23bbf7ab11 Node: Enforce license header in ESLint 2020-11-11 11:06:05 -08:00
Jordan Rose
9a8265bfc7 Switch from TSLint to ESLint, which now supports TypeScript
TSLint was deprecated in 2019, and this gives us more of a clean slate
for linting options.
2020-11-11 11:06:05 -08:00
Jordan Rose
b4a34f48ad node: Support for electron-rebuild
This allows the Desktop client to add this module as a dependency and
have its existing build process take care of building it against the
correct version of Electron. (Within the repo, `yarn build` calling
`electron-build-env` is still necessary; a plain `electron-rebuild`
seems to get confused.)
2020-11-11 11:06:05 -08:00
Jordan Rose
be56945a70 Add a Yarn-based Node package for signal-client
There's very little here yet, just enough to test something.
2020-11-10 11:00:54 -08:00