@coinflowlabs/angular 0.0.4 → 0.0.5-sandbox2

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 (42) hide show
  1. package/esm2022/coinflowlabs-angular.mjs +5 -0
  2. package/esm2022/lib/coinflow-iframe.component.mjs +67 -0
  3. package/esm2022/lib/coinflow-purchase-history.component.mjs +16 -0
  4. package/esm2022/lib/coinflow-purchase-protection.component.mjs +16 -0
  5. package/esm2022/lib/coinflow-purchase.component.mjs +32 -0
  6. package/esm2022/lib/coinflow-withdraw-history.component.mjs +16 -0
  7. package/esm2022/lib/coinflow-withdraw.component.mjs +32 -0
  8. package/esm2022/lib/common/CoinflowLibMessageHandlers.mjs +130 -0
  9. package/esm2022/lib/common/CoinflowTypes.mjs +13 -0
  10. package/esm2022/lib/common/CoinflowUtils.mjs +181 -0
  11. package/esm2022/lib/common/SolanaPeerDeps.mjs +9 -0
  12. package/esm2022/lib/common/index.mjs +4 -0
  13. package/esm2022/public-api.mjs +10 -0
  14. package/fesm2022/coinflowlabs-angular.mjs +504 -0
  15. package/fesm2022/coinflowlabs-angular.mjs.map +1 -0
  16. package/index.d.ts +5 -0
  17. package/lib/coinflow-iframe.component.d.ts +17 -0
  18. package/lib/coinflow-purchase-history.component.d.ts +5 -0
  19. package/lib/coinflow-purchase-protection.component.d.ts +5 -0
  20. package/lib/coinflow-purchase.component.d.ts +10 -0
  21. package/lib/coinflow-withdraw-history.component.d.ts +5 -0
  22. package/lib/coinflow-withdraw.component.d.ts +10 -0
  23. package/lib/common/CoinflowLibMessageHandlers.d.ts +21 -0
  24. package/lib/common/CoinflowTypes.d.ts +286 -0
  25. package/lib/common/CoinflowUtils.d.ts +21 -0
  26. package/lib/common/SolanaPeerDeps.d.ts +4 -0
  27. package/package.json +16 -8
  28. package/{src/public-api.ts → public-api.d.ts} +0 -4
  29. package/ng-package.json +0 -7
  30. package/src/lib/coinflow-iframe.component.ts +0 -63
  31. package/src/lib/coinflow-purchase-history.component.ts +0 -9
  32. package/src/lib/coinflow-purchase-protection.component.ts +0 -9
  33. package/src/lib/coinflow-purchase.component.ts +0 -37
  34. package/src/lib/coinflow-withdraw-history.component.ts +0 -9
  35. package/src/lib/coinflow-withdraw.component.ts +0 -36
  36. package/src/lib/common/CoinflowLibMessageHandlers.ts +0 -188
  37. package/src/lib/common/CoinflowTypes.ts +0 -403
  38. package/src/lib/common/CoinflowUtils.ts +0 -269
  39. package/tsconfig.lib.json +0 -14
  40. package/tsconfig.lib.prod.json +0 -10
  41. package/tsconfig.spec.json +0 -14
  42. /package/{src/lib/common/index.ts → lib/common/index.d.ts} +0 -0
