onetime 0.6.0 → 0.7.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: 8a9d766fe9b66ef0f5617b2447910c268af2700b7bb70c59574f62033b712ad2
4
- data.tar.gz: e1737aa5ee4f29fd5a63c8951bed264c614f9fb2f747e01c73396ac8e0a4bc27
3
+ metadata.gz: 0220be9c2e382cae289a9c9f350a2ed9fc1541da377800216b0b06ff7e93671e
4
+ data.tar.gz: 6fe4dd6670c7ea344c4af9dff5826eca2d93abfe7910690d2fab465ff9310a98
5
5
  SHA512:
6
- metadata.gz: 878bb56df14b1ede5daccac8f08c652c29a4eed12ea1295730f8e322bc44449b5333a8d2967db2ab52dd24908aeb77a28a73a79c9e2e7f0053ad776454e109bd
7
- data.tar.gz: e27104bb9373e1f6b9e68b54f38927679f98e87e0b6730fd6bdb9621f88abe93222a4a1c2260682e8ed764c1f969bf6a00a12f637897992e19020c88b012c058
6
+ metadata.gz: 7704b043afd1c6f65b80f9a5f37f57ce2190afdc58750c55f6d61a6a45c9910f5fc2a6057ad5864e38e4f83303898c117492de3d15d2b01536d776942ca0362e
7
+ data.tar.gz: a9765b7964903cf64e013472cb3a9bb151cd6a7557da14188a2ebb012bae43bfc9532523043345064c21f51c56c172bb3498589f871a72795b15e9a5a4c55ece
data/README.md CHANGED
@@ -1,247 +1,17 @@
1
- # OnetimeSecret Ruby Client
1
+ # `onetime` compatibility package
2
2
 
