Socket
Socket
Sign inDemoInstall

firebase-functions

Package Overview
Dependencies
Maintainers
1
Versions
114
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

firebase-functions - npm Package Compare versions

Comparing version 0.5.9 to 0.6.0

2

changelog.txt

@@ -1,1 +0,1 @@

important - Add ability to listen to granular create/update/delete database events by using onCreate, onUpdate, and onDelete functions.
changed - Updated firebase-admin peer dependency to v5.0.1. For auth functions, event.data.metadata has its fields renamed from ‘createdAt’ to ‘creationTime’ and ‘lastSignedInAt’ to ‘lastSignInTime’, and both are now ISO strings instead of Date objects.

@@ -5,2 +5,11 @@ import { CloudFunction, Event } from '../cloud-functions';

export declare function user(): UserBuilder;
export declare class UserRecordMetadata implements firebase.auth.UserMetadata {
creationTime: string;
lastSignInTime: string;
constructor(creationTime: string, lastSignInTime: string);
toJSON(): {
creationTime: string;
lastSignInTime: string;
};
}
/** Builder used to create Cloud Functions for Firebase Auth user lifecycle events. */

@@ -7,0 +16,0 @@ export declare class UserBuilder {

@@ -25,2 +25,3 @@ "use strict";

var cloud_functions_1 = require("../cloud-functions");
var _ = require("lodash");
/** @internal */

@@ -33,2 +34,39 @@ exports.provider = 'firebase.auth';

exports.user = user;
var UserRecordMetadata = (function () {
function UserRecordMetadata(creationTime, lastSignInTime) {
this.creationTime = creationTime;
this.lastSignInTime = lastSignInTime;
}
;
Object.defineProperty(UserRecordMetadata.prototype, "lastSignedInAt", {
// Remove in v1.0.0
/** @internal */
get: function () {
console.warn('WARNING: "lastSignedInAt" will be removed in firebase-functions v1.0.0. ' +
'Please start using "lastSignInTime", which is an ISO string.');
return new Date(this.lastSignInTime);
},
enumerable: true,
configurable: true
});
Object.defineProperty(UserRecordMetadata.prototype, "createdAt", {
// Remove in v1.0.0
/** @internal */
get: function () {
console.warn('WARNING: "createdAt" will be removed in firebase-functions v1.0.0. ' +
'Please start using "creationTime", which is an ISO string.');
return new Date(this.creationTime);
},
enumerable: true,
configurable: true
});
UserRecordMetadata.prototype.toJSON = function () {
return {
creationTime: this.creationTime,
lastSignInTime: this.lastSignInTime,
};
};
return UserRecordMetadata;
}());
exports.UserRecordMetadata = UserRecordMetadata;
/** Builder used to create Cloud Functions for Firebase Auth user lifecycle events. */

@@ -42,18 +80,10 @@ var UserBuilder = (function () {

// The UserRecord returned here is an interface. The firebase-admin/auth/user-record module
// also has a class of the same name, which is one implementation of the interface. Here,
// because our wire format already almost matches the UserRecord interface, we only use the
// interface, no need to use the class.
//
// The one change we need to make to match the interface is to our incoming timestamps. The
// interface requires them to be Date objects, while they raw payload has them as strings.
if (raw.data.metadata) {
var metadata = raw.data.metadata;
if (metadata.lastSignedInAt && typeof metadata.lastSignedInAt === 'string') {
metadata.lastSignedInAt = new Date(metadata.lastSignedInAt);
}
if (metadata.createdAt && typeof metadata.createdAt === 'string') {
metadata.createdAt = new Date(metadata.createdAt);
}
// also has a class of the same name, which is one implementation of the interface.
// Transform payload to firebase-admin v5.0.0 format
var data = _.clone(raw.data);
if (data.metadata) {
var meta = data.metadata;
data.metadata = new UserRecordMetadata(meta.createdAt || meta.creationTime, meta.lastSignedInAt || meta.lastSignInTime);
}
return raw.data;
return data;
};

@@ -60,0 +90,0 @@ /** Respond to the creation of a Firebase Auth user. */

@@ -16,3 +16,11 @@ import { CloudFunction, Event } from '../cloud-functions';

private resource;
onWrite(handler: (event: Event<any>) => PromiseLike<any> | any): CloudFunction<any>;
/** Respond to all document writes (creates, updates, or deletes). */
onWrite(handler: (event: Event<DeltaDocumentSnapshot>) => PromiseLike<any> | any): CloudFunction<DeltaDocumentSnapshot>;
/** Respond only to document creations. */
onCreate(handler: (event: Event<DeltaDocumentSnapshot>) => PromiseLike<any> | any): CloudFunction<DeltaDocumentSnapshot>;
/** Respond only to document updates. */
onUpdate(handler: (event: Event<DeltaDocumentSnapshot>) => PromiseLike<any> | any): CloudFunction<DeltaDocumentSnapshot>;
/** Respond only to document deletions. */
onDelete(handler: (event: Event<DeltaDocumentSnapshot>) => PromiseLike<any> | any): CloudFunction<DeltaDocumentSnapshot>;
private onOperation(handler, eventType);
}

@@ -19,0 +27,0 @@ export declare class DeltaDocumentSnapshot {

@@ -74,3 +74,19 @@ "use strict";

}
/** Respond to all document writes (creates, updates, or deletes). */
DocumentBuilder.prototype.onWrite = function (handler) {
return this.onOperation(handler, 'document.write');
};
/** Respond only to document creations. */
DocumentBuilder.prototype.onCreate = function (handler) {
return this.onOperation(handler, 'document.create');
};
/** Respond only to document updates. */
DocumentBuilder.prototype.onUpdate = function (handler) {
return this.onOperation(handler, 'document.update');
};
/** Respond only to document deletions. */
DocumentBuilder.prototype.onDelete = function (handler) {
return this.onOperation(handler, 'document.delete');
};
DocumentBuilder.prototype.onOperation = function (handler, eventType) {
var dataConstructor = function (raw) {

@@ -85,3 +101,3 @@ if (raw.data instanceof DeltaDocumentSnapshot) {

resource: this.resource,
eventType: 'document.write',
eventType: eventType,
dataConstructor: dataConstructor,

@@ -111,2 +127,4 @@ });

Object.defineProperty(DeltaDocumentSnapshot.prototype, "previous", {
// Note: this is an expected assymetry between event.data and
// event.data.previous until we move the latter to event.previous
get: function () {

@@ -154,3 +172,3 @@ if (_.isEmpty(this._old)) {

else if (fieldType === 'referenceValue') {
console.log('WARNING: you have a data field which is a datastore reference. ' +
console.warn('WARNING: you have a data field which is a datastore reference. ' +
'There will be a breaking change later which will change it from a string to a reference object.');

@@ -157,0 +175,0 @@ result = fieldValue;

{
"name": "firebase-functions",
"version": "0.5.9",
"version": "0.6.0",
"description": "Firebase SDK for Cloud Functions",

@@ -10,3 +10,3 @@ "main": "lib/index.js",

"build:release": "npm install --production && npm install typescript firebase-admin && node_modules/.bin/tsc -p tsconfig.release.json",
"lint": "node_modules/.bin/tslint src/{**/*,*}.ts spec/{**/*,*}.ts",
"lint": "node_modules/.bin/tslint src/{**/*,*}.ts spec/{**/*,*}.ts integration_test/functions/src/{**/*,*}.ts",
"pretest": "node_modules/.bin/tsc && cp -r spec/fixtures .tmp/spec",

@@ -42,3 +42,2 @@ "test": "mocha .tmp/spec/index.spec.js",

"chai-as-promised": "^5.2.0",
"firebase-admin": "^4.2.1",
"istanbul": "^0.4.2",

@@ -53,3 +52,3 @@ "mocha": "^2.4.5",

"peerDependencies": {
"firebase-admin": "~4.2.1"
"firebase-admin": "~5.0.1"
},

@@ -56,0 +55,0 @@ "dependencies": {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc