Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'expires_at' is missing in the parameter of'generateScopedSearchKey' #82

Closed
ueda19850603 opened this issue Nov 9, 2021 · 6 comments
Closed

Comments

@ueda19850603
Copy link

Description

According to the official website, you can specify'expires_at' when creating a restricted key.
https://typesense.org/docs/0.21.0/api/api-keys.html#generate-scoped-search-key

However, VScode prints a warning because there is no'expires_at' in the TypeScript type definition.

Steps to reproduce

スクリーンショット 2021-11-09 11 53 44

write code
import * as Typesense from 'typesense'
async function makeLimitKey () {
  const client = new Typesense.Client({
    nodes: [{
      host: 'samplehost_xxxxx',
      port: 443,
      protocol: 'https'
    }],
    apiKey: 'apikey_secret_xxxxxx',
    connectionTimeoutSeconds: 2
  })
  
  const dangerKey = await client.keys().create({
    'description': 'xxxxxx',
    'actions': ['documents:search'],
    'collections': ['*']
  })
  if (dangerKey.value === undefined) {
    return false
  }
  const expiresAt = dayjs().add(30, 'day').unix()
  
  const limitedKey = client.keys().generateScopedSearchKey(
    dangerKey.value,
    {
      'filter_by': 'roomId:dummyData',
      'expires_at': expiresAt // <= here warning
    }
  )
}

Expected Behavior

No warning is displayed

Actual Behavior

Warning is displayed

Metadata

VSCode 1.16.0
TypeScript 4.2.4

Typsense Version:
Version 1.0.0

OS:

@jasonbosco
Copy link
Member

Oh yes, thank you for catching that. Will push out a fix shortly.

jasonbosco added a commit that referenced this issue Nov 9, 2021
@jasonbosco
Copy link
Member

@ueda19850603 Just pushed out v1.0.1 with a fix for this.

@ueda19850603
Copy link
Author

Thank you for your prompt response.
Are q and query_by required to create a restricted key?
Previously you could create a restricted key without passing q and query_by.

issue

@jasonbosco
Copy link
Member

jasonbosco commented Nov 9, 2021

No q and query_by are optional when generating scoped search keys. This is another bug with the type definitions. I'll push out a fix for this shortly.

@jasonbosco
Copy link
Member

@ueda19850603 Could you try again in this version: 1.0.2-0?

@ueda19850603
Copy link
Author

I confirmed the operation with 1.0.2-0.
It worked fine.
Thank you very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants