Skip to content

Commit 99fee0e

Browse files
authored
Merge pull request #19 from blinkmobile/ON-2307
ON-2307 # Added check for minimum expiry in seconds
2 parents f3d711a + 6f549d2 commit 99fee0e

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

classes/Forms.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ module.exports = class Forms extends OneBlinkAPI {
8080
if (typeof expiryInSeconds !== 'number') {
8181
return Promise.reject(new TypeError('Must supply "expiryInSeconds" as a number'))
8282
}
83+
if (expiryInSeconds < 900) {
84+
return Promise.reject(new TypeError('"expiryInSeconds" must be greater than or equal to 900'))
85+
}
8386

8487
return super.postRequest(`/forms/${formId}/retrieval-url/${submissionId}?expirySeconds=${expiryInSeconds}`)
8588
}

docs/forms.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ forms.generateFormUrl(formId, externalId, preFilledData)
6161
```javascript
6262
const formId = 1
6363
const submissionId = 'c1f0f27b-4289-4ce5-9807-bf84971991aa'
64-
const expiryInSeconds = 300
64+
const expiryInSeconds = 900
6565
forms.generateSubmissionDataUrl(formId, submissionId, expiryInSeconds)
6666
.then((result) => {
6767
const submissionDataUrl = result.url
@@ -75,7 +75,7 @@ forms.generateSubmissionDataUrl(formId, submissionId, expiryInSeconds)
7575
|---|---|---|---|
7676
| `formId` | Yes | `number` | The exact id of the form you wish to generate a URL for |
7777
| `submissionId` | Yes | `string` | The submission identifier generated after a successful form submission, this will be return to you after a successful forms submission via a callback URL |
78-
| `expiryInSeconds` | Yes | `number` | The number of seconds the signed URL should be valid for |
78+
| `expiryInSeconds` | Yes | `number` | The number of seconds the signed URL should be valid for, must be greater than or equal to `900` |
7979

8080
### Result (Resolved Promise)
8181

tests/lib/forms.test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ describe('Forms SDK Class', () => {
118118
test('"expiryInSeconds"', () => {
119119
return expect(forms.generateSubmissionDataUrl(1, '123')).rejects.toThrow('Must supply "expiryInSeconds" as a number')
120120
})
121+
122+
test('minimum "expiryInSeconds"', () => {
123+
return expect(forms.generateSubmissionDataUrl(1, '123', 600)).rejects.toThrow('"expiryInSeconds" must be greater than or equal to 900')
124+
})
121125
})
122126
})
123127

0 commit comments

Comments
 (0)