@slates/oauth-microsoft 1.0.0-rc.1
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/README.md +3 -0
- package/dist/index.cjs +61 -0
- package/dist/index.d.cts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.module.js +33 -0
- package/package.json +38 -0
- package/src/index.test.ts +40 -0
- package/src/index.ts +34 -0
package/README.md
ADDED
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
MICROSOFT_OAUTH_INTEGRATION_KEYS: () => MICROSOFT_OAUTH_INTEGRATION_KEYS,
|
|
24
|
+
normalizeMicrosoftRedirectUri: () => normalizeMicrosoftRedirectUri,
|
|
25
|
+
normalizeMicrosoftRedirectUriForIntegration: () => normalizeMicrosoftRedirectUriForIntegration,
|
|
26
|
+
usesMicrosoftOAuth: () => usesMicrosoftOAuth
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(index_exports);
|
|
29
|
+
var MICROSOFT_OAUTH_INTEGRATION_KEYS = /* @__PURE__ */ new Set([
|
|
30
|
+
"azure-blob-storage",
|
|
31
|
+
"azure-devops",
|
|
32
|
+
"azure-functions",
|
|
33
|
+
"azure-repos",
|
|
34
|
+
"dynamics-365",
|
|
35
|
+
"excel-online",
|
|
36
|
+
"microsoft-teams",
|
|
37
|
+
"onedrive",
|
|
38
|
+
"onenote",
|
|
39
|
+
"outlook",
|
|
40
|
+
"power-bi",
|
|
41
|
+
"powerpoint-online",
|
|
42
|
+
"sharepoint",
|
|
43
|
+
"superhuman-microsoft365",
|
|
44
|
+
"word-online"
|
|
45
|
+
]);
|
|
46
|
+
var usesMicrosoftOAuth = (integration) => MICROSOFT_OAUTH_INTEGRATION_KEYS.has(integration);
|
|
47
|
+
var normalizeMicrosoftRedirectUri = (redirectUri) => {
|
|
48
|
+
let url = new URL(redirectUri);
|
|
49
|
+
if (url.protocol === "http:" && url.hostname === "127.0.0.1") {
|
|
50
|
+
url.hostname = "localhost";
|
|
51
|
+
}
|
|
52
|
+
return url.toString();
|
|
53
|
+
};
|
|
54
|
+
var normalizeMicrosoftRedirectUriForIntegration = (integration, redirectUri) => usesMicrosoftOAuth(integration) ? normalizeMicrosoftRedirectUri(redirectUri) : redirectUri;
|
|
55
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
+
0 && (module.exports = {
|
|
57
|
+
MICROSOFT_OAUTH_INTEGRATION_KEYS,
|
|
58
|
+
normalizeMicrosoftRedirectUri,
|
|
59
|
+
normalizeMicrosoftRedirectUriForIntegration,
|
|
60
|
+
usesMicrosoftOAuth
|
|
61
|
+
});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
declare let MICROSOFT_OAUTH_INTEGRATION_KEYS: Set<string>;
|
|
2
|
+
declare let usesMicrosoftOAuth: (integration: string) => boolean;
|
|
3
|
+
declare let normalizeMicrosoftRedirectUri: (redirectUri: string) => string;
|
|
4
|
+
declare let normalizeMicrosoftRedirectUriForIntegration: (integration: string, redirectUri: string) => string;
|
|
5
|
+
|
|
6
|
+
export { MICROSOFT_OAUTH_INTEGRATION_KEYS, normalizeMicrosoftRedirectUri, normalizeMicrosoftRedirectUriForIntegration, usesMicrosoftOAuth };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
declare let MICROSOFT_OAUTH_INTEGRATION_KEYS: Set<string>;
|
|
2
|
+
declare let usesMicrosoftOAuth: (integration: string) => boolean;
|
|
3
|
+
declare let normalizeMicrosoftRedirectUri: (redirectUri: string) => string;
|
|
4
|
+
declare let normalizeMicrosoftRedirectUriForIntegration: (integration: string, redirectUri: string) => string;
|
|
5
|
+
|
|
6
|
+
export { MICROSOFT_OAUTH_INTEGRATION_KEYS, normalizeMicrosoftRedirectUri, normalizeMicrosoftRedirectUriForIntegration, usesMicrosoftOAuth };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
var MICROSOFT_OAUTH_INTEGRATION_KEYS = /* @__PURE__ */ new Set([
|
|
3
|
+
"azure-blob-storage",
|
|
4
|
+
"azure-devops",
|
|
5
|
+
"azure-functions",
|
|
6
|
+
"azure-repos",
|
|
7
|
+
"dynamics-365",
|
|
8
|
+
"excel-online",
|
|
9
|
+
"microsoft-teams",
|
|
10
|
+
"onedrive",
|
|
11
|
+
"onenote",
|
|
12
|
+
"outlook",
|
|
13
|
+
"power-bi",
|
|
14
|
+
"powerpoint-online",
|
|
15
|
+
"sharepoint",
|
|
16
|
+
"superhuman-microsoft365",
|
|
17
|
+
"word-online"
|
|
18
|
+
]);
|
|
19
|
+
var usesMicrosoftOAuth = (integration) => MICROSOFT_OAUTH_INTEGRATION_KEYS.has(integration);
|
|
20
|
+
var normalizeMicrosoftRedirectUri = (redirectUri) => {
|
|
21
|
+
let url = new URL(redirectUri);
|
|
22
|
+
if (url.protocol === "http:" && url.hostname === "127.0.0.1") {
|
|
23
|
+
url.hostname = "localhost";
|
|
24
|
+
}
|
|
25
|
+
return url.toString();
|
|
26
|
+
};
|
|
27
|
+
var normalizeMicrosoftRedirectUriForIntegration = (integration, redirectUri) => usesMicrosoftOAuth(integration) ? normalizeMicrosoftRedirectUri(redirectUri) : redirectUri;
|
|
28
|
+
export {
|
|
29
|
+
MICROSOFT_OAUTH_INTEGRATION_KEYS,
|
|
30
|
+
normalizeMicrosoftRedirectUri,
|
|
31
|
+
normalizeMicrosoftRedirectUriForIntegration,
|
|
32
|
+
usesMicrosoftOAuth
|
|
33
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@slates/oauth-microsoft",
|
|
3
|
+
"version": "1.0.0-rc.1",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"files": [
|
|
8
|
+
"src/**",
|
|
9
|
+
"dist/**",
|
|
10
|
+
"README.md",
|
|
11
|
+
"package.json"
|
|
12
|
+
],
|
|
13
|
+
"author": "Tobias Herber",
|
|
14
|
+
"license": "FSL 1.1",
|
|
15
|
+
"type": "module",
|
|
16
|
+
"source": "src/index.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"require": "./dist/index.cjs",
|
|
20
|
+
"import": "./dist/index.module.js",
|
|
21
|
+
"default": "./dist/index.module.js"
|
|
22
|
+
},
|
|
23
|
+
"main": "./dist/index.cjs",
|
|
24
|
+
"module": "./dist/index.module.js",
|
|
25
|
+
"types": "dist/index.d.ts",
|
|
26
|
+
"unpkg": "./dist/index.module.js",
|
|
27
|
+
"scripts": {
|
|
28
|
+
"test": "vitest run --config vitest.config.ts --passWithNoTests",
|
|
29
|
+
"lint": "prettier src/**/*.ts --check",
|
|
30
|
+
"build": "tsup --config ../../tsup.packages.config.ts --external async_hooks",
|
|
31
|
+
"typecheck": "tsc --noEmit"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@slates/tsconfig": "1.0.0-rc.1",
|
|
35
|
+
"typescript": "5.8.2",
|
|
36
|
+
"vitest": "^3.1.2"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import {
|
|
3
|
+
normalizeMicrosoftRedirectUri,
|
|
4
|
+
normalizeMicrosoftRedirectUriForIntegration,
|
|
5
|
+
usesMicrosoftOAuth
|
|
6
|
+
} from './index';
|
|
7
|
+
|
|
8
|
+
describe('@slates/oauth-microsoft', () => {
|
|
9
|
+
it('normalizes loopback IPv4 redirect URIs to localhost', () => {
|
|
10
|
+
expect(normalizeMicrosoftRedirectUri('http://127.0.0.1:45873/callback')).toBe(
|
|
11
|
+
'http://localhost:45873/callback'
|
|
12
|
+
);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('leaves non-loopback redirect URIs unchanged', () => {
|
|
16
|
+
expect(normalizeMicrosoftRedirectUri('https://example.com/callback')).toBe(
|
|
17
|
+
'https://example.com/callback'
|
|
18
|
+
);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('detects Microsoft OAuth integrations', () => {
|
|
22
|
+
expect(usesMicrosoftOAuth('sharepoint')).toBe(true);
|
|
23
|
+
expect(usesMicrosoftOAuth('github')).toBe(false);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('only normalizes redirect URIs for Microsoft OAuth integrations', () => {
|
|
27
|
+
expect(
|
|
28
|
+
normalizeMicrosoftRedirectUriForIntegration(
|
|
29
|
+
'outlook',
|
|
30
|
+
'http://127.0.0.1:45873/callback'
|
|
31
|
+
)
|
|
32
|
+
).toBe('http://localhost:45873/callback');
|
|
33
|
+
expect(
|
|
34
|
+
normalizeMicrosoftRedirectUriForIntegration(
|
|
35
|
+
'github',
|
|
36
|
+
'http://127.0.0.1:45873/callback'
|
|
37
|
+
)
|
|
38
|
+
).toBe('http://127.0.0.1:45873/callback');
|
|
39
|
+
});
|
|
40
|
+
});
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export let MICROSOFT_OAUTH_INTEGRATION_KEYS = new Set([
|
|
2
|
+
'azure-blob-storage',
|
|
3
|
+
'azure-devops',
|
|
4
|
+
'azure-functions',
|
|
5
|
+
'azure-repos',
|
|
6
|
+
'dynamics-365',
|
|
7
|
+
'excel-online',
|
|
8
|
+
'microsoft-teams',
|
|
9
|
+
'onedrive',
|
|
10
|
+
'onenote',
|
|
11
|
+
'outlook',
|
|
12
|
+
'power-bi',
|
|
13
|
+
'powerpoint-online',
|
|
14
|
+
'sharepoint',
|
|
15
|
+
'superhuman-microsoft365',
|
|
16
|
+
'word-online'
|
|
17
|
+
]);
|
|
18
|
+
|
|
19
|
+
export let usesMicrosoftOAuth = (integration: string) =>
|
|
20
|
+
MICROSOFT_OAUTH_INTEGRATION_KEYS.has(integration);
|
|
21
|
+
|
|
22
|
+
export let normalizeMicrosoftRedirectUri = (redirectUri: string) => {
|
|
23
|
+
let url = new URL(redirectUri);
|
|
24
|
+
if (url.protocol === 'http:' && url.hostname === '127.0.0.1') {
|
|
25
|
+
url.hostname = 'localhost';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return url.toString();
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export let normalizeMicrosoftRedirectUriForIntegration = (
|
|
32
|
+
integration: string,
|
|
33
|
+
redirectUri: string
|
|
34
|
+
) => (usesMicrosoftOAuth(integration) ? normalizeMicrosoftRedirectUri(redirectUri) : redirectUri);
|