omniauth-vitsme 0.5.0 → 0.6.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: fe1046427776ebdb907dcc848a56718b386960ea66222aa903a1e1a63876049b
4
- data.tar.gz: 86549c0e17bfbb4359c131818c5058748a2af1ccc37c96625b7d2a28cc6f1e40
3
+ metadata.gz: 110b41d2f27a5dc18c65283b4fab14a657c95c3dd5794f9da5b5520d60e6a3d7
4
+ data.tar.gz: c1815b99a5c966917bcb06db93b73fcfda710c9ca29b7f3699fc3be5d9e13f19
5
5
  SHA512:
6
- metadata.gz: 6f9e23e6f7bc5c05da65f0fe17151929a94b2cfa4c2a081e2321f614e8bc7fb65a952b7d1d9ff9dda460d0efa558923f886d3acee31a8aa382b0b8243fa7725d
7
- data.tar.gz: b577a1d0cd8d69dc49e082c6e71638b7e3e649cc1f703f9fb916651cec7e32cb434fa777394d1e3c8751dcc3165143e55c9e5a377421b5f4d8ff7028534fd5a6
6
+ metadata.gz: c3fea5371b786b385adf82fa06380cc0b1e290cfb6034c57488d4a9fb645e1eafdc69a7e95c4791fb7b56f6664bddf8397f9e4b3358042db83071f44b441ea10
7
+ data.tar.gz: 0abf8f83269d66acfd2980bdc28714aa4d411edd3af7e8dd3fc109fcb9d81e2955beb0757188e174f1c2e5dc29b0e98c26184daae4b9da91575153f12c4e82dc
data/AGENTS.md CHANGED
@@ -10,7 +10,9 @@ person's verified details to another.
10
10
  Read it instead of guessing; an unknown scope raises at boot.
11
11
  - Ask for the least that answers the question: `age__over_18` rather than `birthdate`, a gate
12
12
  rather than `nationality` when "is this person Israeli?" is all you need.
13
- - vits.me has no email, phone, picture or username claim. Ask the person for anything else.
13
+ - vits.me has no email, phone or username claim, and no picture URL. Ask the person for anything else.
14
+ - `portrait` is the person's photo, sent whole as an `OmniAuth::Vitsme::Image`. Attach it to your own
15
+ storage in the callback (`photo.io`); never link to vits.me for it, and never log it.
14
16
 
15
17
  ## Rules
16
18
 
@@ -40,8 +42,8 @@ person's verified details to another.
40
42
  `not_signed_in`, `identity_mismatch`, `unverified_identity`, `nationality_gate_refused`,
41
43
  `site_suspended`, `access_denied`.
42
44
  11. **Ask only for scopes the site registered.** Its page at vits.me/developer sets which it may ask
43
- for, and vits.me refuses a request for any other. `il_government_id_number` is enabled by vits.me
44
- on request, per site.
45
+ for, and vits.me refuses a request for any other. `il_government_id_number` and `portrait` are
46
+ enabled by vits.me on request, per site.
45
47
  12. **Partners (KNOTs) are asked directly, not through vits.me.** Use `provider :vitsme_partner` with the
46
48
  partner's issuer as vits.me lists it (`OmniAuth::Vitsme::Partner.listing`), its own scope names from its
47
49
  documentation, and `id_token:` returning the vits.me ID token you kept for the signed-in person. Never ask
data/CHANGELOG.md CHANGED
@@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.6.0] - 2026-11-21
11
+
12
+ ### Added
13
+
14
+ - The `full_name__local` and `full_name__intl` scopes: a full name in the person's own language and
15
+ script, and in its international variant (English, capitalized, Latin letters with dashes and apostrophes,
16
+ no accents). The person may leave out given names or show them as initials, keeping one written out.
17
+ - The `portrait` scope: the person's photo, the first picture claim. `extra.claims["portrait"]` is an
18
+ `OmniAuth::Vitsme::Image` (`content_type`, `width`, `height`, `data`, `io`), decoded from the strict-base64
19
+ JPEG vits.me sends whole in UserInfo; anything else (another type, loose base64, over 200 KB) is dropped.
20
+ It is kept out of `info` and `extra.raw_info`, and its bytes out of `inspect`. Enabled by vits.me per site,
21
+ on request. `OmniAuth::Vitsme::Test` takes one as a claim.
22
+
10
23
  ## [0.5.0] - 2026-11-13
