@cedarjs/auth-netlify-web 5.0.4-next.167 → 5.0.4
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/cjs/index.d.ts +2 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +28 -0
- package/dist/cjs/netlify.d.ts +13 -0
- package/dist/cjs/netlify.d.ts.map +1 -0
- package/dist/cjs/netlify.js +87 -0
- package/dist/cjs/package.json +1 -0
- package/package.json +18 -8
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
var index_exports = {};
|
|
20
|
+
__export(index_exports, {
|
|
21
|
+
createAuth: () => import_netlify.createAuth
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(index_exports);
|
|
24
|
+
var import_netlify = require("./netlify.js");
|
|
25
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
26
|
+
0 && (module.exports = {
|
|
27
|
+
createAuth
|
|
28
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type * as NetlifyIdentityNS from 'netlify-identity-widget';
|
|
2
|
+
import type { CurrentUser } from '@cedarjs/auth';
|
|
3
|
+
type NetlifyIdentity = typeof NetlifyIdentityNS;
|
|
4
|
+
export declare function createAuth(netlifyIdentity: NetlifyIdentity, customProviderHooks?: {
|
|
5
|
+
useCurrentUser?: () => Promise<CurrentUser>;
|
|
6
|
+
useHasRole?: (currentUser: CurrentUser | null) => (rolesToCheck: string | string[]) => boolean;
|
|
7
|
+
}): {
|
|
8
|
+
AuthContext: import("react").Context<import("@cedarjs/auth").AuthContextInterface<NetlifyIdentityNS.User, never, NetlifyIdentityNS.User | null, never, void, never, null, unknown, unknown, unknown, unknown, typeof NetlifyIdentityNS> | undefined>;
|
|
9
|
+
AuthProvider: ({ children }: import("@cedarjs/auth").AuthProviderProps) => import("react").JSX.Element;
|
|
10
|
+
useAuth: () => import("@cedarjs/auth").AuthContextInterface<NetlifyIdentityNS.User, never, NetlifyIdentityNS.User | null, never, void, never, null, unknown, unknown, unknown, unknown, typeof NetlifyIdentityNS>;
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=netlify.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"netlify.d.ts","sourceRoot":"","sources":["../../src/netlify.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,iBAAiB,MAAM,yBAAyB,CAAA;AAEjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAShD,KAAK,eAAe,GAAG,OAAO,iBAAiB,CAAA;AAE/C,wBAAgB,UAAU,CACxB,eAAe,EAAE,eAAe,EAChC,mBAAmB,CAAC,EAAE;IACpB,cAAc,CAAC,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,CAAA;IAC3C,UAAU,CAAC,EAAE,CACX,WAAW,EAAE,WAAW,GAAG,IAAI,KAC5B,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,OAAO,CAAA;CAClD;;;;EASF"}
|
|
@@ -0,0 +1,87 @@
|
|
|
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
|
+
var netlify_exports = {};
|
|
20
|
+
__export(netlify_exports, {
|
|
21
|
+
createAuth: () => createAuth
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(netlify_exports);
|
|
24
|
+
var import_auth = require("@cedarjs/auth");
|
|
25
|
+
function createAuth(netlifyIdentity, customProviderHooks) {
|
|
26
|
+
const authImplementation = createAuthImplementation(netlifyIdentity);
|
|
27
|
+
return (0, import_auth.createAuthentication)(authImplementation, customProviderHooks);
|
|
28
|
+
}
|
|
29
|
+
function createAuthImplementation(netlifyIdentity) {
|
|
30
|
+
return {
|
|
31
|
+
type: "netlify",
|
|
32
|
+
client: netlifyIdentity,
|
|
33
|
+
// `_options: never` is needed to help TS infer the TLogInOptions type
|
|
34
|
+
login: (_options) => {
|
|
35
|
+
return new Promise((resolve, reject) => {
|
|
36
|
+
let autoClosedModal = false;
|
|
37
|
+
netlifyIdentity.open("login");
|
|
38
|
+
netlifyIdentity.on("login", (user) => {
|
|
39
|
+
autoClosedModal = true;
|
|
40
|
+
netlifyIdentity.close();
|
|
41
|
+
return resolve(user);
|
|
42
|
+
});
|
|
43
|
+
netlifyIdentity.on("close", () => {
|
|
44
|
+
if (!autoClosedModal) {
|
|
45
|
+
resolve(null);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
netlifyIdentity.on("error", reject);
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
logout: (_options) => {
|
|
52
|
+
return new Promise((resolve, reject) => {
|
|
53
|
+
netlifyIdentity.logout();
|
|
54
|
+
netlifyIdentity.on("logout", resolve);
|
|
55
|
+
netlifyIdentity.on("error", reject);
|
|
56
|
+
});
|
|
57
|
+
},
|
|
58
|
+
signup: (_options) => {
|
|
59
|
+
return new Promise((resolve, reject) => {
|
|
60
|
+
netlifyIdentity.open("signup");
|
|
61
|
+
netlifyIdentity.on("close", () => {
|
|
62
|
+
resolve(null);
|
|
63
|
+
});
|
|
64
|
+
netlifyIdentity.on("error", reject);
|
|
65
|
+
});
|
|
66
|
+
},
|
|
67
|
+
getToken: async () => {
|
|
68
|
+
try {
|
|
69
|
+
await netlifyIdentity.refresh();
|
|
70
|
+
const user = netlifyIdentity.currentUser();
|
|
71
|
+
return user?.token?.access_token || null;
|
|
72
|
+
} catch {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
getUserMetadata: async () => {
|
|
77
|
+
return netlifyIdentity.currentUser();
|
|
78
|
+
},
|
|
79
|
+
restoreAuthState: async () => {
|
|
80
|
+
return netlifyIdentity.currentUser();
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
85
|
+
0 && (module.exports = {
|
|
86
|
+
createAuth
|
|
87
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/auth-netlify-web",
|
|
3
|
-
"version": "5.0.4
|
|
3
|
+
"version": "5.0.4",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/cedarjs/cedar.git",
|
|
@@ -10,19 +10,28 @@
|
|
|
10
10
|
"type": "module",
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
13
|
-
"
|
|
13
|
+
"import": {
|
|
14
14
|
"types": "./dist/index.d.ts",
|
|
15
15
|
"default": "./dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"default": {
|
|
18
|
+
"types": "./dist/cjs/index.d.ts",
|
|
19
|
+
"default": "./dist/cjs/index.js"
|
|
16
20
|
}
|
|
17
21
|
},
|
|
18
22
|
"./dist/netlify": {
|
|
19
|
-
"
|
|
23
|
+
"import": {
|
|
20
24
|
"types": "./dist/netlify.d.ts",
|
|
21
25
|
"default": "./dist/netlify.js"
|
|
26
|
+
},
|
|
27
|
+
"default": {
|
|
28
|
+
"types": "./dist/cjs/netlify.d.ts",
|
|
29
|
+
"default": "./dist/cjs/netlify.js"
|
|
22
30
|
}
|
|
23
31
|
}
|
|
24
32
|
},
|
|
25
|
-
"main": "./dist/index.js",
|
|
33
|
+
"main": "./dist/cjs/index.js",
|
|
34
|
+
"module": "./dist/index.js",
|
|
26
35
|
"types": "./dist/index.d.ts",
|
|
27
36
|
"files": [
|
|
28
37
|
"dist"
|
|
@@ -31,6 +40,7 @@
|
|
|
31
40
|
"build": "node ./build.ts",
|
|
32
41
|
"build:pack": "yarn pack -o cedarjs-auth-netlify-web.tgz",
|
|
33
42
|
"build:types": "tsc --build --verbose ./tsconfig.build.json",
|
|
43
|
+
"build:types-cjs": "tsc --build --verbose ./tsconfig.cjs.json",
|
|
34
44
|
"build:watch": "nodemon --watch src --ext \"js,jsx,ts,tsx,template\" --ignore dist --exec \"yarn build\"",
|
|
35
45
|
"check:attw": "yarn cedar-fwtools-attw",
|
|
36
46
|
"check:package": "concurrently npm:check:attw yarn:publint",
|
|
@@ -39,17 +49,17 @@
|
|
|
39
49
|
"test:watch": "vitest watch"
|
|
40
50
|
},
|
|
41
51
|
"dependencies": {
|
|
42
|
-
"@cedarjs/auth": "5.0.4
|
|
52
|
+
"@cedarjs/auth": "5.0.4"
|
|
43
53
|
},
|
|
44
54
|
"devDependencies": {
|
|
45
|
-
"@cedarjs/framework-tools": "5.0.4
|
|
55
|
+
"@cedarjs/framework-tools": "5.0.4",
|
|
46
56
|
"@types/netlify-identity-widget": "1.9.7",
|
|
47
57
|
"@types/react": "^18.2.55",
|
|
48
58
|
"concurrently": "9.2.4",
|
|
49
|
-
"publint": "0.3.
|
|
59
|
+
"publint": "0.3.21",
|
|
50
60
|
"react": "18.3.1",
|
|
51
61
|
"typescript": "5.9.3",
|
|
52
|
-
"vitest": "
|
|
62
|
+
"vitest": "3.2.6"
|
|
53
63
|
},
|
|
54
64
|
"peerDependencies": {
|
|
55
65
|
"netlify-identity-widget": "1.9.2"
|