@vintr/node-sdk 1.0.0 → 1.1.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/README.md CHANGED
@@ -11,25 +11,31 @@ npm install @vintr/node-sdk
11
11
  ## Usage
12
12
 
13
13
  ```typescript
14
- import { Vintr } from '@vintr/node-sdk';
14
+ import { Vintr } from "@vintr/node-sdk";
15
15
 
16
- const vintr = new Vintr('vintr_secret_key');
16
+ const vintr = new Vintr("vintr_secret_key");
17
17
 
18
- const location = await vintr.alias.resolve({ alias: 'apple#vintr' });
18
+ const location = await vintr.alias.resolve({
19
+ alias: "apple#vintr",
20
+ code: "ABCDEF", // Alias owner-provided 6-letter authorization code
21
+ });
19
22
  ```
20
23
 
21
24
  ## API
22
25
 
23
- ### `vintr.alias.resolve({ alias })`
26
+ ### `vintr.alias.resolve({ alias, code })`
24
27
 
25
28
  Resolves an alias to its associated location and metadata.
26
29
 
27
30
  **Parameters:**
28
- - `alias` (string): The alias to resolve in full format with suffix (e.g., `apple#vintr`, `asteik#vintr`, `sushi#vintr`)
31
+
32
+ - `alias` (string, required): The alias to resolve (e.g., `apple#vintr`, `asteik#vintr`, `sushi#vintr`)
33
+ - `code` (string, required): A 6-letter authorization code to resolve the alias
29
34
 
30
35
  **Returns:** `AliasResponse` with location details, coordinates, and delivery instructions.
31
36
 
32
37
  **Sample Response:**
38
+
33
39
  ```typescript
34
40
  {
35
41
  alias: "apple#vintr",
@@ -66,5 +72,11 @@ Resolves an alias to its associated location and metadata.
66
72
  Full TypeScript support included with exported types:
67
73
 
68
74
  ```typescript
69
- import type { AliasResponse, Location, Address, Geo, Instructions } from '@vintr/node-sdk';
75
+ import type {
76
+ AliasResponse,
77
+ Location,
78
+ Address,
79
+ Geo,
80
+ Instructions,
81
+ } from "@vintr/node-sdk";
70
82
  ```
package/dist/alias.js CHANGED
@@ -3,6 +3,6 @@ export class AliasAPI {
3
3
  this.client = client;
4
4
  }
5
5
  async resolve(params) {
6
- return this.client.resolveAlias(params.alias);
6
+ return this.client.resolveAlias(params);
7
7
  }
8
8
  }
package/dist/client.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import type { AliasResponse } from './types.js';
1
+ import type { AliasResponse, ResolveAliasParams } from './types.js';
2
2
  export declare class VintrClient {
3
3
  private apiKey;
4
4
  private readonly baseUrl;
5
5
  constructor(apiKey: string);
6
6
  private request;
7
- resolveAlias(alias: string): Promise<AliasResponse>;
7
+ resolveAlias(params: ResolveAliasParams): Promise<AliasResponse>;
8
8
  }
package/dist/client.js CHANGED
@@ -4,18 +4,20 @@ export class VintrClient {
4
4
  this.baseUrl = 'https://api.vintr.xyz';
5
5
  this.apiKey = apiKey;
6
6
  }
7
- async request(path) {
7
+ async request(path, headers) {
8
8
  return new Promise((resolve, reject) => {
9
9
  const url = new URL(path, this.baseUrl);
10
+ const defaultHeaders = {
11
+ 'Authorization': `Bearer ${this.apiKey}`,
12
+ 'Content-Type': 'application/json',
13
+ };
14
+ const allHeaders = { ...defaultHeaders, ...headers };
10
15
  const options = {
11
16
  hostname: url.hostname,
12
17
  port: url.port || 443,
13
- path: url.pathname,
18
+ path: url.pathname + url.search,
14
19
  method: 'GET',
15
- headers: {
16
- 'Authorization': `Bearer ${this.apiKey}`,
17
- 'Content-Type': 'application/json',
18
- },
20
+ headers: allHeaders,
19
21
  };
20
22
  const req = https.request(options, (res) => {
21
23
  let data = '';
@@ -38,7 +40,9 @@ export class VintrClient {
38
40
  req.end();
39
41
  });
40
42
  }
41
- async resolveAlias(alias) {
42
- return this.request(`/${alias}`);
43
+ async resolveAlias(params) {
44
+ const url = new URL(`/${params.alias}`, this.baseUrl);
45
+ url.searchParams.append('code', params.code);
46
+ return this.request(url.pathname + url.search);
43
47
  }
44
48
  }
package/dist/types.d.ts CHANGED
@@ -1,38 +1,39 @@
1
1
  export interface Address {
2
- line1: string;
2
+ line1?: string;
3
3
  line2?: string;
4
4
  line3?: string;
5
- city: string;
6
- state: string;
7
- postal_code: string;
8
- country: string;
5
+ city?: string;
6
+ state?: string;
7
+ postal_code?: string;
8
+ country?: string;
9
9
  }
10
10
  export interface Geo {
11
- latitude: number;
12
- longitude: number;
13
- altitude: number | null;
14
- precision_meters: number;
11
+ latitude?: number;
12
+ longitude?: number;
13
+ altitude?: number | null;
14
+ precision_meters?: number;
15
15
  }
16
16
  export interface Instructions {
17
- general: string;
18
- delivery: string;
19
- autonomous: string;
17
+ general?: string;
18
+ delivery?: string;
19
+ autonomous?: string;
20
20
  }
21
21
  export interface Location {
22
- address: Address;
23
- geo: Geo;
24
- instructions: Instructions;
22
+ address?: Address;
23
+ geo?: Geo;
24
+ instructions?: Instructions;
25
25
  }
26
26
  export interface AliasResponse {
27
27
  alias: string;
28
- type: 'business' | 'individual';
29
- location: Location;
30
- createdAt: string;
31
- updatedAt: string;
28
+ type?: 'business' | 'individual';
29
+ location?: Location;
30
+ createdAt?: string;
31
+ updatedAt?: string;
32
32
  }
33
33
  export interface ErrorResponse {
34
34
  error: string;
35
35
  }
36
36
  export interface ResolveAliasParams {
37
37
  alias: string;
38
+ code: string;
38
39
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vintr/node-sdk",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Minimal, elegant Vintr API SDK for Node.js",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",