-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SDK-2259:added retrieve qr code #290
Changes from 17 commits
6691dec
be2b96b
6f50c88
fb79e33
1586dea
c2d3b6c
22d0896
359a293
cb5f083
ce57837
f61e496
708fe86
2a0f087
5912800
e4a1fc8
06d91c3
f410402
fd1f342
86d40a4
60e2f4d
7a955f4
33131cc
ae46a53
22bbe7d
9a619e8
bc20038
00ef7b0
4cf2791
ad1f3f9
87d61de
6c2d312
d40c218
f8657c2
4c019b3
a841a3e
87f5098
2492915
5bf052f
9661755
75502ef
b7d7b23
8e20b5e
b893957
4993e35
e52a26c
b9d8fed
c09c2c2
8dd3c7c
f705d44
a4775d2
3da5372
9d403b8
af99524
a3d8314
5f1ec57
3fb2de7
ac64677
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,4 @@ report.json | |
# idea files | ||
.idea | ||
|
||
# Generated binaries | ||
/_examples/docscan/docscan | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,9 @@ | ||
.env | ||
# Generated binaries | ||
docscan/docscan | ||
idv/idv | ||
aml/aml | ||
docscansandbox/docscansandbox | ||
profile/profile | ||
profilesandbox/profilesandbox | ||
digitalidentity/digitalidentity |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -13,6 +13,7 @@ import ( | |||||
const identitySessionCreationEndpoint = "/v2/sessions" | ||||||
const identitySessionRetrieval = "/v2/sessions/%s" | ||||||
const identitySessionQrCodeCreation = "/v2/sessions/%s/qr-codes" | ||||||
const identitySessionQrCodeRetrieval = "/v2/qr-codes/%s" | ||||||
|
||||||
// CreateShareSession creates session using the supplied session specification | ||||||
func CreateShareSession(httpClient requests.HttpClient, shareSessionRequest *ShareSessionRequest, clientSdkId, apiUrl string, key *rsa.PrivateKey) (*ShareSession, error) { | ||||||
|
@@ -82,7 +83,7 @@ func GetShareSession(httpClient requests.HttpClient, sessionID string, clientSdk | |||||
return shareSession, err | ||||||
} | ||||||
|
||||||
// CreateQrCode using the supplied sessionID parameter | ||||||
// CreateShareQrCode generates a sharing qr code using the supplied sessionID parameter | ||||||
func CreateShareQrCode(httpClient requests.HttpClient, sessionID string, clientSdkId, apiUrl string, key *rsa.PrivateKey) (*QrCode, error) { | ||||||
endpoint := fmt.Sprintf(identitySessionQrCodeCreation, sessionID) | ||||||
|
||||||
|
@@ -113,3 +114,34 @@ func CreateShareQrCode(httpClient requests.HttpClient, sessionID string, clientS | |||||
err = json.Unmarshal(responseBytes, qrCode) | ||||||
return qrCode, err | ||||||
} | ||||||
|
||||||
// GetShareSessionQrCode is used to fetch the qr code by id. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
extra space |
||||||
func GetShareSessionQrCode(httpClient requests.HttpClient, qrCodeId string, clientSdkId, apiUrl string, key *rsa.PrivateKey) (fetchedQrCode ShareSessionQrCode, err error) { | ||||||
endpoint := fmt.Sprintf(identitySessionQrCodeRetrieval, qrCodeId) | ||||||
headers := requests.AuthHeader(clientSdkId) | ||||||
request, err := requests.SignedRequest{ | ||||||
Key: key, | ||||||
HTTPMethod: http.MethodGet, | ||||||
BaseURL: apiUrl, | ||||||
Endpoint: endpoint, | ||||||
Headers: headers, | ||||||
}.Request() | ||||||
if err != nil { | ||||||
return fetchedQrCode, err | ||||||
} | ||||||
|
||||||
response, err := requests.Execute(httpClient, request) | ||||||
if err != nil { | ||||||
return fetchedQrCode, err | ||||||
} | ||||||
defer response.Body.Close() | ||||||
|
||||||
responseBytes, err := io.ReadAll(response.Body) | ||||||
if err != nil { | ||||||
return fetchedQrCode, err | ||||||
} | ||||||
|
||||||
err = json.Unmarshal(responseBytes, &fetchedQrCode) | ||||||
|
||||||
return fetchedQrCode, err | ||||||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -111,7 +111,7 @@ func TestGetShareSession(t *testing.T) { | |||||
|
||||||
} | ||||||
|
||||||
func TestCreateQrCode(t *testing.T) { | ||||||
func TestCreateShareQrCode(t *testing.T) { | ||||||
key := test.GetValidKey("../test/test-key.pem") | ||||||
mockSessionID := "SOME_SESSION_ID" | ||||||
|
||||||
|
@@ -127,3 +127,22 @@ func TestCreateQrCode(t *testing.T) { | |||||
_, err := CreateShareQrCode(client, mockSessionID, "sdkId", "https://apiurl", key) | ||||||
assert.NilError(t, err) | ||||||
} | ||||||
|
||||||
func TestGetQrCode(t *testing.T) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
key := test.GetValidKey("../test/test-key.pem") | ||||||
mockQrId := "SOME_QR_CODE_ID" | ||||||
mockClientSdkId := "SOME_CLIENT_SDK_ID" | ||||||
mockApiUrl := "https://example.com/api" | ||||||
client := &mockHTTPClient{ | ||||||
do: func(*http.Request) (*http.Response, error) { | ||||||
return &http.Response{ | ||||||
StatusCode: 201, | ||||||
Body: io.NopCloser(strings.NewReader(`{}`)), | ||||||
}, nil | ||||||
}, | ||||||
} | ||||||
|
||||||
_, err := GetShareSessionQrCode(client, mockQrId, mockClientSdkId, mockApiUrl, key) | ||||||
assert.NilError(t, err) | ||||||
|
||||||
} |
klaidas marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package digitalidentity | ||
|
||
type ShareSessionFetchedQrCode struct { | ||
klaidas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
ID string `json:"id"` | ||
Expiry string `json:"expiry"` | ||
Policy string `json:"policy"` | ||
Extensions []interface{} `json:"extensions"` | ||
Session ShareSessionCreated `json:"session"` | ||
klaidas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
RedirectURI string `json:"redirectUri"` | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package digitalidentity | ||
|
||
// ShareSessionCreated Share Session QR Result | ||
type ShareSessionCreated struct { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know how GO architecture works but I'm pretty sure there is a way to reuse the response obj from the session creation There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there is, but the session object here is smaller than what's returned for session created - unless the api docs are mistaken? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we have made this struct inline so i think this is now unnecessary There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dunno what API u're referring to but both
where the full response for the QR fetch endpoint is
would something like the below work?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. when you fetch the session, the session resource seems to be larger than what is returned in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sorry I thought I answered this but I must have not pushed the button. I meant this session created response |
||
ID string `json:"id"` | ||
Satus string `json:"status"` | ||
klaidas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Expiry string `json:"expiry"` | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment + func name (i haven't checked other sdks so happy to just have it all align with whatever they have)