@sogni-ai/sogni-client 0.0.7 → 0.0.8

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 (89) hide show
  1. package/package.json +1 -1
  2. package/dist/Account/CurrentAccount.d.ts +0 -26
  3. package/dist/Account/CurrentAccount.js +0 -71
  4. package/dist/Account/CurrentAccount.js.map +0 -1
  5. package/dist/Account/index.d.ts +0 -27
  6. package/dist/Account/index.js +0 -159
  7. package/dist/Account/index.js.map +0 -1
  8. package/dist/Account/types.d.ts +0 -57
  9. package/dist/Account/types.js +0 -2
  10. package/dist/Account/types.js.map +0 -1
  11. package/dist/ApiClient/ApiClient.d.ts +0 -42
  12. package/dist/ApiClient/ApiClient.js +0 -72
  13. package/dist/ApiClient/ApiClient.js.map +0 -1
  14. package/dist/ApiClient/WebSocketClient/ErrorCode.d.ts +0 -7
  15. package/dist/ApiClient/WebSocketClient/ErrorCode.js +0 -14
  16. package/dist/ApiClient/WebSocketClient/ErrorCode.js.map +0 -1
  17. package/dist/ApiClient/WebSocketClient/events.d.ts +0 -83
  18. package/dist/ApiClient/WebSocketClient/events.js +0 -2
  19. package/dist/ApiClient/WebSocketClient/events.js.map +0 -1
  20. package/dist/ApiClient/WebSocketClient/index.d.ts +0 -28
  21. package/dist/ApiClient/WebSocketClient/index.js +0 -161
  22. package/dist/ApiClient/WebSocketClient/index.js.map +0 -1
  23. package/dist/ApiClient/WebSocketClient/messages.d.ts +0 -5
  24. package/dist/ApiClient/WebSocketClient/messages.js +0 -2
  25. package/dist/ApiClient/WebSocketClient/messages.js.map +0 -1
  26. package/dist/ApiClient/WebSocketClient/types.d.ts +0 -1
  27. package/dist/ApiClient/WebSocketClient/types.js +0 -2
  28. package/dist/ApiClient/WebSocketClient/types.js.map +0 -1
  29. package/dist/ApiClient/events.d.ts +0 -19
  30. package/dist/ApiClient/events.js +0 -2
  31. package/dist/ApiClient/events.js.map +0 -1
  32. package/dist/ApiGroup.d.ts +0 -16
  33. package/dist/ApiGroup.js +0 -11
  34. package/dist/ApiGroup.js.map +0 -1
  35. package/dist/Projects/Job.d.ts +0 -31
  36. package/dist/Projects/Job.js +0 -47
  37. package/dist/Projects/Job.js.map +0 -1
  38. package/dist/Projects/Project.d.ts +0 -50
  39. package/dist/Projects/Project.js +0 -89
  40. package/dist/Projects/Project.js.map +0 -1
  41. package/dist/Projects/createJobRequestMessage.d.ts +0 -63
  42. package/dist/Projects/createJobRequestMessage.js +0 -66
  43. package/dist/Projects/createJobRequestMessage.js.map +0 -1
  44. package/dist/Projects/index.d.ts +0 -41
  45. package/dist/Projects/index.js +0 -248
  46. package/dist/Projects/index.js.map +0 -1
  47. package/dist/Projects/models.json +0 -8906
  48. package/dist/Projects/types/EstimationResponse.d.ts +0 -40
  49. package/dist/Projects/types/EstimationResponse.js +0 -2
  50. package/dist/Projects/types/EstimationResponse.js.map +0 -1
  51. package/dist/Projects/types/events.d.ts +0 -51
  52. package/dist/Projects/types/events.js +0 -2
  53. package/dist/Projects/types/events.js.map +0 -1
  54. package/dist/Projects/types/index.d.ts +0 -58
  55. package/dist/Projects/types/index.js +0 -2
  56. package/dist/Projects/types/index.js.map +0 -1
  57. package/dist/Stats/index.d.ts +0 -6
  58. package/dist/Stats/index.js +0 -20
  59. package/dist/Stats/index.js.map +0 -1
  60. package/dist/Stats/types.d.ts +0 -19
  61. package/dist/Stats/types.js +0 -2
  62. package/dist/Stats/types.js.map +0 -1
  63. package/dist/index.d.ts +0 -39
  64. package/dist/index.js +0 -51
  65. package/dist/index.js.map +0 -1
  66. package/dist/lib/DataEntity.d.ts +0 -18
  67. package/dist/lib/DataEntity.js +0 -26
  68. package/dist/lib/DataEntity.js.map +0 -1
  69. package/dist/lib/EIP712Helper.d.ts +0 -13
  70. package/dist/lib/EIP712Helper.js +0 -37
  71. package/dist/lib/EIP712Helper.js.map +0 -1
  72. package/dist/lib/RestClient.d.ts +0 -18
  73. package/dist/lib/RestClient.js +0 -64
  74. package/dist/lib/RestClient.js.map +0 -1
  75. package/dist/lib/TypedEventEmitter.d.ts +0 -34
  76. package/dist/lib/TypedEventEmitter.js +0 -56
  77. package/dist/lib/TypedEventEmitter.js.map +0 -1
  78. package/dist/lib/base64.d.ts +0 -2
  79. package/dist/lib/base64.js +0 -8
  80. package/dist/lib/base64.js.map +0 -1
  81. package/dist/lib/isNodejs.d.ts +0 -2
  82. package/dist/lib/isNodejs.js +0 -3
  83. package/dist/lib/isNodejs.js.map +0 -1
  84. package/dist/types/ErrorData.d.ts +0 -5
  85. package/dist/types/ErrorData.js +0 -2
  86. package/dist/types/ErrorData.js.map +0 -1
  87. package/dist/types/json.d.ts +0 -5
  88. package/dist/types/json.js +0 -2
  89. package/dist/types/json.js.map +0 -1
