chat_xdk 0.7.10-x86_64-linux
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +150 -0
- data/THIRD_PARTY_NOTICES.md +570 -0
- data/lib/chat_xdk/chat.rb +1253 -0
- data/lib/chat_xdk/errors.rb +83 -0
- data/lib/chat_xdk/feature_fetch.rb +249 -0
- data/lib/chat_xdk/feature_http.rb +416 -0
- data/lib/chat_xdk/file_decryptor.rb +102 -0
- data/lib/chat_xdk/file_encryptor.rb +100 -0
- data/lib/chat_xdk/native/linux-x64/libchat_xdk_ffi.so +0 -0
- data/lib/chat_xdk/native.rb +266 -0
- data/lib/chat_xdk/types.rb +1860 -0
- data/lib/chat_xdk/utilities.rb +82 -0
- data/lib/chat_xdk/version.rb +7 -0
- data/lib/chat_xdk.rb +12 -0
- metadata +79 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "json"
|
|
4
|
+
|
|
5
|
+
module ChatXdk
|
|
6
|
+
# Stateless utility helpers exposed directly on the ChatXdk module.
|
|
7
|
+
module Utilities
|
|
8
|
+
# Return the exact byte size of a file once encrypted: the total_bytes an
|
|
9
|
+
# upload declares before the file is encrypted.
|
|
10
|
+
#
|
|
11
|
+
# @param plaintext_size [Integer] non-negative plaintext size in bytes
|
|
12
|
+
# @return [Integer]
|
|
13
|
+
def encrypted_file_size(plaintext_size)
|
|
14
|
+
unless plaintext_size.is_a?(Integer) && plaintext_size >= 0
|
|
15
|
+
raise ArgumentError, "plaintext_size must be a non-negative Integer"
|
|
16
|
+
end
|
|
17
|
+
if plaintext_size > 0xFFFF_FFFF_FFFF_FFFF
|
|
18
|
+
raise InvalidInputError.new("Encrypted file size overflow", kind: :invalid_input)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
Native.consume(Native.chat_xdk_encrypted_file_size(plaintext_size)).to_i
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Encode bytes to standard base64.
|
|
25
|
+
#
|
|
26
|
+
# @param data [String]
|
|
27
|
+
# @return [String] UTF-8 base64 string
|
|
28
|
+
def bytes_to_base64(data)
|
|
29
|
+
Native.with_bytes(data) { |ptr, len| Native.consume(Native.chat_xdk_bytes_to_base64(ptr, len)) }
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Decode standard base64 to binary bytes. Raises {InvalidInputError} on
|
|
33
|
+
# malformed input.
|
|
34
|
+
#
|
|
35
|
+
# @param b64 [String]
|
|
36
|
+
# @return [String] binary bytes
|
|
37
|
+
def base64_to_bytes(b64)
|
|
38
|
+
inner = Native.consume(Native.chat_xdk_base64_to_bytes(Native.utf8_ptr(b64)))
|
|
39
|
+
Native.b64_decode(inner)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Encode bytes to lowercase hex.
|
|
43
|
+
#
|
|
44
|
+
# @param data [String]
|
|
45
|
+
# @return [String] UTF-8 hex string
|
|
46
|
+
def bytes_to_hex(data)
|
|
47
|
+
Native.with_bytes(data) { |ptr, len| Native.consume(Native.chat_xdk_bytes_to_hex(ptr, len)) }
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Decode even-length hex to binary bytes. Raises {InvalidInputError} on
|
|
51
|
+
# malformed input.
|
|
52
|
+
#
|
|
53
|
+
# @param hex [String]
|
|
54
|
+
# @return [String] binary bytes
|
|
55
|
+
def hex_to_bytes(hex)
|
|
56
|
+
inner = Native.consume(Native.chat_xdk_hex_to_bytes(Native.utf8_ptr(hex)))
|
|
57
|
+
Native.b64_decode(inner)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# Detect MIME type from magic bytes; returns nil if unknown.
|
|
61
|
+
#
|
|
62
|
+
# @param data [String]
|
|
63
|
+
# @return [String, nil]
|
|
64
|
+
def detect_mime_type(data)
|
|
65
|
+
result = Native.with_bytes(data) { |ptr, len| Native.consume(Native.chat_xdk_detect_mime_type(ptr, len)) }
|
|
66
|
+
result.empty? ? nil : result
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# Detect image dimensions from a header; returns nil if unknown.
|
|
70
|
+
#
|
|
71
|
+
# @param data [String]
|
|
72
|
+
# @return [ImageDimensions, nil]
|
|
73
|
+
def detect_image_dimensions(data)
|
|
74
|
+
json = Native.with_bytes(data) { |ptr, len| Native.consume(Native.chat_xdk_detect_image_dimensions(ptr, len)) }
|
|
75
|
+
return nil if json.empty? || json == "null"
|
|
76
|
+
|
|
77
|
+
ImageDimensions.from_h(JSON.parse(json))
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
extend Utilities
|
|
82
|
+
end
|
data/lib/chat_xdk.rb
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "chat_xdk/version"
|
|
4
|
+
require_relative "chat_xdk/errors"
|
|
5
|
+
require_relative "chat_xdk/native"
|
|
6
|
+
require_relative "chat_xdk/types"
|
|
7
|
+
require_relative "chat_xdk/feature_http"
|
|
8
|
+
require_relative "chat_xdk/feature_fetch"
|
|
9
|
+
require_relative "chat_xdk/file_encryptor"
|
|
10
|
+
require_relative "chat_xdk/file_decryptor"
|
|
11
|
+
require_relative "chat_xdk/utilities"
|
|
12
|
+
require_relative "chat_xdk/chat"
|
metadata
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: chat_xdk
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.7.10
|
|
5
|
+
platform: x86_64-linux
|
|
6
|
+
authors:
|
|
7
|
+
- X Developer Platform
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2026-12-03 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: ffi
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.15'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.15'
|
|
27
|
+
description: |-
|
|
28
|
+
Ruby bindings for the X Chat encryption SDK (chat-xdk). Wraps the native
|
|
29
|
+
chat_xdk_ffi shared library via Ruby FFI for end-to-end encrypted X Direct
|
|
30
|
+
Messages: key generation, Juicebox key recovery, message/file encryption
|
|
31
|
+
and decryption, and signed group/conversation actions.
|
|
32
|
+
email:
|
|
33
|
+
executables: []
|
|
34
|
+
extensions: []
|
|
35
|
+
extra_rdoc_files: []
|
|
36
|
+
files:
|
|
37
|
+
- LICENSE
|
|
38
|
+
- README.md
|
|
39
|
+
- THIRD_PARTY_NOTICES.md
|
|
40
|
+
- lib/chat_xdk.rb
|
|
41
|
+
- lib/chat_xdk/chat.rb
|
|
42
|
+
- lib/chat_xdk/errors.rb
|
|
43
|
+
- lib/chat_xdk/feature_fetch.rb
|
|
44
|
+
- lib/chat_xdk/feature_http.rb
|
|
45
|
+
- lib/chat_xdk/file_decryptor.rb
|
|
46
|
+
- lib/chat_xdk/file_encryptor.rb
|
|
47
|
+
- lib/chat_xdk/native.rb
|
|
48
|
+
- lib/chat_xdk/native/linux-x64/libchat_xdk_ffi.so
|
|
49
|
+
- lib/chat_xdk/types.rb
|
|
50
|
+
- lib/chat_xdk/utilities.rb
|
|
51
|
+
- lib/chat_xdk/version.rb
|
|
52
|
+
homepage: https://github.com/xdevplatform/chat-xdk
|
|
53
|
+
licenses:
|
|
54
|
+
- MIT
|
|
55
|
+
metadata:
|
|
56
|
+
source_code_uri: https://github.com/xdevplatform/chat-xdk
|
|
57
|
+
changelog_uri: https://github.com/xdevplatform/chat-xdk/blob/main/CHANGELOG.md
|
|
58
|
+
documentation_uri: https://github.com/xdevplatform/chat-xdk/blob/main/docs/API.md
|
|
59
|
+
bug_tracker_uri: https://github.com/xdevplatform/chat-xdk/issues
|
|
60
|
+
post_install_message:
|
|
61
|
+
rdoc_options: []
|
|
62
|
+
require_paths:
|
|
63
|
+
- lib
|
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '3.0'
|
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
70
|
+
requirements:
|
|
71
|
+
- - ">="
|
|
72
|
+
- !ruby/object:Gem::Version
|
|
73
|
+
version: '0'
|
|
74
|
+
requirements: []
|
|
75
|
+
rubygems_version: 3.5.22
|
|
76
|
+
signing_key:
|
|
77
|
+
specification_version: 4
|
|
78
|
+
summary: X Chat SDK - encryption for X Direct Messages (Ruby bindings)
|
|
79
|
+
test_files: []
|