instasign 1.1.0 → 1.1.2

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
@@ -2,6 +2,20 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [1.1.2] - 2026-03-01
6
+
7
+ ### Added
8
+ - **Scoped Types Package**: Rewrote the shared types infrastructure to use the scoped `@instasign/types` package, resolving naming conflicts with the main SDK.
9
+ - **Type Re-exports**: Shared types are now directly re-exported from the `instasign` entry point, enabling seamless IntelliSense and simpler imports (e.g., `import { WebhookEventType } from 'instasign'`).
10
+
11
+ ### Fixed
12
+ - **Type Import Error**: Resolved the TypeScript error `Cannot import type declaration files` caused by direct `@types/instasign` imports.
13
+
14
+ ## [1.1.1] - 2026-02-28
15
+
16
+ ### Changed
17
+ - **Version Bump**: Updated version to 1.1.1 to fix publishing issues.
18
+
5
19
  ## [1.1.0] - 2026-02-28
6
20
 
7
21
  ### Added
@@ -9,7 +23,7 @@ All notable changes to this project will be documented in this file.
9
23
 
10
24
  ### Changed
11
25
  - **License**: Changed package license from ISC to Apache-2.0.
12
- - **Dependency Refactoring**: Moved shared types to a dedicated `@instasign/types` package for better consistency across the project.
26
+ - **Dependency Refactoring**: Moved shared types to a dedicated `@types/instasign` package for better consistency across the project.
13
27
  - **Type Safety**: Improved internal type synchronization with compile-time schema validation against the OpenAPI specification.
14
28
 
