yrby-rails 0.4.0 → 0.5.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: 1fe04378813fb80d02f8a7044258741096d7db25ddfca9d15451055bb00893a0
4
- data.tar.gz: fa3f4d4f4b5bd62884c56235addb80c38c0c6b2185ffeb8f7862b83389bbcbd0
3
+ metadata.gz: 805c1e286dbc5d7fd802c9b6a1a70fce29b9ea10b6ba1e45966c5c29507cc4c2
4
+ data.tar.gz: e5939ca7311f642d1685ad785f8ea8b312d6ae20f59661139f481b95a1253fb2
5
5
  SHA512:
6
- metadata.gz: 4e1226ee5c5de50fb97cd8712f2e9dd4ac0730be26449d0053e177910516308caf7021b0b0e192b63ae19f693c417455fcdab53d45135434acae72352064550e
7
- data.tar.gz: 5a47202000292a09671ce92791b5accc72400eb13e035d26994c65bf490b0b1c8abddb30a69d0c73fb1876ff01db7736fe1fc18707367dbcf74ae822b37eca30
6
+ metadata.gz: aa51adae8ea5fc9259453730d24a609c7faf990ceef1a6c4bce18a49123d6222a1402695bcb9d44e3e53dd634ab560522ee03f705c892d7dfd188121205cfbb8
7
+ data.tar.gz: '09ada40a8d1e1989a7a514e8b06ea5128d0fcb3cee79a59c61430681634b54d6f5ee7db717da3c9b94ad07137ef7d49367ace024f5d5ac0cf377925375ea0bdf'
data/CHANGELOG-rails.md CHANGED
@@ -5,6 +5,21 @@ documented here. The
5
5
  format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
6
6
  this project aims to follow [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.5.0] - 2026-08-05
9
+
10
+ ### Added
11
+
12
+ - `Y::EncryptedDocument` / `Y::EncryptedDocumentUpdate`: document storage
13
+ encrypted with Active Record encryption (`state` and update payloads),
14
+ on the same tables — the class you access through decides the
15
+ cryptography, the way `ActionText::EncryptedRichText` does. Point a
16
+ channel's `on_load`/`on_change` (or a record association) at
17
+ `Y::EncryptedDocument` and configure the app's encryption keys. Keep
18
+ one access path per document: rows written encrypted read back as
19
+ ciphertext through the plain classes. Ciphertext is larger than the
20
+ plaintext, so the effective payload cap is roughly three quarters of
21
+ the column limit.
22
+
8
23
  ## [0.4.0] - 2026-08-04
9
24
 
10
25
  ### Changed
data/README.md CHANGED
@@ -492,6 +492,13 @@ The models ship in the gem, the way Action Text owns
492
492
  quarantined until they heal rather than compacted into state or
493
493
  deleted. Destroying a document deletes its updates with it.
494
494
 
495
+ Encrypted storage: `Y::EncryptedDocument` stores `state` and update
496
+ payloads through Active Record encryption on the same tables, the way
497
+ `ActionText::EncryptedRichText` does — point the channel's
498
+ `on_load`/`on_change` at it instead and configure your app's encryption
499
+ keys. Use one access path per document: rows written encrypted read back
500
+ as ciphertext through the plain classes.
501
+
495
502
  The migration creates `y_documents` and `y_document_updates`. To rename
496
503
  them, edit the generated migration and point `Y::Document.table_name` /
497
504
  `Y::DocumentUpdate.table_name` at the new names in an initializer.
@@ -119,7 +119,7 @@ class Y::Document < ActiveRecord::Base
119
119
  # healed by a newer tail row is served immediately instead of waiting
120
120
  # for the next compaction.
121
121
  def load_state
122
- tail = Y::DocumentUpdate.where(document_id: id).pluck(:payload)
122
+ tail = updates.reset.pluck(:payload) # reset: never a cached tail
123
123
  snapshot = self.class.where(id: id).pick(:state)
124
124
  return snapshot if tail.empty?
125
125
 
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ # A document whose stored bytes are encrypted with Active Record encryption
4
+ # (state here, update payloads via Y::EncryptedDocumentUpdate). Same tables
5
+ # as Y::Document — the class you access through decides the cryptography,
6
+ # the way ActionText::EncryptedRichText does for rich text. Keep one access
7
+ # path per document: rows written encrypted read back as ciphertext through
8
+ # the plain classes.
9
+ #
10
+ # Requires the app to configure Active Record encryption keys. Ciphertext
11
+ # is larger than the plaintext (a serialized envelope around Base64), so
12
+ # the effective payload cap drops to roughly three quarters of the column
13
+ # limit.
14
+ class Y::EncryptedDocument < Y::Document
15
+ has_many :updates, class_name: "Y::EncryptedDocumentUpdate",
16
+ foreign_key: :document_id, dependent: :delete_all,
17
+ inverse_of: :document
18
+
19
+ encrypts :state
20
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ # The encrypted tail row: Y::DocumentUpdate with the payload encrypted.
4
+ # Written and read through Y::EncryptedDocument's updates association.
5
+ class Y::EncryptedDocumentUpdate < Y::DocumentUpdate
6
+ belongs_to :document, class_name: "Y::EncryptedDocument"
7
+
8
+ encrypts :payload
9
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Yrby
4
4
  module Rails
5
- VERSION = "0.4.0"
5
+ VERSION = "0.5.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yrby-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - JP Camara
@@ -136,6 +136,8 @@ files:
136
136
  - README.md
137
137
  - app/models/y/document.rb
138
138
  - app/models/y/document_update.rb
139
+ - app/models/y/encrypted_document.rb
140
+ - app/models/y/encrypted_document_update.rb
139
141
  - lib/generators/yrby/install/USAGE
140
142
  - lib/generators/yrby/install/install_generator.rb
141
143
  - lib/generators/yrby/install/templates/document_channel.rb