1+
2+ export class IMSInterface {
3+ /**
4+ * Establishes an IMS session. Must be called before any IMS access methods.
5+ * This method is not thread safe.
6+ *
7+ * @return An IMS reference string, as returned from IMSLib, which you
8+ * can then use to make further IMS calls to this object's methods.
9+ *
10+ * @deprecated Please use imsConnectWithEndpoint instead.
11+ */
12+ imsConnect ( ) : string {
13+ return window . __adobe_cep__ . imsConnect ( ) ;
14+ }
15+
16+ imsDisconnect ( imsRef : string ) : void {
17+ window . __adobe_cep__ . imsDisconnect ( imsRef ) ;
18+ }
19+
20+ imsConnectWithEndpoint ( imsEndpoint ?: string ) : string {
21+ return JSON . parse ( window . __adobe_cep__ . invokeSync ( "imsConnectWithEndpoint" , JSON . stringify ( { imsEndpoint : imsEndpoint } ) ) ) . result
22+ }
23+
24+ imsFetchAccounts ( imsRef : string , clientId : string ) : string {
25+ return window . __adobe_cep__ . imsFetchAccounts ( imsRef , clientId ) ;
26+ }
27+
28+ imsFetchUserProfileData ( imsRef : string , userAccountGuid : string ) : string {
29+ const data = {
30+ imsRef : imsRef ,
31+ userAccountGuid : userAccountGuid
32+ } ;
33+ return window . __adobe_cep__ . invokeSync ( "imsFetchUserProfileData" , JSON . stringify ( data ) )
34+ }
35+
36+ /**
37+ * Requests an access token from IMS for a given user and service.
38+ *
39+ * This function is asynchronous. To handle the result, register a callback for the event
40+ * "com.adobe.csxs.events.internal.ims.FetchAccessToken" or "com.adobe.csxs.events.internal.ims.FetchAccessTokenWithStatus".
41+ * For event "com.adobe.csxs.events.internal.ims.FetchAccessToken", the event data is a JSON string
42+ * with format {"toua":"...",...,"emailVerified":"false"}.
43+ * For event "com.adobe.csxs.events.internal.ims.FetchAccessTokenWithStatus", the event data is a JSON string
44+ * with format {"status":"0","details":{"toua":"...",...,"emailVerified":"false"}}.
45+ *
46+ * @see addEventListener()
47+ *
48+ * @param imsRef An IMS reference returned from the \c IMSConnect() call.
49+ * @param clientId The IMS client ID for your extension, assigned by the IMS team on registration.
50+ * This is the service-code value in the Renga Service Account Object for your client.
51+ * @param clientSecret The client secret associated with the provided client ID
52+ * @param userAccountGuid The unique person GUID for the Renga account, as returned by the <code>fetchAccounts()</code> method. The token is generated for this user.
53+ * @param serviceAccountGuid (optional, not currently used) A unique identifier for a Service Account Object (SAO).
54+ * @param scope (optional) A comma delimited list of services for which the refresh and access tokens are requested.
55+ *
56+ * By default, this is 'openid,AdobeID'. Scope strings are case sensitive.
57+ * If the cached version of the refresh token does not match the requested service scopes, a new refresh token is fetched.
58+ * To request your service's own SAO, add your service to the list;
59+ * for example, 'openid,AdobeID,browserlab'.
60+ *
61+ * @return A boolean status. Returning true means only the call to imsFetchAccessToken function itself is successful.
62+ * Returning false means that failed to fetch access token.
63+ */
64+ imsFetchAccessToken ( imsRef : string , clientId : string , clientSecret : string , userAccountGuid : string , serviceAccountGuid ?: string , scope ?: string ) : boolean {
65+ return window . __adobe_cep__ . imsFetchAccessToken ( imsRef , clientId , clientSecret , userAccountGuid , serviceAccountGuid , scope ) ;
66+ }
67+
68+ imsFetchContinueToken ( imsRef : any , bearerToken : string , targetClientId : string , redirectUri ?: string , scope ?: string , responseType ?: string , locale ?: string ) : string {
69+ const data = {
70+ imsRef : imsRef ,
71+ bearerToken : bearerToken ,
72+ targetClientId : targetClientId ,
73+ redirectUri : redirectUri ,
74+ scope : scope ,
75+ responseType : responseType ,
76+ locale : locale
77+ } ;
78+
79+ return JSON . parse ( window . __adobe_cep__ . invokeSync ( "imsFetchContinueToken" , JSON . stringify ( data ) ) ) . result ;
80+ }
81+
82+ imsRevokeDeviceToken ( imsRef : string , clientId : string , clientSecret : string , userAccountGuid : string , serviceAccountGuid ?: string ) : boolean {
83+ return window . __adobe_cep__ . imsFetchAccessToken ( imsRef , clientId , clientSecret , userAccountGuid , serviceAccountGuid , "REVOKE" ) ;
84+ }
85+
86+ imsSetProxyCredentials ( proxyUsername : string , proxyPassword : string ) : void {
87+ window . __adobe_cep__ . imsSetProxyCredentials ( proxyUsername , proxyPassword ) ;
88+ }
89+
90+ showAAM ( clientId : string , clientSecret : string , redirectUri : string , userAccountGuid : string , serviceAccountGuid : string , scope : string ) : Boolean {
91+ return window . __adobe_cep__ . showAAM ( clientId , clientSecret , redirectUri , userAccountGuid , serviceAccountGuid , scope )
92+ }
93+
94+ imsGetCurrentUserId ( ) : object {
95+ return window . __adobe_cep__ . getCurrentImsUserId ( ) ;
96+ }
97+
98+ imsGetCurrentUserIdHelper ( callback : Function ) : void {
99+ const hostEnvironment = JSON . parse ( window . __adobe_cep__ . getHostEnvironment ( ) ) ;
100+ const appName = hostEnvironment . appName ;
101+
102+ if ( "ILST" === appName ) {
103+ window . __adobe_cep__ . evalScript ( "app.userGUID" , function ( result : any ) {
104+ callback ( result ) ;
105+ } ) ;
106+ } else if ( "IDSN" === appName ) {
107+ window . __adobe_cep__ . evalScript ( "app.userGuid" , function ( result : any ) {
108+ callback ( result ) ;
109+ } ) ;
110+ } else if ( "PHSP" === appName || "PHXS" === appName ) {
111+ window . __adobe_cep__ . evalScript ( "var getUserIdPhotoshop = function() {var userId = '';try {var bhnc = app.charIDToTypeID('bhnc');var ref = new ActionReference();ref.putProperty(app.charIDToTypeID('Prpr'), bhnc);ref.putEnumerated(app.charIDToTypeID('capp'), app.charIDToTypeID('Ordn'), app.charIDToTypeID('Trgt'));var appDesc = app.executeActionGet(ref);if (appDesc.hasKey(bhnc)) {userId = appDesc.getString(bhnc);}} catch (e) {}return userId;};" , function ( result : any ) {
112+ window . __adobe_cep__ . evalScript ( "getUserIdPhotoshop()" , function ( result : any ) {
113+ callback ( result ) ;
114+ } )
115+ } ) ;
116+ } else {
117+ const clientId = window . __adobe_cep__ . getCurrentImsUserId ( ) ;
118+ callback ( clientId )
119+ }
120+ }
121+
122+ imsLogoutUser ( imsRef : string , userAccountGuid : string , clientId : string ) : object {
123+ const data = {
124+ imsRef : imsRef ,
125+ userAccountGuid : userAccountGuid ,
126+ clientId : clientId
127+ } ;
128+ return JSON . parse ( window . __adobe_cep__ . invokeSync ( "imsLogoutUser" , JSON . stringify ( data ) ) ) . result
129+ }
130+
131+ imsAttemptSSOJumpWorkflows ( openBrowser : boolean , url : string , imsRef : string , clientId ?: string , clientSecret ?: string , scope ?: string , userAccountGuid ?: string , targetClientId ?: string , targetScope ?: string , targetResponseType ?: string , targetLocale ?: string ) {
132+ const data = {
133+ openBrowser : openBrowser ,
134+ url : url ,
135+ imsRef : imsRef ,
136+ clientId : clientId ,
137+ clientSecret : clientSecret ,
138+ scope : scope ,
139+ userAccountGuid : userAccountGuid ,
140+ targetClientId : targetClientId ,
141+ targetScope : targetScope ,
142+ targetResponseType : targetResponseType ,
143+ targetLocale : targetLocale
144+ } ;
145+ return JSON . parse ( window . __adobe_cep__ . invokeSync ( "imsAttemptSSOJumpWorkflows" , JSON . stringify ( data ) ) ) . result
146+ }
147+ }
148+
149+ export namespace IMSInterface {
150+ export enum Events {
151+ imsFetchAccessTokenWithStatus = "com.adobe.csxs.events.internal.ims.FetchAccessTokenWithStatus" ,
152+ imsFetchAccessToken = "com.adobe.csxs.events.internal.ims.FetchAccessToken" ,
153+ imsRevokeAccessToken = "com.adobe.csxs.events.internal.ims.FetchAccessTokenWithStatus" ,
154+ imsFetchContinueToken = "com.adobe.csxs.events.internal.ims.FetchAccessTokenWithStatus" ,
155+ imsAAMIMSStatus = "vulcan.SuiteMessage.com.adobe.aam.AAMIMSStatus" ,
156+ imsLogoutUser = "com.adobe.csxs.events.internal.ims.LogoutUser" ,
157+ imsSSOStatus = "com.adobe.csxs.events.internal.ims.SSOStatus"
158+ }
159+
160+ export enum Status {
161+ IMS_SUCCESS = "0" ,
162+ IMS_ERROR_FAILURE = "1" ,
163+ IMS_ERROR_INVALID_ARGUMENTS = "2" ,
164+ IMS_ERROR_CANCEL = "20" ,
165+ IMS_ERROR_TIMEOUT = "21" ,
166+ IMS_ERROR_HTTPFAILURE = "22" ,
167+ IMS_ERROR_SSLFAILURE = "23" ,
168+ IMS_ERROR_AUTH_PROXY_REQUIRED = "24" ,
169+ IMS_ERROR_AUTH_PROXY_FAILED = "25" ,
170+ IMS_ERROR_IN_ACCESS_IDP = "26" ,
171+ IMS_ERROR_ANOTHER_REQUEST_IN_PROCESS = "40" ,
172+ IMS_ERROR_IN_READ_USER_DATA = "60" ,
173+ IMS_ERROR_IN_SAVE_USER_DATA = "61" ,
174+ IMS_ERROR_IN_REMOVE_USER_DATA = "62" ,
175+ IMS_ERROR_USER_DATA_NOT_PRESENT = "63" ,
176+ IMS_ERROR_IN_READ_DEVICE_TOKEN = "64" ,
177+ IMS_ERROR_IN_SAVE_DEVICE_TOKEN = "65" ,
178+ IMS_ERROR_IN_REMOVE_DEVICE_TOKEN = "66" ,
179+ IMS_ERROR_DEVICE_TOKEN_NOT_PRESENT = "67" ,
180+ IMS_ERROR_INVALID_DEVICE_TOKEN = "68" ,
181+ IMS_ERROR_CLIENTID_NOT_PRESENT = "69" ,
182+ IMS_ERROR_IN_FETCH_USER_ACCOUNTS = "70" ,
183+ IMS_ERROR_IN_SAVE_USER_FOR_CLIENTID = "71" ,
184+ IMS_ERROR_DEVICE_ID_NOT_PRESENT = "72" ,
185+ IMS_ERROR_DEFAULT_USER_FOR_CLIENTID_NOT_PRESENT = "73" ,
186+ IMS_ERROR_NO_USER_RECORDS_PRESENT = "74" ,
187+ IMS_ERROR_ACCESS_DENIED = "80" ,
188+ IMS_ERROR_INVALID_REQUEST = "81" ,
189+ IMS_ERROR_INVALID_CLIENT = "82" ,
190+ IMS_ERROR_INVALID_GRANT = "83" ,
191+ IMS_ERROR_UNAUTHORIZED_CLIENT = "84" ,
192+ IMS_ERROR_UNSUPPORTED_RESPONSE_TYPE = "85" ,
193+ IMS_ERROR_INVALID_SCOPE = "86" ,
194+ IMS_ERROR_UNSUPPORTED_GRANT_TYPE = "87" ,
195+ IMS_ERROR_BAD_REQUEST = "88" ,
196+ IMS_ERROR_INVALID_CREDENTIALS = "89" ,
197+ IMS_ERROR_IN_GET_AUTH_DATA_FROM_IDP = "100" ,
198+ IMS_ERROR_IN_GET_DEVICE_TOKEN_FROM_IDP = "101" ,
199+ IMS_ERROR_IN_GET_REFRESH_TOKEN_FROM_IDP = "102" ,
200+ IMS_ERROR_IN_GET_ACCESS_TOKEN_FROM_IDP = "103" ,
201+ IMS_ERROR_IN_GET_PROFILE_DATA_FROM_IDP = "104" ,
202+ IMS_ERROR_TOU_CHANGED = "120" ,
203+ IMS_ERROR_IN_REVOKE_DEVICE_TOKEN = "121" ,
204+ IMS_ERROR_TOU_NOT_CURRENT = "122" ,
205+ IMS_ERROR_EVS_INVALID = "123" ,
206+ IMS_ERROR_ACCT_ACT_REQ = "124" ,
207+ IMS_ERROR_ACCT_DISABLED = "125" ,
208+ IMS_ERROR_SUBS_ACT_REQ = "126" ,
209+ IMS_ERROR_SUBS_NO_SUB = "127" ,
210+ IMS_ERROR_NO_BUDDY_GROUP_FOR_CLIENT = "150" ,
211+ IMS_ERROR_CLIENT_REGISTERED_FOR_OTHER_GROUP = "151" ,
212+ IMS_ERROR_GROUP_ENTRY_NOT_PRESENT = "152" ,
213+ IMS_ERROR_IN_SAVE_GROUP_DATA = "153" ,
214+ IMS_ERROR_CNAME_ENTRY_NOT_PRESENT = "154" ,
215+ IMS_ERROR_IN_SAVE_BACKOFF_DATA = "155" ,
216+ IMSMANAGER_ERROR_EXCEPTION = "3000" ,
217+ IMSMANAGER_ERROR_ENCODING = "3001" ,
218+ IMSMANAGER_SUCCESS_BROWSER_OPENED = "3002" ,
219+ IMSMANAGER_ERROR_BROWSER_FAILED_TO_OPEN = "3003" ,
220+ IMS_UNKNOWN_ERROR = "0xFFFF"
221+ }
222+ }
0 commit comments