@flipdish/authorization 0.0.2-rc.1756734895 → 0.0.5-rc.1756734017

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.
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('Authorisation', () => {
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 authorise 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.2-rc.1756734895"
103
+ "user-agent": "Flipdish authorization typescript SDK / 0.0.5-rc.1756734017"
104
104
  }
105
105
  };
106
106
 
package/dist/api.js CHANGED
@@ -48,8 +48,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
48
48
  });
49
49
  };
50
50
  var __generator = (this && this.__generator) || function (thisArg, body) {
51
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
52
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
51
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
52
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
53
53
  function verb(n) { return function (v) { return step([n, v]); }; }
54
54
  function step(op) {
55
55
  if (f) throw new TypeError("Generator is already executing.");
package/dist/common.d.ts CHANGED
@@ -62,4 +62,4 @@ export declare const toPathString: (url: URL) => string;
62
62
  *
63
63
  * @export
64
64
  */
65
- export declare const createRequestFunction: (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) => <T = unknown, R = AxiosResponse<T, any>>(axios?: AxiosInstance, basePath?: string) => Promise<R>;
65
+ export declare const createRequestFunction: (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) => <T = unknown, R = AxiosResponse<T>>(axios?: AxiosInstance, basePath?: string) => Promise<R>;
package/dist/common.js CHANGED
@@ -33,8 +33,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
33
33
  });
34
34
  };
35
35
  var __generator = (this && this.__generator) || function (thisArg, body) {
36
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
37
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
36
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
37
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
38
38
  function verb(n) { return function (v) { return step([n, v]); }; }
39
39
  function step(op) {
40
40
  if (f) throw new TypeError("Generator is already executing.");
@@ -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.2-rc.1756734895"
39
+ "user-agent": "Flipdish authorization typescript SDK / 0.0.5-rc.1756734017"
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.2-rc.1756734895",
3
+ "version": "0.0.5-rc.1756734017",
4
4
  "description": "OpenAPI client for @flipdish/authorization",
5
5
  "author": "OpenAPI-Generator Contributors",
6
6
  "repository": {