@shipstatic/types 2.5.0 → 2.6.0

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
@@ -1009,30 +1009,35 @@ export declare const AuthMethod: {
1009
1009
  };
1010
1010
  export type AuthMethodType = (typeof AuthMethod)[keyof typeof AuthMethod];
1011
1011
  /**
1012
- * Shape constants for API keys (`ship-{64 hex chars}`).
1012
+ * Shape constants for API keys (`ship-{32 hex chars}`).
1013
1013
  * Single source of truth used by validation utilities and auth middleware.
1014
1014
  */
1015
1015
  export declare const API_KEY: {
1016
1016
  /** Prefix that identifies an API key. */
1017
1017
  readonly PREFIX: "ship-";
1018
1018
  /** Number of hex characters following the prefix. */
1019
- readonly HEX_LENGTH: 64;
1020
- /** Total length of an API key including prefix (`PREFIX.length + HEX_LENGTH = 69`). */
1021
- readonly TOTAL_LENGTH: 69;
1019
+ readonly HEX_LENGTH: 32;
1020
+ /** Total length of an API key including prefix (`PREFIX.length + HEX_LENGTH = 37`). */
1021
+ readonly TOTAL_LENGTH: 37;
1022
1022
  /** Number of trailing characters used to display a redacted hint (e.g. last 4). */
1023
1023
  readonly HINT_LENGTH: 4;
1024
1024
  };
1025
1025
  /**
1026
- * Shape constants for deploy tokens (`deploy-{64 hex chars}`).
1026
+ * Shape constants for deploy tokens (`deploy-{32 hex chars}`).
1027
1027
  * Single source of truth used by validation utilities and auth middleware.
1028
+ *
1029
+ * Deliberately the same width as `API_KEY`: both are minted by one generator
1030
+ * and classified by prefix alone, so a length that differed between them
1031
+ * would be a second thing to know about a credential whose prefix already
1032
+ * says what it is.
1028
1033
  */
1029
1034
  export declare const DEPLOY_TOKEN: {
1030
1035
  /** Prefix that identifies a deploy token. */
1031
1036
  readonly PREFIX: "deploy-";
1032
1037
  /** Number of hex characters following the prefix. */
1033
- readonly HEX_LENGTH: 64;
1034
- /** Total length of a deploy token including prefix (`PREFIX.length + HEX_LENGTH = 71`). */
1035
- readonly TOTAL_LENGTH: 71;
1038
+ readonly HEX_LENGTH: 32;
1039
+ /** Total length of a deploy token including prefix (`PREFIX.length + HEX_LENGTH = 39`). */
1040
+ readonly TOTAL_LENGTH: 39;
1036
1041
  };
1037
1042
  /**
1038
1043
  * Shape constants for caller identifiers (the `X-Caller` instance-identity
package/dist/index.js CHANGED
@@ -886,6 +886,28 @@ export function hasUnbuiltMarker(filePath) {
886
886
  // that distinguish populations on the wire (API_KEY, DEPLOY_TOKEN, CALLER),
887
887
  // the single dispatch over them (TokenKind, classifyToken), and the
888
888
  // delegated-access scopes (OAuthScope).
889
+ //
890
+ // THE SHAPE LAW, in three clauses. Every secret the platform mints obeys it,
891
+ // and `tests/validation-constants.test.ts` holds all three mechanically.
892
+ //
893
+ // 1. ONE ENTROPY STANDARD. Every minted random secret is `HEX_LENGTH` hex
894
+ // characters — one width for the whole platform, so "how long is a
895
+ // credential" has a single answer rather than one per population.
896
+ //
897
+ // 2. A PREFIX MARKS A SHARED SLOT, AND NOTHING ELSE. API keys and deploy
898
+ // tokens both arrive as `Authorization: Bearer`, so something must say
899
+ // which population a value belongs to: that is what the prefix IS, and
900
+ // `classifyToken` below is its only reader. Secrets that arrive somewhere
901
+ // unambiguous carry none — the deployment claim code reaches its own
902
+ // route in its own field, inside a URL whose path already says `/claim/`,
903
+ // so a prefix there would be a second name for what the route states.
904
+ //
905
+ // 3. NO PREFIX IS A PREFIX OF ANOTHER. This is what makes the dispatch
906
+ // order-independent, and it is the reason the populations are named on
907
+ // different axes (`ship-` for the product, `deploy-` for the capability)
908
+ // rather than sharing a stem. A `ship-` / `ship-deploy-` pair reads tidier
909
+ // and is a trap: every deploy token would also match the API-key branch,
910
+ // leaving correctness resting on the order of two `if`s.
889
911
  /**
890
912
  * Where human identity is mounted on the API host. The API mounts Better
891
913
  * Auth at this path (sign-in, sign-out, session reads, admin impersonation)
@@ -913,30 +935,35 @@ export const AuthMethod = {
913
935
  SYSTEM: 'system',
914
936
  };
915
937
  /**
916
- * Shape constants for API keys (`ship-{64 hex chars}`).
938
+ * Shape constants for API keys (`ship-{32 hex chars}`).
917
939
  * Single source of truth used by validation utilities and auth middleware.
918
940
  */
