From 01b26887af51c4a4b872b56ae15c63e26646f805 Mon Sep 17 00:00:00 2001 From: David Alpert Date: Fri, 12 Mar 2021 09:32:21 -0600 Subject: [PATCH] GH-39 relax ofx response parsing to support TYPE1 responses Section 4.2.2.2 Type 1 Protocol Overview in the [Open Financial Exchange Specification 2.2, Nov 26, 2017](https://www.ofx.net/downloads/OFX%202.2.pdf) states that: Type 1 applies only to the request part of a message; the server response is unaffected. Thus it appears that we can safely parse SECURITY:TYPE1 using the same logic that we parse SECURITY:NONE As I understand it, Security:TYPE1 indicates that the financial institution uses SSL enryption to protect customer credentials in transit. This applies explicitly to the incoming requests which may contain authentication as part of the request but does not appear to cause any material changes to the response format. As a result it appears that we can safely parse SECURITY:TYPE1 responess in the same way that we parse SECURITY:NONE responsese. --- response.go | 4 +- .../valid_responses/moneymrkt1_v103_TYPE1.ofx | 75 +++++++++++++++++++ 2 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 samples/valid_responses/moneymrkt1_v103_TYPE1.ofx diff --git a/response.go b/response.go index a510556..61f471e 100644 --- a/response.go +++ b/response.go @@ -93,8 +93,8 @@ func (or *Response) readSGMLHeaders(r *bufio.Reader) error { return errors.New("OFX VERSION > 160 in SGML header") } case "SECURITY": - if headerValue != "NONE" { - return errors.New("OFX SECURITY header not NONE") + if !(headerValue == "NONE" || headerValue == "TYPE1") { + return errors.New("OFX SECURITY header must be NONE or TYPE1") } case "COMPRESSION": if headerValue != "NONE" { diff --git a/samples/valid_responses/moneymrkt1_v103_TYPE1.ofx b/samples/valid_responses/moneymrkt1_v103_TYPE1.ofx new file mode 100644 index 0000000..4665a4e --- /dev/null +++ b/samples/valid_responses/moneymrkt1_v103_TYPE1.ofx @@ -0,0 +1,75 @@ +OFXHEADER:100 +DATA:OFXSGML +VERSION:103 +SECURITY:TYPE1 +ENCODING:USASCII +CHARSET:1252 +COMPRESSION:NONE +OLDFILEUID:NONE +NEWFILEUID:NONE + + + + +0 +INFO + +20170407001840.607[0:GMT] +ENG + +UJKDO +3534 + + + + + +e1707dfd-695d-4451-8d9c-0e142fdc456a + +0 +INFO + + +USD + +598813374 +35342483513 +MONEYMRKT + + +20170107011841.262[0:GMT] +20170407001841.262[0:GMT] + +CREDIT +20170117120000.000[0:GMT] +-995.4190396554627 +2fb2640c-cee3-4643-8ba3-ea21a4d18954 +Dividend Earned + + +CREDIT +20170215120000.000[0:GMT] +788.5385340523635 +c9d856df-339c-47c6-9f6a-8c2e2910f62e +Dividend Earned + + +CREDIT +20170315120000.000[0:GMT] +3070.1328011762807 +1107ace0-048b-4c0c-b5f3-45b6be4cd71d +Dividend Earned + + + +2607.1664944585727 +20170407001841.262[0:GMT] + + +4503.683156768119 +20170407001841.262[0:GMT] + + + + + \ No newline at end of file