@cdk8s/awscdk-resolver 0.0.645 → 0.0.646

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.
Files changed (38) hide show
  1. package/.jsii +3 -3
  2. package/lib/resolve.js +1 -1
  3. package/node_modules/@aws-sdk/client-cloudformation/dist-cjs/index.js +1 -1
  4. package/node_modules/@aws-sdk/client-cloudformation/package.json +3 -3
  5. package/node_modules/@aws-sdk/core/dist-cjs/submodules/protocols/index.js +1164 -1130
  6. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/AwsJsonRpcProtocol.js +2 -2
  7. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/AwsRestJsonProtocol.js +3 -3
  8. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v1/JsonShapeSerializer.js +5 -2
  9. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v2/JsonShapeSerializer2.js +42 -12
  10. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/AwsJson1_0Protocol.d.ts +2 -1
  11. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/AwsJson1_1Protocol.d.ts +2 -1
  12. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/AwsJsonRpcProtocol.d.ts +4 -3
  13. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/AwsRestJsonProtocol.d.ts +5 -3
  14. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/AwsJson1_0Protocol.d.ts +2 -1
  15. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/AwsJson1_1Protocol.d.ts +2 -1
  16. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/AwsJsonRpcProtocol.d.ts +3 -2
  17. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/AwsRestJsonProtocol.d.ts +4 -1
  18. package/node_modules/@aws-sdk/core/package.json +1 -1
  19. package/node_modules/@aws-sdk/credential-provider-env/package.json +2 -2
  20. package/node_modules/@aws-sdk/credential-provider-http/package.json +2 -2
  21. package/node_modules/@aws-sdk/credential-provider-ini/package.json +9 -9
  22. package/node_modules/@aws-sdk/credential-provider-login/dist-cjs/index.js +35 -28
  23. package/node_modules/@aws-sdk/credential-provider-login/dist-es/LoginCredentialsFetcher.js +35 -28
  24. package/node_modules/@aws-sdk/credential-provider-login/dist-types/LoginCredentialsFetcher.d.ts +1 -0
  25. package/node_modules/@aws-sdk/credential-provider-login/dist-types/ts3.4/LoginCredentialsFetcher.d.ts +1 -0
  26. package/node_modules/@aws-sdk/credential-provider-login/package.json +3 -3
  27. package/node_modules/@aws-sdk/credential-provider-node/package.json +7 -7
  28. package/node_modules/@aws-sdk/credential-provider-process/package.json +2 -2
  29. package/node_modules/@aws-sdk/credential-provider-sso/package.json +4 -4
  30. package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +3 -3
  31. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/cognito-identity/index.js +1 -1
  32. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/signin/index.js +1 -1
  33. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso/index.js +1 -1
  34. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso-oidc/index.js +1 -1
  35. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/index.js +1 -1
  36. package/node_modules/@aws-sdk/nested-clients/package.json +2 -2
  37. package/node_modules/@aws-sdk/token-providers/package.json +3 -3
  38. package/package.json +3 -3
@@ -1,7 +1,7 @@
1
1
  import { RpcProtocol } from "@smithy/core/protocols";
2
2
  import { deref, NormalizedSchema } from "@smithy/core/schema";
3
3
  import { ProtocolLib } from "../ProtocolLib";
4
- import { JsonCodec } from "./codec-v1/JsonCodec";
4
+ import { JsonCodec2 } from "./codec-v2/JsonCodec2";
5
5
  import { loadJsonRpcErrorCode } from "./parseJsonBody";
