@magic-ext/oidc 1.0.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/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # v1.0.0 (Tue Aug 16 2022)
2
+
3
+ #### Added
4
+
5
+ - Magic OIDC
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018-present Magic Labs, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,61 @@
1
+ # 🔒 Magic Open Id Connect for Web Browsers
2
+
3
+ [![<MagicLabs>](https://circleci.com/gh/magiclabs/magic-js.svg?style=shield)](https://circleci.com/gh/magiclabs/magic-js)
4
+
5
+ > Magic Open Id Connect JavaScript SDK extension.
6
+
7
+ <p align="center">
8
+ <a href="https://github.com/magiclabs/magic-js/blob/master/packages/@magic-ext/oidc/LICENSE">License</a> ·
9
+ <a href="https://github.com/magiclabs/magic-js/blob/master/packages/@magic-ext/oidc/CHANGELOG.md">Changelog</a> ·
10
+ <a href="https://github.com/magiclabs/magic-js/blob/master/CONTRIBUTING.md">Contributing Guide</a>
11
+ </p>
12
+
13
+ ## 📖 Documentation
14
+
15
+ TODO once docs links are active.
16
+
17
+ ## 🔗 Installation
18
+
19
+ Integrating your app with Magic will require our client-side NPM package and the OIDC extension:
20
+
21
+ ```bash
22
+ # Via NPM:
23
+ npm install --save magic-sdk @magic-ext/oidc
24
+
25
+ # Via Yarn:
26
+ yarn add magic-sdk @magic-ext/oidc
27
+ ```
28
+
29
+ Alternatively, you can load via CDN with by adding a script tag to your app’s `<head>`:
30
+
31
+ ```html
32
+ <script src="https://cdn.jsdelivr.net/npm/magic-sdk/dist/magic.js"></script>
33
+ <script src="https://cdn.jsdelivr.net/npm/@magic-ext/oidc/dist/extension.js"></script>
34
+ ```
35
+
36
+ ## ⚡️ Quick Start
37
+
38
+ Sign up or log in to the [developer dashboard](https://dashboard.magic.link) to receive API keys that will allow your application to interact with Magic's APIs.
39
+
40
+ Request access to this feature sending the API key you want enabled to our customer support.
41
+
42
+ From your login page:
43
+
44
+ ```ts
45
+ import Web3 from 'web3';
46
+ import { Magic } from 'magic-sdk';
47
+ import { OpenIdExtension } from '@magic-ext/oidc';
48
+
49
+ const magic = new Magic('YOUR_API_KEY', {
50
+ extensions: [new OpenIdExtension()],
51
+ network: 'mainnet', // 'mainnet' or 'testnet'
52
+ });
53
+
54
+ const DID = await magic.openid.loginWithOIDC({
55
+ jwt: myOpenIdJwt,
56
+ providerId: myProviderId,
57
+ });
58
+
59
+ const web3 = new Web3(magic.rpcProvider);
60
+ await web3.eth.getAccounts();
61
+ ```
@@ -0,0 +1,2 @@
1
+ var e=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var c=i=>e(i,"__esModule",{value:!0});var h=(i,t)=>{for(var n in t)e(i,n,{get:t[n],enumerable:!0})},l=(i,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of g(t))!m.call(i,o)&&(n||o!=="default")&&e(i,o,{get:()=>t[o],enumerable:!(a=d(t,o))||a.enumerable});return i};var u=(i=>(t,n)=>i&&i.get(t)||(n=l(c({}),t,1),i&&i.set(t,n),n))(typeof WeakMap!="undefined"?new WeakMap:0);var I={};h(I,{MagicOpenIdConnectPayloadMethod:()=>r,OpenIdExtension:()=>p});var s=require("magic-sdk");var r=(t=>(t.LoginWithOIDC="magic_auth_login_with_oidc",t))(r||{});var p=class extends s.Extension.Internal{constructor(){super(...arguments);this.name="openid";this.config={}}loginWithOIDC(t){let n=this.utils.createJsonRpcRequestPayload("magic_auth_login_with_oidc",[t]);return this.request(n)}};module.exports=u(I);
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts", "../../src/types.ts"],
4
+ "sourcesContent": ["import { Extension } from 'magic-sdk';\nimport { MagicOpenIdConnectPayloadMethod, LoginWithOpenIdParams } from './types';\n\nexport class OpenIdExtension extends Extension.Internal<'openid', any> {\n name = 'openid' as const;\n config: any = {};\n\n public loginWithOIDC(params: LoginWithOpenIdParams) {\n const requestPayload = this.utils.createJsonRpcRequestPayload(MagicOpenIdConnectPayloadMethod.LoginWithOIDC, [\n params,\n ]);\n return this.request<boolean>(requestPayload);\n }\n}\n\nexport * from './types';\n", "export interface LoginWithOpenIdParams {\n jwt: string;\n providerId: string;\n}\n\nexport enum MagicOpenIdConnectPayloadMethod {\n LoginWithOIDC = 'magic_auth_login_with_oidc',\n}\n"],
5
+ "mappings": "8gBAAA,kFAA0B,qBCKnB,GAAK,GAAL,CAAK,GACV,iBAAgB,6BADN,WDFL,mBAA8B,aAAU,QAAwB,CAAhE,aAHP,CAGO,oBACL,UAAO,SACP,YAAc,GAEP,cAAc,EAA+B,CAClD,GAAM,GAAiB,KAAK,MAAM,4BAA4B,6BAA+C,CAC3G,IAEF,MAAO,MAAK,QAAiB",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ import{Extension as o}from"magic-sdk";var i=(t=>(t.LoginWithOIDC="magic_auth_login_with_oidc",t))(i||{});var e=class extends o.Internal{constructor(){super(...arguments);this.name="openid";this.config={}}loginWithOIDC(t){let n=this.utils.createJsonRpcRequestPayload("magic_auth_login_with_oidc",[t]);return this.request(n)}};export{i as MagicOpenIdConnectPayloadMethod,e as OpenIdExtension};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts", "../../src/types.ts"],
4
+ "sourcesContent": ["import { Extension } from 'magic-sdk';\nimport { MagicOpenIdConnectPayloadMethod, LoginWithOpenIdParams } from './types';\n\nexport class OpenIdExtension extends Extension.Internal<'openid', any> {\n name = 'openid' as const;\n config: any = {};\n\n public loginWithOIDC(params: LoginWithOpenIdParams) {\n const requestPayload = this.utils.createJsonRpcRequestPayload(MagicOpenIdConnectPayloadMethod.LoginWithOIDC, [\n params,\n ]);\n return this.request<boolean>(requestPayload);\n }\n}\n\nexport * from './types';\n", "export interface LoginWithOpenIdParams {\n jwt: string;\n providerId: string;\n}\n\nexport enum MagicOpenIdConnectPayloadMethod {\n LoginWithOIDC = 'magic_auth_login_with_oidc',\n}\n"],
5
+ "mappings": "AAAA,sCCKO,GAAK,GAAL,CAAK,GACV,iBAAgB,6BADN,WDFL,mBAA8B,GAAU,QAAwB,CAAhE,aAHP,CAGO,oBACL,UAAO,SACP,YAAc,GAEP,cAAc,EAA+B,CAClD,GAAM,GAAiB,KAAK,MAAM,4BAA4B,6BAA+C,CAC3G,IAEF,MAAO,MAAK,QAAiB",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ import{Extension as o}from"magic-sdk";var i=(t=>(t.LoginWithOIDC="magic_auth_login_with_oidc",t))(i||{});var e=class extends o.Internal{constructor(){super(...arguments);this.name="openid";this.config={}}loginWithOIDC(t){let n=this.utils.createJsonRpcRequestPayload("magic_auth_login_with_oidc",[t]);return this.request(n)}};export{i as MagicOpenIdConnectPayloadMethod,e as OpenIdExtension};
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts", "../../src/types.ts"],
4
+ "sourcesContent": ["import { Extension } from 'magic-sdk';\nimport { MagicOpenIdConnectPayloadMethod, LoginWithOpenIdParams } from './types';\n\nexport class OpenIdExtension extends Extension.Internal<'openid', any> {\n name = 'openid' as const;\n config: any = {};\n\n public loginWithOIDC(params: LoginWithOpenIdParams) {\n const requestPayload = this.utils.createJsonRpcRequestPayload(MagicOpenIdConnectPayloadMethod.LoginWithOIDC, [\n params,\n ]);\n return this.request<boolean>(requestPayload);\n }\n}\n\nexport * from './types';\n", "export interface LoginWithOpenIdParams {\n jwt: string;\n providerId: string;\n}\n\nexport enum MagicOpenIdConnectPayloadMethod {\n LoginWithOIDC = 'magic_auth_login_with_oidc',\n}\n"],
5
+ "mappings": "AAAA,sCCKO,GAAK,GAAL,CAAK,GACV,iBAAgB,6BADN,WDFL,mBAA8B,GAAU,QAAwB,CAAhE,aAHP,CAGO,oBACL,UAAO,SACP,YAAc,GAEP,cAAc,EAA+B,CAClD,GAAM,GAAiB,KAAK,MAAM,4BAA4B,6BAA+C,CAC3G,IAEF,MAAO,MAAK,QAAiB",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ var MagicOpenIdConnectExtension=(()=>{var O=Object.create;var n=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames,m=Object.getOwnPropertySymbols,L=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty,P=Object.prototype.propertyIsEnumerable;var g=(o,t,e)=>t in o?n(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e,c=(o,t)=>{for(var e in t||(t={}))d.call(t,e)&&g(o,e,t[e]);if(m)for(var e of m(t))P.call(t,e)&&g(o,e,t[e]);return o};var h=o=>n(o,"__esModule",{value:!0});var _=(o,t)=>()=>(t||o((t={exports:{}}).exports,t),t.exports),l=(o,t)=>{for(var e in t)n(o,e,{get:t[e],enumerable:!0})},u=(o,t,e,p)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of y(t))!d.call(o,i)&&(e||i!=="default")&&n(o,i,{get:()=>t[i],enumerable:!(p=W(t,i))||p.enumerable});return o},b=(o,t)=>u(h(n(o!=null?O(L(o)):{},"default",!t&&o&&o.__esModule?{get:()=>o.default,enumerable:!0}:{value:o,enumerable:!0})),o),q=(o=>(t,e)=>o&&o.get(t)||(e=u(h({}),t,1),o&&o.set(t,e),e))(typeof WeakMap!="undefined"?new WeakMap:0);var I=_((w,x)=>{x.exports=Magic});var D={};l(D,{default:()=>C});var f=b(I());var s={};l(s,{MagicOpenIdConnectPayloadMethod:()=>a});var a=(t=>(t.LoginWithOIDC="magic_auth_login_with_oidc",t))(a||{});var r=class extends f.Extension.Internal{constructor(){super(...arguments);this.name="openid";this.config={}}loginWithOIDC(t){let e=this.utils.createJsonRpcRequestPayload("magic_auth_login_with_oidc",[t]);return this.request(e)}};Object.assign(r,c({},s));var C=r;return q(D);})();
2
+ if (MagicOpenIdConnectExtension && MagicOpenIdConnectExtension.default != null) { MagicOpenIdConnectExtension = Object.assign(MagicOpenIdConnectExtension.default, MagicOpenIdConnectExtension); delete MagicOpenIdConnectExtension.default; }
@@ -0,0 +1,2 @@
1
+ import { OpenIdExtension } from './index';
2
+ export default OpenIdExtension;
@@ -0,0 +1,12 @@
1
+ import { Extension } from 'magic-sdk';
2
+ import { LoginWithOpenIdParams } from './types';
3
+ export declare class OpenIdExtension extends Extension.Internal<'openid', any> {
4
+ name: "openid";
5
+ config: any;
6
+ loginWithOIDC(params: LoginWithOpenIdParams): import("magic-sdk").PromiEvent<boolean, {
7
+ done: (result: boolean) => void;
8
+ error: (reason: any) => void;
9
+ settled: () => void;
10
+ }>;
11
+ }
12
+ export * from './types';
@@ -0,0 +1,7 @@
1
+ export interface LoginWithOpenIdParams {
2
+ jwt: string;
3
+ providerId: string;
4
+ }
5
+ export declare enum MagicOpenIdConnectPayloadMethod {
6
+ LoginWithOIDC = "magic_auth_login_with_oidc"
7
+ }
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@magic-ext/oidc",
3
+ "version": "1.0.0",
4
+ "description": "Magic OIDC SDK Extension for Web environments.",
5
+ "author": "Magic <team@magic.link> (https://magic.link/)",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/magiclabs/magic-js"
10
+ },
11
+ "files": [
12
+ "dist"
13
+ ],
14
+ "target": "browser",
15
+ "cdnGlobalName": "MagicOpenIdConnectExtension",
16
+ "main": "./dist/cjs/index.js",
17
+ "module": "./dist/es/index.js",
18
+ "types": "./dist/types/index.d.ts",
19
+ "jsdelivr": "./dist/extension.js",
20
+ "exports": {
21
+ "import": "./dist/es/index.mjs",
22
+ "require": "./dist/cjs/index.js"
23
+ },
24
+ "externals": {
25
+ "include": [
26
+ "magic-sdk"
27
+ ]
28
+ },
29
+ "devDependencies": {
30
+ "magic-sdk": "^9.0.0"
31
+ }
32
+ }