@flipdish/authorization 0.0.2-rc.1756734895 → 0.0.3-rc.1756733706

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/authorisation';
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('Authorisation 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,90 @@ 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({
45
- headers: {
46
- 'Cookie': `FD-Authorization=${process.env.FD_AUTH_COOKIE_PROD};`,
47
- },
48
- action: Permissions.AnyAuditLogs,
49
- resource: {
50
- id: "org12345",
51
- type: "Org",
42
+ describe('Authenticate and Authorise', () => {
43
+ it('should authenticate and authorise with a valid FD-Authorization cookie', async () => {
44
+ const authorizationResponse = await authorization.authenticateAndAuthorize({
45
+ authenticateAndAuthorizeRequest: {
46
+ headers: {
47
+ 'Cookie': `FD-Authorization=${process.env.FD_AUTH_COOKIE_PROD};`,
48
+ },
49
+ action: Permissions.AnyAuditLogs,
50
+ resource: {
51
+ id: "org12345",
52
+ type: "Org",
53
+ }
52
54
  }
53
55
  });
54
56
 
55
57
  expect(authorizationResponse.status).toBe(200);
56
58
  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");
59
+ expect(authorizationResponse.data.authentication.principal?.type).toBe("User");
60
+ expect(authorizationResponse.data.authentication.principal?.id).toBe("8147747");
59
61
  });
60
62
 
61
- it('should not authenticate and authorize with an invalid FD-Authorization cookie', async () => {
63
+ it('should not authenticate and authorise with an invalid FD-Authorization cookie', async () => {
62
64
  try {
63
65
  await authorization.authenticateAndAuthorize({
64
- headers: {
65
- 'Cookie': `FD-Authorization=not-a-valid-cookie;`,
66
- },
67
- action: Permissions.AnyAuditLogs,
68
- resource: {
69
- id: "org12345",
70
- type: "Org",
71
- },
66
+ authenticateAndAuthorizeRequest: {
67
+ headers: {
68
+ 'Cookie': `FD-Authorization=not-a-valid-cookie;`,
69
+ },
70
+ action: Permissions.AnyAuditLogs,
71
+ resource: {
72
+ id: "org12345",
73
+ type: "Org",
74
+ },
75
+ }
72
76
  });
73
77
  } catch (error: any) {
74
78
  expect(error.response.status).toBe(401);
75
- expect(error.response.data.message).toBe("Unauthenticated");
79
+ expect(error.response.data.message).toBe("Unauthenticated");
76
80
  }
77
81
  });
78
82
 
79
- it('should authenticate and authorize with a valid Bearer token', async () => {
80
- const authorizationResponse = await authorization.authenticateAndAuthorize({
81
- headers: {
82
- 'Authorization': `Bearer ${process.env.FLIPDISH_BEARER_TOKEN_PROD}`,
83
- },
84
- action: Permissions.AnyAuditLogs,
85
- resource: {
86
- id: "org12345",
87
- type: "Org",
83
+ it('should authenticate and authorise with a valid Bearer token', async () => {
84
+ const authorizationResponse = await authorization.authenticateAndAuthorize({
85
+ authenticateAndAuthorizeRequest: {
86
+ headers: {
87
+ 'Authorization': `Bearer ${process.env.FLIPDISH_BEARER_TOKEN_PROD}`,
88
+ },
89
+ action: Permissions.AnyAuditLogs,
90
+ resource: {
91
+ id: "org12345",
92
+ type: "Org",
93
+ }
88
94
  }
89
95
  });
90
96
 
91
97
  expect(authorizationResponse.status).toBe(200);
92
98
  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");
99
+ expect(authorizationResponse.data.authentication.principal?.type).toBe("User");
100
+ expect(authorizationResponse.data.authentication.principal?.id).toBe("8147747");
95
101
  });
96
102
  });
97
103
 
98
104
 
99
- test('Authorize', async () => {
100
- let testPrincipal: any = {
101
- id: "12345",
102
- type: "User",
105
+ test('Authorise', async () => {
106
+ let testPrincipal: any = {
107
+ id: "12345",
108
+ type: "User",
103
109
  };
104
110
 
105
- let testResource: any = {
106
- id: "org12345",
107
- type: "Org",
111
+ let testResource: any = {
112
+ id: "org12345",
113
+ type: "Org",
108
114
  };
109
115
 
110
- const authorizationResponse = await authorization.authorize({
111
- principal: testPrincipal,
112
- action: Permissions.AnyAuditLogs,
113
- resource: testResource
116
+ const authorizationResponse = await authorization.authorize({
117
+ authorizationRequest: {
118
+ principal: testPrincipal,
119
+ action: Permissions.AnyAuditLogs,
120
+ resource: testResource
121
+ }
114
122
  });
115
123
  expect(authorizationResponse.status).toBe(200);
116
124
  expect(authorizationResponse.data.allowed).toBe(false);
117
- expect(authorizationResponse.data.decision).toBe("DENY");
125
+ expect(authorizationResponse.data.decision).toBe("DENY");
118
126
  });
119
127
  });
120
128
  });
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.3-rc.1756733706"
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.3-rc.1756733706"
40
40
  }
41
41
  };
42
42
  this.baseOptions = __assign(__assign({}, extraHeaders), param.baseOptions);
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@flipdish/authorization",
3
- "version": "0.0.2-rc.1756734895",
3
+ "version": "0.0.3-rc.1756733706",
4
4
  "description": "OpenAPI client for @flipdish/authorization",
5
5
  "author": "OpenAPI-Generator Contributors",
6
6
  "repository": {
7
- "type": "git"
7
+ "type": "git",
8
+ "url": "https://github.com/GIT_USER_ID/GIT_REPO_ID.git"
8
9
  },
9
10
  "keywords": [
10
11
  "axios",