@fystack/sdk 0.1.1 → 0.1.2
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.
- package/dist/index.cjs +10 -3
- package/dist/index.d.cts +2 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.esm.d.ts +2 -0
- package/dist/index.esm.js +10 -3
- package/dist/index.mjs +10 -3
- package/dist/types/index.d.ts +2 -0
- package/package.json +1 -1
- package/src/api.ts +7 -1
- package/src/signer.ts +5 -1
- package/src/solanaSigner.ts +7 -1
- package/src/types.ts +3 -0
package/dist/index.cjs
CHANGED
|
@@ -133,7 +133,13 @@ exports.WalletAddressType = void 0;
|
|
|
133
133
|
})(exports.WalletAddressType || (exports.WalletAddressType = {}));
|
|
134
134
|
async function composeAPIHeaders(credentials, httpMethod, apiEndpoint, body = {}) {
|
|
135
135
|
if (credentials.apiSecret == '') {
|
|
136
|
-
// If APISecret is not provided,
|
|
136
|
+
// If APISecret is not provided, use authToken
|
|
137
|
+
if (credentials.authToken) {
|
|
138
|
+
return {
|
|
139
|
+
Authorization: credentials.authToken
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
// fallback to cookie mode with no headers
|
|
137
143
|
return {};
|
|
138
144
|
}
|
|
139
145
|
const currentTimestampInSeconds = Math.floor(Date.now() / 1000);
|
|
@@ -534,7 +540,7 @@ class EtherSigner extends ethers.AbstractSigner {
|
|
|
534
540
|
if (this.address) {
|
|
535
541
|
return this.address;
|
|
536
542
|
}
|
|
537
|
-
if (!this.APICredentials.apiKey && !this.walletDetail.WalletID) {
|
|
543
|
+
if (!this.APICredentials.apiKey && !this.APICredentials.authToken && !this.walletDetail.WalletID) {
|
|
538
544
|
throw new Error('Wallet detail not found, use setWallet(walletId) to set wallet first!');
|
|
539
545
|
}
|
|
540
546
|
const detail = await this.APIService.getWalletDetail(exports.WalletAddressType.Evm, this.walletDetail?.WalletID);
|
|
@@ -795,7 +801,7 @@ class SolanaSigner {
|
|
|
795
801
|
if (this.address) {
|
|
796
802
|
return this.address;
|
|
797
803
|
}
|
|
798
|
-
if (!this.
|
|
804
|
+
if (!this.APICredentials.apiKey && !this.APICredentials.apiSecret && !this.walletDetail?.WalletID) {
|
|
799
805
|
throw new Error('Wallet detail not found, use setWallet(walletId) to set wallet first!');
|
|
800
806
|
}
|
|
801
807
|
const detail = await this.APIService.getWalletDetail(exports.WalletAddressType.Sol, this.walletDetail?.WalletID);
|
|
@@ -938,6 +944,7 @@ class SolanaSigner {
|
|
|
938
944
|
}
|
|
939
945
|
}
|
|
940
946
|
constructor(credentials, environment, pollerOptions){
|
|
947
|
+
this.APICredentials = credentials;
|
|
941
948
|
this.APIKey = credentials.apiKey;
|
|
942
949
|
this.APIService = new APIService(credentials, environment);
|
|
943
950
|
this.pollerOptions = pollerOptions;
|
package/dist/index.d.cts
CHANGED
|
@@ -23,6 +23,7 @@ declare enum TxApprovalStatus {
|
|
|
23
23
|
interface APICredentials {
|
|
24
24
|
apiKey: string;
|
|
25
25
|
apiSecret: string;
|
|
26
|
+
authToken?: string;
|
|
26
27
|
}
|
|
27
28
|
interface WebhookEvent {
|
|
28
29
|
webhook_id: string;
|
|
@@ -255,6 +256,7 @@ declare class SolanaSigner {
|
|
|
255
256
|
private APIKey;
|
|
256
257
|
private walletDetail;
|
|
257
258
|
private pollerOptions?;
|
|
259
|
+
private APICredentials;
|
|
258
260
|
constructor(credentials: APICredentials, environment: Environment, pollerOptions?: StatusPollerOptions);
|
|
259
261
|
setWallet(walletId: string): void;
|
|
260
262
|
getAddress(): Promise<string>;
|
package/dist/index.d.mts
CHANGED
|
@@ -23,6 +23,7 @@ declare enum TxApprovalStatus {
|
|
|
23
23
|
interface APICredentials {
|
|
24
24
|
apiKey: string;
|
|
25
25
|
apiSecret: string;
|
|
26
|
+
authToken?: string;
|
|
26
27
|
}
|
|
27
28
|
interface WebhookEvent {
|
|
28
29
|
webhook_id: string;
|
|
@@ -255,6 +256,7 @@ declare class SolanaSigner {
|
|
|
255
256
|
private APIKey;
|
|
256
257
|
private walletDetail;
|
|
257
258
|
private pollerOptions?;
|
|
259
|
+
private APICredentials;
|
|
258
260
|
constructor(credentials: APICredentials, environment: Environment, pollerOptions?: StatusPollerOptions);
|
|
259
261
|
setWallet(walletId: string): void;
|
|
260
262
|
getAddress(): Promise<string>;
|
package/dist/index.esm.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ declare enum TxApprovalStatus {
|
|
|
23
23
|
interface APICredentials {
|
|
24
24
|
apiKey: string;
|
|
25
25
|
apiSecret: string;
|
|
26
|
+
authToken?: string;
|
|
26
27
|
}
|
|
27
28
|
interface WebhookEvent {
|
|
28
29
|
webhook_id: string;
|
|
@@ -255,6 +256,7 @@ declare class SolanaSigner {
|
|
|
255
256
|
private APIKey;
|
|
256
257
|
private walletDetail;
|
|
257
258
|
private pollerOptions?;
|
|
259
|
+
private APICredentials;
|
|
258
260
|
constructor(credentials: APICredentials, environment: Environment, pollerOptions?: StatusPollerOptions);
|
|
259
261
|
setWallet(walletId: string): void;
|
|
260
262
|
getAddress(): Promise<string>;
|
package/dist/index.esm.js
CHANGED
|
@@ -125,7 +125,13 @@ var WalletAddressType;
|
|
|
125
125
|
})(WalletAddressType || (WalletAddressType = {}));
|
|
126
126
|
async function composeAPIHeaders(credentials, httpMethod, apiEndpoint, body = {}) {
|
|
127
127
|
if (credentials.apiSecret == '') {
|
|
128
|
-
// If APISecret is not provided,
|
|
128
|
+
// If APISecret is not provided, use authToken
|
|
129
|
+
if (credentials.authToken) {
|
|
130
|
+
return {
|
|
131
|
+
Authorization: credentials.authToken
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
// fallback to cookie mode with no headers
|
|
129
135
|
return {};
|
|
130
136
|
}
|
|
131
137
|
const currentTimestampInSeconds = Math.floor(Date.now() / 1000);
|
|
@@ -526,7 +532,7 @@ class EtherSigner extends AbstractSigner {
|
|
|
526
532
|
if (this.address) {
|
|
527
533
|
return this.address;
|
|
528
534
|
}
|
|
529
|
-
if (!this.APICredentials.apiKey && !this.walletDetail.WalletID) {
|
|
535
|
+
if (!this.APICredentials.apiKey && !this.APICredentials.authToken && !this.walletDetail.WalletID) {
|
|
530
536
|
throw new Error('Wallet detail not found, use setWallet(walletId) to set wallet first!');
|
|
531
537
|
}
|
|
532
538
|
const detail = await this.APIService.getWalletDetail(WalletAddressType.Evm, this.walletDetail?.WalletID);
|
|
@@ -787,7 +793,7 @@ class SolanaSigner {
|
|
|
787
793
|
if (this.address) {
|
|
788
794
|
return this.address;
|
|
789
795
|
}
|
|
790
|
-
if (!this.
|
|
796
|
+
if (!this.APICredentials.apiKey && !this.APICredentials.apiSecret && !this.walletDetail?.WalletID) {
|
|
791
797
|
throw new Error('Wallet detail not found, use setWallet(walletId) to set wallet first!');
|
|
792
798
|
}
|
|
793
799
|
const detail = await this.APIService.getWalletDetail(WalletAddressType.Sol, this.walletDetail?.WalletID);
|
|
@@ -930,6 +936,7 @@ class SolanaSigner {
|
|
|
930
936
|
}
|
|
931
937
|
}
|
|
932
938
|
constructor(credentials, environment, pollerOptions){
|
|
939
|
+
this.APICredentials = credentials;
|
|
933
940
|
this.APIKey = credentials.apiKey;
|
|
934
941
|
this.APIService = new APIService(credentials, environment);
|
|
935
942
|
this.pollerOptions = pollerOptions;
|
package/dist/index.mjs
CHANGED
|
@@ -125,7 +125,13 @@ var WalletAddressType;
|
|
|
125
125
|
})(WalletAddressType || (WalletAddressType = {}));
|
|
126
126
|
async function composeAPIHeaders(credentials, httpMethod, apiEndpoint, body = {}) {
|
|
127
127
|
if (credentials.apiSecret == '') {
|
|
128
|
-
// If APISecret is not provided,
|
|
128
|
+
// If APISecret is not provided, use authToken
|
|
129
|
+
if (credentials.authToken) {
|
|
130
|
+
return {
|
|
131
|
+
Authorization: credentials.authToken
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
// fallback to cookie mode with no headers
|
|
129
135
|
return {};
|
|
130
136
|
}
|
|
131
137
|
const currentTimestampInSeconds = Math.floor(Date.now() / 1000);
|
|
@@ -526,7 +532,7 @@ class EtherSigner extends AbstractSigner {
|
|
|
526
532
|
if (this.address) {
|
|
527
533
|
return this.address;
|
|
528
534
|
}
|
|
529
|
-
if (!this.APICredentials.apiKey && !this.walletDetail.WalletID) {
|
|
535
|
+
if (!this.APICredentials.apiKey && !this.APICredentials.authToken && !this.walletDetail.WalletID) {
|
|
530
536
|
throw new Error('Wallet detail not found, use setWallet(walletId) to set wallet first!');
|
|
531
537
|
}
|
|
532
538
|
const detail = await this.APIService.getWalletDetail(WalletAddressType.Evm, this.walletDetail?.WalletID);
|
|
@@ -787,7 +793,7 @@ class SolanaSigner {
|
|
|
787
793
|
if (this.address) {
|
|
788
794
|
return this.address;
|
|
789
795
|
}
|
|
790
|
-
if (!this.
|
|
796
|
+
if (!this.APICredentials.apiKey && !this.APICredentials.apiSecret && !this.walletDetail?.WalletID) {
|
|
791
797
|
throw new Error('Wallet detail not found, use setWallet(walletId) to set wallet first!');
|
|
792
798
|
}
|
|
793
799
|
const detail = await this.APIService.getWalletDetail(WalletAddressType.Sol, this.walletDetail?.WalletID);
|
|
@@ -930,6 +936,7 @@ class SolanaSigner {
|
|
|
930
936
|
}
|
|
931
937
|
}
|
|
932
938
|
constructor(credentials, environment, pollerOptions){
|
|
939
|
+
this.APICredentials = credentials;
|
|
933
940
|
this.APIKey = credentials.apiKey;
|
|
934
941
|
this.APIService = new APIService(credentials, environment);
|
|
935
942
|
this.pollerOptions = pollerOptions;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ declare enum TxApprovalStatus {
|
|
|
23
23
|
interface APICredentials {
|
|
24
24
|
apiKey: string;
|
|
25
25
|
apiSecret: string;
|
|
26
|
+
authToken?: string;
|
|
26
27
|
}
|
|
27
28
|
interface WebhookEvent {
|
|
28
29
|
webhook_id: string;
|
|
@@ -255,6 +256,7 @@ declare class SolanaSigner {
|
|
|
255
256
|
private APIKey;
|
|
256
257
|
private walletDetail;
|
|
257
258
|
private pollerOptions?;
|
|
259
|
+
private APICredentials;
|
|
258
260
|
constructor(credentials: APICredentials, environment: Environment, pollerOptions?: StatusPollerOptions);
|
|
259
261
|
setWallet(walletId: string): void;
|
|
260
262
|
getAddress(): Promise<string>;
|
package/package.json
CHANGED
package/src/api.ts
CHANGED
|
@@ -67,7 +67,13 @@ async function composeAPIHeaders(
|
|
|
67
67
|
body: Record<string, any> = {}
|
|
68
68
|
): Promise<Record<string, string>> {
|
|
69
69
|
if (credentials.apiSecret == '') {
|
|
70
|
-
// If APISecret is not provided,
|
|
70
|
+
// If APISecret is not provided, use authToken
|
|
71
|
+
if (credentials.authToken) {
|
|
72
|
+
return {
|
|
73
|
+
Authorization: credentials.authToken
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
// fallback to cookie mode with no headers
|
|
71
77
|
return {}
|
|
72
78
|
}
|
|
73
79
|
|
package/src/signer.ts
CHANGED
|
@@ -64,7 +64,11 @@ export class EtherSigner extends AbstractSigner {
|
|
|
64
64
|
return this.address
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
if (
|
|
67
|
+
if (
|
|
68
|
+
!this.APICredentials.apiKey &&
|
|
69
|
+
!this.APICredentials.authToken &&
|
|
70
|
+
!this.walletDetail.WalletID
|
|
71
|
+
) {
|
|
68
72
|
throw new Error('Wallet detail not found, use setWallet(walletId) to set wallet first!')
|
|
69
73
|
}
|
|
70
74
|
|
package/src/solanaSigner.ts
CHANGED
|
@@ -12,12 +12,14 @@ export class SolanaSigner {
|
|
|
12
12
|
private APIKey: string
|
|
13
13
|
private walletDetail: WalletDetail
|
|
14
14
|
private pollerOptions?: StatusPollerOptions
|
|
15
|
+
private APICredentials!: APICredentials
|
|
15
16
|
|
|
16
17
|
constructor(
|
|
17
18
|
credentials: APICredentials,
|
|
18
19
|
environment: Environment,
|
|
19
20
|
pollerOptions?: StatusPollerOptions
|
|
20
21
|
) {
|
|
22
|
+
this.APICredentials = credentials
|
|
21
23
|
this.APIKey = credentials.apiKey
|
|
22
24
|
this.APIService = new APIService(credentials, environment)
|
|
23
25
|
this.pollerOptions = pollerOptions
|
|
@@ -45,7 +47,11 @@ export class SolanaSigner {
|
|
|
45
47
|
return this.address
|
|
46
48
|
}
|
|
47
49
|
|
|
48
|
-
if (
|
|
50
|
+
if (
|
|
51
|
+
!this.APICredentials.apiKey &&
|
|
52
|
+
!this.APICredentials.apiSecret &&
|
|
53
|
+
!this.walletDetail?.WalletID
|
|
54
|
+
) {
|
|
49
55
|
throw new Error('Wallet detail not found, use setWallet(walletId) to set wallet first!')
|
|
50
56
|
}
|
|
51
57
|
|