15
29
  ## [1.0.1] - 2026-02-27
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/resources/Envelopes.ts","../src/resources/SignRequests.ts","../src/resources/Webhooks.ts"],"sourcesContent":["import axios, { AxiosInstance } from 'axios';\nimport { Envelopes } from './resources/Envelopes.js';\nimport { SignRequests } from './resources/SignRequests.js';\nimport { Webhooks } from './resources/Webhooks.js';\n\nexport * from './resources/Envelopes.js';\nexport * from './resources/SignRequests.js';\nexport * from './resources/Webhooks.js';\n\nexport type * from '../types/schema.js';\n\nexport interface IInstasignConfig {\n /// Required Instasign API key\n apiKey: string;\n\n /// Optional Parse Server config\n appId?: string;\n restApiKey?: string;\n serverUrl?: string;\n /// Optional webhook signature tolerance in seconds (default 300)\n webhookTolerance?: number;\n}\n\nexport class Instasign {\n private client: AxiosInstance;\n\n public envelopes: Envelopes;\n public signRequests: SignRequests;\n public webhooks: Webhooks;\n\n constructor(config: IInstasignConfig) {\n this.client = axios.create({\n baseURL: config.serverUrl || 'https://parseapi.back4app.com',\n headers: {\n 'X-Parse-APPLICATION-ID': config.appId || 'jKFo8BFQRdiAUV4F3o3SIDWLpLUb2TVW7bVl7lwH',\n 'X-Parse-REST-API-KEY': config.restApiKey || 'Gjm9pmxZh0DjXHkcFlf0kGZjHfYEY4ERw71TvLig',\n 'x-api-key': config.apiKey,\n 'Content-Type': 'application/json',\n },\n });\n\n this.envelopes = new Envelopes(this.client);\n this.signRequests = new SignRequests(this.client);\n this.webhooks = new Webhooks(config.webhookTolerance ?? 300);\n }\n}\n\n","import { AxiosInstance } from 'axios';\nimport {\n type CreateEnvelopeParams,\n type CreateEnvelopeResponse,\n type GetEnvelopesParams,\n type EnvelopeListItem,\n type Envelope,\n type OperationResponse,\n type UpdateEnvelopeMetadataParams,\n type UpdateEnvelopeMetadataResponse,\n type RemoveSignRequestFromEnvelopeParams,\n type AddSignRequestToEnvelopeParams,\n type AddSignRequestToEnvelopeResponse,\n} from '../types.js';\n\nexport class Envelopes {\n constructor(private client: AxiosInstance) { }\n\n /**\n * Create a new envelope\n */\n async create(params: CreateEnvelopeParams): Promise<CreateEnvelopeResponse | undefined> {\n const response = await this.client.post('/functions/createEnvelope', params);\n return response.data.result;\n }\n\n /**\n * List envelopes\n */\n async list(params: GetEnvelopesParams = {}): Promise<EnvelopeListItem[] | undefined> {\n const response = await this.client.post('/functions/getEnvelopes', params);\n return response.data.result;\n }\n\n /**\n * Retrieve a single envelope with its sign requests\n */\n async get(envelopeId: string): Promise<Envelope | undefined> {\n const response = await this.client.post('/functions/getEnvelope', { envelopeId });\n return response.data.result;\n }\n\n /**\n * Complete an envelope\n */\n async complete(envelopeId: string): Promise<OperationResponse | undefined> {\n const response = await this.client.post('/functions/completeEnvelope', { envelopeId });\n return response.data.result;\n }\n\n /**\n * Delete an envelope\n */\n async delete(envelopeId: string): Promise<OperationResponse | undefined> {\n const response = await this.client.post('/functions/deleteEnvelope', { envelopeId });\n return response.data.result;\n }\n\n /**\n * Update envelope metadata\n */\n async updateMetadata(params: UpdateEnvelopeMetadataParams): Promise<UpdateEnvelopeMetadataResponse | undefined> {\n const response = await this.client.post('/functions/updateEnvelopeMetadata', params);\n return response.data.result;\n }\n\n /**\n * Remove a sign request from an envelope\n */\n async removeSignRequest(params: RemoveSignRequestFromEnvelopeParams): Promise<OperationResponse | undefined> {\n const response = await this.client.post('/functions/removeSignRequestFromEnvelope', params);\n return response.data.result;\n }\n\n /**\n * Add a sign request to an envelope\n */\n async addSignRequest(params: AddSignRequestToEnvelopeParams): Promise<AddSignRequestToEnvelopeResponse | undefined> {\n const response = await this.client.post('/functions/addSignRequestToEnvelope', params);\n return response.data.result;\n }\n\n /**\n * Add multiple sign requests to an envelope\n */\n // async addSignRequests(params: AddSignRequestToEnvelopeParams[]): Promise<AddSignRequestToEnvelopeResponse[] | undefined> {\n // // TODO(ciro): must be implemented on back-end\n // const response = await this.client.post('/functions/addMultipleSignRequestsToEnvelope', params);\n // return response.data.result;\n // }\n}","import { AxiosInstance } from 'axios';\nimport {\n type CreateSignRequestParams,\n type CreateSignRequestResponse,\n type CompleteSignRequestParams,\n type CompleteSignRequestResponse,\n type SignRequestFile,\n} from '../types.js';\n\nexport class SignRequests {\n constructor(private client: AxiosInstance) { }\n\n /**\n * Create a new sign request\n */\n async create(params: CreateSignRequestParams): Promise<CreateSignRequestResponse | undefined> {\n const response = await this.client.post('/functions/createSignRequest', params);\n return response.data.result;\n }\n\n /**\n * Complete a sign request\n */\n async complete(params: CompleteSignRequestParams): Promise<CompleteSignRequestResponse | undefined> {\n const response = await this.client.post('/functions/completeSignRequest', params);\n return response.data.result;\n }\n\n /**\n * Get the file associated with a sign request\n */\n async getFile(requestId: string): Promise<SignRequestFile | undefined> {\n const response = await this.client.post('/functions/getFileFromRequestId', { requestId });\n return response.data.result;\n }\n}","import * as crypto from 'node:crypto';\nimport { WebhookEvent } from '../types';\n\nexport class Webhooks {\n constructor(private tolerance: number = 300) { }\n\n /**\n * Verify and parse a webhook event\n */\n public constructEvent(payload: string, signatureHeader: string, webhookSecret: string): WebhookEvent {\n const parts = signatureHeader.split(',');\n const timestamp = parts.find((p) => p.startsWith('t='))?.split('=')[1];\n const signature = parts.find((p) => p.startsWith('v1='))?.split('=')[1];\n\n if (!timestamp || !signature) {\n throw new Error('Invalid signature header');\n }\n\n const now = Math.floor(Date.now() / 1000);\n if (Math.abs(now - parseInt(timestamp)) > this.tolerance) {\n throw new Error('Signature too old');\n }\n\n const signedPayload = `${timestamp}.${payload}`;\n const expectedSignature = crypto\n .createHmac('sha256', webhookSecret)\n .update(signedPayload)\n .digest('hex');\n\n const isValid = crypto.timingSafeEqual(\n Buffer.from(signature),\n Buffer.from(expectedSignature)\n );\n\n if (!isValid) {\n throw new Error('Invalid signature');\n }\n\n return JSON.parse(payload) as WebhookEvent;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAqC;;;ACe9B,IAAM,YAAN,MAAgB;AAAA,EACnB,YAAoB,QAAuB;AAAvB;AAAA,EAAyB;AAAA;AAAA;AAAA;AAAA,EAK7C,MAAM,OAAO,QAA2E;AACpF,UAAM,WAAW,MAAM,KAAK,OAAO,KAAK,6BAA6B,MAAM;AAC3E,WAAO,SAAS,KAAK;AAAA,EACzB;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,KAAK,SAA6B,CAAC,GAA4C;AACjF,UAAM,WAAW,MAAM,KAAK,OAAO,KAAK,2BAA2B,MAA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,EAC7B;AACJ;;;AHjBO,IAAM,YAAN,MAAgB;AAAA,EACb;AAAA,EAED;AAAA,EACA;AAAA,EACA;AAAA,EAEP,YAAY,QAA0B;AACpC,SAAK,SAAS,aAAAA,QAAM,OAAO;AAAA,MACzB,SAAS,OAAO,aAAa;AAAA,MAC7B,SAAS;AAAA,QACP,0BAA0B,OAAO,SAAS;AAAA,QAC1C,wBAAwB,OAAO,cAAc;AAAA,QAC7C,aAAa,OAAO;AAAA,QACpB,gBAAgB;AAAA,MAClB;AAAA,IACF,CAAC;AAED,SAAK,YAAY,IAAI,UAAU,KAAK,MAAM;AAC1C,SAAK,eAAe,IAAI,aAAa,KAAK,MAAM;AAChD,SAAK,WAAW,IAAI,SAAS,OAAO,oBAAoB,GAAG;AAAA,EAC7D;AACF;","names":["axios"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/resources/Envelopes.ts","../src/resources/SignRequests.ts","../src/resources/Webhooks.ts"],"sourcesContent":["import axios, { AxiosInstance } from 'axios';\nimport { Envelopes } from './resources/Envelopes.js';\nimport { SignRequests } from './resources/SignRequests.js';\nimport { Webhooks } from './resources/Webhooks.js';\n\nexport * from './resources/Envelopes.js';\nexport * from './resources/SignRequests.js';\nexport * from './resources/Webhooks.js';\nexport * from './types.js';\n\nexport type * from '../types/schema.js';\n\nexport interface IInstasignConfig {\n /// Required Instasign API key\n apiKey: string;\n\n /// Optional Parse Server config\n appId?: string;\n restApiKey?: string;\n serverUrl?: string;\n /// Optional webhook signature tolerance in seconds (default 300)\n webhookTolerance?: number;\n}\n\nexport class Instasign {\n private client: AxiosInstance;\n\n public envelopes: Envelopes;\n public signRequests: SignRequests;\n public webhooks: Webhooks;\n\n constructor(config: IInstasignConfig) {\n this.client = axios.create({\n baseURL: config.serverUrl || 'https://parseapi.back4app.com',\n headers: {\n 'X-Parse-APPLICATION-ID': config.appId || 'jKFo8BFQRdiAUV4F3o3SIDWLpLUb2TVW7bVl7lwH',\n 'X-Parse-REST-API-KEY': config.restApiKey || 'Gjm9pmxZh0DjXHkcFlf0kGZjHfYEY4ERw71TvLig',\n 'x-api-key': config.apiKey,\n 'Content-Type': 'application/json',\n },\n });\n\n this.envelopes = new Envelopes(this.client);\n this.signRequests = new SignRequests(this.client);\n this.webhooks = new Webhooks(config.webhookTolerance ?? 300);\n }\n}\n\n","import { AxiosInstance } from 'axios';\nimport {\n type CreateEnvelopeParams,\n type CreateEnvelopeResponse,\n type GetEnvelopesParams,\n type EnvelopeListItem,\n type Envelope,\n type OperationResponse,\n type UpdateEnvelopeMetadataParams,\n type UpdateEnvelopeMetadataResponse,\n type RemoveSignRequestFromEnvelopeParams,\n type AddSignRequestToEnvelopeParams,\n type AddSignRequestToEnvelopeResponse,\n} from '../types.js';\n\nexport class Envelopes {\n constructor(private client: AxiosInstance) { }\n\n /**\n * Create a new envelope\n */\n async create(params: CreateEnvelopeParams): Promise<CreateEnvelopeResponse | undefined> {\n const response = await this.client.post('/functions/createEnvelope', params);\n return response.data.result;\n }\n\n /**\n * List envelopes\n */\n async list(params: GetEnvelopesParams = {}): Promise<EnvelopeListItem[] | undefined> {\n const response = await this.client.post('/functions/getEnvelopes', params);\n return response.data.result;\n }\n\n /**\n * Retrieve a single envelope with its sign requests\n */\n async get(envelopeId: string): Promise<Envelope | undefined> {\n const response = await this.client.post('/functions/getEnvelope', { envelopeId });\n return response.data.result;\n }\n\n /**\n * Complete an envelope\n */\n async complete(envelopeId: string): Promise<OperationResponse | undefined> {\n const response = await this.client.post('/functions/completeEnvelope', { envelopeId });\n return response.data.result;\n }\n\n /**\n * Delete an envelope\n */\n async delete(envelopeId: string): Promise<OperationResponse | undefined> {\n const response = await this.client.post('/functions/deleteEnvelope', { envelopeId });\n return response.data.result;\n }\n\n /**\n * Update envelope metadata\n */\n async updateMetadata(params: UpdateEnvelopeMetadataParams): Promise<UpdateEnvelopeMetadataResponse | undefined> {\n const response = await this.client.post('/functions/updateEnvelopeMetadata', params);\n return response.data.result;\n }\n\n /**\n * Remove a sign request from an envelope\n */\n async removeSignRequest(params: RemoveSignRequestFromEnvelopeParams): Promise<OperationResponse | undefined> {\n const response = await this.client.post('/functions/removeSignRequestFromEnvelope', params);\n return response.data.result;\n }\n\n /**\n * Add a sign request to an envelope\n */\n async addSignRequest(params: AddSignRequestToEnvelopeParams): Promise<AddSignRequestToEnvelopeResponse | undefined> {\n const response = await this.client.post('/functions/addSignRequestToEnvelope', params);\n return response.data.result;\n }\n\n /**\n * Add multiple sign requests to an envelope\n */\n // async addSignRequests(params: AddSignRequestToEnvelopeParams[]): Promise<AddSignRequestToEnvelopeResponse[] | undefined> {\n // // TODO(ciro): must be implemented on back-end\n // const response = await this.client.post('/functions/addMultipleSignRequestsToEnvelope', params);\n // return response.data.result;\n // }\n}","import { AxiosInstance } from 'axios';\nimport {\n type CreateSignRequestParams,\n type CreateSignRequestResponse,\n type CompleteSignRequestParams,\n type CompleteSignRequestResponse,\n type SignRequestFile,\n} from '../types.js';\n\nexport class SignRequests {\n constructor(private client: AxiosInstance) { }\n\n /**\n * Create a new sign request\n */\n async create(params: CreateSignRequestParams): Promise<CreateSignRequestResponse | undefined> {\n const response = await this.client.post('/functions/createSignRequest', params);\n return response.data.result;\n }\n\n /**\n * Complete a sign request\n */\n async complete(params: CompleteSignRequestParams): Promise<CompleteSignRequestResponse | undefined> {\n const response = await this.client.post('/functions/completeSignRequest', params);\n return response.data.result;\n }\n\n /**\n * Get the file associated with a sign request\n */\n async getFile(requestId: string): Promise<SignRequestFile | undefined> {\n const response = await this.client.post('/functions/getFileFromRequestId', { requestId });\n return response.data.result;\n }\n}","import * as crypto from 'node:crypto';\nimport { WebhookEvent } from '../types';\n\nexport class Webhooks {\n constructor(private tolerance: number = 300) { }\n\n /**\n * Verify and parse a webhook event\n */\n public constructEvent(payload: string, signatureHeader: string, webhookSecret: string): WebhookEvent {\n const parts = signatureHeader.split(',');\n const timestamp = parts.find((p) => p.startsWith('t='))?.split('=')[1];\n const signature = parts.find((p) => p.startsWith('v1='))?.split('=')[1];\n\n if (!timestamp || !signature) {\n throw new Error('Invalid signature header');\n }\n\n const now = Math.floor(Date.now() / 1000);\n if (Math.abs(now - parseInt(timestamp)) > this.tolerance) {\n throw new Error('Signature too old');\n }\n\n const signedPayload = `${timestamp}.${payload}`;\n const expectedSignature = crypto\n .createHmac('sha256', webhookSecret)\n .update(signedPayload)\n .digest('hex');\n\n const isValid = crypto.timingSafeEqual(\n Buffer.from(signature),\n Buffer.from(expectedSignature)\n );\n\n if (!isValid) {\n throw new Error('Invalid signature');\n }\n\n return JSON.parse(payload) as WebhookEvent;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAqC;;;ACe9B,IAAM,YAAN,MAAgB;AAAA,EACnB,YAAoB,QAAuB;AAAvB;AAAA,EAAyB;AAAA;AAAA;AAAA;AAAA,EAK7C,MAAM,OAAO,QAA2E;AACpF,UAAM,WAAW,MAAM,KAAK,OAAO,KAAK,6BAA6B,MAAM;AAC3E,WAAO,SAAS,KAAK;AAAA,EACzB;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,KAAK,SAA6B,CAAC,GAA4C;AACjF,UAAM,WAAW,MAAM,KAAK,OAAO,KAAK,2BAA2B,MAAM;AACzE,WAAO,SAAS,KAAK;AAAA,EACzB;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,IAAI,YAAmD;AACzD,UAAM,WAAW,MAAM,KAAK,OAAO,KAAK,0BAA0B,EAAE,WAAW,CAAC;AAChF,WAAO,SAAS,KAAK;AAAA,EACzB;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,SAAS,YAA4D;AACvE,UAAM,WAAW,MAAM,KAAK,OAAO,KAAK,+BAA+B,EAAE,WAAW,CAAC;AACrF,WAAO,SAAS,KAAK;AAAA,EACzB;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,OAAO,YAA4D;AACrE,UAAM,WAAW,MAAM,KA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AAChD,SAAK,WAAW,IAAI,SAAS,OAAO,oBAAoB,GAAG;AAAA,EAC7D;AACF;","names":["axios"]}
package/dist/index.d.cts CHANGED
@@ -135,6 +135,21 @@ type WebhookEvent = {
135
135
  eventType: T;
136
136
  } & WebhookPayloadMap[T];
137
137
  }[WebhookEventType];
