Skip to content

Commit

Permalink
feat(js-storefrontaware-utils): Enforce empty crystallize secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
Plopix committed Oct 4, 2022
1 parent 2e430c4 commit 28f133c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@crystallize/js-storefrontaware-utils",
"license": "MIT",
"version": "0.2.0",
"version": "0.2.1",
"author": "Crystallize <[email protected]> (https://crystallize.com)",
"contributors": [
"Sébastien Morel <[email protected]>"
Expand Down
13 changes: 12 additions & 1 deletion src/adapters/filesystem.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,18 @@ export const createFilesystemAdapter = (filename: string): TStoreFrontAdapter =>
return {
config: async (withSecrets: boolean): Promise<TStoreFrontConfig> => {
const data = await fs.readFile(filename, { encoding: 'utf8' });
return JSON.parse(data);
const unfilteredSecrets = JSON.parse(data);
if (withSecrets) {
return unfilteredSecrets;
}
return {
...unfilteredSecrets,
configuration: {
...unfilteredSecrets.configuration,
ACCESS_TOKEN_ID: '',
ACCESS_TOKEN_SECRET: '',
},
};
},
};
};
14 changes: 13 additions & 1 deletion src/adapters/memory.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@ import { TStoreFrontAdapter, TStoreFrontConfig } from '../types';

export const createMemoryAdapter = (config: TStoreFrontConfig): TStoreFrontAdapter => {
return {
config: async (withSecrets: boolean): Promise<TStoreFrontConfig> => config,
config: async (withSecrets: boolean): Promise<TStoreFrontConfig> => {
if (withSecrets) {
return config;
}
return {
...config,
configuration: {
...config.configuration,
ACCESS_TOKEN_ID: '',
ACCESS_TOKEN_SECRET: '',
},
};
},
};
};

0 comments on commit 28f133c

Please sign in to comment.