Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .fern/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"generatorConfig": {
"moduleName": "CloudPDF"
},
"originGitCommit": "e074ee8465006a168ff6d8cfa73928df13ae159c",
"originGitCommit": "4b156274cbffac1a19f266d36d27b4ed07bf2b53",
"originGitCommitIsDirty": false,
"invokedBy": "ci",
"requestedVersion": "3.2.0",
"requestedVersion": "3.3.0",
"ciProvider": "github"
}
8 changes: 4 additions & 4 deletions cloudpdf-generation.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"language": "ruby",
"canonicalVersion": "3.2.0",
"sdkVersion": "3.2.0",
"canonicalVersion": "3.3.0",
"sdkVersion": "3.3.0",
"source": {
"repository": "embedpdf/embed-pdf-viewer",
"openapi": "cloudpdf/contract/openapi.json",
"openapiSha256": "92b335b44d0957c70139f64ee3dd92e19d9d3a1452c90077002ed31dbddc3e7d",
"gitCommit": "e074ee8465006a168ff6d8cfa73928df13ae159c",
"openapiSha256": "8d6fda1d157a3f3f82d3a16835381932eaa6efe3054100bb0aa63c0ad5ac6909",
"gitCommit": "4b156274cbffac1a19f266d36d27b4ed07bf2b53",
"gitCommitIsDirty": false
},
"fern": {
Expand Down
2 changes: 1 addition & 1 deletion lib/CloudPDF/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def initialize(token:, base_url: nil, max_retries: 2)
headers: {
"X-Fern-Language" => "Ruby",
Authorization: "Bearer #{token}",
"EmbedPDF-Version" => "3.2"
"EmbedPDF-Version" => "3.3"
},
max_retries: max_retries
)
Expand Down
111 changes: 109 additions & 2 deletions lib/CloudPDF/doc/signatures/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,10 @@ def analysis(request_options: {}, **params)
# Multipart: a JSON `body` part (field, subFilter, digest, contentsSize, signer, certify, lock), naming the
# appearance PDF it may carry as `resources: { appearance: '<key>' }`, and that PDF as the part
# `resource:<key>`. A certification (`certify.permission`) additionally requires `doc.sign.certify`. The layer
# is read-only until the signing completes, is cancelled, or expires (15 minutes). The signature is made over
# the layer's own base: the upload, or the version its last signature made.
# is read-only until the signing completes, is cancelled, or expires (15 minutes). A document timestamp (`kind:
# 'timestamp'`) may leave `field` out, since 3.3: the engine then makes a field of no size for it, under a name
# no other field has, and the answer names it in `field`. That needs `doc.sign` for the document. The signature
# is made over the layer's own base: the upload, or the version its last signature made.
#
# @param request_options [Hash]
# @param params [void]
Expand Down Expand Up @@ -277,6 +279,111 @@ def prepare(request_options: {}, **params)
raise error_class.new(response.body, code: code)
end
end

# Each entry is one DER object, base64. It reads the layer as it is now, so entries stored and not yet sealed by
# a signature are among them. Arrived in 3.3.
#
# @param request_options [Hash]
# @param params [Hash]
# @option request_options [String] :base_url
# @option request_options [Hash{String => Object}] :additional_headers
# @option request_options [Hash{String => Object}] :additional_query_parameters
# @option request_options [Hash{String => Object}] :additional_body_parameters
# @option request_options [Integer] :timeout_in_seconds
# @option params [String] :doc_id
# @option params [String] :layer_name
# @option params [String, nil] :document_password
#
# @example
# client.doc.signatures.validation_info(
# doc_id: "docId",
# layer_name: "layerName"
# )
#
# @return [CloudPDF::Types::DocSignaturesValidationInfoResponse]
def validation_info(request_options: {}, **params)
params = CloudPDF::Internal::Types::Utils.normalize_keys(params)
headers = {}
headers["X-Document-Password"] = params[:document_password] if params[:document_password]