138
+ type EnvelopeCreatedEvent = Extract<WebhookEvent, {
139
+ eventType: 'envelope_created';
140
+ }>;
141
+ type EnvelopeExpiredEvent = Extract<WebhookEvent, {
142
+ eventType: 'envelope_expired';
143
+ }>;
144
+ type SignRequestCreatedEvent = Extract<WebhookEvent, {
145
+ eventType: 'sign_request_created';
146
+ }>;
147
+ type SignRequestSignedEvent = Extract<WebhookEvent, {
148
+ eventType: 'sign_request_signed';
149
+ }>;
150
+ type SignRequestExpiredEvent = Extract<WebhookEvent, {
151
+ eventType: 'sign_request_expired';
152
+ }>;
138
153
 
139
154
  declare class Envelopes {
140
155
  private client;
@@ -1403,4 +1418,4 @@ declare class Instasign {
1403
1418
  constructor(config: IInstasignConfig);
1404
1419
  }
1405
1420
 
1406
- export { type $defs, Envelopes, type IInstasignConfig, Instasign, SignRequests, Webhooks, type components, type operations, type paths, type webhooks };
1421
+ export { type $defs, type AddSignRequestToEnvelopeParams, type AddSignRequestToEnvelopeResponse, type CompleteSignRequestParams, type CompleteSignRequestResponse, type CreateEnvelopeParams, type CreateEnvelopeResponse, type CreateSignRequestParams, type CreateSignRequestResponse, type Envelope, type EnvelopeCreatedEvent, type EnvelopeExpiredEvent, type EnvelopeListItem, type EnvelopeSignRequest, Envelopes, type GetEnvelopesParams, type IInstasignConfig, Instasign, type Metadata, type OperationResponse, type RemoveSignRequestFromEnvelopeParams, type SignRequestCreatedEvent, type SignRequestExpiredEvent, type SignRequestFile, type SignRequestSignedEvent, SignRequests, type UpdateEnvelopeMetadataParams, type UpdateEnvelopeMetadataResponse, type WebhookEvent, Webhooks, type components, type operations, type paths, type webhooks };
package/dist/index.d.ts CHANGED
@@ -135,6 +135,21 @@ type WebhookEvent = {
135
135
  eventType: T;
136
136
  } & WebhookPayloadMap[T];
137
137
  }[WebhookEventType];
