@sudoplatform/sudo-user 12.0.1 → 12.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/package.json +28 -20
  2. package/{cjs → types}/client/apiClient.d.ts +0 -0
  3. package/{cjs → types}/core/api-key-names.d.ts +0 -0
  4. package/{cjs → types}/core/auth-store.d.ts +0 -0
  5. package/{cjs → types}/core/crypto.d.ts +0 -0
  6. package/{cjs → types}/core/key-manager.d.ts +0 -0
  7. package/{cjs → types}/core/protected-store.d.ts +0 -0
  8. package/{cjs → types}/core/publisher.d.ts +0 -0
  9. package/{cjs → types}/core/sdk-config.d.ts +0 -0
  10. package/{cjs → types}/core/subscriber.d.ts +0 -0
  11. package/{cjs → types}/gen/graphql-types.d.ts +0 -0
  12. package/{cjs → types}/index.d.ts +0 -0
  13. package/{cjs → types}/runtimes/browser/browser-crypto.d.ts +0 -0
  14. package/{cjs → types}/runtimes/node/node-crypto.d.ts +0 -0
  15. package/{cjs → types}/sdk.d.ts +0 -0
  16. package/{cjs → types}/user/auth-provider.d.ts +0 -0
  17. package/{cjs → types}/user/auth.d.ts +0 -0
  18. package/{cjs → types}/user/error.d.ts +0 -0
  19. package/{cjs → types}/user/identity-provider.d.ts +0 -0
  20. package/{cjs → types}/user/user-client-interface.d.ts +0 -0
  21. package/{cjs → types}/user/user-client.d.ts +0 -0
  22. package/{cjs → types}/user/user-key-names.d.ts +0 -0
  23. package/{cjs → types}/utils/resolvable-promise.d.ts +0 -0
  24. package/lib/client/apiClient.d.ts +0 -25
  25. package/lib/core/api-key-names.d.ts +0 -8
  26. package/lib/core/auth-store.d.ts +0 -51
  27. package/lib/core/crypto.d.ts +0 -3
  28. package/lib/core/key-manager.d.ts +0 -31
  29. package/lib/core/protected-store.d.ts +0 -5
  30. package/lib/core/publisher.d.ts +0 -6
  31. package/lib/core/sdk-config.d.ts +0 -52
  32. package/lib/core/subscriber.d.ts +0 -3
  33. package/lib/gen/graphql-types.d.ts +0 -101
  34. package/lib/index.d.ts +0 -4
  35. package/lib/runtimes/browser/browser-crypto.d.ts +0 -2
  36. package/lib/runtimes/node/node-crypto.d.ts +0 -2
  37. package/lib/sdk.d.ts +0 -1
  38. package/lib/user/auth-provider.d.ts +0 -97
  39. package/lib/user/auth.d.ts +0 -64
  40. package/lib/user/error.d.ts +0 -18
  41. package/lib/user/identity-provider.d.ts +0 -73
  42. package/lib/user/user-client-interface.d.ts +0 -168
  43. package/lib/user/user-client.d.ts +0 -82
  44. package/lib/user/user-key-names.d.ts +0 -6
  45. package/lib/utils/resolvable-promise.d.ts +0 -9
  46. package/types/redux-offline/index.d.ts +0 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sudoplatform/sudo-user",
3
- "version": "12.0.1",
3
+ "version": "12.0.2",
4
4
  "author": "Anonyome Labs, Inc.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -18,14 +18,22 @@
18
18
  "integration-test": "/bin/bash -c 'jest test/integration'",
19
19
  "test": "yarn unit-test",
20
20
  "build": "yarn codegen && yarn verify && yarn build:transpile && yarn build:docs",
21
- "build:transpile": "concurrently \"yarn build:transpile:cjs\" \"yarn build:transpile:esm\"",
21
+ "build:transpile": "concurrently \"yarn build:transpile:declarations\" \"yarn build:transpile:cjs\" \"yarn build:transpile:esm\"",
22
22
  "build:transpile:cjs": "tsc --project tsconfig.commonjs.json",
23
23
  "build:transpile:esm": "tsc",
24
- "build:docs": "typedoc --excludePrivate --out docs src/index.ts"
24
+ "build:transpile:declarations": "tsc --project tsconfig.declarations.json",
25
+ "build:docs": "typedoc --tsconfig tsconfig.declarations.json --excludePrivate --out docs src/index.ts"
25
26
  },
26
27
  "main": "./cjs/index.js",
27
- "types": "./cjs/index.d.ts",
28
- "module": "./lib/index.js",
28
+ "types": "./types/index.d.ts",
29
+ "exports": {
30
+ ".": {
31
+ "types": "./types/index.d.ts",
32
+ "import": "./lib/index.js",
33
+ "require": "./cjs/index.js",
34
+ "default": "./lib/index.js"
35
+ }
36
+ },
29
37
  "sideEffects": false,
30
38
  "files": [
31
39
  "cjs",
@@ -37,15 +45,15 @@
37
45
  "./lib/runtimes/node/node-crypto.js": "./lib/runtimes/browser/browser-crypto.js"
38
46
  },
