@immagin/client 0.2.5 → 1.0.3

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/dist/index.d.mts CHANGED
@@ -148,6 +148,7 @@ interface CreateKeyResult {
148
148
  interface ProjectInfo {
149
149
  tenantId: string;
150
150
  tenantSecret: string;
151
+ emailVerified: boolean;
151
152
  }
152
153
  interface ImmaginConfig {
153
154
  apiKey: string;
@@ -187,6 +188,8 @@ declare class Immagin {
187
188
  tenantId?: string;
188
189
  /** @internal */
189
190
  tenantSecret?: string;
191
+ /** @internal */
192
+ emailVerified?: boolean;
190
193
  private _tenantInfoPromise?;
191
194
  images: ImagesResource;
192
195
  keys: KeysResource;
@@ -197,6 +200,8 @@ declare class Immagin {
197
200
  tenantSecret: string;
198
201
  }>;
199
202
  /** @internal */
203
+ requireVerified(): Promise<void>;
204
+ /** @internal */
200
205
  request<T>(method: string, path: string, options?: {
201
206
  body?: unknown;
202
207
  params?: Record<string, string>;
package/dist/index.mjs CHANGED
@@ -54,6 +54,7 @@ var ImagesResource = class {
54
54
  this.client = client;
55
55
  }
56
56
  async url(key, edits, output) {
57
+ await this.client.requireVerified();
57
58
  const { tenantId, tenantSecret } = await this.client.resolveTenantInfo();
58
59
  const payload = { key };
59
60
  if (edits) {
@@ -65,6 +66,7 @@ var ImagesResource = class {
65
66
  return `https://${tenantId}.immag.in/${base64}?sig=${createHmac("sha256", tenantSecret).update(base64).digest("hex").slice(0, 16)}`;
66
67
  }
67
68
  async signUrl(key) {
69
+ await this.client.requireVerified();
68
70
  const contentType = mimeFromKey(key);
69
71
  return this.client.request("POST", "/v1/images/sign-url", { body: contentType ? {
70
72
  key,
@@ -72,6 +74,7 @@ var ImagesResource = class {
72
74
  } : { key } });
73
75
  }
74
76
  async upload(file, key) {
77
+ await this.client.requireVerified();
75
78
  const contentType = mimeFromFile(file) ?? mimeFromKey(key);
76
79
  const signResult = await this.client.request("POST", "/v1/images/sign-url", { body: contentType ? {
77
80
  key,
@@ -138,6 +141,8 @@ var Immagin = class {
138
141
  tenantId;
139
142
  /** @internal */
140
143
  tenantSecret;
144
+ /** @internal */
145
+ emailVerified;
141
146
  _tenantInfoPromise;
142
147
  images;
143
148
  keys;
@@ -159,6 +164,8 @@ var Immagin = class {
159
164
  if (!this._tenantInfoPromise) this._tenantInfoPromise = this.request("GET", "/v1/project").then((info) => {
160
165
  this.tenantId = info.tenantId;
161
166
  this.tenantSecret = info.tenantSecret;
167
+ this.emailVerified = info.emailVerified;
168
+ if (!info.emailVerified) console.warn("[immagin] Warning: Your account email is not verified. Please verify your email at console.immag.in to avoid service interruptions.");
162
169
  return info;
163
170
  }).catch((err) => {
164
171
  this._tenantInfoPromise = void 0;
@@ -167,6 +174,11 @@ var Immagin = class {
167
174
  return this._tenantInfoPromise;
168
175
  }
169
176
  /** @internal */
177
+ async requireVerified() {
178
+ await this.resolveTenantInfo();
179
+ if (this.emailVerified === false) throw new ImmaginError("Email not verified. Please verify your email at console.immag.in.", 403);
180
+ }
181
+ /** @internal */
170
182
  async request(method, path, options) {
171
183
  const url = new URL(path, this.baseUrl);
172
184
  if (options?.params) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@immagin/client",
3
- "version": "0.2.5",
3
+ "version": "1.0.3",
4
4
  "description": "Node.js and browser client for the Immagin image processing API",
5
5
  "type": "module",
6
6
  "license": "MIT",