addigy 2.2.2 → 2.3.0

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/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Extension, IAddigyConfig, IAddigyInternalAuthObject, PPPCInput } from './types';
1
+ import { Extension, IAddigyConfig, IAddigyInternalAuthObject, NotificationSettings, PPPCInput, SupportedOsVersions } from './types';
2
2
  export * from './types';
3
3
  declare enum AlertStatus {
4
4
  Acknowledged = "Acknowledged",
@@ -58,11 +58,14 @@ export declare class Addigy {
58
58
  allowedSystemExtensions?: Extension[];
59
59
  allowedSystemExtensionTypes?: Extension[];
60
60
  allowedTeamIdentifiers?: string[];
61
- }): Promise<object>;
61
+ }): Promise<any>;
62
+ createNotificationSettingsPolicy(authObject: IAddigyInternalAuthObject, name: string, notificationSettings: NotificationSettings[]): Promise<any>;
63
+ createCustomProfile(authObject: IAddigyInternalAuthObject, name: string, customProfileText: string, supportedOsVersions: SupportedOsVersions, payloadScope?: 'System' | 'User', is_profile_signed?: boolean): Promise<any>;
62
64
  createPPPCPolicy(authObject: IAddigyInternalAuthObject, name: string, pppcPolicy: PPPCInput[]): Promise<any>;
63
65
  getMdmConfigurations(authObject: IAddigyInternalAuthObject): Promise<any[]>;
64
66
  getMdmConfigurationByName(authObject: IAddigyInternalAuthObject, name: string): Promise<any>;
65
67
  getFileVaultKeys(authObject: IAddigyInternalAuthObject): Promise<object[]>;
68
+ toSnakeCase(text: string): string;
66
69
  getApnsCerts(authObject: IAddigyInternalAuthObject, next?: string, previous?: string): Promise<object[]>;
67
70
  getAuthObject(): Promise<IAddigyInternalAuthObject>;
68
71
  getImpersonationAuthObject(authObject: IAddigyInternalAuthObject, orgId: string): Promise<IAddigyInternalAuthObject>;
package/index.js CHANGED
@@ -16,6 +16,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
16
16
  exports.Addigy = void 0;
17
17
  const got_1 = __importDefault(require("got"));
18
18
  const uuid_1 = require("uuid");
19
+ const plist_1 = __importDefault(require("@expo/plist"));
19
20
  __exportStar(require("./types"), exports);
20
21
  var AlertStatus;
21
22
  (function (AlertStatus) {
@@ -533,7 +534,7 @@ class Addigy {
533
534
  method: 'POST',
534
535
  json: postBody,
535
536
  });
536
- return res.body;
537
+ return JSON.parse(res.body);
537
538
  }
538
539
  catch (err) {
539
540
  throw err;
@@ -548,7 +549,7 @@ class Addigy {
548
549
  },
549
550
  method: 'DELETE',
550
551
  });
551
- return res.body;
552
+ return JSON.parse(res.body);
552
553
  }
553
554
  catch (err) {
554
555
  throw err;
@@ -613,7 +614,7 @@ class Addigy {
613
614
  method: 'POST',
614
615
  json: { payloads: [payload] },
615
616
  });
616
- return res.body;
617
+ return JSON.parse(res.body);
617
618
  }
618
619
  catch (err) {
619
620
  throw err;
@@ -660,7 +661,67 @@ class Addigy {
660
661
  method: 'POST',
661
662
  json: { payloads: [payload] },
662
663
  });
