workers-firebase
Advanced tools
Comparing version 0.0.18 to 0.0.19
@@ -10,2 +10,3 @@ import type { Settings } from '../types'; | ||
signInWithEmailAndPassword(email: string, password: string): Promise<SignInResponse>; | ||
signInWithIdp(credentials: string, requestUri: string, returnIdpCredential?: boolean): Promise<SignInResponse>; | ||
signInWithCustomToken(token: string): Promise<SignInResponse>; | ||
@@ -12,0 +13,0 @@ refreshToken(refreshToken: string): Promise<Tokens>; |
@@ -39,2 +39,10 @@ import { FirebaseService } from '../service'; | ||
} | ||
// 0auth signing | ||
async signInWithIdp(credentials, requestUri, returnIdpCredential = false) { | ||
const data = { postBody: credentials, requestUri, returnSecureToken, returnIdpCredential }; | ||
const result = await this.userRequest('POST', ':signInWithIdp', data); | ||
const tokens = convertSignInResponse(result); | ||
const user = await this.getUser(tokens.idToken); | ||
return { user, tokens }; | ||
} | ||
async signInWithCustomToken(token) { | ||
@@ -41,0 +49,0 @@ const data = { token, returnSecureToken }; |
import { encodeValue } from './serializer'; | ||
export class FieldValue { | ||
constructor(transform, value) { | ||
this.transform = transform; | ||
this.value = value; | ||
} | ||
static serverTimestamp() { | ||
@@ -25,2 +21,6 @@ return new FieldValue('setToServerValue', 'REQUEST_TIME'); | ||
} | ||
constructor(transform, value) { | ||
this.transform = transform; | ||
this.value = value; | ||
} | ||
encode(fieldPath) { | ||
@@ -27,0 +27,0 @@ const value = fieldPath === 'setToServerValue' ? this.value : encodeValue(this.value); |
@@ -5,3 +5,3 @@ /** | ||
*/ | ||
export declare type DocumentData = { | ||
export type DocumentData = { | ||
[field: string]: any; | ||
@@ -13,3 +13,3 @@ }; | ||
*/ | ||
export declare type PartialWithFieldValue<T> = Partial<T> | (T extends Primitive ? T : T extends {} ? { | ||
export type PartialWithFieldValue<T> = Partial<T> | (T extends Primitive ? T : T extends {} ? { | ||
[K in keyof T]?: PartialWithFieldValue<T[K]> | FieldValue; | ||
@@ -21,3 +21,3 @@ } : never); | ||
*/ | ||
export declare type WithFieldValue<T> = T | (T extends Primitive ? T : T extends {} ? { | ||
export type WithFieldValue<T> = T | (T extends Primitive ? T : T extends {} ? { | ||
[K in keyof T]: WithFieldValue<T[K]> | FieldValue; | ||
@@ -39,7 +39,7 @@ } : never); | ||
*/ | ||
export declare type UpdateData<T> = T extends Primitive ? T : T extends {} ? { | ||
export type UpdateData<T> = T extends Primitive ? T : T extends {} ? { | ||
[K in keyof T]?: UpdateData<T[K]> | FieldValue; | ||
} & NestedUpdateFields<T> : Partial<T>; | ||
/** Primitive types. */ | ||
export declare type Primitive = string | number | boolean | undefined | null; | ||
export type Primitive = string | number | boolean | undefined | null; | ||
/** | ||
@@ -50,3 +50,3 @@ * For each field (e.g. 'bar'), find all nested keys (e.g. {'bar.baz': T1, | ||
*/ | ||
export declare type NestedUpdateFields<T extends Record<string, unknown>> = UnionToIntersection<{ | ||
export type NestedUpdateFields<T extends Record<string, unknown>> = UnionToIntersection<{ | ||
[K in keyof T & string]: ChildUpdateFields<K, T[K]>; | ||
@@ -64,3 +64,3 @@ }[keyof T & string]>; | ||
*/ | ||
export declare type ChildUpdateFields<K extends string, V> = V extends Record<string, unknown> ? AddPrefixToKeys<K, UpdateData<V>> : never; | ||
export type ChildUpdateFields<K extends string, V> = V extends Record<string, unknown> ? AddPrefixToKeys<K, UpdateData<V>> : never; | ||
/** | ||
@@ -70,3 +70,3 @@ * Returns a new map where every key is prefixed with the outer key appended | ||
*/ | ||
export declare type AddPrefixToKeys<Prefix extends string, T extends Record<string, unknown>> = { | ||
export type AddPrefixToKeys<Prefix extends string, T extends Record<string, unknown>> = { | ||
[K in keyof T & string as `${Prefix}.${K}`]+?: T[K]; | ||
@@ -84,4 +84,4 @@ }; | ||
*/ | ||
export declare type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never; | ||
export declare type FieldValue = { | ||
export type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never; | ||
export type FieldValue = { | ||
/** | ||
@@ -146,7 +146,7 @@ * Returns a sentinel used with set(), create() or update() to include a | ||
}; | ||
export declare type SetOptions = { | ||
export type SetOptions = { | ||
readonly merge?: boolean; | ||
}; | ||
export declare type WhereFilterOp = '<' | '<=' | '==' | '!=' | '>=' | '>' | 'array-contains' | 'in' | 'not-in' | 'array-contains-any'; | ||
export declare type OrderByDirection = 'desc' | 'asc'; | ||
export type WhereFilterOp = '<' | '<=' | '==' | '!=' | '>=' | '>' | 'array-contains' | 'in' | 'not-in' | 'array-contains-any'; | ||
export type OrderByDirection = 'desc' | 'asc'; | ||
export interface ReadTransactionOptions { | ||
@@ -153,0 +153,0 @@ transaction?: string; |
export * from './auth/types'; | ||
export * from './firestore/types'; | ||
export declare type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'DELETE'; | ||
export declare type TokenGetter = (claims?: object) => Promise<string>; | ||
export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'DELETE'; | ||
export type TokenGetter = (claims?: object) => Promise<string>; | ||
export interface ServiceAccount { | ||
@@ -18,3 +18,3 @@ projectId: string; | ||
} | ||
export declare type Settings = ServiceAccount | UserAccount; | ||
export type Settings = ServiceAccount | UserAccount; | ||
//# sourceMappingURL=types.d.ts.map |
{ | ||
"name": "workers-firebase", | ||
"version": "0.0.18", | ||
"version": "0.0.19", | ||
"scripts": { | ||
@@ -5,0 +5,0 @@ "start": "tsc --watch", |
@@ -42,2 +42,11 @@ import type { Settings } from '../types'; | ||
// 0auth signing | ||
async signInWithIdp(credentials: string, requestUri: string, returnIdpCredential = false): Promise<SignInResponse> { | ||
const data = { postBody: credentials, requestUri, returnSecureToken, returnIdpCredential }; | ||
const result: SignInFirebaseResponse = await this.userRequest('POST', ':signInWithIdp', data); | ||
const tokens = convertSignInResponse(result); | ||
const user = await this.getUser(tokens.idToken); | ||
return { user, tokens }; | ||
} | ||
async signInWithCustomToken(token: string): Promise<SignInResponse> { | ||
@@ -44,0 +53,0 @@ const data = { token, returnSecureToken }; |
@@ -162,3 +162,3 @@ import type { | ||
if ((opStr === '==' || opStr === '!=') && (value === null || typeof value === 'number' && isNaN(value))) { | ||
const op = unaryOperators[opStr][value] as api.UnaryFilterOperator; | ||
const op = unaryOperators[opStr][value as any] as api.UnaryFilterOperator; | ||
filter = { unaryFilter: { field: { fieldPath }, op } }; | ||
@@ -237,3 +237,3 @@ } else { | ||
if (fieldOrders[i].field === FieldPath.documentId && typeof fieldValue === 'string') { | ||
if (fieldOrders[i].field === FieldPath.documentId as string && typeof fieldValue === 'string') { | ||
fieldValue = this.ref.doc(fieldValue); | ||
@@ -351,3 +351,3 @@ } | ||
} | ||
if (!fieldOrders.some(o => o.field === FieldPath.documentId)) { | ||
if (!fieldOrders.some(o => o.field === FieldPath.documentId as string)) { | ||
fieldOrders.push({ field: { fieldPath: FieldPath.documentId }}); | ||
@@ -362,3 +362,3 @@ } | ||
for (const fieldOrder of fieldOrders) { | ||
if (fieldOrder.field === FieldPath.documentId) { | ||
if (fieldOrder.field === FieldPath.documentId as string) { | ||
fieldValues.push(documentSnapshot.ref); | ||
@@ -365,0 +365,0 @@ } else { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
136575
73
2904
5