@flipdish/authorization 0.1.0 → 0.1.2-rc.1756985320
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/.openapi-generator/FILES +1 -0
- package/README.md +23 -4
- package/configuration.ts +1 -1
- package/dist/configuration.js +1 -1
- package/package.json +1 -1
package/.openapi-generator/FILES
CHANGED
package/README.md
CHANGED
|
@@ -7,11 +7,12 @@ 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';
|
|
10
|
+
import { AuthorizationApi, Configuration, PermissionsApi, Permissions, UserPermissionsApi } from '@flipdish/authorization';
|
|
11
11
|
import { describe, expect, test, it } from '@jest/globals';
|
|
12
|
+
import axios from 'axios';
|
|
12
13
|
|
|
13
14
|
const basePath = "https://api.flipdish.co/auth/";
|
|
14
|
-
const
|
|
15
|
+
const bearerConfiguration = new Configuration({
|
|
15
16
|
basePath,
|
|
16
17
|
// to get the API key, you should follow these docs:
|
|
17
18
|
// https://developers.flipdish.com/docs/getting-started
|
|
@@ -21,8 +22,16 @@ const configuration = new Configuration({
|
|
|
21
22
|
// useDefaultUserAgent: true
|
|
22
23
|
});
|
|
23
24
|
|
|
24
|
-
const authorization = new AuthorizationApi(
|
|
25
|
-
const permissions = new PermissionsApi(
|
|
25
|
+
const authorization = new AuthorizationApi(bearerConfiguration);
|
|
26
|
+
const permissions = new PermissionsApi(bearerConfiguration);
|
|
27
|
+
|
|
28
|
+
// mimic brower config where cookies will be sent automatically
|
|
29
|
+
// you shouldn't need to pass an axios instance as the cookies will be
|
|
30
|
+
// sent automatically by the browser
|
|
31
|
+
const userPermissions = new UserPermissionsApi(
|
|
32
|
+
new Configuration({ basePath }), undefined,
|
|
33
|
+
axios.create({ headers: { 'Cookie': `FD-Authorization=${process.env.FD_AUTH_COOKIE_PROD_JM_CLIENT};` } }),
|
|
34
|
+
);
|
|
26
35
|
|
|
27
36
|
describe('Authorization Tests', () => {
|
|
28
37
|
describe('Authorization', () => {
|
|
@@ -39,6 +48,16 @@ describe('Authorization Tests', () => {
|
|
|
39
48
|
expect(permissionsResponse.data.permissions).toContain(Permissions.EditAppAssets);
|
|
40
49
|
});
|
|
41
50
|
|
|
51
|
+
describe('List User Permission Sets', () => {
|
|
52
|
+
it('should list user permission sets', async () => {
|
|
53
|
+
const userPermissionSetsResponse = await userPermissions.listOwnPermissions("org42068");
|
|
54
|
+
expect(userPermissionSetsResponse.status).toBe(200);
|
|
55
|
+
expect(userPermissionSetsResponse.data.resources).toBeDefined();
|
|
56
|
+
expect(userPermissionSetsResponse.data.resources).toHaveProperty("org42068");
|
|
57
|
+
expect(userPermissionSetsResponse.data.resources["org42068"].permissions.length).toBeGreaterThan(0);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
|
|
42
61
|
describe('Authenticate and Authorize', () => {
|
|
43
62
|
it('should authenticate and authorize with a valid FD-Authorization cookie', async () => {
|
|
44
63
|
const authorizationResponse = await authorization.authenticateAndAuthorize({
|
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.1.
|
|
103
|
+
"user-agent": "Flipdish authorization typescript SDK / 0.1.2-rc.1756985320"
|
|
104
104
|
}
|
|
105
105
|
};
|
|
106
106
|
|
package/dist/configuration.js
CHANGED
|
@@ -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.1.
|
|
39
|
+
"user-agent": "Flipdish authorization typescript SDK / 0.1.2-rc.1756985320"
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
42
|
this.baseOptions = __assign(__assign({}, extraHeaders), param.baseOptions);
|