Skip to content

Commit

Permalink
fix: plat-5545 reading new env var in actions layer
Browse files Browse the repository at this point in the history
  • Loading branch information
NicoMolinaOZ committed Jan 10, 2025
1 parent 7652d86 commit 7aeb571
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
6 changes: 5 additions & 1 deletion packages/kvstore/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ export class KeyValueStoreClient implements IKeyValueStoreClient {
protected implementation: IKeyValueStoreClient;

public constructor(params: KeyValueStoreCreateParams | LocalKeyValueStoreCreateParams) {
if (isActionCreateParams(params)) {
const defenderAction = process.env.DEFENDER_ENV;
if (defenderAction === 'action') {
if (!isActionCreateParams(params)) {
throw new Error('Invalid create params for KeyValueStoreClient');
}
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { KeyValueStoreActionClient } = require('./action');
this.implementation = new KeyValueStoreActionClient(params);
Expand Down
11 changes: 7 additions & 4 deletions packages/relay-signer/src/relayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,12 @@ export class Relayer implements IRelayer {

public constructor(credentials: RelayerParams) {
this.credentials = credentials;
if (isActionCredentials(credentials)) {
const defenderAction = process.env.DEFENDER_ENV;
const errorMessage = `Missing credentials for creating a Relayer instance. If you are running this code in an Action, make sure you pass the "credentials" parameter from the handler to the Relayer constructor. If you are running this on your own process, then pass an object with the "apiKey" and "apiSecret" generated by the relayer.`;
if (defenderAction === 'action') {
if (!isActionCredentials(credentials)) {
throw new Error(errorMessage);
}
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { ActionRelayer } = require('./action');
this.relayer = new ActionRelayer(credentials);
Expand All @@ -69,9 +74,7 @@ export class Relayer implements IRelayer {
authConfig: { ...credentials.authConfig, type: 'relay' },
});
} else {
throw new Error(
`Missing credentials for creating a Relayer instance. If you are running this code in an Action, make sure you pass the "credentials" parameter from the handler to the Relayer constructor. If you are running this on your own process, then pass an object with the "apiKey" and "apiSecret" generated by the relayer.`,
);
throw new Error(errorMessage);
}
}

Expand Down

0 comments on commit 7aeb571

Please sign in to comment.