From b68b855291eb1ad292a4b496bbca42f0132795a9 Mon Sep 17 00:00:00 2001 From: Tim Holm Date: Mon, 13 Nov 2023 10:45:22 +1100 Subject: [PATCH] Ensure at least one permission when calling for on secure resources. --- src/resources/bucket.ts | 2 +- src/resources/collection.ts | 2 +- src/resources/queue.ts | 2 +- src/resources/secret.ts | 2 +- src/resources/topic.ts | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/resources/bucket.ts b/src/resources/bucket.ts index 8c85d284..22ac7404 100644 --- a/src/resources/bucket.ts +++ b/src/resources/bucket.ts @@ -211,7 +211,7 @@ export class BucketResource extends SecureResource { * @param perms the required permission set * @returns a usable bucket reference */ - public for(...perms: BucketPermission[]): Bucket { + public for(perm: BucketPermission, ...perms: BucketPermission[]): Bucket { this.registerPolicy(...perms); return storage().bucket(this.name); diff --git a/src/resources/collection.ts b/src/resources/collection.ts index ae96ab30..e5c53032 100644 --- a/src/resources/collection.ts +++ b/src/resources/collection.ts @@ -107,7 +107,7 @@ export class CollectionResource< * @param perms the required permission set * @returns a usable collection reference */ - public for(...perms: CollectionPermission[]) { + public for(perm: CollectionPermission, ...perms: CollectionPermission[]) { this.registerPolicy(...perms); return documents().collection(this.name); diff --git a/src/resources/queue.ts b/src/resources/queue.ts index 393a93c5..08faaa95 100644 --- a/src/resources/queue.ts +++ b/src/resources/queue.ts @@ -92,7 +92,7 @@ export class QueueResource< * @param perms the access that the currently scoped function is requesting to this resource. * @returns a useable queue. */ - public for(...perms: QueuePermission[]): Queue { + public for(perm: QueuePermission, ...perms: QueuePermission[]): Queue { this.registerPolicy(...perms); return queues().queue(this.name); diff --git a/src/resources/secret.ts b/src/resources/secret.ts index 89f4ad13..7c9bfb94 100644 --- a/src/resources/secret.ts +++ b/src/resources/secret.ts @@ -79,7 +79,7 @@ export class SecretResource extends SecureResource { throw new Error('details unimplemented for secret'); } - public for(...perms: SecretPermission[]): Secret { + public for(perm: SecretPermission, ...perms: SecretPermission[]): Secret { this.registerPolicy(...perms); return secrets().secret(this.name); diff --git a/src/resources/topic.ts b/src/resources/topic.ts index 2cf9d1af..d37cddff 100644 --- a/src/resources/topic.ts +++ b/src/resources/topic.ts @@ -136,7 +136,7 @@ export class TopicResource< * @param perms the required permission set * @returns a usable topic reference */ - public for(...perms: TopicPermission[]): Topic { + public for(perm: TopicPermission, ...perms: TopicPermission[]): Topic { this.registerPolicy(...perms); return events().topic(this.name); }