@echoxyz/sonar-core 0.6.0 → 0.8.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,21 @@
1
1
  # @echoxyz/sonar-core
2
2
 
3
+ ## 0.8.0
4
+
5
+ ### Minor Changes
6
+
7
+ - f1c6ddd: Added refresh token endpoint. Aligned to new response type shapes.
8
+
9
+ ## 0.7.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 5b96860: Add listAvailableEntities / useSonarEntities
14
+
15
+ ### Patch Changes
16
+
17
+ - ef7e0f9: Switch to new ExchangeAuthorizationCodeV2 endpoint
18
+
3
19
  ## 0.6.0
4
20
 
5
21
  ### Minor Changes
package/README.md CHANGED
@@ -71,9 +71,14 @@ export async function completeOAuthFromCallback() {
71
71
  // Call APIs (after token is set)
72
72
  export async function exampleCalls() {
73
73
  const { walletAddress } = useWallet(); // User's connected wallet.
74
- // List entities available to this user for the configured sale
74
+
75
+ // Read the entity for linked to the wallet for the configured sale.
76
+ // If the authenticated user has not yet linked the wallet on Sonar, this will return a 404.
75
77
  const { Entity } = await client.readEntity({ saleUUID, walletAddress });
76
78
 
79
+ // List entities available to this user for the configured sale
80
+ const { Entities } = await client.listAvailableEntities({ saleUUD });
81
+
77
82
  // Run a pre-purchase check
78
83
  const pre = await client.prePurchaseCheck({
79
84
  saleUUID,
package/dist/index.cjs CHANGED
@@ -265,15 +265,20 @@ var SonarClient = class {
265
265
  }
266
266
  async exchangeAuthorizationCode(args) {
267
267
  return this.postJSON(
268
- "/oauth.ExchangeAuthorizationCode",
268
+ "/oauth.ExchangeAuthorizationCodeV2",
269
269
  {
270
- Code: args.code,
271
- CodeVerifier: args.codeVerifier,
272
- RedirectURI: args.redirectURI
270
+ code: args.code,
271
+ code_verifier: args.codeVerifier,
272
+ redirect_uri: args.redirectURI
273
273
  },
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,
@@ -300,6 +305,11 @@ var SonarClient = class {
300
305
  WalletAddress: args.walletAddress
301
306
  });
302
307
  }
308
+ async listAvailableEntities(args) {
309
+ return this.postJSON("/externalapi.ListAvailableEntities", {
310
+ SaleUUID: args.saleUUID
311
+ });
312
+ }
303
313
  };
304
314
  var APIError = class extends Error {
305
315
  status;
package/dist/index.d.cts CHANGED
@@ -105,6 +105,15 @@ type AllocationResponse = {
105
105
  type ReadEntityResponse = {
106
106
  Entity: EntityDetails;
107
107
  };
108
+ type ListAvailableEntitiesResponse = {
109
+ Entities: EntityDetails[];
110
+ };
111
+ type TokenResponse = {
112
+ access_token: string;
113
+ refresh_token: string;
114
+ token_type: string;
115
+ expires_in: number;
116
+ };
108
117
  type ClientOptions = {
109
118
  auth?: AuthSession;
110
119
  fetch?: FetchLike;
@@ -129,9 +138,10 @@ declare class SonarClient {
129
138
  code: string;
130
139
  codeVerifier: string;
131
140
  redirectURI: string;
132
- }): Promise<{
133
- token: string;
134
- }>;
141
+ }): Promise<TokenResponse>;
142
+ refreshToken(args: {
143
+ refreshToken: string;
144
+ }): Promise<TokenResponse>;
135
145
  prePurchaseCheck(args: {
136
146
  saleUUID: string;
137
147
  entityID: Hex;
@@ -150,6 +160,9 @@ declare class SonarClient {
150
160
  saleUUID: string;
151
161
  walletAddress: string;
152
162
  }): Promise<ReadEntityResponse>;
163
+ listAvailableEntities(args: {
164
+ saleUUID: string;
165
+ }): Promise<ListAvailableEntitiesResponse>;
153
166
  }
154
167
  declare class APIError extends Error {
155
168
  readonly status: number;
@@ -184,4 +197,4 @@ type CreateClientOptions = {
184
197
  };
185
198
  declare function createClient(options?: CreateClientOptions): SonarClient;
186
199
 
187
- 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 PrePurchaseCheckResponse, PrePurchaseFailureReason, type PurchasePermit, PurchasePermitType, type ReadEntityResponse, SaleEligibility, SonarClient, type StorageLike, buildAuthorizationUrl, createClient, createMemoryStorage, createWebStorage, generatePKCEParams };
200
+ 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, type TokenResponse, buildAuthorizationUrl, createClient, createMemoryStorage, createWebStorage, generatePKCEParams };
package/dist/index.d.ts CHANGED
@@ -105,6 +105,15 @@ type AllocationResponse = {
105
105
  type ReadEntityResponse = {
106
106
  Entity: EntityDetails;
107
107
  };
108
+ type ListAvailableEntitiesResponse = {
109
+ Entities: EntityDetails[];
110
+ };
111
+ type TokenResponse = {
112
+ access_token: string;
113
+ refresh_token: string;
114
+ token_type: string;
115
+ expires_in: number;
116
+ };
108
117
  type ClientOptions = {
109
118
  auth?: AuthSession;
110
119
  fetch?: FetchLike;
@@ -129,9 +138,10 @@ declare class SonarClient {
129
138
  code: string;
130
139
  codeVerifier: string;
131
140
  redirectURI: string;
132
- }): Promise<{
133
- token: string;
134
- }>;
141
+ }): Promise<TokenResponse>;
142
+ refreshToken(args: {
143
+ refreshToken: string;
144
+ }): Promise<TokenResponse>;
135
145
  prePurchaseCheck(args: {
136
146
  saleUUID: string;
137
147
  entityID: Hex;
@@ -150,6 +160,9 @@ declare class SonarClient {
150
160
  saleUUID: string;
151
161
  walletAddress: string;
152
162
  }): Promise<ReadEntityResponse>;
163
+ listAvailableEntities(args: {
164
+ saleUUID: string;
165
+ }): Promise<ListAvailableEntitiesResponse>;
153
166
  }
154
167
  declare class APIError extends Error {
155
168
  readonly status: number;
@@ -184,4 +197,4 @@ type CreateClientOptions = {
184
197
  };
185
198
  declare function createClient(options?: CreateClientOptions): SonarClient;
186
199
 
187
- 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 PrePurchaseCheckResponse, PrePurchaseFailureReason, type PurchasePermit, PurchasePermitType, type ReadEntityResponse, SaleEligibility, SonarClient, type StorageLike, buildAuthorizationUrl, createClient, createMemoryStorage, createWebStorage, generatePKCEParams };
200
+ 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, type TokenResponse, buildAuthorizationUrl, createClient, createMemoryStorage, createWebStorage, generatePKCEParams };
package/dist/index.js CHANGED
@@ -228,15 +228,20 @@ var SonarClient = class {
228
228
  }
229
229
  async exchangeAuthorizationCode(args) {
230
230
  return this.postJSON(
231
- "/oauth.ExchangeAuthorizationCode",
231
+ "/oauth.ExchangeAuthorizationCodeV2",
232
232
  {
233
- Code: args.code,
234
- CodeVerifier: args.codeVerifier,
235
- RedirectURI: args.redirectURI
233
+ code: args.code,
234
+ code_verifier: args.codeVerifier,
235
+ redirect_uri: args.redirectURI
236
236
  },
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,
@@ -263,6 +268,11 @@ var SonarClient = class {
263
268
  WalletAddress: args.walletAddress
264
269
  });
265
270
  }
271
+ async listAvailableEntities(args) {
272
+ return this.postJSON("/externalapi.ListAvailableEntities", {
273
+ SaleUUID: args.saleUUID
274
+ });
275
+ }
266
276
  };
267
277
  var APIError = class extends Error {
268
278
  status;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@echoxyz/sonar-core",
3
- "version": "0.6.0",
3
+ "version": "0.8.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",