calmlens 0.27.5 → 0.27.6
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 +4 -4
- data/lib/calmlens/error_codes.rb +4 -0
- data/lib/calmlens/testing/fake_api.rb +19 -23
- data/lib/calmlens/version.rb +1 -1
- data/sig/error_codes.rbs +2 -0
- data/sig/models.rbs +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a4d40bb424d825417760e22485731a17019108a5fd485eaaa406fe0d04a768bb
|
|
4
|
+
data.tar.gz: 288157ee652bda22b8481bd21cd051898f8ebcb5b02dd8609dd3abdb1c8ace24
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: afe4728bd5220e0f97b103c32479150ebd59572bdf5dc06825e6a4ddfeb594cc56e83523864c4238c6cdfdd5fd659fe8eca4384eccf7a7d2c4141598d3f05381
|
|
7
|
+
data.tar.gz: e5403ea13a37801f0ecc13adf0326c4a6e06be4a3662d0e6fc56905cbaed6cdc9bdf023185432e73b5f597cf847120d00e20fa7f29bbe2efcb4e7ca87ae2b9d4
|
data/lib/calmlens/error_codes.rb
CHANGED
|
@@ -44,6 +44,7 @@ module CalmLens
|
|
|
44
44
|
INVALID_IMAGE = 'image/invalid'
|
|
45
45
|
IMAGE_TOO_LARGE = 'image/too-large'
|
|
46
46
|
FREE_UPLOADS_EXHAUSTED = 'usage/free-uploads-exhausted'
|
|
47
|
+
WEBSITE_BILLING_REQUIRED = 'payment/billing-required'
|
|
47
48
|
UPLOADS_PAUSED = 'usage/uploads-paused'
|
|
48
49
|
UNSUPPORTED_UPLOAD_TYPE = 'upload/unsupported-type'
|
|
49
50
|
INVALID_UPLOAD_PAYLOAD = 'upload-payload/invalid'
|
|
@@ -83,6 +84,7 @@ module CalmLens
|
|
|
83
84
|
HASH_LIST_ENTRY_NOT_FOUND = 'hash-list-entry/not-found'
|
|
84
85
|
HASH_LIST_LIMIT_REACHED = 'hash-list/limit-reached'
|
|
85
86
|
HASH_LIST_ENTRY_LIMIT_REACHED = 'hash-list-entry/limit-reached'
|
|
87
|
+
HASH_LIST_ENTRY_QUALITY_TOO_LOW = 'hash-list-entry/quality-too-low'
|
|
86
88
|
HASH_LIST_ASSET_NOT_HASHED = 'hash-list/asset-not-hashed'
|
|
87
89
|
POLICY_NOT_FOUND = 'policy/not-found'
|
|
88
90
|
POLICY_REVISION_CONFLICT = 'policy/revision-conflict'
|
|
@@ -164,6 +166,7 @@ module CalmLens
|
|
|
164
166
|
'image/invalid' => 422,
|
|
165
167
|
'image/too-large' => 422,
|
|
166
168
|
'usage/free-uploads-exhausted' => 403,
|
|
169
|
+
'payment/billing-required' => 409,
|
|
167
170
|
'usage/uploads-paused' => 402,
|
|
168
171
|
'upload/unsupported-type' => 415,
|
|
169
172
|
'upload-payload/invalid' => 400,
|
|
@@ -203,6 +206,7 @@ module CalmLens
|
|
|
203
206
|
'hash-list-entry/not-found' => 404,
|
|
204
207
|
'hash-list/limit-reached' => 409,
|
|
205
208
|
'hash-list-entry/limit-reached' => 409,
|
|
209
|
+
'hash-list-entry/quality-too-low' => 422,
|
|
206
210
|
'hash-list/asset-not-hashed' => 409,
|
|
207
211
|
'policy/not-found' => 404,
|
|
208
212
|
'policy/revision-conflict' => 409,
|
|
@@ -1775,7 +1775,7 @@ module CalmLens
|
|
|
1775
1775
|
return not_available if item['content']['safetyHold']
|
|
1776
1776
|
return placeholder(method, item, authorised) if resource == 'placeholder'
|
|
1777
1777
|
|
|
1778
|
-
deliver(method, item, resource, params, selected ? options || {} : nil, authorised)
|
|
1778
|
+
deliver(method, item, resource, params, selected ? options || {} : nil, authorised, grant)
|
|
1779
1779
|
end
|
|
1780
1780
|
|
|
1781
1781
|
# What a grant doesn't cover, or, like the CDN, removed content for anyone (isAssetContentNotKept)
|
|
@@ -1862,13 +1862,13 @@ module CalmLens
|
|
|
1862
1862
|
# Serves a found asset's resource after the delivery, age and access checks, then whether it
|
|
1863
1863
|
# has the resource and takes the selector, then the transform options' schema check.
|
|
1864
1864
|
# `selector` is the selector's options (empty for a lens alone), or nil without one.
|
|
1865
|
-
def deliver(method, item, resource, params, selector, authorised)
|
|
1865
|
+
def deliver(method, item, resource, params, selector, authorised, grant)
|
|
1866
1866
|
stored = @state.content[item['id']]
|
|
1867
1867
|
refused = refuse_delivery(item, resource, stored, params, authorised)
|
|
1868
1868
|
return refused if refused
|
|
1869
1869
|
|
|
1870
1870
|
restricted = item['visibility'] != 'public'
|
|
1871
|
-
return embed(method, item
|
|
1871
|
+
return embed(method, item) if resource == 'embed'
|
|
1872
1872
|
|
|
1873
1873
|
# Then whether the asset has the resource, and whether it is a still image that takes a lens
|
|
1874
1874
|
# or transform: the preview always is, the rendered file only when it is an image.
|
|
@@ -1886,8 +1886,9 @@ module CalmLens
|
|
|
1886
1886
|
bytes, type = resource_body(item, resource, stored)
|
|
1887
1887
|
return not_available unless bytes
|
|
1888
1888
|
|
|
1889
|
-
|
|
1890
|
-
|
|
1889
|
+
image_response = still || (resource == 'original' && item['type'] == 'image')
|
|
1890
|
+
cache = delivery_cache_control(restricted, grant, params)
|
|
1891
|
+
cdn_response(method, bytes, delivery_headers(item, type, image_response, cache))
|
|
1891
1892
|
end
|
|
1892
1893
|
|
|
1893
1894
|
# The delivery checks, which refuse everyone, then age and access, as an error response, or nil.
|
|
@@ -1926,19 +1927,17 @@ module CalmLens
|
|
|
1926
1927
|
JSON.parse(params.fetch('viewerClaims', '{}'))['ageConfirmed'] == true
|
|
1927
1928
|
end
|
|
1928
1929
|
|
|
1929
|
-
def
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1930
|
+
def delivery_cache_control(restricted, grant, params)
|
|
1931
|
+
return 'private, no-store' if params.key?('viewerClaims')
|
|
1932
|
+
return 'private, no-cache' if restricted && !grant
|
|
1933
|
+
|
|
1934
|
+
max_age = grant ? ((grant[:expires_at] - @now.call) / 1000).clamp(0, 86_400) : 86_400
|
|
1935
|
+
"#{restricted ? 'private' : 'public'}, max-age=#{max_age}, must-revalidate"
|
|
1933
1936
|
end
|
|
1934
1937
|
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
cache = if params.key?('viewerClaims') then 'private, no-store'
|
|
1939
|
-
else "#{restricted ? 'private' : 'public'}, max-age=3600"
|
|
1940
|
-
end
|
|
1941
|
-
cdn_response(method, EMBED_HTML, { 'content-type' => 'text/html; charset=utf-8', 'cache-control' => cache,
|
|
1938
|
+
def embed(method, item)
|
|
1939
|
+
cdn_response(method, EMBED_HTML, { 'content-type' => 'text/html; charset=utf-8',
|
|
1940
|
+
'cache-control' => 'private, no-store',
|
|
1942
1941
|
'cache-tag' => "asset-#{item['id']}", 'x-content-type-options' => 'nosniff' })
|
|
1943
1942
|
end
|
|
1944
1943
|
|
|
@@ -1963,13 +1962,10 @@ module CalmLens
|
|
|
1963
1962
|
'cache-tag' => "asset-#{item['id']}", 'etag' => "\"#{thumbhash}\"")
|
|
1964
1963
|
end
|
|
1965
1964
|
|
|
1966
|
-
#
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
headers = { 'content-type' => type, 'cache-control' => "#{restricted ? 'private' : 'public'}, #{lifetime}",
|
|
1971
|
-
'cache-tag' => "asset-#{item['id']}" }
|
|
1972
|
-
headers.merge!('etag' => "\"#{item['id']}\"", 'expires' => Time.at((@now.call / 1000) + 31_536_000).utc.httpdate) if immutable
|
|
1965
|
+
# Active content is served as a download.
|
|
1966
|
+
def delivery_headers(item, type, image_response, cache)
|
|
1967
|
+
headers = { 'content-type' => type, 'cache-control' => cache, 'cache-tag' => "asset-#{item['id']}" }
|
|
1968
|
+
headers['etag'] = "\"#{item['id']}\"" if image_response
|
|
1973
1969
|
headers.merge!('x-content-type-options' => 'nosniff', 'content-security-policy' => "sandbox; default-src 'none'")
|
|
1974
1970
|
mime = type.downcase.split(';', 2).first.to_s.strip
|
|
1975
1971
|
headers['content-disposition'] = 'attachment' if ACTIVE_TYPES.include?(mime) || mime.end_with?('+xml')
|
data/lib/calmlens/version.rb
CHANGED
data/sig/error_codes.rbs
CHANGED
|
@@ -41,6 +41,7 @@ module CalmLens
|
|
|
41
41
|
INVALID_IMAGE: String
|
|
42
42
|
IMAGE_TOO_LARGE: String
|
|
43
43
|
FREE_UPLOADS_EXHAUSTED: String
|
|
44
|
+
WEBSITE_BILLING_REQUIRED: String
|
|
44
45
|
UPLOADS_PAUSED: String
|
|
45
46
|
UNSUPPORTED_UPLOAD_TYPE: String
|
|
46
47
|
INVALID_UPLOAD_PAYLOAD: String
|
|
@@ -80,6 +81,7 @@ module CalmLens
|
|
|
80
81
|
HASH_LIST_ENTRY_NOT_FOUND: String
|
|
81
82
|
HASH_LIST_LIMIT_REACHED: String
|
|
82
83
|
HASH_LIST_ENTRY_LIMIT_REACHED: String
|
|
84
|
+
HASH_LIST_ENTRY_QUALITY_TOO_LOW: String
|
|
83
85
|
HASH_LIST_ASSET_NOT_HASHED: String
|
|
84
86
|
POLICY_NOT_FOUND: String
|
|
85
87
|
POLICY_REVISION_CONFLICT: String
|
data/sig/models.rbs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Generated by script/generate_models.rb from testdata/types.json; do not edit.
|
|
2
2
|
module CalmLens
|
|
3
3
|
type moderation_qualifier = "sexual-pornographic-media" | "hate-nazi-symbols-public-display" | "hate-nazi-insignia-public-display" | "hate-nazi-genocide-public-peace" | "hate-nazi-genocide-denial-or-approval" | "hate-adjudicated-nazi-crimes-denial" | "violence-high-impact" | "self-harm-age-restricted" | "personal-information-contact" | "personal-information-email" | "personal-information-phone" | "personal-information-government-id" | "personal-information-financial" | "personal-information-location" | "personal-information-identifiers" | "personal-information-credentials" | "personal-information-request" | "personal-information-self-disclosure" | "personal-information-third-party" | "personal-information-historical" | "personal-information-documentary" | "personal-information-educational" | "personal-information-fictional" | "personal-information-support-prevention" | "profanity-mild" | "profanity-strong" | "profanity-slurs" | "profanity-obfuscated" | "profanity-historical" | "profanity-documentary" | "profanity-educational" | "profanity-fictional" | "profanity-support-prevention" | "sexual-nudity" | "sexual-activity" | "sexual-explicit-language" | "sexual-assault-media" | "sexual-non-consensual" | "sexual-intimate-image-abuse" | "sexual-extreme" | "sexual-strangulation" | "sexual-incest" | "sexual-minors" | "sexual-solicitation" | "sexual-paid" | "sexual-adult-promotion" | "sexual-revealing-clothing" | "sexual-suggestive" | "sexual-non-erotic-nudity" | "sexual-text" | "sexual-historical" | "sexual-documentary" | "sexual-educational" | "sexual-discussion" | "sexual-fictional" | "sexual-artistic" | "sexual-support-prevention" | "violence-attack" | "violence-threat" | "violence-preparation" | "violence-encouragement" | "violence-wish" | "violence-coded-incitement" | "violence-extremism" | "violence-injury" | "violence-violent-death" | "violence-natural-death" | "violence-graphic" | "violence-decapitation-act" | "violence-gore" | "violence-weapon" | "violence-sport" | "violence-text" | "violence-historical" | "violence-documentary" | "violence-educational" | "violence-discussion" | "violence-fictional" | "violence-fantasy" | "violence-support-prevention" | "self-harm-thoughts" | "self-harm-preparation" | "self-harm-act" | "self-harm-methods" | "self-harm-encouragement" | "self-harm-historical" | "self-harm-documentary" | "self-harm-educational" | "self-harm-fictional" | "self-harm-support-prevention" | "harassment-abuse" | "harassment-mild" | "harassment-bullying" | "harassment-public-target" | "harassment-threat" | "harassment-sexual" | "harassment-encouragement" | "harassment-historical" | "harassment-documentary" | "harassment-educational" | "harassment-fictional" | "harassment-support-prevention" | "hate-abuse" | "hate-slurs" | "hate-dehumanization" | "hate-inferiority" | "hate-exclusion" | "hate-symbol" | "hate-hostility" | "hate-threat" | "hate-personal" | "hate-historical" | "hate-documentary" | "hate-educational" | "hate-fictional" | "hate-counterspeech" | "hate-support-prevention" | "criminal-activity-demonstration" | "criminal-activity-preparation" | "criminal-activity-request" | "criminal-activity-instructions" | "criminal-activity-promotion" | "criminal-activity-coded-incitement" | "criminal-activity-substances" | "criminal-activity-grooming" | "criminal-activity-csam" | "criminal-activity-alcohol" | "criminal-activity-tobacco" | "criminal-activity-gambling" | "criminal-activity-fraud" | "criminal-activity-sexual-solicitation" | "criminal-activity-graffiti" | "criminal-activity-historical" | "criminal-activity-documentary" | "criminal-activity-educational" | "criminal-activity-discussion" | "criminal-activity-fictional" | "criminal-activity-support-prevention"
|
|
4
|
-
type event_type = "asset.uploaded" | "asset.classified" | "asset.region-restricted" | "asset.allowed" | "asset.limited" | "asset.age-restricted" | "asset.blocked" | "asset.purged" | "asset.failed" | "asset.progress-updated" | "asset.deleted" | "asset.content-removed" | "asset.retried" | "asset.review-requested" | "asset.review-completed" | "asset.hash-matched" | "usage.free-uploads-exhausted" | "usage.uploads-paused" | "upload-preset.daily-limit-reached" | "project.member-joined" | "project.member-removed" | "project.member-left" | "project.member-role-changed" | "project.invitation-sent" | "project.transferred" | "api-key.created" | "api-key.revoked" | "api-key.deleted" | "connector.disabled"
|
|
4
|
+
type event_type = "asset.uploaded" | "asset.classified" | "asset.region-restricted" | "asset.allowed" | "asset.limited" | "asset.age-restricted" | "asset.blocked" | "asset.purged" | "asset.failed" | "asset.progress-updated" | "asset.media-ready" | "asset.deleted" | "asset.content-removed" | "asset.retried" | "asset.review-requested" | "asset.review-completed" | "asset.hash-matched" | "usage.free-uploads-exhausted" | "usage.uploads-paused" | "upload-preset.daily-limit-reached" | "project.member-joined" | "project.member-removed" | "project.member-left" | "project.member-role-changed" | "project.invitation-sent" | "project.transferred" | "api-key.created" | "api-key.revoked" | "api-key.deleted" | "connector.disabled"
|
|
5
5
|
type event_fact_key = "asset-name" | "asset-type" | "file-format" | "test" | "parent-asset" | "flagged-categories" | "moderation-status" | "automated-status" | "region" | "rule" | "status" | "reviewer-name" | "note" | "child-asset" | "child-status" | "previous-status" | "failure-reason" | "completed-sections" | "total-sections" | "batch-id" | "review-reason" | "uncertain-categories" | "review-id" | "decision" | "applied-to-asset" | "hash-list-id" | "hash-list-name" | "distance" | "match-action" | "limit" | "used" | "organisation-id" | "reason" | "resumes-at" | "preset-id" | "preset-name" | "daily-limit" | "member-user-id" | "member-name" | "role" | "previous-role" | "invitee-email" | "previous-organisation-id" | "previous-organisation-name" | "organisation-name" | "method" | "api-keys-revoked" | "connectors-paused" | "key-id" | "key-name" | "created-by-name" | "revoked-by-name" | "deleted-by-name" | "connector-id" | "connector-name" | "connector-type" | "consecutive-failures" | "last-error"
|
|
6
6
|
class Asset < Model
|
|
7
7
|
def id: () -> String
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: calmlens
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.27.
|
|
4
|
+
version: 0.27.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- CalmLens
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-11-
|
|
11
|
+
date: 2026-11-24 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: 'Server-side client for the CalmLens API: moderation, uploads, events,
|
|
14
14
|
webhooks and CDN delivery.'
|