138
+ type EnvelopeCreatedEvent = Extract<WebhookEvent, {
139
+ eventType: 'envelope_created';
140
+ }>;
141
+ type EnvelopeExpiredEvent = Extract<WebhookEvent, {
142
+ eventType: 'envelope_expired';
143
+ }>;
144
+ type SignRequestCreatedEvent = Extract<WebhookEvent, {
145
+ eventType: 'sign_request_created';
146
+ }>;
147
+ type SignRequestSignedEvent = Extract<WebhookEvent, {
148
+ eventType: 'sign_request_signed';
149
+ }>;
150
+ type SignRequestExpiredEvent = Extract<WebhookEvent, {
151
+ eventType: 'sign_request_expired';
152
+ }>;
138
153
 
139
154
  declare class Envelopes {
140
155
  private client;
@@ -1403,4 +1418,4 @@ declare class Instasign {
1403
1418
  constructor(config: IInstasignConfig);
1404
1419
  }
1405
1420
 
1406
- export { type $defs, Envelopes, type IInstasignConfig, Instasign, SignRequests, Webhooks, type components, type operations, type paths, type webhooks };
1421
+ export { type $defs, type AddSignRequestToEnvelopeParams, type AddSignRequestToEnvelopeResponse, type CompleteSignRequestParams, type CompleteSignRequestResponse, type CreateEnvelopeParams, type CreateEnvelopeResponse, type CreateSignRequestParams, type CreateSignRequestResponse, type Envelope, type EnvelopeCreatedEvent, type EnvelopeExpiredEvent, type EnvelopeListItem, type EnvelopeSignRequest, Envelopes, type GetEnvelopesParams, type IInstasignConfig, Instasign, type Metadata, type OperationResponse, type RemoveSignRequestFromEnvelopeParams, type SignRequestCreatedEvent, type SignRequestExpiredEvent, type SignRequestFile, type SignRequestSignedEvent, SignRequests, type UpdateEnvelopeMetadataParams, type UpdateEnvelopeMetadataResponse, type WebhookEvent, Webhooks, type components, type operations, type paths, type webhooks };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/resources/Envelopes.ts","../src/resources/SignRequests.ts","../src/resources/Webhooks.ts"],"sourcesContent":["import axios, { AxiosInstance } from 'axios';\nimport { Envelopes } from './resources/Envelopes.js';\nimport { SignRequests } from './resources/SignRequests.js';\nimport { Webhooks } from './resources/Webhooks.js';\n\nexport * from './resources/Envelopes.js';\nexport * from './resources/SignRequests.js';\nexport * from './resources/Webhooks.js';\n\nexport type * from '../types/schema.js';\n\nexport interface IInstasignConfig {\n /// Required Instasign API key\n apiKey: string;\n\n /// Optional Parse Server config\n appId?: string;\n restApiKey?: string;\n serverUrl?: string;\n /// Optional webhook signature tolerance in seconds (default 300)\n webhookTolerance?: number;\n}\n\nexport class Instasign {\n private client: AxiosInstance;\n\n public envelopes: Envelopes;\n public signRequests: SignRequests;\n public webhooks: Webhooks;\n\n constructor(config: IInstasignConfig) {\n this.client = axios.create({\n baseURL: config.serverUrl || 'https://parseapi.back4app.com',\n headers: {\n 'X-Parse-APPLICATION-ID': config.appId || 'jKFo8BFQRdiAUV4F3o3SIDWLpLUb2TVW7bVl7lwH',\n 'X-Parse-REST-API-KEY': config.restApiKey || 'Gjm9pmxZh0DjXHkcFlf0kGZjHfYEY4ERw71TvLig',\n 'x-api-key': config.apiKey,\n 'Content-Type': 'application/json',\n },\n });\n\n this.envelopes = new Envelopes(this.client);\n this.signRequests = new SignRequests(this.client);\n this.webhooks = new Webhooks(config.webhookTolerance ?? 300);\n }\n}\n\n","import { AxiosInstance } from 'axios';\nimport {\n type CreateEnvelopeParams,\n type CreateEnvelopeResponse,\n type GetEnvelopesParams,\n type EnvelopeListItem,\n type Envelope,\n type OperationResponse,\n type UpdateEnvelopeMetadataParams,\n type UpdateEnvelopeMetadataResponse,\n type RemoveSignRequestFromEnvelopeParams,\n type AddSignRequestToEnvelopeParams,\n type AddSignRequestToEnvelopeResponse,\n} from '../types.js';\n\nexport class Envelopes {\n constructor(private client: AxiosInstance) { }\n\n /**\n * Create a new envelope\n */\n async create(params: CreateEnvelopeParams): Promise<CreateEnvelopeResponse | undefined> {\n const response = await this.client.post('/functions/createEnvelope', params);\n return response.data.result;\n }\n\n /**\n * List envelopes\n */\n async list(params: GetEnvelopesParams = {}): Promise<EnvelopeListItem[] | undefined> {\n const response = await this.client.post('/functions/getEnvelopes', params);\n return response.data.result;\n }\n\n /**\n * Retrieve a single envelope with its sign requests\n */\n async get(envelopeId: string): Promise<Envelope | undefined> {\n const response = await this.client.post('/functions/getEnvelope', { envelopeId });\n return response.data.result;\n }\n\n /**\n * Complete an envelope\n */\n async complete(envelopeId: string): Promise<OperationResponse | undefined> {\n const response = await this.client.post('/functions/completeEnvelope', { envelopeId });\n return response.data.result;\n }\n\n /**\n * Delete an envelope\n */\n async delete(envelopeId: string): Promise<OperationResponse | undefined> {\n const response = await this.client.post('/functions/deleteEnvelope', { envelopeId });\n return response.data.result;\n }\n\n /**\n * Update envelope metadata\n */\n async updateMetadata(params: UpdateEnvelopeMetadataParams): Promise<UpdateEnvelopeMetadataResponse | undefined> {\n const response = await this.client.post('/functions/updateEnvelopeMetadata', params);\n return response.data.result;\n }\n\n /**\n * Remove a sign request from an envelope\n */\n async removeSignRequest(params: RemoveSignRequestFromEnvelopeParams): Promise<OperationResponse | undefined> {\n const response = await this.client.post('/functions/removeSignRequestFromEnvelope', params);\n return response.data.result;\n }\n\n /**\n * Add a sign request to an envelope\n */\n async addSignRequest(params: AddSignRequestToEnvelopeParams): Promise<AddSignRequestToEnvelopeResponse | undefined> {\n const response = await this.client.post('/functions/addSignRequestToEnvelope', params);\n return response.data.result;\n }\n\n /**\n * Add multiple sign requests to an envelope\n */\n // async addSignRequests(params: AddSignRequestToEnvelopeParams[]): Promise<AddSignRequestToEnvelopeResponse[] | undefined> {\n // // TODO(ciro): must be implemented on back-end\n // const response = await this.client.post('/functions/addMultipleSignRequestsToEnvelope', params);\n // return response.data.result;\n // }\n}","import { AxiosInstance } from 'axios';\nimport {\n type CreateSignRequestParams,\n type CreateSignRequestResponse,\n type CompleteSignRequestParams,\n type CompleteSignRequestResponse,\n type SignRequestFile,\n} from '../types.js';\n\nexport class SignRequests {\n constructor(private client: AxiosInstance) { }\n\n /**\n * Create a new sign request\n */\n async create(params: CreateSignRequestParams): Promise<CreateSignRequestResponse | undefined> {\n const response = await this.client.post('/functions/createSignRequest', params);\n return response.data.result;\n }\n\n /**\n * Complete a sign request\n */\n async complete(params: CompleteSignRequestParams): Promise<CompleteSignRequestResponse | undefined> {\n const response = await this.client.post('/functions/completeSignRequest', params);\n return response.data.result;\n }\n\n /**\n * Get the file associated with a sign request\n */\n async getFile(requestId: string): Promise<SignRequestFile | undefined> {\n const response = await this.client.post('/functions/getFileFromRequestId', { requestId });\n return response.data.result;\n }\n}","import * as crypto from 'node:crypto';\nimport { WebhookEvent } from '../types';\n\nexport class Webhooks {\n constructor(private tolerance: number = 300) { }\n\n /**\n * Verify and parse a webhook event\n */\n public constructEvent(payload: string, signatureHeader: string, webhookSecret: string): WebhookEvent {\n const parts = signatureHeader.split(',');\n const timestamp = parts.find((p) => p.startsWith('t='))?.split('=')[1];\n const signature = parts.find((p) => p.startsWith('v1='))?.split('=')[1];\n\n if (!timestamp || !signature) {\n throw new Error('Invalid signature header');\n }\n\n const now = Math.floor(Date.now() / 1000);\n if (Math.abs(now - parseInt(timestamp)) > this.tolerance) {\n throw new Error('Signature too old');\n }\n\n const signedPayload = `${timestamp}.${payload}`;\n const expectedSignature = crypto\n .createHmac('sha256', webhookSecret)\n .update(signedPayload)\n .digest('hex');\n\n const isValid = crypto.timingSafeEqual(\n Buffer.from(signature),\n Buffer.from(expectedSignature)\n );\n\n if (!isValid) {\n throw new Error('Invalid signature');\n }\n\n return JSON.parse(payload) as WebhookEvent;\n }\n}\n"],"mappings":";AAAA,OAAO,WAA8B;;;ACe9B,IAAM,YAAN,MAAgB;AAAA,EACnB,YAAoB,QAAuB;AAAvB;AAAA,EAAyB;AAAA;AAAA;AAAA;AAAA,EAK7C,MAAM,OAAO,QAA2E;AACpF,UAAM,WAAW,MAAM,KAAK,OAAO,KAAK,6BAA6B,MAAM;AAC3E,WAAO,SAAS,KAAK;AAAA,EACzB;AAAA;AAAA;AAAA;AAAA,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,QAAI,CAAC,SAAS;AACV,YAAM,IAAI,MAAM,mBAAmB;AAAA,IACvC;AAEA,WAAO,KAAK,MAAM,OAAO;AAAA,EAC7B;AACJ;;;AHjBO,IAAM,YAAN,MAAgB;AAAA,EACb;AAAA,EAED;AAAA,EACA;AAAA,EACA;AAAA,EAEP,YAAY,QAA0B;AACpC,SAAK,SAAS,MAAM,OAAO;AAAA,MACzB,SAAS,OAAO,aAAa;AAAA,MAC7B,SAAS;AAAA,QACP,0BAA0B,OAAO,SAAS;AAAA,QAC1C,wBAAwB,OAAO,cAAc;AAAA,QAC7C,aAAa,OAAO;AAAA,QACpB,gBAAgB;AAAA,MAClB;AAAA,IACF,CAAC;AAED,SAAK,YAAY,IAAI,UAAU,KAAK,MAAM;AAC1C,SAAK,eAAe,IAAI,aAAa,KAAK,MAAM;AAChD,SAAK,WAAW,IAAI,SAAS,OAAO,oBAAoB,GAAG;AAAA,EAC7D;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts","../src/resources/Envelopes.ts","../src/resources/SignRequests.ts","../src/resources/Webhooks.ts"],"sourcesContent":["import axios, { AxiosInstance } from 'axios';\nimport { Envelopes } from './resources/Envelopes.js';\nimport { SignRequests } from './resources/SignRequests.js';\nimport { Webhooks } from './resources/Webhooks.js';\n\nexport * from './resources/Envelopes.js';\nexport * from './resources/SignRequests.js';\nexport * from './resources/Webhooks.js';\nexport * from './types.js';\n\nexport type * from '../types/schema.js';\n\nexport interface IInstasignConfig {\n /// Required Instasign API key\n apiKey: string;\n\n /// Optional Parse Server config\n appId?: string;\n restApiKey?: string;\n serverUrl?: string;\n /// Optional webhook signature tolerance in seconds (default 300)\n webhookTolerance?: number;\n}\n\nexport class Instasign {\n private client: AxiosInstance;\n\n public envelopes: Envelopes;\n public signRequests: SignRequests;\n public webhooks: Webhooks;\n\n constructor(config: IInstasignConfig) {\n this.client = axios.create({\n baseURL: config.serverUrl || 'https://parseapi.back4app.com',\n headers: {\n 'X-Parse-APPLICATION-ID': config.appId || 'jKFo8BFQRdiAUV4F3o3SIDWLpLUb2TVW7bVl7lwH',\n 'X-Parse-REST-API-KEY': config.restApiKey || 'Gjm9pmxZh0DjXHkcFlf0kGZjHfYEY4ERw71TvLig',\n 'x-api-key': config.apiKey,\n 'Content-Type': 'application/json',\n },\n });\n\n this.envelopes = new Envelopes(this.client);\n this.signRequests = new SignRequests(this.client);\n this.webhooks = new Webhooks(config.webhookTolerance ?? 300);\n }\n}\n\n","import { AxiosInstance } from 'axios';\nimport {\n type CreateEnvelopeParams,\n type CreateEnvelopeResponse,\n type GetEnvelopesParams,\n type EnvelopeListItem,\n type Envelope,\n type OperationResponse,\n type UpdateEnvelopeMetadataParams,\n type UpdateEnvelopeMetadataResponse,\n type RemoveSignRequestFromEnvelopeParams,\n type AddSignRequestToEnvelopeParams,\n type AddSignRequestToEnvelopeResponse,\n} from '../types.js';\n\nexport class Envelopes {\n constructor(private client: AxiosInstance) { }\n\n /**\n * Create a new envelope\n */\n async create(params: CreateEnvelopeParams): Promise<CreateEnvelopeResponse | undefined> {\n const response = await this.client.post('/functions/createEnvelope', params);\n return response.data.result;\n }\n\n /**\n * List envelopes\n */\n async list(params: GetEnvelopesParams = {}): Promise<EnvelopeListItem[] | undefined> {\n const response = await this.client.post('/functions/getEnvelopes', params);\n return response.data.result;\n }\n\n /**\n * Retrieve a single envelope with its sign requests\n */\n async get(envelopeId: string): Promise<Envelope | undefined> {\n const response = await this.client.post('/functions/getEnvelope', { envelopeId });\n return response.data.result;\n }\n\n /**\n * Complete an envelope\n */\n async complete(envelopeId: string): Promise<OperationResponse | undefined> {\n const response = await this.client.post('/functions/completeEnvelope', { envelopeId });\n return response.data.result;\n }\n\n /**\n * Delete an envelope\n */\n async delete(envelopeId: string): Promise<OperationResponse | undefined> {\n const response = await this.client.post('/functions/deleteEnvelope', { envelopeId });\n return response.data.result;\n }\n\n /**\n * Update envelope metadata\n */\n async updateMetadata(params: UpdateEnvelopeMetadataParams): Promise<UpdateEnvelopeMetadataResponse | undefined> {\n const response = await this.client.post('/functions/updateEnvelopeMetadata', params);\n return response.data.result;\n }\n\n /**\n * Remove a sign request from an envelope\n */\n async removeSignRequest(params: RemoveSignRequestFromEnvelopeParams): Promise<OperationResponse | undefined> {\n const response = await this.client.post('/functions/removeSignRequestFromEnvelope', params);\n return response.data.result;\n }\n\n /**\n * Add a sign request to an envelope\n */\n async addSignRequest(params: AddSignRequestToEnvelopeParams): Promise<AddSignRequestToEnvelopeResponse | undefined> {\n const response = await this.client.post('/functions/addSignRequestToEnvelope', params);\n return response.data.result;\n }\n\n /**\n * Add multiple sign requests to an envelope\n */\n // async addSignRequests(params: AddSignRequestToEnvelopeParams[]): Promise<AddSignRequestToEnvelopeResponse[] | undefined> {\n // // TODO(ciro): must be implemented on back-end\n // const response = await this.client.post('/functions/addMultipleSignRequestsToEnvelope', params);\n // return response.data.result;\n // }\n}","import { AxiosInstance } from 'axios';\nimport {\n type CreateSignRequestParams,\n type CreateSignRequestResponse,\n type CompleteSignRequestParams,\n type CompleteSignRequestResponse,\n type SignRequestFile,\n} from '../types.js';\n\nexport class SignRequests {\n constructor(private client: AxiosInstance) { }\n\n /**\n * Create a new sign request\n */\n async create(params: CreateSignRequestParams): Promise<CreateSignRequestResponse | undefined> {\n const response = await this.client.post('/functions/createSignRequest', params);\n return response.data.result;\n }\n\n /**\n * Complete a sign request\n */\n async complete(params: CompleteSignRequestParams): Promise<CompleteSignRequestResponse | undefined> {\n const response = await this.client.post('/functions/completeSignRequest', params);\n return response.data.result;\n }\n\n /**\n * Get the file associated with a sign request\n */\n async getFile(requestId: string): Promise<SignRequestFile | undefined> {\n const response = await this.client.post('/functions/getFileFromRequestId', { requestId });\n return response.data.result;\n }\n}","import * as crypto from 'node:crypto';\nimport { WebhookEvent } from '../types';\n\nexport class Webhooks {\n constructor(private tolerance: number = 300) { }\n\n /**\n * Verify and parse a webhook event\n */\n public constructEvent(payload: string, signatureHeader: string, webhookSecret: string): WebhookEvent {\n const parts = signatureHeader.split(',');\n const timestamp = parts.find((p) => p.startsWith('t='))?.split('=')[1];\n const signature = parts.find((p) => p.startsWith('v1='))?.split('=')[1];\n\n if (!timestamp || !signature) {\n throw new Error('Invalid signature header');\n }\n\n const now = Math.floor(Date.now() / 1000);\n if (Math.abs(now - parseInt(timestamp)) > this.tolerance) {\n throw new Error('Signature too old');\n }\n\n const signedPayload = `${timestamp}.${payload}`;\n const expectedSignature = crypto\n .createHmac('sha256', webhookSecret)\n .update(signedPayload)\n .digest('hex');\n\n const isValid = crypto.timingSafeEqual(\n Buffer.from(signature),\n Buffer.from(expectedSignature)\n );\n\n if (!isValid) {\n throw new Error('Invalid signature');\n }\n\n return JSON.parse(payload) as WebhookEvent;\n }\n}\n"],"mappings":";AAAA,OAAO,WAA8B;;;ACe9B,IAAM,YAAN,MAAgB;AAAA,EACnB,YAAoB,QAAuB;AAAvB;AAAA,EAAyB;AAAA;AAAA;AAAA;AAAA,EAK7C,MAAM,OAAO,QAA2E;AACpF,UAAM,WAAW,MAAM,KAAK,OAAO,KAAK,6BAA6B,MAAM;AAC3E,WAAO,SAAS,KAAK;AAAA,EACzB;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,KAAK,SAA6B,CAAC,GAA4C;AACjF,UAAM,WAAW,MAAM,KAAK,OAAO,KAAK,2BAA2B,MAAM;AACzE,WAAO,SAAS,KAAK;AAAA,EACzB;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,IAAI,YAAmD;AACzD,UAAM,WAAW,MAAM,KAAK,OAAO,KAAK,0BAA0B,EAAE,WAAW,CAAC;AAChF,WAAO,SAAS,KAAK;AAAA,EACzB;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,SAAS,YAA4D;AACvE,UAAM,WAAW,MAAM,KAAK,OAAO,KAAK,+BAA+B,EAAE,WAAW,CAAC;AACrF,WAAO,SAAS,KAAK;AAAA,EACzB;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,OAAO,YAA4D;AACrE,UAAM,WAAW,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MAAM;AAChD,SAAK,WAAW,IAAI,SAAS,OAAO,oBAAoB,GAAG;AAAA,EAC7D;AACF;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "instasign",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "Instasign API wrapper",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -45,12 +45,12 @@
45
45
  ],
46
46
  "license": "Apache-2.0",
47
47
  "dependencies": {
48
- "axios": "^1.12.2",
49
- "@instasign/types": "*"
48
+ "axios": "^1.12.2"
50
49
  },
51
50
  "devDependencies": {
52
51
  "tsup": "^8.0.0",
53
52
  "typescript": "^5.8.0",
54
- "@types/node": "^22.0.0"
53
+ "@types/node": "^22.0.0",
54
+ "@instasign/types": "*"
55
55
  }
56
56
  }