@naturalpay/sdk 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/client.d.mts +23 -20
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +23 -20
  5. package/client.d.ts.map +1 -1
  6. package/client.js +11 -8
  7. package/client.js.map +1 -1
  8. package/client.mjs +12 -9
  9. package/client.mjs.map +1 -1
  10. package/internal/tslib.js +17 -17
  11. package/internal/utils/query.d.mts +3 -0
  12. package/internal/utils/query.d.mts.map +1 -1
  13. package/internal/utils/query.d.ts +3 -0
  14. package/internal/utils/query.d.ts.map +1 -1
  15. package/internal/utils/query.js +16 -3
  16. package/internal/utils/query.js.map +1 -1
  17. package/internal/utils/query.mjs +16 -2
  18. package/internal/utils/query.mjs.map +1 -1
  19. package/package.json +1 -1
  20. package/resources/agents.d.mts +554 -268
  21. package/resources/agents.d.mts.map +1 -1
  22. package/resources/agents.d.ts +554 -268
  23. package/resources/agents.d.ts.map +1 -1
  24. package/resources/agents.js +72 -20
  25. package/resources/agents.js.map +1 -1
  26. package/resources/agents.mjs +72 -20
  27. package/resources/agents.mjs.map +1 -1
  28. package/resources/api-keys.d.mts +16 -2
  29. package/resources/api-keys.d.mts.map +1 -1
  30. package/resources/api-keys.d.ts +16 -2
  31. package/resources/api-keys.d.ts.map +1 -1
  32. package/resources/api-keys.js +7 -4
  33. package/resources/api-keys.js.map +1 -1
  34. package/resources/api-keys.mjs +7 -4
  35. package/resources/api-keys.mjs.map +1 -1
  36. package/resources/customers.d.mts +243 -114
  37. package/resources/customers.d.mts.map +1 -1
  38. package/resources/customers.d.ts +243 -114
  39. package/resources/customers.d.ts.map +1 -1
  40. package/resources/customers.js +6 -7
  41. package/resources/customers.js.map +1 -1
  42. package/resources/customers.mjs +6 -7
  43. package/resources/customers.mjs.map +1 -1
  44. package/resources/index.d.mts +7 -7
  45. package/resources/index.d.mts.map +1 -1
  46. package/resources/index.d.ts +7 -7
  47. package/resources/index.d.ts.map +1 -1
  48. package/resources/index.js +3 -3
  49. package/resources/index.js.map +1 -1
  50. package/resources/index.mjs +2 -2
  51. package/resources/index.mjs.map +1 -1
  52. package/resources/invitations.d.mts +16 -7
  53. package/resources/invitations.d.mts.map +1 -1
  54. package/resources/invitations.d.ts +16 -7
  55. package/resources/invitations.d.ts.map +1 -1
  56. package/resources/invitations.js +6 -4
  57. package/resources/invitations.js.map +1 -1
  58. package/resources/invitations.mjs +6 -4
  59. package/resources/invitations.mjs.map +1 -1
  60. package/resources/parties.d.mts +53 -26
  61. package/resources/parties.d.mts.map +1 -1
  62. package/resources/parties.d.ts +53 -26
  63. package/resources/parties.d.ts.map +1 -1
  64. package/resources/parties.js +27 -1
  65. package/resources/parties.js.map +1 -1
  66. package/resources/parties.mjs +27 -1
  67. package/resources/parties.mjs.map +1 -1
  68. package/resources/payment-requests.d.mts +738 -33
  69. package/resources/payment-requests.d.mts.map +1 -1
  70. package/resources/payment-requests.d.ts +738 -33
  71. package/resources/payment-requests.d.ts.map +1 -1
  72. package/resources/payment-requests.js +82 -1
  73. package/resources/payment-requests.js.map +1 -1
  74. package/resources/payment-requests.mjs +82 -1
  75. package/resources/payment-requests.mjs.map +1 -1
  76. package/resources/payments.d.mts +390 -24
  77. package/resources/payments.d.mts.map +1 -1
  78. package/resources/payments.d.ts +390 -24
  79. package/resources/payments.d.ts.map +1 -1
  80. package/resources/payments.js +53 -3
  81. package/resources/payments.js.map +1 -1
  82. package/resources/payments.mjs +53 -3
  83. package/resources/payments.mjs.map +1 -1
  84. package/resources/transactions.d.mts +50 -118
  85. package/resources/transactions.d.mts.map +1 -1
  86. package/resources/transactions.d.ts +50 -118
  87. package/resources/transactions.d.ts.map +1 -1
  88. package/resources/transactions.js +2 -2
  89. package/resources/transactions.mjs +2 -2
  90. package/resources/transfers.d.mts +1030 -0
  91. package/resources/transfers.d.mts.map +1 -0
  92. package/resources/transfers.d.ts +1030 -0
  93. package/resources/transfers.d.ts.map +1 -0
  94. package/resources/transfers.js +114 -0
  95. package/resources/transfers.js.map +1 -0
  96. package/resources/transfers.mjs +110 -0
  97. package/resources/transfers.mjs.map +1 -0
  98. package/resources/wallet.d.mts +1 -189
  99. package/resources/wallet.d.mts.map +1 -1
  100. package/resources/wallet.d.ts +1 -189
  101. package/resources/wallet.d.ts.map +1 -1
  102. package/resources/wallet.js +0 -66
  103. package/resources/wallet.js.map +1 -1
  104. package/resources/wallet.mjs +0 -66
  105. package/resources/wallet.mjs.map +1 -1
  106. package/resources/webhooks.d.mts +7 -7
  107. package/resources/webhooks.d.mts.map +1 -1
  108. package/resources/webhooks.d.ts +7 -7
  109. package/resources/webhooks.d.ts.map +1 -1
  110. package/src/client.ts +82 -43
  111. package/src/internal/utils/query.ts +18 -2
  112. package/src/resources/agents.ts +676 -300
  113. package/src/resources/api-keys.ts +26 -4
  114. package/src/resources/customers.ts +273 -132
  115. package/src/resources/index.ts +38 -18
  116. package/src/resources/invitations.ts +26 -10
  117. package/src/resources/parties.ts +85 -30
  118. package/src/resources/payment-requests.ts +949 -58
  119. package/src/resources/payments.ts +518 -23
  120. package/src/resources/transactions.ts +50 -136
  121. package/src/resources/transfers.ts +1338 -0
  122. package/src/resources/wallet.ts +0 -268
  123. package/src/resources/webhooks.ts +7 -0
  124. package/src/version.ts +1 -1
  125. package/version.d.mts +1 -1
  126. package/version.d.ts +1 -1
  127. package/version.js +1 -1
  128. package/version.mjs +1 -1
  129. package/internal/qs/formats.d.mts +0 -7
  130. package/internal/qs/formats.d.mts.map +0 -1
  131. package/internal/qs/formats.d.ts +0 -7
  132. package/internal/qs/formats.d.ts.map +0 -1
  133. package/internal/qs/formats.js +0 -13
  134. package/internal/qs/formats.js.map +0 -1
  135. package/internal/qs/formats.mjs +0 -9
  136. package/internal/qs/formats.mjs.map +0 -1
  137. package/internal/qs/index.d.mts +0 -10
  138. package/internal/qs/index.d.mts.map +0 -1
  139. package/internal/qs/index.d.ts +0 -10
  140. package/internal/qs/index.d.ts.map +0 -1
  141. package/internal/qs/index.js +0 -14
  142. package/internal/qs/index.js.map +0 -1
  143. package/internal/qs/index.mjs +0 -10
  144. package/internal/qs/index.mjs.map +0 -1
  145. package/internal/qs/stringify.d.mts +0 -3
  146. package/internal/qs/stringify.d.mts.map +0 -1
  147. package/internal/qs/stringify.d.ts +0 -3
  148. package/internal/qs/stringify.d.ts.map +0 -1
  149. package/internal/qs/stringify.js +0 -277
  150. package/internal/qs/stringify.js.map +0 -1
  151. package/internal/qs/stringify.mjs +0 -274
  152. package/internal/qs/stringify.mjs.map +0 -1
  153. package/internal/qs/types.d.mts +0 -57
  154. package/internal/qs/types.d.mts.map +0 -1
  155. package/internal/qs/types.d.ts +0 -57
  156. package/internal/qs/types.d.ts.map +0 -1
  157. package/internal/qs/types.js +0 -3
  158. package/internal/qs/types.js.map +0 -1
  159. package/internal/qs/types.mjs +0 -2
  160. package/internal/qs/types.mjs.map +0 -1
  161. package/internal/qs/utils.d.mts +0 -15
  162. package/internal/qs/utils.d.mts.map +0 -1
  163. package/internal/qs/utils.d.ts +0 -15
  164. package/internal/qs/utils.d.ts.map +0 -1
  165. package/internal/qs/utils.js +0 -230
  166. package/internal/qs/utils.js.map +0 -1
  167. package/internal/qs/utils.mjs +0 -217
  168. package/internal/qs/utils.mjs.map +0 -1
  169. package/resources/delegations.d.mts +0 -458
  170. package/resources/delegations.d.mts.map +0 -1
  171. package/resources/delegations.d.ts +0 -458
  172. package/resources/delegations.d.ts.map +0 -1
  173. package/resources/delegations.js +0 -47
  174. package/resources/delegations.js.map +0 -1
  175. package/resources/delegations.mjs +0 -43
  176. package/resources/delegations.mjs.map +0 -1
  177. package/src/internal/qs/LICENSE.md +0 -13
  178. package/src/internal/qs/README.md +0 -3
  179. package/src/internal/qs/formats.ts +0 -10
  180. package/src/internal/qs/index.ts +0 -13
  181. package/src/internal/qs/stringify.ts +0 -385
  182. package/src/internal/qs/types.ts +0 -71
  183. package/src/internal/qs/utils.ts +0 -265
  184. package/src/resources/delegations.ts +0 -580