@@ -1,269 +0,0 @@
1
- import {
2
- CoinflowBlockchain,
3
- CoinflowEnvs,
4
- CoinflowIFrameProps,
5
- CoinflowPurchaseProps,
6
- } from './CoinflowTypes';
7
- import * as web3 from '@solana/web3.js';
8
- import * as base58 from 'bs58';
9
-
10
- export class CoinflowUtils {
11
- env: CoinflowEnvs;
12
- url: string;
13
-
14
- constructor(env?: CoinflowEnvs) {
15
- this.env = env ?? 'prod';
16
- if (this.env === 'prod') this.url = 'https://api.coinflow.cash';
17
- else if (this.env === 'local') this.url = 'http://localhost:5000';
18
- else this.url = `https://api-${this.env}.coinflow.cash`;
19
- }
20
-
21
- async getNSurePartnerId(merchantId: string): Promise<string | undefined> {
22
- return fetch(this.url + `/merchant/view/${merchantId}`)
23
- .then(response => response.json())
24
- .then(
25
- (json: {
26
- nSurePartnerId: string | undefined;
27
- nSureSettings: {nSurePartnerId: string | undefined};
28
- }) => json.nSureSettings?.nSurePartnerId || json.nSurePartnerId
29
- )
30
- .catch(e => {
31
- console.error(e);
32
- return undefined;
33
- });
34
- }
35
-
36
- async getCreditBalance(
37
- publicKey: string,
38
- merchantId: string,
39
- blockchain: 'solana' | 'near'
40
- ): Promise<{cents: number}> {
41
- const response = await fetch(
42
- this.url + `/api/customer/balances/${merchantId}`,
43
- {
44
- method: 'GET',
45
- headers: {
46
- 'x-coinflow-auth-wallet': publicKey,
47
- 'x-coinflow-auth-blockchain': blockchain,
48
- },
49
- }
50
- );
51
- const {credits} = await response.json();
52
- return credits;
53
- }
54
-
55
- static getCoinflowBaseUrl(env?: CoinflowEnvs): string {
56
- if (!env || env === 'prod') return 'https://coinflow.cash';
57
- if (env === 'local') return 'http://localhost:3000';
58
-
59
- return `https://${env}.coinflow.cash`;
60
- }
61
-
62
- static getCoinflowApiUrl(env?: CoinflowEnvs): string {
63
- if (!env || env === 'prod') return 'https://api.coinflow.cash';
64
- if (env === 'local') return 'http://localhost:5000';
65
-
66
- return `https://api-${env}.coinflow.cash`;
67
- }
68
-
69
- static getCoinflowUrl({
70
- walletPubkey,
71
- route,
72
- routePrefix,
73
- env,
74
- amount,
75
- transaction,
76
- blockchain,
77
- supportsVersionedTransactions,
78
- webhookInfo,
79
- email,
80
- loaderBackground,
81
- handleHeightChange,
82
- bankAccountLinkRedirect,
83
- additionalWallets,
84
- nearDeposit,
85
- chargebackProtectionData,
86
- merchantCss,
87
- color,
88
- rent,
89
- lockDefaultToken,
90
- token,
91
- tokens,
92
- planCode,
93
- disableApplePay,
94
- disableGooglePay,
95
- customerInfo,
96
- settlementType,
97
- lockAmount,
98
- nativeSolToConvert,
99
- theme,
100
- usePermit,
101
- transactionSigner,
102
- authOnly,
103
- deviceId,
104
- }: CoinflowIFrameProps): string {
105
- const prefix = routePrefix
106
- ? `/${routePrefix}/${blockchain}`
107
- : `/${blockchain}`;
108
- const url = new URL(prefix + route, CoinflowUtils.getCoinflowBaseUrl(env));
109
- url.searchParams.append('pubkey', walletPubkey!);
110
-
111
- if (transaction) {
112
- url.searchParams.append('transaction', transaction);
113
- }
114
- if (amount) {
115
- url.searchParams.append('amount', amount.toString());
116
- }
117
-
118
- if (supportsVersionedTransactions) {
119
- url.searchParams.append('supportsVersionedTransactions', 'true');
120
- }
121
-
122
- if (webhookInfo) {
123
- url.searchParams.append(
124
- 'webhookInfo',
125
- Buffer.from(JSON.stringify(webhookInfo)).toString('base64')
126
- );
127
- }
128
-
129
- if (theme) {
130
- url.searchParams.append(
131
- 'theme',
132
- Buffer.from(JSON.stringify(theme)).toString('base64')
133
- );
134
- }
135
-
136
- if (customerInfo) {
137
- url.searchParams.append(
138
- 'customerInfo',
139
- Buffer.from(JSON.stringify(customerInfo)).toString('base64')
140
- );
141
- }
142
-
143
- if (email) {
144
- url.searchParams.append('email', email);
145
- }
146
-
147
- if (token) {
148
- url.searchParams.append('token', token.toString());
149
- }
150
-
151
- if (tokens) {
152
- url.searchParams.append('tokens', tokens.toString());
153
- }
154
-
155
- if (loaderBackground) {
156
- url.searchParams.append('loaderBackground', loaderBackground);
157
- }
158
-
159
- if (handleHeightChange) {
160
- url.searchParams.append('useHeightChange', 'true');
161
- }
162
-
163
- if (bankAccountLinkRedirect) {
164
- url.searchParams.append(
165
- 'bankAccountLinkRedirect',
166
- bankAccountLinkRedirect
167
- );
168
- }
169
-
170
- if (additionalWallets)
171
- url.searchParams.append(
172
- 'additionalWallets',
173
- JSON.stringify(additionalWallets)
174
- );
175
-
176
- if (nearDeposit) url.searchParams.append('nearDeposit', nearDeposit);
177
-
178
- if (chargebackProtectionData)
179
- url.searchParams.append(
180
- 'chargebackProtectionData',
181
- JSON.stringify(chargebackProtectionData)
182
- );
183
- if (deviceId) {
184
- url.searchParams.append('deviceId', deviceId);
185
- } else {
186
- if (typeof window !== 'undefined') {
187
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
188
- // @ts-ignore
189
- const deviceId = window?.nSureSDK?.getDeviceId();
190
- if (deviceId) url.searchParams.append('deviceId', deviceId);
191
- }
192
- }
193
-
194
- if (merchantCss) url.searchParams.append('merchantCss', merchantCss);
195
- if (color) url.searchParams.append('color', color);
196
- if (rent) url.searchParams.append('rent', rent.lamports.toString());
197
- if (nativeSolToConvert)
198
- url.searchParams.append(
199
- 'nativeSolToConvert',
200
- nativeSolToConvert.lamports.toString()
201
- );
202
- if (lockDefaultToken) url.searchParams.append('lockDefaultToken', 'true');
203
- if (planCode) url.searchParams.append('planCode', planCode);
204
-
205
- if (disableApplePay) url.searchParams.append('disableApplePay', 'true');
206
- if (disableGooglePay) url.searchParams.append('disableGooglePay', 'true');
207
- if (settlementType)
208
- url.searchParams.append('settlementType', settlementType);
209
-
210
- if (lockAmount) url.searchParams.append('lockAmount', 'true');
211
-
212
- if (usePermit === false) url.searchParams.append('usePermit', 'false');
213
- if (transactionSigner)
214
- url.searchParams.append('transactionSigner', transactionSigner);
215
- if (authOnly === true) url.searchParams.append('authOnly', 'true');
216
-
217
- return url.toString();
218
- }
219
-
220
- static getTransaction(props: CoinflowPurchaseProps): string | undefined {
221
- if ('transaction' in props && props.transaction !== undefined) {
222
- const {transaction} = props;
223
- if (web3 && transaction instanceof web3.Transaction) {
224
- if (!base58) throw new Error('bs58 dependency is required for Solana');
225
- return base58.encode(
226
- transaction.serialize({
227
- requireAllSignatures: false,
228
- verifySignatures: false,
229
- })
230
- );
231
- }
232
-
233
- if (web3 && transaction instanceof web3.VersionedTransaction) {
234
- if (!base58) throw new Error('bs58 dependency is required for Solana');
235
- return base58.encode(transaction.serialize());
236
- }
237
-
238
- return btoa(JSON.stringify(transaction));
239
- }
240
-
241
- if ('action' in props && props.action !== undefined) {
242
- return btoa(JSON.stringify(props.action));
243
- }
244
-
245
- return undefined;
246
- }
247
-
248
- static byBlockchain<T>(
249
- blockchain: CoinflowBlockchain,
250
- args: {solana: T; near: T; eth?: T; polygon: T; base: T}
251
- ): T {
252
- switch (blockchain) {
253
- case 'solana':
254
- return args.solana;
255
- case 'near':
256
- return args.near;
257
- case 'polygon':
258
- return args.polygon;
259
- case 'eth':
260
- if (args.eth === undefined)
261
- throw new Error('blockchain not supported for this operation!');
262
- return args.eth;
263
- case 'base':
264
- return args.base;
265
- default:
266
- throw new Error('blockchain not supported!');
267
- }
268
- }
269
- }
package/tsconfig.lib.json DELETED
@@ -1,14 +0,0 @@
1
- /* To learn more about this file see: https://angular.io/config/tsconfig. */
2
- {
3
- "extends": "../../tsconfig.json",
4
- "compilerOptions": {
5
- "outDir": "../../out-tsc/lib",
6
- "declaration": true,
7
- "declarationMap": true,
8
- "inlineSources": true,
9
- "types": []
10
- },
11
- "exclude": [
12
- "**/*.spec.ts"
13
- ]
14
- }
@@ -1,10 +0,0 @@
1
- /* To learn more about this file see: https://angular.io/config/tsconfig. */
2
- {
3
- "extends": "./tsconfig.lib.json",
4
- "compilerOptions": {
5
- "declarationMap": false
6
- },
7
- "angularCompilerOptions": {
8
- "compilationMode": "partial"
9
- }
10
- }
@@ -1,14 +0,0 @@
1
- /* To learn more about this file see: https://angular.io/config/tsconfig. */
2
- {
3
- "extends": "../../tsconfig.json",
4
- "compilerOptions": {
5
- "outDir": "../../out-tsc/spec",
6
- "types": [
7
- "jasmine"
8
- ]
9
- },
10
- "include": [
11
- "**/*.spec.ts",
12
- "**/*.d.ts"
13
- ]
14
- }