919
941
  export const API_KEY = {
920
942
  /** Prefix that identifies an API key. */
921
943
  PREFIX: 'ship-',
922
944
  /** Number of hex characters following the prefix. */
923
- HEX_LENGTH: 64,
924
- /** Total length of an API key including prefix (`PREFIX.length + HEX_LENGTH = 69`). */
925
- TOTAL_LENGTH: 69,
945
+ HEX_LENGTH: 32,
946
+ /** Total length of an API key including prefix (`PREFIX.length + HEX_LENGTH = 37`). */
947
+ TOTAL_LENGTH: 37,
926
948
  /** Number of trailing characters used to display a redacted hint (e.g. last 4). */
927
949
  HINT_LENGTH: 4,
928
950
  };
929
951
  /**
930
- * Shape constants for deploy tokens (`deploy-{64 hex chars}`).
952
+ * Shape constants for deploy tokens (`deploy-{32 hex chars}`).
931
953
  * Single source of truth used by validation utilities and auth middleware.
954
+ *
955
+ * Deliberately the same width as `API_KEY`: both are minted by one generator
956
+ * and classified by prefix alone, so a length that differed between them
957
+ * would be a second thing to know about a credential whose prefix already
958
+ * says what it is.
932
959
  */
933
960
  export const DEPLOY_TOKEN = {
934
961
  /** Prefix that identifies a deploy token. */
935
962
  PREFIX: 'deploy-',
936
963
  /** Number of hex characters following the prefix. */
937
- HEX_LENGTH: 64,
938
- /** Total length of a deploy token including prefix (`PREFIX.length + HEX_LENGTH = 71`). */
939
- TOTAL_LENGTH: 71,
964
+ HEX_LENGTH: 32,
965
+ /** Total length of a deploy token including prefix (`PREFIX.length + HEX_LENGTH = 39`). */
966
+ TOTAL_LENGTH: 39,
940
967
  };