@@ -1,40 +0,0 @@
1
- export interface EstimationResponse {
2
- request: Request;
3
- rate: Rate;
4
- quote: Quote;
5
- }
6
- export interface Quote {
7
- model: Model;
8
- job: Job;
9
- project: Job;
10
- }
11
- export interface Job {
12
- costInRenderSec: string;
13
- costInUSD: string;
14
- costInToken: string;
15
- calculatedStepCount?: number;
16
- }
17
- export interface Model {
18
- weight: string;
19
- secPerStep: string;
20
- secPerPreview: string;
21
- secForCN: string;
22
- }
23
- export interface Rate {
24
- costPerBaseHQRenderInUSD: string;
25
- tokenMarkePriceUSD: string;
26
- costPerRenderSecUSD: string;
27
- costPerRenderSecToken: string;
28
- network: string;
29
- networkCostMultiplier: string;
30
- }
31
- export interface Request {
32
- model: string;
33
- name: string;
34
- imageCount: number;
35
- stepCount: number;
36
- previewCount: number;
37
- cnEnabled: boolean;
38
- denoiseStrength: string;
39
- time: Date;
40
- }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=EstimationResponse.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EstimationResponse.js","sourceRoot":"","sources":["../../../src/Projects/types/EstimationResponse.ts"],"names":[],"mappings":""}
@@ -1,51 +0,0 @@
1
- import { AvailableModel } from './index';
2
- import ErrorData from '../../types/ErrorData';
3
- export interface ProjectEventBase {
4
- projectId: string;
5
- }
6
- export interface ProjectQueued extends ProjectEventBase {
7
- type: 'queued';
8
- queuePosition: number;
9
- }
10
- export interface ProjectCompleted extends ProjectEventBase {
11
- type: 'completed';
12
- }
13
- export interface ProjectError extends ProjectEventBase {
14
- type: 'error';
15
- error: ErrorData;
16
- }
17
- export type ProjectEvent = ProjectQueued | ProjectCompleted | ProjectError;
18
- export interface JobEventBase {
19
- projectId: string;
20
- jobId: string;
21
- }
22
- export interface JobInitiating extends JobEventBase {
23
- type: 'initiating';
24
- }
25
- export interface JobStarted extends JobEventBase {
26
- type: 'started';
27
- }
28
- export interface JobProgress extends JobEventBase {
29
- type: 'progress';
30
- step: number;
31
- stepCount: number;
32
- }
33
- export interface JobPreview extends JobEventBase {
34
- type: 'preview';
35
- url: string;
36
- }
37
- export interface JobCompleted extends JobEventBase {
38
- type: 'completed';
39
- steps: number;
40
- resultUrl: string;
41
- }
42
- export interface JobError extends JobEventBase {
43
- type: 'error';
44
- error: ErrorData;
45
- }
46
- export type JobEvent = JobInitiating | JobStarted | JobProgress | JobPreview | JobCompleted | JobError;
47
- export interface ProjectApiEvents {
48
- availableModels: AvailableModel[];
49
- project: ProjectEvent;
50
- job: JobEvent;
51
- }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=events.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"events.js","sourceRoot":"","sources":["../../../src/Projects/types/events.ts"],"names":[],"mappings":""}
@@ -1,58 +0,0 @@
1
- import { SupernetType } from '../../ApiClient/WebSocketClient/types';
2
- export interface AvailableModel {
3
- id: string;
4
- name: string;
5
- workerCount: number;
6
- }
7
- export interface AiModel {
8
- isSD3: boolean;
9
- modelShortName: string;
10
- isIOSslowest: boolean;
11
- hasOriginalVersionOnly: boolean;
12
- isUserModel: boolean;
13
- isTurboXL: boolean;
14
- isRealistic: boolean;
15
- isArtistic: boolean;
16
- tier: string;
17
- splitAttentionSuffix: string;
18
- isSD3XL: boolean;
19
- originalAttentionSuffix: string;
20
- isLCM: boolean;
21
- zipWeight: number;
22
- modelId: string;
23
- modelVersion: string;
24
- parentId: string;
25
- quantized: boolean;
26
- isXL: boolean;
27
- splitAttentionV2Suffix: string;
28
- supportsAttentionV2: boolean;
29
- supportsControlNet: boolean;
30
- supportsEncoder: boolean;
31
- onlySplitEinsumV2available: boolean;
32
- customSize?: number[];
33
- }
34
- export interface ProjectParams {
35
- modelId: string;
36
- positivePrompt: string;
37
- negativePrompt: string;
38
- stylePrompt: string;
39
- steps: number;
40
- guidance: number;
41
- seed: string;
42
- numberOfImages: number;
43
- }
44
- export type ImageUrlParams = {
45
- imageId: string;
46
- jobId: string;
47
- type: 'preview' | 'complete' | 'startingImage' | 'cnImage';
48
- startContentType?: string;
49
- };
50
- export interface EstimateRequest {
51
- network: SupernetType;
52
- model: string;
53
- imageCount: number;
54
- stepCount: number;
55
- previewCount: number;
56
- cnEnabled?: boolean;
57
- denoiseStrength?: number;
58
- }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Projects/types/index.ts"],"names":[],"mappings":""}
@@ -1,6 +0,0 @@
1
- import ApiGroup from '../ApiGroup';
2
- import { LeaderboardItem, LeaderboardParams } from './types';
3
- declare class StatsApi extends ApiGroup {
4
- leaderboard(params: LeaderboardParams): Promise<LeaderboardItem[]>;
5
- }
6
- export default StatsApi;
@@ -1,20 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import ApiGroup from '../ApiGroup';
11
- class StatsApi extends ApiGroup {
12
- leaderboard(params) {
13
- return __awaiter(this, void 0, void 0, function* () {
14
- const res = yield this.client.rest.get('/v1/leaderboard/', params);
15
- return res.data;
16
- });
17
- }
18
- }
19
- export default StatsApi;
20
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Stats/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,QAAQ,MAAM,aAAa,CAAC;AAInC,MAAM,QAAS,SAAQ,QAAQ;IACvB,WAAW,CAAC,MAAyB;;YACzC,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CACpC,kBAAkB,EAClB,MAAM,CACP,CAAC;YACF,OAAO,GAAG,CAAC,IAAI,CAAC;QAClB,CAAC;KAAA;CACF;AAED,eAAe,QAAQ,CAAC"}
@@ -1,19 +0,0 @@
1
- export type LeaderboardType = 'renderUSDCompleteWorker' | 'renderUSDCompleteArtist' | 'renderSecCompleteWorker' | 'renderSecCompleteArtist' | 'renderTokenCompleteWorker' | 'renderTokenCompleteArtist' | 'jobCompleteWorker' | 'jobCompleteArtist' | 'projectCompleteArtist' | 'uloginWorker' | 'uloginArtist' | 'tokenVolume' | 'referral';
2
- export interface LeaderboardParams {
3
- type: LeaderboardType;
4
- period: 'day' | 'lifetime';
5
- username?: string;
6
- network?: 'fast' | 'relaxed' | 'all';
7
- page?: number;
8
- limit?: number;
9
- date?: number;
10
- address?: string;
11
- }
12
- export interface LeaderboardItem {
13
- rank: number;
14
- username: string;
15
- address: string;
16
- country: string;
17
- value: string;
18
- role: string;
19
- }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/Stats/types.ts"],"names":[],"mappings":""}
package/dist/index.d.ts DELETED
@@ -1,39 +0,0 @@
1
- import AccountApi from './Account';
2
- import { ApiError } from './ApiClient/ApiClient';
3
- import ProjectsApi from './Projects';
4
- import StatsApi from './Stats';
5
- import { AvailableModel } from './Projects/types';
6
- import CurrentAccount from './Account/CurrentAccount';
7
- import DataEntity from './lib/DataEntity';
8
- import Project, { ProjectStatus } from './Projects/Project';
9
- import Job, { JobStatus } from './Projects/Job';
10
- import { SupernetType } from './ApiClient/WebSocketClient/types';
11
- import ErrorData from './types/ErrorData';
12
- import * as ProjectApiEvents from './Projects/types/events';
13
- export type { AvailableModel, CurrentAccount, DataEntity, ErrorData, Job, JobStatus, ProjectApiEvents, ProjectStatus, Project, SupernetType };
14
- export { ApiError };
15
- export interface BaseConfig {
16
- appId: string;
17
- restEndpoint: string;
18
- socketEndpoint: string;
19
- }
20
- export interface SimpleConfig extends BaseConfig {
21
- testnet: boolean;
22
- }
23
- export interface FullConfig extends BaseConfig {
24
- jsonRpcUrl: string;
25
- }
26
- export type SogniClientConfig = SimpleConfig | FullConfig;
27
- export declare class SogniClient {
28
- account: AccountApi;
29
- projects: ProjectsApi;
30
- stats: StatsApi;
31
- private constructor();
32
- get currentAccount(): CurrentAccount;
33
- /**
34
- * Instance creation may involve async operations, so we use a static method
35
- * @param config
36
- */
37
- static createInstance(config: SogniClientConfig): Promise<SogniClient>;
38
- }
39
- export default SogniClient;
package/dist/index.js DELETED
@@ -1,51 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { JsonRpcProvider, getDefaultProvider } from 'ethers';
11
- import AccountApi from './Account';
12
- import ApiClient, { ApiError } from './ApiClient/ApiClient';
13
- import EIP712Helper from './lib/EIP712Helper';
14
- import ProjectsApi from './Projects';
15
- import StatsApi from './Stats';
16
- export { ApiError };
17
- export class SogniClient {
18
- constructor(config) {
19
- this.account = new AccountApi(config);
20
- this.projects = new ProjectsApi(config);
21
- this.stats = new StatsApi(config);
22
- }
23
- get currentAccount() {
24
- return this.account.currentAccount;
25
- }
26
- /**
27
- * Instance creation may involve async operations, so we use a static method
28
- * @param config
29
- */
30
- static createInstance(config) {
31
- return __awaiter(this, void 0, void 0, function* () {
32
- const client = new ApiClient(config.restEndpoint, config.socketEndpoint, config.appId);
33
- let provider;
34
- if ('jsonRpcUrl' in config) {
35
- provider = new JsonRpcProvider(config.jsonRpcUrl);
36
- }
37
- else {
38
- provider = getDefaultProvider(config.testnet ? 84532 : 8453);
39
- }
40
- const chainId = yield provider.getNetwork().then((network) => network.chainId);
41
- const eip712 = new EIP712Helper({
42
- name: 'Sogni-testnet',
43
- version: '1',
44
- chainId: chainId.toString()
45
- });
46
- return new SogniClient({ client, provider, eip712 });
47
- });
48
- }
49
- }
50
- export default SogniClient;
51
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAoB,eAAe,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAC/E,OAAO,UAAU,MAAM,WAAW,CAAC;AACnC,OAAO,SAAS,EAAE,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAC9C,OAAO,WAAW,MAAM,YAAY,CAAC;AACrC,OAAO,QAAQ,MAAM,SAAS,CAAC;AAuB/B,OAAO,EAAE,QAAQ,EAAE,CAAC;AAkBpB,MAAM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TypedEventEmitter from './TypedEventEmitter';
2
- export interface EntityEvents {
3
- updated: string[];
4
- }
5
- declare abstract class DataEntity<D, E extends EntityEvents = EntityEvents> extends TypedEventEmitter<E> {
6
- protected data: D;
7
- constructor(data: D);
8
- /**
9
- * @internal
10
- * @param delta
11
- */
12
- _update(delta: Partial<D>): void;
13
- /**
14
- * Get a copy of the entity's data
15
- */
16
- toJSON(): D;
17
- }
18
- export default DataEntity;
@@ -1,26 +0,0 @@
1
- import { cloneDeep } from 'lodash';
2
- import TypedEventEmitter from './TypedEventEmitter';
3
- class DataEntity extends TypedEventEmitter {
4
- constructor(data) {
5
- super();
6
- this.data = data;
7
- }
8
- /**
9
- * @internal
10
- * @param delta
11
- */
12
- _update(delta) {
13
- //@ts-ignore
14
- const changedKeys = Object.keys(delta).filter((key) => this.data[key] !== delta[key]);
15
- this.data = Object.assign(Object.assign({}, this.data), delta);
16
- this.emit('updated', changedKeys);
17
- }
18
- /**
19
- * Get a copy of the entity's data
20
- */
21
- toJSON() {
22
- return cloneDeep(this.data);
23
- }
24
- }
25
- export default DataEntity;
26
- //# sourceMappingURL=DataEntity.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DataEntity.js","sourceRoot":"","sources":["../../src/lib/DataEntity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AAMpD,MAAe,UAAqD,SAAQ,iBAAoB;IAG9F,YAAY,IAAO;QACjB,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED;;;OAGG;IACH,OAAO,CAAC,KAAiB;QACvB,YAAY;QACZ,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;QACtF,IAAI,CAAC,IAAI,mCAAQ,IAAI,CAAC,IAAI,GAAK,KAAK,CAAE,CAAC;QACvC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;IACpC,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;CACF;AAED,eAAe,UAAU,CAAC"}
@@ -1,13 +0,0 @@
1
- import { AbstractSigner } from 'ethers';
2
- type SupportedTypes = 'authentication' | 'signup';
3
- interface Options {
4
- name: string;
5
- version: string;
6
- chainId: string;
7
- }
8
- declare class EIP712Helper {
9
- private readonly EIP712Domain;
10
- constructor(options: Options);
11
- signTypedData(signer: AbstractSigner, type: SupportedTypes, data: Record<string, string | number>): Promise<string>;
12
- }
13
- export default EIP712Helper;
@@ -1,37 +0,0 @@
1
- const EIP712_TYPES = {
2
- authentication: {
3
- Authentication: [
4
- { name: 'walletAddress', type: 'address' },
5
- { name: 'nonce', type: 'string' }
6
- ]
7
- },
8
- signup: {
9
- Signup: [
10
- { name: 'appid', type: 'string' },
11
- { name: 'username', type: 'string' },
12
- { name: 'email', type: 'string' },
13
- { name: 'subscribe', type: 'uint256' },
14
- { name: 'walletAddress', type: 'address' },
15
- { name: 'nonce', type: 'string' }
16
- ]
17
- }
18
- };
19
- class EIP712Helper {
20
- constructor(options) {
21
- this.EIP712Domain = {
22
- name: options.name,
23
- version: options.version,
24
- chainId: options.chainId,
25
- verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC'
26
- };
27
- }
28
- signTypedData(signer, type, data) {
29
- const types = EIP712_TYPES[type];
30
- if (!types) {
31
- throw new Error(`Unknown type: ${type}`);
32
- }
33
- return signer.signTypedData(this.EIP712Domain, types, data);
34
- }
35
- }
36
- export default EIP712Helper;
37
- //# sourceMappingURL=EIP712Helper.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"E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,eAAe,YAAY,CAAC"}
@@ -1,18 +0,0 @@
1
- import TypedEventEmitter, { EventMap } from './TypedEventEmitter';
2
- import { JSONValue } from '../types/json';
3
- export interface AuthData {
4
- token: string;
5
- }
6
- declare class RestClient<E extends EventMap = never> extends TypedEventEmitter<E> {
7
- readonly baseUrl: string;
8
- _auth: AuthData | null;
9
- constructor(baseUrl: string);
10
- get auth(): AuthData | null;
11
- set auth(auth: AuthData | null);
12
- private formatUrl;
13
- private request;
14
- private processResponse;
15
- get<T = JSONValue>(path: string, query?: Record<string, any>): Promise<T>;
16
- post<T = JSONValue>(path: string, body?: Record<string, unknown>): Promise<T>;
17
- }
18
- export default RestClient;
@@ -1,64 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { ApiError } from '../ApiClient/ApiClient';
11
- import TypedEventEmitter from './TypedEventEmitter';
12
- class RestClient extends TypedEventEmitter {
13
- constructor(baseUrl) {
14
- super();
15
- this._auth = null;
16
- this.baseUrl = baseUrl;
17
- }
18
- get auth() {
19
- return this._auth;
20
- }
21
- set auth(auth) {
22
- this._auth = auth;
23
- }
24
- formatUrl(relativeUrl, query = {}) {
25
- const url = new URL(relativeUrl, this.baseUrl);
26
- Object.keys(query).forEach((key) => {
27
- url.searchParams.append(key, query[key]);
28
- });
29
- return url.toString();
30
- }
31
- request(url, options = {}) {
32
- return fetch(url, Object.assign(Object.assign({}, options), { headers: Object.assign(Object.assign({}, (options.headers || {})), (this.auth ? { Authorization: this.auth.token } : {})) })).then((r) => this.processResponse(r));
33
- }
34
- processResponse(response) {
35
- return __awaiter(this, void 0, void 0, function* () {
36
- let responseData;
37
- try {
38
- responseData = yield response.json();
39
- }
40
- catch (e) {
41
- console.error('Failed to parse response:', e);
42
- throw new Error('Failed to parse response');
43
- }
44
- if (!response.ok) {
45
- throw new ApiError(response.status, responseData);
46
- }
47
- return responseData;
48
- });
49
- }
50
- get(path, query = {}) {
51
- return this.request(this.formatUrl(path, query), query);
52
- }
53
- post(path, body = {}) {
54
- return this.request(this.formatUrl(path), {
55
- method: 'POST',
56
- headers: {
57
- 'Content-Type': 'application/json'
58
- },
59
- body: JSON.stringify(body)
60
- });
61
- }
62
- }
63
- export default RestClient;
64
- //# sourceMappingURL=RestClient.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RestClient.js","sourceRoot":"","sources":["../../src/lib/RestClient.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAoB,MAAM,wBAAwB,CAAC;AACpE,OAAO,iBAA+B,MAAM,qBAAqB,CAAC;AAOlE,MAAM,UAAuC,SAAQ,iBAAoB;IAIvE,YAAY,OAAe;QACzB,KAAK,EAAE,CAAC;QAHV,UAAK,GAAoB,IAAI,CAAC;QAI5B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,IAAI,IAAI,CAAC,IAAqB;QAC5B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAEO,SAAS,CAAC,WAAmB,EAAE,QAAgC,EAAE;QACvE,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAC/C,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YACjC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,GAAG,EAA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,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE;YAC3C,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;SAC3B,CAAC,CAAC;IACL,CAAC;CACF;AAED,eAAe,UAAU,CAAC"}
@@ -1,34 +0,0 @@
1
- export interface EventMap {
2
- [event: string]: any;
3
- }
4
- export type EventListener<D> = (data: D) => void;
5
- declare abstract class TypedEventEmitter<E extends EventMap> {
6
- protected listeners: {
7
- [K in keyof E]?: EventListener<E[K]>[];
8
- };
9
- /**
10
- * Add an event listener, returns a function that can be called to remove the listener
11
- * @param event
12
- * @param listener
13
- */
14
- on<T extends keyof E>(event: T, listener: EventListener<E[T]>): () => void;
15
- /**
16
- * Add an event listener that will be called only once
17
- * @param event
18
- * @param listener
19
- */
20
- once<T extends keyof E>(event: T, listener: EventListener<E[T]>): () => void;
21
- /**
22
- * Remove an event listener
23
- * @param event
24
- * @param listener
25
- */
26
- off<T extends keyof E>(event: T, listener: EventListener<E[T]>): void;
27
- /**
28
- * Dispatch an event to all listeners
29
- * @param event
30
- * @param data
31
- */
32
- emit<T extends keyof E>(event: T, data: E[T]): void;
33
- }
34
- export default TypedEventEmitter;
@@ -1,56 +0,0 @@
1
- class TypedEventEmitter {
2
- constructor() {
3
- this.listeners = {};
4
- }
5
- /**
6
- * Add an event listener, returns a function that can be called to remove the listener
7
- * @param event
8
- * @param listener
9
- */
10
- on(event, listener) {
11
- if (!this.listeners[event]) {
12
- this.listeners[event] = [];
13
- }
14
- this.listeners[event].push(listener);
15
- return () => {
16
- this.off(event, listener);
17
- };
18
- }
19
- /**
20
- * Add an event listener that will be called only once
21
- * @param event
22
- * @param listener
23
- */
24
- once(event, listener) {
25
- const remove = this.on(event, (data) => {
26
- remove();
27
- listener(data);
28
- });
29
- return remove;
30
- }
31
- /**
32
- * Remove an event listener
33
- * @param event
34
- * @param listener
35
- */
36
- off(event, listener) {
37
- if (!this.listeners[event]) {
38
- return;
39
- }
40
- this.listeners[event] = this.listeners[event].filter((l) => l !== listener);
41
- }
42
- /**
43
- * Dispatch an event to all listeners
44
- * @param event
45
- * @param data
46
- */
47
- emit(event, data) {
48
- const listeners = this.listeners[event];
49
- if (!listeners) {
50
- return;
51
- }
52
- listeners.forEach((listener) => listener(data));
53
- }
54
- }
55
- export default TypedEventEmitter;
56
- //# sourceMappingURL=TypedEventEmitter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TypedEventEmitter.js","sourceRoot":"","sources":["../../src/lib/TypedEventEmitter.ts"],"names":[],"mappings":"AAMA,MAAe,iBAAiB;IAAhC;QACY,cAAS,GAA+C,EAAE,CAAC;IAsDvE,CAAC;IApDC;;;;OAIG;IACH,EAAE,CAAoB,KAAQ,EAAE,QAA6B;QAC3D,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;YAC3B,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;QAC7B,CAAC;QACD,IAAI,CAAC,SAAS,CAAC,KAAK,CAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACtC,OAAO,GAAG,EAAE;YACV,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QAC5B,CAAC,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,IAAI,CAAoB,KAAQ,EAAE,QAA6B;QAC7D,MAAM,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE;YACrC,MAAM,EAAE,CAAC;YACT,QAAQ,CAAC,IAAI,CAAC,CAAC;QACjB,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;;;OAIG;IACH,GAAG,CAAoB,KAAQ,EAAE,QAA6B;QAC5D,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;YAC3B,OAAO;QACT,CAAC;QACD,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC;IAC/E,CAAC;IAED;;;;OAIG;IACH,IAAI,CAAoB,KAAQ,EAAE,IAAU;QAC1C,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACxC,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,OAAO;QACT,CAAC;QACD,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;IAClD,CAAC;CACF;AAED,eAAe,iBAAiB,CAAC"}
@@ -1,2 +0,0 @@
1
- export declare function base64Encode(str: string): string;
2
- export declare function base64Decode(str: string): string;
@@ -1,8 +0,0 @@
1
- import isNodejs from './isNodejs';
2
- export function base64Encode(str) {
3
- return isNodejs ? Buffer.from(str).toString('base64') : btoa(str);
4
- }
5
- export function base64Decode(str) {
6
- return isNodejs ? Buffer.from(str, 'base64').toString() : atob(str);
7
- }
8
- //# sourceMappingURL=base64.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"base64.js","sourceRoot":"","sources":["../../src/lib/base64.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,YAAY,CAAC;AAElC,MAAM,UAAU,YAAY,CAAC,GAAW;IACtC,OAAO,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACpE,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,GAAW;IACtC,OAAO,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACtE,CAAC"}
@@ -1,2 +0,0 @@
1
- declare const isNodejs: boolean;
2
- export default isNodejs;
@@ -1,3 +0,0 @@
1
- const isNodejs = typeof process !== 'undefined' && process.versions != null && process.versions.node != null;
2
- export default isNodejs;
3
- //# sourceMappingURL=isNodejs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"isNodejs.js","sourceRoot":"","sources":["../../src/lib/isNodejs.ts"],"names":[],"mappings":"AAAA,MAAM,QAAQ,GACZ,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,QAAQ,IAAI,IAAI,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,IAAI,IAAI,CAAC;AAE9F,eAAe,QAAQ,CAAC"}