UNPKG

@aws-amplify/auth

Version:
1 lines 1.61 kB
{"version":3,"file":"apiHelpers.mjs","sources":["../../../../../src/providers/cognito/utils/apiHelpers.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n/**\n * Transforms a user attributes object into an array of AttributeType objects.\n * @param attributes user attributes to be mapped to AttributeType objects.\n * @returns an array of AttributeType objects.\n */\nexport function toAttributeType(attributes) {\n return Object.entries(attributes).map(([key, value]) => ({\n Name: key,\n Value: value,\n }));\n}\n/**\n * Transforms an array of AttributeType objects into a user attributes object.\n *\n * @param attributes - an array of AttributeType objects.\n * @returns AuthUserAttributes object.\n */\nexport function toAuthUserAttribute(attributes) {\n const userAttributes = {};\n attributes?.forEach(attribute => {\n if (attribute.Name)\n userAttributes[attribute.Name] = attribute.Value;\n });\n return userAttributes;\n}\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,eAAe,CAAC,UAAU,EAAE;AAC5C,IAAI,OAAO,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,MAAM;AAC7D,QAAQ,IAAI,EAAE,GAAG;AACjB,QAAQ,KAAK,EAAE,KAAK;AACpB,KAAK,CAAC,CAAC;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,mBAAmB,CAAC,UAAU,EAAE;AAChD,IAAI,MAAM,cAAc,GAAG,EAAE;AAC7B,IAAI,UAAU,EAAE,OAAO,CAAC,SAAS,IAAI;AACrC,QAAQ,IAAI,SAAS,CAAC,IAAI;AAC1B,YAAY,cAAc,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,KAAK;AAC5D,KAAK,CAAC;AACN,IAAI,OAAO,cAAc;AACzB;;;;"}