identisure-client 0.1.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 +7 -0
- data/LICENSE +19 -0
- data/README.md +105 -0
- data/lib/identisure/age_verification.rb +87 -0
- data/lib/identisure/bank_id_no.rb +219 -0
- data/lib/identisure/bank_id_se.rb +338 -0
- data/lib/identisure/callback.rb +15 -0
- data/lib/identisure/client.rb +77 -0
- data/lib/identisure/document.rb +31 -0
- data/lib/identisure/environment.rb +17 -0
- data/lib/identisure/error.rb +21 -0
- data/lib/identisure/freja.rb +224 -0
- data/lib/identisure/ftn.rb +168 -0
- data/lib/identisure/mit_id.rb +205 -0
- data/lib/identisure/poll_options.rb +12 -0
- data/lib/identisure/transport.rb +90 -0
- data/lib/identisure/version.rb +5 -0
- data/lib/identisure/vipps.rb +153 -0
- metadata +75 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Identisure
|
|
4
|
+
module Vipps
|
|
5
|
+
class AuthRequest
|
|
6
|
+
attr_reader :redirect_url, :request_ssn, :request_phone, :request_email,
|
|
7
|
+
:request_address, :ref_id, :app_callback_uri
|
|
8
|
+
|
|
9
|
+
def initialize(redirect_url: nil, request_ssn: nil, request_phone: nil,
|
|
10
|
+
request_email: nil, request_address: nil, ref_id: nil,
|
|
11
|
+
app_callback_uri: nil)
|
|
12
|
+
@redirect_url = redirect_url; @request_ssn = request_ssn
|
|
13
|
+
@request_phone = request_phone; @request_email = request_email
|
|
14
|
+
@request_address = request_address; @ref_id = ref_id
|
|
15
|
+
@app_callback_uri = app_callback_uri
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def to_h
|
|
19
|
+
{
|
|
20
|
+
redirectUrl: @redirect_url, requestSsn: @request_ssn,
|
|
21
|
+
requestPhone: @request_phone, requestEmail: @request_email,
|
|
22
|
+
requestAddress: @request_address, refId: @ref_id,
|
|
23
|
+
appCallbackUri: @app_callback_uri
|
|
24
|
+
}.compact
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
class BackchannelAuthRequest
|
|
29
|
+
attr_reader :phone, :request_ssn, :request_email, :request_address,
|
|
30
|
+
:callback_url, :ref_id
|
|
31
|
+
|
|
32
|
+
def initialize(phone:, request_ssn: nil, request_email: nil,
|
|
33
|
+
request_address: nil, callback_url: nil, ref_id: nil)
|
|
34
|
+
@phone = phone; @request_ssn = request_ssn
|
|
35
|
+
@request_email = request_email; @request_address = request_address
|
|
36
|
+
@callback_url = callback_url; @ref_id = ref_id
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def to_h
|
|
40
|
+
{
|
|
41
|
+
phone: @phone, requestSsn: @request_ssn,
|
|
42
|
+
requestEmail: @request_email, requestAddress: @request_address,
|
|
43
|
+
callbackUrl: @callback_url, refId: @ref_id
|
|
44
|
+
}.compact
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
class Pending
|
|
49
|
+
attr_reader :id, :ref_id, :url
|
|
50
|
+
|
|
51
|
+
def initialize(id:, ref_id: nil, url: nil)
|
|
52
|
+
@id = id; @ref_id = ref_id; @url = url
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def deconstruct_keys(_) = { id: @id, ref_id: @ref_id, url: @url }
|
|
56
|
+
|
|
57
|
+
def self.from_json(d) = new(id: d['id'], ref_id: d['refId'], url: d['url'])
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
class Completed
|
|
61
|
+
attr_reader :id, :ref_id, :ssn, :name, :given_name, :surname,
|
|
62
|
+
:phone, :email, :address, :birth_date, :pid, :bank_id,
|
|
63
|
+
:authenticated_at
|
|
64
|
+
|
|
65
|
+
def initialize(id:, ssn:, name:, given_name:, surname:, ref_id: nil,
|
|
66
|
+
phone: nil, email: nil, address: nil, birth_date: nil,
|
|
67
|
+
pid: nil, bank_id: nil, authenticated_at: nil)
|
|
68
|
+
@id = id; @ref_id = ref_id; @ssn = ssn; @name = name
|
|
69
|
+
@given_name = given_name; @surname = surname; @phone = phone
|
|
70
|
+
@email = email; @address = address; @birth_date = birth_date
|
|
71
|
+
@pid = pid; @bank_id = bank_id; @authenticated_at = authenticated_at
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def deconstruct_keys(_)
|
|
75
|
+
{ id: @id, ref_id: @ref_id, ssn: @ssn, name: @name,
|
|
76
|
+
given_name: @given_name, surname: @surname, phone: @phone,
|
|
77
|
+
email: @email, address: @address, birth_date: @birth_date,
|
|
78
|
+
pid: @pid, bank_id: @bank_id, authenticated_at: @authenticated_at }
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def self.from_json(d)
|
|
82
|
+
new(
|
|
83
|
+
id: d['id'], ref_id: d['refId'], ssn: d['ssn'], name: d['name'],
|
|
84
|
+
given_name: d['givenName'], surname: d['surname'], phone: d['phone'],
|
|
85
|
+
email: d['email'], address: d['address'], birth_date: d['birthDate'],
|
|
86
|
+
pid: d['pid'], bank_id: d['bankId'],
|
|
87
|
+
authenticated_at: d['authenticatedAt']
|
|
88
|
+
)
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
class Failed
|
|
93
|
+
attr_reader :id, :ref_id, :error
|
|
94
|
+
|
|
95
|
+
def initialize(id:, error:, ref_id: nil)
|
|
96
|
+
@id = id; @ref_id = ref_id; @error = error
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def deconstruct_keys(_) = { id: @id, ref_id: @ref_id, error: @error }
|
|
100
|
+
|
|
101
|
+
def self.from_json(d) = new(id: d['id'], ref_id: d['refId'], error: d['error'])
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
class Unknown
|
|
105
|
+
attr_reader :status
|
|
106
|
+
|
|
107
|
+
def initialize(status:)
|
|
108
|
+
@status = status
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def deconstruct_keys(_) = { status: @status }
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
module Status
|
|
115
|
+
def self.from_json(d)
|
|
116
|
+
case d['status']
|
|
117
|
+
when 'PENDING' then Pending.from_json(d)
|
|
118
|
+
when 'COMPLETED' then Completed.from_json(d)
|
|
119
|
+
when 'FAILED' then Failed.from_json(d)
|
|
120
|
+
when String then Unknown.new(status: d['status'])
|
|
121
|
+
else raise IdentisureError.new(0, "Invalid vipps status: #{d['status'].inspect}")
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
class Endpoint
|
|
127
|
+
# @api private
|
|
128
|
+
def initialize(transport)
|
|
129
|
+
@transport = transport
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def auth(req) = Status.from_json(@transport.post('/v3/vipps/auth', req.to_h))
|
|
133
|
+
def backchannel_auth(req) = Status.from_json(@transport.post('/v3/vipps/backchannel/auth', req.to_h))
|
|
134
|
+
def auth_status(id) = Status.from_json(@transport.get("/v3/vipps/auth/#{id}"))
|
|
135
|
+
def cancel_auth(id) = @transport.delete("/v3/vipps/auth/#{id}")
|
|
136
|
+
|
|
137
|
+
def wait_for_auth(id, opts: PollOptions.new) = poll(opts) { auth_status(id) }
|
|
138
|
+
|
|
139
|
+
private
|
|
140
|
+
|
|
141
|
+
def poll(opts)
|
|
142
|
+
deadline = Process.clock_gettime(Process::CLOCK_MONOTONIC) + opts.timeout
|
|
143
|
+
loop do
|
|
144
|
+
status = yield
|
|
145
|
+
return status unless status.is_a?(Pending)
|
|
146
|
+
raise WaitError.new(timeout: true) if Process.clock_gettime(Process::CLOCK_MONOTONIC) >= deadline
|
|
147
|
+
|
|
148
|
+
sleep opts.interval
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: identisure-client
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Identisure
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2026-10-29 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: faraday
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '2.10'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '2.10'
|
|
27
|
+
description: Synchronous Ruby client for Identisure, supporting BankID SE/NO, Freja,
|
|
28
|
+
MitID, FTN, Vipps and document upload.
|
|
29
|
+
email:
|
|
30
|
+
executables: []
|
|
31
|
+
extensions: []
|
|
32
|
+
extra_rdoc_files: []
|
|
33
|
+
files:
|
|
34
|
+
- LICENSE
|
|
35
|
+
- README.md
|
|
36
|
+
- lib/identisure/age_verification.rb
|
|
37
|
+
- lib/identisure/bank_id_no.rb
|
|
38
|
+
- lib/identisure/bank_id_se.rb
|
|
39
|
+
- lib/identisure/callback.rb
|
|
40
|
+
- lib/identisure/client.rb
|
|
41
|
+
- lib/identisure/document.rb
|
|
42
|
+
- lib/identisure/environment.rb
|
|
43
|
+
- lib/identisure/error.rb
|
|
44
|
+
- lib/identisure/freja.rb
|
|
45
|
+
- lib/identisure/ftn.rb
|
|
46
|
+
- lib/identisure/mit_id.rb
|
|
47
|
+
- lib/identisure/poll_options.rb
|
|
48
|
+
- lib/identisure/transport.rb
|
|
49
|
+
- lib/identisure/version.rb
|
|
50
|
+
- lib/identisure/vipps.rb
|
|
51
|
+
homepage: https://github.com/identisure/api-client-ruby
|
|
52
|
+
licenses:
|
|
53
|
+
- MIT
|
|
54
|
+
metadata:
|
|
55
|
+
rubygems_mfa_required: 'true'
|
|
56
|
+
post_install_message:
|
|
57
|
+
rdoc_options: []
|
|
58
|
+
require_paths:
|
|
59
|
+
- lib
|
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
61
|
+
requirements:
|
|
62
|
+
- - ">="
|
|
63
|
+
- !ruby/object:Gem::Version
|
|
64
|
+
version: 3.2.0
|
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
66
|
+
requirements:
|
|
67
|
+
- - ">="
|
|
68
|
+
- !ruby/object:Gem::Version
|
|
69
|
+
version: '0'
|
|
70
|
+
requirements: []
|
|
71
|
+
rubygems_version: 3.5.22
|
|
72
|
+
signing_key:
|
|
73
|
+
specification_version: 4
|
|
74
|
+
summary: Ruby client for the Identisure REST API
|
|
75
|
+
test_files: []
|