@davidvornholt/standards 0.15.0 → 0.15.1

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": "@davidvornholt/standards",
3
- "version": "0.15.0",
3
+ "version": "0.15.1",
4
4
  "description": "Bootstrap, synchronize, and validate davidvornholt/standards consumers",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -30,6 +30,7 @@
30
30
  "src/creds-cloudflare.ts",
31
31
  "src/creds-cloudflare-api.ts",
32
32
  "src/creds-cloudflare-condition.ts",
33
+ "src/creds-cloudflare-expiry.ts",
33
34
  "src/creds-cloudflare-pagination.ts",
34
35
  "src/creds-commands.ts",
35
36
  "src/creds-args.ts",
package/src/creds-add.ts CHANGED
@@ -2,6 +2,7 @@ import { commitCreatedCloudflareToken } from './creds-add-cloudflare-commit';
2
2
  import { findManagedDestinationCollision } from './creds-add-collision';
3
3
  import { resolveTokenPolicy } from './creds-add-policy';
4
4
  import { createAccountToken } from './creds-cloudflare';
5
+ import { cloudflareExpiresOn } from './creds-cloudflare-expiry';
5
6
  import { resolveContext, selectAccount } from './creds-dest';
6
7
  import { tokenNameOf } from './creds-naming';
7
8
  import {
@@ -117,7 +118,7 @@ export const runCredsAddCloudflare = async (
117
118
  return false;
118
119
  }
119
120
  const ttlDays = options.ttlDays ?? DEFAULT_TTL_DAYS;
120
- const expiresOn = new Date(Date.now() + ttlDays * DAY_MS).toISOString();
121
+ const expiresOn = cloudflareExpiresOn(Date.now() + ttlDays * DAY_MS);
121
122
  const created = await createAccountToken(account.accountId, account.token, {
122
123
  name,
123
124
  expiresOn,
@@ -0,0 +1,7 @@
1
+ // Cloudflare rejects fractional seconds in expires_on before creating the
2
+ // token; it requires whole-second RFC3339 like "2005-12-30T01:02:03Z".
3
+
4
+ const FRACTIONAL_SECONDS = /\.\d{3}Z$/u;
5
+
6
+ export const cloudflareExpiresOn = (epochMs: number): string =>
7
+ new Date(epochMs).toISOString().replace(FRACTIONAL_SECONDS, 'Z');
package/src/creds-plan.ts CHANGED
@@ -5,6 +5,7 @@
5
5
  // lifetime. Secret keys without a brokered token are simply unmanaged — most
6
6
  // secrets are — and are never touched. Execution lives in creds-plan-run.ts.
7
7
 
8
+ import { cloudflareExpiresOn } from './creds-cloudflare-expiry';
8
9
  import { parseTokenName } from './creds-naming';
9
10
  import { groupByIntersectingFootprint } from './creds-plan-groups';
10
11
  import type {
@@ -105,9 +106,9 @@ const dispositionOf = (
105
106
  format,
106
107
  policies: token.policies,
107
108
  condition: token.condition.value,
108
- replacementExpiresOn: new Date(
109
+ replacementExpiresOn: cloudflareExpiresOn(
109
110
  input.now.getTime() + expiry - issued,
110
- ).toISOString(),
111
+ ),
111
112
  reason: `expires ${token.expiresOn}`,
112
113
  },
113
114
  };