11
24
 
12
25
  ### Changed (breaking)
data/README.md CHANGED
@@ -26,7 +26,7 @@ rules built in.
26
26
 
27
27
  ```ruby
28
28
  # Gemfile
29
- gem "omniauth-vitsme", "~> 0.5"
29
+ gem "omniauth-vitsme", "~> 0.6"
30
30
  gem "omniauth-rails_csrf_protection" # OmniAuth 2 starts sign-in by POST only
31
31
  ```
32
32
 
@@ -79,9 +79,12 @@ formats, is [data/claims.json](data/claims.json).
79
79
  |---|---|---|
80
80
  | `name` | String: one name at the detail the person chose | `"Jane"`, `"J. D."`, `"Jane Doe"` |
81
81
  | `name__full` | String | `"Jane Doe"` |
82
+ | `full_name__local` | String: a full name in the person's own language and script; given names may be left out or initialled, one kept whole | `"יובל טוביאס"`, `"José Núñez"` |
83
+ | `full_name__intl` | String: the same in its international variant (English, capitalized, Latin letters, dashes and apostrophes, no accents) | `"Jose Nunez"`, `"Jane M. Doe"` |
82
84
  | `nationality` | String, ISO 3166-1 alpha-2 | `"IL"` |
83
85
  | `nationality__in_eu`, `__in_eea`, `__in_esm`, `__gdpr_compliant` | Boolean | `true` |
84
86
  | `il_government_id_number` | String | (sensitive: ask only with a legal need) |
87
+ | `portrait` | `OmniAuth::Vitsme::Image`: the person's photo, a JPEG, with `content_type`, `width`, `height`, `data` and `io` | (enabled by vits.me on request; see below) |
85
88
  | `age` | String: a threshold, generation, range or years | `"over_18"`, `"gen_x"`, `"25_to_34"`, `"37"` |
86
89
  | `age__years` | Integer | `37` |
87
90
  | `age__range` | String | `"25_to_34"` |
@@ -105,7 +108,23 @@ else ask_them_to_share_it
105
108
  end