request = CloudPDF::Internal::JSON::Request.new(
base_url: request_options[:base_url],
method: "GET",
path: "v1/docs/#{URI.encode_uri_component(params[:doc_id].to_s)}/layers/#{URI.encode_uri_component(params[:layer_name].to_s)}/signatures/validation-info",
headers: headers,
request_options: request_options
)
begin
response = @client.send(request)
rescue Net::HTTPRequestTimeout
raise CloudPDF::Errors::TimeoutError
end
code = response.code.to_i
if code.between?(200, 299)
(response.body.to_s.empty? ? nil : CloudPDF::Types::DocSignaturesValidationInfoResponse.load(response.body))
else
error_class = CloudPDF::Errors::ResponseError.subclass_for_code(code)
raise error_class.new(response.body, code: code)
end
end

# Each entry is one DER object of at most 16 MiB, base64. An entry the file already holds, byte for byte, is not
# stored again: `added` counts the new ones. An entry that is not one DER object fails the request and nothing
# is stored; the error names it, as in `certificates[1]`. The server stores what it is given and asks no
# certificate authority: collect the answers first. It needs `doc.sign` for the document, not for a group of
# fields, and is refused after a certification that allows no changes. It cannot be undone, and it leaves undo
# for earlier changes as it was. Arrived in 3.3.
#
# @param request_options [Hash]
# @param params [CloudPDF::Doc::Signatures::Types::DocSignaturesAddValidationInfoRequest]
# @option request_options [String] :base_url
# @option request_options [Hash{String => Object}] :additional_headers
# @option request_options [Hash{String => Object}] :additional_query_parameters
# @option request_options [Hash{String => Object}] :additional_body_parameters
# @option request_options [Integer] :timeout_in_seconds
# @option params [String] :doc_id
# @option params [String] :layer_name
# @option params [String, nil] :document_password
# @option params [String, nil] :idempotency_key
#
# @example
# client.doc.signatures.add_validation_info(
# doc_id: "docId",
# layer_name: "layerName"
# )
#
# @return [CloudPDF::Types::DocSignaturesAddValidationInfoResponse]
def add_validation_info(request_options: {}, **params)
params = CloudPDF::Internal::Types::Utils.normalize_keys(params)
request_data = CloudPDF::Doc::Signatures::Types::DocSignaturesAddValidationInfoRequest.new(params).to_h
non_body_param_names = %w[docId layerName X-Document-Password Idempotency-Key]
body = request_data.except(*non_body_param_names)

headers = {}
headers["X-Document-Password"] = params[:document_password] if params[:document_password]
headers["Idempotency-Key"] = params[:idempotency_key] if params[:idempotency_key]

request = CloudPDF::Internal::JSON::Request.new(
base_url: request_options[:base_url],
method: "POST",
path: "v1/docs/#{URI.encode_uri_component(params[:doc_id].to_s)}/layers/#{URI.encode_uri_component(params[:layer_name].to_s)}/signatures/validation-info",
headers: headers,
body: body,
request_options: request_options
)
begin
response = @client.send(request)
rescue Net::HTTPRequestTimeout
raise CloudPDF::Errors::TimeoutError
end
code = response.code.to_i
if code.between?(200, 299)
(response.body.to_s.empty? ? nil : CloudPDF::Types::DocSignaturesAddValidationInfoResponse.load(response.body))
else
error_class = CloudPDF::Errors::ResponseError.subclass_for_code(code)
raise error_class.new(response.body, code: code)
end
end
end
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# frozen_string_literal: true

module CloudPDF
module Doc
module Signatures
module Types
class DocSignaturesAddValidationInfoRequest < Internal::Types::Model
field :doc_id, -> { String }, optional: false, nullable: false, api_name: "docId"

field :layer_name, -> { String }, optional: false, nullable: false, api_name: "layerName"

field :document_password, -> { String }, optional: true, nullable: false, api_name: "X-Document-Password"

field :idempotency_key, -> { String }, optional: true, nullable: false, api_name: "Idempotency-Key"

field :certificates, -> { Internal::Types::Array[String] }, optional: true, nullable: false

