@immagin/client 0.2.4 → 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/README.md +6 -0
- package/dist/index.d.mts +7 -0
- package/dist/index.mjs +12 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -63,6 +63,12 @@ const adjusted = await client.images.url('photo.jpg', [
|
|
|
63
63
|
{ modulate: { brightness: 1.2, saturation: 0.8 } },
|
|
64
64
|
])
|
|
65
65
|
|
|
66
|
+
// Disable auto-orient (enabled by default)
|
|
67
|
+
const raw = await client.images.url('photo.jpg', [
|
|
68
|
+
{ autoOrient: false },
|
|
69
|
+
{ resize: { width: 800 } },
|
|
70
|
+
])
|
|
71
|
+
|
|
66
72
|
// Custom output format (default is WebP at quality 90)
|
|
67
73
|
const jpeg = await client.images.url(
|
|
68
74
|
'photo.jpg',
|
package/dist/index.d.mts
CHANGED
|
@@ -92,6 +92,8 @@ type ImageOperation = {
|
|
|
92
92
|
normalize: NormalizeOptions;
|
|
93
93
|
} | {
|
|
94
94
|
trim: TrimOptions;
|
|
95
|
+
} | {
|
|
96
|
+
autoOrient: boolean;
|
|
95
97
|
};
|
|
96
98
|
type OutputFormat = 'webp' | 'jpeg' | 'png' | 'gif' | 'jp2' | 'tiff' | 'avif' | 'heif';
|
|
97
99
|
interface OutputOptions {
|
|
@@ -146,6 +148,7 @@ interface CreateKeyResult {
|
|
|
146
148
|
interface ProjectInfo {
|
|
147
149
|
tenantId: string;
|
|
148
150
|
tenantSecret: string;
|
|
151
|
+
emailVerified: boolean;
|
|
149
152
|
}
|
|
150
153
|
interface ImmaginConfig {
|
|
151
154
|
apiKey: string;
|
|
@@ -185,6 +188,8 @@ declare class Immagin {
|
|
|
185
188
|
tenantId?: string;
|
|
186
189
|
/** @internal */
|
|
187
190
|
tenantSecret?: string;
|
|
191
|
+
/** @internal */
|
|
192
|
+
emailVerified?: boolean;
|
|
188
193
|
private _tenantInfoPromise?;
|
|
189
194
|
images: ImagesResource;
|
|
190
195
|
keys: KeysResource;
|
|
@@ -195,6 +200,8 @@ declare class Immagin {
|
|
|
195
200
|
tenantSecret: string;
|
|
196
201
|
}>;
|
|
197
202
|
/** @internal */
|
|
203
|
+
requireVerified(): Promise<void>;
|
|
204
|
+
/** @internal */
|
|
198
205
|
request<T>(method: string, path: string, options?: {
|
|
199
206
|
body?: unknown;
|
|
200
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) {
|