@zyphr-dev/node-sdk 0.1.21 → 0.1.23

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zyphr-dev/node-sdk",
3
- "version": "0.1.21",
3
+ "version": "0.1.23",
4
4
  "description": "Official Zyphr SDK for Node.js, React, and React Native",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -28,6 +28,9 @@
28
28
  "build": "tsup",
29
29
  "lint": "tsc --noEmit",
30
30
  "test": "echo 'No tests yet for generated SDK'",
31
+ "examples:typecheck": "tsc --noEmit -p examples/tsconfig.json",
32
+ "readme:check": "node ../scripts/verify-readme-methods.mjs",
33
+ "verify": "yarn lint && yarn examples:typecheck && yarn readme:check",
31
34
  "clean": "rm -rf dist"
32
35
  },
33
36
  "devDependencies": {
package/src/errors.ts CHANGED
@@ -82,6 +82,26 @@ export class ZyphrNotFoundError extends ZyphrError {
82
82
  }
83
83
  }
84
84
 
85
+ /**
86
+ * Thrown when a Zyphr webhook signature fails verification.
87
+ *
88
+ * Use the verification helper shown in `examples/14-webhook-handler.ts`
89
+ * (or write your own) to detect tampered or replayed webhook deliveries.
90
+ */
91
+ export class ZyphrWebhookVerificationError extends ZyphrError {
92
+ constructor(message: string) {
93
+ super({ message, status: 401, code: 'webhook_verification_failed' });
94
+ this.name = 'ZyphrWebhookVerificationError';
95
+ }
96
+ }
97
+
98
+ /**
99
+ * Alias for {@link ZyphrWebhookVerificationError}. Provided for symmetry with
100
+ * `Zyphr*Error` naming and shorter import statements in webhook handlers.
101
+ */
102
+ export const WebhookVerificationError = ZyphrWebhookVerificationError;
103
+ export type WebhookVerificationError = ZyphrWebhookVerificationError;
104
+
85
105
  /**
86
106
  * Parse an API error response and throw the appropriate ZyphrError subclass.
87
107
  */
@@ -49,12 +49,6 @@ export interface CreateTemplateRequest {
49
49
  * @memberof CreateTemplateRequest
50
50
  */
51
51
  text?: string;
52
- /**
53
- * Default variable values
54
- * @type {{ [key: string]: any; }}
55
- * @memberof CreateTemplateRequest
56
- */
57
- variables?: { [key: string]: any; };
58
52
  }
59
53
 
60
54
  /**
@@ -80,7 +74,6 @@ export function CreateTemplateRequestFromJSONTyped(json: any, ignoreDiscriminato
80
74
  'subject': json['subject'] == null ? undefined : json['subject'],
81
75
  'html': json['html'] == null ? undefined : json['html'],
82
76
  'text': json['text'] == null ? undefined : json['text'],
83
- 'variables': json['variables'] == null ? undefined : json['variables'],
84
77
  };
85
78
  }
86
79
 
@@ -100,7 +93,6 @@ export function CreateTemplateRequestToJSONTyped(value?: CreateTemplateRequest |
100
93
  'subject': value['subject'],
101
94
  'html': value['html'],
102
95
  'text': value['text'],
103
- 'variables': value['variables'],
104
96
  };
105
97
  }
106
98
 
@@ -56,11 +56,13 @@ export interface Template {
56
56
  */
57
57
  text?: string | null;
58
58
  /**
59
+ * Variable names auto-detected from `{{var}}` placeholders in subject,
60
+ * html, and text. Server-derived; ignored if supplied on create/update.
59
61
  *
60
- * @type {object}
62
+ * @type {Array<string>}
61
63
  * @memberof Template
62
64
  */
63
- variables?: object | null;
65
+ readonly variables?: Array<string> | null;
64
66
  /**
65
67
  *
66
68
  * @type {number}
@@ -115,7 +117,7 @@ export function TemplateToJSON(json: any): Template {
115
117
  return TemplateToJSONTyped(json, false);
116
118
  }
117
119
 
118
- export function TemplateToJSONTyped(value?: Template | null, ignoreDiscriminator: boolean = false): any {
120
+ export function TemplateToJSONTyped(value?: Omit<Template, 'variables'> | null, ignoreDiscriminator: boolean = false): any {
119
121
  if (value == null) {
120
122
  return value;
121
123
  }
@@ -128,7 +130,6 @@ export function TemplateToJSONTyped(value?: Template | null, ignoreDiscriminator
128
130
  'subject': value['subject'],
129
131
  'html': value['html'],
130
132
  'text': value['text'],
131
- 'variables': value['variables'],
132
133
  'version': value['version'],
133
134
  'created_at': value['createdAt'] == null ? undefined : ((value['createdAt']).toISOString()),
134
135
  'updated_at': value['updatedAt'] == null ? undefined : ((value['updatedAt']).toISOString()),
@@ -49,12 +49,6 @@ export interface UpdateTemplateRequest {
49
49
  * @memberof UpdateTemplateRequest
50
50
  */
51
51
  text?: string;
52
- /**
53
- *
54
- * @type {{ [key: string]: any; }}
55
- * @memberof UpdateTemplateRequest
56
- */
57
- variables?: { [key: string]: any; };
58
52
  }
59
53
 
60
54
  /**
@@ -79,7 +73,6 @@ export function UpdateTemplateRequestFromJSONTyped(json: any, ignoreDiscriminato
79
73
  'subject': json['subject'] == null ? undefined : json['subject'],
80
74
  'html': json['html'] == null ? undefined : json['html'],
81
75
  'text': json['text'] == null ? undefined : json['text'],
82
- 'variables': json['variables'] == null ? undefined : json['variables'],
83
76
  };
84
77
  }
85
78
 
@@ -99,7 +92,6 @@ export function UpdateTemplateRequestToJSONTyped(value?: UpdateTemplateRequest |
99
92
  'subject': value['subject'],
100
93
  'html': value['html'],
101
94
  'text': value['text'],
102
- 'variables': value['variables'],
103
95
  };
104
96
  }
105
97