Skip to content

Commit

Permalink
Moving/Renaming Sep10 stuff around a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaptic committed Oct 13, 2023
1 parent 1ab6696 commit 4947082
Show file tree
Hide file tree
Showing 11 changed files with 749 additions and 748 deletions.
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ This version is marked by a major version bump because of the significant upgrad

### Add

- Add [SEP-1](https://stellar.org/protocol/sep-1) fields to `StellarTomlResolver` for type checks ([#794](https://github.com/stellar/js-stellar-sdk/pull/794)).
- Add [SEP-1](https://stellar.org/protocol/sep-1) fields to `TomlResolver` for type checks ([#794](https://github.com/stellar/js-stellar-sdk/pull/794)).
- Add support for passing `X-Auth-Token` as a custom header ([#795](https://github.com/stellar/js-stellar-sdk/pull/795)).

### Update
Expand Down Expand Up @@ -1142,7 +1142,7 @@ Many thanks to @Ffloriel and @Akuukis for their help with this release!
## 0.8.2
- Added `timeout` option to `StellarTomlResolver` and `FederationServer` calls
- Added `timeout` option to `TomlResolver` and `FederationServer` calls
(https://github.com/stellar/js-stellar-sdk/issues/158).
- Fixed adding random value to URLs multiple times
(https://github.com/stellar/js-stellar-sdk/issues/169).
Expand Down Expand Up @@ -1210,7 +1210,7 @@ Many thanks to @Ffloriel and @Akuukis for their help with this release!
- **Breaking change** Upgraded `stellar-base` to `0.6.0`. `ed25519` package is
now an optional dependency. Check `StellarSdk.FastSigning` variable to check
if `ed25519` package is available. More in README file.
- New `StellarTomlResolver` class that allows getting `stellar.toml` file for a
- New `TomlResolver` class that allows getting `stellar.toml` file for a
domain.
- New `Config` class to set global config values.
Expand Down
4 changes: 2 additions & 2 deletions src/federation/federation_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import URI from "urijs";

import { Config } from "../config";
import { BadResponseError } from "../errors";
import { StellarTomlResolver } from "./stellar_toml_resolver";
import { TomlResolver } from "./stellar_toml_resolver";

// FEDERATION_RESPONSE_MAX_SIZE is the maximum size of response from a federation server
export const FEDERATION_RESPONSE_MAX_SIZE = 100 * 1024;
Expand Down Expand Up @@ -129,7 +129,7 @@ export class FederationServer {
domain: string,
opts: FederationServer.Options = {},
): Promise<FederationServer> {
const tomlObject = await StellarTomlResolver.resolve(domain, opts);
const tomlObject = await TomlResolver.resolve(domain, opts);
if (!tomlObject.FEDERATION_SERVER) {
return Promise.reject(
new Error("stellar.toml does not contain FEDERATION_SERVER field"),
Expand Down
2 changes: 1 addition & 1 deletion src/federation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ export {
} from './federation_server';

export {
StellarTomlResolver,
TomlResolver,
STELLAR_TOML_MAX_SIZE
} from './stellar_toml_resolver';
16 changes: 7 additions & 9 deletions src/federation/stellar_toml_resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,19 @@ import { Networks } from "stellar-base";

import { Config } from "../config";

// STELLAR_TOML_MAX_SIZE is the maximum size of stellar.toml file
/** the maximum size of stellar.toml file */
export const STELLAR_TOML_MAX_SIZE = 100 * 1024;

// axios timeout doesn't catch missing urls, e.g. those with no response
// so we use the axios cancel token to ensure the timeout
const CancelToken = axios.CancelToken;

/**
* StellarTomlResolver allows resolving `stellar.toml` files.
*/
export class StellarTomlResolver {
/** TomlResolver allows resolving `stellar.toml` files. */
export class TomlResolver {
/**
* Returns a parsed `stellar.toml` file for a given domain.
* ```js
* StellarSdk.StellarTomlResolver.resolve('acme.com')
* StellarSdk.TomlResolver.resolve('acme.com')
* .then(stellarToml => {
* // stellarToml in an object representing domain stellar.toml file.
* })
Expand All @@ -35,8 +33,8 @@ export class StellarTomlResolver {
*/
public static async resolve(
domain: string,
opts: StellarTomlResolver.StellarTomlResolveOptions = {},
): Promise<StellarTomlResolver.StellarToml> {
opts: TomlResolver.StellarTomlResolveOptions = {},
): Promise<TomlResolver.StellarToml> {
const allowHttp =
typeof opts.allowHttp === "undefined"
? Config.isAllowHttp()
Expand Down Expand Up @@ -85,7 +83,7 @@ export class StellarTomlResolver {
}

/* tslint:disable-next-line: no-namespace */
export namespace StellarTomlResolver {
export namespace TomlResolver {
export interface StellarTomlResolveOptions {
allowHttp?: boolean;
timeout?: number;
Expand Down
6 changes: 5 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Expose all types
export * from './errors';
export { Config } from './config';
export { Sep10, Utils } from './utils';
export { Utils } from './utils';

// TOML and federation resolvers to expose
export * as Federation from './federation';
Expand All @@ -14,6 +14,10 @@ export * as Horizon from './horizon';

// Soroban RPC-related classes to expose
export * as SorobanRpc from './soroban';
export { ContractSpec } from './soroban'; // not RPC related, so at top-level

// SEP-10 related helpers to expose
export * as Sep10 from './sep10';

// expose classes and functions from stellar-base
export * from 'stellar-base';
Expand Down
Loading

0 comments on commit 4947082

Please sign in to comment.