@infoxchange/make-it-so 2.11.0-internal-testing-vdt-199-add-auth-token-verify-function-2.5 → 2.11.0-internal-testing-vdt-199-add-auth-token-verify-function-2.6

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.
@@ -87,7 +87,24 @@ function _sign(input, key, method) {
87
87
  return crypto.createHmac(method, key).update(input).digest("base64url");
88
88
  }
89
89
  function _base64urlDecode(str) {
90
- return Buffer.from(str, "base64url").toString();
90
+ str = str.replace(/-/g, '+').replace(/_/g, '/');
91
+ while (str.length % 4)
92
+ str += '=';
93
+ const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
94
+ let output = '';
95
+ let bc = 0, bs = 0, buffer, i = 0;
96
+ for (; i < str.length; i++) {
97
+ buffer = chars.indexOf(str.charAt(i));
98
+ if (buffer === -1)
99
+ continue;
100
+ bs = (bs << 6) | buffer;
101
+ bc += 6;
102
+ if (bc >= 8) {
103
+ bc -= 8;
104
+ output += String.fromCharCode((bs >> bc) & 0xFF);
105
+ }
106
+ }
107
+ return output;
91
108
  }
92
109
  const jwtToken = request.cookies["auth-token"] && request.cookies["auth-token"].value;
93
110
  if (!jwtToken) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cdk-constructs/SiteOidcAuth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,UAAU,MAAM,4BAA4B,CAAC;AACpD,OAAO,GAAG,MAAM,aAAa,CAAC;AAE9B,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AAOtC,OAAO,KAAK,EACV,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,2BAA2B,CAAC;AAEnC,KAAK,cAAc,GAAG,qBAAqB,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;AACjE,KAAK,WAAW,GAA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AE,SAAS,EACpB,EAAE,MAA+B,EAAE,GAAE,cAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAqC1D,OAAO,CAAC,eAAe;IAgBvB,OAAO,CAAC,sBAAsB;IA+B9B,OAAO,CAAC,2BAA2B;IAoBnC,OAAO,CAAC,yCAAyC;IAgBjD,OAAO,CAAC,sBAAsB;CAiF/B"}
@@ -115,10 +115,10 @@ export class SiteOidcAuth extends Construct {
115
115
  .readFileSync(path.join(import.meta.dirname, "auth-check-handler-body.js"), "utf8")
116
116
  .replace("__placeholder-for-jwt-secret__", jwtSecret.secretValue.toString())
117
117
  .replace("__placeholder-for-auth-route-prefix__", authRoutePrefix)
118
- // When typescript builds the make-it-so code including it may add an "export {}" at the end to make it a module.
119
- // This will cause a syntax error in CloudFront Functions so remove it here.
118
+ // When typescript builds the make-it-so code including "auth-check-handler-body.ts" it will add "export {}" to
119
+ // the end of the file if it's not already a module. This will cause a syntax error in CloudFront Functions so we
120
+ // remove it here.
120
121
  .replace(/export {};\s*$/g, "");
121
- ;
122
122
  }
123
123
  convertToCloudFrontFunctionCompatibleCode(sourceCode) {
124
124
  // ESBuild doesn't currently support transforming const/let to var, which is required for CloudFront Functions
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infoxchange/make-it-so",
3
- "version": "2.11.0-internal-testing-vdt-199-add-auth-token-verify-function-2.5",
3
+ "version": "2.11.0-internal-testing-vdt-199-add-auth-token-verify-function-2.6",
4
4
  "description": "Makes deploying services to IX infra easy",
5
5
  "repository": "github:infoxchange/make-it-so",
6
6
  "type": "module",
@@ -116,7 +116,27 @@ function _sign(input: string, key: string, method: string) {
116
116
  }
117
117
 
118
118
  function _base64urlDecode(str: string) {
119
- return Buffer.from(str, "base64url").toString();
119
+ str = str.replace(/-/g, '+').replace(/_/g, '/');
120
+ while (str.length % 4) str += '=';
121
+
122
+ const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
123
+ let output = '';
124
+
125
+ let bc = 0, bs = 0, buffer, i = 0;
126
+ for (; i < str.length; i++) {
127
+ buffer = chars.indexOf(str.charAt(i));
128
+ if (buffer === -1) continue;
129
+
130
+ bs = (bs << 6) | buffer;
131
+ bc += 6;
132
+
133
+ if (bc >= 8) {
134
+ bc -= 8;
135
+ output += String.fromCharCode((bs >> bc) & 0xFF);
136
+ }
137
+ }
138
+
139
+ return output;
120
140
  }
121
141
 
122
142
  const jwtToken =
@@ -189,9 +189,10 @@ export class SiteOidcAuth extends Construct {
189
189
  jwtSecret.secretValue.toString(),
190
190
  )
191
191
  .replace("__placeholder-for-auth-route-prefix__", authRoutePrefix)
192
- // When typescript builds the make-it-so code including it may add an "export {}" at the end to make it a module.
193
- // This will cause a syntax error in CloudFront Functions so remove it here.
194
- .replace(/export {};\s*$/g, "");;
192
+ // When typescript builds the make-it-so code including "auth-check-handler-body.ts" it will add "export {}" to
193
+ // the end of the file if it's not already a module. This will cause a syntax error in CloudFront Functions so we
194
+ // remove it here.
195
+ .replace(/export {};\s*$/g, "");
195
196
  }
196
197
 
197
198
  private convertToCloudFrontFunctionCompatibleCode(