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

"sshKeyMemoryNew" is not found in Typescript #1962

Closed
nakky opened this issue Jan 9, 2023 · 3 comments · May be fixed by #1973
Closed

"sshKeyMemoryNew" is not found in Typescript #1962

nakky opened this issue Jan 9, 2023 · 3 comments · May be fixed by #1973

Comments

@nakky
Copy link

nakky commented Jan 9, 2023

Probably because namespace "Cred" has changed, "sshKeyMemoryNew" is not found in Typescript.

"sshKeyNew" can be used although the following warning is issued.

Use NodeGit.Credential.sshKeyNew instead of NodeGit.Cred.sshKeyNew

I think it will probably be solved by updating the definition of Typescript.
(It worked when I directly modified the output js file)
The definition may not have been updated because it is alpha, but it is necessary for check, so please support it.

System information

  • node version: v16.3.0
  • npm or yarn version: yarn 1.22.18
  • OS/version/architecture: darwin 21.4.0 arm64
  • Applicable nodegit version: 0.28.0-alpha.20
@tkmcmaster
Copy link

tkmcmaster commented Feb 28, 2023

I'm having a different problem. Typescript does have NodeGit.Cred.sshKeyMemoryNew for me but no NodeGit.Credential. Trying to use NodeGit.Cred.sshKeyMemoryNew doesn't work in Node 14 or 16 when using "nodegit": "^0.28.0-alpha.21" and "@types/nodegit": "^0.28.2". If I change to sshKeyNew I get the same deprecation warning, but it works. I've been trying different builds of nodegit 0.28.0 alphas for a while and have yet to find one that works on sskKeyMemoryNew. The same code does work in "nodegit": "^0.27.0"

Trying to use NodeGit.Cred.sshKeyMemoryNew simply throws the error Method clone has thrown an error. with no additional info (or fetch or other calls). Trying to call it directly looks like it's been removed.

import { Cred } from "nodegit";

const credentials = await Cred.sshKeyMemoryNew("git", deployKeyPublic, deployKeyPrivate, "");

throws:
TypeError: nodegit_1.Cred.sshKeyMemoryNew is not a function

So it looks like sshKeyMemoryNew has been removed from the new version but is still in the typings and docs. Looking at https://github.com/nodegit/nodegit/blob/master/lib/credential.js seems to concur.

Edit: More digging, it looks like the deprecated Cred doesn't have sshKeyMemoryNew but Credential does.

{
    "typeof NodeGit.Cred": "object",
    "typeof NodeGit.Credential": "function",
    "Object.keys(NodeGit.Cred)": [
      "defaultNew",
      "sshKeyFromAgent",
      "sshKeyNew",
      "usernameNew",
      "userpassPlaintextNew",
      "TYPE"
    ],
    "Object.keys(NodeGit.Credential)": [
      "defaultNew",
      "sshKeyFromAgent",
      "sshKeyMemoryNew",
      "sshKeyNew",
      "usernameNew",
      "userpassPlaintextNew",
      "getSelfFreeingInstanceCount",
      "getNonSelfFreeingConstructedCount",
      "TYPE"
    ]
  }

So there's two bugs. One is here in nodegit that sshKeyMemoryNew is missing from credential.js. The second is in DefinitelyTyped that it's missing NodeGit.Credential.

tkmcmaster added a commit to tkmcmaster/DefinitelyTyped that referenced this issue Mar 3, 2023
- See https://github.com/nodegit/nodegit/blob/master/CHANGELOG.md#v0280-alpha1-2021-03-12 Deprecations
- Note. NodeGit.Cred.sshKeyMemoryNew currently does not work. See nodegit/nodegit#1962, however NodeGit.Credential.sshKeyMemoryNew does work.
typescript-bot pushed a commit to DefinitelyTyped/DefinitelyTyped that referenced this issue Mar 3, 2023
…aster

* Updated NodeGit.Clone to match the typings in the v0.28.0-alpha versions

- Clone has been changed from a Class to a Function. See https://github.com/nodegit/nodegit/blob/master/examples/clone.js and https://github.com/nodegit/nodegit/tree/master/guides/cloning

* Added NodeGit.Credential and marked NodeGit.Cred as deprecated

- See https://github.com/nodegit/nodegit/blob/master/CHANGELOG.md#v0280-alpha1-2021-03-12 Deprecations
- Note. NodeGit.Cred.sshKeyMemoryNew currently does not work. See nodegit/nodegit#1962, however NodeGit.Credential.sshKeyMemoryNew does work.

* Fixed lint error

* Added tests for Clone and Credential

* Added back the LOCAL enum after confirming it's still there in 0.28.0-alpha.21
tkmcmaster added a commit to tkmcmaster/nodegit that referenced this issue Mar 3, 2023
@tkmcmaster
Copy link

@nakky Upgrade @types/nodegit to ^0.28.3 to fix Typescript using NodeGit.Credential.sshKeyMemoryNew(). #1973 will fix NodeGit.Cred.sshKeyMemoryNew().

@nakky
Copy link
Author

nakky commented Mar 8, 2023

@tkmcmaster I agree with you. When I was looking inside, it seemed that the namespace of the js library had been changed, but Typescript did not support it. (I used "@types/nodegit": "^0.28.2")
Thanks for the update!! After updating to ^0.28.3 and rewriting to Credential, it worked! !

@nakky nakky closed this as completed Mar 8, 2023
prudhvi22 pushed a commit to prudhvi22/DefinitelyTyped that referenced this issue Mar 13, 2023
…Clone by @tkmcmaster

* Updated NodeGit.Clone to match the typings in the v0.28.0-alpha versions

- Clone has been changed from a Class to a Function. See https://github.com/nodegit/nodegit/blob/master/examples/clone.js and https://github.com/nodegit/nodegit/tree/master/guides/cloning

* Added NodeGit.Credential and marked NodeGit.Cred as deprecated

- See https://github.com/nodegit/nodegit/blob/master/CHANGELOG.md#v0280-alpha1-2021-03-12 Deprecations
- Note. NodeGit.Cred.sshKeyMemoryNew currently does not work. See nodegit/nodegit#1962, however NodeGit.Credential.sshKeyMemoryNew does work.

* Fixed lint error

* Added tests for Clone and Credential

* Added back the LOCAL enum after confirming it's still there in 0.28.0-alpha.21
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

Successfully merging a pull request may close this issue.

2 participants