|
2 | 2 | Brief: Helper utilities. |
3 | 3 | */ |
4 | 4 |
|
5 | | -import securelayEndpoint, * as securelay from 'https://cdn.jsdelivr.net/gh/securelay/[email protected].2/script.js'; |
| 5 | +import securelayEndpoint, * as securelay from 'https://cdn.jsdelivr.net/gh/securelay/[email protected].3/script.js'; |
6 | 6 |
|
7 | 7 | /* |
8 | 8 | Brief: Returns the first block of hex chars from a v4 UUID as a unique string |
@@ -93,30 +93,30 @@ Brief: GET at private path of Securelay. |
93 | 93 | Arg: Key is string of the format `<privateKey>@<endpointID>`. Optionally provide webhook URL. |
94 | 94 | Error: Throws status code of the response when promise is rejected. |
95 | 95 | */ |
96 | | -export async function syncSecurelay (key, webhook = null, timeout = 5000) { |
| 96 | +export async function syncSecurelay (key, { webhook, timeout = 5000 } = {}) { |
97 | 97 | const [privateKey, endpointID] = key.split('@'); |
98 | | - return securelay.sync(privateKey, endpointID, webhook, timeout); |
| 98 | + return securelay.sync(privateKey, endpointID, { webhook: webhook, timeout: timeout }); |
99 | 99 | } |
100 | 100 |
|
101 | | -export async function keySecurelay (timeout = 5000) { |
102 | | - const [_, endpointID] = await securelayEndpoint(); |
103 | | - const privateKey = await securelay.key(endpointID, timeout); |
| 101 | +export async function keySecurelay ({ timeout = 5000 } = {}) { |
| 102 | + const [, endpointID] = await securelayEndpoint(); |
| 103 | + const privateKey = await securelay.key(endpointID, { timeout: timeout }); |
104 | 104 | return `${privateKey}@${endpointID}`; |
105 | 105 | } |
106 | 106 |
|
107 | | -export async function privateUrlSecurelay (key, timeout = 5000) { |
| 107 | +export async function privateUrlSecurelay (key, { timeout = 5000 } = {}) { |
108 | 108 | const [privateKey, endpointID] = key.split('@'); |
109 | | - return securelay.privateUrl(privateKey, endpointID, timeout); |
| 109 | + return securelay.privateUrl(privateKey, endpointID, { timeout: timeout }); |
110 | 110 | } |
111 | 111 |
|
112 | | -export async function publicUrlSecurelay (key, timeout = 5000) { |
| 112 | +export async function publicUrlSecurelay (key, { timeout = 5000 } = {}) { |
113 | 113 | const [privateKey, endpointID] = key.split('@'); |
114 | | - return securelay.publicUrl(privateKey, endpointID, timeout); |
| 114 | + return securelay.publicUrl(privateKey, endpointID, { timeout: timeout }); |
115 | 115 | } |
116 | 116 |
|
117 | | -export async function appIdSecurelay (key, app='formonit', timeout = 5000) { |
| 117 | +export async function appIdSecurelay (key, { app = 'formonit', timeout = 5000 } = {}) { |
118 | 118 | const [privateKey, endpointID] = key.split('@'); |
119 | | - return securelay.appId(endpointID, app, timeout); |
| 119 | + return securelay.appId(endpointID, app, { timeout: timeout }); |
120 | 120 | } |
121 | 121 |
|
122 | 122 | /* |
|
0 commit comments