@amazon-devices/keplerscript-identity-lwa-lib 0.0.55
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.
- package/LICENSE +7 -0
- package/SystemBundles/04ad59b8f4ab7babde58b0bfe339453f6425964d333795efdf79108211197086.bundle +1126 -0
- package/SystemBundles/04ad59b8f4ab7babde58b0bfe339453f6425964d333795efdf79108211197086.bundle.map +1 -0
- package/SystemModules/amzn__keplerscript-identity-lwa-lib-0.modules.txt +4 -0
- package/SystemModules/amzn__keplerscript-identity-lwa-lib-0.private.modules.txt +17 -0
- package/SystemModules/keplerscript-system-bundle-config.json +7 -0
- package/THIRD_PARTY_NOTICES.txt +5993 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +8 -0
- package/dist/kepler/tm-manifest.json +1 -0
- package/dist/turbo-modules/KeplerLWATurboModuleManager.d.ts +57 -0
- package/dist/turbo-modules/KeplerLWATurboModuleManager.js +132 -0
- package/dist/turbo-modules/__mocks__/keplerLWATurboModules.d.ts +22 -0
- package/dist/turbo-modules/__mocks__/keplerLWATurboModules.js +34 -0
- package/dist/turbo-modules/keplerLWATurboModules.d.ts +11 -0
- package/dist/turbo-modules/keplerLWATurboModules.js +4 -0
- package/dist/types/LWADataTypes.d.ts +235 -0
- package/dist/types/LWADataTypes.js +49 -0
- package/kepler-compatibility.json +16 -0
- package/kepler-transformed-package-info.json +3 -0
- package/package.json +1 -0
- package/react-native.config.js +19 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { AuthorizationManager } from './turbo-modules/KeplerLWATurboModuleManager';
|
|
2
|
+
export type { GetTokenCallbacks, AuthorizeCallbacks, GetUserCallbacks, SignOutCallbacks, AuthorizeCancellationReason, AuthorizeSuccessParams, AuthorizeRequest, } from './types/LWADataTypes';
|
|
3
|
+
export { ScopeName, GrantTypeName } from './types/LWADataTypes';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GrantTypeName = exports.ScopeName = exports.AuthorizationManager = void 0;
|
|
4
|
+
var KeplerLWATurboModuleManager_1 = require("./turbo-modules/KeplerLWATurboModuleManager");
|
|
5
|
+
Object.defineProperty(exports, "AuthorizationManager", { enumerable: true, get: function () { return KeplerLWATurboModuleManager_1.AuthorizationManager; } });
|
|
6
|
+
var LWADataTypes_1 = require("./types/LWADataTypes");
|
|
7
|
+
Object.defineProperty(exports, "ScopeName", { enumerable: true, get: function () { return LWADataTypes_1.ScopeName; } });
|
|
8
|
+
Object.defineProperty(exports, "GrantTypeName", { enumerable: true, get: function () { return LWADataTypes_1.GrantTypeName; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"schema":1,"fileSets":{"native":[{"arch":"aarch64","variant":"release","directoryPath":"aarch64-release"},{"arch":"armv7","variant":"release","directoryPath":"armv7-release"},{"arch":"x86_64","variant":"release","directoryPath":"x86_64-release"},{"arch":"aarch64","variant":"debug","directoryPath":"aarch64-debug"},{"arch":"armv7","variant":"debug","directoryPath":"armv7-debug"},{"arch":"x86_64","variant":"debug","directoryPath":"x86_64-debug"}]}}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { AuthorizeCallbacks, AuthorizeRequest, GetTokenCallbacks, GetUserCallbacks, SignOutCallbacks } from '../types/LWADataTypes';
|
|
2
|
+
/**
|
|
3
|
+
* Manages the interaction with the LWATurboModules (Login with Amazon).
|
|
4
|
+
* This class provides methods to register event listeners, obtain tokens, authorize users,
|
|
5
|
+
* retrieve user information, and sign out.
|
|
6
|
+
*/
|
|
7
|
+
export declare class AuthorizationManager {
|
|
8
|
+
/**
|
|
9
|
+
* Requests an authorization token (using OAuth 2.0).
|
|
10
|
+
* The `authorize` API method must have been called successfully with the same scopes,
|
|
11
|
+
* and the user must have granted consent to those scopes once, prior to this call, in order to get a token.
|
|
12
|
+
*
|
|
13
|
+
* If the app has restarted since the last authorize call, `getToken` may still succeed using the cached credentials.
|
|
14
|
+
*
|
|
15
|
+
* @param {GetTokenCallbacks} [getTokenCallbacks] - Optional callbacks to handle token retrieval success or failure.
|
|
16
|
+
* @throws {Error} - Throws an error if `keplerLWATurboModules` is not available.
|
|
17
|
+
*/
|
|
18
|
+
static getToken(getTokenCallbacks?: GetTokenCallbacks): void;
|
|
19
|
+
/**
|
|
20
|
+
* Performs authorization (using OAuth 2.0) using the specified scopes in the AuthorizeRequest object.
|
|
21
|
+
* By default, an Amazon-hosted WebView is used to present a page that prompts the user to authorize the application.
|
|
22
|
+
* To be notified when the authorization flow has finished, register an AuthorizeCallbacks on the request.
|
|
23
|
+
* The user should provide consent for these scopes before this authorization call. This method will initiate the OAuth flow.
|
|
24
|
+
* @param {AuthorizeRequest} authorizeRequest - Object containing the scopes for which authorization is requested.
|
|
25
|
+
* The user must grant consent for these scopes.
|
|
26
|
+
* @param {AuthorizeCallbacks} [authorizeCallbacks] - Optional callbacks to handle authorization success, failure, or cancellation.
|
|
27
|
+
* @throws {Error} - Throws an error if `keplerLWATurboModules` is not available.
|
|
28
|
+
*/
|
|
29
|
+
static authorize(authorizeRequest: AuthorizeRequest, authorizeCallbacks?: AuthorizeCallbacks): void;
|
|
30
|
+
/**
|
|
31
|
+
* Retrieves basic profile information for a user (using OAuth 2.0) for the scopes requested in the last call to `authorize` API.
|
|
32
|
+
* The authorize method must have been called once prior to this call so that a user can authorize the app.
|
|
33
|
+
* If the app has restarted since the last authorize call, this may still succeed using the cached profile data and/or credentials.
|
|
34
|
+
*
|
|
35
|
+
* @param {GetUserCallbacks} [getUserCallbacks] - This is mandatory on the first call and it gets registered internally.
|
|
36
|
+
* For the subsequent calls it is optional. If provided it would take the given callback if not whatever was registered previously.
|
|
37
|
+
* @return {void} - This method does not return a value. Instead, it uses callbacks to handle success or failure.
|
|
38
|
+
*/
|
|
39
|
+
static getUser(getUserCallbacks?: GetUserCallbacks): void;
|
|
40
|
+
/**
|
|
41
|
+
* Removes any local authorization for the current user from this application.
|
|
42
|
+
* This method will sign out the user by clearing local credentials and cached authorization tokens.
|
|
43
|
+
* User must call authorize again to get tokens or user profile information.
|
|
44
|
+
* @param {SignOutCallbacks} [signOutCallbacks] - This is mandatory on the first call and it gets registered internally.
|
|
45
|
+
* For the subsequent calls it is optional. If provided it would take the given callback if not whatever was registered previously.
|
|
46
|
+
* @return {void} - This method does not return a value. Instead, it uses callbacks to handle success or failure.
|
|
47
|
+
*/
|
|
48
|
+
static signOut(signOutCallbacks?: SignOutCallbacks): void;
|
|
49
|
+
/**
|
|
50
|
+
* Registers an event listener for a specified event.
|
|
51
|
+
* @param {string} eventName - The name of the event to listen for.
|
|
52
|
+
* @param {function} callback - The callback function to execute when the event is triggered.
|
|
53
|
+
* The callback receives the event payload.
|
|
54
|
+
* @private
|
|
55
|
+
*/
|
|
56
|
+
private static registerListener;
|
|
57
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.AuthorizationManager = void 0;
|
|
7
|
+
const LWADataTypes_1 = require("../types/LWADataTypes");
|
|
8
|
+
const keplerLWATurboModules_1 = __importDefault(require("./keplerLWATurboModules"));
|
|
9
|
+
/**
|
|
10
|
+
* Manages the interaction with the LWATurboModules (Login with Amazon).
|
|
11
|
+
* This class provides methods to register event listeners, obtain tokens, authorize users,
|
|
12
|
+
* retrieve user information, and sign out.
|
|
13
|
+
*/
|
|
14
|
+
class AuthorizationManager {
|
|
15
|
+
/**
|
|
16
|
+
* Requests an authorization token (using OAuth 2.0).
|
|
17
|
+
* The `authorize` API method must have been called successfully with the same scopes,
|
|
18
|
+
* and the user must have granted consent to those scopes once, prior to this call, in order to get a token.
|
|
19
|
+
*
|
|
20
|
+
* If the app has restarted since the last authorize call, `getToken` may still succeed using the cached credentials.
|
|
21
|
+
*
|
|
22
|
+
* @param {GetTokenCallbacks} [getTokenCallbacks] - Optional callbacks to handle token retrieval success or failure.
|
|
23
|
+
* @throws {Error} - Throws an error if `keplerLWATurboModules` is not available.
|
|
24
|
+
*/
|
|
25
|
+
static getToken(getTokenCallbacks) {
|
|
26
|
+
if (!keplerLWATurboModules_1.default) {
|
|
27
|
+
throw Error(`Something went wrong. Error creating the Turbo module manager`);
|
|
28
|
+
}
|
|
29
|
+
if (getTokenCallbacks) {
|
|
30
|
+
this.registerListener('getTokenSuccess', getTokenCallbacks.getTokenSuccess);
|
|
31
|
+
this.registerListener('getTokenFailure', getTokenCallbacks.getTokenFailure);
|
|
32
|
+
}
|
|
33
|
+
keplerLWATurboModules_1.default.getToken();
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Performs authorization (using OAuth 2.0) using the specified scopes in the AuthorizeRequest object.
|
|
37
|
+
* By default, an Amazon-hosted WebView is used to present a page that prompts the user to authorize the application.
|
|
38
|
+
* To be notified when the authorization flow has finished, register an AuthorizeCallbacks on the request.
|
|
39
|
+
* The user should provide consent for these scopes before this authorization call. This method will initiate the OAuth flow.
|
|
40
|
+
* @param {AuthorizeRequest} authorizeRequest - Object containing the scopes for which authorization is requested.
|
|
41
|
+
* The user must grant consent for these scopes.
|
|
42
|
+
* @param {AuthorizeCallbacks} [authorizeCallbacks] - Optional callbacks to handle authorization success, failure, or cancellation.
|
|
43
|
+
* @throws {Error} - Throws an error if `keplerLWATurboModules` is not available.
|
|
44
|
+
*/
|
|
45
|
+
static authorize(authorizeRequest, authorizeCallbacks) {
|
|
46
|
+
if (!keplerLWATurboModules_1.default) {
|
|
47
|
+
throw Error(`Something went wrong. Error creating the Turbo module manager`);
|
|
48
|
+
}
|
|
49
|
+
const [scopes, finalGrantType, finalCodeChallenge, finalCodeChallengeMethod] = buildAuthorizeParams(authorizeRequest);
|
|
50
|
+
if (authorizeCallbacks) {
|
|
51
|
+
this.registerListener('authorizeSuccess', authorizeCallbacks.authorizeSuccess);
|
|
52
|
+
this.registerListener('authorizeFailure', authorizeCallbacks.authorizeFailure);
|
|
53
|
+
this.registerListener('authorizeCancel', authorizeCallbacks.authorizeCancel);
|
|
54
|
+
}
|
|
55
|
+
keplerLWATurboModules_1.default.authorize(scopes, finalGrantType, finalCodeChallenge, finalCodeChallengeMethod);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Retrieves basic profile information for a user (using OAuth 2.0) for the scopes requested in the last call to `authorize` API.
|
|
59
|
+
* The authorize method must have been called once prior to this call so that a user can authorize the app.
|
|
60
|
+
* If the app has restarted since the last authorize call, this may still succeed using the cached profile data and/or credentials.
|
|
61
|
+
*
|
|
62
|
+
* @param {GetUserCallbacks} [getUserCallbacks] - This is mandatory on the first call and it gets registered internally.
|
|
63
|
+
* For the subsequent calls it is optional. If provided it would take the given callback if not whatever was registered previously.
|
|
64
|
+
* @return {void} - This method does not return a value. Instead, it uses callbacks to handle success or failure.
|
|
65
|
+
*/
|
|
66
|
+
static getUser(getUserCallbacks) {
|
|
67
|
+
if (!keplerLWATurboModules_1.default) {
|
|
68
|
+
throw Error(`Something went wrong. Error creating the Turbo module manager`);
|
|
69
|
+
}
|
|
70
|
+
if (getUserCallbacks) {
|
|
71
|
+
this.registerListener('getUserSuccess', getUserCallbacks.getUserSuccess);
|
|
72
|
+
this.registerListener('getUserFailure', getUserCallbacks.getUserFailure);
|
|
73
|
+
}
|
|
74
|
+
keplerLWATurboModules_1.default.getUser();
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Removes any local authorization for the current user from this application.
|
|
78
|
+
* This method will sign out the user by clearing local credentials and cached authorization tokens.
|
|
79
|
+
* User must call authorize again to get tokens or user profile information.
|
|
80
|
+
* @param {SignOutCallbacks} [signOutCallbacks] - This is mandatory on the first call and it gets registered internally.
|
|
81
|
+
* For the subsequent calls it is optional. If provided it would take the given callback if not whatever was registered previously.
|
|
82
|
+
* @return {void} - This method does not return a value. Instead, it uses callbacks to handle success or failure.
|
|
83
|
+
*/
|
|
84
|
+
static signOut(signOutCallbacks) {
|
|
85
|
+
if (!keplerLWATurboModules_1.default) {
|
|
86
|
+
throw Error(`Something went wrong. Error creating the Turbo module manager`);
|
|
87
|
+
}
|
|
88
|
+
if (signOutCallbacks) {
|
|
89
|
+
this.registerListener('signOutFailure', signOutCallbacks.signOutFailure);
|
|
90
|
+
this.registerListener('signOutSuccess', signOutCallbacks.signOutSuccess);
|
|
91
|
+
}
|
|
92
|
+
keplerLWATurboModules_1.default.signOut();
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Registers an event listener for a specified event.
|
|
96
|
+
* @param {string} eventName - The name of the event to listen for.
|
|
97
|
+
* @param {function} callback - The callback function to execute when the event is triggered.
|
|
98
|
+
* The callback receives the event payload.
|
|
99
|
+
* @private
|
|
100
|
+
*/
|
|
101
|
+
static registerListener = (eventName, callback) => {
|
|
102
|
+
keplerLWATurboModules_1.default.registerListener(eventName, callback);
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
exports.AuthorizationManager = AuthorizationManager;
|
|
106
|
+
/**
|
|
107
|
+
* Builds and returns the parameters required for an authorization request
|
|
108
|
+
* based on the grant type and other optional fields.
|
|
109
|
+
*
|
|
110
|
+
* @param authorizeRequest - Object containing scopes, grantType, codeChallenge, and codeChallengeMethod
|
|
111
|
+
* @returns A tuple containing:
|
|
112
|
+
* - scopes: The requested scopes
|
|
113
|
+
* - finalGrantType: The grant type to use (default is ACCESS_TOKEN)
|
|
114
|
+
* - finalCodeChallenge: The PKCE code challenge (if applicable)
|
|
115
|
+
* - finalCodeChallengeMethod: The PKCE challenge method (if applicable)
|
|
116
|
+
*/
|
|
117
|
+
const buildAuthorizeParams = (authorizeRequest) => {
|
|
118
|
+
// Destructure fields from the authorize request. Using 'any' for flexibility in input structure.
|
|
119
|
+
const { scopes, grantType, codeChallenge, codeChallengeMethod } = authorizeRequest;
|
|
120
|
+
// Set default values
|
|
121
|
+
let finalGrantType = LWADataTypes_1.GrantTypeName.ACCESS_TOKEN; // Default grant type
|
|
122
|
+
let finalCodeChallenge = ''; // Default empty string for code challenge
|
|
123
|
+
let finalCodeChallengeMethod = ''; // Default empty string for challenge method
|
|
124
|
+
// If the grant type is AUTH_CODE (indicating PKCE flow), override defaults
|
|
125
|
+
if (grantType === 'AUTH_CODE') {
|
|
126
|
+
finalGrantType = grantType;
|
|
127
|
+
finalCodeChallenge = codeChallenge || ''; // Use provided code challenge or empty string
|
|
128
|
+
finalCodeChallengeMethod = codeChallengeMethod || ''; // Use provided method or empty string
|
|
129
|
+
}
|
|
130
|
+
// Return all required parameters as an array
|
|
131
|
+
return [scopes, finalGrantType, finalCodeChallenge, finalCodeChallengeMethod];
|
|
132
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
declare function identityFunction<T>(value: T): T;
|
|
2
|
+
declare const _default: {
|
|
3
|
+
getConstants: () => {
|
|
4
|
+
const1: boolean;
|
|
5
|
+
const2: number;
|
|
6
|
+
const3: string;
|
|
7
|
+
};
|
|
8
|
+
voidFunc: () => {};
|
|
9
|
+
getBool: typeof identityFunction;
|
|
10
|
+
getNumber: typeof identityFunction;
|
|
11
|
+
getString: typeof identityFunction;
|
|
12
|
+
getArray: typeof identityFunction;
|
|
13
|
+
getArrayBuffer: typeof identityFunction;
|
|
14
|
+
getObject: typeof identityFunction;
|
|
15
|
+
getValue: typeof identityFunction;
|
|
16
|
+
getValueWithCallback: (callback: any) => void;
|
|
17
|
+
getValueWithPromise: (error: boolean) => Promise<string>;
|
|
18
|
+
getMajorVersion: () => number;
|
|
19
|
+
getMinorVersion: () => number;
|
|
20
|
+
getPatchVersion: () => number;
|
|
21
|
+
};
|
|
22
|
+
export default _default;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
function identityFunction(value) {
|
|
4
|
+
return value;
|
|
5
|
+
}
|
|
6
|
+
exports.default = {
|
|
7
|
+
getConstants: () => ({
|
|
8
|
+
const1: true,
|
|
9
|
+
const2: 375,
|
|
10
|
+
const3: 'something',
|
|
11
|
+
}),
|
|
12
|
+
voidFunc: () => ({}),
|
|
13
|
+
getBool: identityFunction,
|
|
14
|
+
getNumber: identityFunction,
|
|
15
|
+
getString: identityFunction,
|
|
16
|
+
getArray: identityFunction,
|
|
17
|
+
getArrayBuffer: identityFunction,
|
|
18
|
+
getObject: identityFunction,
|
|
19
|
+
getValue: identityFunction,
|
|
20
|
+
getValueWithCallback: (callback) => {
|
|
21
|
+
callback('value from callback!');
|
|
22
|
+
},
|
|
23
|
+
getValueWithPromise: (error) => {
|
|
24
|
+
if (error) {
|
|
25
|
+
return Promise.reject('intentional promise rejection');
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
return Promise.resolve('result!');
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
getMajorVersion: () => 1,
|
|
32
|
+
getMinorVersion: () => 0,
|
|
33
|
+
getPatchVersion: () => 0,
|
|
34
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { KeplerTurboModule } from '@amazon-devices/keplerscript-turbomodule-api';
|
|
2
|
+
import { GrantTypeName, Scope } from '../types/LWADataTypes';
|
|
3
|
+
export interface keplerLWATurboModules extends KeplerTurboModule {
|
|
4
|
+
registerListener: (eventName: string, callback: (payload: any) => void) => void;
|
|
5
|
+
getUser: () => void;
|
|
6
|
+
signOut: () => void;
|
|
7
|
+
getToken: () => void;
|
|
8
|
+
authorize: (scopes: Scope[], grantType: GrantTypeName, codeChallenge: string, codeChallengeMethod: string) => void;
|
|
9
|
+
}
|
|
10
|
+
declare const _default: keplerLWATurboModules;
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const keplerscript_turbomodule_api_1 = require("@amazon-devices/keplerscript-turbomodule-api");
|
|
4
|
+
exports.default = keplerscript_turbomodule_api_1.TurboModuleRegistry.getEnforcing('keplerLWATurboModules');
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request data object to hold the authorization request
|
|
3
|
+
*/
|
|
4
|
+
export interface AuthorizeRequest {
|
|
5
|
+
scopes: Scope[];
|
|
6
|
+
grantType?: GrantTypeName;
|
|
7
|
+
codeChallenge?: string;
|
|
8
|
+
codeChallengeMethod?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare enum GrantTypeName {
|
|
11
|
+
ACCESS_TOKEN = "ACCESS_TOKEN",
|
|
12
|
+
AUTH_CODE = "AUTH_CODE"
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Defines the programmatic concept of an OAuth 2.0 scope.
|
|
16
|
+
* The AuthorizationManager and related APIs take in scopes that conform to this interface.
|
|
17
|
+
*/
|
|
18
|
+
export interface Scope {
|
|
19
|
+
/**
|
|
20
|
+
* Name of the scope requesteds
|
|
21
|
+
*/
|
|
22
|
+
name: ScopeName;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Contains list of all possible scopes supported by Amazon Identity
|
|
26
|
+
*/
|
|
27
|
+
export declare enum ScopeName {
|
|
28
|
+
/**
|
|
29
|
+
* Provides authorization to the user profile
|
|
30
|
+
*/
|
|
31
|
+
PROFILE = "PROFILE",
|
|
32
|
+
/**
|
|
33
|
+
* Provides authorization to the user's Amazon account ID
|
|
34
|
+
*/
|
|
35
|
+
USERID = "USERID",
|
|
36
|
+
/**
|
|
37
|
+
* Provides authorization to the user's zip/postal code
|
|
38
|
+
*/
|
|
39
|
+
POSTAL_CODE = "POSTAL_CODE",
|
|
40
|
+
/**
|
|
41
|
+
* Provides authorization to the user's Mobile number
|
|
42
|
+
*/
|
|
43
|
+
MOBILE_NUMBER = "MOBILE_NUMBER"
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* @interface TokenCallbacks
|
|
47
|
+
* @description Represents a set of callback functions for token-related events.
|
|
48
|
+
*
|
|
49
|
+
* @property {function} getTokenSuccess - A callback function invoked when a token is successfully obtained.
|
|
50
|
+
* @param {string} access_token - The access token obtained successfully.
|
|
51
|
+
*
|
|
52
|
+
* @property {function} getTokenFailure - A callback function invoked when there's a failure in obtaining a token.
|
|
53
|
+
* @param {string} error_msg - The error message indicating the reason for the failure.
|
|
54
|
+
*/
|
|
55
|
+
/**
|
|
56
|
+
* GetTokenCallbacks defines a set of callback functions for token-related events.
|
|
57
|
+
* @type {GetTokenCallbacks}
|
|
58
|
+
*/
|
|
59
|
+
export interface GetTokenCallbacks {
|
|
60
|
+
/**
|
|
61
|
+
* Callback function invoked when a token is successfully obtained.
|
|
62
|
+
*
|
|
63
|
+
* @param {string} access_token - The access token obtained successfully.
|
|
64
|
+
*/
|
|
65
|
+
getTokenSuccess: (access_token: string) => void;
|
|
66
|
+
/**
|
|
67
|
+
* Callback function invoked when there's a failure in obtaining a token.
|
|
68
|
+
*
|
|
69
|
+
* @param {string} error_msg - The error message indicating the reason for the failure.
|
|
70
|
+
*/
|
|
71
|
+
getTokenFailure: (error_msg: string) => void;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* @interface User - Represents a user's profile information retrieved from their Amazon account.
|
|
75
|
+
* @property {string} userId - The user's Amazon account ID. Provided when the requested scope includes `PROFILE` or `USERID`.
|
|
76
|
+
* @property {string} userName - The user's name as set in their Amazon customer profile. Provided when the requested scope includes `PROFILE`.
|
|
77
|
+
* @property {string} userEmail - The email address of the customer's Amazon account. Provided when the requested scope includes `PROFILE`.
|
|
78
|
+
* @property {string} userPostalCode - The zip/postal code associated with the customer's account. Provided when the requested scope includes `POSTAL_CODE`.
|
|
79
|
+
* @property {string} userMobileNumber - The mobile number associated with the customer's account. Provided when the requested scope includes `MOBILE_NUMBER`.
|
|
80
|
+
*/
|
|
81
|
+
export interface User {
|
|
82
|
+
/**
|
|
83
|
+
* The user's Amazon account ID, provided when the requested scope includes `PROFILE` or `USERID`.
|
|
84
|
+
*/
|
|
85
|
+
userId: string;
|
|
86
|
+
/**
|
|
87
|
+
* The user's name as set in their Amazon customer profile, provided when the requested scope includes `PROFILE`.
|
|
88
|
+
*/
|
|
89
|
+
userName: string;
|
|
90
|
+
/**
|
|
91
|
+
* The email address of the customer's Amazon account, provided when the requested scope includes `PROFILE`.
|
|
92
|
+
*/
|
|
93
|
+
userEmail: string;
|
|
94
|
+
/**
|
|
95
|
+
* The zip/postal code associated with the customer's account, provided when the requested scope includes `POSTAL_CODE`.
|
|
96
|
+
*/
|
|
97
|
+
userPostalCode: string;
|
|
98
|
+
/**
|
|
99
|
+
* The mobile number associated with the customer's account, provided when the requested scope includes `MOBILE_NUMBER`.
|
|
100
|
+
*/
|
|
101
|
+
userMobileNumber: string;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* @interface AuthorizeCancellationReason - Represents possible reasons for authentication cancellation.
|
|
105
|
+
* @property {string} CANCELLED_CONSENT - Indicates that the user explicitly aborted the authorization flow
|
|
106
|
+
* by not providing consent.
|
|
107
|
+
*/
|
|
108
|
+
export interface AuthorizeCancellationReason {
|
|
109
|
+
/**
|
|
110
|
+
* Indicates that the user explicitly aborted the authorization flow by not providing consent.
|
|
111
|
+
*/
|
|
112
|
+
readonly CANCELLED_CONSENT: 'CANCELLED_CONSENT';
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* @interface AuthorizeSuccessParams
|
|
116
|
+
* @description Represents the parameters passed to the `authorizeSuccess` callback function when authorization is successful.
|
|
117
|
+
*
|
|
118
|
+
* @property {string} access_token - The access token obtained upon successful authorization.
|
|
119
|
+
* @property {User} user - The user object containing information about the authorized user.
|
|
120
|
+
*/
|
|
121
|
+
/**
|
|
122
|
+
* AuthorizeSuccessParams represents the parameters passed to the `authorizeSuccess` callback function when authorization is successful.
|
|
123
|
+
* @type {AuthorizeSuccessParams}
|
|
124
|
+
*/
|
|
125
|
+
export interface AuthorizeSuccessParams {
|
|
126
|
+
access_token: string;
|
|
127
|
+
user: User;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* @interface AuthorizeCallbacks
|
|
131
|
+
* @description Represents a set of callback functions for authorization-related events.
|
|
132
|
+
*
|
|
133
|
+
* @property {function} authorizeSuccess - A callback function invoked when authorization is successful.
|
|
134
|
+
* @param {AuthorizeSuccessParams} response - Parameters containing the access token and user information upon successful authorization.
|
|
135
|
+
*
|
|
136
|
+
* @property {function} authorizeFailure - A callback function invoked when authorization fails.
|
|
137
|
+
* @param {string} error_msg - The error message indicating the reason for authorization failure.
|
|
138
|
+
*
|
|
139
|
+
* @property {function} authorizeCancel - A callback function invoked when the authorization process is cancelled.
|
|
140
|
+
* @param {AuthorizeCancellationReason} cancel_reason - The reason for authorization cancellation.
|
|
141
|
+
*/
|
|
142
|
+
/**
|
|
143
|
+
* AuthorizeCallbacks defines a set of callback functions for authorization-related events.
|
|
144
|
+
* @type {AuthorizeCallbacks}
|
|
145
|
+
*/
|
|
146
|
+
export interface AuthorizeCallbacks {
|
|
147
|
+
/**
|
|
148
|
+
* Callback function invoked when authorization is successful.
|
|
149
|
+
*
|
|
150
|
+
* @param {AuthorizeSuccessParams} response - Parameters containing the access token and user information upon successful authorization.
|
|
151
|
+
*/
|
|
152
|
+
authorizeSuccess: (response: AuthorizeSuccessParams) => void;
|
|
153
|
+
/**
|
|
154
|
+
* Callback function invoked when authorization fails.
|
|
155
|
+
*
|
|
156
|
+
* @param {string} error_msg - The error message indicating the reason for authorization failure.
|
|
157
|
+
*/
|
|
158
|
+
authorizeFailure: (error_msg: string) => void;
|
|
159
|
+
/**
|
|
160
|
+
* Callback function invoked when the authorization process is cancelled.
|
|
161
|
+
*
|
|
162
|
+
* @param {AuthorizeCancellationReason} cancel_reason - The reason for authorization cancellation.
|
|
163
|
+
*/
|
|
164
|
+
authorizeCancel: (cancel_reason: AuthorizeCancellationReason) => void;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* @interface GetUserCallbacks
|
|
168
|
+
* @description Represents a set of callback functions for retrieving user-related information.
|
|
169
|
+
*
|
|
170
|
+
* @property {function} getUserSuccess - A callback function invoked when user information retrieval is successful.
|
|
171
|
+
* @param {User} user - The user object containing information about the user.
|
|
172
|
+
*
|
|
173
|
+
* @property {function} getUserFailure - A callback function invoked when retrieving user information fails.
|
|
174
|
+
* @param {string} error_msg - The error message indicating the reason for user information retrieval failure.
|
|
175
|
+
*/
|
|
176
|
+
/**
|
|
177
|
+
* GetUserCallbacks defines a set of callback functions for retrieving user-related information.
|
|
178
|
+
* @type {GetUserCallbacks}
|
|
179
|
+
*/
|
|
180
|
+
export interface GetUserCallbacks {
|
|
181
|
+
/**
|
|
182
|
+
* Callback function invoked when user information retrieval is successful.
|
|
183
|
+
*
|
|
184
|
+
* @param {User} user - The user object containing information about the user.
|
|
185
|
+
*/
|
|
186
|
+
getUserSuccess: (user: User) => void;
|
|
187
|
+
/**
|
|
188
|
+
* Callback function invoked when retrieving user information fails.
|
|
189
|
+
*
|
|
190
|
+
* @param {string} error_msg - The error message indicating the reason for user information retrieval failure.
|
|
191
|
+
*/
|
|
192
|
+
getUserFailure: (error_msg: string) => void;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* @interface SignOutCallbacks
|
|
196
|
+
* @description Represents a set of callback functions for sign-out related events.
|
|
197
|
+
*
|
|
198
|
+
* @property {function} signOutFailure - A callback function invoked when sign-out operation fails.
|
|
199
|
+
* @param {string} error_msg - The error message indicating the reason for sign-out operation failure.
|
|
200
|
+
*
|
|
201
|
+
* @property {function} signOutSuccess - A callback function invoked when the sign-out operation is successful.
|
|
202
|
+
*/
|
|
203
|
+
/**
|
|
204
|
+
* SignOutCallbacks defines a set of callback functions for sign-out related events.
|
|
205
|
+
* @type {SignOutCallbacks}
|
|
206
|
+
*/
|
|
207
|
+
export interface SignOutCallbacks {
|
|
208
|
+
/**
|
|
209
|
+
* Callback function invoked when sign-out operation fails.
|
|
210
|
+
*
|
|
211
|
+
* @param {string} error_msg - The error message indicating the reason for sign-out operation failure.
|
|
212
|
+
*/
|
|
213
|
+
signOutFailure: (error_msg: string) => void;
|
|
214
|
+
/**
|
|
215
|
+
* Callback function invoked when sign-out operation is successful.
|
|
216
|
+
*/
|
|
217
|
+
signOutSuccess: () => void;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Enum representing various status codes for authentication and authorization errors.
|
|
221
|
+
*/
|
|
222
|
+
export declare enum Status {
|
|
223
|
+
/**
|
|
224
|
+
* Indicates an access denied error, typically due to lack of permissions or authorization.
|
|
225
|
+
*/
|
|
226
|
+
AccessDeniedError = 0,
|
|
227
|
+
/**
|
|
228
|
+
* Indicates a missing token error for required scopes during authentication.
|
|
229
|
+
*/
|
|
230
|
+
MissingTokenForRequiredScopes = 1,
|
|
231
|
+
/**
|
|
232
|
+
* Indicates other miscellaneous errors not covered by specific codes.
|
|
233
|
+
*/
|
|
234
|
+
Other = 2
|
|
235
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Status = exports.ScopeName = exports.GrantTypeName = void 0;
|
|
4
|
+
var GrantTypeName;
|
|
5
|
+
(function (GrantTypeName) {
|
|
6
|
+
GrantTypeName["ACCESS_TOKEN"] = "ACCESS_TOKEN";
|
|
7
|
+
GrantTypeName["AUTH_CODE"] = "AUTH_CODE";
|
|
8
|
+
})(GrantTypeName = exports.GrantTypeName || (exports.GrantTypeName = {}));
|
|
9
|
+
/**
|
|
10
|
+
* Contains list of all possible scopes supported by Amazon Identity
|
|
11
|
+
*/
|
|
12
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
13
|
+
var ScopeName;
|
|
14
|
+
(function (ScopeName) {
|
|
15
|
+
/**
|
|
16
|
+
* Provides authorization to the user profile
|
|
17
|
+
*/
|
|
18
|
+
ScopeName["PROFILE"] = "PROFILE";
|
|
19
|
+
/**
|
|
20
|
+
* Provides authorization to the user's Amazon account ID
|
|
21
|
+
*/
|
|
22
|
+
ScopeName["USERID"] = "USERID";
|
|
23
|
+
/**
|
|
24
|
+
* Provides authorization to the user's zip/postal code
|
|
25
|
+
*/
|
|
26
|
+
ScopeName["POSTAL_CODE"] = "POSTAL_CODE";
|
|
27
|
+
/**
|
|
28
|
+
* Provides authorization to the user's Mobile number
|
|
29
|
+
*/
|
|
30
|
+
ScopeName["MOBILE_NUMBER"] = "MOBILE_NUMBER";
|
|
31
|
+
})(ScopeName = exports.ScopeName || (exports.ScopeName = {}));
|
|
32
|
+
/**
|
|
33
|
+
* Enum representing various status codes for authentication and authorization errors.
|
|
34
|
+
*/
|
|
35
|
+
var Status;
|
|
36
|
+
(function (Status) {
|
|
37
|
+
/**
|
|
38
|
+
* Indicates an access denied error, typically due to lack of permissions or authorization.
|
|
39
|
+
*/
|
|
40
|
+
Status[Status["AccessDeniedError"] = 0] = "AccessDeniedError";
|
|
41
|
+
/**
|
|
42
|
+
* Indicates a missing token error for required scopes during authentication.
|
|
43
|
+
*/
|
|
44
|
+
Status[Status["MissingTokenForRequiredScopes"] = 1] = "MissingTokenForRequiredScopes";
|
|
45
|
+
/**
|
|
46
|
+
* Indicates other miscellaneous errors not covered by specific codes.
|
|
47
|
+
*/
|
|
48
|
+
Status[Status["Other"] = 2] = "Other";
|
|
49
|
+
})(Status = exports.Status || (exports.Status = {}));
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"versions": {
|
|
3
|
+
"0.0.44": "/com.amazon.kepler.identity_lwa_lib_0@IIdentityLwaLib_0",
|
|
4
|
+
"0.0.45": "/com.amazon.kepler.identity_lwa_lib_0@IIdentityLwaLib_0",
|
|
5
|
+
"0.0.46": "/com.amazon.kepler.identity_lwa_lib_0@IIdentityLwaLib_0",
|
|
6
|
+
"0.0.47": "/com.amazon.kepler.identity_lwa_lib_0@IIdentityLwaLib_0",
|
|
7
|
+
"0.0.48": "/com.amazon.kepler.identity_lwa_lib_0@IIdentityLwaLib_0",
|
|
8
|
+
"0.0.49": "/com.amazon.kepler.identity_lwa_lib_0@IIdentityLwaLib_0",
|
|
9
|
+
"0.0.50": "/com.amazon.kepler.identity_lwa_lib_0@IIdentityLwaLib_0",
|
|
10
|
+
"0.0.51": "/com.amazon.kepler.identity_lwa_lib_0@IIdentityLwaLib_0",
|
|
11
|
+
"0.0.52": "/com.amazon.kepler.identity_lwa_lib_0@IIdentityLwaLib_0",
|
|
12
|
+
"0.0.53": "/com.amazon.kepler.identity_lwa_lib_0@IIdentityLwaLib_0",
|
|
13
|
+
"0.0.54": "/com.amazon.kepler.identity_lwa_lib_0@IIdentityLwaLib_0"
|
|
14
|
+
"0.0.55": "/com.amazon.kepler.identity_lwa_lib_0@IIdentityLwaLib_0"
|
|
15
|
+
}
|
|
16
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name": "@amazon-devices/keplerscript-identity-lwa-lib", "version": "0.0.55", "main": "dist/index.js", "types": "dist/index.d.ts", "files": ["dist", "react-native.config.js", "kepler-compatibility.json", "SystemModules", "SystemBundles", "THIRD_PARTY_NOTICES.txt", "kepler-transformed-package-info.json"], "scripts": {"clean": "rm -rf node_modules buildinfo.json dist bvm && echo 'Cleanup completed.' || echo 'Cleanup failed.'", "kepler-codegen": "keplerscript-turbomodule-api codegen src/turbo-modules/keplerLWATurboModules.ts -o kepler/turbo-modules/ --new -s keplerLWATurboModulesTurboModule && npm run clean-codegen-backups && echo 'Kepler codegen completed.' || echo 'Kepler codegen failed.'", "clean-codegen-backups": "rm -rf kepler/turbo-modules/keplerLWATurboModules.cpp.bak kepler/turbo-modules/keplerLWATurboModules.h.bak && echo 'Cleaned codegen backups.' || echo 'Failed to clean codegen backups.'", "test": "jest --colors", "lint": "eslint src tst", "lint:fix": "eslint src tst .ts,.tsx --fix", "compile": "tsc -p tsconfig-build.json", "format": "prettier --write src tst", "prepublishOnly": "KEPLER_NPM_COMMAND=npm-pretty-much react-native build-system-bundle-kepler", "generate-attribution": "generate-attribution -o ./.attr && mv .attr/attribution.txt THIRD_PARTY_NOTICES.txt && rm -rf .attr", "checkLicenses": "license-checker --production --exclude MIT,Apache-2.0,BSD-2-Clause,BSD-3-Clause,ISC,0BSD", "build": "npm-run-all lint test compile checkLicenses generate-attribution"}, "dependencies": {"@amazon-devices/keplerscript-turbomodule-api": "^1.0.0"}, "devDependencies": {"@babel/core": "^7.20.0", "@babel/runtime": "^7.20.0", "@react-native/eslint-config": "0.72.2", "@types/jest": "^28.0.0", "@typescript-eslint/eslint-plugin": "^5.30.0", "babel-jest": "^28.0.0", "eslint": "^8.12.0", "jest": "^28.0.0", "metro-react-native-babel-preset": "^0.76.5", "npm-run-all": "^4.1.5", "prettier": "^2.6.2", "ts-jest": "^28.0.0", "typescript": "4.8.4", "@amazon-devices/kepler-cli-platform": "^0", "@react-native-community/cli": "^11.2.0", "license-checker": "^25.0.1", "oss-attribution-generator": "^1.7.1"}, "kepler": {"projectType": "turbomodule", "targets": ["tv"], "features": ["vega"], "toolchain": "clang", "api": 0.1, "keplerInitializationSharedLibrary": "keplerLWATurboModules"}, "license": "See license in LICENSE"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
module.exports = {
|
|
3
|
+
dependency: {
|
|
4
|
+
platforms: {
|
|
5
|
+
kepler: {
|
|
6
|
+
"autolink": {
|
|
7
|
+
"keplerLWATurboModules": {
|
|
8
|
+
"libraryName": "libkeplerLWATurboModules.so",
|
|
9
|
+
"linkDynamic": true,
|
|
10
|
+
"components": [],
|
|
11
|
+
"turbomodules": [
|
|
12
|
+
"keplerLWATurboModules"
|
|
13
|
+
]
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|