@echoxyz/sonar-core 0.7.0 → 0.9.0

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @echoxyz/sonar-core
2
2
 
3
+ ## 0.9.0
4
+
5
+ ### Minor Changes
6
+
7
+ - cbf7964: Support new V2 permit
8
+
9
+ ## 0.8.0
10
+
11
+ ### Minor Changes
12
+
13
+ - f1c6ddd: Added refresh token endpoint. Aligned to new response type shapes.
14
+
3
15
  ## 0.7.0
4
16
 
5
17
  ### Minor Changes
package/dist/index.cjs CHANGED
@@ -274,6 +274,11 @@ var SonarClient = class {
274
274
  { includeAuth: false }
275
275
  );
276
276
  }
277
+ async refreshToken(args) {
278
+ return this.postJSON("/oauth.RefreshAccessToken", {
279
+ refresh_token: args.refreshToken
280
+ });
281
+ }
277
282
  async prePurchaseCheck(args) {
278
283
  return this.postJSON("/externalapi.PrePurchaseCheck", {
279
284
  SaleUUID: args.saleUUID,
@@ -393,6 +398,7 @@ var SaleEligibility = /* @__PURE__ */ ((SaleEligibility2) => {
393
398
  })(SaleEligibility || {});
394
399
  var PurchasePermitType = /* @__PURE__ */ ((PurchasePermitType2) => {
395
400
  PurchasePermitType2["BASIC"] = "basic";
401
+ PurchasePermitType2["BASIC_V2"] = "basic-v2";
396
402
  PurchasePermitType2["ALLOCATION"] = "allocation";
397
403
  return PurchasePermitType2;
398
404
  })(PurchasePermitType || {});
package/dist/index.d.cts CHANGED
@@ -59,11 +59,23 @@ type AllocationPermit = {
59
59
  MaxAmount: string;
60
60
  MinAmount: string;
61
61
  };
62
+ type BasicPermitV2 = {
63
+ EntityID: Hex;
64
+ SaleUUID: Hex;
65
+ Wallet: Hex;
66
+ ExpiresAt: number;
67
+ MinAmount: string;
68
+ MaxAmount: string;
69
+ MinPrice: number;
70
+ MaxPrice: number;
71
+ Payload: Hex;
72
+ };
62
73
  declare enum PurchasePermitType {
63
74
  BASIC = "basic",
75
+ BASIC_V2 = "basic-v2",
64
76
  ALLOCATION = "allocation"
65
77
  }
66
- type PurchasePermit<T extends PurchasePermitType> = T extends PurchasePermitType.BASIC ? BasicPermit : T extends PurchasePermitType.ALLOCATION ? AllocationPermit : never;
78
+ type PurchasePermit<T extends PurchasePermitType> = T extends PurchasePermitType.BASIC ? BasicPermit : T extends PurchasePermitType.BASIC_V2 ? BasicPermitV2 : T extends PurchasePermitType.ALLOCATION ? AllocationPermit : never;
67
79
  declare enum PrePurchaseFailureReason {
68
80
  UNKNOWN = "unknown",
69
81
  WALLET_RISK = "wallet-risk",
@@ -94,7 +106,7 @@ type PrePurchaseCheckResponse = {
94
106
  LivenessCheckURL: string;
95
107
  };
96
108
  type GeneratePurchasePermitResponse = {
97
- PermitJSON: BasicPermit | AllocationPermit;
109
+ PermitJSON: BasicPermit | BasicPermitV2 | AllocationPermit;
98
110
  Signature: Hex;
99
111
  };
100
112
  type AllocationResponse = {
@@ -108,6 +120,12 @@ type ReadEntityResponse = {
108
120
  type ListAvailableEntitiesResponse = {
109
121
  Entities: EntityDetails[];
110
122
  };
123
+ type TokenResponse = {
124
+ access_token: string;
125
+ refresh_token: string;
126
+ token_type: string;
127
+ expires_in: number;
128
+ };
111
129
  type ClientOptions = {
112
130
  auth?: AuthSession;
113
131
  fetch?: FetchLike;
@@ -132,9 +150,10 @@ declare class SonarClient {
132
150
  code: string;
133
151
  codeVerifier: string;
134
152
  redirectURI: string;
135
- }): Promise<{
136
- token: string;
137
- }>;
153
+ }): Promise<TokenResponse>;
154
+ refreshToken(args: {
155
+ refreshToken: string;
156
+ }): Promise<TokenResponse>;
138
157
  prePurchaseCheck(args: {
139
158
  saleUUID: string;
140
159
  entityID: Hex;
@@ -190,4 +209,4 @@ type CreateClientOptions = {
190
209
  };
191
210
  declare function createClient(options?: CreateClientOptions): SonarClient;
192
211
 
193
- export { APIError, type AllocationPermit, type AllocationResponse, type BasicPermit, type BuildAuthorizationUrlArgs, type ClientOptions, type CreateClientOptions, type EntityDetails, EntitySetupState, EntityType, type FetchLike, type GeneratePurchasePermitResponse, type Hex, InvestingRegion, type ListAvailableEntitiesResponse, type PrePurchaseCheckResponse, PrePurchaseFailureReason, type PurchasePermit, PurchasePermitType, type ReadEntityResponse, SaleEligibility, SonarClient, type StorageLike, buildAuthorizationUrl, createClient, createMemoryStorage, createWebStorage, generatePKCEParams };
212
+ export { APIError, type AllocationPermit, type AllocationResponse, type BasicPermit, type BasicPermitV2, type BuildAuthorizationUrlArgs, type ClientOptions, type CreateClientOptions, type EntityDetails, EntitySetupState, EntityType, type FetchLike, type GeneratePurchasePermitResponse, type Hex, InvestingRegion, type ListAvailableEntitiesResponse, type PrePurchaseCheckResponse, PrePurchaseFailureReason, type PurchasePermit, PurchasePermitType, type ReadEntityResponse, SaleEligibility, SonarClient, type StorageLike, type TokenResponse, buildAuthorizationUrl, createClient, createMemoryStorage, createWebStorage, generatePKCEParams };
package/dist/index.d.ts CHANGED
@@ -59,11 +59,23 @@ type AllocationPermit = {
59
59
  MaxAmount: string;
60
60
  MinAmount: string;
61
61
  };
62
+ type BasicPermitV2 = {
63
+ EntityID: Hex;
64
+ SaleUUID: Hex;
65
+ Wallet: Hex;
66
+ ExpiresAt: number;
67
+ MinAmount: string;
68
+ MaxAmount: string;
69
+ MinPrice: number;
70
+ MaxPrice: number;
71
+ Payload: Hex;
72
+ };
62
73
  declare enum PurchasePermitType {
63
74
  BASIC = "basic",
75
+ BASIC_V2 = "basic-v2",
64
76
  ALLOCATION = "allocation"
65
77
  }
66
- type PurchasePermit<T extends PurchasePermitType> = T extends PurchasePermitType.BASIC ? BasicPermit : T extends PurchasePermitType.ALLOCATION ? AllocationPermit : never;
78
+ type PurchasePermit<T extends PurchasePermitType> = T extends PurchasePermitType.BASIC ? BasicPermit : T extends PurchasePermitType.BASIC_V2 ? BasicPermitV2 : T extends PurchasePermitType.ALLOCATION ? AllocationPermit : never;
67
79
  declare enum PrePurchaseFailureReason {
68
80
  UNKNOWN = "unknown",
69
81
  WALLET_RISK = "wallet-risk",
@@ -94,7 +106,7 @@ type PrePurchaseCheckResponse = {
94
106
  LivenessCheckURL: string;
95
107
  };
96
108
  type GeneratePurchasePermitResponse = {
97
- PermitJSON: BasicPermit | AllocationPermit;
109
+ PermitJSON: BasicPermit | BasicPermitV2 | AllocationPermit;
98
110
  Signature: Hex;
99
111
  };
100
112
  type AllocationResponse = {
@@ -108,6 +120,12 @@ type ReadEntityResponse = {
108
120
  type ListAvailableEntitiesResponse = {
109
121
  Entities: EntityDetails[];
110
122
  };
123
+ type TokenResponse = {
124
+ access_token: string;
125
+ refresh_token: string;
126
+ token_type: string;
127
+ expires_in: number;
128
+ };
111
129
  type ClientOptions = {
112
130
  auth?: AuthSession;
113
131
  fetch?: FetchLike;
@@ -132,9 +150,10 @@ declare class SonarClient {
132
150
  code: string;
133
151
  codeVerifier: string;
134
152
  redirectURI: string;
135
- }): Promise<{
136
- token: string;
137
- }>;
153
+ }): Promise<TokenResponse>;
154
+ refreshToken(args: {
155
+ refreshToken: string;
156
+ }): Promise<TokenResponse>;
138
157
  prePurchaseCheck(args: {
139
158
  saleUUID: string;
140
159
  entityID: Hex;
@@ -190,4 +209,4 @@ type CreateClientOptions = {
190
209
  };
191
210
  declare function createClient(options?: CreateClientOptions): SonarClient;
192
211
 
193
- export { APIError, type AllocationPermit, type AllocationResponse, type BasicPermit, type BuildAuthorizationUrlArgs, type ClientOptions, type CreateClientOptions, type EntityDetails, EntitySetupState, EntityType, type FetchLike, type GeneratePurchasePermitResponse, type Hex, InvestingRegion, type ListAvailableEntitiesResponse, type PrePurchaseCheckResponse, PrePurchaseFailureReason, type PurchasePermit, PurchasePermitType, type ReadEntityResponse, SaleEligibility, SonarClient, type StorageLike, buildAuthorizationUrl, createClient, createMemoryStorage, createWebStorage, generatePKCEParams };
212
+ export { APIError, type AllocationPermit, type AllocationResponse, type BasicPermit, type BasicPermitV2, type BuildAuthorizationUrlArgs, type ClientOptions, type CreateClientOptions, type EntityDetails, EntitySetupState, EntityType, type FetchLike, type GeneratePurchasePermitResponse, type Hex, InvestingRegion, type ListAvailableEntitiesResponse, type PrePurchaseCheckResponse, PrePurchaseFailureReason, type PurchasePermit, PurchasePermitType, type ReadEntityResponse, SaleEligibility, SonarClient, type StorageLike, type TokenResponse, buildAuthorizationUrl, createClient, createMemoryStorage, createWebStorage, generatePKCEParams };
package/dist/index.js CHANGED
@@ -237,6 +237,11 @@ var SonarClient = class {
237
237
  { includeAuth: false }
238
238
  );
239
239
  }
240
+ async refreshToken(args) {
241
+ return this.postJSON("/oauth.RefreshAccessToken", {
242
+ refresh_token: args.refreshToken
243
+ });
244
+ }
240
245
  async prePurchaseCheck(args) {
241
246
  return this.postJSON("/externalapi.PrePurchaseCheck", {
242
247
  SaleUUID: args.saleUUID,
@@ -356,6 +361,7 @@ var SaleEligibility = /* @__PURE__ */ ((SaleEligibility2) => {
356
361
  })(SaleEligibility || {});
357
362
  var PurchasePermitType = /* @__PURE__ */ ((PurchasePermitType2) => {
358
363
  PurchasePermitType2["BASIC"] = "basic";
364
+ PurchasePermitType2["BASIC_V2"] = "basic-v2";
359
365
  PurchasePermitType2["ALLOCATION"] = "allocation";
360
366
  return PurchasePermitType2;
361
367
  })(PurchasePermitType || {});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@echoxyz/sonar-core",
3
- "version": "0.7.0",
3
+ "version": "0.9.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",