@platform-x/hep-push-notification-client 1.0.5 → 1.0.6
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,38 +1,58 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
//
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
//
|
|
35
|
-
//
|
|
36
|
-
|
|
37
|
-
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.SecretKeyServices = void 0;
|
|
16
|
+
const hep_secret_access_1 = require("hep-secret-access");
|
|
17
|
+
const constants_1 = require("../../platform-x/constants");
|
|
18
|
+
const config_1 = __importDefault(require("../../config"));
|
|
19
|
+
class SecretKeyServices {
|
|
20
|
+
constructor() {
|
|
21
|
+
this.ruleCache = new Map();
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Fetches all the secret keys
|
|
25
|
+
*/
|
|
26
|
+
getSecretKeys() {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
try {
|
|
29
|
+
// Initialize secret manager object
|
|
30
|
+
if (this.ruleCache.has('secret_data')) {
|
|
31
|
+
return this.ruleCache.get('secret_data');
|
|
32
|
+
}
|
|
33
|
+
const secretObject = (0, hep_secret_access_1.secretManager)();
|
|
34
|
+
// If secret mode is ENV – read one by one
|
|
35
|
+
// for local testing
|
|
36
|
+
if ((config_1.default === null || config_1.default === void 0 ? void 0 : config_1.default.SECRET_MODE) === 'env') {
|
|
37
|
+
const keyConfig = {};
|
|
38
|
+
for (const key of Object.values(constants_1.DynamicValues)) {
|
|
39
|
+
// Fetch individual value (existing read() method)
|
|
40
|
+
const value = yield secretObject.read(key);
|
|
41
|
+
keyConfig[key] = value;
|
|
42
|
+
}
|
|
43
|
+
this.ruleCache.set('secret_data', keyConfig);
|
|
44
|
+
return keyConfig;
|
|
45
|
+
}
|
|
46
|
+
// else – fetch all secrets from GSM
|
|
47
|
+
const data = yield secretObject.readAllSecrets();
|
|
48
|
+
this.ruleCache.set('secret_data', data);
|
|
49
|
+
return data;
|
|
50
|
+
}
|
|
51
|
+
catch (err) {
|
|
52
|
+
return {};
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.SecretKeyServices = SecretKeyServices;
|
|
38
58
|
//# sourceMappingURL=secretKeyManager.js.map
|
package/dist/src/index.js
CHANGED
|
@@ -21,7 +21,7 @@ exports.getPushNotificationSecrets = getPushNotificationSecrets;
|
|
|
21
21
|
// export const testval = async () => {
|
|
22
22
|
// let id: any = new pushNotificationManager();
|
|
23
23
|
// // // .iamAuthenticator('kiwi', false);
|
|
24
|
-
// let client = await id.pushNotificationProvider(
|
|
24
|
+
// let client = await id.pushNotificationProvider({sitename:"kiwi", provider: "fcm"});
|
|
25
25
|
// // // getuserdetails
|
|
26
26
|
// let validate: any = await client.sendNotificationsToTopics(['articles'], {
|
|
27
27
|
// title: 'Test Title',
|
|
@@ -30,6 +30,12 @@ exports.getPushNotificationSecrets = getPushNotificationSecrets;
|
|
|
30
30
|
// }
|
|
31
31
|
// );
|
|
32
32
|
// console.log('>>>>>>>>>>>>>idd>>>>', validate)
|
|
33
|
+
// let id: any = new pushNotificationManager();
|
|
34
|
+
// // // .iamAuthenticator('kiwi', false);
|
|
35
|
+
// let client = await id.pushNotificationProvider({sitename:"kiwi", provider: "fcm"});
|
|
36
|
+
// // // getuserdetails
|
|
37
|
+
// let validate: any = await client.fetchTopics();
|
|
38
|
+
// console.log('>>>>>>>>>>>>>idd>>>>', validate)
|
|
33
39
|
// }
|
|
34
40
|
// testval()
|
|
35
41
|
//# sourceMappingURL=index.js.map
|
|
@@ -7,7 +7,7 @@ export declare class FcmClient implements PushNotifyProvider {
|
|
|
7
7
|
sendPushNotification(token: string, notificationMessage: any): Promise<any>;
|
|
8
8
|
sendChunkedPushNotification(tokens: string[], notificationMessage: string): Promise<unknown>;
|
|
9
9
|
chunkTokens(tokens: string[], chunkSize: number): Promise<any>;
|
|
10
|
-
fetchTopics(): Promise<any>;
|
|
10
|
+
fetchTopics(isArrayRes?: boolean): Promise<any>;
|
|
11
11
|
/**
|
|
12
12
|
* Method to send notification based on topics
|
|
13
13
|
* @param topics
|
|
@@ -129,7 +129,7 @@ class FcmClient {
|
|
|
129
129
|
}
|
|
130
130
|
});
|
|
131
131
|
}
|
|
132
|
-
fetchTopics() {
|
|
132
|
+
fetchTopics(isArrayRes) {
|
|
133
133
|
return __awaiter(this, void 0, void 0, function* () {
|
|
134
134
|
try {
|
|
135
135
|
const db = admin.firestore(); // Use Firestore// Firebase Realtime Database reference
|
|
@@ -140,7 +140,12 @@ class FcmClient {
|
|
|
140
140
|
}
|
|
141
141
|
const topics = [];
|
|
142
142
|
snapshot.forEach((doc) => {
|
|
143
|
-
|
|
143
|
+
if (isArrayRes) {
|
|
144
|
+
topics.push(doc.data().name); // Assuming each topic has a 'name' field
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
topics.push({ name: doc.data().name }); // Assuming each topic has a 'name' field
|
|
148
|
+
}
|
|
144
149
|
});
|
|
145
150
|
return topics;
|
|
146
151
|
}
|