@usemogul/connect-common 0.3.0 → 0.4.0
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/dist/index.cjs +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +9 -9
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i={ready:"mogul:ready",requestToken:"mogul:request-token",success:"mogul:success",exit:"mogul:exit",error:"mogul:error"},s={init:"mogul:init",logout:"mogul:logout"},u={tokenError:"token_error",invalidTarget:"invalid_target",clientMismatch:"client_mismatch",identityUnavailable:"identity_unavailable",originNotAllowed:"origin_not_allowed",verificationFailed:"verification_failed"},
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i={ready:"mogul:ready",requestToken:"mogul:request-token",success:"mogul:success",exit:"mogul:exit",error:"mogul:error"},s={init:"mogul:init",logout:"mogul:logout"},u={tokenError:"token_error",invalidTarget:"invalid_target",clientMismatch:"client_mismatch",identityUnavailable:"identity_unavailable",originNotAllowed:"origin_not_allowed",verificationFailed:"verification_failed"},c=t=>{if(typeof t!="object"||t===null)return;const e=t;if(typeof e.id!="string"||typeof e.name!="string"||!Array.isArray(e.accounts))return;const n=[];for(const o of e.accounts){if(typeof o!="object"||o===null)return;const r=o;if(typeof r.id!="string"||typeof r.name!="string")return;n.push({id:r.id,name:r.name})}return{id:e.id,name:e.name,accounts:n}},l=t=>{if(typeof t!="object"||t===null)return null;const e=t;switch(e.type){case"mogul:ready":case"mogul:request-token":case"mogul:exit":return{type:e.type};case"mogul:success":{const n=c(e.connectedIdentity);return typeof e.sourceId=="number"&&typeof e.accountId=="string"&&n?{type:"mogul:success",sourceId:e.sourceId,accountId:e.accountId,connectedIdentity:n}:null}case"mogul:error":return typeof e.code=="string"?{type:"mogul:error",code:e.code}:null;default:return null}},a=t=>{if(typeof t!="object"||t===null)return null;const e=t;switch(e.type){case"mogul:init":{const{token:n,clientId:o,locale:r}=e;return typeof n!="string"||n.length===0||typeof o!="string"||o.length===0?null:typeof r=="string"?{type:"mogul:init",token:n,clientId:o,locale:r}:{type:"mogul:init",token:n,clientId:o}}case"mogul:logout":return{type:"mogul:logout"};default:return null}};exports.CONNECT_ERROR_CODE=u;exports.FRAME_EVENT=i;exports.PARENT_EVENT=s;exports.parseFrameMessage=l;exports.parseParentMessage=a;
|
package/dist/index.d.cts
CHANGED
|
@@ -10,7 +10,7 @@ export declare const CONNECT_ERROR_CODE: {
|
|
|
10
10
|
*/
|
|
11
11
|
readonly clientMismatch: "client_mismatch";
|
|
12
12
|
/**
|
|
13
|
-
* Frame: the connection succeeded, but the
|
|
13
|
+
* Frame: the connection succeeded, but the source ID or a complete
|
|
14
14
|
* identity couldn't be resolved, so no `mogul:success` is sent.
|
|
15
15
|
*/
|
|
16
16
|
readonly identityUnavailable: "identity_unavailable";
|
|
@@ -66,8 +66,8 @@ export declare type FrameMessage = {
|
|
|
66
66
|
* Otherwise the frame sends `mogul:error` `identity_unavailable` instead.
|
|
67
67
|
*/
|
|
68
68
|
type: 'mogul:success';
|
|
69
|
-
/** The
|
|
70
|
-
|
|
69
|
+
/** The connected source. Used for royalty-report API calls. */
|
|
70
|
+
sourceId: number;
|
|
71
71
|
/** Mogul account the integration belongs to (from the session token). */
|
|
72
72
|
accountId: string;
|
|
73
73
|
/** Identity parsed from the connected integration. */
|
package/dist/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export declare const CONNECT_ERROR_CODE: {
|
|
|
10
10
|
*/
|
|
11
11
|
readonly clientMismatch: "client_mismatch";
|
|
12
12
|
/**
|
|
13
|
-
* Frame: the connection succeeded, but the
|
|
13
|
+
* Frame: the connection succeeded, but the source ID or a complete
|
|
14
14
|
* identity couldn't be resolved, so no `mogul:success` is sent.
|
|
15
15
|
*/
|
|
16
16
|
readonly identityUnavailable: "identity_unavailable";
|
|
@@ -66,8 +66,8 @@ export declare type FrameMessage = {
|
|
|
66
66
|
* Otherwise the frame sends `mogul:error` `identity_unavailable` instead.
|
|
67
67
|
*/
|
|
68
68
|
type: 'mogul:success';
|
|
69
|
-
/** The
|
|
70
|
-
|
|
69
|
+
/** The connected source. Used for royalty-report API calls. */
|
|
70
|
+
sourceId: number;
|
|
71
71
|
/** Mogul account the integration belongs to (from the session token). */
|
|
72
72
|
accountId: string;
|
|
73
73
|
/** Identity parsed from the connected integration. */
|
package/dist/index.js
CHANGED
|
@@ -4,10 +4,10 @@ const u = {
|
|
|
4
4
|
success: "mogul:success",
|
|
5
5
|
exit: "mogul:exit",
|
|
6
6
|
error: "mogul:error"
|
|
7
|
-
},
|
|
7
|
+
}, c = {
|
|
8
8
|
init: "mogul:init",
|
|
9
9
|
logout: "mogul:logout"
|
|
10
|
-
},
|
|
10
|
+
}, s = {
|
|
11
11
|
/** Loader: the partner's `getToken()` threw. */
|
|
12
12
|
tokenError: "token_error",
|
|
13
13
|
/** Frame: the preselected `/embed/connect/<target>` isn't a known source. */
|
|
@@ -18,7 +18,7 @@ const u = {
|
|
|
18
18
|
*/
|
|
19
19
|
clientMismatch: "client_mismatch",
|
|
20
20
|
/**
|
|
21
|
-
* Frame: the connection succeeded, but the
|
|
21
|
+
* Frame: the connection succeeded, but the source ID or a complete
|
|
22
22
|
* identity couldn't be resolved, so no `mogul:success` is sent.
|
|
23
23
|
*/
|
|
24
24
|
identityUnavailable: "identity_unavailable",
|
|
@@ -46,7 +46,7 @@ const u = {
|
|
|
46
46
|
n.push({ id: r.id, name: r.name });
|
|
47
47
|
}
|
|
48
48
|
return { id: e.id, name: e.name, accounts: n };
|
|
49
|
-
},
|
|
49
|
+
}, l = (t) => {
|
|
50
50
|
if (typeof t != "object" || t === null) return null;
|
|
51
51
|
const e = t;
|
|
52
52
|
switch (e.type) {
|
|
@@ -58,9 +58,9 @@ const u = {
|
|
|
58
58
|
const n = i(
|
|
59
59
|
e.connectedIdentity
|
|
60
60
|
);
|
|
61
|
-
return typeof e.
|
|
61
|
+
return typeof e.sourceId == "number" && typeof e.accountId == "string" && n ? {
|
|
62
62
|
type: "mogul:success",
|
|
63
|
-
|
|
63
|
+
sourceId: e.sourceId,
|
|
64
64
|
accountId: e.accountId,
|
|
65
65
|
connectedIdentity: n
|
|
66
66
|
} : null;
|
|
@@ -85,9 +85,9 @@ const u = {
|
|
|
85
85
|
}
|
|
86
86
|
};
|
|
87
87
|
export {
|
|
88
|
-
|
|
88
|
+
s as CONNECT_ERROR_CODE,
|
|
89
89
|
u as FRAME_EVENT,
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
c as PARENT_EVENT,
|
|
91
|
+
l as parseFrameMessage,
|
|
92
92
|
a as parseParentMessage
|
|
93
93
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usemogul/connect-common",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Shared schemas for the Mogul Connect embedded component: message types, event-name constants, and validators shared by the connect-js loader and the Mogul application.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "shawn@usemogul.com",
|