@stellar/typescript-wallet-sdk 1.5.0 → 1.6.0-beta.1719867067726
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/CHANGELOG.MD +11 -1
- package/lib/bundle.js +7354 -3358
- package/lib/bundle.js.map +1 -1
- package/lib/bundle_browser.js +1117 -11
- package/lib/bundle_browser.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/walletSdk/Exceptions/index.d.ts +15 -0
- package/lib/walletSdk/Types/anchor.d.ts +5 -1
- package/lib/walletSdk/Types/index.d.ts +1 -0
- package/lib/walletSdk/Types/sep7.d.ts +15 -0
- package/lib/walletSdk/Uri/Sep7Base.d.ts +187 -0
- package/lib/walletSdk/Uri/Sep7Pay.d.ts +121 -0
- package/lib/walletSdk/Uri/Sep7Tx.d.ts +133 -0
- package/lib/walletSdk/Uri/index.d.ts +4 -0
- package/lib/walletSdk/Uri/sep7Parser.d.ts +60 -0
- package/lib/walletSdk/Utils/index.d.ts +2 -1
- package/package.json +3 -3
- package/src/index.ts +9 -0
- package/src/walletSdk/Auth/WalletSigner.ts +3 -3
- package/src/walletSdk/Customer/index.ts +7 -7
- package/src/walletSdk/Exceptions/index.ts +38 -1
- package/src/walletSdk/Horizon/Account.ts +2 -1
- package/src/walletSdk/Types/anchor.ts +4 -0
- package/src/walletSdk/Types/index.ts +1 -0
- package/src/walletSdk/Types/sep7.ts +19 -0
- package/src/walletSdk/Uri/Sep7Base.ts +311 -0
- package/src/walletSdk/Uri/Sep7Pay.ts +169 -0
- package/src/walletSdk/Uri/Sep7Tx.ts +193 -0
- package/src/walletSdk/Uri/index.ts +9 -0
- package/src/walletSdk/Uri/sep7Parser.ts +220 -0
- package/src/walletSdk/Utils/index.ts +2 -1
- package/src/walletSdk/Watcher/index.ts +3 -1
- package/test/customer.test.ts +7 -7
- package/test/integration/anchorplatform.test.ts +2 -2
- package/test/sep7.test.ts +825 -0
package/lib/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export { Sep10, WalletSigner, DefaultSigner } from "./walletSdk/Auth";
|
|
|
14
14
|
export { AuthHeaderSigner, DefaultAuthHeaderSigner, DomainAuthHeaderSigner, } from "./walletSdk/Auth/AuthHeaderSigner";
|
|
15
15
|
export { AccountKeypair, PublicKeypair, SigningKeypair, AccountService, Stellar, CommonTransactionBuilder, TransactionBuilder, SponsoringBuilder, } from "./walletSdk/Horizon";
|
|
16
16
|
export { Recovery } from "./walletSdk/Recovery";
|
|
17
|
+
export { Sep7Base, Sep7Pay, Sep7Tx, isValidSep7Uri, parseSep7Uri, sep7ReplacementsFromString, sep7ReplacementsToString, } from "./walletSdk/Uri";
|
|
17
18
|
export { Watcher } from "./walletSdk/Watcher";
|
|
18
19
|
/**
|
|
19
20
|
* Utils
|
|
@@ -115,9 +115,24 @@ export declare class UnknownAnchorTransactionError extends Error {
|
|
|
115
115
|
export declare class InvalidJsonError extends Error {
|
|
116
116
|
constructor();
|
|
117
117
|
}
|
|
118
|
+
export declare class SigningKeypairMissingSecretError extends Error {
|
|
119
|
+
constructor();
|
|
120
|
+
}
|
|
121
|
+
export declare class DefaultSignerDomainAccountError extends Error {
|
|
122
|
+
constructor();
|
|
123
|
+
}
|
|
118
124
|
export declare class AuthHeaderSigningKeypairRequiredError extends Error {
|
|
119
125
|
constructor();
|
|
120
126
|
}
|
|
121
127
|
export declare class AuthHeaderClientDomainRequiredError extends Error {
|
|
122
128
|
constructor();
|
|
123
129
|
}
|
|
130
|
+
export declare class Sep7InvalidUriError extends Error {
|
|
131
|
+
constructor(reason: string);
|
|
132
|
+
}
|
|
133
|
+
export declare class Sep7LongMsgError extends Error {
|
|
134
|
+
constructor(msgMaxLength: number);
|
|
135
|
+
}
|
|
136
|
+
export declare class Sep7UriTypeNotSupportedError extends Error {
|
|
137
|
+
constructor(type: string);
|
|
138
|
+
}
|
|
@@ -159,5 +159,9 @@ export declare enum TransactionStatus {
|
|
|
159
159
|
/** Deposit/withdrawal size exceeded max_amount. */
|
|
160
160
|
too_large = "too_large",
|
|
161
161
|
/** Catch-all for any error not enumerated above. */
|
|
162
|
-
error = "error"
|
|
162
|
+
error = "error",
|
|
163
|
+
/** deposit/withdrawal is currently on hold for additional checks after receiving user's funds.
|
|
164
|
+
* Anchor may use this status to indicate to the user that transaction is being reviewed (for example,
|
|
165
|
+
* for compliance reasons). Once this status cleared, transaction should follow the regular flow */
|
|
166
|
+
on_hold = "on_hold"
|
|
163
167
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const WEB_STELLAR_SCHEME = "web+stellar:";
|
|
2
|
+
export declare enum Sep7OperationType {
|
|
3
|
+
tx = "tx",
|
|
4
|
+
pay = "pay"
|
|
5
|
+
}
|
|
6
|
+
export declare const URI_MSG_MAX_LENGTH = 300;
|
|
7
|
+
export type Sep7Replacement = {
|
|
8
|
+
id: string;
|
|
9
|
+
path: string;
|
|
10
|
+
hint: string;
|
|
11
|
+
};
|
|
12
|
+
export type IsValidSep7UriResult = {
|
|
13
|
+
result: boolean;
|
|
14
|
+
reason?: string;
|
|
15
|
+
};
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { Keypair, Networks } from "@stellar/stellar-sdk";
|
|
2
|
+
import { Sep7OperationType } from "../Types";
|
|
3
|
+
/**
|
|
4
|
+
* A base abstract class containing common functions that should be used by both
|
|
5
|
+
* Sep7Tx and Sep7Pay classes for parsing or constructing SEP-0007 Stellar URIs.
|
|
6
|
+
*
|
|
7
|
+
* @see https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0007.md#specification
|
|
8
|
+
*/
|
|
9
|
+
export declare abstract class Sep7Base {
|
|
10
|
+
protected uri: URL;
|
|
11
|
+
/**
|
|
12
|
+
* Creates a new instance of the Sep7 class.
|
|
13
|
+
*
|
|
14
|
+
* @constructor
|
|
15
|
+
* @param {URL | string} uri - uri to initialize the Sep7 instance.
|
|
16
|
+
*/
|
|
17
|
+
constructor(uri: URL | string);
|
|
18
|
+
/**
|
|
19
|
+
* Should return a deep clone of this instance.
|
|
20
|
+
*
|
|
21
|
+
* @returns {Sep7Base} a deep clone of the Sep7Base extended instance.
|
|
22
|
+
*/
|
|
23
|
+
abstract clone(): Sep7Base;
|
|
24
|
+
/**
|
|
25
|
+
* Returns a stringfied URL-decoded version of the 'uri' object.
|
|
26
|
+
*
|
|
27
|
+
* @returns {string} the uri decoded string value.
|
|
28
|
+
*/
|
|
29
|
+
toString(): string;
|
|
30
|
+
/**
|
|
31
|
+
* Returns uri's pathname as the operation type.
|
|
32
|
+
*
|
|
33
|
+
* @returns {Sep7OperationType} the operation type, either "tx" or "pay".
|
|
34
|
+
*/
|
|
35
|
+
get operationType(): Sep7OperationType;
|
|
36
|
+
/**
|
|
37
|
+
* Returns a URL-decoded version of the uri 'callback' param without
|
|
38
|
+
* the 'url:' prefix.
|
|
39
|
+
*
|
|
40
|
+
* The URI handler should send the signed XDR to this callback url, if this
|
|
41
|
+
* value is omitted then the URI handler should submit it to the network.
|
|
42
|
+
*
|
|
43
|
+
* @returns {string | undefined} URL-decoded 'callback' param if present.
|
|
44
|
+
*/
|
|
45
|
+
get callback(): string | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Sets and URL-encodes the uri 'callback' param, appends the 'url:'
|
|
48
|
+
* prefix to it if not yet present.
|
|
49
|
+
*
|
|
50
|
+
* Deletes the uri 'callback' param if set as 'undefined'.
|
|
51
|
+
*
|
|
52
|
+
* The URI handler should send the signed XDR to this callback url, if this
|
|
53
|
+
* value is omitted then the URI handler should submit it to the network.
|
|
54
|
+
*
|
|
55
|
+
* @param {string | undefined} callback the uri 'callback' param to be set.
|
|
56
|
+
*/
|
|
57
|
+
set callback(callback: string | undefined);
|
|
58
|
+
/**
|
|
59
|
+
* Returns a URL-decoded version of the uri 'msg' param.
|
|
60
|
+
*
|
|
61
|
+
* This message should indicate any additional information that the website
|
|
62
|
+
* or application wants to show the user in her wallet.
|
|
63
|
+
*
|
|
64
|
+
* @returns {string | undefined} URL-decoded 'msg' param if present.
|
|
65
|
+
*/
|
|
66
|
+
get msg(): string | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* Sets and URL-encodes the uri 'msg' param, the 'msg' param can't
|
|
69
|
+
* be larger than 300 characters.
|
|
70
|
+
*
|
|
71
|
+
* Deletes the uri 'msg' param if set as 'undefined'.
|
|
72
|
+
*
|
|
73
|
+
* This message should indicate any additional information that the website
|
|
74
|
+
* or application wants to show the user in her wallet.
|
|
75
|
+
*
|
|
76
|
+
* @param {string | undefined} msg the uri 'msg' param to be set.
|
|
77
|
+
* @throws {Sep7LongMsgError} if 'msg' length is bigger than 300.
|
|
78
|
+
*/
|
|
79
|
+
set msg(msg: string | undefined);
|
|
80
|
+
/**
|
|
81
|
+
* Returns uri 'network_passphrase' param, if not present returns
|
|
82
|
+
* the PUBLIC Network value by default: 'Public Global Stellar Network ; September 2015'.
|
|
83
|
+
*
|
|
84
|
+
* @returns {Networks} the Stellar network passphrase considered for this uri.
|
|
85
|
+
*/
|
|
86
|
+
get networkPassphrase(): Networks;
|
|
87
|
+
/**
|
|
88
|
+
* Sets the uri 'network_passphrase' param.
|
|
89
|
+
*
|
|
90
|
+
* Deletes the uri 'network_passphrase' param if set as 'undefined'.
|
|
91
|
+
*
|
|
92
|
+
* Only need to set it if this transaction is for a network other than
|
|
93
|
+
* the public network.
|
|
94
|
+
*
|
|
95
|
+
* @param {Networks | undefined} networkPassphrase the uri 'network_passphrase'
|
|
96
|
+
* param to be set.
|
|
97
|
+
*/
|
|
98
|
+
set networkPassphrase(networkPassphrase: Networks | undefined);
|
|
99
|
+
/**
|
|
100
|
+
* Returns a URL-decoded version of the uri 'origin_domain' param.
|
|
101
|
+
*
|
|
102
|
+
* This should be a fully qualified domain name that specifies the originating
|
|
103
|
+
* domain of the URI request.
|
|
104
|
+
*
|
|
105
|
+
* @returns {string | undefined} URL-decoded 'origin_domain' param if present.
|
|
106
|
+
*/
|
|
107
|
+
get originDomain(): string | undefined;
|
|
108
|
+
/**
|
|
109
|
+
* Sets and URL-encodes the uri 'origin_domain' param.
|
|
110
|
+
*
|
|
111
|
+
* Deletes the uri 'origin_domain' param if set as 'undefined'.
|
|
112
|
+
*
|
|
113
|
+
* This should be a fully qualified domain name that specifies the originating
|
|
114
|
+
* domain of the URI request.
|
|
115
|
+
*
|
|
116
|
+
* @param {string | undefined} originDomain the uri 'origin_domain' param
|
|
117
|
+
* to be set.
|
|
118
|
+
*/
|
|
119
|
+
set originDomain(originDomain: string | undefined);
|
|
120
|
+
/**
|
|
121
|
+
* Returns a URL-decoded version of the uri 'signature' param.
|
|
122
|
+
*
|
|
123
|
+
* This should be a signature of the hash of the URI request (excluding the
|
|
124
|
+
* 'signature' field and value itself).
|
|
125
|
+
*
|
|
126
|
+
* Wallets should use the URI_REQUEST_SIGNING_KEY specified in the
|
|
127
|
+
* origin_domain's stellar.toml file to validate this signature.
|
|
128
|
+
* If the verification fails, wallets must alert the user.
|
|
129
|
+
*
|
|
130
|
+
* @returns {string | undefined} URL-decoded 'signature' param if present.
|
|
131
|
+
*/
|
|
132
|
+
get signature(): string | undefined;
|
|
133
|
+
/**
|
|
134
|
+
* Signs the URI with the given keypair, which means it sets the 'signature' param.
|
|
135
|
+
*
|
|
136
|
+
* This should be the last step done before generating the URI string,
|
|
137
|
+
* otherwise the signature will be invalid for the URI.
|
|
138
|
+
*
|
|
139
|
+
* @see https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0007.md#request-signing
|
|
140
|
+
*
|
|
141
|
+
* @param {Keypair} keypair The keypair (including secret key), used to sign the request.
|
|
142
|
+
* This should be the keypair found in the URI_REQUEST_SIGNING_KEY field of the
|
|
143
|
+
* origin_domains' stellar.toml.
|
|
144
|
+
*
|
|
145
|
+
* @returns {string} the generated 'signature' param.
|
|
146
|
+
*/
|
|
147
|
+
addSignature(keypair: Keypair): string;
|
|
148
|
+
/**
|
|
149
|
+
* Verifies that the signature added to the URI is valid.
|
|
150
|
+
*
|
|
151
|
+
* @see https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0007.md#request-signing
|
|
152
|
+
*
|
|
153
|
+
* @returns {Promise<boolean>} returns 'true' if the signature is valid for
|
|
154
|
+
* the current URI and origin_domain. Returns 'false' if signature verification
|
|
155
|
+
* fails, or if there is a problem looking up the stellar.toml associated with
|
|
156
|
+
* the origin_domain.
|
|
157
|
+
*/
|
|
158
|
+
verifySignature(): Promise<boolean>;
|
|
159
|
+
/**
|
|
160
|
+
* Finds the uri param related to the inputted 'key', if any, and returns
|
|
161
|
+
* a URL-decoded version of it. Returns 'undefined' if key param not found.
|
|
162
|
+
*
|
|
163
|
+
* @param {string} key the uri param key.
|
|
164
|
+
*
|
|
165
|
+
* @returns {string | undefined} URL-decoded value of the uri param if found.
|
|
166
|
+
*/
|
|
167
|
+
protected getParam(key: string): string | undefined;
|
|
168
|
+
/**
|
|
169
|
+
* Sets and URL-encodes a 'key=value' uri param.
|
|
170
|
+
*
|
|
171
|
+
* Deletes the uri param if 'value' set as 'undefined'.
|
|
172
|
+
*
|
|
173
|
+
* @param {string} key the uri param key.
|
|
174
|
+
* @param {string | undefined} value the uri param value to be set.
|
|
175
|
+
*/
|
|
176
|
+
protected setParam(key: string, value: string | undefined): void;
|
|
177
|
+
/**
|
|
178
|
+
* Converts the URI request into the payload that will be signed by
|
|
179
|
+
* the 'addSignature' method.
|
|
180
|
+
*
|
|
181
|
+
* @see https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0007.md#request-signing
|
|
182
|
+
*
|
|
183
|
+
* @returns {Buffer} array of bytes to be signed with given keypair on
|
|
184
|
+
* the 'addSignature' method.
|
|
185
|
+
*/
|
|
186
|
+
private createSignaturePayload;
|
|
187
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { MemoType } from "@stellar/stellar-sdk";
|
|
2
|
+
import { Sep7Base } from "../Uri";
|
|
3
|
+
/**
|
|
4
|
+
* The Sep-7 'pay' operation represents a request to pay a specific address
|
|
5
|
+
* with a specific asset, regardless of the source asset used by the payer.
|
|
6
|
+
*
|
|
7
|
+
* @see https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0007.md#operation-pay
|
|
8
|
+
*/
|
|
9
|
+
export declare class Sep7Pay extends Sep7Base {
|
|
10
|
+
/**
|
|
11
|
+
* Creates a Sep7Pay instance with given destination.
|
|
12
|
+
*
|
|
13
|
+
* @param {string} destination a valid Stellar address to receive the payment.
|
|
14
|
+
*
|
|
15
|
+
* @returns {Sep7Pay} the Sep7Pay instance.
|
|
16
|
+
*/
|
|
17
|
+
static forDestination(destination: string): Sep7Pay;
|
|
18
|
+
/**
|
|
19
|
+
* Creates a new instance of the Sep7Pay class.
|
|
20
|
+
*
|
|
21
|
+
* @constructor
|
|
22
|
+
* @param {URL | string} [uri] - uri to initialize the Sep7 instance.
|
|
23
|
+
*/
|
|
24
|
+
constructor(uri?: URL | string);
|
|
25
|
+
/**
|
|
26
|
+
* Returns a deep clone of this instance.
|
|
27
|
+
*
|
|
28
|
+
* @returns {Sep7Pay} a deep clone of this Sep7Pay instance.
|
|
29
|
+
*/
|
|
30
|
+
clone(): Sep7Pay;
|
|
31
|
+
/**
|
|
32
|
+
* Gets the destination of the payment request, which should be a valid
|
|
33
|
+
* Stellar address.
|
|
34
|
+
*
|
|
35
|
+
* @returns {string | undefined} the 'destination' uri param if present.
|
|
36
|
+
*/
|
|
37
|
+
get destination(): string | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Sets the destination of the payment request, which should be a valid
|
|
40
|
+
* Stellar address.
|
|
41
|
+
*
|
|
42
|
+
* Deletes the uri 'destination' param if set as 'undefined'.
|
|
43
|
+
*
|
|
44
|
+
* @param {string | undefined} destination the uri 'destination' param to be set.
|
|
45
|
+
*/
|
|
46
|
+
set destination(destination: string | undefined);
|
|
47
|
+
/**
|
|
48
|
+
* Gets the amount that destination should receive.
|
|
49
|
+
*
|
|
50
|
+
* @returns {string | undefined} the 'amount' uri param if present.
|
|
51
|
+
*/
|
|
52
|
+
get amount(): string | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Sets the amount that destination should receive.
|
|
55
|
+
*
|
|
56
|
+
* Deletes the uri 'amount' param if set as 'undefined'.
|
|
57
|
+
*
|
|
58
|
+
* @param {string | undefined} amount the uri 'amount' param to be set.
|
|
59
|
+
*/
|
|
60
|
+
set amount(amount: string | undefined);
|
|
61
|
+
/**
|
|
62
|
+
* Gets the code from the asset that destination should receive.
|
|
63
|
+
*
|
|
64
|
+
* @returns {string | undefined} the 'asset_code' uri param if present.
|
|
65
|
+
*/
|
|
66
|
+
get assetCode(): string | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* Sets the code from the asset that destination should receive.
|
|
69
|
+
*
|
|
70
|
+
* Deletes the uri 'asset_code' param if set as 'undefined'.
|
|
71
|
+
*
|
|
72
|
+
* @param {string | undefined} assetCode the uri 'asset_code' param to be set.
|
|
73
|
+
*/
|
|
74
|
+
set assetCode(assetCode: string | undefined);
|
|
75
|
+
/**
|
|
76
|
+
* Gets the account ID of asset issuer the destination should receive.
|
|
77
|
+
*
|
|
78
|
+
* @returns {string | undefined} the 'asset_issuer' uri param if present.
|
|
79
|
+
*/
|
|
80
|
+
get assetIssuer(): string | undefined;
|
|
81
|
+
/**
|
|
82
|
+
* Sets the account ID of asset issuer the destination should receive.
|
|
83
|
+
*
|
|
84
|
+
* Deletes the uri 'asset_issuer' param if set as 'undefined'.
|
|
85
|
+
*
|
|
86
|
+
* @param {string | undefined} assetIssuer the uri 'asset_issuer' param to be set.
|
|
87
|
+
*/
|
|
88
|
+
set assetIssuer(assetIssuer: string | undefined);
|
|
89
|
+
/**
|
|
90
|
+
* Gets the memo to be included in the payment / path payment.
|
|
91
|
+
* Memos of type MEMO_HASH and MEMO_RETURN should be base64-decoded
|
|
92
|
+
* after returned from this function.
|
|
93
|
+
*
|
|
94
|
+
* @returns {string | undefined} the 'memo' uri param if present.
|
|
95
|
+
*/
|
|
96
|
+
get memo(): string | undefined;
|
|
97
|
+
/**
|
|
98
|
+
* Sets the memo to be included in the payment / path payment.
|
|
99
|
+
* Memos of type MEMO_HASH and MEMO_RETURN should be base64-encoded
|
|
100
|
+
* prior to being passed on this function.
|
|
101
|
+
*
|
|
102
|
+
* Deletes the uri 'memo' param if set as 'undefined'.
|
|
103
|
+
*
|
|
104
|
+
* @param {string | undefined} memo the uri 'memo' param to be set.
|
|
105
|
+
*/
|
|
106
|
+
set memo(memo: string | undefined);
|
|
107
|
+
/**
|
|
108
|
+
* Gets the type of the memo.
|
|
109
|
+
*
|
|
110
|
+
* @returns {MemoType | undefined} the 'memo_type' uri param if present.
|
|
111
|
+
*/
|
|
112
|
+
get memoType(): MemoType | undefined;
|
|
113
|
+
/**
|
|
114
|
+
* Sets the type of the memo.
|
|
115
|
+
*
|
|
116
|
+
* Deletes the uri 'memo_type' param if set as 'undefined'.
|
|
117
|
+
*
|
|
118
|
+
* @param {MemoType | undefined} memoType the uri 'memo_type' param to be set.
|
|
119
|
+
*/
|
|
120
|
+
set memoType(memoType: MemoType | undefined);
|
|
121
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { Transaction } from "@stellar/stellar-sdk";
|
|
2
|
+
import { Sep7Base } from "../Uri";
|
|
3
|
+
import { Sep7Replacement } from "../Types";
|
|
4
|
+
/**
|
|
5
|
+
* The Sep-7 'tx' operation represents a request to sign
|
|
6
|
+
* a specific XDR TransactionEnvelope.
|
|
7
|
+
*
|
|
8
|
+
* @see https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0007.md#operation-tx
|
|
9
|
+
*/
|
|
10
|
+
export declare class Sep7Tx extends Sep7Base {
|
|
11
|
+
/**
|
|
12
|
+
* Creates a Sep7Tx instance with given transaction.
|
|
13
|
+
*
|
|
14
|
+
* Sets the 'xdr' param as a Stellar TransactionEnvelope in XDR format that
|
|
15
|
+
* is base64 encoded and then URL-encoded.
|
|
16
|
+
*
|
|
17
|
+
* @param {Transaction} transaction a transaction which will be used to set the
|
|
18
|
+
* URI 'xdr' and 'network_passphrase' query params.
|
|
19
|
+
*
|
|
20
|
+
* @returns {Sep7Tx} the Sep7Tx instance.
|
|
21
|
+
*/
|
|
22
|
+
static forTransaction(transaction: Transaction): Sep7Tx;
|
|
23
|
+
/**
|
|
24
|
+
* Creates a new instance of the Sep7Tx class.
|
|
25
|
+
*
|
|
26
|
+
* @constructor
|
|
27
|
+
* @param {URL | string} [uri] - uri to initialize the Sep7 instance.
|
|
28
|
+
*/
|
|
29
|
+
constructor(uri?: URL | string);
|
|
30
|
+
/**
|
|
31
|
+
* Returns a deep clone of this instance.
|
|
32
|
+
*
|
|
33
|
+
* @returns {Sep7Tx} a deep clone of this Sep7Tx instance.
|
|
34
|
+
*/
|
|
35
|
+
clone(): Sep7Tx;
|
|
36
|
+
/**
|
|
37
|
+
* Returns a URL-decoded version of the uri 'xdr' param.
|
|
38
|
+
*
|
|
39
|
+
* @returns {string | undefined} URL-decoded 'xdr' param if present.
|
|
40
|
+
*/
|
|
41
|
+
get xdr(): string | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Sets and URL-encodes the uri 'xdr' param.
|
|
44
|
+
*
|
|
45
|
+
* Deletes the uri 'xdr' param if set as 'undefined'.
|
|
46
|
+
*
|
|
47
|
+
* @param {string | undefined} xdr the uri 'xdr' param to be set.
|
|
48
|
+
*/
|
|
49
|
+
set xdr(xdr: string | undefined);
|
|
50
|
+
/**
|
|
51
|
+
* Returns the uri 'pubkey' param.
|
|
52
|
+
*
|
|
53
|
+
* This param specifies which public key the URI handler should sign for.
|
|
54
|
+
*
|
|
55
|
+
* @returns {string | undefined} URL-decoded 'pubkey' param if present.
|
|
56
|
+
*/
|
|
57
|
+
get pubkey(): string | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* Sets the uri 'pubkey' param.
|
|
60
|
+
*
|
|
61
|
+
* Deletes the uri 'pubkey' param if set as 'undefined'.
|
|
62
|
+
*
|
|
63
|
+
* This param should specify which public key you want the URI handler
|
|
64
|
+
* to sign for.
|
|
65
|
+
*
|
|
66
|
+
* @param {string | undefined} pubkey the uri 'pubkey' param to be set.
|
|
67
|
+
*/
|
|
68
|
+
set pubkey(pubkey: string | undefined);
|
|
69
|
+
/**
|
|
70
|
+
* Returns a URL-decoded version of the uri 'chain' param.
|
|
71
|
+
*
|
|
72
|
+
* There can be an optional chain query param to include a single SEP-0007
|
|
73
|
+
* request that spawned or triggered the creation of this SEP-0007 request.
|
|
74
|
+
* This will be a URL-encoded value. The goal of this field is to be
|
|
75
|
+
* informational only and can be used to forward SEP-0007 requests.
|
|
76
|
+
*
|
|
77
|
+
* @returns {string | undefined} URL-decoded 'chain' param if present.
|
|
78
|
+
*/
|
|
79
|
+
get chain(): string | undefined;
|
|
80
|
+
/**
|
|
81
|
+
* Sets and URL-encodes the uri 'chain' param.
|
|
82
|
+
*
|
|
83
|
+
* Deletes the uri 'chain' param if set as 'undefined'.
|
|
84
|
+
*
|
|
85
|
+
* There can be an optional chain query param to include a single SEP-0007
|
|
86
|
+
* request that spawned or triggered the creation of this SEP-0007 request.
|
|
87
|
+
* This will be a URL-encoded value. The goal of this field is to be
|
|
88
|
+
* informational only and can be used to forward SEP-0007 requests.
|
|
89
|
+
*
|
|
90
|
+
* @param {string | undefined} chain the 'chain' param to be set.
|
|
91
|
+
*/
|
|
92
|
+
set chain(chain: string | undefined);
|
|
93
|
+
/**
|
|
94
|
+
* Gets a list of fields in the transaction that need to be replaced.
|
|
95
|
+
*
|
|
96
|
+
* @returns {Sep7Replacement[]} list of fields that need to be replaced.
|
|
97
|
+
*/
|
|
98
|
+
getReplacements(): Sep7Replacement[];
|
|
99
|
+
/**
|
|
100
|
+
* Sets and URL-encodes the uri 'replace' param, which is a list of fields in
|
|
101
|
+
* the transaction that needs to be replaced.
|
|
102
|
+
*
|
|
103
|
+
* Deletes the uri 'replace' param if set as empty array '[]' or 'undefined'.
|
|
104
|
+
*
|
|
105
|
+
* This 'replace' param should be a URL-encoded value that identifies the
|
|
106
|
+
* fields to be replaced in the XDR using the 'Txrep (SEP-0011)' representation.
|
|
107
|
+
* This will be specified in the format of:
|
|
108
|
+
* txrep_tx_field_name_1:reference_identifier_1,txrep_tx_field_name_2:reference_identifier_2;reference_identifier_1:hint_1,reference_identifier_2:hint_2
|
|
109
|
+
*
|
|
110
|
+
* @see https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0011.md
|
|
111
|
+
*
|
|
112
|
+
* @param {Sep7Replacement[]} replacements a list of replacements to set.
|
|
113
|
+
*/
|
|
114
|
+
setReplacements(replacements: Sep7Replacement[] | undefined): void;
|
|
115
|
+
/**
|
|
116
|
+
* Adds an additional replacement.
|
|
117
|
+
*
|
|
118
|
+
* @param {Sep7Replacement} replacement the replacement to add.
|
|
119
|
+
*/
|
|
120
|
+
addReplacement(replacement: Sep7Replacement): void;
|
|
121
|
+
/**
|
|
122
|
+
* Removes all replacements with the given identifier.
|
|
123
|
+
*
|
|
124
|
+
* @param {string} id the identifier to remove.
|
|
125
|
+
*/
|
|
126
|
+
removeReplacement(id: string): void;
|
|
127
|
+
/**
|
|
128
|
+
* Creates a Stellar Transaction from the URI's XDR and networkPassphrase.
|
|
129
|
+
*
|
|
130
|
+
* @returns {Transaction} the Stellar Transaction.
|
|
131
|
+
*/
|
|
132
|
+
getTransaction(): Transaction;
|
|
133
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Sep7Pay, Sep7Tx } from "../Uri";
|
|
2
|
+
import { Sep7Replacement, IsValidSep7UriResult } from "../Types";
|
|
3
|
+
/**
|
|
4
|
+
* Returns true if the given URI is a SEP-7 compliant URI, false otherwise.
|
|
5
|
+
*
|
|
6
|
+
* Currently this checks whether it starts with 'web+stellar:tx' or 'web+stellar:pay'
|
|
7
|
+
* and has its required parameters: 'xdr=' and 'destination=' respectively.
|
|
8
|
+
*
|
|
9
|
+
* @param {string} uri The URI string to check.
|
|
10
|
+
*
|
|
11
|
+
* @returns {IsValidSep7UriResult} returns '{ result: true }' if it's a valid Sep-7
|
|
12
|
+
* uri, returns '{ result: false, reason: "<reason>" }' containing a 'reason' message
|
|
13
|
+
* in case the verification fails.
|
|
14
|
+
*/
|
|
15
|
+
export declare const isValidSep7Uri: (uri: string) => IsValidSep7UriResult;
|
|
16
|
+
/**
|
|
17
|
+
* Try parsing a SEP-7 URI string and returns a Sep7Tx or Sep7Pay instance,
|
|
18
|
+
* depending on the type.
|
|
19
|
+
*
|
|
20
|
+
* @param {string} uri The URI string to parse.
|
|
21
|
+
*
|
|
22
|
+
* @returns {Sep7Tx | Sep7Pay} a uri parsed Sep7Tx or Sep7Pay instance.
|
|
23
|
+
*
|
|
24
|
+
* @throws {Sep7InvalidUriError} if the inputted uri is not a valid SEP-7 URI.
|
|
25
|
+
* @throws {Sep7UriTypeNotSupportedError} if the inputted uri does not have a
|
|
26
|
+
* supported SEP-7 type.
|
|
27
|
+
*/
|
|
28
|
+
export declare const parseSep7Uri: (uri: string) => Sep7Tx | Sep7Pay;
|
|
29
|
+
/**
|
|
30
|
+
* Takes a Sep-7 URL-decoded 'replace' string param and parses it to a list of
|
|
31
|
+
* Sep7Replacement objects for easy of use.
|
|
32
|
+
*
|
|
33
|
+
* This string identifies the fields to be replaced in the XDR using
|
|
34
|
+
* the 'Txrep (SEP-0011)' representation, which should be specified in the format of:
|
|
35
|
+
* txrep_tx_field_name_1:reference_identifier_1,txrep_tx_field_name_2:reference_identifier_2;reference_identifier_1:hint_1,reference_identifier_2:hint_2
|
|
36
|
+
*
|
|
37
|
+
* @see https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0011.md
|
|
38
|
+
*
|
|
39
|
+
* @param {string} [replacements] a replacements string in the
|
|
40
|
+
* 'Txrep (SEP-0011)' representation.
|
|
41
|
+
*
|
|
42
|
+
* @returns {Sep7Replacement[]} a list of parsed Sep7Replacement objects.
|
|
43
|
+
*/
|
|
44
|
+
export declare const sep7ReplacementsFromString: (replacements?: string) => Sep7Replacement[];
|
|
45
|
+
/**
|
|
46
|
+
* Takes a list of Sep7Replacement objects and parses it to a string that
|
|
47
|
+
* could be URL-encoded and used as a Sep-7 URI 'replace' param.
|
|
48
|
+
*
|
|
49
|
+
* This string identifies the fields to be replaced in the XDR using
|
|
50
|
+
* the 'Txrep (SEP-0011)' representation, which should be specified in the format of:
|
|
51
|
+
* txrep_tx_field_name_1:reference_identifier_1,txrep_tx_field_name_2:reference_identifier_2;reference_identifier_1:hint_1,reference_identifier_2:hint_2
|
|
52
|
+
*
|
|
53
|
+
* @see https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0011.md
|
|
54
|
+
*
|
|
55
|
+
* @param {Sep7Replacement[]} [replacements] a list of Sep7Replacement objects.
|
|
56
|
+
*
|
|
57
|
+
* @returns {string} a string that identifies the fields to be replaced in the
|
|
58
|
+
* XDR using the 'Txrep (SEP-0011)' representation.
|
|
59
|
+
*/
|
|
60
|
+
export declare const sep7ReplacementsToString: (replacements?: Sep7Replacement[]) => string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stellar/typescript-wallet-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0-beta.1719867067726",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">=18"
|
|
6
6
|
},
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"webpack-cli": "^5.1.1"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@stellar/stellar-sdk": "
|
|
47
|
+
"@stellar/stellar-sdk": "12.1.0",
|
|
48
48
|
"axios": "^1.4.0",
|
|
49
49
|
"base64url": "^3.0.1",
|
|
50
50
|
"https-browserify": "^1.0.0",
|
|
@@ -70,4 +70,4 @@
|
|
|
70
70
|
"build": "run-p build:web build:node",
|
|
71
71
|
"example:sep24": "ts-node examples/sep24/sep24.ts"
|
|
72
72
|
}
|
|
73
|
-
}
|
|
73
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -33,6 +33,15 @@ export {
|
|
|
33
33
|
SponsoringBuilder,
|
|
34
34
|
} from "./walletSdk/Horizon";
|
|
35
35
|
export { Recovery } from "./walletSdk/Recovery";
|
|
36
|
+
export {
|
|
37
|
+
Sep7Base,
|
|
38
|
+
Sep7Pay,
|
|
39
|
+
Sep7Tx,
|
|
40
|
+
isValidSep7Uri,
|
|
41
|
+
parseSep7Uri,
|
|
42
|
+
sep7ReplacementsFromString,
|
|
43
|
+
sep7ReplacementsToString,
|
|
44
|
+
} from "./walletSdk/Uri";
|
|
36
45
|
export { Watcher } from "./walletSdk/Watcher";
|
|
37
46
|
|
|
38
47
|
/**
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
HttpHeaders,
|
|
11
11
|
} from "../Types";
|
|
12
12
|
import { DefaultClient } from "../";
|
|
13
|
+
import { DefaultSignerDomainAccountError } from "../Exceptions";
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* A Wallet Signer for signing Stellar transactions.
|
|
@@ -51,9 +52,8 @@ export const DefaultSigner: WalletSigner = {
|
|
|
51
52
|
},
|
|
52
53
|
// eslint-disable-next-line @typescript-eslint/require-await
|
|
53
54
|
signWithDomainAccount: async () => {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
);
|
|
55
|
+
// The DefaultSigner can't sign transactions with domain account
|
|
56
|
+
throw new DefaultSignerDomainAccountError();
|
|
57
57
|
},
|
|
58
58
|
};
|
|
59
59
|
|