@@ -1,265 +0,0 @@
1
- import { RFC1738 } from './formats';
2
- import type { DefaultEncoder, Format } from './types';
3
- import { isArray } from '../utils/values';
4
-
5
- export let has = (obj: object, key: PropertyKey): boolean => (
6
- (has = (Object as any).hasOwn ?? Function.prototype.call.bind(Object.prototype.hasOwnProperty)),
7
- has(obj, key)
8
- );
9
-
10
- const hex_table = /* @__PURE__ */ (() => {
11
- const array = [];
12
- for (let i = 0; i < 256; ++i) {
13
- array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase());
14
- }
15
-
16
- return array;
17
- })();
18
-
19
- function compact_queue<T extends Record<string, any>>(queue: Array<{ obj: T; prop: string }>) {
20
- while (queue.length > 1) {
21
- const item = queue.pop();
22
- if (!item) continue;
23
-
24
- const obj = item.obj[item.prop];
25
-
26
- if (isArray(obj)) {
27
- const compacted: unknown[] = [];
28
-
29
- for (let j = 0; j < obj.length; ++j) {
30
- if (typeof obj[j] !== 'undefined') {
31
- compacted.push(obj[j]);
32
- }
33
- }
34
-
35
- // @ts-ignore
36
- item.obj[item.prop] = compacted;
37
- }
38
- }
39
- }
40
-
41
- function array_to_object(source: any[], options: { plainObjects: boolean }) {
42
- const obj = options && options.plainObjects ? Object.create(null) : {};
43
- for (let i = 0; i < source.length; ++i) {
44
- if (typeof source[i] !== 'undefined') {
45
- obj[i] = source[i];
46
- }
47
- }
48
-
49
- return obj;
50
- }
51
-
52
- export function merge(
53
- target: any,
54
- source: any,
55
- options: { plainObjects?: boolean; allowPrototypes?: boolean } = {},
56
- ) {
57
- if (!source) {
58
- return target;
59
- }
60
-
61
- if (typeof source !== 'object') {
62
- if (isArray(target)) {
63
- target.push(source);
64
- } else if (target && typeof target === 'object') {
65
- if ((options && (options.plainObjects || options.allowPrototypes)) || !has(Object.prototype, source)) {
66
- target[source] = true;
67
- }
68
- } else {
69
- return [target, source];
70
- }
71
-
72
- return target;
73
- }
74
-
75
- if (!target || typeof target !== 'object') {
76
- return [target].concat(source);
77
- }
78
-
79
- let mergeTarget = target;
80
- if (isArray(target) && !isArray(source)) {
81
- // @ts-ignore
82
- mergeTarget = array_to_object(target, options);
83
- }
84
-
85
- if (isArray(target) && isArray(source)) {
86
- source.forEach(function (item, i) {
87
- if (has(target, i)) {
88
- const targetItem = target[i];
89
- if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') {
90
- target[i] = merge(targetItem, item, options);
91
- } else {
92
- target.push(item);
93
- }
94
- } else {
95
- target[i] = item;
96
- }
97
- });
98
- return target;
99
- }
100
-
101
- return Object.keys(source).reduce(function (acc, key) {
102
- const value = source[key];
103
-
104
- if (has(acc, key)) {
105
- acc[key] = merge(acc[key], value, options);
106
- } else {
107
- acc[key] = value;
108
- }
109
- return acc;
110
- }, mergeTarget);
111
- }
112
-
113
- export function assign_single_source(target: any, source: any) {
114
- return Object.keys(source).reduce(function (acc, key) {
115
- acc[key] = source[key];
116
- return acc;
117
- }, target);
118
- }
119
-
120
- export function decode(str: string, _: any, charset: string) {
121
- const strWithoutPlus = str.replace(/\+/g, ' ');
122
- if (charset === 'iso-8859-1') {
123
- // unescape never throws, no try...catch needed:
124
- return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape);
125
- }
126
- // utf-8
127
- try {
128
- return decodeURIComponent(strWithoutPlus);
129
- } catch (e) {
130
- return strWithoutPlus;
131
- }
132
- }
133
-
134
- const limit = 1024;
135
-
136
- export const encode: (
137
- str: any,
138
- defaultEncoder: DefaultEncoder,
139
- charset: string,
140
- type: 'key' | 'value',
141
- format: Format,
142
- ) => string = (str, _defaultEncoder, charset, _kind, format: Format) => {
143
- // This code was originally written by Brian White for the io.js core querystring library.
144
- // It has been adapted here for stricter adherence to RFC 3986
145
- if (str.length === 0) {
146
- return str;
147
- }
148
-
149
- let string = str;
150
- if (typeof str === 'symbol') {
151
- string = Symbol.prototype.toString.call(str);
152
- } else if (typeof str !== 'string') {
153
- string = String(str);
154
- }
155
-
156
- if (charset === 'iso-8859-1') {
157
- return escape(string).replace(/%u[0-9a-f]{4}/gi, function ($0) {
158
- return '%26%23' + parseInt($0.slice(2), 16) + '%3B';
159
- });
160
- }
161
-
162
- let out = '';
163
- for (let j = 0; j < string.length; j += limit) {
164
- const segment = string.length >= limit ? string.slice(j, j + limit) : string;
165
- const arr = [];
166
-
167
- for (let i = 0; i < segment.length; ++i) {
168
- let c = segment.charCodeAt(i);
169
- if (
170
- c === 0x2d || // -
171
- c === 0x2e || // .
172
- c === 0x5f || // _
173
- c === 0x7e || // ~
174
- (c >= 0x30 && c <= 0x39) || // 0-9
175
- (c >= 0x41 && c <= 0x5a) || // a-z
176
- (c >= 0x61 && c <= 0x7a) || // A-Z
177
- (format === RFC1738 && (c === 0x28 || c === 0x29)) // ( )
178
- ) {
179
- arr[arr.length] = segment.charAt(i);
180
- continue;
181
- }
182
-
183
- if (c < 0x80) {
184
- arr[arr.length] = hex_table[c];
185
- continue;
186
- }
187
-
188
- if (c < 0x800) {
189
- arr[arr.length] = hex_table[0xc0 | (c >> 6)]! + hex_table[0x80 | (c & 0x3f)];
190
- continue;
191
- }
192
-
193
- if (c < 0xd800 || c >= 0xe000) {
194
- arr[arr.length] =
195
- hex_table[0xe0 | (c >> 12)]! + hex_table[0x80 | ((c >> 6) & 0x3f)] + hex_table[0x80 | (c & 0x3f)];
196
- continue;
197
- }
198
-
199
- i += 1;
200
- c = 0x10000 + (((c & 0x3ff) << 10) | (segment.charCodeAt(i) & 0x3ff));
201
-
202
- arr[arr.length] =
203
- hex_table[0xf0 | (c >> 18)]! +
204
- hex_table[0x80 | ((c >> 12) & 0x3f)] +
205
- hex_table[0x80 | ((c >> 6) & 0x3f)] +
206
- hex_table[0x80 | (c & 0x3f)];
207
- }
208
-
209
- out += arr.join('');
210
- }
211
-
212
- return out;
213
- };
214
-
215
- export function compact(value: any) {
216
- const queue = [{ obj: { o: value }, prop: 'o' }];
217
- const refs = [];
218
-
219
- for (let i = 0; i < queue.length; ++i) {
220
- const item = queue[i];
221
- // @ts-ignore
222
- const obj = item.obj[item.prop];
223
-
224
- const keys = Object.keys(obj);
225
- for (let j = 0; j < keys.length; ++j) {
226
- const key = keys[j]!;
227
- const val = obj[key];
228
- if (typeof val === 'object' && val !== null && refs.indexOf(val) === -1) {
229
- queue.push({ obj: obj, prop: key });
230
- refs.push(val);
231
- }
232
- }
233
- }
234
-
235
- compact_queue(queue);
236
-
237
- return value;
238
- }
239
-
240
- export function is_regexp(obj: any) {
241
- return Object.prototype.toString.call(obj) === '[object RegExp]';
242
- }
243
-
244
- export function is_buffer(obj: any) {
245
- if (!obj || typeof obj !== 'object') {
246
- return false;
247
- }
248
-
249
- return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
250
- }
251
-
252
- export function combine(a: any, b: any) {
253
- return [].concat(a, b);
254
- }
255
-
256
- export function maybe_map<T>(val: T[], fn: (v: T) => T) {
257
- if (isArray(val)) {
258
- const mapped = [];
259
- for (let i = 0; i < val.length; i += 1) {
260
- mapped.push(fn(val[i]!));
261
- }
262
- return mapped;
263
- }
264
- return fn(val);
265
- }