-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "chore: [DX-3334] Add the Subresource Integrity attribute to C…
…heckout files" (#2330)
- Loading branch information
1 parent
aa44226
commit 8d4f6d5
Showing
10 changed files
with
18 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,55 +2,35 @@ | |
import { SDK_VERSION_MARKER } from '../env'; | ||
import { getWidgetsEsmUrl, loadUnresolvedBundle } from './load'; | ||
|
||
const SDK_VERSION = SDK_VERSION_MARKER; | ||
|
||
jest.mock('./hashUtils', () => ({ | ||
generateSHA512Hash: jest.fn(async () => 'sha512-abc123'), | ||
// eslint-disable-next-line max-len | ||
validatedHashesUrl: jest.fn(async () => `https://raw.githubusercontent.com/immutable/ts-immutable-sdk/refs/tags/${SDK_VERSION}/packages/checkout/widgets-lib/hashes.json`), | ||
})); | ||
|
||
describe('load', () => { | ||
const SDK_VERSION = SDK_VERSION_MARKER; | ||
const scriptId = 'immutable-checkout-widgets-bundle'; | ||
|
||
beforeEach(() => { | ||
jest.spyOn(console, 'warn').mockImplementation(() => { }); | ||
}); | ||
|
||
describe('load unresolved bundle', () => { | ||
it('should validate the versioning', async () => { | ||
it('should validate the versioning', () => { | ||
const tag = document.createElement('script'); | ||
await loadUnresolvedBundle(tag, scriptId, SDK_VERSION); | ||
|
||
loadUnresolvedBundle(tag, scriptId, SDK_VERSION); | ||
expect(document.head.innerHTML).toBe( | ||
'<script ' | ||
+ 'integrity="sha512-abc123" ' | ||
+ 'crossorigin="anonymous" ' | ||
+ 'id="immutable-checkout-widgets-bundle" ' | ||
'<script id="immutable-checkout-widgets-bundle" ' | ||
+ 'data-version="__SDK_VERSION__" ' | ||
+ `src="https://cdn.jsdelivr.net/npm/@imtbl/sdk@${SDK_VERSION}/dist/browser/checkout/widgets.js"></script>`, | ||
); | ||
}); | ||
}); | ||
|
||
describe('get widgets esm url', () => { | ||
beforeEach(() => { | ||
// @ts-expect-error mocking only json value of fetch response | ||
global.fetch = jest.fn(async () => ({ | ||
json: async () => ({ 'dist/index.js': 'sha512-abc123' }), | ||
})); | ||
}); | ||
|
||
it('should validate the versioning', async () => { | ||
const widgetsEsmUrl = await getWidgetsEsmUrl(SDK_VERSION); | ||
expect(widgetsEsmUrl).toEqual( | ||
it('should validate the versioning', () => { | ||
expect(getWidgetsEsmUrl(SDK_VERSION)).toEqual( | ||
`https://cdn.jsdelivr.net/npm/@imtbl/sdk@${SDK_VERSION}/dist/browser/checkout/widgets-esm.js`, | ||
); | ||
}); | ||
|
||
it('should change version', async () => { | ||
const widgetsEsmUrl = await getWidgetsEsmUrl('1.2.3'); | ||
expect(widgetsEsmUrl).toEqual( | ||
it('should change version', () => { | ||
expect(getWidgetsEsmUrl('1.2.3')).toEqual( | ||
'https://cdn.jsdelivr.net/npm/@imtbl/[email protected]/dist/browser/checkout/widgets-esm.js', | ||
); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -178,4 +178,4 @@ | |
}, | ||
"type": "module", | ||
"types": "./dist/index.d.ts" | ||
} | ||
} |