106
109
  ```
107
110
 
108
- There is no email, phone, picture or username. If you need a public handle, ask the person for one.
111
+ There is no email, phone or username, and no picture URL. If you need a public handle, ask the person for one.
112
+
113
+ **The photo.** `portrait` is the face the person's passport chip carries, the one they chose to share. It
114
+ arrives whole in the callback, as a plain JPEG at the passport's own resolution and framing, never cropped:
115
+ **keep your own copy**, because there is no URL to fetch it from later and the tokens live five seconds.
116
+
117
+ ```ruby
118
+ if (photo = auth.extra.claims["portrait"])
119
+ user.photo.attach(io: photo.io, filename: "portrait.jpg", content_type: photo.content_type)
120
+ end
121
+ ```
122
+
123
+ It is in `extra.claims` only: not in `info`, and left out of `extra.raw_info` so an auth hash kept in a cookie
124
+ session does not carry the picture. Anything that is not the JPEG vits.me promises (another type, loose
125
+ base64, over 200 KB) is dropped. A face links a person's accounts across sites whatever their identifiers, so
126
+ vits.me enables the scope per site, on request, like `il_government_id_number`. In tests, pass one:
127
+ `OmniAuth::Vitsme::Test.mock_auth(claims: { portrait: OmniAuth::Vitsme::Image.new(content_type: "image/jpeg", width: 3, height: 4, data: jpeg_bytes) })`.
109
128
 
110
129
  ## Verifying a signed-in person
111
130
 
data/data/claims.json CHANGED
@@ -57,6 +57,19 @@
57
57
  "examples": ["Jane Doe", "Jane M. Doe"],
58
58
  "description": "A full name, chosen from the person's full-name forms."
59
59
  },
60
+ "full_name__local": {
61
+ "scope": "full_name__local",
62
+ "type": "string",
63
+ "examples": ["יובל טוביאס", "יובל ש. טוביאס", "José Núñez"],
64
+ "description": "A full name in the person's own language and script, as their documents print it: Hebrew for an Israeli. The person may leave out given names or show them as initials, keeping at least one written out; the family name is whole. Not a legal name."
65
+ },
66
+ "full_name__intl": {
67
+ "scope": "full_name__intl",
68
+ "type": "string",
69
+ "format": "Latin letters A-Z, words joined by a space, a dash or an apostrophe, and a period only after an initial; capitalized, never all caps; no accents",
70
+ "examples": ["Jane Doe", "Jane M. Doe", "Jean-Luc O'Brien", "Jose Nunez"],
71
+ "description": "A full name in its international variant: the English version, capitalized, in Latin letters without accents. The person may leave out given names or show them as initials, keeping at least one written out; the family name is whole. Not a legal name."
72
+ },
60
73
  "nationality": {
61
74
  "scope": "nationality",
62
75
  "type": "string",
@@ -89,6 +102,13 @@
89
102
  "type": "string",
90
103
  "description": "Israeli government ID number (teudat zehut). Highly sensitive: request only with a legal need."
91
104
  },
105
+ "portrait": {
106
+ "scope": "portrait",
107
+ "type": "image",
108
+ "format": "An object: content_type \"image/jpeg\", width and height in pixels, and content, the JPEG in standard base64 (RFC 4648 §4, no line breaks). Always a plain sRGB JPEG with no metadata, at most 200 KB, at the passport's own resolution and framing (about 7:9), never cropped or upscaled.",
109
+ "examples": [{ "content_type": "image/jpeg", "width": 480, "height": 640, "content": "/9j/4AAQSkZJRgABAQ…" }],
110
+ "description": "The person's photo: the face their passport chip carries, the one they chose to share. Sent whole: keep your own copy, there is no URL to fetch it from. Enabled by vits.me on request, per site, since a face links a person's accounts across sites whatever their identifiers."
111
+ },
92
112
  "age": {
93
113
  "scope": "age",
94
114
  "type": "string",
@@ -33,10 +33,16 @@ module OmniAuth
33
33
  # Tentative accounts (keyed by a pending signup's FLUID) to merge into this person.
34
34
  fluid_uids: Array(raw_info['fluid']),
35
35
  claims: claims(raw_info),
36
- raw_info: raw_info
36
+ # Without the pictures: kept whole there, they would follow the auth hash into a cookie session
37
+ # and overflow it. The decoded picture is in `claims`.
38
+ raw_info: raw_info.except(*image_claims)
37
39
  }
38
40
  end
39
41
 
42
+ def image_claims
43
+ @image_claims ||= Catalog.claims.select { |_name, spec| spec['type'] == 'image' }.keys.freeze
44
+ end
45
+
40
46
  # The disclosure claims vits.me returned, typed by the catalog. Identity claims (sub, solid,
41
47
  # defunct_solids, fluid) are in `uid`, `lookup_uids` and `fluid_uids` instead; anything the
42
48
  # catalog does not know stays in raw_info only.
@@ -50,6 +50,7 @@ module OmniAuth
50
50
  when 'boolean' then boolean(value)
51
51
  when 'integer' then integer(value)
52
52
  when 'string_array' then Array(value).map(&:to_s)
53
+ when 'image' then Image.from_claim(value)
53
54
  else value.to_s
54
55
  end
55
56
  end
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'base64'
4
+ require 'stringio'
5
+
6
+ module OmniAuth
7
+ module Vitsme
8
+ # A picture claim (`portrait`), decoded: the JPEG vits.me sent, with its size. vits.me sends it whole, in
9
+ # UserInfo, so your app keeps its own copy:
10
+ #
11
+ # if (photo = auth.extra.claims['portrait'])
12
+ # user.photo.attach(io: photo.io, filename: 'portrait.jpg', content_type: photo.content_type)
13
+ # end
14
+ #
15
+ # Read only from what vits.me promises: a JPEG (by its bytes, not only its label) in strict base64, no
16
+ # larger than MAX_BYTES. Anything else is dropped (nil), never guessed at.
17
+ Image = Struct.new(:content_type, :width, :height, :data, keyword_init: true) do
18
+ def io = StringIO.new(data)
19
+ def bytesize = data.bytesize
20
+
21
+ # The claim as vits.me sends it, for OmniAuth::Vitsme::Test.
22
+ def to_claim
23
+ { 'content_type' => content_type, 'width' => width, 'height' => height,
24
+ 'content' => Base64.strict_encode64(data) }
25
+ end
26
+
27
+ # The bytes are a person's face: never in an inspect, a log line or an exception message.
28
+ def inspect = "#<OmniAuth::Vitsme::Image #{content_type} #{width}x#{height} #{bytesize} bytes>"
29
+ alias_method :to_s, :inspect
30
+ end
31
+
32
+ class << Image
33
+ MAX_BYTES = 200 * 1024
34
+ JPEG_MAGIC = "\xFF\xD8\xFF".b
35
+
36
+ def max_bytes = MAX_BYTES
37
+
38
+ # An Image from the claim's JSON value, or nil.
39
+ def from_claim(value)
40
+ return value if value.is_a?(Image)
41
+ return nil unless value.is_a?(Hash)
42
+
43
+ value = value.transform_keys(&:to_s)
44
+ data = jpeg_bytes(value)
45
+ return nil unless data
46
+
47
+ new(content_type: 'image/jpeg', width: dimension(value['width']), height: dimension(value['height']),
48
+ data: data)
49
+ end
50
+
51
+ private
52
+
53
+ # The decoded content, if it is what vits.me promises: a JPEG label, strict base64, JPEG bytes, in size.
54
+ def jpeg_bytes(value)
55
+ content = value['content']
56
+ return nil unless value['content_type'] == 'image/jpeg' && content.is_a?(String)
57
+ return nil if content.bytesize > (MAX_BYTES * 4 / 3) + 4 # refused before it is decoded
58
+
59
+ data = Base64.strict_decode64(content)
60
+ data if data.bytesize <= MAX_BYTES && data.start_with?(JPEG_MAGIC)
61
+ rescue ArgumentError
62
+ nil
63
+ end
64
+
65
+ def dimension(value) = value.is_a?(Integer) && value.positive? ? value : nil
66
+ end
67
+ end
68
+ end
@@ -30,7 +30,9 @@ module OmniAuth
30
30
 
31
31
  # The UserInfo response vits.me would send: identity claims plus the disclosure claims given.
32
32
  def raw_info(uid:, claims: {}, defunct_uids: [], fluid_uids: [])
33
+ # A picture is given as an OmniAuth::Vitsme::Image and sent as vits.me sends it.
33
34
  claims = claims.transform_keys(&:to_s)
35
+ .transform_values { |value| value.respond_to?(:to_claim) ? value.to_claim : value }
34
36
  unknown = claims.keys.reject { |name| Catalog.claim(name) }
35
37
  raise ArgumentError, "omniauth-vitsme: unknown claim(s) #{unknown.join(', ')}" unless unknown.empty?
36
38
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OmniAuth
4
4
  module Vitsme
5
- VERSION = '0.5.0'
5
+ VERSION = '0.6.0'
6
6
  end
7
7
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'omniauth/vitsme/version'
4
4
  require 'omniauth/vitsme/issuers'
5
+ require 'omniauth/vitsme/image'
5
6
  require 'omniauth/vitsme/catalog'
6
7
  require 'omniauth/vitsme/auth_shape'
7
8
  require 'omniauth/vitsme/partner'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-vitsme
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuval Tobias
@@ -52,6 +52,7 @@ files:
52
52
  - lib/omniauth/vitsme/catalog.rb
53
53
  - lib/omniauth/vitsme/events.rb
54
54
  - lib/omniauth/vitsme/http.rb
55
+ - lib/omniauth/vitsme/image.rb
55
56
  - lib/omniauth/vitsme/issuers.rb
56
57
  - lib/omniauth/vitsme/jws.rb
57
58
  - lib/omniauth/vitsme/keys.rb