663
- return res.body;
664
+ return JSON.parse(res.body);
665
+ }
666
+ catch (err) {
667
+ throw err;
668
+ }
669
+ }
670
+ async createNotificationSettingsPolicy(authObject, name, notificationSettings) {
671
+ const groupUUID = uuid_1.v4();
672
+ const payload = {
673
+ addigy_payload_type: 'com.addigy.notifications.com.apple.notificationsettings',
674
+ payload_type: 'com.apple.notificationsettings',
675
+ payload_version: 1,
676
+ payload_identifier: `com.addigy.notifications.com.apple.notificationsettings.${groupUUID}`,
677
+ payload_uuid: uuid_1.v4(),
678
+ payload_group_id: groupUUID,
679
+ payload_display_name: name,
680
+ notification_settings: notificationSettings,
681
+ };
682
+ let res = await this._addigyRequest('https://app-prod.addigy.com/api/mdm/user/profiles/configurations', {
683
+ headers: {
684
+ Cookie: `auth_token=${authObject.authToken};`,
685
+ origin: 'https://app-prod.addigy.com',
686
+ },
687
+ method: 'POST',
688
+ json: { payloads: [payload] },
689
+ });
690
+ return JSON.parse(res.body);
691
+ }
692
+ async createCustomProfile(authObject, name, customProfileText, supportedOsVersions, payloadScope = 'System', is_profile_signed = false) {
693
+ const groupUUID = uuid_1.v4();
694
+ const customProfileJson = plist_1.default.parse(customProfileText);
695
+ const updateCustomProfileJson = Object.entries(customProfileJson).reduce((acc, [key, value]) => {
696
+ acc[this.toSnakeCase(key)] = value;
697
+ return acc;
698
+ }, {});
699
+ const customProfileBase64 = Buffer.from(customProfileText).toString('base64');
700
+ const payload = {
701
+ addigy_payload_type: 'com.addigy.custom.mdm.payload',
702
+ payload_type: 'custom',
703
+ payload_version: 1,
704
+ payload_identifier: `com.addigy.custom.mdm.payload.${groupUUID}`,
705
+ payload_uuid: `custom-profile-${uuid_1.v4()}`,
706
+ payload_group_id: groupUUID,
707
+ payload_display_name: name,
708
+ is_profile_signed,
709
+ profile_json_data: updateCustomProfileJson,
710
+ decoded_profile_content: customProfileText,
711
+ custom_profile_content: customProfileBase64,
712
+ supported_os_versions: supportedOsVersions,
713
+ payload_scope: payloadScope,
714
+ };
715
+ try {
716
+ let res = await this._addigyRequest('https://app-prod.addigy.com/api/mdm/user/profiles/configurations', {
717
+ headers: {
718
+ Cookie: `auth_token=${authObject.authToken};`,
719
+ origin: 'https://app-prod.addigy.com',
720
+ },
721
+ method: 'POST',
722
+ json: { payloads: [payload] },
723
+ });
724
+ return JSON.parse(res.body);
664
725
  }
665
726
  catch (err) {
666
727
  throw err;
@@ -738,7 +799,7 @@ class Addigy {
738
799
  method: 'POST',
739
800
  json: { payloads: [payload] },
740
801
  });
741
- return res.body;
802
+ return JSON.parse(res.body);
742
803
  }
743
804
  async getMdmConfigurations(authObject) {
744
805
  var _a;
@@ -780,6 +841,11 @@ class Addigy {
780
841
  throw err;
781
842
  }
782
843
  }
844
+ toSnakeCase(text) {
845
+ return text
846
+ .replace(/([^\p{L}\d]+|(?<=\p{L})(?=\d)|(?<=\d)(?=\p{L})|(?<=[\p{Ll}\d])(?=\p{Lu})|(?<=\p{Lu})(?=\p{Lu}\p{Ll})|(?<=[\p{L}\d])(?=\p{Lu}\p{Ll}))/gu, '_')
847
+ .toLowerCase();
848
+ }
783
849
  async getApnsCerts(authObject, next, previous) {
784
850
  let url = 'https://app-prod.addigy.com/api/apn/user/apn/list';
785
851
  if (next) {
@@ -798,7 +864,7 @@ class Addigy {
798
864
  },
799
865
  method: 'GET',
800
866
  });
801
- return JSON.parse(res.body).mdm_app_list;
867
+ return JSON.parse(res.body).items;
802
868
  }
803
869
  catch (err) {
804
870
  throw err;
package/package.json CHANGED
@@ -6,6 +6,7 @@
6
6
  }
7
7
  },