941
968
  /**
942
969
  * Shape constants for caller identifiers (the `X-Caller` instance-identity
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shipstatic/types",
3
- "version": "2.5.0",
3
+ "version": "2.6.0",
4
4
  "description": "Shared types for ShipStatic platform",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -13,6 +13,7 @@
13
13
  },
14
14
  "scripts": {
15
15
  "build": "tsc",
16
+ "prepack": "pnpm run build",
16
17
  "clean": "rm -rf dist",
17
18
  "test": "vitest",
18
19
  "lint": "biome check .",
@@ -47,5 +48,9 @@
47
48
  "@types/node": "^24.13.3",
48
49
  "typescript": "^5.9.3",
49
50
  "vitest": "^2.1.9"
51
+ },
52
+ "publishConfig": {
53
+ "access": "public",
54
+ "provenance": true
50
55
  }
51
56
  }
package/src/index.ts CHANGED
@@ -1541,6 +1541,28 @@ export interface PingResponse {
1541
1541
  // that distinguish populations on the wire (API_KEY, DEPLOY_TOKEN, CALLER),
1542
1542
  // the single dispatch over them (TokenKind, classifyToken), and the
1543
1543
  // delegated-access scopes (OAuthScope).
1544
+ //
1545
+ // THE SHAPE LAW, in three clauses. Every secret the platform mints obeys it,
1546
+ // and `tests/validation-constants.test.ts` holds all three mechanically.
1547
+ //
1548
+ // 1. ONE ENTROPY STANDARD. Every minted random secret is `HEX_LENGTH` hex
1549
+ // characters — one width for the whole platform, so "how long is a
1550
+ // credential" has a single answer rather than one per population.
1551
+ //
1552
+ // 2. A PREFIX MARKS A SHARED SLOT, AND NOTHING ELSE. API keys and deploy
1553
+ // tokens both arrive as `Authorization: Bearer`, so something must say
1554
+ // which population a value belongs to: that is what the prefix IS, and
1555
+ // `classifyToken` below is its only reader. Secrets that arrive somewhere
1556
+ // unambiguous carry none — the deployment claim code reaches its own
1557
+ // route in its own field, inside a URL whose path already says `/claim/`,
1558
+ // so a prefix there would be a second name for what the route states.
1559
+ //
1560
+ // 3. NO PREFIX IS A PREFIX OF ANOTHER. This is what makes the dispatch
1561
+ // order-independent, and it is the reason the populations are named on
1562
+ // different axes (`ship-` for the product, `deploy-` for the capability)
1563
+ // rather than sharing a stem. A `ship-` / `ship-deploy-` pair reads tidier
1564
+ // and is a trap: every deploy token would also match the API-key branch,
1565
+ // leaving correctness resting on the order of two `if`s.
1544
1566
 
1545
1567
  /**
1546
1568
  * Where human identity is mounted on the API host. The API mounts Better
@@ -1573,31 +1595,36 @@ export const AuthMethod = {
1573
1595
  export type AuthMethodType = (typeof AuthMethod)[keyof typeof AuthMethod];
1574
1596
 
1575
1597
  /**
1576
- * Shape constants for API keys (`ship-{64 hex chars}`).
1598
+ * Shape constants for API keys (`ship-{32 hex chars}`).
1577
1599
  * Single source of truth used by validation utilities and auth middleware.
1578
1600
  */
1579
1601
  export const API_KEY = {
1580
1602
  /** Prefix that identifies an API key. */
1581
1603
  PREFIX: 'ship-',
1582
1604
  /** Number of hex characters following the prefix. */
1583
- HEX_LENGTH: 64,
1584
- /** Total length of an API key including prefix (`PREFIX.length + HEX_LENGTH = 69`). */
1585
- TOTAL_LENGTH: 69,
1605
+ HEX_LENGTH: 32,
1606
+ /** Total length of an API key including prefix (`PREFIX.length + HEX_LENGTH = 37`). */
1607
+ TOTAL_LENGTH: 37,
1586
1608
  /** Number of trailing characters used to display a redacted hint (e.g. last 4). */
1587
1609
  HINT_LENGTH: 4,
1588
1610
  } as const;
1589
1611
 
1590
1612
  /**
1591
- * Shape constants for deploy tokens (`deploy-{64 hex chars}`).
1613
+ * Shape constants for deploy tokens (`deploy-{32 hex chars}`).
1592
1614
  * Single source of truth used by validation utilities and auth middleware.
1615
+ *
1616
+ * Deliberately the same width as `API_KEY`: both are minted by one generator
1617
+ * and classified by prefix alone, so a length that differed between them
1618
+ * would be a second thing to know about a credential whose prefix already
1619
+ * says what it is.
1593
1620
  */
1594
1621
  export const DEPLOY_TOKEN = {
1595
1622
  /** Prefix that identifies a deploy token. */
1596
1623
  PREFIX: 'deploy-',
1597
1624
  /** Number of hex characters following the prefix. */
1598
- HEX_LENGTH: 64,
1599
- /** Total length of a deploy token including prefix (`PREFIX.length + HEX_LENGTH = 71`). */
1600
- TOTAL_LENGTH: 71,
1625
+ HEX_LENGTH: 32,
1626
+ /** Total length of a deploy token including prefix (`PREFIX.length + HEX_LENGTH = 39`). */
1627
+ TOTAL_LENGTH: 39,
1601
1628
  } as const;
1602
1629
 
1603
1630
  /**