@flipdish/authorization 0.0.1 → 0.0.2-rc.1756734895

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.
@@ -1,5 +1,6 @@
1
1
  .gitignore
2
2
  .npmignore
3
+ .openapi-generator-ignore
3
4
  README.md
4
5
  api.ts
5
6
  base.ts
package/README.md CHANGED
@@ -7,11 +7,11 @@ Internally the package utilizes the [axios](https://github.com/axios/axios) as i
7
7
  ### Example code
8
8
 
9
9
  ```typescript
10
- import { AuthorizationApi, Configuration, PermissionsApi, Permissions } from '@flipdish/authorization';
11
- import { describe, expect, test, it } from '@jest/globals';
10
+ import { AuthorizationApi, Configuration, PermissionsApi, Permissions } from '@flipdish/authorization';
11
+ import { describe, expect, test, it } from '@jest/globals';
12
12
 
13
- const basePath = "https://api.flipdish.co/auth/";
14
- const configuration = new Configuration({
13
+ const basePath = "https://api.flipdish.co/auth/";
14
+ const configuration = new Configuration({
15
15
  basePath,
16
16
  // to get the API key, you should follow these docs:
17
17
  // https://developers.flipdish.com/docs/getting-started
@@ -21,14 +21,14 @@ const configuration = new Configuration({
21
21
  // useDefaultUserAgent: true
22
22
  });
23
23
 
24
- const authorization = new AuthorizationApi(configuration);
25
- const permissions = new PermissionsApi(configuration);
24
+ const authorization = new AuthorizationApi(configuration);
25
+ const permissions = new PermissionsApi(configuration);
26
26
 
27
- describe('Authorization Tests', () => {
28
- describe('Authorization', () => {
27
+ describe('Authorization Tests', () => {
28
+ describe('Authorization', () => {
29
29
 
30
- test('List Permissions', async () => {
31
- const permissionsResponse = await permissions.listPermissions();
30
+ test('List Permissions', async () => {
31
+ const permissionsResponse = await permissions.listPermissions();
32
32
  expect(permissionsResponse.status).toBe(200);
33
33
  expect(permissionsResponse.data.permissions).toBeDefined();
34
34
  expect(permissionsResponse.data.permissions.length).toBeGreaterThan(0);
@@ -39,82 +39,82 @@ describe('Authorization Tests', () => {
39
39
  expect(permissionsResponse.data.permissions).toContain(Permissions.EditAppAssets);
40
40
  });
41
41
 
42
- describe('Authenticate and Authorize', () => {
43
- it('should authenticate and authorize with a valid FD-Authorization cookie', async () => {
44
- const authorizationResponse = await authorization.authenticateAndAuthorize({
42
+ describe('Authenticate and Authorize', () => {
43
+ it('should authenticate and authorize with a valid FD-Authorization cookie', async () => {
44
+ const authorizationResponse = await authorization.authenticateAndAuthorize({
45
45
  headers: {
46
- 'Cookie': `FD-Authorization=${process.env.FD_AUTH_COOKIE_PROD};`,
46
+ 'Cookie': `FD-Authorization=${process.env.FD_AUTH_COOKIE_PROD};`,
47
47
  },
48
48
  action: Permissions.AnyAuditLogs,
49
49
  resource: {
50
- id: "org12345",
51
- type: "Org",
50
+ id: "org12345",
51
+ type: "Org",
52
52
  }
53
53
  });
54
54
 
55
55
  expect(authorizationResponse.status).toBe(200);
56
56
  expect(authorizationResponse.data.authentication.authenticated).toBe(true);
57
- expect(authorizationResponse.data.authentication.principal?.type).toBe("User");
58
- expect(authorizationResponse.data.authentication.principal?.id).toBe("8147747");
57
+ expect(authorizationResponse.data.authentication.principal?.type).toBe("User");
58
+ expect(authorizationResponse.data.authentication.principal?.id).toBe("8147747");
59
59
  });
60
60
 
61
- it('should not authenticate and authorize with an invalid FD-Authorization cookie', async () => {
61
+ it('should not authenticate and authorize with an invalid FD-Authorization cookie', async () => {
62
62
  try {
63
63
  await authorization.authenticateAndAuthorize({
64
64
  headers: {
65
- 'Cookie': `FD-Authorization=not-a-valid-cookie;`,
65
+ 'Cookie': `FD-Authorization=not-a-valid-cookie;`,
66
66
  },
67
67
  action: Permissions.AnyAuditLogs,
68
68
  resource: {
69
- id: "org12345",
70
- type: "Org",
69
+ id: "org12345",
70
+ type: "Org",
71
71
  },
72
72
  });
73
73
  } catch (error: any) {
74
74
  expect(error.response.status).toBe(401);
75
- expect(error.response.data.message).toBe("Unauthenticated");
75
+ expect(error.response.data.message).toBe("Unauthenticated");
76
76
  }
77
77
  });
78
78
 
79
- it('should authenticate and authorize with a valid Bearer token', async () => {
80
- const authorizationResponse = await authorization.authenticateAndAuthorize({
79
+ it('should authenticate and authorize with a valid Bearer token', async () => {
80
+ const authorizationResponse = await authorization.authenticateAndAuthorize({
81
81
  headers: {
82
- 'Authorization': `Bearer ${process.env.FLIPDISH_BEARER_TOKEN_PROD}`,
82
+ 'Authorization': `Bearer ${process.env.FLIPDISH_BEARER_TOKEN_PROD}`,
83
83
  },
84
84
  action: Permissions.AnyAuditLogs,
85
85
  resource: {
86
- id: "org12345",
87
- type: "Org",
86
+ id: "org12345",
87
+ type: "Org",
88
88
  }
89
89
  });
90
90
 
91
91
  expect(authorizationResponse.status).toBe(200);
92
92
  expect(authorizationResponse.data.authentication.authenticated).toBe(true);
93
- expect(authorizationResponse.data.authentication.principal?.type).toBe("User");
94
- expect(authorizationResponse.data.authentication.principal?.id).toBe("8147747");
93
+ expect(authorizationResponse.data.authentication.principal?.type).toBe("User");
94
+ expect(authorizationResponse.data.authentication.principal?.id).toBe("8147747");
95
95
  });
96
96
  });
97
97
 
98
98
 
99
- test('Authorize', async () => {
100
- let testPrincipal: any = {
101
- id: "12345",
102
- type: "User",
99
+ test('Authorize', async () => {
100
+ let testPrincipal: any = {
101
+ id: "12345",
102
+ type: "User",
103
103
  };
104
104
 
105
- let testResource: any = {
106
- id: "org12345",
107
- type: "Org",
105
+ let testResource: any = {
106
+ id: "org12345",
107
+ type: "Org",
108
108
  };
109
109
 
110
- const authorizationResponse = await authorization.authorize({
110
+ const authorizationResponse = await authorization.authorize({
111
111
  principal: testPrincipal,
112
112
  action: Permissions.AnyAuditLogs,
113
113
  resource: testResource
114
114
  });
115
115
  expect(authorizationResponse.status).toBe(200);
116
116
  expect(authorizationResponse.data.allowed).toBe(false);
117
- expect(authorizationResponse.data.decision).toBe("DENY");
117
+ expect(authorizationResponse.data.decision).toBe("DENY");
118
118
  });
119
119
  });
120
120
  });
package/configuration.ts CHANGED
@@ -100,7 +100,7 @@ export class Configuration {
100
100
 
101
101
  const extraHeaders = param.useDefaultUserAgent ? {} : {
102
102
  headers: {
103
- "user-agent": "Flipdish authorization typescript SDK / 0.0.1"
103
+ "user-agent": "Flipdish authorization typescript SDK / 0.0.2-rc.1756734895"
104
104
  }
105
105
  };
106
106
 
@@ -36,7 +36,7 @@ var Configuration = /** @class */ (function () {
36
36
  this.serverIndex = param.serverIndex;
37
37
  var extraHeaders = param.useDefaultUserAgent ? {} : {
38
38
  headers: {
39
- "user-agent": "Flipdish authorization typescript SDK / 0.0.1"
39
+ "user-agent": "Flipdish authorization typescript SDK / 0.0.2-rc.1756734895"
40
40
  }
41
41
  };
42
42
  this.baseOptions = __assign(__assign({}, extraHeaders), param.baseOptions);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flipdish/authorization",
3
- "version": "0.0.1",
3
+ "version": "0.0.2-rc.1756734895",
4
4
  "description": "OpenAPI client for @flipdish/authorization",
5
5
  "author": "OpenAPI-Generator Contributors",
6
6
  "repository": {