Skip to content
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

Merged
merged 57 commits into from
Dec 14, 2023

Conversation

mehmet-yoti
Copy link
Contributor

No description provided.

return share, err
}

err = json.Unmarshal(responseBytes, &share)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

share? This as instance of ShareSessionFetchedQrCode should be named accordinly

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated


func TestGetQrCode(t *testing.T) {
key := test.GetValidKey("../test/test-key.pem")
mockQrId := "SOME_SESSION_ID"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SOME_QR_CODE_ID or similiar

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

package digitalidentity

// ShareSessionCreated Share Session QR Result
type ShareSessionCreated struct {
Copy link

Choose a reason for hiding this comment

The 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

Copy link
Collaborator

Choose a reason for hiding this comment

The 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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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

Copy link

@irotech irotech Nov 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dunno what API u're referring to but both Session creation and QR fetch response (limited to the session) are

{
  "id": "",
  "status": "",
  "expiry": ""
}

where the full response for the QR fetch endpoint is

{
  "id": "",
  "expiry": "",
  "policy": "", 
  "extensions": [ ],
  "session": {
    "id": "",
    "status": "",
    "expiry": ""
  },
  "redirectUri": ""
}

would something like the below work?

type session struct {
	id 		string
	status  string
	expiry	string
}

type qr struct {
	id		string
	expiry 	string
	policy 	string
	session
	...
}

Copy link
Collaborator

Choose a reason for hiding this comment

The 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 fetch qr code response (what you posted), we could embed it and just have it unmarshal the whole thing, but some extra fields will just be empty for the RP, imo it's better to avoid it if the API itself specifically limits the fields and not give the RP any cause for confusion or incorrect expectations.

Copy link

Choose a reason for hiding this comment

The 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

Comment on lines 118 to 119
// Get Share QR info using the supplied sessionID
func GetShareQr(httpClient requests.HttpClient, sessionID string, clientSdkId, apiUrl string, key *rsa.PrivateKey) (share ShareSessionFetchedQrCode, err error) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both the function and the comment use the wrong id. This is not the sessionId but the qrId from the qr code creation endpoint

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

_examples/idv/handlers.session.go Outdated Show resolved Hide resolved
_examples/idv/handlers.session.go Outdated Show resolved Hide resolved
digitalidentity/share_retrieve_qr.go Show resolved Hide resolved
digitalidentity/share_retrieve_qr.go Show resolved Hide resolved
digitalidentity/share_retrieve_qr.go Show resolved Hide resolved
digitalidentity/share_session_created.go Show resolved Hide resolved
digitalidentity/service.go Outdated Show resolved Hide resolved
Comment on lines 80 to 81
// Get session QR code based on generated Qr ID
func (client *DigitalIdentityClient) GetQrCode(qrCodeId string) (share digitalidentity.ShareSessionFetchedQrCode, err error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Get session QR code based on generated Qr ID
func (client *DigitalIdentityClient) GetQrCode(qrCodeId string) (share digitalidentity.ShareSessionFetchedQrCode, err error) {
// GetShareSessionQrCode retrieves a session QR code based on generated Qr ID
func (client *DigitalIdentityClient) GetShareSessionQrCode(qrCodeId string) (share digitalidentity.ShareSessionQrCode, err error) {

might aswell keep the naming consistent "ShareSession" everywhere

Comment on lines +80 to +81
// Get session QR code based on generated Qr ID
func (client *DigitalIdentityClient) GetQrCode(qrCodeId string) (share digitalidentity.ShareSessionQrCode, err error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Get session QR code based on generated Qr ID
func (client *DigitalIdentityClient) GetQrCode(qrCodeId string) (share digitalidentity.ShareSessionQrCode, err error) {
// GetShareSessionQrCode retrieves a session QR code based on generated Qr ID
func (client *DigitalIdentityClient) GetShareSessionQrCode(qrCodeId string) (share digitalidentity.ShareSessionQrCode, err error) {

comment + func name (i haven't checked other sdks so happy to just have it all align with whatever they have)

@@ -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) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func TestGetQrCode(t *testing.T) {
func GetShareSessionQrCode(t *testing.T) {

@@ -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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// GetShareSessionQrCode is used to fetch the qr code by id.
// GetShareSessionQrCode is used to fetch the qr code by id.

extra space

Copy link
Collaborator

@klaidas klaidas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couple minor fixes we can still do, but after that LGTM

mehmet-yoti and others added 29 commits November 7, 2023 23:11
Co-authored-by: Klaidas Urbanavicius <[email protected]>
Co-authored-by: Klaidas Urbanavicius <[email protected]>
Co-authored-by: Klaidas Urbanavicius <[email protected]>
Co-authored-by: Klaidas Urbanavicius <[email protected]>
Co-authored-by: Klaidas Urbanavicius <[email protected]>
Co-authored-by: Klaidas Urbanavicius <[email protected]>
Co-authored-by: Klaidas Urbanavicius <[email protected]>
Co-authored-by: Klaidas Urbanavicius <[email protected]>
Co-authored-by: Klaidas Urbanavicius <[email protected]>
Co-authored-by: Klaidas Urbanavicius <[email protected]>
Co-authored-by: Klaidas Urbanavicius <[email protected]>
Co-authored-by: Klaidas Urbanavicius <[email protected]>
Co-authored-by: Klaidas Urbanavicius <[email protected]>
@mehmet-yoti mehmet-yoti merged commit fb179ee into SDK-2254-go-create-qr-code Dec 14, 2023
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants