altair-graphql-core 6.4.0 → 6.4.2

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.
@@ -3,7 +3,7 @@ export default class ApiKeyAuthorizationProvider extends AuthorizationProvider {
3
3
  async execute(options) {
4
4
  return {
5
5
  headers: {
6
- [options.data.key]: options.data.value,
6
+ [options.data.key]: this.hydrate(options.data.value),
7
7
  },
8
8
  };
9
9
  }
@@ -15,5 +15,19 @@ describe('basic', () => {
15
15
  },
16
16
  });
17
17
  });
18
+ it('should return basic auth header with environment variables', async () => {
19
+ const authProvider = new ApiKeyAuthorizationProvider((x) => x.replace(/(^{{)|(}}$)/g, ''));
20
+ const res = await authProvider.execute({
21
+ data: {
22
+ key: 'X-API-Key',
23
+ value: '{{api_1a2s3d4f5g6h7j8k9l0}}',
24
+ },
25
+ });
26
+ expect(res).toEqual({
27
+ headers: {
28
+ 'X-API-Key': 'api_1a2s3d4f5g6h7j8k9l0',
29
+ },
30
+ });
31
+ });
18
32
  });
19
33
  //# sourceMappingURL=api-key.spec.js.map
@@ -8,7 +8,7 @@ export default class BasicAuthorizationProvider extends AuthorizationProvider {
8
8
  }
9
9
  return {
10
10
  headers: {
11
- Authorization: `Basic ${(await import('abab')).btoa(`${options.data.username}:${options.data.password}`)}`,
11
+ Authorization: `Basic ${(await import('abab')).btoa(`${this.hydrate(options.data.username)}:${this.hydrate(options.data.password)}`)}`,
12
12
  },
13
13
  };
14
14
  }
@@ -15,6 +15,20 @@ describe('basic', () => {
15
15
  },
16
16
  });
17
17
  });
18
+ it('should return basic auth header with environment variables', async () => {
19
+ const authProvider = new BasicAuthorizationProvider((x) => x.replace(/(^{{)|(}}$)/g, ''));
20
+ const res = await authProvider.execute({
21
+ data: {
22
+ username: '{{username}}',
23
+ password: '{{password}}',
24
+ },
25
+ });
26
+ expect(res).toEqual({
27
+ headers: {
28
+ Authorization: 'Basic dXNlcm5hbWU6cGFzc3dvcmQ=',
29
+ },
30
+ });
31
+ });
18
32
  it('should not return headers if username or password is missing', async () => {
19
33
  const authProvider = new BasicAuthorizationProvider((x) => x);
20
34
  const res = await authProvider.execute({
@@ -3,7 +3,7 @@ export default class BearerAuthorizationProvider extends AuthorizationProvider {
3
3
  async execute(options) {
4
4
  return {
5
5
  headers: {
6
- Authorization: `Bearer ${options.data.token}`,
6
+ Authorization: `Bearer ${this.hydrate(options.data.token)}`,
7
7
  },
8
8
  };
9
9
  }
@@ -14,5 +14,18 @@ describe('basic', () => {
14
14
  },
15
15
  });
16
16
  });
17
+ it('should return basic auth header with environment variables', async () => {
18
+ const authProvider = new BearerAuthorizationProvider((x) => x.replace(/(^{{)|(}}$)/g, ''));
19
+ const res = await authProvider.execute({
20
+ data: {
21
+ token: '{{tk_1a2s3d4f5g6h7j8k9l0}}',
22
+ },
23
+ });
24
+ expect(res).toEqual({
25
+ headers: {
26
+ Authorization: 'Bearer tk_1a2s3d4f5g6h7j8k9l0',
27
+ },
28
+ });
29
+ });
17
30
  });
18
31
  //# sourceMappingURL=bearer.spec.js.map
@@ -5,7 +5,7 @@ class ApiKeyAuthorizationProvider extends authorization_provider_1.Authorization
5
5
  async execute(options) {
6
6
  return {
7
7
  headers: {
8
- [options.data.key]: options.data.value,
8
+ [options.data.key]: this.hydrate(options.data.value),
9
9
  },
10
10
  };
11
11
  }
@@ -20,5 +20,19 @@ const api_key_1 = __importDefault(require("./api-key"));
20
20
  },
21
21
  });
22
22
  });
