sendmux-core 1.0.0 → 1.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5ec69806267556e76727d816bb6d01054bc5c77434a04596d02975252059ab2a
4
- data.tar.gz: a1872633a358fbd8c9d63f62e28d1ff4a9ef593ace894586fa3d824b6605c597
3
+ metadata.gz: 6f7280607072f289f30f40b8a525dac73a3ba919d5947f88e50897727a79ea72
4
+ data.tar.gz: 4b30715c9fa1c545a0f51c15a8142b20b17b9654c7bcee1ab8253657d0b3c9a9
5
5
  SHA512:
6
- metadata.gz: a0e6497dc16e4b7900822a2f95c773c6ca8d555dc06eb10ac421646622ec9fc9f351768df70d2ade31553ef45711892f8ced4ea5981adc19399d42700a64ef37
7
- data.tar.gz: 7540b87b27243eb36500d0afb1659162e76afe2aebb3f59f3d48aa7387b2f63203d0377297dc1c01d1412257301fc48d645b6246ba7f9f92675f68e3f522d6df
6
+ metadata.gz: ebc3cc155bc1c79850c19428e2265986cd5d2fe29217acd77a68579c393e2c0cf3c73bf3171b51a1474e08b306d89d4d9f3186baec5051c8356e803fee3ebf0c
7
+ data.tar.gz: 1259a51bfa4f700cc23faf10b918de1b6deab56bc7d683277bf7c6f943002a4a644da1bb88de1acde68ec09c44313b2b2c2b33598ffa22b0e441be06b76828c2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.1.0](https://github.com/Sendmux/sendmux-sdk/compare/ruby-core/v1.0.0...ruby-core/v1.1.0) (2026-07-01)
4
+
5
+
6
+ ### Features
7
+
8
+ * allow owner-approved agent tokens for sending ([9d1cb7d](https://github.com/Sendmux/sendmux-sdk/commit/9d1cb7df3df5aef1f59a4990dc087178ba3a7b21))
9
+
3
10
  ## 1.0.0 (2026-06-02)
4
11
 
5
12
 
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Sendmux
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -1,3 +1,98 @@
1
1
  # sendmux-core
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/sendmux-core.svg)](https://rubygems.org/gems/sendmux-core)
4
+ [![CI](https://github.com/Sendmux/sendmux-sdk/actions/workflows/ci.yml/badge.svg)](https://github.com/Sendmux/sendmux-sdk/actions/workflows/ci.yml)
5
+ [![Licence: MIT](https://img.shields.io/badge/licence-MIT-blue.svg)](https://github.com/Sendmux/sendmux-sdk/blob/main/LICENSE)
6
+
3
7
  Shared authentication, retry, pagination, header, and error helpers for the Sendmux Ruby SDK packages.
8
+
9
+ ## Documentation
10
+
11
+ - Ruby SDK guide: https://sendmux.ai/docs/sdks/ruby
12
+ - Source: https://github.com/Sendmux/sendmux-sdk/tree/main/packages/ruby/core
13
+ - Changelog: https://github.com/Sendmux/sendmux-sdk/blob/main/packages/ruby/core/CHANGELOG.md
14
+
15
+ ## Requirements
16
+
17
+ - Ruby 3.1 or newer.
18
+ - A Sendmux API key when using the helpers with a surface client.
19
+
20
+ ## Installation
21
+
22
+ ```sh
23
+ gem install sendmux-core
24
+ ```
25
+
26
+ Or add it to your Gemfile:
27
+
28
+ ```ruby
29
+ gem "sendmux-core", "~> 1.0"
30
+ ```
31
+
32
+ ## Usage
33
+
34
+ The core package is installed automatically by the surface gems, but it can also be used directly when you need shared helpers.
35
+
36
+ ```ruby
37
+ require "sendmux/core"
38
+
39
+ surface = Sendmux::Core::Auth.assert_api_key_surface(
40
+ ENV.fetch("SENDMUX_ROOT_KEY"),
41
+ Sendmux::Core::ApiKeySurface::ROOT
42
+ )
43
+
44
+ puts surface
45
+ ```
46
+
47
+ Use `Sendmux::Core::ApiKeySurface::ROOT` for root-key management clients, `Sendmux::Core::ApiKeySurface::SENDING` for send-capable `smx_mbx_` keys or owner-approved Sending-resource `smx_agent_` tokens, and `Sendmux::Core::ApiKeySurface::MAILBOX` for mailbox-compatible credentials. Mailbox-compatible credentials can start with `smx_mbx_` or `smx_agent_`.
48
+
49
+ ### Header helpers
50
+
51
+ Generated Ruby operations accept option hashes. The header helpers return the option keys expected by those generated operations.
52
+
53
+ ```ruby
54
+ headers = Sendmux::Core::Headers.idempotency_key("idem_123")
55
+ etag = Sendmux::Core::Headers.if_match('W/"etag"')
56
+ conditional = Sendmux::Core::Headers.conditional(if_none_match: 'W/"cached"')
57
+ ```
58
+
59
+ ### Cursor pagination
60
+
61
+ `Sendmux::Core.each_cursor` wraps any generated list call that accepts a cursor option and returns Sendmux pagination metadata.
62
+
63
+ ```ruby
64
+ pager = Sendmux::Core.each_cursor(lambda do |opts|
65
+ mailbox_client.mailbox_api.mailbox_list_messages(opts.merge(limit: 50))
66
+ end)
67
+
68
+ pager.each do |message|
69
+ puts message.id
70
+ end
71
+ ```
72
+
73
+ ### Retries and errors
74
+
75
+ Surface clients accept `Sendmux::Core::RetryOptions` and map generated errors to `Sendmux::Core::ApiError`.
76
+
77
+ ```ruby
78
+ retry_options = Sendmux::Core::RetryOptions.new(max_attempts: 4)
79
+
80
+ begin
81
+ # Pass retry_options: retry_options to any Sendmux surface client.
82
+ # Call a generated operation here.
83
+ nil
84
+ rescue Sendmux::Core::ApiError => error
85
+ warn "#{error.code}: #{error.message} (request #{error.request_id})"
86
+ end
87
+ ```
88
+
89
+ Retries are enabled for safe requests and for idempotent `POST` requests that use an `Idempotency-Key`.
90
+
91
+ ## Support
92
+
93
+ - Documentation: https://sendmux.ai/docs
94
+ - Contact: contact@sendmux.ai
95
+
96
+ ## Licence
97
+
98
+ MIT licence. See https://github.com/Sendmux/sendmux-sdk/blob/main/LICENSE.
@@ -5,6 +5,7 @@ module Sendmux
5
5
  module ApiKeySurface
6
6
  ROOT = 'root'
7
7
  MAILBOX = 'mailbox'
8
+ SENDING = 'sending'
8
9
  end
9
10
  end
10
11
  end
@@ -7,6 +7,7 @@ module Sendmux
7
7
  class Auth
8
8
  ROOT_PREFIX = 'smx_root_'
9
9
  MAILBOX_PREFIX = 'smx_mbx_'
10
+ AGENT_PREFIX = 'smx_agent_'
10
11
 
11
12
  def self.configure_bearer(configuration, api_key, expected_surface, base_url: nil)
12
13
  assert_api_key_surface(api_key, expected_surface)
@@ -21,15 +22,28 @@ module Sendmux
21
22
 
22
23
  def self.assert_api_key_surface(api_key, expected_surface)
23
24
  actual = surface_for(api_key)
24
- raise ArgumentError, "Sendmux API keys must start with #{ROOT_PREFIX} or #{MAILBOX_PREFIX}" unless actual
25
- return actual if actual == expected_surface
25
+ unless actual
26
+ raise ArgumentError,
27
+ "Sendmux API keys must start with #{ROOT_PREFIX}, #{MAILBOX_PREFIX}, or #{AGENT_PREFIX}"
28
+ end
29
+ return actual if compatible_surface?(api_key, actual, expected_surface)
26
30
 
27
31
  raise ArgumentError, "Expected a #{expected_surface} API key, received a #{actual} API key"
28
32
  end
29
33
 
34
+ def self.compatible_surface?(api_key, actual, expected_surface)
35
+ return true if actual == expected_surface
36
+ return true if expected_surface == ApiKeySurface::SENDING &&
37
+ (api_key.start_with?(MAILBOX_PREFIX) || api_key.start_with?(AGENT_PREFIX))
38
+ return true if expected_surface == ApiKeySurface::MAILBOX && actual == ApiKeySurface::MAILBOX
39
+
40
+ false
41
+ end
42
+
30
43
  def self.surface_for(api_key)
31
44
  return ApiKeySurface::ROOT if api_key.start_with?(ROOT_PREFIX)
32
45
  return ApiKeySurface::MAILBOX if api_key.start_with?(MAILBOX_PREFIX)
46
+ return ApiKeySurface::MAILBOX if api_key.start_with?(AGENT_PREFIX)
33
47
 
34
48
  nil
35
49
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sendmux
4
4
  module Core
5
- VERSION = '1.0.0'
5
+ VERSION = '1.1.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sendmux-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sendmux
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2026-06-02 00:00:00.000000000 Z
10
+ date: 2026-07-01 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: faraday
@@ -50,6 +50,7 @@ extensions: []
50
50
  extra_rdoc_files: []
51
51
  files:
52
52
  - CHANGELOG.md
53
+ - LICENSE
53
54
  - README.md
54
55
  - lib/sendmux/core.rb
55
56
  - lib/sendmux/core/api_key_surface.rb