field :ocsp_responses, -> { Internal::Types::Array[String] }, optional: true, nullable: false, api_name: "ocspResponses"

field :crls, -> { Internal::Types::Array[String] }, optional: true, nullable: false
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

module CloudPDF
module Doc
module Signatures
module Types
class ValidationInfoSignaturesRequest < Internal::Types::Model
field :doc_id, -> { String }, optional: false, nullable: false, api_name: "docId"

field :layer_name, -> { String }, optional: false, nullable: false, api_name: "layerName"

field :document_password, -> { String }, optional: true, nullable: false, api_name: "X-Document-Password"
end
end
end
end
end
17 changes: 14 additions & 3 deletions lib/CloudPDF/doc/versions/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ def list(request_options: {}, **params)
end

# Exactly one of `since.signature` / `since.revision`; `until=<revision>` defaults to the last. The same answer
# for every caller.
# for every caller. A version never changes, but the rules that judge it can: with `engine`, the `analysis`
# value of the layer's head, a settled answer is `immutable`. Without it, or with another value, the answer is
# this server's own, with `no-store` and the current value in `EmbedPDF-Engine`.
#
# @param request_options [Hash]
# @param params [Hash]
Expand All @@ -75,7 +77,7 @@ def list(request_options: {}, **params)
# @option params [Integer, nil] :since_revision
# @option params [CloudPDF::Doc::Versions::Types::AnalysisVersionsRequestLevel, nil] :level
# @option params [Integer, nil] :until_
# @option params [Integer, nil] :policy
# @option params [String, nil] :engine
# @option params [String, nil] :document_password
#
# @example
Expand All @@ -93,7 +95,7 @@ def analysis(request_options: {}, **params)
query_params["since.revision"] = params[:since_revision] if params.key?(:since_revision)
query_params["level"] = params[:level] if params.key?(:level)
query_params["until"] = params[:until_] if params.key?(:until_)
query_params["policy"] = params[:policy] if params.key?(:policy)
query_params["engine"] = params[:engine] if params.key?(:engine)

headers = {}
headers["X-Document-Password"] = params[:document_password] if params[:document_password]
Expand Down Expand Up @@ -210,6 +212,10 @@ def revision(request_options: {}, **params)
raise error_class.new(response.body, code: code)
end

# A version never changes, but what the server reads from it can: with `engine`, the `signatures` value of the
# layer's head, the answer is `immutable`. Without it, or with another value, the answer is this server's own,
# with `no-store` and the current value in `EmbedPDF-Engine`.
#
# @param request_options [Hash]
# @param params [Hash]
# @option request_options [String] :base_url
Expand All @@ -220,6 +226,7 @@ def revision(request_options: {}, **params)
# @option params [String] :doc_id
# @option params [String] :layer_name
# @option params [String] :sha256
# @option params [String, nil] :engine
# @option params [String, nil] :document_password
#
# @example
Expand All @@ -232,6 +239,9 @@ def revision(request_options: {}, **params)
# @return [CloudPDF::Types::DocVersionsSignaturesResponse]
def signatures(request_options: {}, **params)
params = CloudPDF::Internal::Types::Utils.normalize_keys(params)
query_params = {}
query_params["engine"] = params[:engine] if params.key?(:engine)

headers = {}
headers["X-Document-Password"] = params[:document_password] if params[:document_password]

Expand All @@ -240,6 +250,7 @@ def signatures(request_options: {}, **params)
method: "GET",
path: "v1/docs/#{URI.encode_uri_component(params[:doc_id].to_s)}/layers/#{URI.encode_uri_component(params[:layer_name].to_s)}/versions/signatures/#{URI.encode_uri_component(params[:sha256].to_s)}",
headers: headers,
query: query_params,
request_options: request_options
)
begin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class AnalysisVersionsRequest < Internal::Types::Model

field :until_, -> { Integer }, optional: true, nullable: false, api_name: "until"

field :policy, -> { Integer }, optional: true, nullable: false
field :engine, -> { String }, optional: true, nullable: false