8
8
  "dependencies": {
9
+ "@expo/plist": "0.0.18",
9
10
  "form-data": "4.0.0",
10
11
  "got": "11.8.2",
11
12
  "uuid": "8.3.2"
@@ -13,20 +14,20 @@
13
14
  "description": "",
14
15
  "devDependencies": {
15
16
  "@pliancy/eslint-config-ts": "0.0.5",
16
- "@pliancy/semantic-release-config-npm": "^2.1.0",
17
+ "@pliancy/semantic-release-config-npm": "2.1.0",
17
18
  "@types/got": "9.6.11",
18
19
  "@types/jest": "26.0.23",
19
20
  "@types/node": "15.12.5",
20
21
  "@types/uuid": "8.3.0",
21
- "commitizen": "^4.2.4",
22
+ "commitizen": "4.2.4",
22
23
  "cpy-cli": "3.1.1",
23
24
  "cz-conventional-changelog": "3.3.0",
24
25
  "gh-pages": "3.2.3",
25
- "husky": "^7.0.1",
26
+ "husky": "7.0.1",
26
27
  "jest": "27.0.6",
27
- "npm-run-all": "^4.1.5",
28
+ "npm-run-all": "4.1.5",
28
29
  "open": "8.2.1",
29
- "pinst": "^2.1.6",
30
+ "pinst": "2.1.6",
30
31
  "rimraf": "3.0.2",
31
32
  "ts-jest": "27.0.3",
32
33
  "typedoc": "0.21.2",
@@ -58,7 +59,7 @@
58
59
  "tsc": "tsc -p tsconfig.build.json"
59
60
  },
60
61
  "types": "index.d.ts",
61
- "version": "2.2.2",
62
+ "version": "2.3.0",
62
63
  "volta": {
63
64
  "node": "14.17.1",
64
65
  "yarn": "1.22.10"
package/types.d.ts CHANGED
@@ -10,8 +10,8 @@ export interface IAddigyInternalAuthObject {
10
10
  emailAddress: string;
11
11
  }
12
12
  export interface Payload {
13
- addigy_payload_type: 'com.addigy.syspolicy.system-extension-policy.com.apple.system-extension-policy' | 'com.addigy.TCC.configuration-profile-policy.com.apple.TCC.configuration-profile-policy' | 'com.addigy.syspolicy.kernel-extension-policy.com.apple.syspolicy.kernel-extension-policy';
14
- payload_type: 'com.apple.system-extension-policy' | 'com.apple.syspolicy.kernel-extension-policy' | 'com.apple.TCC.configuration-profile-policy';
13
+ addigy_payload_type: 'com.addigy.syspolicy.system-extension-policy.com.apple.system-extension-policy' | 'com.addigy.TCC.configuration-profile-policy.com.apple.TCC.configuration-profile-policy' | 'com.addigy.syspolicy.kernel-extension-policy.com.apple.syspolicy.kernel-extension-policy' | 'com.addigy.notifications.com.apple.notificationsettings' | 'com.addigy.custom.mdm.payload';
14
+ payload_type: 'com.apple.system-extension-policy' | 'com.apple.syspolicy.kernel-extension-policy' | 'com.apple.TCC.configuration-profile-policy' | 'com.apple.notificationsettings' | 'custom';
15
15
  payload_version: number;
16
16
  payload_identifier: string;
17
17
  payload_uuid: string;
@@ -109,3 +109,41 @@ export interface Extension {
109
109
  teamIdentifier: string;
110
110
  bundleIdentifiers: string[];
111
111
  }
112
+ export interface NotificationSettings {
113
+ bundle_identifier: string;
114
+ notifications_enabled: boolean;
115
+ show_in_lock_screen: boolean;
116
+ show_in_notification_center: boolean;
117
+ sounds_enabled: boolean;
118
+ badges_enabled: boolean;
119
+ critical_alert_enabled: boolean;
120
+ preview_type?: any;
121
+ alert_type?: any;
122
+ }
123
+ export interface NotificationSettingsPayload extends Payload {
124
+ notification_settings: NotificationSettings[];
125
+ }
126
+ export interface CustomProfilePayload extends Payload {
127
+ is_profile_signed: boolean;
128
+ custom_profile_content: string;
129
+ decoded_profile_content: string;
130
+ supported_os_versions: SupportedOsVersions;
131
+ payload_scope: 'System' | 'User';
132
+ profile_json_data: CustomProfileJSONData[];
133
+ }
134
+ export interface CustomProfileJSONData {
135
+ payload_identifier: string;
136
+ payload_removal_disallowed: boolean;
137
+ payload_scope: string;
138
+ payload_type: string;
139
+ payload_uuid: string;
140
+ payload_organization: string;
141
+ payload_version: number;
142
+ payload_display_name: string;
143
+ payload_content: any[];
144
+ }
145
+ export interface SupportedOsVersions {
146
+ macOS?: string;
147
+ iOS?: string;
148
+ tvOS?: string;
149
+ }