@aws-amplify/rtn-web-browser 1.3.1-unstable.fb2c88e.0 → 1.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/esm/apis/openAuthSessionAsync.mjs +1 -1
- package/package.json +2 -2
- package/dist/cjs/apis/__tests__/openAuthSessionAsync.test.js +0 -50
- package/dist/cjs/apis/__tests__/openAuthSessionAsync.test.js.map +0 -1
- package/dist/esm/apis/__tests__/openAuthSessionAsync.test.d.ts +0 -1
- package/dist/esm/apis/__tests__/openAuthSessionAsync.test.mjs +0 -48
- package/dist/esm/apis/__tests__/openAuthSessionAsync.test.mjs.map +0 -1
- package/src/apis/__tests__/openAuthSessionAsync.test.ts +0 -78
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Platform, NativeModules, Linking, AppState } from 'react-native';
|
|
2
2
|
import { nativeModule } from '../nativeModule.mjs';
|
|
3
3
|
|
|
4
4
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-amplify/rtn-web-browser",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "React Native module for aws-amplify web browser",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/esm/index.mjs",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"dist/esm",
|
|
48
48
|
"src"
|
|
49
49
|
],
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "46ff4ba5bf95304d8b51456094b4fccf00674c08"
|
|
51
51
|
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const react_native_1 = require("react-native");
|
|
7
|
-
const nativeModule_1 = require("../../nativeModule");
|
|
8
|
-
const openAuthSessionAsync_1 = require("../openAuthSessionAsync");
|
|
9
|
-
jest.mock('react-native', () => ({
|
|
10
|
-
Platform: { OS: 'ios' },
|
|
11
|
-
AppState: { addEventListener: jest.fn() },
|
|
12
|
-
Linking: { addEventListener: jest.fn() },
|
|
13
|
-
NativeModules: {},
|
|
14
|
-
}));
|
|
15
|
-
jest.mock('../../nativeModule', () => ({
|
|
16
|
-
nativeModule: { openAuthSessionAsync: jest.fn() },
|
|
17
|
-
}));
|
|
18
|
-
const mockPlatform = react_native_1.Platform;
|
|
19
|
-
const mockNativeModule = nativeModule_1.nativeModule;
|
|
20
|
-
describe('openAuthSessionAsync', () => {
|
|
21
|
-
beforeEach(() => {
|
|
22
|
-
jest.clearAllMocks();
|
|
23
|
-
mockPlatform.OS = 'ios';
|
|
24
|
-
});
|
|
25
|
-
describe('isChromebook', () => {
|
|
26
|
-
it('returns false by default', async () => {
|
|
27
|
-
const result = await (0, openAuthSessionAsync_1.isChromebook)();
|
|
28
|
-
expect(result).toBe(false);
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
describe('openAuthSessionAsync', () => {
|
|
32
|
-
it('enforces HTTPS on URLs', async () => {
|
|
33
|
-
mockNativeModule.openAuthSessionAsync.mockResolvedValue('result');
|
|
34
|
-
await (0, openAuthSessionAsync_1.openAuthSessionAsync)('http://example.com', ['myapp://callback']);
|
|
35
|
-
expect(mockNativeModule.openAuthSessionAsync).toHaveBeenCalledWith('https://example.com', 'myapp://callback', false);
|
|
36
|
-
});
|
|
37
|
-
it('calls iOS implementation', async () => {
|
|
38
|
-
mockNativeModule.openAuthSessionAsync.mockResolvedValue('result');
|
|
39
|
-
const result = await (0, openAuthSessionAsync_1.openAuthSessionAsync)('https://example.com', ['myapp://callback'], true);
|
|
40
|
-
expect(result).toBe('result');
|
|
41
|
-
expect(mockNativeModule.openAuthSessionAsync).toHaveBeenCalledWith('https://example.com', 'myapp://callback', true);
|
|
42
|
-
});
|
|
43
|
-
it('finds first non-web URL for redirect', async () => {
|
|
44
|
-
const redirectUrls = ['https://web.com', 'myapp://deep'];
|
|
45
|
-
await (0, openAuthSessionAsync_1.openAuthSessionAsync)('https://example.com', redirectUrls);
|
|
46
|
-
expect(mockNativeModule.openAuthSessionAsync).toHaveBeenCalledWith('https://example.com', 'myapp://deep', false);
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
//# sourceMappingURL=openAuthSessionAsync.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"openAuthSessionAsync.test.js","sources":["../../../../src/apis/__tests__/openAuthSessionAsync.test.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nconst react_native_1 = require(\"react-native\");\nconst nativeModule_1 = require(\"../../nativeModule\");\nconst openAuthSessionAsync_1 = require(\"../openAuthSessionAsync\");\njest.mock('react-native', () => ({\n Platform: { OS: 'ios' },\n AppState: { addEventListener: jest.fn() },\n Linking: { addEventListener: jest.fn() },\n NativeModules: {},\n}));\njest.mock('../../nativeModule', () => ({\n nativeModule: { openAuthSessionAsync: jest.fn() },\n}));\nconst mockPlatform = react_native_1.Platform;\nconst mockNativeModule = nativeModule_1.nativeModule;\ndescribe('openAuthSessionAsync', () => {\n beforeEach(() => {\n jest.clearAllMocks();\n mockPlatform.OS = 'ios';\n });\n describe('isChromebook', () => {\n it('returns false by default', async () => {\n const result = await (0, openAuthSessionAsync_1.isChromebook)();\n expect(result).toBe(false);\n });\n });\n describe('openAuthSessionAsync', () => {\n it('enforces HTTPS on URLs', async () => {\n mockNativeModule.openAuthSessionAsync.mockResolvedValue('result');\n await (0, openAuthSessionAsync_1.openAuthSessionAsync)('http://example.com', ['myapp://callback']);\n expect(mockNativeModule.openAuthSessionAsync).toHaveBeenCalledWith('https://example.com', 'myapp://callback', false);\n });\n it('calls iOS implementation', async () => {\n mockNativeModule.openAuthSessionAsync.mockResolvedValue('result');\n const result = await (0, openAuthSessionAsync_1.openAuthSessionAsync)('https://example.com', ['myapp://callback'], true);\n expect(result).toBe('result');\n expect(mockNativeModule.openAuthSessionAsync).toHaveBeenCalledWith('https://example.com', 'myapp://callback', true);\n });\n it('finds first non-web URL for redirect', async () => {\n const redirectUrls = ['https://web.com', 'myapp://deep'];\n await (0, openAuthSessionAsync_1.openAuthSessionAsync)('https://example.com', redirectUrls);\n expect(mockNativeModule.openAuthSessionAsync).toHaveBeenCalledWith('https://example.com', 'myapp://deep', false);\n });\n });\n});\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,MAAM,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC;AAC9C,MAAM,cAAc,GAAG,OAAO,CAAC,oBAAoB,CAAC;AACpD,MAAM,sBAAsB,GAAG,OAAO,CAAC,yBAAyB,CAAC;AACjE,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,OAAO;AACjC,IAAI,QAAQ,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE;AAC3B,IAAI,QAAQ,EAAE,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE,EAAE,EAAE;AAC7C,IAAI,OAAO,EAAE,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE,EAAE,EAAE;AAC5C,IAAI,aAAa,EAAE,EAAE;AACrB,CAAC,CAAC,CAAC;AACH,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE,OAAO;AACvC,IAAI,YAAY,EAAE,EAAE,oBAAoB,EAAE,IAAI,CAAC,EAAE,EAAE,EAAE;AACrD,CAAC,CAAC,CAAC;AACH,MAAM,YAAY,GAAG,cAA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AC,gBAAgB,CAAC,oBAAoB,CAAC,CAAC,oBAAoB,CAAC,qBAAqB,EAAE,kBAAkB,EAAE,IAAI,CAAC;AAC/H,QAAQ,CAAC,CAAC;AACV,QAAQ,EAAE,CAAC,sCAAsC,EAAE,YAAY;AAC/D,YAAY,MAAM,YAAY,GAAG,CAAC,iBAAiB,EAAE,cAAc,CAAC;AACpE,YAAY,MAAM,IAAI,sBAAsB,CAAC,oBAAoB,EAAE,qBAAqB,EAAE,YAAY,CAAC;AACvG,YAAY,MAAM,CAAC,gBAAgB,CAAC,oBAAoB,CAAC,CAAC,oBAAoB,CAAC,qBAAqB,EAAE,cAAc,EAAE,KAAK,CAAC;AAC5H,QAAQ,CAAC,CAAC;AACV,IAAI,CAAC,CAAC;AACN,CAAC,CAAC;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { Platform } from 'react-native';
|
|
2
|
-
import { nativeModule } from '../../nativeModule.mjs';
|
|
3
|
-
import { isChromebook, openAuthSessionAsync } from '../openAuthSessionAsync.mjs';
|
|
4
|
-
|
|
5
|
-
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
6
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
7
|
-
jest.mock('react-native', () => ({
|
|
8
|
-
Platform: { OS: 'ios' },
|
|
9
|
-
AppState: { addEventListener: jest.fn() },
|
|
10
|
-
Linking: { addEventListener: jest.fn() },
|
|
11
|
-
NativeModules: {},
|
|
12
|
-
}));
|
|
13
|
-
jest.mock('../../nativeModule', () => ({
|
|
14
|
-
nativeModule: { openAuthSessionAsync: jest.fn() },
|
|
15
|
-
}));
|
|
16
|
-
const mockPlatform = Platform;
|
|
17
|
-
const mockNativeModule = nativeModule;
|
|
18
|
-
describe('openAuthSessionAsync', () => {
|
|
19
|
-
beforeEach(() => {
|
|
20
|
-
jest.clearAllMocks();
|
|
21
|
-
mockPlatform.OS = 'ios';
|
|
22
|
-
});
|
|
23
|
-
describe('isChromebook', () => {
|
|
24
|
-
it('returns false by default', async () => {
|
|
25
|
-
const result = await isChromebook();
|
|
26
|
-
expect(result).toBe(false);
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
describe('openAuthSessionAsync', () => {
|
|
30
|
-
it('enforces HTTPS on URLs', async () => {
|
|
31
|
-
mockNativeModule.openAuthSessionAsync.mockResolvedValue('result');
|
|
32
|
-
await openAuthSessionAsync('http://example.com', ['myapp://callback']);
|
|
33
|
-
expect(mockNativeModule.openAuthSessionAsync).toHaveBeenCalledWith('https://example.com', 'myapp://callback', false);
|
|
34
|
-
});
|
|
35
|
-
it('calls iOS implementation', async () => {
|
|
36
|
-
mockNativeModule.openAuthSessionAsync.mockResolvedValue('result');
|
|
37
|
-
const result = await openAuthSessionAsync('https://example.com', ['myapp://callback'], true);
|
|
38
|
-
expect(result).toBe('result');
|
|
39
|
-
expect(mockNativeModule.openAuthSessionAsync).toHaveBeenCalledWith('https://example.com', 'myapp://callback', true);
|
|
40
|
-
});
|
|
41
|
-
it('finds first non-web URL for redirect', async () => {
|
|
42
|
-
const redirectUrls = ['https://web.com', 'myapp://deep'];
|
|
43
|
-
await openAuthSessionAsync('https://example.com', redirectUrls);
|
|
44
|
-
expect(mockNativeModule.openAuthSessionAsync).toHaveBeenCalledWith('https://example.com', 'myapp://deep', false);
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
//# sourceMappingURL=openAuthSessionAsync.test.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"openAuthSessionAsync.test.mjs","sources":["../../../../src/apis/__tests__/openAuthSessionAsync.test.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Platform } from 'react-native';\nimport { nativeModule } from '../../nativeModule';\nimport { isChromebook, openAuthSessionAsync } from '../openAuthSessionAsync';\njest.mock('react-native', () => ({\n Platform: { OS: 'ios' },\n AppState: { addEventListener: jest.fn() },\n Linking: { addEventListener: jest.fn() },\n NativeModules: {},\n}));\njest.mock('../../nativeModule', () => ({\n nativeModule: { openAuthSessionAsync: jest.fn() },\n}));\nconst mockPlatform = Platform;\nconst mockNativeModule = nativeModule;\ndescribe('openAuthSessionAsync', () => {\n beforeEach(() => {\n jest.clearAllMocks();\n mockPlatform.OS = 'ios';\n });\n describe('isChromebook', () => {\n it('returns false by default', async () => {\n const result = await isChromebook();\n expect(result).toBe(false);\n });\n });\n describe('openAuthSessionAsync', () => {\n it('enforces HTTPS on URLs', async () => {\n mockNativeModule.openAuthSessionAsync.mockResolvedValue('result');\n await openAuthSessionAsync('http://example.com', ['myapp://callback']);\n expect(mockNativeModule.openAuthSessionAsync).toHaveBeenCalledWith('https://example.com', 'myapp://callback', false);\n });\n it('calls iOS implementation', async () => {\n mockNativeModule.openAuthSessionAsync.mockResolvedValue('result');\n const result = await openAuthSessionAsync('https://example.com', ['myapp://callback'], true);\n expect(result).toBe('result');\n expect(mockNativeModule.openAuthSessionAsync).toHaveBeenCalledWith('https://example.com', 'myapp://callback', true);\n });\n it('finds first non-web URL for redirect', async () => {\n const redirectUrls = ['https://web.com', 'myapp://deep'];\n await openAuthSessionAsync('https://example.com', redirectUrls);\n expect(mockNativeModule.openAuthSessionAsync).toHaveBeenCalledWith('https://example.com', 'myapp://deep', false);\n });\n });\n});\n"],"names":[],"mappings":";;;;AAAA;AACA;AAIA,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,OAAO;AACjC,IAAI,QAAQ,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE;AAC3B,IAAI,QAAQ,EAAE,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE,EAAE,EAAE;AAC7C,IAAI,OAAO,EAAE,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE,EAAE,EAAE;AAC5C,IAAI,aAAa,EAAE,EAAE;AACrB,CAAC,CAAC,CAAC;AACH,IAAI,C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MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC;AACzC,YAAY,MAAM,CAAC,gBAAgB,CAAC,oBAAoB,CAAC,CAAC,oBAAoB,CAAC,qBAAqB,EAAE,kBAAkB,EAAE,IAAI,CAAC;AAC/H,QAAQ,CAAC,CAAC;AACV,QAAQ,EAAE,CAAC,sCAAsC,EAAE,YAAY;AAC/D,YAAY,MAAM,YAAY,GAAG,CAAC,iBAAiB,EAAE,cAAc,CAAC;AACpE,YAAY,MAAM,oBAAoB,CAAC,qBAAqB,EAAE,YAAY,CAAC;AAC3E,YAAY,MAAM,CAAC,gBAAgB,CAAC,oBAAoB,CAAC,CAAC,oBAAoB,CAAC,qBAAqB,EAAE,cAAc,EAAE,KAAK,CAAC;AAC5H,QAAQ,CAAC,CAAC;AACV,IAAI,CAAC,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
import { Platform } from 'react-native';
|
|
5
|
-
|
|
6
|
-
import { nativeModule } from '../../nativeModule';
|
|
7
|
-
import { isChromebook, openAuthSessionAsync } from '../openAuthSessionAsync';
|
|
8
|
-
|
|
9
|
-
jest.mock('react-native', () => ({
|
|
10
|
-
Platform: { OS: 'ios' },
|
|
11
|
-
AppState: { addEventListener: jest.fn() },
|
|
12
|
-
Linking: { addEventListener: jest.fn() },
|
|
13
|
-
NativeModules: {},
|
|
14
|
-
}));
|
|
15
|
-
|
|
16
|
-
jest.mock('../../nativeModule', () => ({
|
|
17
|
-
nativeModule: { openAuthSessionAsync: jest.fn() },
|
|
18
|
-
}));
|
|
19
|
-
|
|
20
|
-
const mockPlatform = Platform as jest.Mocked<typeof Platform>;
|
|
21
|
-
const mockNativeModule = nativeModule as jest.Mocked<typeof nativeModule>;
|
|
22
|
-
|
|
23
|
-
describe('openAuthSessionAsync', () => {
|
|
24
|
-
beforeEach(() => {
|
|
25
|
-
jest.clearAllMocks();
|
|
26
|
-
mockPlatform.OS = 'ios';
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
describe('isChromebook', () => {
|
|
30
|
-
it('returns false by default', async () => {
|
|
31
|
-
const result = await isChromebook();
|
|
32
|
-
expect(result).toBe(false);
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
describe('openAuthSessionAsync', () => {
|
|
37
|
-
it('enforces HTTPS on URLs', async () => {
|
|
38
|
-
mockNativeModule.openAuthSessionAsync.mockResolvedValue('result');
|
|
39
|
-
|
|
40
|
-
await openAuthSessionAsync('http://example.com', ['myapp://callback']);
|
|
41
|
-
|
|
42
|
-
expect(mockNativeModule.openAuthSessionAsync).toHaveBeenCalledWith(
|
|
43
|
-
'https://example.com',
|
|
44
|
-
'myapp://callback',
|
|
45
|
-
false,
|
|
46
|
-
);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('calls iOS implementation', async () => {
|
|
50
|
-
mockNativeModule.openAuthSessionAsync.mockResolvedValue('result');
|
|
51
|
-
|
|
52
|
-
const result = await openAuthSessionAsync(
|
|
53
|
-
'https://example.com',
|
|
54
|
-
['myapp://callback'],
|
|
55
|
-
true,
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
expect(result).toBe('result');
|
|
59
|
-
expect(mockNativeModule.openAuthSessionAsync).toHaveBeenCalledWith(
|
|
60
|
-
'https://example.com',
|
|
61
|
-
'myapp://callback',
|
|
62
|
-
true,
|
|
63
|
-
);
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it('finds first non-web URL for redirect', async () => {
|
|
67
|
-
const redirectUrls = ['https://web.com', 'myapp://deep'];
|
|
68
|
-
|
|
69
|
-
await openAuthSessionAsync('https://example.com', redirectUrls);
|
|
70
|
-
|
|
71
|
-
expect(mockNativeModule.openAuthSessionAsync).toHaveBeenCalledWith(
|
|
72
|
-
'https://example.com',
|
|
73
|
-
'myapp://deep',
|
|
74
|
-
false,
|
|
75
|
-
);
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
});
|