3
- The official Ruby client for the [OnetimeSecret](https://onetimesecret.com)
4
- API. Share sensitive information through a link that can only be viewed once.
3
+ The canonical RubyGem for the OnetimeSecret Ruby client is now
4
+ [`onetimesecret`](https://rubygems.org/gems/onetimesecret).
5
5
 
6
- The gem is **`onetime`**. This repository, **`onetime-ruby`**, is the Ruby SDK
7
- in the OnetimeSecret SDK family — each language has its own repository, and the
8
- repository name is not the package name.
9
-
10
- - **Zero runtime dependencies** — built entirely on the Ruby standard library
11
- (`net/http`, `uri`, `json`), so it drops into any environment without pulling
12
- transitive gems.
13
- - **Supports API v1 and v2** — pick a version per client. The same resource
14
- methods exist for both, but each version returns its own response shape (they
15
- are different APIs; the client does not normalize them). **v1 is deprecated**
16
- and included only because the service still serves it — use v2 for new work.
17
- - **Ruby 3.1+**.
18
-
19
- > The `onetime` command-line tool has moved to a separate `onetime-cli` gem so
20
- > that this library stays dependency-free.
21
-
22
- ## Installation
23
-
24
- ```sh
25
- gem install onetime
26
- ```
27
-
28
- Or in a Gemfile:
29
-
30
- ```ruby
31
- gem "onetime", "~> 0.6" # the constraint matters, see below
32
- ```
33
-
34
-
35
- Maintainers: see [docs/releasing.md](docs/releasing.md).
36
-
37
- ## Quick start
38
-
39
- ```ruby
40
- require "onetime"
41
-
42
- client = Onetime::Client.new(
43
- base_url: "https://ca.onetimesecret.com", # choose your region's API host (required)
44
- customer: "ur1abc23defghijklmnop", # customer extid (see below)
45
- api_token: ENV["ONETIME_API_TOKEN"], # API token from your account page
46
- api_version: :v2, # :v1 or :v2 (default)
47
- )
48
-
49
- # Conceal a secret you already have
50
- res = client.secrets.conceal(secret: "hunter2", ttl: 3600, passphrase: "pw12")
51
- res.dig("record", "receipt", "identifier") # the receipt (creator) key
52
- res.dig("record", "secret", "identifier") # the secret (recipient) key
53
-
54
- # Generate a random secret server-side
55
- client.secrets.generate(ttl: 86_400)
56
-
57
- # Reveal (consume) a secret — one-time only
58
- secret = client.secrets.reveal("abc123secretkey", passphrase: "pw12")
59
- secret.dig("record", "secret_value")
60
-
61
- # Service status (works on v1 and v2)
62
- client.status
63
- ```
64
-
65
- ### Authentication
66
-
67
- Authentication uses HTTP Basic, where the **customer extid** is the username
68
- and your **API token** is the password.
69
-
70
- The customer extid is a short, opaque identifier that begins with `ur` — for
71
- example `ur1abc23def`. It is shown, with a copy button, at the bottom of the
72
- user menu when you are signed in. Other identifiers the API uses are not
73
- interchangeable with it.
74
-
75
- The format is checked at construction, so a value of the wrong kind fails
76
- immediately rather than at the first request:
6
+ Update your Gemfile:
77
7
 
78
8
  ```ruby
79
- Onetime::Client.new(base_url: "https://ca.onetimesecret.com",
80
- customer: "acct-123", api_token: ENV["ONETIME_API_TOKEN"])
81
- # => Onetime::ConfigurationError: customer "acct-123" is not a customer extid:
82
- # extids begin with "ur" (e.g. "ur1abc23def"). ...
83
- ```
84
-
85
- > Self-hosted servers older than
86
- > [onetimesecret#3945](https://github.com/onetimesecret/onetimesecret/pull/3945)
87
- > silently accept invalid credentials and create the secret **anonymously**
88
- > instead of returning 401 — the call succeeds, but the secret never appears in
89
- > your account. Current servers return 401.
90
-
91
- ### Base URL (required)
92
-
93
- `base_url` must be the API host for your region, your self-hosted domain, or
94
- your custom domain. There is no default: deployments are region-isolated for
95
- data sovereignty, so the client cannot guess one for you.
96
-
97
- Regional API hosts:
98
-
99
- | Region | Host |
100
- |---|---|
101
- | United States | `https://us.onetimesecret.com` |
102
- | Europe | `https://eu.onetimesecret.com` |
103
- | United Kingdom | `https://uk.onetimesecret.com` |
104
- | Canada | `https://ca.onetimesecret.com` |
105
- | Aotearoa New Zealand | `https://nz.onetimesecret.com` |
106
-
107
- > The apex `onetimesecret.com` is the company website, not an API host, and
108
- > is rejected with a helpful error.
109
-
110
- ### Configuration
111
-
112
- | Option | Default | Notes |
113
- |----------------|-----------------------------------------------|-----------------------------------------|
114
- | `base_url` | — (**required**) | Region/self-hosted/custom domain |
115
- | `api_version` | `:v2` | `:v1` or `:v2` |
116
- | `customer` | `ENV["ONETIME_CUSTOMER_EXTID"]` | Customer extid (`ur...`) |
117
- | `api_token` | `ENV["ONETIME_API_TOKEN"]` | API token |
118
- | `timeout` | `30` | Read timeout (seconds) |
119
- | `open_timeout` | `10` | Connect timeout (seconds) |
120
- | `max_retries` | `2` | Retries for idempotent (GET) requests |
121
- | `logger` | `nil` | Receives per-request `debug` lines |
122
-
123
- Environment fallbacks: `base_url` ← `ONETIME_BASE_URL`; `customer` ←
124
- `ONETIME_CUSTOMER_EXTID`; `api_token` ← `ONETIME_API_TOKEN`.
125
-
126
- Clients are thread-safe: they hold only configuration and a stateless
127
- transport, opening a fresh connection per request.
128
-
129
- ## Anonymous and guest usage
130
-
131
- A client created without credentials is anonymous and can use public and guest
132
- endpoints:
133
-
134
- ```ruby
135
- guest = Onetime::Client.new(base_url: "https://ca.onetimesecret.com") # no credentials
136
- guest.secrets.conceal(secret: "no account needed", guest: true)
137
- ```
138
-
139
- ## Resources
140
-
141
- ### `client.secrets`
142
-
143
- | Method | v1 | v2 |
144
- |---|----|----|
145
- | `conceal(secret:, ttl:, passphrase:, recipient:, share_domain:)` | yes | yes |
146
- | `generate(ttl:, passphrase:, recipient:, share_domain:)` | yes | yes |
147
- | `reveal(key, passphrase:, continue:)` | yes | yes |
148
- | `show(key)` | — | yes |
149
- | `status(key)` | — | yes |
150
- | `status_list(keys)` | — | yes |
151
-
152
- `conceal` is also available as `share`. `reveal`/`show` accept either a bare
153
- key or a full secret URL.
154
-
155
- ### `client.receipts`
156
-
157
- | Method | v1 | v2 |
158
- |---|----|----|
159
- | `show(key)` | yes | yes |
160
- | `recent` | yes | yes |
161
- | `burn(key, passphrase:, continue:)` | yes | yes |
162
- | `update(key, memo:)` | — | yes |
163
-
164
- ### Meta
165
-
166
- `client.status` (v1 & v2), `client.version` / `client.supported_locales`
167
- (v2 only), `client.authcheck` (v1 only).
168
-
169
- ## Responses
170
-
171
- Resource methods return an `Onetime::Response` with indifferent (String or
172
- Symbol) key access:
173
-
174
- ```ruby
175
- res = client.secrets.conceal(secret: "hi")
176
- res["record"] # Hash
177
- res.dig(:record, :secret, :secret_value) # deep access
178
- res.success? # 2xx?
179
- res.http_status # Integer
180
- res.to_h # the parsed body
181
- ```
182
-
183
- The response shape is the API's, unchanged. v1 and v2 differ on purpose —
184
- v1 returns flat, all-string fields; v2 nests data under `record`/`details`
185
- with richer typing — and the client does not reconcile them. Read the
186
- [API docs](https://docs.onetimesecret.com/) for the shape of the version
187
- you target.
188
-
189
- ## Errors
190
-
191
- HTTP errors (status >= 400) raise typed exceptions following the API's
192
- ADR-013 error contract (`{ error:, error_type:, ... }`):
193
-
194
- ```ruby
195
- begin
196
- client.secrets.reveal("missing")
197
- rescue Onetime::NotFoundError => e
198
- e.message # human-readable message ("error" field)
199
- e.error_type # machine-readable type ("RecordNotFound")
200
- e.http_status # 404
201
- rescue Onetime::RateLimitError => e
202
- e.retry_after
203
- rescue Onetime::APIError => e
204
- # any other API error
205
- end
206
- ```
207
-
208
- | Exception | When |
209
- |---|---|
210
- | `Onetime::BadRequestError` | 400 / `FormError` (see `#field`) |
211
- | `Onetime::AuthenticationError` | 401 |
212
- | `Onetime::AccountRequiredError` | the operation needs an authenticated account (`requires_account`); subclasses `AuthenticationError`, keeps `#field` |
213
- | `Onetime::ForbiddenError` | 403 / `Forbidden`, `GuestRoutesDisabled` |
214
- | `Onetime::EntitlementError` | `EntitlementRequired` (see `#entitlement`) |
215
- | `Onetime::NotFoundError` | 404 / `RecordNotFound` |
216
- | `Onetime::RateLimitError` | 429 / `LimitExceeded` (see `#retry_after`) |
217
- | `Onetime::ServerError` | 5xx |
218
- | `Onetime::TransportError` / `TimeoutError` | network failures |
219
- | `Onetime::ConfigurationError` | bad `base_url`, malformed `customer` extid, incomplete credentials (raised at construction) |
220
-
221
- All inherit from `Onetime::Error`.
222
-
223
- `AccountRequiredError` exists because the service reports "this needs an
224
- account" inside a `400` form-error body (`field: "requires_account"`). Mapping
225
- that to `BadRequestError` sent people auditing their request payload for a
226
- problem that was never there, so it gets its own class under
227
- `AuthenticationError`:
228
-
229
- ```ruby
230
- begin
231
- client.secrets.conceal(secret: "hi")
232
- rescue Onetime::AccountRequiredError => e
233
- e.field # "requires_account" — preserved
234
- e.http_status # whatever the server sent (400 today)
235
- end
236
- ```
237
-
238
- ## Development
239
-
240
- ```sh
241
- bundle install
242
- rake test
9
+ gem "onetimesecret", "~> 0.7.0"
243
10
  ```
244
11
 
245
- ## License
12
+ The Ruby API remains under the `Onetime` namespace. Both
13
+ `require "onetimesecret"` and `require "onetime"` are supported by the
14
+ canonical package.
246
15
 
247
- See [LICENSE.txt](LICENSE.txt).
16
+ This package contains no implementation files. It depends on `onetimesecret`
17
+ so existing `onetime` users can transition without loading conflicting files.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onetime
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Delano Mandelbaum
@@ -10,19 +10,19 @@ cert_chain: []
10
10
  date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
- name: minitest
13
+ name: onetimesecret
14
14
  requirement: !ruby/object:Gem::Requirement
15
15
  requirements:
16
16
  - - "~>"
17
17
  - !ruby/object:Gem::Version
18
- version: '5.0'
19
- type: :development
18
+ version: 0.7.0
19
+ type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - "~>"
24
24
  - !ruby/object:Gem::Version
25
- version: '5.0'
25
+ version: 0.7.0
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: rake
28
28
  requirement: !ruby/object:Gem::Requirement
@@ -37,26 +37,15 @@ dependencies:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
39
  version: '13.0'
40
- description: A dependency-free Ruby client for the OnetimeSecret API, supporting the
41
- v1 and v2 API versions.
40
+ description: The onetime gem has moved to the canonical onetimesecret package.
42
41
  email:
43
42
  - gems@onetimesecret.com
44
43
  executables: []
45
44
  extensions: []
46
45
  extra_rdoc_files: []
47
46
  files:
48
- - CHANGES.txt
49
47
  - LICENSE.txt
50
48
  - README.md
51
- - lib/onetime.rb
52
- - lib/onetime/client.rb
53
- - lib/onetime/configuration.rb
54
- - lib/onetime/errors.rb
55
- - lib/onetime/resources/receipts.rb
56
- - lib/onetime/resources/secrets.rb
57
- - lib/onetime/response.rb
58
- - lib/onetime/transport.rb
59
- - lib/onetime/version.rb
60
49
  homepage: https://github.com/onetimesecret/onetime-ruby
61
50
  licenses:
62
51
  - MIT
@@ -66,6 +55,17 @@ metadata:
66
55
  documentation_uri: https://docs.onetimesecret.com/
67
56
  changelog_uri: https://github.com/onetimesecret/onetime-ruby/blob/main/CHANGES.txt
68
57
  rubygems_mfa_required: 'true'
58
+ post_install_message: |2+
59
+
60
+ The `onetime` gem has moved to `onetimesecret`.
61
+
62
+ Update your Gemfile:
63
+
64
+ gem "onetimesecret", "~> 0.7.0"
65
+
66
+ The Ruby namespace remains `Onetime`, and `require "onetime"` remains
67
+ supported by the canonical gem.
68
+
69
69
  rdoc_options: []
70
70
  require_paths:
71
71
  - lib
@@ -82,5 +82,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
82
  requirements: []
83
83
  rubygems_version: 3.6.9
84
84
  specification_version: 4
85
- summary: Official Ruby client for the OnetimeSecret API
85
+ summary: Compatibility package; use the onetimesecret gem
86
86
  test_files: []
87
+ ...
data/CHANGES.txt DELETED
@@ -1,102 +0,0 @@
1
- ONETIME, CHANGES
2
-
3
- #### 0.6.0 (unreleased; tag v0.6.0 to publish) #########
4
-
5
- The first release of the `onetime` gem since 0.5.1 (2013): the same gem,
6
- cleaned up and brought current. The API surface changes completely, and
7
- the command-line tool moves out to `onetime-cli`, so treat this as a
8
- rewrite rather than a drop-in upgrade. See docs/releasing.md for the
9
- RubyGems publishing steps.
10
-
11
- * REWRITE: Modern, zero-dependency client built on stdlib Net::HTTP.
12
- A clean break from 0.5.x (2013); no backward compatibility is maintained.
13
-
14
- * ADDED: Onetime::AccountRequiredError for responses that require an
15
- authenticated account. The service reports this inside a 400 form-error
16
- body (field "requires_account"), which previously surfaced as
17
- BadRequestError and sent callers auditing a request body that was fine.
18
- It subclasses AuthenticationError and preserves #field. Also matched via
19
- error_key, code (e.g. GUEST_CONCEAL_REQUIRES_ACCOUNT) and the
20
- RequiresAccount / AccountRequired error types.
21
-
22
- * ADDED: customer extid format validation at client construction. Values
23
- that don't match the "ur..." extid shape are rejected immediately, with a
24
- message that says where to find the right one.
25
-
26
- * ADDED: Release workflow (.github/workflows/release.yml) publishing to
27
- RubyGems via Trusted Publishing on a v* tag, with a tag/version guard,
28
- plus docs/releasing.md.
29
-
30
- * CHANGE: README installation instructions now ask for the `~> 0.6`
31
- version constraint, and say why: the previous release under this gem
32
- name is the 2013 command-line tool (0.5.1), which an unconstrained
33
- dependency can still resolve to.
34
-
35
- * CHANGE: README authentication section now describes the customer extid
36
- format up front, rather than contrasting it with the pre-1.0 email custid.
37
-
38
- * ADDED: Onetime::Client with secrets/receipts resources and meta methods.
39
- * ADDED: Support for the v1 and v2 APIs (selectable via api_version).
40
- * ADDED: Typed error hierarchy mapped to the ADR-013 wire format
41
- ({ error, error_type, ... }) and legacy v1 { message } responses.
42
- * ADDED: Indifferent-access Onetime::Response wrapper.
43
- * ADDED: Anonymous / guest endpoint support for v2.
44
- * ADDED: Retries with exponential backoff for idempotent requests.
45
- * ADDED: Minitest test suite (unit + real Net::HTTP integration).
46
-
47
- * CHANGE: Authentication uses the customer extid (the "ur..." identifier at
48
- the bottom of the user menu) as the HTTP Basic username, with the API
49
- token as the password. Set it via `customer:` / ONETIME_CUSTOMER_EXTID.
50
- * CHANGE: base_url is now required (no default). Region-isolated deployments
51
- mean there is no safe default; the apex onetimesecret.com (company website)
52
- is rejected with guidance toward regional/self-hosted/custom hosts.
53
- * CHANGE: Requires Ruby 3.1+.
54
- * CHANGE: The `onetime` CLI moves to a separate `onetime-cli` gem.
55
-
56
- * REMOVED: httparty, drydock, jeweler, and yajl dependencies.
57
- * REMOVED: Legacy Onetime::API / OT::API shim, the OT top-level alias, the
58
- `username:` option alias, and the old ONETIME_HOST / ONETIME_CUSTID /
59
- ONETIME_APIKEY environment variables.
60
- * REMOVED: The drydock-based `bin/onetime` executable and the gem signing
61
- certificate.
62
- * REMOVED: The redundant top-level VERSION file; lib/onetime/version.rb is
63
- the single source of version truth.
64
-
65
- #### 0.5.1 (2013-02-12) ###############################
66
-
67
- * ADDED: global recipient parameter for 'generate' and 'share' commands.
68
-
69
- #### 0.5.0 (2013-02-12) ###############################
70
-
71
- * ADDED: Support for getting secrets based on the URI
72
- * ADDED: Command alias 'get' for 'secret'
73
- * ADDED: Explicit support for string format
74
- * FIXED: Confusion around csv support (there is no csv support)
75
- * CHANGE: Disabled checking for tty. Just assume string format.
76
- * CHANGE: 'secret' command returns just the secret message by default (not yaml)
77
-
78
-
79
- #### 0.4.1 (2013-02-12) ###############################
80
-
81
- * CHANGE: All releases will now be signed. See "Installation" in the readme.
82
- * CHANGE: json dependency upgraded from 1.6.4 to 1.6.8
83
-
84
- #### 0.4.0 (2012-01-07) ###############################
85
-
86
- * ADDED: Support for ttl, passphrase, and email recipient
87
- * ADDED: Better error handling
88
- * CHANGE: env variable ONETIME_ACCOUNT -> ONETIME_CUSTID
89
- * CHANGE: global option -u is now -H
90
-
91
-
92
- #### 0.3.1 (2012-01-06) ###############################
93
-
94
- * FIXED: Added httparty to gemspec dependencies
95
- * ADDED: X-Onetime-Client header
96
-
97
-
98
- #### 0.3.0 (2012-01-06) ###############################
99
-
100
- Initial public release
101
-
102
-
@@ -1,100 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "configuration"
4
- require_relative "transport"
5
- require_relative "resources/secrets"
6
- require_relative "resources/receipts"
7
-
8
- module Onetime
9
- # The main entry point for the OnetimeSecret API client.
10
- #
11
- # client = Onetime::Client.new(
12
- # base_url: "https://ca.onetimesecret.com",
13
- # customer: "ur1abc23def", # customer extid
14
- # api_token: ENV["ONETIME_API_TOKEN"],
15
- # api_version: :v2, # :v1 or :v2
16
- # )
17
- #
18
- # client.secrets.conceal(secret: "hunter2", ttl: 3600)
19
- # client.receipts.recent
20
- # client.status
21
- #
22
- # A client is safe to share across threads: it holds configuration and a
23
- # stateless transport, and creates a fresh Net::HTTP connection per request.
24
- class Client
25
- attr_reader :config, :transport
26
-
27
- # Accepts the same keyword arguments as Onetime::Configuration, or an
28
- # already-built Configuration via `config:`.
29
- def initialize(config: nil, **options)
30
- @config = config || Configuration.new(**options)
31
- @config.validate!
32
- @transport = @config.transport || Transport.new(@config)
33
- end
34
-
35
- def api_version
36
- config.api_version
37
- end
38
-
39
- # Secret resource accessor (conceal/generate/reveal/show/status).
40
- def secrets
41
- @secrets ||= Resources::Secrets.new(self)
42
- end
43
-
44
- # Receipt resource accessor (show/recent/burn/update).
45
- def receipts
46
- @receipts ||= Resources::Receipts.new(self)
47
- end
48
-
49
- # --- Meta / public endpoints -------------------------------------------
50
-
51
- # Service status. Available on both v1 and v2.
52
- def status
53
- request(:get, "/status")
54
- end
55
-
56
- # Service version. (v2 only)
57
- def version
58
- require_version!(:v2, "version")
59
- request(:get, "/version")
60
- end
61
-
62
- # Locales supported by the service. (v2 only)
63
- def supported_locales
64
- require_version!(:v2, "supported_locales")
65
- request(:get, "/supported-locales")
66
- end
67
-
68
- # Verify the configured credentials are valid. (v1 only)
69
- def authcheck
70
- require_version!(:v1, "authcheck")
71
- request(:get, "/authcheck")
72
- end
73
-
74
- # --- Low-level request helper ------------------------------------------
75
-
76
- # Issue a request against the configured API version. The path is
77
- # relative to the version prefix (e.g. "/secret/conceal").
78
- #
79
- # @return [Onetime::Response]
80
- def request(method, path, query: nil, body: nil, form: nil, raise_on_error: true)
81
- transport.request(
82
- method, full_path(path),
83
- query: query, body: body, form: form, raise_on_error: raise_on_error
84
- )
85
- end
86
-
87
- private
88
-
89
- def full_path(path)
90
- "#{config.api_path_prefix}#{path}"
91
- end
92
-
93
- def require_version!(expected, operation)
94
- return if api_version == expected
95
-
96
- raise UnsupportedOperationError,
97
- "#{operation} is only available on API #{expected}; client is configured for #{api_version}"
98
- end
99
- end
100
- end