Closed jmarshall9120 closed 5 months ago
Alright, this is not a bug. Somehow, when I was searching through the docs last night I didn't come up with interface, LibraryAuthOptions
which holds a reference to interface CredentialsAndIdentityIdProvider
.
There is a bit of a tricky wicket here, where Amplify.configure
takes two arguments - resourceConfig and libraryOptions:
ResourceConfig, and LibraryOptions contain pretty much the same structure, but their members have different structures.
This is further confused by the fact, that in an app you usually call Amplify.configure(amplify_outputs)
which does not use the libraryOptions
parameter. It's literally the difference between this:
{
'API' : {...},
'Auth' : {...}
}
and
{
'API' : {...}
},{
'Auth: {...}
}
Hopefully this ticket will at least help someone else, because I spent way to much time mucking this up! #skillissue ;)
Before opening, please confirm:
JavaScript Framework
Vue
Amplify APIs
Authentication, DataStore
Amplify Version
v6
Amplify Categories
function
Backend
Amplify Gen 2 (Preview)
Environment information
Describe the bug
Following example here: https://docs.amplify.aws/vue/build-a-backend/functions/examples/create-user-profile-record/
The below line raises a ts error:
The inheritance scheme for AuthConfig is documented here: https://aws-amplify.github.io/amplify-js/api/types/aws_amplify.adapter_core._Reference_Types_.AuthConfig.html
The inheritance for member method getCredentialsAndIdentityId is here: https://aws-amplify.github.io/amplify-js/api/interfaces/aws_amplify.auth.CredentialsAndIdentityIdProvider.html#getCredentialsAndIdentityId
TLDR: It looks to me like the lambda function is set to look for a member variable
credentialsProvider
that has been monkey patched onto anAuthConfig
object. Which of course breaks type script.Here's a quick diagram of the inheritance scheme:
Expected behavior
TS should compile just fine when following example.
Possible solutions:
credentialsProvider:CredentialsAndIdentityIdProvider
to interfaceAuthIdentityPoolConfig
credentialsProvider:CredentialsAndIdentityIdProvider
to interfaceAuthUserPoolConfig
credentialsProvider:CredentialsAndIdentityIdProvider
to interfaceAuthUserPoolAndIdentityPoolConfig
CognitoProviderConfig
that implementscredentialsProvider:CredentialsAndIdentityIdProvider
*https://aws-amplify.github.io/amplify-js/api/types/aws_amplify.adapter_core._Reference_Types_.CognitoProviderConfig.htmlReproduction steps
Implement example handler shown in the link in TS https://docs.amplify.aws/vue/build-a-backend/functions/examples/create-user-profile-record/
Code Snippet
Log output
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response