6
6
  export class AwsJsonRpcProtocol extends RpcProtocol {
7
7
  serializer;
@@ -18,7 +18,7 @@ export class AwsJsonRpcProtocol extends RpcProtocol {
18
18
  this.serviceTarget = serviceTarget;
19
19
  this.codec =
20
20
  jsonCodec ??
21
- new JsonCodec({
21
+ new JsonCodec2({
22
22
  timestampFormat: {
23
23
  useTrait: true,
24
24
  default: 7,
@@ -1,14 +1,14 @@
1
1
  import { HttpBindingProtocol, HttpInterceptingShapeDeserializer, HttpInterceptingShapeSerializer, } from "@smithy/core/protocols";
2
2
  import { NormalizedSchema } from "@smithy/core/schema";
3
3
  import { ProtocolLib } from "../ProtocolLib";
4
- import { JsonCodec } from "./codec-v1/JsonCodec";
4
+ import { JsonCodec2 } from "./codec-v2/JsonCodec2";
5
5
  import { loadRestJsonErrorCode } from "./parseJsonBody";
6
6
  export class AwsRestJsonProtocol extends HttpBindingProtocol {
7
7
  serializer;
8
8
  deserializer;
9
9
  codec;
10
10
  mixin = new ProtocolLib();
11
- constructor({ defaultNamespace, errorTypeRegistries, }) {
11
+ constructor({ defaultNamespace, errorTypeRegistries, jsonCodec, }) {
12
12
  super({
13
13
  defaultNamespace,
14
14
  errorTypeRegistries,
@@ -21,7 +21,7 @@ export class AwsRestJsonProtocol extends HttpBindingProtocol {
21
21
  httpBindings: true,
22
22
  jsonName: true,
23
23
  };
24
- this.codec = new JsonCodec(settings);
24
+ this.codec = jsonCodec ?? new JsonCodec2(settings);
25
25
  this.serializer = new HttpInterceptingShapeSerializer(this.codec.createSerializer(), settings);
26
26
  this.deserializer = new HttpInterceptingShapeDeserializer(this.codec.createDeserializer(), settings);
27
27
  }
@@ -108,7 +108,7 @@ export class JsonShapeSerializer extends SerdeContextConfig {
108
108
  }
109
109
  return out;
110
110
  }
111
- if (value instanceof Uint8Array && (ns.isBlobSchema() || ns.isDocumentSchema())) {
111
+ if (value instanceof Uint8Array && ns.isBlobSchema()) {
112
112
  if (ns === this.rootSchema) {
113
113
  return value;
114
114
  }
@@ -148,7 +148,7 @@ export class JsonShapeSerializer extends SerdeContextConfig {
148
148
  }
149
149
  return value;
150
150
  }
151
- if (typeof value === "number" && ns.isNumericSchema()) {
151
+ if (typeof value === "number") {
152
152
  if (Math.abs(value) === Infinity || isNaN(value)) {
153
153
  return String(value);
154
154
  }
@@ -165,6 +165,9 @@ export class JsonShapeSerializer extends SerdeContextConfig {
165
165
  }
166
166
  if (ns.isDocumentSchema()) {
167
167
  if (isObject) {
168
+ if (value instanceof Uint8Array) {
169
+ return (this.serdeContext?.base64Encoder ?? toBase64)(value);
170
+ }
168
171
  const out = Array.isArray(value) ? [] : {};
169
172
  for (const k in value) {
170
173
  const v = value[k];
@@ -2,7 +2,6 @@ import { determineTimestampFormat } from "@smithy/core/protocols";
2
2
  import { NormalizedSchema } from "@smithy/core/schema";
3
3
  import { dateToUtcString, generateIdempotencyToken, LazyJsonString, NumericValue, toBase64 } from "@smithy/core/serde";
4
4
  import { SerdeContextConfig } from "../../ConfigurableSerdeContext";
5
- import { writeKey } from "../../writeKey";
6
5
  import { JsonBytesStringAdapter } from "./JsonBytesStringAdapter";
7
6
  const encoder = new TextEncoder();
8
7
  const OPEN_BRACE = 0x7b;
@@ -304,7 +303,7 @@ export class JsonShapeSerializer2 extends SerdeContextConfig {
304
303
  return;
305
304
  }
306
305
  if (typeof value === "number") {
307
- if (ns.isNumericSchema() && (Math.abs(value) === Infinity || isNaN(value))) {
306
+ if (Math.abs(value) === Infinity || Number.isNaN(value)) {
308
307
  this.writeAsciiQuoted(String(value));
309
308
  return;
310
309
  }
@@ -396,7 +395,33 @@ export class JsonShapeSerializer2 extends SerdeContextConfig {
396
395
  const valueSchema = ns.getValueSchema();
397
396
  if (!isDocument) {
398
397
  if (valueSchema.isStringSchema() || valueSchema.isNumericSchema() || valueSchema.isBooleanSchema()) {
399
- const json = sparse ? JSON.stringify(value) : JSON.stringify(value.filter((_) => _ != null));
398
+ let hasSpecials = false;
399
+ for (let i = 0; i < value.length; ++i) {
400
+ const v = value[i];
401
+ if (Number.isNaN(v) || v === Infinity || v === -Infinity || (v == null && !sparse)) {
402
+ hasSpecials = true;
403
+ break;
404
+ }
405
+ }
406
+ let json;
407
+ if (!hasSpecials) {
408
+ json = JSON.stringify(value);
409
+ }
410
+ else {
411
+ const out = [];
412
+ for (let i = 0; i < value.length; ++i) {
413
+ const v = value[i];
414
+ if (v == null && !sparse)
415
+ continue;
416
+ if (Number.isNaN(v) || v === Infinity || v === -Infinity) {
417
+ out.push(String(v));
418
+ }
419
+ else {
420
+ out.push(v);
421
+ }
422
+ }
423
+ json = JSON.stringify(out);
424
+ }
400
425
  this.ensure(json.length * 3);
401
426
  this.i += encoder.encodeInto(json, this.json.subarray(this.i)).written;
402
427
  return;
@@ -425,17 +450,22 @@ export class JsonShapeSerializer2 extends SerdeContextConfig {
425
450
  const valueSchema = ns.getValueSchema();
426
451
  if (!isDocument) {
427
452
  if (valueSchema.isStringSchema() || valueSchema.isNumericSchema() || valueSchema.isBooleanSchema()) {
428
- let input = value;
429
- if (sparse) {
430
- input = {};
431
- for (const k in value) {
432
- if (k === "__proto__") {
433
- writeKey(input);
434
- }
435
- input[k] = value[k] ?? null;
453
+ let modifications;
454
+ for (const k in value) {
455
+ const v = value[k];
456
+ if (Number.isNaN(v) || v === Infinity || v === -Infinity) {
457
+ (modifications ??= {})[k] = v;
458
+ value[k] = String(v);
436
459
  }
460
+ else if (v === null && !sparse) {
461
+ (modifications ??= {})[k] = null;
462
+ value[k] = undefined;
463
+ }
464
+ }
465
+ const json = JSON.stringify(value);
466
+ if (modifications) {
467
+ Object.assign(value, modifications);
437
468
  }
438
- const json = JSON.stringify(input);
439
469
  this.ensure(json.length * 3);
440
470
  this.i += encoder.encodeInto(json, this.json.subarray(this.i)).written;
441
471
  return;
@@ -1,6 +1,7 @@
1
1
  import type { TypeRegistry } from "@smithy/core/schema";
2
2
  import { AwsJsonRpcProtocol } from "./AwsJsonRpcProtocol";
3
3
  import type { JsonCodec } from "./codec-v1/JsonCodec";
4
+ import type { JsonCodec2 } from "./codec-v2/JsonCodec2";
4
5
  /**
5
6
  * @public
6
7
  * @see https://smithy.io/2.0/aws/protocols/aws-json-1_1-protocol.html#differences-between-awsjson1-0-and-awsjson1-1
@@ -11,7 +12,7 @@ export declare class AwsJson1_0Protocol extends AwsJsonRpcProtocol {
11
12
  errorTypeRegistries?: TypeRegistry[];
12
13
  serviceTarget: string;
13
14
  awsQueryCompatible?: boolean;
14
- jsonCodec?: JsonCodec;
15
+ jsonCodec?: JsonCodec | JsonCodec2;
15
16
  });
16
17
  getShapeId(): string;
17
18
  protected getJsonRpcVersion(): "1.0";
@@ -1,6 +1,7 @@
1
1
  import type { TypeRegistry } from "@smithy/core/schema";
2
2
  import { AwsJsonRpcProtocol } from "./AwsJsonRpcProtocol";
3
3
  import type { JsonCodec } from "./codec-v1/JsonCodec";
4
+ import type { JsonCodec2 } from "./codec-v2/JsonCodec2";
4
5
  /**
5
6
  * @public
6
7
  * @see https://smithy.io/2.0/aws/protocols/aws-json-1_1-protocol.html#differences-between-awsjson1-0-and-awsjson1-1
@@ -11,7 +12,7 @@ export declare class AwsJson1_1Protocol extends AwsJsonRpcProtocol {
11
12
  errorTypeRegistries?: TypeRegistry[];
12
13
  serviceTarget: string;
13
14
  awsQueryCompatible?: boolean;
14
- jsonCodec?: JsonCodec;
15
+ jsonCodec?: JsonCodec | JsonCodec2;
15
16
  });
16
17
  getShapeId(): string;
17
18
  protected getJsonRpcVersion(): "1.1";
@@ -1,7 +1,8 @@
1
1
  import { RpcProtocol } from "@smithy/core/protocols";
2
2
  import type { TypeRegistry } from "@smithy/core/schema";
3
3
  import type { EndpointBearer, HandlerExecutionContext, HttpRequest, HttpResponse, OperationSchema, ResponseMetadata, SerdeFunctions, ShapeDeserializer, ShapeSerializer } from "@smithy/types";
4
- import { JsonCodec } from "./codec-v1/JsonCodec";
4
+ import type { JsonCodec } from "./codec-v1/JsonCodec";
5
+ import { JsonCodec2 } from "./codec-v2/JsonCodec2";
5
6
  /**
6
7
  * @public
7
8
  */
@@ -17,10 +18,10 @@ export declare abstract class AwsJsonRpcProtocol extends RpcProtocol {
17
18
  errorTypeRegistries?: TypeRegistry[];
18
19
  serviceTarget: string;
19
20
  awsQueryCompatible?: boolean;
20
- jsonCodec?: JsonCodec;
21
+ jsonCodec?: JsonCodec | JsonCodec2;
21
22
  });
22
23
  serializeRequest<Input extends object>(operationSchema: OperationSchema, input: Input, context: HandlerExecutionContext & SerdeFunctions & EndpointBearer): Promise<HttpRequest>;
23
- getPayloadCodec(): JsonCodec;
24
+ getPayloadCodec(): JsonCodec | JsonCodec2;
24
25
  protected abstract getJsonRpcVersion(): "1.1" | "1.0";
25
26
  /**
26
27
  * @override
@@ -1,7 +1,8 @@
1
1
  import { HttpBindingProtocol } from "@smithy/core/protocols";
2
2
  import type { TypeRegistry } from "@smithy/core/schema";
3
3
  import type { EndpointBearer, HandlerExecutionContext, HttpRequest, HttpResponse, MetadataBearer, OperationSchema, ResponseMetadata, SerdeFunctions, ShapeDeserializer, ShapeSerializer } from "@smithy/types";
4
- import { JsonCodec } from "./codec-v1/JsonCodec";
4
+ import type { JsonCodec } from "./codec-v1/JsonCodec";
5
+ import { JsonCodec2 } from "./codec-v2/JsonCodec2";
5
6
  /**
6
7
  * @public
7
8
  */
@@ -10,12 +11,13 @@ export declare class AwsRestJsonProtocol extends HttpBindingProtocol {
10
11
  protected deserializer: ShapeDeserializer<string | Uint8Array>;
11
12
  private readonly codec;
12
13
  private readonly mixin;
13
- constructor({ defaultNamespace, errorTypeRegistries, }: {
14
+ constructor({ defaultNamespace, errorTypeRegistries, jsonCodec, }: {
14
15
  defaultNamespace: string;
15
16
  errorTypeRegistries?: TypeRegistry[];
17
+ jsonCodec?: JsonCodec | JsonCodec2;
16
18
  });
17
19
  getShapeId(): string;
18
- getPayloadCodec(): JsonCodec;
20
+ getPayloadCodec(): JsonCodec | JsonCodec2;
19
21
  setSerdeContext(serdeContext: SerdeFunctions): void;
20
22
  /**
21
23
  * @override
@@ -1,6 +1,7 @@
1
1
  import { TypeRegistry } from "@smithy/core/schema";
2
2
  import { AwsJsonRpcProtocol } from "./AwsJsonRpcProtocol";
3
3
  import { JsonCodec } from "./codec-v1/JsonCodec";
4
+ import { JsonCodec2 } from "./codec-v2/JsonCodec2";
4
5
  export declare class AwsJson1_0Protocol extends AwsJsonRpcProtocol {
5
6
  constructor({
6
7
  defaultNamespace,
@@ -13,7 +14,7 @@ export declare class AwsJson1_0Protocol extends AwsJsonRpcProtocol {
13
14
  errorTypeRegistries?: TypeRegistry[];
14
15
  serviceTarget: string;
15
16
  awsQueryCompatible?: boolean;
16
- jsonCodec?: JsonCodec;
17
+ jsonCodec?: JsonCodec | JsonCodec2;
17
18
  });
18
19
  getShapeId(): string;
19
20
  protected getJsonRpcVersion(): "1.0";
@@ -1,6 +1,7 @@
1
1
  import { TypeRegistry } from "@smithy/core/schema";
2
2
  import { AwsJsonRpcProtocol } from "./AwsJsonRpcProtocol";
3
3
  import { JsonCodec } from "./codec-v1/JsonCodec";
4
+ import { JsonCodec2 } from "./codec-v2/JsonCodec2";
4
5
  export declare class AwsJson1_1Protocol extends AwsJsonRpcProtocol {
5
6
  constructor({
6
7
  defaultNamespace,
@@ -13,7 +14,7 @@ export declare class AwsJson1_1Protocol extends AwsJsonRpcProtocol {
13
14
  errorTypeRegistries?: TypeRegistry[];
14
15
  serviceTarget: string;
15
16
  awsQueryCompatible?: boolean;
16
- jsonCodec?: JsonCodec;
17
+ jsonCodec?: JsonCodec | JsonCodec2;
17
18
  });
18
19
  getShapeId(): string;
19
20
  protected getJsonRpcVersion(): "1.1";
@@ -12,6 +12,7 @@ import {
12
12
  ShapeSerializer,
13
13
  } from "@smithy/types";
14
14
  import { JsonCodec } from "./codec-v1/JsonCodec";
15
+ import { JsonCodec2 } from "./codec-v2/JsonCodec2";
15
16
  export declare abstract class AwsJsonRpcProtocol extends RpcProtocol {
16
17
  protected serializer: ShapeSerializer<string | Uint8Array>;
17
18
  protected deserializer: ShapeDeserializer<string | Uint8Array>;
@@ -30,14 +31,14 @@ export declare abstract class AwsJsonRpcProtocol extends RpcProtocol {
30
31
  errorTypeRegistries?: TypeRegistry[];
31
32
  serviceTarget: string;
32
33
  awsQueryCompatible?: boolean;
33
- jsonCodec?: JsonCodec;
34
+ jsonCodec?: JsonCodec | JsonCodec2;
34
35
  });
35
36
  serializeRequest<Input extends object>(
36
37
  operationSchema: OperationSchema,
37
38
  input: Input,
38
39
  context: HandlerExecutionContext & SerdeFunctions & EndpointBearer,
39
40
  ): Promise<HttpRequest>;
40
- getPayloadCodec(): JsonCodec;
41
+ getPayloadCodec(): JsonCodec | JsonCodec2;
41
42
  protected abstract getJsonRpcVersion(): "1.1" | "1.0";
42
43
  protected handleError(
43
44
  operationSchema: OperationSchema,
@@ -13,6 +13,7 @@ import {
13
13
  ShapeSerializer,
14
14
  } from "@smithy/types";
15
15
  import { JsonCodec } from "./codec-v1/JsonCodec";
16
+ import { JsonCodec2 } from "./codec-v2/JsonCodec2";
16
17
  export declare class AwsRestJsonProtocol extends HttpBindingProtocol {
17
18
  protected serializer: ShapeSerializer<string | Uint8Array>;
18
19
  protected deserializer: ShapeDeserializer<string | Uint8Array>;
@@ -21,12 +22,14 @@ export declare class AwsRestJsonProtocol extends HttpBindingProtocol {
21
22
  constructor({
22
23
  defaultNamespace,
23
24
  errorTypeRegistries,
25
+ jsonCodec,
24
26
  }: {
25
27
  defaultNamespace: string;
26
28
  errorTypeRegistries?: TypeRegistry[];
29
+ jsonCodec?: JsonCodec | JsonCodec2;
27
30
  });
28
31
  getShapeId(): string;
29
- getPayloadCodec(): JsonCodec;
32
+ getPayloadCodec(): JsonCodec | JsonCodec2;
30
33
  setSerdeContext(serdeContext: SerdeFunctions): void;
31
34
  serializeRequest<Input extends object>(
32
35
  operationSchema: OperationSchema,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/core",
3
- "version": "3.977.4",
3
+ "version": "3.977.5",
4
4
  "description": "Core functions & classes shared by multiple AWS SDK clients.",
5
5
  "homepage": "https://github.com/aws/aws-sdk-js-v3/tree/main/packages-internal/core",
6
6
  "license": "Apache-2.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/credential-provider-env",
3
- "version": "3.972.65",
3
+ "version": "3.972.66",
4
4
  "description": "AWS credential provider that sources credentials from known environment variables",
5
5
  "keywords": [
6
6
  "aws",
@@ -43,7 +43,7 @@
43
43
  "test:watch": "yarn g:vitest watch"
44
44
  },
45
45
  "dependencies": {
46
- "@aws-sdk/core": "^3.977.4",
46
+ "@aws-sdk/core": "^3.977.5",
47
47
  "@aws-sdk/types": "^3.974.2",
48
48
  "@smithy/core": "^3.31.1",
49
49
  "@smithy/types": "^4.16.1",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/credential-provider-http",
3
- "version": "3.972.67",
3
+ "version": "3.972.68",
4
4
  "description": "AWS credential provider for containers and HTTP sources",
5
5
  "keywords": [
6
6
  "aws",
@@ -53,7 +53,7 @@
53
53
  "test:integration:watch": "yarn g:vitest watch -c vitest.config.integ.mts"
54
54
  },
55
55
  "dependencies": {
56
- "@aws-sdk/core": "^3.977.4",
56
+ "@aws-sdk/core": "^3.977.5",
57
57
  "@aws-sdk/types": "^3.974.2",
58
58
  "@smithy/core": "^3.31.1",
59
59
  "@smithy/fetch-http-handler": "^5.6.13",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/credential-provider-ini",
3
- "version": "3.973.10",
3
+ "version": "3.973.11",
4
4
  "description": "AWS credential provider that sources credentials from ~/.aws/credentials and ~/.aws/config",
5
5
  "keywords": [
6
6
  "aws",
@@ -45,14 +45,14 @@
45
45
  "test:integration:watch": "yarn g:vitest watch -c vitest.config.integ.mts"
46
46
  },
47
47
  "dependencies": {
48
- "@aws-sdk/core": "^3.977.4",
49
- "@aws-sdk/credential-provider-env": "^3.972.65",
50
- "@aws-sdk/credential-provider-http": "^3.972.67",
51
- "@aws-sdk/credential-provider-login": "^3.972.72",
52
- "@aws-sdk/credential-provider-process": "^3.972.65",
53
- "@aws-sdk/credential-provider-sso": "^3.973.9",
54
- "@aws-sdk/credential-provider-web-identity": "^3.972.71",
55
- "@aws-sdk/nested-clients": "^3.997.39",
48
+ "@aws-sdk/core": "^3.977.5",
49
+ "@aws-sdk/credential-provider-env": "^3.972.66",
50
+ "@aws-sdk/credential-provider-http": "^3.972.68",
51
+ "@aws-sdk/credential-provider-login": "^3.972.73",
52
+ "@aws-sdk/credential-provider-process": "^3.972.66",
53
+ "@aws-sdk/credential-provider-sso": "^3.973.10",
54
+ "@aws-sdk/credential-provider-web-identity": "^3.972.72",
55
+ "@aws-sdk/nested-clients": "^3.997.40",
56
56
  "@aws-sdk/types": "^3.974.2",
57
57
  "@smithy/core": "^3.31.1",
58
58
  "@smithy/credential-provider-imds": "^4.4.16",
@@ -1,5 +1,5 @@
1
1
  const { setCredentialFeature } = require("@aws-sdk/core/client");
2
- const { CredentialsProviderError, readFile, parseKnownFiles, getProfileName } = require("@smithy/core/config");
2
+ const { CredentialsProviderError, parseKnownFiles, getProfileName } = require("@smithy/core/config");
3
3
  const { HttpRequest } = require("@smithy/core/protocols");
4
4
  const { createHash, createPrivateKey, createPublicKey, sign } = require("node:crypto");
5
5
  const { promises } = require("node:fs");
@@ -28,13 +28,7 @@ class LoginCredentialsFetcher {
28
28
  if (timeUntilExpiry <= LoginCredentialsFetcher.REFRESH_THRESHOLD) {
29
29
  return this.refresh(token);
30
30
  }
31
- return {
32
- accessKeyId: accessToken.accessKeyId,
33
- secretAccessKey: accessToken.secretAccessKey,
34
- sessionToken: accessToken.sessionToken,
35
- accountId: accessToken.accountId,
36
- expiration: new Date(accessToken.expiresAt),
37
- };
31
+ return this.toCredentials(token.accessToken);
38
32
  }
39
33
  get logger() {
40
34
  return this.init?.logger;
@@ -42,7 +36,25 @@ class LoginCredentialsFetcher {
42
36
  get loginSession() {
43
37
  return this.profileData.login_session;
44
38
  }
39
+ toCredentials(token) {
40
+ return {
41
+ accessKeyId: token.accessKeyId,
42
+ secretAccessKey: token.secretAccessKey,
43
+ sessionToken: token.sessionToken,
44
+ accountId: token.accountId,
45
+ expiration: new Date(token.expiresAt),
46
+ };
47
+ }
45
48
  async refresh(token) {
49
+ const diskToken = await this.loadToken().catch(() => token);
50
+ const now = Date.now();
51
+ const diskExpiry = new Date(diskToken.accessToken.expiresAt).getTime();
52
+ const tokenExpiry = new Date(token.accessToken.expiresAt).getTime();
53
+ const freshToken = diskExpiry <= now && tokenExpiry > now ? token : diskToken;
54
+ const freshExpiry = new Date(freshToken.accessToken.expiresAt).getTime();
55
+ if (freshExpiry - Date.now() > LoginCredentialsFetcher.REFRESH_THRESHOLD) {
56
+ return this.toCredentials(freshToken.accessToken);
57
+ }
46
58
  const { SigninClient, CreateOAuth2TokenCommand } = require('@aws-sdk/nested-clients/signin');
47
59
  const { logger, userAgentAppId } = this.callerClientConfig ?? {};
48
60
  const isH2 = (requestHandler) => {
@@ -66,8 +78,8 @@ class LoginCredentialsFetcher {
66
78
  this.createDPoPInterceptor(client.middlewareStack);
67
79
  const commandInput = {
68
80
  tokenInput: {
69
- clientId: token.clientId,
70
- refreshToken: token.refreshToken,
81
+ clientId: freshToken.clientId,
82
+ refreshToken: freshToken.refreshToken,
71
83
  grantType: "refresh_token",
72
84
  },
73
85
  };
@@ -84,9 +96,9 @@ class LoginCredentialsFetcher {
84
96
  const expiresInMs = (expiresIn ?? 900) * 1000;
85
97
  const expiration = new Date(Date.now() + expiresInMs);
86
98
  const updatedToken = {
87
- ...token,
99
+ ...freshToken,
88
100
  accessToken: {
89
- ...token.accessToken,
101
+ ...freshToken.accessToken,
90
102
  accessKeyId,
91
103
  secretAccessKey,
92
104
  sessionToken,
@@ -95,14 +107,7 @@ class LoginCredentialsFetcher {
95
107
  refreshToken,
96
108
  };
97
109
  await this.saveToken(updatedToken);
98
- const newAccessToken = updatedToken.accessToken;
99
- return {
100
- accessKeyId: newAccessToken.accessKeyId,
101
- secretAccessKey: newAccessToken.secretAccessKey,
102
- sessionToken: newAccessToken.sessionToken,
103
- accountId: newAccessToken.accountId,
104
- expiration,
105
- };
110
+ return this.toCredentials(updatedToken.accessToken);
106
111
  }
107
112
  catch (error) {
108
113
  if (error.name === "AccessDeniedException") {
@@ -123,7 +128,15 @@ class LoginCredentialsFetcher {
123
128
  default:
124
129
  message = `Failed to refresh token: ${String(error)}. Please re-authenticate using \`aws login\``;
125
130
  }
126
- throw new CredentialsProviderError(message, { logger: this.logger, tryNextLink: false });
131
+ throw new CredentialsProviderError(message, {
132
+ logger: this.logger,
133
+ tryNextLink: false,
134
+ });
135
+ }
136
+ const tokenExpiry = new Date(freshToken.accessToken.expiresAt).getTime();
137
+ if (tokenExpiry > Date.now()) {
138
+ this.logger?.warn?.(`Failed to refresh token: ${String(error)}. Using existing token until expiry.`);
139
+ return this.toCredentials(freshToken.accessToken);
127
140
  }
128
141
  throw new CredentialsProviderError(`Failed to refresh token: ${String(error)}. Please re-authenticate using aws login`, { logger: this.logger });
129
142
  }
@@ -131,13 +144,7 @@ class LoginCredentialsFetcher {
131
144
  async loadToken() {
132
145
  const tokenFilePath = this.getTokenFilePath();
133
146
  try {
134
- let tokenData;
135
- try {
136
- tokenData = await readFile(tokenFilePath, { ignoreCache: this.init?.ignoreCache });
137
- }
138
- catch {
139
- tokenData = await promises.readFile(tokenFilePath, "utf8");
140
- }
147
+ const tokenData = await promises.readFile(tokenFilePath, "utf8");
141
148
  const token = JSON.parse(tokenData);
142
149
  const missingFields = ["accessToken", "clientId", "refreshToken", "dpopKey"].filter((k) => !token[k]);
143
150
  if (!token.accessToken?.accountId) {
@@ -1,4 +1,4 @@
1
- import { CredentialsProviderError, readFile } from "@smithy/core/config";
1
+ import { CredentialsProviderError } from "@smithy/core/config";
2
2
  import { HttpRequest } from "@smithy/core/protocols";
3
3
  import { createHash, createPrivateKey, createPublicKey, sign } from "node:crypto";
4
4
  import { promises as fs } from "node:fs";
@@ -26,13 +26,7 @@ export class LoginCredentialsFetcher {
26
26
  if (timeUntilExpiry <= LoginCredentialsFetcher.REFRESH_THRESHOLD) {
27
27
  return this.refresh(token);
28
28
  }
29
- return {
30
- accessKeyId: accessToken.accessKeyId,
31
- secretAccessKey: accessToken.secretAccessKey,
32
- sessionToken: accessToken.sessionToken,
33
- accountId: accessToken.accountId,
34
- expiration: new Date(accessToken.expiresAt),
35
- };
29
+ return this.toCredentials(token.accessToken);
36
30
  }
37
31
  get logger() {
38
32
  return this.init?.logger;
@@ -40,7 +34,25 @@ export class LoginCredentialsFetcher {
40
34
  get loginSession() {
41
35
  return this.profileData.login_session;
42
36
  }
37
+ toCredentials(token) {
38
+ return {
39
+ accessKeyId: token.accessKeyId,
40
+ secretAccessKey: token.secretAccessKey,
41
+ sessionToken: token.sessionToken,
42
+ accountId: token.accountId,
43
+ expiration: new Date(token.expiresAt),
44
+ };
45
+ }
43
46
  async refresh(token) {
47
+ const diskToken = await this.loadToken().catch(() => token);
48
+ const now = Date.now();
49
+ const diskExpiry = new Date(diskToken.accessToken.expiresAt).getTime();
50
+ const tokenExpiry = new Date(token.accessToken.expiresAt).getTime();
51
+ const freshToken = diskExpiry <= now && tokenExpiry > now ? token : diskToken;
52
+ const freshExpiry = new Date(freshToken.accessToken.expiresAt).getTime();
53
+ if (freshExpiry - Date.now() > LoginCredentialsFetcher.REFRESH_THRESHOLD) {
54
+ return this.toCredentials(freshToken.accessToken);
55
+ }
44
56
  const { SigninClient, CreateOAuth2TokenCommand } = await import("@aws-sdk/nested-clients/signin");
45
57
  const { logger, userAgentAppId } = this.callerClientConfig ?? {};
46
58
  const isH2 = (requestHandler) => {
@@ -64,8 +76,8 @@ export class LoginCredentialsFetcher {
64
76
  this.createDPoPInterceptor(client.middlewareStack);
65
77
  const commandInput = {
66
78
  tokenInput: {
67
- clientId: token.clientId,
68
- refreshToken: token.refreshToken,
79
+ clientId: freshToken.clientId,
80
+ refreshToken: freshToken.refreshToken,
69
81
  grantType: "refresh_token",
70
82
  },
71
83
  };
@@ -82,9 +94,9 @@ export class LoginCredentialsFetcher {
82
94
  const expiresInMs = (expiresIn ?? 900) * 1000;
83
95
  const expiration = new Date(Date.now() + expiresInMs);
84
96
  const updatedToken = {
85
- ...token,
97
+ ...freshToken,
86
98
  accessToken: {
87
- ...token.accessToken,
99
+ ...freshToken.accessToken,
88
100
  accessKeyId,
89
101
  secretAccessKey,
90
102
  sessionToken,
@@ -93,14 +105,7 @@ export class LoginCredentialsFetcher {
93
105
  refreshToken,
94
106
  };
95
107
  await this.saveToken(updatedToken);
96
- const newAccessToken = updatedToken.accessToken;
97
- return {
98
- accessKeyId: newAccessToken.accessKeyId,
99
- secretAccessKey: newAccessToken.secretAccessKey,
100
- sessionToken: newAccessToken.sessionToken,
101
- accountId: newAccessToken.accountId,
102
- expiration,
103
- };
108
+ return this.toCredentials(updatedToken.accessToken);
104
109
  }
105
110
  catch (error) {
106
111
  if (error.name === "AccessDeniedException") {
@@ -121,7 +126,15 @@ export class LoginCredentialsFetcher {
121
126
  default:
122
127
  message = `Failed to refresh token: ${String(error)}. Please re-authenticate using \`aws login\``;
123
128
  }
124
- throw new CredentialsProviderError(message, { logger: this.logger, tryNextLink: false });
129
+ throw new CredentialsProviderError(message, {
130
+ logger: this.logger,
131
+ tryNextLink: false,
132
+ });
133
+ }
134
+ const tokenExpiry = new Date(freshToken.accessToken.expiresAt).getTime();
135
+ if (tokenExpiry > Date.now()) {
136
+ this.logger?.warn?.(`Failed to refresh token: ${String(error)}. Using existing token until expiry.`);
137
+ return this.toCredentials(freshToken.accessToken);
125
138
  }
126
139
  throw new CredentialsProviderError(`Failed to refresh token: ${String(error)}. Please re-authenticate using aws login`, { logger: this.logger });
127
140
  }
@@ -129,13 +142,7 @@ export class LoginCredentialsFetcher {
129
142
  async loadToken() {
130
143
  const tokenFilePath = this.getTokenFilePath();
131
144
  try {
132
- let tokenData;
133
- try {
134
- tokenData = await readFile(tokenFilePath, { ignoreCache: this.init?.ignoreCache });
135
- }
136
- catch {
137
- tokenData = await fs.readFile(tokenFilePath, "utf8");
138
- }
145
+ const tokenData = await fs.readFile(tokenFilePath, "utf8");
139
146
  const token = JSON.parse(tokenData);
140
147
  const missingFields = ["accessToken", "clientId", "refreshToken", "dpopKey"].filter((k) => !token[k]);
141
148
  if (!token.accessToken?.accountId) {
@@ -17,6 +17,7 @@ export declare class LoginCredentialsFetcher {
17
17
  loadCredentials(): Promise<AwsCredentialIdentity>;
18
18
  private get logger();
19
19
  private get loginSession();
20
+ private toCredentials;
20
21
  private refresh;
21
22
  private loadToken;
22
23
  private saveToken;
@@ -14,6 +14,7 @@ export declare class LoginCredentialsFetcher {
14
14
  loadCredentials(): Promise<AwsCredentialIdentity>;
15
15
  private readonly logger: any;
16
16
  private readonly loginSession: any;
17
+ private toCredentials;
17
18
  private refresh;
18
19
  private loadToken;
19
20
  private saveToken;