39
47
  "dependencies": {
40
- "@aws-sdk/client-cognito-identity-provider": "^3.131.0",
48
+ "@aws-sdk/client-cognito-identity-provider": "^3.154.0",
41
49
  "@graphql-typed-document-node/core": "^3.1.1",
42
- "@sudoplatform/sudo-web-crypto-provider": "^7.0.0",
50
+ "@sudoplatform/sudo-web-crypto-provider": "^7.0.1",
43
51
  "amazon-cognito-auth-js": "^1.3.3",
44
52
  "apollo-cache-inmemory": "^1.6.6",
45
53
  "aws-appsync": "^4.1.7",
46
- "fp-ts": "^2.12.1",
54
+ "fp-ts": "^2.12.2",
47
55
  "graphql": "^15.8.0",
48
- "io-ts": "^2.2.16",
56
+ "io-ts": "^2.2.17",
49
57
  "jsonwebtoken": "^8.5.1",
50
58
  "lodash": "^4.17.21",
51
59
  "monocle-ts": "^2.3.13",
@@ -66,23 +74,23 @@
66
74
  "got": "^11.8.5"
67
75
  },
68
76
  "devDependencies": {
69
- "@graphql-codegen/add": "^3.2.0",
70
- "@graphql-codegen/cli": "^2.9.1",
71
- "@graphql-codegen/plugin-helpers": "^2.6.0",
72
- "@graphql-codegen/typed-document-node": "^2.3.2",
73
- "@graphql-codegen/typescript": "^2.7.2",
74
- "@graphql-codegen/typescript-operations": "^2.5.2",
77
+ "@graphql-codegen/add": "^3.2.1",
78
+ "@graphql-codegen/cli": "^2.11.6",
79
+ "@graphql-codegen/plugin-helpers": "^2.6.2",
80
+ "@graphql-codegen/typed-document-node": "^2.3.3",
81
+ "@graphql-codegen/typescript": "^2.7.3",
82
+ "@graphql-codegen/typescript-operations": "^2.5.3",
75
83
  "@graphql-typed-document-node/apollo-client-2": "^1.0.0",
76
- "@sudoplatform/sudo-common": "^8.0.0",
84
+ "@sudoplatform/sudo-common": "^8.0.1",
77
85
  "@types/amazon-cognito-auth-js": "^1.3.0",
78
86
  "@types/firefox-webext-browser": "^94.0.1",
79
87
  "@types/jest": "^28.1.3",
80
88
  "@types/jsonwebtoken": "^8.5.8",
81
- "@types/lodash": "^4.14.182",
82
- "@types/node": "^16.11.45",
89
+ "@types/lodash": "^4.14.184",
90
+ "@types/node": "^16.11.53",
83
91
  "@types/uuid": "^8.3.4",
84
- "@typescript-eslint/eslint-plugin": "^5.33.1",
85
- "@typescript-eslint/parser": "^5.33.1",
92
+ "@typescript-eslint/eslint-plugin": "^5.34.0",
93
+ "@typescript-eslint/parser": "^5.34.0",
86
94
  "apollo-client": "^2.6.10",
87
95
  "concurrently": "^7.3.0",
88
96
  "eslint": "^8.22.0",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,25 +0,0 @@
1
- import { RegisterFederatedIdInput } from '../gen/graphql-types';
2
- import { Logger } from '@sudoplatform/sudo-common';
3
- import { SudoUserClient } from '../user/user-client-interface';
4
- /**
5
- * AppSync wrapper to use to invoke Identity Service APIs.
6
- */
7
- export declare class ApiClient {
8
- private client;
9
- private region;
10
- private graphqlUrl;
11
- private sudoUserClient;
12
- private logger;
13
- constructor(region: string, graphqlUrl: string, sudoUserClient: SudoUserClient, logger: Logger);
14
- deregister(): Promise<{
15
- success: boolean;
16
- }>;
17
- globalSignOut(): Promise<{
18
- success: boolean;
19
- }>;
20
- registerFederatedId(input: RegisterFederatedIdInput): Promise<{
21
- identityId: string;
22
- }>;
23
- reset(): void;
24
- private graphQLErrorsToClientError;
25
- }
@@ -1,8 +0,0 @@
1
- export declare const apiKeyNames: {
2
- idToken: string;
3
- accessToken: string;
4
- refreshToken: string;
5
- tokenExpiry: string;
6
- refreshTokenExpiry: string;
7
- userId: string;
8
- };
@@ -1,51 +0,0 @@
1
- import { Publisher } from './publisher';
2
- import { Subscriber } from './subscriber';
3
- export interface Store {
4
- setItem(keyId: string, value: string): Promise<void>;
5
- getItem(keyId: string): string | undefined;
6
- removeItem(keyId: string): void;
7
- reset(): void;
8
- }
9
- /**
10
- * Stores authentication details such as tokens and username
11
- */
12
- export declare class AuthenticationStore implements Store, Publisher {
13
- #private;
14
- subscribers: Subscriber[];
15
- /** Adds a secret into private _secrets object */
16
- private addSecret;
17
- /**
18
- * Adds a string value into authentication store
19
- */
20
- setItem(keyId: string, value: string): Promise<void>;
21
- /**
22
- * Returns a string value from authentication store
23
- */
24
- getItem(keyId: string): string | undefined;
25
- /**
26
- * Removes a secret
27
- */
28
- removeItem(keyId: string): void;
29
- /**
30
- * Clears all secrets
31
- */
32
- reset(): void;
33
- /**
34
- * Register a subscriber to be notified when items are added
35
- *
36
- * @param subscriber a subscriber to be notified when items are added
37
- */
38
- subscribe(subscriber: Subscriber): Promise<void>;
39
- /**
40
- * Remove a subscriber from the list of subscribers
41
- *
42
- * @param subscriber the subscriber to be removed
43
- */
44
- unsubscribe(subscriber: Subscriber): Promise<void>;
45
- /**
46
- * Notify all subscribers that a change event was triggered for a specific item
47
- *
48
- * @param itemName the name of the item that changed
49
- */
50
- notifySubscribers(itemName: string): Promise<void>;
51
- }
@@ -1,3 +0,0 @@
1
- export interface CryptoProvider {
2
- arrayBufferToBase64(buffer: ArrayBuffer): string;
3
- }
@@ -1,31 +0,0 @@
1
- import { PublicKeyFormat, SudoKeyManager } from '@sudoplatform/sudo-common';
2
- export interface PublicKey {
3
- keyId: string;
4
- algorithm: string;
5
- symmetricAlgorithm: string;
6
- publicKey: string;
7
- keyFormat: PublicKeyFormat;
8
- }
9
- export interface KeyPair {
10
- publicKey: unknown;
11
- publicKeyFormat: PublicKeyFormat;
12
- privateKey: unknown;
13
- }
14
- export interface KeyManager {
15
- addString(keyId: string, value: string): Promise<void>;
16
- getString(keyId: string): Promise<string | undefined>;
17
- generateKeyPair(keyId?: string): Promise<string>;
18
- exportPublicKey(keyId: string): Promise<PublicKey>;
19
- signJWT(keyId: string, payload: Record<string, unknown>): Promise<string>;
20
- reset(): Promise<void>;
21
- removeItem(keyId: string): Promise<void>;
22
- }
23
- /**
24
- * Key Manager
25
- */
26
- export declare class KeyManager implements KeyManager {
27
- private sudoKeyManager;
28
- private static Constants;
29
- constructor(sudoKeyManager: SudoKeyManager);
30
- retrieveKeyPair(keyId: string): Promise<KeyPair>;
31
- }
@@ -1,5 +0,0 @@
1
- export interface ProtectedStore {
2
- put(key: string, value: ArrayBuffer): Promise<void>;
3
- get(key: string): Promise<ArrayBuffer>;
4
- delete(key: string): Promise<void>;
5
- }
@@ -1,6 +0,0 @@
1
- import { Subscriber } from './subscriber';
2
- export interface Publisher {
3
- subscribe(subscriber: Subscriber): void;
4
- unsubscribe(subscriber: Subscriber): void;
5
- notifySubscribers(itemName: string): void;
6
- }
@@ -1,52 +0,0 @@
1
- import * as t from 'io-ts';
2
- export declare const IdentityServiceConfigCodec: t.IntersectionC<[t.TypeC<{
3
- region: t.StringC;
4
- poolId: t.StringC;
5
- clientId: t.StringC;
6
- identityPoolId: t.StringC;
7
- apiUrl: t.StringC;
8
- apiKey: t.StringC;
9
- bucket: t.StringC;
10
- transientBucket: t.StringC;
11
- registrationMethods: t.ArrayC<t.StringC>;
12
- }>, t.PartialC<{
13
- refreshTokenLifetime: t.NumberC;
14
- }>]>;
15
- export declare const FederatedSignInConfigCodec: t.IntersectionC<[t.TypeC<{
16
- appClientId: t.StringC;
17
- signInRedirectUri: t.StringC;
18
- signOutRedirectUri: t.StringC;
19
- webDomain: t.StringC;
20
- }>, t.PartialC<{
21
- identityProvider: t.StringC;
22
- refreshTokenLifetime: t.NumberC;
23
- }>]>;
24
- export declare const Config: t.IntersectionC<[t.TypeC<{
25
- identityService: t.IntersectionC<[t.TypeC<{
26
- region: t.StringC;
27
- poolId: t.StringC;
28
- clientId: t.StringC;
29
- identityPoolId: t.StringC;
30
- apiUrl: t.StringC;
31
- apiKey: t.StringC;
32
- bucket: t.StringC;
33
- transientBucket: t.StringC;
34
- registrationMethods: t.ArrayC<t.StringC>;
35
- }>, t.PartialC<{
36
- refreshTokenLifetime: t.NumberC;
37
- }>]>;
38
- }>, t.PartialC<{
39
- federatedSignIn: t.IntersectionC<[t.TypeC<{
40
- appClientId: t.StringC;
41
- signInRedirectUri: t.StringC;
42
- signOutRedirectUri: t.StringC;
43
- webDomain: t.StringC;
44
- }>, t.PartialC<{
45
- identityProvider: t.StringC;
46
- refreshTokenLifetime: t.NumberC;
47
- }>]>;
48
- }>]>;
49
- export declare type Config = t.TypeOf<typeof Config>;
50
- export declare type IdentityServiceConfig = t.TypeOf<typeof IdentityServiceConfigCodec>;
51
- export declare type FederatedSignInConfig = t.TypeOf<typeof FederatedSignInConfigCodec>;
52
- export declare function getIdentityServiceConfig(): Config;
@@ -1,3 +0,0 @@
1
- export interface Subscriber {
2
- update(itemName: string): void;
3
- }
@@ -1,101 +0,0 @@
1
- import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
2
- export declare type Maybe<T> = T | undefined;
3
- export declare type InputMaybe<T> = T | undefined;
4
- export declare type Exact<T extends {
5
- [key: string]: unknown;
6
- }> = {
7
- [K in keyof T]: T[K];
8
- };
9
- export declare type MakeOptional<T, K extends keyof T> = Omit<T, K> & {
10
- [SubKey in K]?: Maybe<T[SubKey]>;
11
- };
12
- export declare type MakeMaybe<T, K extends keyof T> = Omit<T, K> & {
13
- [SubKey in K]: Maybe<T[SubKey]>;
14
- };
15
- /** All built-in and custom scalars, mapped to their actual values */
16
- export declare type Scalars = {
17
- ID: string;
18
- String: string;
19
- Boolean: boolean;
20
- Int: number;
21
- Float: number;
22
- AWSDate: any;
23
- AWSDateTime: any;
24
- AWSEmail: any;
25
- AWSIPAddress: any;
26
- AWSJSON: unknown;
27
- AWSPhone: any;
28
- AWSTime: any;
29
- AWSTimestamp: any;
30
- AWSURL: any;
31
- };
32
- export declare type Deregister = {
33
- __typename?: 'Deregister';
34
- success: Scalars['Boolean'];
35
- };
36
- export declare type FederatedId = {
37
- __typename?: 'FederatedId';
38
- identityId: Scalars['String'];
39
- };
40
- export declare type GlobalSignOut = {
41
- __typename?: 'GlobalSignOut';
42
- success: Scalars['Boolean'];
43
- };
44
- export declare type Mutation = {
45
- __typename?: 'Mutation';
46
- deregister?: Maybe<Deregister>;
47
- globalSignOut?: Maybe<GlobalSignOut>;
48
- registerFederatedId?: Maybe<FederatedId>;
49
- };
50
- export declare type MutationRegisterFederatedIdArgs = {
51
- input?: InputMaybe<RegisterFederatedIdInput>;
52
- };
53
- export declare type Query = {
54
- __typename?: 'Query';
55
- notImplemented?: Maybe<Scalars['Boolean']>;
56
- };
57
- export declare type QueryNotImplementedArgs = {
58
- dummy: Scalars['String'];
59
- };
60
- export declare type RegisterFederatedIdInput = {
61
- idToken: Scalars['String'];
62
- };
63
- export declare type DeregisterMutationVariables = Exact<{
64
- [key: string]: never;
65
- }>;
66
- export declare type DeregisterMutation = {
67
- __typename?: 'Mutation';
68
- deregister?: {
69
- __typename?: 'Deregister';
70
- success: boolean;
71
- } | undefined;
72
- };
73
- export declare type GlobalSignOutMutationVariables = Exact<{
74
- [key: string]: never;
75
- }>;
76
- export declare type GlobalSignOutMutation = {
77
- __typename?: 'Mutation';
78
- globalSignOut?: {
79
- __typename?: 'GlobalSignOut';
80
- success: boolean;
81
- } | undefined;
82
- };
83
- export declare type RegisterFederatedIdMutationVariables = Exact<{
84
- input: RegisterFederatedIdInput;
85
- }>;
86
- export declare type RegisterFederatedIdMutation = {
87
- __typename?: 'Mutation';
88
- registerFederatedId?: {
89
- __typename?: 'FederatedId';
90
- identityId: string;
91
- } | undefined;
92
- };
93
- export declare const DeregisterDocument: DocumentNode<DeregisterMutation, Exact<{
94
- [key: string]: never;
95
- }>>;
96
- export declare const GlobalSignOutDocument: DocumentNode<GlobalSignOutMutation, Exact<{
97
- [key: string]: never;
98
- }>>;
99
- export declare const RegisterFederatedIdDocument: DocumentNode<RegisterFederatedIdMutation, Exact<{
100
- input: RegisterFederatedIdInput;
101
- }>>;
package/lib/index.d.ts DELETED
@@ -1,4 +0,0 @@
1
- export { DefaultSudoUserClient } from './user/user-client';
2
- export * from './user/user-client-interface';
3
- export { TESTAuthenticationProvider, LocalAuthenticationProvider, AuthenticationProvider, } from './user/auth-provider';
4
- export * from './user/error';
@@ -1,2 +0,0 @@
1
- import { CryptoProvider } from '../../core/crypto';
2
- export declare const cryptoProvider: CryptoProvider;
@@ -1,2 +0,0 @@
1
- import { CryptoProvider } from '../../core/crypto';
2
- export declare const cryptoProvider: CryptoProvider;
package/lib/sdk.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from './core/sdk-config';
@@ -1,97 +0,0 @@
1
- export interface AuthenticationInfo {
2
- /**
3
- * Authentication type.
4
- */
5
- type: string;
6
- /**
7
- * Indicates whether or not the authentication information is valid.
8
- *
9
- * @return *true* if the authentication information is valid.
10
- */
11
- isValid(): boolean;
12
- /**
13
- * Encodes the authentication information as a string.
14
- *
15
- * @return encoded authentication information.
16
- */
17
- encode(): string;
18
- /**
19
- * Returns the username associated with this authentication information.
20
- *
21
- * @return username.
22
- */
23
- getUsername(): string;
24
- }
25
- export interface AuthenticationProvider {
26
- /**
27
- * Generates and returns authentication information.
28
- *
29
- * @return authentication information.
30
- */
31
- getAuthenticationInfo(): Promise<AuthenticationInfo>;
32
- /**
33
- * Resets internal state and releases any associated resources.
34
- */
35
- reset(): void;
36
- }
37
- /**
38
- * Authentication info consisting of a JWT signed using the TEST registration key.
39
- */
40
- export declare class TESTAuthenticationInfo implements AuthenticationInfo {
41
- private jwt;
42
- readonly type: string;
43
- constructor(jwt: string);
44
- isValid(): boolean;
45
- encode(): string;
46
- getUsername(): string;
47
- }
48
- /**
49
- * Authentication provider for generating authentication info using a TEST registration key.
50
- *
51
- * @param name provider name. This name will be prepended to the generated UUID in JWT sub.
52
- * @param privateKey PEM encoded RSA private key.
53
- * @param keyId key ID of the TEST registration key which is obtained from the admin console.
54
- * @param attributes additional attributes to be added to the issued authentication info.
55
- */
56
- export declare class TESTAuthenticationProvider implements AuthenticationProvider {
57
- private name;
58
- private privateKey;
59
- private keyId;
60
- private attributes?;
61
- readonly testRegistrationIssuer: string;
62
- readonly testRegistrationAudience: string;
63
- constructor(name: string, privateKey: string, keyId?: string, attributes?: Record<string, any> | undefined);
64
- getAuthenticationInfo(): Promise<AuthenticationInfo>;
65
- reset(): void;
66
- }
67
- /**
68
- * Authentication info consisting of a JWT signed using the locally stored private key.
69
- */
70
- export declare class LocalAuthenticationInfo implements AuthenticationInfo {
71
- private jwt;
72
- private username;
73
- readonly type: string;
74
- constructor(jwt: string, username: string);
75
- isValid(): boolean;
76
- encode(): string;
77
- getUsername(): string;
78
- }
79
- /**
80
- * Authentication info consisting of a JWT signed using the locally stored private key.
81
- *
82
- * @param name provider name. This name will be used to populate JWT iss (issuer).
83
- * @param privateKey PEM encoded RSA private key.
84
- * @param keyId key ID.
85
- * @param username username to be associated with the issued authentication info.
86
- * @param attributes additional attributes to be added to the issued authentication info.
87
- */
88
- export declare class LocalAuthenticationProvider implements AuthenticationProvider {
89
- private name;
90
- private privateKey;
91
- private keyId;
92
- private username;
93
- private attributes?;
94
- constructor(name: string, privateKey: string, keyId: string, username: string, attributes?: Record<string, any> | undefined);
95
- getAuthenticationInfo(): Promise<AuthenticationInfo>;
96
- reset(): void;
97
- }
@@ -1,64 +0,0 @@
1
- import { Logger } from '@sudoplatform/sudo-common';
2
- import { AuthenticationStore } from '../core/auth-store';
3
- import { KeyManager } from '../core/key-manager';
4
- import { FederatedSignInConfig } from '../core/sdk-config';
5
- import { Subscriber } from '../core/subscriber';
6
- import { AuthenticationTokens } from './user-client-interface';
7
- export interface AuthenticationDetails {
8
- authenticationTokens: AuthenticationTokens;
9
- userId: string;
10
- }
11
- export interface AuthUI {
12
- /**
13
- * Presents the sign in UI for federated sign in using an external identity provider.
14
- */
15
- presentFederatedSignInUI(): void;
16
- /**
17
- * Processes tokens from federated sign in that are returned in exchange
18
- * for the authorization code that is returned to the specified URL.
19
- *
20
- * @param url callback URL containing the authorization code.
21
- * @return Successful authentication result AuthenticationTokens.
22
- */
23
- processFederatedSignInTokens(url: string): Promise<AuthenticationTokens>;
24
- /**
25
- * Resets any internal state.
26
- */
27
- reset(): void;
28
- /**
29
- * Presents the Cognito hosted UI signout endpoint.
30
- * When the endpoint is invoked, the hosted web app's cookies
31
- * will be invalidated, but the user is not logged out of Cognito.
32
- */
33
- presentSignOutUI(): void;
34
- }
35
- export declare const DefaultRefreshTokenLifetime = 60;
36
- export declare class CognitoAuthUI implements AuthUI, Subscriber {
37
- private authenticationStore;
38
- private federatedSignInConfig;
39
- private keyManager;
40
- private launchUriFn?;
41
- private auth;
42
- private tokensRefreshedPromise?;
43
- private refreshTokenLifetime;
44
- private logger;
45
- constructor(authenticationStore: AuthenticationStore, federatedSignInConfig: FederatedSignInConfig, keyManager: KeyManager, logger: Logger, launchUriFn?: ((url: string) => void) | undefined);
46
- private initCognitoAuthSDK;
47
- presentFederatedSignInUI(): void;
48
- processFederatedSignInTokens(url: string): Promise<AuthenticationTokens>;
49
- /**
50
- * This function is called when the authentication store notifies subscribers of an item update.
51
- *
52
- * @param itemName the name of the item being updated
53
- */
54
- update(itemName: string): void;
55
- reset(): void;
56
- presentSignOutUI(): void;
57
- private storeRefreshTokenLifetime;
58
- private getAuthTokens;
59
- private getTokenExpiry;
60
- /**
61
- * Store the authentication tokens and user id of the signed in user in the key manager.
62
- */
63
- private storeTokensInKeyManager;
64
- }
@@ -1,18 +0,0 @@
1
- declare class UserError extends Error {
2
- constructor(msg?: string);
3
- }
4
- /**
5
- * Indicates the user associated with the client is already registered.
6
- */
7
- export declare class AlreadyRegisteredError extends UserError {
8
- constructor();
9
- }
10
- /**
11
- * Indicates the configuration related to Identity Service is not found. This may indicate that Identity Service
12
- * is not deployed into your runtime instance or the config file that
13
- * you are using is invalid.
14
- */
15
- export declare class IdentityServiceConfigNotFoundError extends UserError {
16
- constructor();
17
- }
18
- export {};
@@ -1,73 +0,0 @@
1
- import { Config } from '../core/sdk-config';
2
- import { AuthenticationTokens } from './user-client-interface';
3
- import { KeyManager } from '../core/key-manager';
4
- import { Logger } from '@sudoplatform/sudo-common';
5
- export interface IdentityProvider {
6
- /**
7
- * Signs out the user from all devices.
8
- *
9
- * @param accessToken access token used to authorize the request.
10
- */
11
- globalSignOut(accessToken: string): Promise<void>;
12
- /**
13
- * Registers a new user against the identity provider.
14
- *
15
- * @param uid user ID.
16
- * @param validationData registration parameters.
17
- * @return user ID
18
- */
19
- register(uid: string, validationData: {
20
- Name: string;
21
- Value: string;
22
- }[]): Promise<string>;
23
- /**
24
- * Sign into the identity provider using a signing key.
25
- *
26
- * @param uid user ID.
27
- * @param keyId signing key id.
28
- * @return Successful authentication result AuthenticationTokens
29
- */
30
- signInWithKey(uid: string, keyId: string): Promise<AuthenticationTokens>;
31
- /**
32
- * Sign into the identity provider using a token issued by an external
33
- * authentication provider.
34
- *
35
- * @param uid user ID.
36
- * @param token authentication token.
37
- * @param type token type.
38
- * @return Successful authentication result AuthenticationTokens
39
- */
40
- signInWithToken(uid: string, token: string, type: string): Promise<AuthenticationTokens>;
41
- /**
42
- * Refresh the access and ID tokens using the refresh token.
43
- *
44
- * @param refreshToken refresh token used to refresh the access and ID tokens.
45
- * @return Successful authentication result AuthenticationTokens containing refreshed tokens
46
- */
47
- refreshTokens(refreshToken: string): Promise<AuthenticationTokens>;
48
- /**
49
- * Signs out the user from this device.
50
- *
51
- * @param refreshToken refresh token to revoke to sign out this device.
52
- */
53
- signOut(refreshToken: string): Promise<void>;
54
- }
55
- export declare class CognitoUserPoolIdentityProvider implements IdentityProvider {
56
- private keyManager;
57
- private config;
58
- private idpService;
59
- private refreshTokenLifetime;
60
- private logger;
61
- constructor(keyManager: KeyManager, config: Config, logger: Logger);
62
- private initCognitoIdpService;
63
- globalSignOut(accessToken: string): Promise<void>;
64
- register(uid: string, validationData: {
65
- Name: string;
66
- Value: string;
67
- }[]): Promise<string>;
68
- signInWithKey(userId: string, keyId: string): Promise<AuthenticationTokens>;
69
- signInWithToken(userId: string, token: string, type: string): Promise<AuthenticationTokens>;
70
- refreshTokens(refreshToken: string): Promise<AuthenticationTokens>;
71
- signOut(refreshToken: string): Promise<void>;
72
- private storeRefreshTokenLifetime;
73
- }
@@ -1,168 +0,0 @@
1
- import { SudoKeyManager } from '@sudoplatform/sudo-common';
2
- import { AuthenticationProvider } from './auth-provider';
3
- /**
4
- * Encapsulates the authentication tokens obtained from a successful authentication.
5
- *
6
- * @param idToken ID token containing the user's identity attributes.
7
- * @param accessToken access token required for authorizing API access.
8
- * @param refreshToken refresh token used for refreshing ID and access tokens.
9
- * @param tokenExpiry expiry of ID and access tokens in milliseconds.
10
- */
11
- export interface AuthenticationTokens {
12
- idToken: string;
13
- accessToken: string;
14
- refreshToken: string;
15
- tokenExpiry: number;
16
- }
17
- /**
18
- * Interface encapsulating a library of functions for calling Sudo Platform identity service,
19
- * handling federated sign in, managing keys and performing cryptographic operations.
20
- */
21
- export interface SudoUserClient {
22
- /**
23
- * Presents the sign in UI for federated sign in using an external identity provider.
24
- */
25
- presentFederatedSignInUI(): void;
26
- /**
27
- * Processes tokens from federated sign in returned to the specified URL.
28
- * The tokens are passed to the web app via a redirect URL.
29
- *
30
- * @param url callback URL containing the tokens.
31
- * @return Successful authentication result AuthenticationTokens.
32
- */
33
- processFederatedSignInTokens(url: string): Promise<AuthenticationTokens>;
34
- /**
35
- * Returns the ID token cached from the last sign-in.
36
- *
37
- * @return ID token.
38
- */
39
- getIdToken(): Promise<string | undefined>;
40
- /**
41
- * Returns the access token cached from the last sign-in.
42
- *
43
- * @return access token.
44
- */
45
- getAccessToken(): Promise<string | undefined>;
46
- /**
47
- * Returns the refresh token cached from the last sign-in.
48
- *
49
- * @return refresh token.
50
- */
51
- getRefreshToken(): Promise<string | undefined>;
52
- /**
53
- * Returns the ID and access token expiry cached from the last sign-in.
54
- *
55
- * @return token expiry.
56
- */
57
- getTokenExpiry(): Promise<Date | undefined>;
58
- /**
59
- * Returns the refresh token expiry cached from the last sign-in.
60
- *
61
- * @return refresh token expiry.
62
- */
63
- getRefreshTokenExpiry(): Promise<Date | undefined>;
64
- /**
65
- * Indicates whether or not this client is signed in with Sudo Platform backend. The client is
66
- * considered signed in if it cached valid ID, access and refresh tokens.
67
- *
68
- * @return *true* if the client is signed in.
69
- */
70
- isSignedIn(): Promise<boolean>;
71
- /**
72
- * Refresh the access and ID tokens using the refresh token.
73
- *
74
- * @param refreshToken refresh token used to refresh the access and ID tokens.
75
- * @return Successful authentication result AuthenticationTokens containing refreshed tokens
76
- */
77
- refreshTokens(refreshToken: string): Promise<AuthenticationTokens>;
78
- /**
79
- * Retrieves the latest ID token. This is to be used by the AWS AppSync client.
80
- *
81
- * @returns the latest ID token
82
- */
83
- getLatestAuthToken(): Promise<string>;
84
- /**
85
- * Returns the user name associated with this client. The username maybe needed to contact
86
- * the support team when diagnosing an issue related to a specific user.
87
- *
88
- * @return user name.
89
- */
90
- getUserName(): Promise<string | undefined>;
91
- /**
92
- * Sets the user name associated with this client.
93
- *
94
- * @param name user name.
95
- */
96
- setUserName(name: string): Promise<void>;
97
- /**
98
- * Returns the subject of the user associated with this client.
99
- * Note: This is an internal method used by other Sudo platform SDKs.
100
- *
101
- * @return user subject.
102
- */
103
- getSubject(): Promise<string | undefined>;
104
- /**
105
- * Returns the specified claim associated with the user's identity.
106
- *
107
- * @param name claim name.
108
- */
109
- getUserClaim(name: string): Promise<any | undefined>;
110
- /**
111
- * Signs out the user from this device.
112
- */
113
- signOut(): Promise<void>;
114
- /**
115
- * Signs out the user from all devices.
116
- */
117
- globalSignOut(): Promise<void>;
118
- /**
119
- * Registers this client against the backend with an external authentication provider. The caller must
120
- * implement AuthenticationProvider protocol to return the appropriate authentication token required
121
- * to authorize the registration request.
122
- *
123
- * @param authenticationProvider authentication provider that provides the authentication token.
124
- * @param registrationId registration ID to uniquely identify this registration request.
125
- * @return user ID of the newly created user
126
- */
127
- registerWithAuthenticationProvider(authenticationProvider: AuthenticationProvider, registrationId?: string): Promise<string>;
128
- /**
129
- * Sign into the backend using an external authentication provider. Caller must implement
130
- * *AuthenticationProvider* interface to return the appropriate authentication token associated with
131
- * the external identity registered with *registerWithAuthenticationProvider*.
132
- *
133
- * @param authenticationProvider authentication provider that provides the authentication token.
134
- * @return authentication tokens associated with the successful sign in.
135
- */
136
- signInWithAuthenticationProvider(authenticationProvider: AuthenticationProvider): Promise<AuthenticationTokens>;
137
- /**
138
- * Indicates whether or not this client is registered with Sudo Platform backend.
139
- *
140
- * @return *true* if the client is registered.
141
- */
142
- isRegistered(): Promise<boolean>;
143
- /**
144
- * Sign into the backend using a private key. The client must have created a private/public key pair via
145
- * the *registerWithAuthenticationProvider* method.
146
- *
147
- * @return authentication tokens associated with the successful sign in.
148
- */
149
- signInWithKey(): Promise<AuthenticationTokens>;
150
- /**
151
- * Clears cached authentication tokens.
152
- */
153
- clearAuthenticationTokens(): Promise<void>;
154
- /**
155
- * Presents the Cognito hosted UI signout endpoint.
156
- * When the endpoint is invoked, the hosted web app's cookies
157
- * will be invalidated, but the user is not logged out of Cognito.
158
- */
159
- presentSignOutUI(): void;
160
- /**
161
- * Resets internal state and clears any cached data.
162
- */
163
- reset(): void;
164
- /**
165
- * Getter to retrieve the SudoKeyManager
166
- */
167
- readonly sudoKeyManager: SudoKeyManager;
168
- }
@@ -1,82 +0,0 @@
1
- import { Logger, SudoKeyManager } from '@sudoplatform/sudo-common';
2
- import { AuthenticationProvider } from '..';
3
- import { ApiClient } from '../client/apiClient';
4
- import { AuthenticationStore } from '../core/auth-store';
5
- import { Config } from '../core/sdk-config';
6
- import { AuthUI } from './auth';
7
- import { IdentityProvider } from './identity-provider';
8
- import { AuthenticationTokens, SudoUserClient } from './user-client-interface';
9
- export interface SudoUserOptions {
10
- authenticationStore?: AuthenticationStore;
11
- sudoKeyManager?: SudoKeyManager;
12
- apiClient?: ApiClient;
13
- authUI?: AuthUI;
14
- identityProvider?: IdentityProvider;
15
- launchUriFn?: (url: string) => void;
16
- config?: Config;
17
- logger?: Logger;
18
- }
19
- export declare class DefaultSudoUserClient implements SudoUserClient {
20
- private config;
21
- private keyManager;
22
- private sudoUserKeyManager;
23
- private authenticationStore;
24
- private identityProvider;
25
- private apiClient;
26
- private logger;
27
- private authUI?;
28
- private launchUriFn?;
29
- constructor(options?: SudoUserOptions);
30
- get sudoKeyManager(): SudoKeyManager;
31
- presentFederatedSignInUI(): void;
32
- processFederatedSignInTokens(url: string): Promise<AuthenticationTokens>;
33
- getIdToken(): Promise<string | undefined>;
34
- getAccessToken(): Promise<string | undefined>;
35
- getRefreshToken(): Promise<string | undefined>;
36
- getTokenExpiry(): Promise<Date | undefined>;
37
- getRefreshTokenExpiry(): Promise<Date | undefined>;
38
- getUserName(): Promise<string | undefined>;
39
- setUserName(name: string): Promise<void>;
40
- getUserClaim(name: string): Promise<any | undefined>;
41
- getSubject(): Promise<string | undefined>;
42
- isSignedIn(): Promise<boolean>;
43
- refreshTokens(refreshToken: string): Promise<AuthenticationTokens>;
44
- getLatestAuthToken(): Promise<string>;
45
- signOut(): Promise<void>;
46
- globalSignOut(): Promise<void>;
47
- registerWithAuthenticationProvider(authenticationProvider: AuthenticationProvider, registrationId?: string): Promise<string>;
48
- signInWithAuthenticationProvider(authenticationProvider: AuthenticationProvider): Promise<AuthenticationTokens>;
49
- isRegistered(): Promise<boolean>;
50
- signInWithKey(): Promise<AuthenticationTokens>;
51
- deregister(): Promise<void>;
52
- clearAuthenticationTokens(): Promise<void>;
53
- presentSignOutUI(): void;
54
- reset(): void;
55
- private getTokenClaim;
56
- /**
57
- * Store the authentication tokens and user id of the signed in user. This function
58
- * is only called when a user has successfully signed in using a private key.
59
- */
60
- private storeTokens;
61
- private registerFederatedIdAndRefreshTokens;
62
- private generateRegistrationData;
63
- private getAuthTokens;
64
- /**
65
- * Provide a custom auth UI. This is mainly used for unit testing (optional).
66
- */
67
- setAuthUI(authUI: AuthUI): void;
68
- /**
69
- * Provide a custom identity provider. This is mainly used for unit testing (optional).
70
- */
71
- setIdentityProvider(identityProvider: IdentityProvider): void;
72
- /**
73
- * Provide a custom function to open the sign in url.
74
- * This is mainly used for unit testing (optional).
75
- */
76
- setLaunchUriFn(launchUriFn: (url: string) => void): void;
77
- /**
78
- * Provide a custom authentication store.
79
- * This is mainly used for unit testing (optional).
80
- */
81
- setAuthenticationStore(authenticationStore: AuthenticationStore): void;
82
- }
@@ -1,6 +0,0 @@
1
- export declare const userKeyNames: {
2
- symmetricKeyId: string;
3
- userKeyId: string;
4
- userId: string;
5
- identityId: string;
6
- };
@@ -1,9 +0,0 @@
1
- declare type Resolver<T> = (value: T) => void;
2
- export declare type ResolvablePromise<T> = Promise<T> & {
3
- resolve: Resolver<T>;
4
- };
5
- /**
6
- * A promise that can be resolved externally
7
- */
8
- export declare function createResolvablePromise<T>(): ResolvablePromise<T>;
9
- export {};
@@ -1,4 +0,0 @@
1
- declare module '@redux-offline/redux-offline/lib/types' {
2
- export type NetInfo = any
3
- export type NetworkCallback = any
4
- }