|
1 | 1 | package api |
2 | 2 |
|
3 | 3 | type ( |
| 4 | + // BankIdV6Response used as a catch all response for V2 |
| 5 | + // Deprecated: stick to V1 or move to V3 |
4 | 6 | BankIdV6Response struct { |
5 | 7 | OrderRef string `json:"orderRef"` |
6 | 8 | ErrorCode string `json:"errorCode,omitempty"` |
@@ -32,11 +34,113 @@ type ( |
32 | 34 | BankIdV6StepUp struct { |
33 | 35 | MRTD bool `json:"mrtd,omitempty"` |
34 | 36 | } |
| 37 | + |
| 38 | + // V3 request / response messages |
| 39 | + |
| 40 | + // BankIdv6AuthSignRequestV3 is used to start either an auth or sign request against BankID |
| 41 | + BankIdv6AuthSignRequestV3 struct { |
| 42 | + // EndUserIp The user IP address as it is seen by your service |
| 43 | + EndUserIp string `json:"endUserIp"` |
| 44 | + |
| 45 | + // ReturnUrl Orders started on the same device as where the user's BankID is stored (started with autostart |
| 46 | + // token) will call this URL when the order is completed |
| 47 | + ReturnUrl string `json:"returnUrl,omitempty"` |
| 48 | + |
| 49 | + // UserNonVisibleData Data that you wish to include but not display to the user |
| 50 | + UserNonVisibleData string `json:"userNonVisibleData,omitempty"` |
| 51 | + |
| 52 | + // UserVisibleData Text displayed to the user during the order |
| 53 | + UserVisibleData string `json:"userVisibleData,omitempty"` |
| 54 | + |
| 55 | + // UserVisibleDataFormat, 'plaintext' or 'simpleMarkdownV1' |
| 56 | + UserVisibleDataFormat string `json:"userVisibleDataFormat,omitempty"` |
| 57 | + |
| 58 | + // PersonalNumber The personal identity number allowed to confirm the identification |
| 59 | + PersonalNumber string `json:"personalNumber,omitempty"` |
| 60 | + |
| 61 | + // PinCode User is required to confirm the order with their security code even if they have biometrics activated |
| 62 | + PinCode bool `json:"pinCode,omitempty"` |
| 63 | + |
| 64 | + // Once if true, will start an auth/sign and just return a single QR code, if false, auth/sign endpoint return |
| 65 | + // an SSE / NDJSON stream and send a new QR-code each second, for 30 seconds before returning |
| 66 | + Once bool `json:"once,omitempty"` |
| 67 | + } |
| 68 | + |
| 69 | + // BankIdV6AuthSignResponseV3 is sent as a successful reply to an auth or sign request. If SSE / NDJSON is used, a |
| 70 | + // new BankIdV6AuthSignResponseV3 is sent each second (for 30 seconds) |
| 71 | + BankIdV6AuthSignResponseV3 struct { |
| 72 | + // OrderRef The reference ID for an order |
| 73 | + OrderRef string `json:"orderRef"` |
| 74 | + |
| 75 | + // URI Start URL, for "BankID on this device" |
| 76 | + URI string `json:"uri"` |
| 77 | + |
| 78 | + // QR contain the data for the QR-code |
| 79 | + QR string `json:"qr"` |
| 80 | + } |
| 81 | + |
| 82 | + // BankIdv6CollectRequestV3 is used to collect status on a started auth / sign request |
| 83 | + BankIdv6CollectRequestV3 struct { |
| 84 | + // OrderRef A reference ID for an order |
| 85 | + OrderRef string `json:"orderRef"` |
| 86 | + |
| 87 | + // WaitForChange allows the request to wait until a change is detected |
| 88 | + WaitForChange bool `json:"waitForChange"` |
| 89 | + |
| 90 | + // WaitUntilFinished allows the request to wait until the referenced request has either completed or failed, |
| 91 | + // and will not return on state changes during the ongoing process. |
| 92 | + WaitUntilFinished bool `json:"waitUntilFinished"` |
| 93 | + } |
| 94 | + |
| 95 | + // BankIdV6CollectResponseV3 is sent for a successful collect, if WaitUntilFinished is set in the request, it will |
| 96 | + // only return once the order have either completed or failed. If WaitUntilFinished isn't set, it will return once |
| 97 | + // a change is detected. |
| 98 | + BankIdV6CollectResponseV3 struct { |
| 99 | + // OrderRef The reference ID for an order |
| 100 | + OrderRef string `json:"orderRef"` |
| 101 | + Status string `json:"status,omitempty"` |
| 102 | + HintCode string `json:"hintCode,omitempty"` |
| 103 | + CompletionData *BankIdV6CompletionData `json:"completionData,omitempty"` |
| 104 | + } |
| 105 | + |
| 106 | + // BankIdv6CancelRequestV3 request the cancellation of a pending auth / sign request |
| 107 | + BankIdv6CancelRequestV3 struct { |
| 108 | + // OrderRef A reference ID for an order |
| 109 | + OrderRef string `json:"orderRef"` |
| 110 | + } |
| 111 | + |
| 112 | + BankIdv6CancelResponseV3 struct { |
| 113 | + Status string `json:"status"` |
| 114 | + } |
| 115 | + |
| 116 | + // BankIdv6ErrorResponseV3 is sent when an endpoint return an error (4xx, 5xx) http status code |
| 117 | + BankIdv6ErrorResponseV3 struct { |
| 118 | + // Origin contains the origin of the error, currently either 'Twofer' or 'BankIDv6' |
| 119 | + Origin string `json:"origin"` // Twofer / BankIDv6 |
| 120 | + |
| 121 | + // StatusCode contain the original HTTP status code, if the error originates from BankID |
| 122 | + StatusCode int `json:"statusCode,omitempty"` |
| 123 | + |
| 124 | + // ErrorCode contain the original error code that we may get from BankID when they return an http 400 |
| 125 | + Code string `json:"code,omitempty"` |
| 126 | + |
| 127 | + // Detail may contain the original error detail that we may get from BankID when they return an http 400, or it |
| 128 | + // can be an error message generated in twofer, for twofer errors |
| 129 | + Detail string `json:"detail"` |
| 130 | + } |
35 | 131 | ) |
36 | 132 |
|
| 133 | +// Status codes |
37 | 134 | const ( |
38 | 135 | StatusPending = "pending" |
39 | 136 | StatusComplete = "complete" |
40 | 137 | StatusFailed = "failed" |
41 | 138 | StatusError = "error" |
| 139 | + StatusQrCode = "qrcode" |
| 140 | +) |
| 141 | + |
| 142 | +// Error origin codes |
| 143 | +const ( |
| 144 | + ErrorOriginTwofer = "Twofer" |
| 145 | + ErrorOriginBankIDv6 = "BankIDv6" |
42 | 146 | ) |
0 commit comments