23
+ (0, globals_1.it)('should return basic auth header with environment variables', async () => {
24
+ const authProvider = new api_key_1.default((x) => x.replace(/(^{{)|(}}$)/g, ''));
25
+ const res = await authProvider.execute({
26
+ data: {
27
+ key: 'X-API-Key',
28
+ value: '{{api_1a2s3d4f5g6h7j8k9l0}}',
29
+ },
30
+ });
31
+ (0, globals_1.expect)(res).toEqual({
32
+ headers: {
33
+ 'X-API-Key': 'api_1a2s3d4f5g6h7j8k9l0',
34
+ },
35
+ });
36
+ });
23
37
  });
24
38
  //# sourceMappingURL=api-key.spec.js.map
@@ -33,7 +33,7 @@ class BasicAuthorizationProvider extends authorization_provider_1.AuthorizationP
33
33
  }
34
34
  return {
35
35
  headers: {
36
- Authorization: `Basic ${(await Promise.resolve().then(() => __importStar(require('abab')))).btoa(`${options.data.username}:${options.data.password}`)}`,
36
+ Authorization: `Basic ${(await Promise.resolve().then(() => __importStar(require('abab')))).btoa(`${this.hydrate(options.data.username)}:${this.hydrate(options.data.password)}`)}`,
37
37
  },
38
38
  };
39
39
  }
@@ -20,6 +20,20 @@ const basic_1 = __importDefault(require("./basic"));
20
20
  },
21
21
  });
22
22
  });
23
+ (0, globals_1.it)('should return basic auth header with environment variables', async () => {
24
+ const authProvider = new basic_1.default((x) => x.replace(/(^{{)|(}}$)/g, ''));
25
+ const res = await authProvider.execute({
26
+ data: {
27
+ username: '{{username}}',
28
+ password: '{{password}}',
29
+ },
30
+ });
31
+ (0, globals_1.expect)(res).toEqual({
32
+ headers: {
33
+ Authorization: 'Basic dXNlcm5hbWU6cGFzc3dvcmQ=',
34
+ },
35
+ });
36
+ });
23
37
  (0, globals_1.it)('should not return headers if username or password is missing', async () => {
24
38
  const authProvider = new basic_1.default((x) => x);
25
39
  const res = await authProvider.execute({
@@ -5,7 +5,7 @@ class BearerAuthorizationProvider extends authorization_provider_1.Authorization
5
5
  async execute(options) {
6
6
  return {
7
7
  headers: {
8
- Authorization: `Bearer ${options.data.token}`,
8
+ Authorization: `Bearer ${this.hydrate(options.data.token)}`,
9
9
  },
10
10
  };
11
11
  }
@@ -19,5 +19,18 @@ const bearer_1 = __importDefault(require("./bearer"));
19
19
  },
20
20
  });
21
21
  });
22
+ (0, globals_1.it)('should return basic auth header with environment variables', async () => {
23
+ const authProvider = new bearer_1.default((x) => x.replace(/(^{{)|(}}$)/g, ''));
24
+ const res = await authProvider.execute({
25
+ data: {
26
+ token: '{{tk_1a2s3d4f5g6h7j8k9l0}}',
27
+ },
28
+ });
29
+ (0, globals_1.expect)(res).toEqual({
30
+ headers: {
31
+ Authorization: 'Bearer tk_1a2s3d4f5g6h7j8k9l0',
32
+ },
33
+ });
34
+ });
22
35
  });
23
36
  //# sourceMappingURL=bearer.spec.js.map
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "altair-graphql-core",
3
3
  "description": "Several of the core logic for altair graphql client",
4
- "version": "6.4.0",
4
+ "version": "6.4.2",
5
5
  "author": "Samuel Imolorhe <altair@sirmuel.design> (https://sirmuel.design)",
6
6
  "bugs": "https://github.com/altair-graphql/altair/issues",
7
7
  "dependencies": {
8
8
  "@apollo/client": "3.3.20",
9
+ "abab": "2.0.6",
9
10
  "actioncable": "5.2.6",
10
11
  "apollo-cache-inmemory": "1.6.6",
11
12
  "apollo-link": "1.2.14",
@@ -66,5 +67,5 @@
66
67
  "test": "jest"
67
68
  },
68
69
  "types": "./build/index.d.ts",
69
- "gitHead": "4a30079d23fc1c545fe64465f7f7262f66bf0e5e"
70
+ "gitHead": "7220567f89113b05e8d6b32985cc14b06e24a6f2"
70
71
  }