@stellar/typescript-wallet-sdk 1.4.1 → 1.6.0-beta.1719865729038
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 +98 -0
- package/examples/sep24/sep24.ts +4 -9
- package/jest.e2e.config.js +9 -0
- package/lib/bundle.js +47445 -43024
- package/lib/bundle.js.map +1 -1
- package/lib/bundle_browser.js +45409 -41445
- package/lib/bundle_browser.js.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/walletSdk/Anchor/index.d.ts +1 -1
- package/lib/walletSdk/Auth/AuthHeaderSigner.d.ts +61 -0
- package/lib/walletSdk/Auth/index.d.ts +2 -2
- package/lib/walletSdk/Exceptions/index.d.ts +21 -0
- package/lib/walletSdk/Horizon/AccountService.d.ts +1 -1
- package/lib/walletSdk/Horizon/Stellar.d.ts +1 -1
- package/lib/walletSdk/Horizon/Transaction/TransactionBuilder.d.ts +1 -1
- package/lib/walletSdk/Recovery/AccountRecover.d.ts +1 -1
- package/lib/walletSdk/Recovery/index.d.ts +2 -2
- package/lib/walletSdk/Types/anchor.d.ts +5 -1
- package/lib/walletSdk/Types/auth.d.ts +17 -0
- package/lib/walletSdk/Types/horizon.d.ts +1 -1
- package/lib/walletSdk/Types/index.d.ts +2 -1
- package/lib/walletSdk/Types/recovery.d.ts +2 -2
- 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 +8 -3
- package/src/index.ts +14 -0
- package/src/walletSdk/Anchor/index.ts +1 -1
- package/src/walletSdk/Auth/AuthHeaderSigner.ts +162 -0
- package/src/walletSdk/Auth/WalletSigner.ts +3 -3
- package/src/walletSdk/Auth/index.ts +48 -2
- package/src/walletSdk/Customer/index.ts +7 -7
- package/src/walletSdk/Exceptions/index.ts +56 -0
- package/src/walletSdk/Horizon/Account.ts +2 -1
- package/src/walletSdk/Horizon/AccountService.ts +1 -1
- package/src/walletSdk/Horizon/Stellar.ts +1 -1
- package/src/walletSdk/Horizon/Transaction/TransactionBuilder.ts +1 -1
- package/src/walletSdk/Recovery/AccountRecover.ts +1 -1
- package/src/walletSdk/Recovery/index.ts +2 -2
- package/src/walletSdk/Types/anchor.ts +4 -0
- package/src/walletSdk/Types/auth.ts +19 -0
- package/src/walletSdk/Types/horizon.ts +1 -1
- package/src/walletSdk/Types/index.ts +2 -1
- package/src/walletSdk/Types/recovery.ts +2 -2
- 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/e2e/README.md +11 -0
- package/test/e2e/browser.test.ts +52 -0
- package/test/integration/README.md +38 -0
- package/test/integration/anchorplatform.test.ts +11 -2
- package/test/sep7.test.ts +825 -0
- package/test/server.test.ts +13 -0
- package/test/wallet.test.ts +85 -0
- package/webpack.config.js +4 -0
- package/test/README.md +0 -18
package/lib/index.d.ts
CHANGED
|
@@ -11,8 +11,10 @@ export { Anchor } from "./walletSdk/Anchor";
|
|
|
11
11
|
export { Sep24 } from "./walletSdk/Anchor/Sep24";
|
|
12
12
|
export { IssuedAssetId, NativeAssetId, FiatAssetId } from "./walletSdk/Asset";
|
|
13
13
|
export { Sep10, WalletSigner, DefaultSigner } from "./walletSdk/Auth";
|
|
14
|
+
export { AuthHeaderSigner, DefaultAuthHeaderSigner, DomainAuthHeaderSigner, } from "./walletSdk/Auth/AuthHeaderSigner";
|
|
14
15
|
export { AccountKeypair, PublicKeypair, SigningKeypair, AccountService, Stellar, CommonTransactionBuilder, TransactionBuilder, SponsoringBuilder, } from "./walletSdk/Horizon";
|
|
15
16
|
export { Recovery } from "./walletSdk/Recovery";
|
|
17
|
+
export { Sep7Base, Sep7Pay, Sep7Tx, isValidSep7Uri, parseSep7Uri, sep7ReplacementsFromString, sep7ReplacementsToString, } from "./walletSdk/Uri";
|
|
16
18
|
export { Watcher } from "./walletSdk/Watcher";
|
|
17
19
|
/**
|
|
18
20
|
* Utils
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { AxiosInstance } from "axios";
|
|
2
|
+
import { AuthHeaderClaims, AuthHeaderCreateTokenParams } from "../Types";
|
|
3
|
+
export interface AuthHeaderSigner {
|
|
4
|
+
createToken({ claims, clientDomain, issuer, }: AuthHeaderCreateTokenParams): Promise<string>;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Signer for signing JWT for GET /Auth with a custodial private key
|
|
8
|
+
*
|
|
9
|
+
* @class
|
|
10
|
+
*/
|
|
11
|
+
export declare class DefaultAuthHeaderSigner implements AuthHeaderSigner {
|
|
12
|
+
expiration: number;
|
|
13
|
+
constructor(expiration?: number);
|
|
14
|
+
/**
|
|
15
|
+
* Create a signed JWT for the auth header
|
|
16
|
+
* @constructor
|
|
17
|
+
* @param {AuthHeaderCreateTokenParams} params - The create token parameters
|
|
18
|
+
* @param {AuthHeaderClaims} params.claims - the data to be signed in the JWT
|
|
19
|
+
* @param {string} [params.clientDomain] - the client domain hosting SEP-1 toml
|
|
20
|
+
* @param {AccountKeypair} [params.issuer] - the account signing the JWT
|
|
21
|
+
* @returns {Promise<string>} The signed JWT
|
|
22
|
+
*/
|
|
23
|
+
createToken({ claims, clientDomain, issuer, }: AuthHeaderCreateTokenParams): Promise<string>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Signer for signing JWT for GET /Auth using a remote server to sign.
|
|
27
|
+
*
|
|
28
|
+
* @class
|
|
29
|
+
*/
|
|
30
|
+
export declare class DomainAuthHeaderSigner implements AuthHeaderSigner {
|
|
31
|
+
signerUrl: string;
|
|
32
|
+
expiration: number;
|
|
33
|
+
httpClient: AxiosInstance;
|
|
34
|
+
constructor(signerUrl: string, expiration?: number, httpClient?: AxiosInstance);
|
|
35
|
+
/**
|
|
36
|
+
* Create a signed JWT for the auth header by using a remote server to sign the JWT
|
|
37
|
+
* @constructor
|
|
38
|
+
* @param {AuthHeaderCreateTokenParams} params - The create token parameters
|
|
39
|
+
* @param {AuthHeaderClaims} params.claims - the data to be signed in the JWT
|
|
40
|
+
* @param {string} [params.clientDomain] - the client domain hosting SEP-1 toml
|
|
41
|
+
* @param {AccountKeypair} [params.issuer] - unused, will not be used to sign
|
|
42
|
+
* @returns {Promise<string>} The signed JWT
|
|
43
|
+
*/
|
|
44
|
+
createToken({ claims, clientDomain, issuer, }: AuthHeaderCreateTokenParams): Promise<string>;
|
|
45
|
+
/**
|
|
46
|
+
* Sign JWT by calling a remote server
|
|
47
|
+
* @constructor
|
|
48
|
+
* @param {SignTokenRemoteParams} params - the sign token params
|
|
49
|
+
* @param {AuthHeaderClaims} params.claims - the data to be signed in the JWT
|
|
50
|
+
* @param {string} params.clientDomain - the client domain hosting SEP-1 toml
|
|
51
|
+
* @param {number} params.expiration - when the token should expire
|
|
52
|
+
* @param {number} params.issuedAt - when the token was created
|
|
53
|
+
* @returns {Promise<string>} The signed JWT
|
|
54
|
+
*/
|
|
55
|
+
signTokenRemote({ claims, clientDomain, expiration, issuedAt, }: {
|
|
56
|
+
claims: AuthHeaderClaims;
|
|
57
|
+
clientDomain: string;
|
|
58
|
+
expiration: number;
|
|
59
|
+
issuedAt: number;
|
|
60
|
+
}): Promise<string>;
|
|
61
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AxiosInstance } from "axios";
|
|
2
|
-
import { Config } from "
|
|
2
|
+
import { Config } from "../";
|
|
3
3
|
import { AuthenticateParams, AuthToken } from "../Types";
|
|
4
4
|
export { WalletSigner, DefaultSigner } from "./WalletSigner";
|
|
5
5
|
type Sep10Params = {
|
|
@@ -35,7 +35,7 @@ export declare class Sep10 {
|
|
|
35
35
|
* @param {string} [params.clientDomain] - Domain hosting stellar.toml file containing `SIGNING_KEY`.
|
|
36
36
|
* @returns {Promise<AuthToken>} The authentication token.
|
|
37
37
|
*/
|
|
38
|
-
authenticate({ accountKp, walletSigner, memoId, clientDomain, }: AuthenticateParams): Promise<AuthToken>;
|
|
38
|
+
authenticate({ accountKp, walletSigner, memoId, clientDomain, authHeaderSigner, }: AuthenticateParams): Promise<AuthToken>;
|
|
39
39
|
private challenge;
|
|
40
40
|
private sign;
|
|
41
41
|
private getToken;
|
|
@@ -115,3 +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
|
+
}
|
|
124
|
+
export declare class AuthHeaderSigningKeypairRequiredError extends Error {
|
|
125
|
+
constructor();
|
|
126
|
+
}
|
|
127
|
+
export declare class AuthHeaderClientDomainRequiredError extends Error {
|
|
128
|
+
constructor();
|
|
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
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Horizon, Transaction, FeeBumpTransaction } from "@stellar/stellar-sdk";
|
|
2
|
-
import { Config } from "
|
|
2
|
+
import { Config } from "../";
|
|
3
3
|
import { AccountService } from "./AccountService";
|
|
4
4
|
import { TransactionBuilder } from "./Transaction/TransactionBuilder";
|
|
5
5
|
import { TransactionParams, SubmitWithFeeIncreaseParams, FeeBumpTransactionParams } from "../Types";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Account as StellarAccount, Transaction, Horizon, Memo, xdr } from "@stellar/stellar-sdk";
|
|
2
|
-
import { Config } from "
|
|
2
|
+
import { Config } from "../../";
|
|
3
3
|
import { AccountKeypair } from "../Account";
|
|
4
4
|
import { StellarAssetId } from "../../Asset";
|
|
5
5
|
import { WithdrawTransaction, PathPayParams } from "../../Types";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AxiosInstance } from "axios";
|
|
2
2
|
import { Transaction } from "@stellar/stellar-sdk";
|
|
3
|
-
import { RecoveryServer, RecoveryServerKey, RecoveryServerMap, RecoveryServerSigningMap } from "
|
|
3
|
+
import { RecoveryServer, RecoveryServerKey, RecoveryServerMap, RecoveryServerSigningMap } from "../Types";
|
|
4
4
|
import { AccountKeypair, Stellar } from "../Horizon";
|
|
5
5
|
/**
|
|
6
6
|
* Used for Account Recovery using Sep-30.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AxiosInstance } from "axios";
|
|
2
2
|
import { Transaction } from "@stellar/stellar-sdk";
|
|
3
|
-
import { Config } from "
|
|
4
|
-
import { AccountSigner, AccountThreshold, CommonBuilder, RecoverableWallet, RecoverableWalletConfig, RecoveryAccountInfoMap, RecoveryAuthMap, RecoveryServerKey, RecoveryServerMap } from "
|
|
3
|
+
import { Config } from "../";
|
|
4
|
+
import { AccountSigner, AccountThreshold, CommonBuilder, RecoverableWallet, RecoverableWalletConfig, RecoveryAccountInfoMap, RecoveryAuthMap, RecoveryServerKey, RecoveryServerMap } from "../Types";
|
|
5
5
|
import { AccountRecover } from "./AccountRecover";
|
|
6
6
|
import { Sep10 } from "../Auth";
|
|
7
7
|
import { AccountKeypair, Stellar } from "../Horizon";
|
|
@@ -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
|
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { Transaction } from "@stellar/stellar-sdk";
|
|
2
2
|
import { WalletSigner } from "../Auth/WalletSigner";
|
|
3
3
|
import { AccountKeypair, SigningKeypair } from "../Horizon/Account";
|
|
4
|
+
import { AuthHeaderSigner } from "../Auth/AuthHeaderSigner";
|
|
4
5
|
export type AuthenticateParams = {
|
|
5
6
|
accountKp: AccountKeypair;
|
|
6
7
|
walletSigner?: WalletSigner;
|
|
7
8
|
memoId?: string;
|
|
8
9
|
clientDomain?: string;
|
|
10
|
+
authHeaderSigner?: AuthHeaderSigner;
|
|
9
11
|
};
|
|
10
12
|
export declare class AuthToken {
|
|
11
13
|
token: string;
|
|
@@ -22,6 +24,7 @@ export type ChallengeParams = {
|
|
|
22
24
|
accountKp: AccountKeypair;
|
|
23
25
|
memoId?: string;
|
|
24
26
|
clientDomain?: string;
|
|
27
|
+
authHeaderSigner?: AuthHeaderSigner;
|
|
25
28
|
};
|
|
26
29
|
export type XdrEncodedTransaction = string;
|
|
27
30
|
export type NetworkPassphrase = string;
|
|
@@ -56,3 +59,17 @@ export type SignChallengeTxnResponse = {
|
|
|
56
59
|
transaction: XdrEncodedTransaction;
|
|
57
60
|
networkPassphrase: NetworkPassphrase;
|
|
58
61
|
};
|
|
62
|
+
export type AuthHeaderClaims = {
|
|
63
|
+
account: string;
|
|
64
|
+
home_domain: string;
|
|
65
|
+
web_auth_endpoint: string;
|
|
66
|
+
memo?: string;
|
|
67
|
+
client_domain?: string;
|
|
68
|
+
exp?: number;
|
|
69
|
+
iat?: number;
|
|
70
|
+
};
|
|
71
|
+
export type AuthHeaderCreateTokenParams = {
|
|
72
|
+
claims: AuthHeaderClaims;
|
|
73
|
+
clientDomain?: string;
|
|
74
|
+
issuer?: AccountKeypair;
|
|
75
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Memo, Horizon, Transaction } from "@stellar/stellar-sdk";
|
|
2
2
|
import { AccountKeypair } from "../Horizon/Account";
|
|
3
|
-
import { SponsoringBuilder, TransactionBuilder } from "
|
|
3
|
+
import { SponsoringBuilder, TransactionBuilder } from "../Horizon";
|
|
4
4
|
import { StellarAssetId } from "../Asset";
|
|
5
5
|
export declare enum NETWORK_URLS {
|
|
6
6
|
PUBLIC = "https://horizon.stellar.org",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RawAxiosRequestHeaders } from "axios";
|
|
2
2
|
import { Networks } from "@stellar/stellar-sdk";
|
|
3
|
-
import { ApplicationConfiguration, StellarConfiguration } from "
|
|
3
|
+
import { ApplicationConfiguration, StellarConfiguration } from "../";
|
|
4
4
|
import { RecoveryServerMap } from "./recovery";
|
|
5
5
|
export type WalletParams = {
|
|
6
6
|
stellarConfiguration: StellarConfiguration;
|
|
@@ -36,6 +36,7 @@ export * from "./auth";
|
|
|
36
36
|
export * from "./horizon";
|
|
37
37
|
export * from "./recovery";
|
|
38
38
|
export * from "./sep6";
|
|
39
|
+
export * from "./sep7";
|
|
39
40
|
export * from "./sep12";
|
|
40
41
|
export * from "./sep24";
|
|
41
42
|
export * from "./sep38";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Transaction } from "@stellar/stellar-sdk";
|
|
2
|
-
import { WalletSigner } from "
|
|
3
|
-
import { AccountKeypair, PublicKeypair } from "
|
|
2
|
+
import { WalletSigner } from "../Auth";
|
|
3
|
+
import { AccountKeypair, PublicKeypair } from "../Horizon";
|
|
4
4
|
import { AuthToken } from "./auth";
|
|
5
5
|
import { CommonBuilder } from "./horizon";
|
|
6
6
|
/**
|
|
@@ -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
|
+
}
|