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.
This commit is contained in:
David Alpert 2021-03-12 09:32:21 -06:00 committed by Aaron Lindsay
parent 2b8a79e4b7
commit 01b26887af
2 changed files with 77 additions and 2 deletions

View File

@ -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" {

View File

@ -0,0 +1,75 @@
OFXHEADER:100
DATA:OFXSGML
VERSION:103
SECURITY:TYPE1
ENCODING:USASCII
CHARSET:1252
COMPRESSION:NONE
OLDFILEUID:NONE
NEWFILEUID:NONE
<OFX>
<SIGNONMSGSRSV1><SONRS>
<STATUS>
<CODE>0
<SEVERITY>INFO
</STATUS>
<DTSERVER>20170407001840.607[0:GMT]
<LANGUAGE>ENG
<FI>
<ORG>UJKDO
<FID>3534
</FI>
</SONRS>
</SIGNONMSGSRSV1>
<BANKMSGSRSV1>
<STMTTRNRS>
<TRNUID>e1707dfd-695d-4451-8d9c-0e142fdc456a
<STATUS>
<CODE>0
<SEVERITY>INFO
</STATUS>
<STMTRS>
<CURDEF>USD
<BANKACCTFROM>
<BANKID>598813374
<ACCTID>35342483513
<ACCTTYPE>MONEYMRKT
</BANKACCTFROM>
<BANKTRANLIST>
<DTSTART>20170107011841.262[0:GMT]
<DTEND>20170407001841.262[0:GMT]
<STMTTRN>
<TRNTYPE>CREDIT
<DTPOSTED>20170117120000.000[0:GMT]
<TRNAMT>-995.4190396554627
<FITID>2fb2640c-cee3-4643-8ba3-ea21a4d18954
<NAME>Dividend Earned
</STMTTRN>
<STMTTRN>
<TRNTYPE>CREDIT
<DTPOSTED>20170215120000.000[0:GMT]
<TRNAMT>788.5385340523635
<FITID>c9d856df-339c-47c6-9f6a-8c2e2910f62e
<NAME>Dividend Earned
</STMTTRN>
<STMTTRN>
<TRNTYPE>CREDIT
<DTPOSTED>20170315120000.000[0:GMT]
<TRNAMT>3070.1328011762807
<FITID>1107ace0-048b-4c0c-b5f3-45b6be4cd71d
<NAME>Dividend Earned
</STMTTRN>
</BANKTRANLIST>
<LEDGERBAL>
<BALAMT>2607.1664944585727
<DTASOF>20170407001841.262[0:GMT]
</LEDGERBAL>
<AVAILBAL>
<BALAMT>4503.683156768119
<DTASOF>20170407001841.262[0:GMT]
</AVAILBAL>
</STMTRS>
</STMTTRNRS>
</BANKMSGSRSV1>
</OFX>