diff --git a/.github/actions/send-email/package-lock.json b/.github/actions/send-email/package-lock.json index 7c530a0d4f..2963ba307e 100644 --- a/.github/actions/send-email/package-lock.json +++ b/.github/actions/send-email/package-lock.json @@ -57,11 +57,11 @@ "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" }, "node_modules/axios": { - "version": "1.6.7", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.7.tgz", - "integrity": "sha512-/hDJGff6/c7u0hDkvkGxR/oy6CbCs8ziCsC7SqmhjfozqiJGc8Z11wrv9z9lYfY4K8l+H9TpjcMDX0xOZmx+RA==", + "version": "1.7.4", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.4.tgz", + "integrity": "sha512-DukmaFRnY6AzAALSH4J2M3k6PkaC+MfaAGdEERRWcC9q3/TWQwLpHR8ZRLKTdQ3aBDL64EdluRDjJqKw+BPZEw==", "dependencies": { - "follow-redirects": "^1.15.4", + "follow-redirects": "^1.15.6", "form-data": "^4.0.0", "proxy-from-env": "^1.1.0" } diff --git a/etc/firebase-admin.messaging.api.md b/etc/firebase-admin.messaging.api.md index 84cb3e9b84..78cb17c5ce 100644 --- a/etc/firebase-admin.messaging.api.md +++ b/etc/firebase-admin.messaging.api.md @@ -198,11 +198,13 @@ export class Messaging { sendEachForMulticast(message: MulticastMessage, dryRun?: boolean): Promise; // @deprecated sendMulticast(message: MulticastMessage, dryRun?: boolean): Promise; + // @deprecated sendToCondition(condition: string, payload: MessagingPayload, options?: MessagingOptions): Promise; // @deprecated sendToDevice(registrationTokenOrTokens: string | string[], payload: MessagingPayload, options?: MessagingOptions): Promise; // @deprecated sendToDeviceGroup(notificationKey: string, payload: MessagingPayload, options?: MessagingOptions): Promise; + // @deprecated sendToTopic(topic: string, payload: MessagingPayload, options?: MessagingOptions): Promise; subscribeToTopic(registrationTokenOrTokens: string | string[], topic: string): Promise; unsubscribeFromTopic(registrationTokenOrTokens: string | string[], topic: string): Promise; diff --git a/package-lock.json b/package-lock.json index 42849267a2..a811d0c732 100644 --- a/package-lock.json +++ b/package-lock.json @@ -441,9 +441,9 @@ } }, "@firebase/app": { - "version": "0.10.8", - "resolved": "https://registry.npmjs.org/@firebase/app/-/app-0.10.8.tgz", - "integrity": "sha512-xSLmW0/RShcnUEXH7l+wC0AFWaUtty4tUFF2loIgbtXTRmra0UH/SqYDf/IcfreUninRrCsusNmvoTidGkXJPw==", + "version": "0.10.9", + "resolved": "https://registry.npmjs.org/@firebase/app/-/app-0.10.9.tgz", + "integrity": "sha512-AmGlPg/4SoDhwCdvVDeZsN5Yn+czYD/m/NAEOOCOhwn3Cz1xmEFKAKcyZKKahLrh5QPmge5Adyw+sk3cBTubBg==", "dev": true, "requires": { "@firebase/component": "0.6.8", @@ -480,12 +480,12 @@ "integrity": "sha512-LMs47Vinv2HBMZi49C09dJxp0QT5LwDzFaVGf/+ITHe3BlIhUiLNttkATSXplc89A2lAaeTqjgqVkiRfUGyQiQ==" }, "@firebase/app-compat": { - "version": "0.2.38", - "resolved": "https://registry.npmjs.org/@firebase/app-compat/-/app-compat-0.2.38.tgz", - "integrity": "sha512-36ZrSvkYLW7QR01Sii2X+IY18ErMpRg6e2B2f/DVTtJBolthwXOnNBps+wvaVBvegdvdVPspgDXZUV0ppqh45w==", + "version": "0.2.39", + "resolved": "https://registry.npmjs.org/@firebase/app-compat/-/app-compat-0.2.39.tgz", + "integrity": "sha512-NnTFywe+M/jxZn751NIEhidgDePiDvlcfabvGxBy4YbU1E+b0TpEuJUnm3L6YDZtaZLVEz8ieoq9wbJkgGZ2rg==", "dev": true, "requires": { - "@firebase/app": "0.10.8", + "@firebase/app": "0.10.9", "@firebase/component": "0.6.8", "@firebase/logger": "0.4.2", "@firebase/util": "1.9.7", @@ -727,9 +727,9 @@ "optional": true }, "@google-cloud/storage": { - "version": "7.12.0", - "resolved": "https://registry.npmjs.org/@google-cloud/storage/-/storage-7.12.0.tgz", - "integrity": "sha512-122Ui67bhnf8MkRnxQAC5lf7wPGkPP5hL3+J5s9HHDw2J9RpaMmnV8iahn+RUn9BH70W6uRe6nMZLXiRaJM/3g==", + "version": "7.12.1", + "resolved": "https://registry.npmjs.org/@google-cloud/storage/-/storage-7.12.1.tgz", + "integrity": "sha512-Z3ZzOnF3YKLuvpkvF+TjQ6lztxcAyTILp+FjKonmVpEwPa9vFvxpZjubLR4sB6bf19i/8HL2AXRjA0YFgHFRmQ==", "optional": true, "requires": { "@google-cloud/paginator": "^5.0.0", @@ -738,7 +738,7 @@ "abort-controller": "^3.0.0", "async-retry": "^1.3.3", "duplexify": "^4.1.3", - "fast-xml-parser": "^4.3.0", + "fast-xml-parser": "^4.4.1", "gaxios": "^6.0.2", "google-auth-library": "^9.6.3", "html-entities": "^2.5.2", @@ -1574,11 +1574,11 @@ } }, "@types/node": { - "version": "22.1.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.1.0.tgz", - "integrity": "sha512-AOmuRF0R2/5j1knA3c6G3HOk523Ga+l+ZXltX8SF1+5oqcXijjfTd8fY3XRZqSihEu9XhtQnKYLmkFaoxgsJHw==", + "version": "22.3.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.3.0.tgz", + "integrity": "sha512-nrWpWVaDZuaVc5X84xJ0vNrLvomM205oQyLsRt7OHNZbSHslcWsvgFR7O7hire2ZonjLrWBbedmotmIlJDVd6g==", "requires": { - "undici-types": "~6.13.0" + "undici-types": "~6.18.2" } }, "@types/qs": { @@ -5855,9 +5855,9 @@ "dev": true }, "mocha": { - "version": "10.7.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.7.0.tgz", - "integrity": "sha512-v8/rBWr2VO5YkspYINnvu81inSz2y3ODJrhO175/Exzor1RcEZZkizgE2A+w/CAXXoESS8Kys5E62dOHGHzULA==", + "version": "10.7.3", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.7.3.tgz", + "integrity": "sha512-uQWxAu44wwiACGqjbPYmjo7Lg8sFrS3dQe7PP2FQI+woptP4vZXSMcfMyFL/e1yFEeEpV4RtyTpZROOKmxis+A==", "dev": true, "requires": { "ansi-colors": "^4.1.3", @@ -8225,9 +8225,9 @@ "dev": true }, "undici-types": { - "version": "6.13.0", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.13.0.tgz", - "integrity": "sha512-xtFJHudx8S2DSoujjMd1WeWvn7KKWFRESZTMeL1RptAYERu29D6jphMjjY+vn96jvN3kVPDNxU/E13VTaXj6jg==" + "version": "6.18.2", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.18.2.tgz", + "integrity": "sha512-5ruQbENj95yDYJNS3TvcaxPMshV7aizdv/hWYjGIKoANWKjhWNBsr2YEuYZKodQulB1b8l7ILOuDQep3afowQQ==" }, "unique-stream": { "version": "2.3.1", diff --git a/src/messaging/messaging.ts b/src/messaging/messaging.ts index ad78783fb9..38c6edcc42 100644 --- a/src/messaging/messaging.ts +++ b/src/messaging/messaging.ts @@ -686,6 +686,8 @@ export class Messaging { * * @returns A promise fulfilled with the server's response after the message * has been sent. + * + * @deprecated Use {@link Messaging.send} instead. */ public sendToTopic( topic: string, @@ -737,6 +739,8 @@ export class Messaging { * * @returns A promise fulfilled with the server's response after the message * has been sent. + * + * @deprecated Use {@link Messaging.send} instead. */ public sendToCondition( condition: string, diff --git a/test/integration/messaging.spec.ts b/test/integration/messaging.spec.ts index 8292637faf..dc6d662f0b 100644 --- a/test/integration/messaging.spec.ts +++ b/test/integration/messaging.spec.ts @@ -17,25 +17,20 @@ import * as chai from 'chai'; import * as chaiAsPromised from 'chai-as-promised'; import { Message, MulticastMessage, getMessaging } from '../../lib/messaging/index'; -import { legacyTransportApp } from './setup'; chai.should(); chai.use(chaiAsPromised); const expect = chai.expect; -// The registration token and notification key have the proper format, but are not guaranteed to +// The registration token have the proper format, but are not guaranteed to // work. The intention of these integration tests is that the endpoints returns the proper payload, // but it is hard to ensure these tokens will always be valid. The tests below should still pass // even if they are rotated or invalid. const registrationToken = 'fGw0qy4TGgk:APA91bGtWGjuhp4WRhHXgbabIYp1jxEKI08ofj_v1bKhWAGJQ4e3arRCW' + 'zeTfHaLz83mBnDh0aPWB1AykXAVUUGl2h1wT4XI6XazWpvY7RBUSYfoxtqSWGIm2nvWh2BOP1YG501SsRoE'; -const notificationKey = 'APA91bFYr4cWCkDs_H9VY2Ai6Erw1ABup1NEYqBjz70O8SzxjpALp_bN913XJMlOepaVv9e' + - 'Qs2QrtqX_RZ6cVVv4czgTQXg62qicITR6tQDizaFilDnlVf0'; -const registrationTokens = [registrationToken + '0', registrationToken + '1', registrationToken + '2']; const topic = 'mock-topic'; -const condition = '"test0" in topics || ("test1" in topics && "test2" in topics)'; const invalidTopic = 'topic-$%#^'; @@ -83,30 +78,7 @@ const message: Message = { topic: 'foo-bar', }; -const payload = { - data: { - foo: 'bar', - }, - notification: { - title: 'Message title', - body: 'Message body', - }, -}; - -const invalidPayload: any = { - foo: 'bar', -}; - -const options = { - timeToLive: 60, -}; - describe('admin.messaging', () => { - - before(() => { - getMessaging(legacyTransportApp).enableLegacyHttpTransport() - }) - it('send(message, dryRun) returns a message ID', () => { return getMessaging().send(message, true) .then((name) => { @@ -115,37 +87,6 @@ describe('admin.messaging', () => { }); it('sendEach()', () => { - const messages: Message[] = [message, message, message]; - return getMessaging(legacyTransportApp).sendEach(messages, true) - .then((response) => { - expect(response.responses.length).to.equal(messages.length); - expect(response.successCount).to.equal(messages.length); - expect(response.failureCount).to.equal(0); - response.responses.forEach((resp) => { - expect(resp.success).to.be.true; - expect(resp.messageId).matches(/^projects\/.*\/messages\/.*$/); - }); - }); - }); - - it('sendEach(500)', () => { - const messages: Message[] = []; - for (let i = 0; i < 500; i++) { - messages.push({ topic: `foo-bar-${i % 10}` }); - } - return getMessaging(legacyTransportApp).sendEach(messages, true) - .then((response) => { - expect(response.responses.length).to.equal(messages.length); - expect(response.successCount).to.equal(messages.length); - expect(response.failureCount).to.equal(0); - response.responses.forEach((resp) => { - expect(resp.success).to.be.true; - expect(resp.messageId).matches(/^projects\/.*\/messages\/.*$/); - }); - }); - }); - - it('sendEach() using HTTP2', () => { const messages: Message[] = [message, message, message]; return getMessaging().sendEach(messages, true) .then((response) => { @@ -159,7 +100,7 @@ describe('admin.messaging', () => { }); }); - it('sendEach(500) using HTTP2', () => { + it('sendEach(500)', () => { const messages: Message[] = []; for (let i = 0; i < 500; i++) { messages.push({ topic: `foo-bar-${i % 10}` }); @@ -176,57 +117,7 @@ describe('admin.messaging', () => { }); }); - it('sendAll()', () => { - const messages: Message[] = [message, message, message]; - return getMessaging().sendAll(messages, true) - .then((response) => { - expect(response.responses.length).to.equal(messages.length); - expect(response.successCount).to.equal(messages.length); - expect(response.failureCount).to.equal(0); - response.responses.forEach((resp) => { - expect(resp.success).to.be.true; - expect(resp.messageId).matches(/^projects\/.*\/messages\/.*$/); - }); - }); - }); - - it('sendAll(500)', () => { - const messages: Message[] = []; - for (let i = 0; i < 500; i++) { - messages.push({ topic: `foo-bar-${i % 10}` }); - } - return getMessaging().sendAll(messages, true) - .then((response) => { - expect(response.responses.length).to.equal(messages.length); - expect(response.successCount).to.equal(messages.length); - expect(response.failureCount).to.equal(0); - response.responses.forEach((resp) => { - expect(resp.success).to.be.true; - expect(resp.messageId).matches(/^projects\/.*\/messages\/.*$/); - }); - }); - }); - it('sendEachForMulticast()', () => { - const multicastMessage: MulticastMessage = { - data: message.data, - android: message.android, - tokens: ['not-a-token', 'also-not-a-token'], - }; - return getMessaging(legacyTransportApp).sendEachForMulticast(multicastMessage, true) - .then((response) => { - expect(response.responses.length).to.equal(2); - expect(response.successCount).to.equal(0); - expect(response.failureCount).to.equal(2); - response.responses.forEach((resp) => { - expect(resp.success).to.be.false; - expect(resp.messageId).to.be.undefined; - expect(resp.error).to.have.property('code', 'messaging/invalid-argument'); - }); - }); - }); - - it('sendEachForMulticast() using HTTP2', () => { const multicastMessage: MulticastMessage = { data: message.data, android: message.android, @@ -245,85 +136,6 @@ describe('admin.messaging', () => { }); }); - it('sendMulticast()', () => { - const multicastMessage: MulticastMessage = { - data: message.data, - android: message.android, - tokens: ['not-a-token', 'also-not-a-token'], - }; - return getMessaging().sendMulticast(multicastMessage, true) - .then((response) => { - expect(response.responses.length).to.equal(2); - expect(response.successCount).to.equal(0); - expect(response.failureCount).to.equal(2); - response.responses.forEach((resp) => { - expect(resp.success).to.be.false; - expect(resp.messageId).to.be.undefined; - expect(resp.error).to.have.property('code', 'messaging/invalid-argument'); - }); - }); - }); - - it('sendToDevice(token) returns a response with multicast ID', () => { - return getMessaging().sendToDevice(registrationToken, payload, options) - .then((response) => { - expect(typeof response.multicastId).to.equal('number'); - }); - }); - - it('sendToDevice(token-list) returns a response with multicat ID', () => { - return getMessaging().sendToDevice(registrationTokens, payload, options) - .then((response) => { - expect(typeof response.multicastId).to.equal('number'); - }); - }); - - it.skip('sendToDeviceGroup() returns a response with success count', () => { - return getMessaging().sendToDeviceGroup(notificationKey, payload, options) - .then((response) => { - expect(typeof response.successCount).to.equal('number'); - }); - }); - - it('sendToTopic() returns a response with message ID', () => { - return getMessaging().sendToTopic(topic, payload, options) - .then((response) => { - expect(typeof response.messageId).to.equal('number'); - }); - }); - - it('sendToCondition() returns a response with message ID', () => { - return getMessaging().sendToCondition(condition, payload, options) - .then((response) => { - expect(typeof response.messageId).to.equal('number'); - }); - }); - - it('sendToDevice(token) fails when called with invalid payload', () => { - return getMessaging().sendToDevice(registrationToken, invalidPayload, options) - .should.eventually.be.rejected.and.have.property('code', 'messaging/invalid-payload'); - }); - - it('sendToDevice(token-list) fails when called with invalid payload', () => { - return getMessaging().sendToDevice(registrationTokens, invalidPayload, options) - .should.eventually.be.rejected.and.have.property('code', 'messaging/invalid-payload'); - }); - - it('sendToDeviceGroup() fails when called with invalid payload', () => { - return getMessaging().sendToDeviceGroup(notificationKey, invalidPayload, options) - .should.eventually.be.rejected.and.have.property('code', 'messaging/invalid-payload'); - }); - - it('sendToTopic() fails when called with invalid payload', () => { - return getMessaging().sendToTopic(topic, invalidPayload, options) - .should.eventually.be.rejected.and.have.property('code', 'messaging/invalid-payload'); - }); - - it('sendToCondition() fails when called with invalid payload', () => { - return getMessaging().sendToCondition(condition, invalidPayload, options) - .should.eventually.be.rejected.and.have.property('code', 'messaging/invalid-payload'); - }); - it('subscribeToTopic() returns a response with success count', () => { return getMessaging().subscribeToTopic(registrationToken, topic) .then((response) => {