@shipstatic/types 0.1.11 → 0.1.12

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.ts CHANGED
@@ -217,11 +217,18 @@ export interface PingResponse {
217
217
  export declare const API_KEY_PREFIX = "ship-";
218
218
  export declare const API_KEY_HEX_LENGTH = 64;
219
219
  export declare const API_KEY_TOTAL_LENGTH: number;
220
+ export declare const DEPLOY_TOKEN_PREFIX = "token-";
221
+ export declare const DEPLOY_TOKEN_HEX_LENGTH = 64;
222
+ export declare const DEPLOY_TOKEN_TOTAL_LENGTH: number;
220
223
  export declare const DEPLOYMENT_CONFIG_FILENAME = "ship.json";
221
224
  /**
222
225
  * Validate API key format
223
226
  */
224
227
  export declare function validateApiKey(apiKey: string): void;
228
+ /**
229
+ * Validate deploy token format
230
+ */
231
+ export declare function validateDeployToken(deployToken: string): void;
225
232
  /**
226
233
  * Validate API URL format
227
234
  */
package/dist/index.js CHANGED
@@ -161,6 +161,10 @@ export const serverConfig = {
161
161
  export const API_KEY_PREFIX = 'ship-';
162
162
  export const API_KEY_HEX_LENGTH = 64;
163
163
  export const API_KEY_TOTAL_LENGTH = API_KEY_PREFIX.length + API_KEY_HEX_LENGTH; // 69
164
+ // Deploy Token Configuration
165
+ export const DEPLOY_TOKEN_PREFIX = 'token-';
166
+ export const DEPLOY_TOKEN_HEX_LENGTH = 64;
167
+ export const DEPLOY_TOKEN_TOTAL_LENGTH = DEPLOY_TOKEN_PREFIX.length + DEPLOY_TOKEN_HEX_LENGTH; // 70
164
168
  // Deployment Configuration
165
169
  export const DEPLOYMENT_CONFIG_FILENAME = 'ship.json';
166
170
  // =============================================================================
@@ -181,6 +185,21 @@ export function validateApiKey(apiKey) {
181
185
  throw ShipError.validation(`API key must contain ${API_KEY_HEX_LENGTH} hexadecimal characters after "${API_KEY_PREFIX}" prefix`);
182
186
  }
183
187
  }
188
+ /**
189
+ * Validate deploy token format
190
+ */
191
+ export function validateDeployToken(deployToken) {
192
+ if (!deployToken.startsWith(DEPLOY_TOKEN_PREFIX)) {
193
+ throw ShipError.validation(`Deploy token must start with "${DEPLOY_TOKEN_PREFIX}"`);
194
+ }
195
+ if (deployToken.length !== DEPLOY_TOKEN_TOTAL_LENGTH) {
196
+ throw ShipError.validation(`Deploy token must be ${DEPLOY_TOKEN_TOTAL_LENGTH} characters total (${DEPLOY_TOKEN_PREFIX} + ${DEPLOY_TOKEN_HEX_LENGTH} hex chars)`);
197
+ }
198
+ const hexPart = deployToken.slice(DEPLOY_TOKEN_PREFIX.length);
199
+ if (!/^[a-f0-9]{64}$/i.test(hexPart)) {
200
+ throw ShipError.validation(`Deploy token must contain ${DEPLOY_TOKEN_HEX_LENGTH} hexadecimal characters after "${DEPLOY_TOKEN_PREFIX}" prefix`);
201
+ }
202
+ }
184
203
  /**
185
204
  * Validate API URL format
186
205
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shipstatic/types",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "description": "Shared types for Shipstatic platform",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
package/src/index.ts CHANGED
@@ -360,6 +360,11 @@ export const API_KEY_PREFIX = 'ship-';
360
360
  export const API_KEY_HEX_LENGTH = 64;
361
361
  export const API_KEY_TOTAL_LENGTH = API_KEY_PREFIX.length + API_KEY_HEX_LENGTH; // 69
362
362
 
363
+ // Deploy Token Configuration
364
+ export const DEPLOY_TOKEN_PREFIX = 'token-';
365
+ export const DEPLOY_TOKEN_HEX_LENGTH = 64;
366
+ export const DEPLOY_TOKEN_TOTAL_LENGTH = DEPLOY_TOKEN_PREFIX.length + DEPLOY_TOKEN_HEX_LENGTH; // 70
367
+
363
368
  // Deployment Configuration
364
369
  export const DEPLOYMENT_CONFIG_FILENAME = 'ship.json';
365
370
 
@@ -385,6 +390,24 @@ export function validateApiKey(apiKey: string): void {
385
390
  }
386
391
  }
387
392
 
393
+ /**
394
+ * Validate deploy token format
395
+ */
396
+ export function validateDeployToken(deployToken: string): void {
397
+ if (!deployToken.startsWith(DEPLOY_TOKEN_PREFIX)) {
398
+ throw ShipError.validation(`Deploy token must start with "${DEPLOY_TOKEN_PREFIX}"`);
399
+ }
400
+
401
+ if (deployToken.length !== DEPLOY_TOKEN_TOTAL_LENGTH) {
402
+ throw ShipError.validation(`Deploy token must be ${DEPLOY_TOKEN_TOTAL_LENGTH} characters total (${DEPLOY_TOKEN_PREFIX} + ${DEPLOY_TOKEN_HEX_LENGTH} hex chars)`);
403
+ }
404
+
405
+ const hexPart = deployToken.slice(DEPLOY_TOKEN_PREFIX.length);
406
+ if (!/^[a-f0-9]{64}$/i.test(hexPart)) {
407
+ throw ShipError.validation(`Deploy token must contain ${DEPLOY_TOKEN_HEX_LENGTH} hexadecimal characters after "${DEPLOY_TOKEN_PREFIX}" prefix`);
408
+ }
409
+ }
410
+
388
411
  /**
389
412
  * Validate API URL format
390
413
  */