6.0.82 • Published 2 years ago

gingersnap-foundry-client v6.0.82

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

gingersnap-foundry-client

NPM

Description

This repository authenticates with foundry, stores user data in cookies and configures an API Gateway client for usage on applications.

This package also manages refreshing the credentials for the SigV4Client every 50 minutes, so you should never have to manage that yourself.

The Sigv4 client signs all requests using the AWS signature methods.

The API gateway code is exported the the API GW export feature. This repository builds on top of the API GW exported code, to implement the custom logic for authenticating

Table of Contents

Getting Started

To install:

./install.sh

Publishing

Pull credentials

yarn pull:npm:creds

Bump package version versioning

# Run deployment

./deploy.sh

Versioning

  • Semantic Versioning semver
  • {major}.{minor}.{hotfix}

Structure

FoldersDescription
apigw-generated-codeGenerated code provided by AWS Gateway
testsContains tests for the foundry-client
FilesDescription
cognitoAuth.jsFoundry auth functions
iotClientFactory.jsCode for creating iot client
logger.jsConsole logger
GingersnapFoundryClient.jsGlobal package configuration
apigClient.jsGenerated code to connect to API Gateway client
index.jsPackage exports

External Reference Links

Scripts

  • npm run clean - Remove dist/ directory
  • npm test - Run tests with linting and coverage results.
  • npm test:only - Run tests without linting or coverage.
  • npm test:watch - You can even re-run tests on file changes!
  • npm run lint - Run ESlint with airbnb-config
  • npm run cover - Get coverage report for your code.
  • npm run build - Babel will transpile ES6 => ES5 and minify the code.
  • npm run prepublish - Hook for npm. Do all the checks before publishing your module.

Config Options

NameTypeDescriptionRequired
usernameStringFoundry UsernameNo
passwordStringFoundry PasswordNo
accountIdStringAccount IDNo
apiGatewayEndpointStringAPI Gateway Endpoint URLYes
cognitoDeveloperProviderNameStringAWS Cognito Developer Provider NameYes
cognitoIdentityPoolIdStringAWS Cognito Identity Pool IDYes
expireCookieDaysNumberExpire auth cookies in daysNo

Examples

const { GingersnapFoundryClient, authenticate, authorizeWithCookies } = require('./src')

/** this configuration can be retrieved from the foundry stack that is deployed */
const foundryConfig = {
  apiGatewayEndpoint: 'https://<your-foundry-apigateway-endpoint>.com/<foundry-env>/foundry', 
  cognitoDeveloperProviderName: 'com.<developer-name>.foundry',
  cognitoIdentityPoolId: '<aws-region>:<pool-id>',
}

// set the global configuration
GingersnapFoundryClient.setConfig(foundryConfig)

// authorize with credentials
authenticate(
  '<account-id>',
  '<username>',
  '<password>'
).then(async (user) => {
  console.log(user)
  // GingersnapFoundryClient.apigwClient is now populated 
  GingersnapFoundryClient.apigwClient
      .foundryUserUserIdGet({
        user_id: '7d3b50d0-2ad6-11ec-9205-c1884ebfd6e6',
      })
})
.catch((e) => {
  // failed to login
})
  

// authorize with cookies after the initial login above ^
// the package stores, retreives, and has a method to clear them
 authorizeWithCookies()
  .then(() => {
    GingersnapFoundryClient.apigwClient
        .foundryUserUserIdGet({
          user_id: '7d3b50d0-2ad6-11ec-9205-c1884ebfd6e6',
        })
  })
  .catch(e => {
    GingersnapFoundryClient.logout()    
  })


