intuit-embedded-widget-sdk 2.3.0 → 2.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/package.json +4 -1
- package/.eslintrc.yml +0 -18
- package/.github/CODEOWNERS +0 -4
- package/.github/pull_request_template.md +0 -11
- package/CHANGELOG.md +0 -67
- package/COMMUNITY.md +0 -3
- package/CONTRIBUTING.md +0 -8
- package/GETTINGSTARTED.md +0 -3
- package/Jenkinsfile +0 -156
- package/babel.config.js +0 -15
- package/codecov.yml +0 -11
- package/jest.config.js +0 -27
- package/jest.setup.js +0 -9
- package/renovate.json +0 -6
- package/rollup.config.js +0 -38
- package/src/IntuitEmbeddedSDK.ts +0 -201
- package/src/__tests__/EmbeddedChild.test.ts +0 -330
- package/src/authorizationModule/Authorization.ts +0 -152
- package/src/authorizationModule/types.ts +0 -14
- package/src/index.ts +0 -6
- package/src/messagingModule/Messaging.ts +0 -196
- package/src/messagingModule/messagingUtils.ts +0 -57
- package/src/messagingModule/types.ts +0 -50
- package/src/telemetryModule/Telemetry.ts +0 -236
- package/src/telemetryModule/types.ts +0 -72
- package/tsconfig.json +0 -25
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "intuit-embedded-widget-sdk",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.4.0",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"browser": "dist/index.iife.js",
|
|
@@ -30,6 +30,9 @@
|
|
|
30
30
|
"publishConfig": {
|
|
31
31
|
"registry": "https://registry.npmjs.intuit.com/"
|
|
32
32
|
},
|
|
33
|
+
"files": [
|
|
34
|
+
"dist"
|
|
35
|
+
],
|
|
33
36
|
"dependencies": {},
|
|
34
37
|
"devDependencies": {
|
|
35
38
|
"@auto-it/git-tag": "^10.24.1",
|
package/.eslintrc.yml
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
env:
|
|
2
|
-
browser: true
|
|
3
|
-
es2020: true
|
|
4
|
-
amd: true
|
|
5
|
-
node: true
|
|
6
|
-
jest: true
|
|
7
|
-
extends:
|
|
8
|
-
- 'eslint:recommended'
|
|
9
|
-
parserOptions:
|
|
10
|
-
ecmaFeatures:
|
|
11
|
-
jsx: true
|
|
12
|
-
ecmaVersion: 11
|
|
13
|
-
sourceType: module
|
|
14
|
-
plugins:
|
|
15
|
-
- react
|
|
16
|
-
rules: {
|
|
17
|
-
"semi": ["error", "always"]
|
|
18
|
-
}
|
package/.github/CODEOWNERS
DELETED
package/CHANGELOG.md
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
# v2.3.0 (Fri Feb 13 2026)
|
|
2
|
-
|
|
3
|
-
#### 🚀 Enhancement
|
|
4
|
-
|
|
5
|
-
- feat: refactor sdk - INTX-5124 [#6](https://github.intuit.com/IntX/embedded-widget-sdk/pull/6) ([@npangarkar](https://github.intuit.com/npangarkar))
|
|
6
|
-
|
|
7
|
-
#### Authors: 1
|
|
8
|
-
|
|
9
|
-
- npangarkar ([@npangarkar](https://github.intuit.com/npangarkar))
|
|
10
|
-
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
# v2.2.0 (Tue Feb 10 2026)
|
|
14
|
-
|
|
15
|
-
#### 🚀 Enhancement
|
|
16
|
-
|
|
17
|
-
- feat: add IIFE build output via Rollup - INTX-5124 [#5](https://github.intuit.com/IntX/embedded-widget-sdk/pull/5) ([@npangarkar](https://github.intuit.com/npangarkar))
|
|
18
|
-
|
|
19
|
-
#### Authors: 1
|
|
20
|
-
|
|
21
|
-
- npangarkar ([@npangarkar](https://github.intuit.com/npangarkar))
|
|
22
|
-
|
|
23
|
-
---
|
|
24
|
-
|
|
25
|
-
# v2.1.0 (Tue Feb 10 2026)
|
|
26
|
-
|
|
27
|
-
#### 🚀 Enhancement
|
|
28
|
-
|
|
29
|
-
- feat: add type declarations - INTX-5124 [#4](https://github.intuit.com/IntX/embedded-widget-sdk/pull/4) ([@npangarkar](https://github.intuit.com/npangarkar))
|
|
30
|
-
|
|
31
|
-
#### Authors: 1
|
|
32
|
-
|
|
33
|
-
- npangarkar ([@npangarkar](https://github.intuit.com/npangarkar))
|
|
34
|
-
|
|
35
|
-
---
|
|
36
|
-
|
|
37
|
-
# v2.0.0 (Mon Feb 09 2026)
|
|
38
|
-
|
|
39
|
-
#### 💥 Breaking Change
|
|
40
|
-
|
|
41
|
-
- feat: add EmbeddedChild - INTX-5124 [#2](https://github.intuit.com/IntX/embedded-widget-sdk/pull/2) ([@npangarkar](https://github.intuit.com/npangarkar))
|
|
42
|
-
|
|
43
|
-
#### 🚀 Enhancement
|
|
44
|
-
|
|
45
|
-
- feat: Update README.md - INTX-5124 [#3](https://github.intuit.com/IntX/embedded-widget-sdk/pull/3) ([@npangarkar](https://github.intuit.com/npangarkar))
|
|
46
|
-
|
|
47
|
-
#### Authors: 1
|
|
48
|
-
|
|
49
|
-
- npangarkar ([@npangarkar](https://github.intuit.com/npangarkar))
|
|
50
|
-
|
|
51
|
-
---
|
|
52
|
-
|
|
53
|
-
# v1.0.1 (Wed Feb 04 2026)
|
|
54
|
-
|
|
55
|
-
#### ⚠️ Pushed to `master`
|
|
56
|
-
|
|
57
|
-
- MSAASINT-6891: Automated Changes, to NPM Library Template by msaas-services-paved-road (svcdoaadmin)
|
|
58
|
-
- Initial commit (svcdoaadmin)
|
|
59
|
-
|
|
60
|
-
#### Authors: 1
|
|
61
|
-
|
|
62
|
-
- svcdoaadmin ([@svcdoaadmin](https://github.intuit.com/svcdoaadmin))
|
|
63
|
-
|
|
64
|
-
---
|
|
65
|
-
|
|
66
|
-
# Change Log
|
|
67
|
-
All notable changes to this project will be documented in this file.
|
package/COMMUNITY.md
DELETED
package/CONTRIBUTING.md
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
# [CONTRIBUTING Reference](https://github.intuit.com/pages/dev-patterns/Intuit-InnerSource/adoption/readiness/#contributingmd)
|
|
2
|
-
|
|
3
|
-
| Section | Required actions and specifications |
|
|
4
|
-
| ------------------------ |-------------------------------------|
|
|
5
|
-
| Before creating PR | <ul><li>What pre-work is necessary to contribute a feature or bugfix? Filing an issue in a tracker, design discussions, architecture decision records etc.</li><li>What is the expected turnaround time for reviewing a feature proposal?</li></ul> |
|
|
6
|
-
| Process for merging a PR | <ul><li>Who will review code and help get PRs merged? Consider link to CODEOWNERS file, list of trusted committers and maintainers.</li><li>What is the SLA -- expected turnaround time -- for reviewing PRs and new commits to existing PRs?</li><li>What is the Git branching strategy, should branch names follow a format including issue number?</li><li>Documentation and changelog requirements</li><li>Git commit message expectations</li><li>Code Style expectations</li><li>Required tests, expected testing strategy and coverage</li><li>Design activities and artifacts that should be included in the PR</li></ul>|
|
|
7
|
-
| After PR merged | <ul><li>What happens after the code is merged?</li><li>Are there ownership expectations in preprod/prod for a period of time?</li><li>When can a contributor expect to see merged code built and deployed to preprod and prod?</li><li>How can a contributor validate their code changes after changes have been deployed?</li></ul> |
|
|
8
|
-
| Contact information | <ul><li>Who are the maintainers? Consider linking to the [.github/CODEOWNERS](.github/CODEOWNERS)</li><li>How to contact for support? Consider linking to the [README.md support section](./README.md#support).</li></ul> |
|
package/GETTINGSTARTED.md
DELETED
package/Jenkinsfile
DELETED
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
def dockerHostName = 'docker.intuit.com'
|
|
4
|
-
def assetId = "3465537506594279808"
|
|
5
|
-
def failureEmail = "some_email@intuit.com"
|
|
6
|
-
def nodeImage = 'node:20'
|
|
7
|
-
def releaseBranch = 'master'
|
|
8
|
-
def skipCI = false
|
|
9
|
-
def config = [:]
|
|
10
|
-
node {
|
|
11
|
-
config["assetId"] = '3465537506594279808'
|
|
12
|
-
config["assetAlias"] = "Intuit.intx.embeddedwidgetsdk"
|
|
13
|
-
config["artifactoryCredentialsId"] = "artifactory-embedded-widget-sdk"
|
|
14
|
-
config["githubCredentialsId"] = "github-svc-sbseg-ci"
|
|
15
|
-
config["applicationName"] = 'embedded-widget-sdk'
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
pipeline {
|
|
19
|
-
agent {
|
|
20
|
-
kubernetes {
|
|
21
|
-
// Use a dynamic pod name because static labels are known to cause pod creation errors.
|
|
22
|
-
label "node-pod-${UUID.randomUUID().toString()}"
|
|
23
|
-
defaultContainer "nodejs"
|
|
24
|
-
yaml """
|
|
25
|
-
apiVersion: v1
|
|
26
|
-
kind: Pod
|
|
27
|
-
spec:
|
|
28
|
-
containers:
|
|
29
|
-
- name: nodejs
|
|
30
|
-
image: '${dockerHostName}/${nodeImage}'
|
|
31
|
-
command:
|
|
32
|
-
- cat
|
|
33
|
-
tty: true
|
|
34
|
-
"""
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
options {
|
|
38
|
-
timestamps()
|
|
39
|
-
buildDiscarder(logRotator(daysToKeepStr: '30', numToKeepStr: '50', artifactNumToKeepStr: '30'))
|
|
40
|
-
}
|
|
41
|
-
environment {
|
|
42
|
-
BUILD_URL = "${env.BUILD_URL}"
|
|
43
|
-
NPM_DEVPROD_REF_CREDENTIAL = credentials("${config.artifactoryCredentialsId}")
|
|
44
|
-
NPM_USER = "${env.NPM_DEVPROD_REF_CREDENTIAL_USR}"
|
|
45
|
-
NPM_TOKEN = "${env.NPM_DEVPROD_REF_CREDENTIAL_PSW}"
|
|
46
|
-
PATH = "node_modules/.bin/:$PATH"
|
|
47
|
-
|
|
48
|
-
/* Git */
|
|
49
|
-
GH = credentials("${config.githubCredentialsId}") // Update this accordingly to use github creds available on your jenkins node
|
|
50
|
-
GH_USER = "${env.GH_USR}"
|
|
51
|
-
GH_TOKEN = "${env.GH_PSW}"
|
|
52
|
-
GH_EMAIL = "some_email@intuit.com"
|
|
53
|
-
}
|
|
54
|
-
stages {
|
|
55
|
-
stage('Check Skip CI') {
|
|
56
|
-
steps {
|
|
57
|
-
script {
|
|
58
|
-
def isTriggeredByTimer = !currentBuild.getBuildCauses('hudson.triggers.TimerTrigger$TimerTriggerCause').isEmpty()
|
|
59
|
-
def isTriggeredByUser = !currentBuild.getBuildCauses('hudson.model.Cause$UserIdCause').isEmpty()
|
|
60
|
-
|
|
61
|
-
checkout([
|
|
62
|
-
$class: 'GitSCM',
|
|
63
|
-
branches: scm.branches,
|
|
64
|
-
extensions: scm.extensions + [[$class: 'CleanCheckout'], [$class: 'CleanBeforeCheckout'], [$class: 'LocalBranch'], [$class: 'CloneOption', noTags: false]],
|
|
65
|
-
userRemoteConfigs: scm.userRemoteConfigs
|
|
66
|
-
])
|
|
67
|
-
sh script: "git config --global --add safe.directory ${env.WORKSPACE}", label: "add safe.directory for git"
|
|
68
|
-
result = sh (script: "git log -1 | grep '.*\\[skip ci\\].*'", returnStatus: true)
|
|
69
|
-
if (result == 0 && !isTriggeredByTimer && !isTriggeredByUser) {
|
|
70
|
-
echo ("'skip ci' spotted in git commit. Aborting.")
|
|
71
|
-
currentBuild.result = 'SUCCESS'
|
|
72
|
-
skipCI = true
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
stage('Run CI') {
|
|
78
|
-
when {
|
|
79
|
-
expression { return skipCI != true }
|
|
80
|
-
}
|
|
81
|
-
stages {
|
|
82
|
-
stage('Auth') {
|
|
83
|
-
steps {
|
|
84
|
-
sh '''
|
|
85
|
-
git config --global user.name "${GH_USER}"
|
|
86
|
-
git config --global user.email "${GH_EMAIL}"
|
|
87
|
-
'''
|
|
88
|
-
sh "echo '//registry.npmjs.intuit.com/:_authToken=${NPM_TOKEN}' >> ~/.npmrc"
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
stage('Install') {
|
|
92
|
-
steps {
|
|
93
|
-
sh 'yarn install --frozen-lockfile'
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
stage('Build') {
|
|
97
|
-
steps {
|
|
98
|
-
sh 'yarn build:prod'
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
stage('Test') {
|
|
102
|
-
failFast true
|
|
103
|
-
parallel {
|
|
104
|
-
stage('PR Version Check') {
|
|
105
|
-
when { changeRequest() }
|
|
106
|
-
steps {
|
|
107
|
-
sh "GIT_LOCAL_BRANCH=$CHANGE_BRANCH && auto pr-check --pr $CHANGE_ID --url $BUILD_URL"
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
stage('Unit Tests') {
|
|
111
|
-
steps {
|
|
112
|
-
sh 'yarn test'
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
stage('Lint') {
|
|
116
|
-
steps {
|
|
117
|
-
sh 'yarn lint'
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
post {
|
|
122
|
-
always {
|
|
123
|
-
junit '**/target/surefire-reports/*.xml'
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
stage('NPM Release') {
|
|
128
|
-
steps {
|
|
129
|
-
sh script: "git config --global --add safe.directory ${env.WORKSPACE}", label: "re-add safe.directory to git"
|
|
130
|
-
sh "auto shipit"
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
post {
|
|
137
|
-
success {
|
|
138
|
-
library 'msaas-shared-lib'
|
|
139
|
-
script {
|
|
140
|
-
if (env.BRANCH_NAME == releaseBranch) {
|
|
141
|
-
config["envName"] = "prd"
|
|
142
|
-
} else {
|
|
143
|
-
config["envName"] = "qal"
|
|
144
|
-
}
|
|
145
|
-
config["version"] = sh(returnStdout: true, script: "grep 'version' package.json | cut -d '\"' -f4 | tr '\\n' '\\0'")
|
|
146
|
-
customReleaseMetrics(config)
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
failure {
|
|
150
|
-
echo "Pipeline Failure"
|
|
151
|
-
mail to: "${failureEmail}",
|
|
152
|
-
subject: "Failed Pipeline: ${currentBuild.fullDisplayName}",
|
|
153
|
-
body: "Something is wrong in ${env.BUILD_URL}"
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
package/babel.config.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
presets: [
|
|
3
|
-
['@babel/preset-env', {
|
|
4
|
-
targets: {
|
|
5
|
-
node: 'current'
|
|
6
|
-
},
|
|
7
|
-
modules: false // Output ES modules for browser compatibility
|
|
8
|
-
}],
|
|
9
|
-
'@babel/preset-typescript'
|
|
10
|
-
],
|
|
11
|
-
plugins: [
|
|
12
|
-
['add-import-extension', { extension: 'js' }]
|
|
13
|
-
]
|
|
14
|
-
};
|
|
15
|
-
|
package/codecov.yml
DELETED
package/jest.config.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
testEnvironment: 'jsdom',
|
|
3
|
-
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
|
|
4
|
-
roots: ['<rootDir>/src/'],
|
|
5
|
-
testMatch: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'],
|
|
6
|
-
testPathIgnorePatterns: ['/node_modules/', '/dist/'],
|
|
7
|
-
moduleFileExtensions: ['js', 'jsx', 'json', 'ts', 'tsx'],
|
|
8
|
-
transform: {
|
|
9
|
-
'^.+\\.(ts|tsx)$': 'ts-jest',
|
|
10
|
-
'^.+\\.(js|jsx)$': ['babel-jest', { rootMode: 'upward' }]
|
|
11
|
-
},
|
|
12
|
-
moduleNameMapper: {
|
|
13
|
-
'^(\\.{1,2}/.*)\\.js$': '$1',
|
|
14
|
-
'\\.(css|md)$': 'identity-obj-proxy'
|
|
15
|
-
},
|
|
16
|
-
coverageDirectory: '<rootDir>/coverage/',
|
|
17
|
-
collectCoverageFrom: [
|
|
18
|
-
'src/**/*.{js,jsx,ts,tsx}',
|
|
19
|
-
'!src/**/__tests__/**',
|
|
20
|
-
'!src/**/*.d.ts'
|
|
21
|
-
],
|
|
22
|
-
reporters: [
|
|
23
|
-
'default',
|
|
24
|
-
'jest-junit'
|
|
25
|
-
],
|
|
26
|
-
verbose: true
|
|
27
|
-
};
|
package/jest.setup.js
DELETED
package/renovate.json
DELETED
package/rollup.config.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
const typescript = require('@rollup/plugin-typescript');
|
|
2
|
-
const resolve = require('@rollup/plugin-node-resolve');
|
|
3
|
-
const commonjs = require('@rollup/plugin-commonjs');
|
|
4
|
-
const terser = require('@rollup/plugin-terser');
|
|
5
|
-
|
|
6
|
-
module.exports = {
|
|
7
|
-
input: 'src/index.ts',
|
|
8
|
-
output: {
|
|
9
|
-
file: 'dist/iife/index.js',
|
|
10
|
-
format: 'iife',
|
|
11
|
-
name: 'IntuitEmbeddedSDK',
|
|
12
|
-
sourcemap: true,
|
|
13
|
-
exports: 'named',
|
|
14
|
-
globals: {},
|
|
15
|
-
},
|
|
16
|
-
plugins: [
|
|
17
|
-
resolve.default({
|
|
18
|
-
browser: true,
|
|
19
|
-
}),
|
|
20
|
-
commonjs.default(),
|
|
21
|
-
typescript.default({
|
|
22
|
-
tsconfig: './tsconfig.json',
|
|
23
|
-
noEmit: false,
|
|
24
|
-
declaration: false,
|
|
25
|
-
declarationMap: false,
|
|
26
|
-
}),
|
|
27
|
-
terser.default({
|
|
28
|
-
compress: {
|
|
29
|
-
drop_console: false,
|
|
30
|
-
},
|
|
31
|
-
mangle: true,
|
|
32
|
-
format: {
|
|
33
|
-
comments: false,
|
|
34
|
-
},
|
|
35
|
-
}),
|
|
36
|
-
],
|
|
37
|
-
};
|
|
38
|
-
|
package/src/IntuitEmbeddedSDK.ts
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
import { AuthorizationModule } from './authorizationModule/types';
|
|
2
|
-
import { createChildAuthorizationModule } from './authorizationModule/Authorization';
|
|
3
|
-
import {
|
|
4
|
-
sendHandshakeReply,
|
|
5
|
-
sendLog,
|
|
6
|
-
sendMetrics
|
|
7
|
-
} from './messagingModule/Messaging';
|
|
8
|
-
import { MessageTypes } from './messagingModule/types';
|
|
9
|
-
import { TelemetryModule } from './telemetryModule/Telemetry';
|
|
10
|
-
import { Logger, Metrics } from './telemetryModule/types';
|
|
11
|
-
|
|
12
|
-
const HANDSHAKE_TIMEOUT = 30000; // 30 seconds timeout
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Main entry point for IntuitEmbeddedSDK.
|
|
16
|
-
* Manages child (iFrame) communication with the parent application.
|
|
17
|
-
*/
|
|
18
|
-
export default class IntuitEmbeddedSDK {
|
|
19
|
-
private static instance: IntuitEmbeddedSDK;
|
|
20
|
-
|
|
21
|
-
authorizationModule: AuthorizationModule | undefined;
|
|
22
|
-
|
|
23
|
-
child: Window;
|
|
24
|
-
|
|
25
|
-
parentOrigin: string | undefined;
|
|
26
|
-
|
|
27
|
-
parentWindow: Window;
|
|
28
|
-
|
|
29
|
-
telemetryModule: TelemetryModule;
|
|
30
|
-
|
|
31
|
-
private constructor() {
|
|
32
|
-
this.child = window;
|
|
33
|
-
this.parentWindow = this.child.parent;
|
|
34
|
-
this.parentOrigin = undefined;
|
|
35
|
-
|
|
36
|
-
// Initialize telemetry module with default logger (will be updated on handshake)
|
|
37
|
-
this.telemetryModule = new TelemetryModule();
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Returns the singleton instance of the SDK
|
|
42
|
-
*/
|
|
43
|
-
static getInstance(): IntuitEmbeddedSDK {
|
|
44
|
-
if (!IntuitEmbeddedSDK.instance) {
|
|
45
|
-
IntuitEmbeddedSDK.instance = new IntuitEmbeddedSDK();
|
|
46
|
-
}
|
|
47
|
-
return IntuitEmbeddedSDK.instance;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Initializes the child and establishes handshake with parent
|
|
52
|
-
* @return Resolves when handshake is complete
|
|
53
|
-
*/
|
|
54
|
-
async initialize(): Promise<void> {
|
|
55
|
-
// Establish handshake with parent
|
|
56
|
-
await this.establishHandshake();
|
|
57
|
-
|
|
58
|
-
// Create authorization module now that we have parentOrigin
|
|
59
|
-
if (this.parentOrigin) {
|
|
60
|
-
const module = createChildAuthorizationModule({
|
|
61
|
-
childWindow: this.child,
|
|
62
|
-
parentOrigin: this.parentOrigin,
|
|
63
|
-
parentWindow: this.parentWindow,
|
|
64
|
-
});
|
|
65
|
-
this.authorizationModule = module;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Responds to a handshake initiated by the parent
|
|
71
|
-
* @return Resolves when handshake is complete
|
|
72
|
-
*/
|
|
73
|
-
private establishHandshake(): Promise<void> {
|
|
74
|
-
return new Promise((resolve, reject) => {
|
|
75
|
-
/**
|
|
76
|
-
* @param event - The message event from the parent
|
|
77
|
-
*/
|
|
78
|
-
const handshake = (event: MessageEvent) => {
|
|
79
|
-
if (!event.data.message) {
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (event.data.message === MessageTypes.HANDSHAKE) {
|
|
84
|
-
clearTimeout(timeoutId);
|
|
85
|
-
this.child.removeEventListener('message', handshake, false);
|
|
86
|
-
|
|
87
|
-
sendHandshakeReply({ origin: event.origin, target: event.source as Window });
|
|
88
|
-
|
|
89
|
-
this.parentOrigin = event.origin;
|
|
90
|
-
|
|
91
|
-
this.setupTelemetryProxies();
|
|
92
|
-
|
|
93
|
-
resolve();
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
// Set up timeout for handshake
|
|
98
|
-
const timeoutId = setTimeout(() => {
|
|
99
|
-
this.child.removeEventListener('message', handshake, false);
|
|
100
|
-
reject(
|
|
101
|
-
new Error(
|
|
102
|
-
'Handshake timeout: Parent did not send handshake within 30 seconds'
|
|
103
|
-
)
|
|
104
|
-
);
|
|
105
|
-
}, HANDSHAKE_TIMEOUT);
|
|
106
|
-
|
|
107
|
-
this.child.addEventListener('message', handshake, false);
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Sets up proxy logger and metrics capture to forward to parent
|
|
113
|
-
*/
|
|
114
|
-
private setupTelemetryProxies(): void {
|
|
115
|
-
const proxyLogger: Logger = {
|
|
116
|
-
debug: async (message: string, ...args: any[]) => {
|
|
117
|
-
if (this.parentOrigin) {
|
|
118
|
-
sendLog({
|
|
119
|
-
logArgs: args,
|
|
120
|
-
logMessage: message,
|
|
121
|
-
logType: 'debug',
|
|
122
|
-
origin: this.parentOrigin,
|
|
123
|
-
target: this.parentWindow
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
info: async (message: string, ...args: any[]) => {
|
|
128
|
-
if (this.parentOrigin) {
|
|
129
|
-
sendLog({
|
|
130
|
-
logArgs: args,
|
|
131
|
-
logMessage: message,
|
|
132
|
-
logType: 'info',
|
|
133
|
-
origin: this.parentOrigin,
|
|
134
|
-
target: this.parentWindow
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
},
|
|
138
|
-
warn: async (message: string, ...args: any[]) => {
|
|
139
|
-
if (this.parentOrigin) {
|
|
140
|
-
sendLog({
|
|
141
|
-
logArgs: args,
|
|
142
|
-
logMessage: message,
|
|
143
|
-
logType: 'warn',
|
|
144
|
-
origin: this.parentOrigin,
|
|
145
|
-
target: this.parentWindow
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
},
|
|
149
|
-
error: async (message: string, ...args: any[]) => {
|
|
150
|
-
if (this.parentOrigin) {
|
|
151
|
-
sendLog({
|
|
152
|
-
logArgs: args,
|
|
153
|
-
logMessage: message,
|
|
154
|
-
logType: 'error',
|
|
155
|
-
origin: this.parentOrigin,
|
|
156
|
-
target: this.parentWindow
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
},
|
|
160
|
-
log: async (message: string, ...args: any[]) => {
|
|
161
|
-
if (this.parentOrigin) {
|
|
162
|
-
sendLog({
|
|
163
|
-
logArgs: args,
|
|
164
|
-
logMessage: message,
|
|
165
|
-
logType: 'log',
|
|
166
|
-
origin: this.parentOrigin,
|
|
167
|
-
target: this.parentWindow
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
this.telemetryModule.setLogger({ logger: proxyLogger });
|
|
174
|
-
|
|
175
|
-
const proxyCaptureMetrics = async (metrics: Metrics) => {
|
|
176
|
-
if (this.parentOrigin) {
|
|
177
|
-
sendMetrics({ metrics, origin: this.parentOrigin, target: this.parentWindow });
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
this.telemetryModule.setCaptureMetrics({ captureMetrics: proxyCaptureMetrics });
|
|
182
|
-
|
|
183
|
-
this.telemetryModule.initialize().catch(err => {
|
|
184
|
-
console.error('[IntuitEmbeddedSDK] Failed to initialize telemetry:', err);
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* Cleans up resources and event listeners
|
|
190
|
-
*/
|
|
191
|
-
destroy(): void {
|
|
192
|
-
// Clean up telemetry listeners
|
|
193
|
-
if (this.telemetryModule) {
|
|
194
|
-
this.telemetryModule.destroy();
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
// Reset state
|
|
198
|
-
this.parentOrigin = undefined;
|
|
199
|
-
this.authorizationModule = undefined;
|
|
200
|
-
}
|
|
201
|
-
}
|