field :document_password, -> { String }, optional: true, nullable: false, api_name: "X-Document-Password"
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class SignaturesVersionsRequest < Internal::Types::Model

field :sha256, -> { String }, optional: false, nullable: false

field :engine, -> { String }, optional: true, nullable: false

field :document_password, -> { String }, optional: true, nullable: false, api_name: "X-Document-Password"
end
end
Expand Down
11 changes: 11 additions & 0 deletions lib/CloudPDF/types/doc_signatures_add_validation_info_response.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

module CloudPDF
module Types
class DocSignaturesAddValidationInfoResponse < Internal::Types::Model
field :added, -> { CloudPDF::Types::DocSignaturesAddValidationInfoResponseAdded }, optional: false, nullable: false

field :meta, -> { CloudPDF::Types::MutationMeta }, optional: false, nullable: false
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

module CloudPDF
module Types
class DocSignaturesAddValidationInfoResponseAdded < Internal::Types::Model
field :certificates, -> { Integer }, optional: false, nullable: false

field :ocsp_responses, -> { Integer }, optional: false, nullable: false, api_name: "ocspResponses"

field :crls, -> { Integer }, optional: false, nullable: false
end
end
end
2 changes: 2 additions & 0 deletions lib/CloudPDF/types/doc_signatures_prepare_response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class DocSignaturesPrepareResponse < Internal::Types::Model
field :expected_version, -> { CloudPDF::Types::DocSignaturesPrepareResponseExpectedVersion }, optional: false, nullable: false, api_name: "expectedVersion"

field :expires_at, -> { String }, optional: false, nullable: true, api_name: "expiresAt"

field :field, -> { CloudPDF::Types::FormFieldRef }, optional: true, nullable: false
end
end
end
13 changes: 13 additions & 0 deletions lib/CloudPDF/types/doc_signatures_validation_info_response.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

module CloudPDF
module Types
class DocSignaturesValidationInfoResponse < Internal::Types::Model
field :certificates, -> { Internal::Types::Array[String] }, optional: false, nullable: false

field :ocsp_responses, -> { Internal::Types::Array[String] }, optional: false, nullable: false, api_name: "ocspResponses"

field :crls, -> { Internal::Types::Array[String] }, optional: false, nullable: false
end
end
end
2 changes: 1 addition & 1 deletion lib/CloudPDF/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module CloudPDF
VERSION = "3.2.0"
VERSION = "3.3.0"
end
5 changes: 5 additions & 0 deletions lib/cloudpdf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1402,6 +1402,9 @@
require_relative "CloudPDF/types/doc_signatures_analysis_response_later"
require_relative "CloudPDF/types/doc_signatures_analysis_response_verdict"
require_relative "CloudPDF/types/doc_signatures_analysis_response"
require_relative "CloudPDF/types/doc_signatures_validation_info_response"
require_relative "CloudPDF/types/doc_signatures_add_validation_info_response_added"
require_relative "CloudPDF/types/doc_signatures_add_validation_info_response"
require_relative "CloudPDF/types/doc_signatures_prepare_response_algorithm"
require_relative "CloudPDF/types/doc_signatures_prepare_response_expected_version"
require_relative "CloudPDF/types/doc_signatures_prepare_response"
Expand Down Expand Up @@ -1597,6 +1600,8 @@
require_relative "CloudPDF/doc/signatures/types/doc_signatures_complete_request"
require_relative "CloudPDF/doc/signatures/types/analysis_signatures_request"
require_relative "CloudPDF/doc/signatures/types/prepare_signatures_request"
require_relative "CloudPDF/doc/signatures/types/validation_info_signatures_request"
require_relative "CloudPDF/doc/signatures/types/doc_signatures_add_validation_info_request"
require_relative "CloudPDF/doc/versions/client"
require_relative "CloudPDF/doc/versions/types/list_versions_request"
require_relative "CloudPDF/doc/versions/types/analysis_versions_request"
Expand Down
Loading
Loading