// logout clears all cookies and global AWS config
GingersnapFoundryClient.logout()
// Methods on client
- foundryAccountPut
- foundryAccountPost
- foundryAccountOptions
- foundryAccountIsEmptyGet
- foundryAccountIsEmptyOptions
- foundryAccountAclGet
- foundryAccountAclPut
- foundryAccountAclPost
- foundryAccountAclOptions
- foundryAccountAclSearchGet
- foundryAccountAclSearchOptions
- foundryAccountAclAclIdDelete
- foundryAccountAclAclIdOptions
- foundryAccountPicturePost
- foundryAccountPictureOptions
- foundryAccountAccountIdGet
- foundryAccountAccountIdDelete
- foundryAccountAccountIdOptions
- foundryAccountAccountIdMetadataGet
- foundryAccountAccountIdMetadataPut
- foundryAccountAccountIdMetadataPost
- foundryAccountAccountIdMetadataDelete
- foundryAccountAccountIdMetadataOptions
- foundryAccountAccountIdPreferencesGet
- foundryAccountAccountIdPreferencesPut
- foundryAccountAccountIdPreferencesOptions
- foundryAccountAccountIdRootPost
- foundryAccountAccountIdRootOptions
- foundryAccountsGet
- foundryAccountsOptions
- foundryAccountsTreeGet
- foundryAccountsTreeOptions
- foundryActionPost
- foundryActionOptions
- foundryActionHttpPost
- foundryActionHttpOptions
- foundryArScenePut
- foundryArScenePost
- foundryArSceneOptions
- foundryArSceneSceneIdGet
- foundryArSceneSceneIdDelete
- foundryArSceneSceneIdOptions
- foundryArScenesGet
- foundryArScenesOptions
- foundryAuthenticatePost
- foundryAuthenticateOptions
- foundryCertificatesGenerateGet
- foundryCertificatesGenerateOptions
- foundryCertificatesProvisionPost
- foundryCertificatesProvisionOptions
- foundryCertificatesRevokeDelete
- foundryCertificatesRevokeOptions
- foundryCftemplatePost
- foundryCftemplateOndeletePost
- foundryCheckRequestGet
- foundryCheckRequestOptions
- foundryCognitoDataGet
- foundryCognitoDataOptions
- foundryCustomPagePut
- foundryCustomPagePost
- foundryCustomPageOptions
- foundryCustomPageIdGet
- foundryCustomPageIdDelete
- foundryCustomPageIdOptions
- foundryCustomPagesOptions
- foundryCustomPagesAccountIdGet
- foundryCustomPagesAccountIdOptions
- foundryDevicePut
- foundryDevicePost
- foundryDeviceOptions
- foundryDeviceAttributesPut
- foundryDeviceAttributesOptions
- foundryDeviceTypePut
- foundryDeviceTypePost
- foundryDeviceTypeOptions
- foundryDeviceTypeDownloadPost
- foundryDeviceTypeDownloadOptions
- foundryDeviceTypeTypeIdGet
- foundryDeviceTypeTypeIdDelete
- foundryDeviceTypeTypeIdOptions
- foundryDeviceTypesGet
- foundryDeviceTypesOptions
- foundryDeviceDeviceDataPost
- foundryDeviceDeviceDataOptions
- foundryDeviceHistoryGet
- foundryDeviceHistoryOptions
- foundryDeviceHistoryExportPost
- foundryDeviceHistoryExportOptions
- foundryDeviceHistoryMqttGet
- foundryDeviceHistoryMqttOptions
- foundryDeviceHistoryMqttExportPost
- foundryDeviceHistoryMqttExportOptions
- foundryDeviceJunctionPost
- foundryDeviceJunctionDelete
- foundryDeviceJunctionOptions
- foundryDeviceDeviceIdGet
- foundryDeviceDeviceIdDelete
- foundryDeviceDeviceIdOptions
- foundryDeviceDeviceIdChildrenGet
- foundryDeviceDeviceIdChildrenOptions
- foundryDeviceDeviceIdJunctionsDelete
- foundryDeviceDeviceIdJunctionsOptions
- foundryDeviceDeviceIdParentsGet
- foundryDeviceDeviceIdParentsOptions
- foundryDevicesGet
- foundryDevicesPost
- foundryDevicesOptions
- foundryDevicesAdvancedSearchPost
- foundryDevicesAdvancedSearchOptions
- foundryDevicesAdvancedSearchExportPost
- foundryDevicesAdvancedSearchExportOptions
- foundryDevicesAdvancedSearchNewPost
- foundryDevicesAdvancedSearchNewOptions
- foundryDevicesAdvancedSearchPagePost
- foundryDevicesAdvancedSearchPageOptions
- foundryDevicesByTypeGet
- foundryDevicesByTypeOptions
- foundryDevicesHierarchyGet
- foundryDevicesHierarchyOptions
- foundryDevicesScheduledPost
- foundryDevicesScheduledOptions
- foundryDevicesSearchServiceGet
- foundryDevicesSearchServicePost
- foundryDevicesSearchServiceOptions
- foundryForgotPasswordGet
- foundryForgotPasswordPut
- foundryForgotPasswordPost
- foundryForgotPasswordOptions
- foundryFormToMqttPost
- foundryFormToMqttOptions
- foundryGroupAttributePut
- foundryGroupAttributePost
- foundryGroupAttributeOptions
- foundryGroupAttributeGroupIdGet
- foundryGroupAttributeGroupIdDelete
- foundryGroupAttributeGroupIdOptions
- foundryGroupAttributesGet
- foundryGroupAttributesOptions
- foundryIamCredentialsGet
- foundryIamCredentialsPut
- foundryIamCredentialsPost
- foundryIamCredentialsOptions
- foundryIamCredentialsCredentialsIdDelete
- foundryIamCredentialsCredentialsIdOptions
- foundryIotCertificateGet
- foundryIotCertificatePut
- foundryIotCertificatePost
- foundryIotCertificateDelete
- foundryIotCertificateOptions
- foundryIotRulesGet
- foundryIotRulesPut
- foundryIotRulesPost
- foundryIotRulesDelete
- foundryIotRulesOptions
- foundryIotRulesCustomSmsPut
- foundryIotRulesCustomSmsPost
- foundryIotRulesCustomSmsOptions
- foundryIotRulesDetailsGet
- foundryIotRulesDetailsPut
- foundryIotRulesDetailsOptions
- foundryListViewGet
- foundryListViewPut
- foundryListViewPost
- foundryListViewOptions
- foundryListViewIdDelete
- foundryListViewIdOptions
- foundryLoginGet
- foundryLoginOptions
- foundryLoginInternalPost
- foundryLoginInternalOptions
- foundryLoginSalesforcePost
- foundryLoginSalesforceOptions
- foundryMetricsPost
- foundryMetricsOptions
- foundryMigrationPost
- foundryMqttConfigGet
- foundryMqttConfigPost
- foundryMqttConfigOptions
- foundryMqttPublishGet
- foundryMqttPublishPost
- foundryMqttPublishOptions
- foundryMqttSubscribeGet
- foundryMqttSubscribePost
- foundryMqttSubscribeOptions
- foundryMqttSubscribeSubscribeIdDelete
- foundryMqttSubscribeSubscribeIdOptions
- foundryOAuthGet
- foundryOAuthPut
- foundryOAuthPost
- foundryOAuthDelete
- foundryOAuthOptions
- foundryObjectSearchPost
- foundryObjectSearchOptions
- foundryObjectSearchExportPost
- foundryObjectSearchExportOptions
- foundryPoliciesGet
- foundryPoliciesOptions
- foundryPolicyGet
- foundryPolicyPut
- foundryPolicyPost
- foundryPolicyDelete
- foundryPolicyOptions
- foundryPortalPagePut
- foundryPortalPagePost
- foundryPortalPageOptions
- foundryPortalPagePageIdGet
- foundryPortalPagePageIdDelete
- foundryPortalPagePageIdOptions
- foundryPortalPagesGet
- foundryPortalPagesOptions
- foundryPublishMqttPost
- foundryPublishMqttOptions
- foundryReferencePost
- foundryReferenceDelete
- foundryReferenceOptions
- foundryReferenceDeviceIdToGet
- foundryReferenceDeviceIdToOptions
- foundryS3Get
- foundryS3Post
- foundryS3Delete
- foundryS3Options
- foundryS3BucketGet
- foundryS3BucketPost
- foundryS3BucketOptions
- foundrySavedSearchGet
- foundrySavedSearchPut
- foundrySavedSearchPost
- foundrySavedSearchOptions
- foundrySavedSearchIdGet
- foundrySavedSearchIdDelete
- foundrySavedSearchIdOptions
- foundrySendEmailPost
- foundrySendEmailOptions
- foundrySfdcOptions
- foundrySfdcIdentityUrlGet
- foundrySfdcIdentityUrlOptions
- foundrySfdcTokensGet
- foundrySfdcTokensOptions
- foundrySfdcUserDetailsPost
- foundrySfdcUserDetailsOptions
- foundrySignupPost
- foundrySignupOptions
- foundrySyncPost
- foundrySyncStatusPost
- foundryTemplateGet
- foundryTemplatePut
- foundryTemplatePost
- foundryTemplateDelete
- foundryTemplateOptions
- foundryTemplateListGet
- foundryTemplateListOptions
- foundryTokenGet
- foundryTokenOptions
- foundryUserPut
- foundryUserPost
- foundryUserOptions
- foundryUserAcceptInvitePost
- foundryUserAcceptInviteOptions
- foundryUserCheckGet
- foundryUserCheckOptions
- foundryUserInvitePost
- foundryUserInviteOptions
- foundryUserPicturePost
- foundryUserPictureOptions
- foundryUserResendActivationPost
- foundryUserResendActivationOptions
- foundryUserSecretPut
- foundryUserSecretPost
- foundryUserSecretDelete
- foundryUserSecretOptions
- foundryUserSecretsGet
- foundryUserSecretsOptions
- foundryUserVerifyPut
- foundryUserVerifyPost
- foundryUserVerifyOptions
- foundryUserUserIdGet
- foundryUserUserIdDelete
- foundryUserUserIdOptions
- foundryUserUserIdActivatePut
- foundryUserUserIdActivateOptions
- foundryUserUserIdPolicyPost
- foundryUserUserIdPolicyDelete
- foundryUserUserIdPolicyOptions
- foundryUsersGet
- foundryUsersOptions
6.0.82

2 years ago

6.0.81

2 years ago

6.0.7

2 years ago

6.0.6

2 years ago

6.0.8

2 years ago

6.0.1

2 years ago

6.0.0

2 years ago

6.0.3

2 years ago

6.0.2

2 years ago

6.0.5

2 years ago

6.0.4

2 years ago

5.2.19

2 years ago

5.2.18

2 years ago

5.1.19

2 years ago

5.1.18

2 years ago

5.1.17

2 years ago

5.1.16

2 years ago

5.1.15

2 years ago

5.1.14

2 years ago

5.1.13

2 years ago

5.1.12

2 years ago

5.2.23

2 years ago

5.1.11

2 years ago

5.2.22

2 years ago

5.2.21

2 years ago

5.2.20

2 years ago

3.0.8

2 years ago

3.0.7

2 years ago

4.1.9

2 years ago

2.0.3

2 years ago

4.1.10

2 years ago

2.0.5

2 years ago

2.0.7

2 years ago

2.0.6

2 years ago

5.1.10

2 years ago

3.1.9

2 years ago

3.0.9

2 years ago

2.0.2

2 years ago

1.1.2

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago